Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guaranteed Minimum APR Program #327

Open
wants to merge 7 commits into
base: development
Choose a base branch
from
Open

Conversation

Drypto13
Copy link
Contributor

@Drypto13 Drypto13 commented Apr 1, 2023

No description provided.

IToken iToken = IToken(PROTOCOL.underlyingToLoanPool(base));
claimID = keccak256(abi.encode(address(iToken),msg.sender,endTimestamp));
require(claims[claimID].token == address(0), "already used id");
require(block.timestamp <= endTimestamp && endTimestamp-block.timestamp<tokenSettings.maxLockTime, "invalid ending time");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

endTimestamp-block.timestamp<tokenSettings.maxLockTime is sufficient enough to check. it will fail anyway if block.timestamp <= endTimestamp is false

claimID = keccak256(abi.encode(address(iToken),msg.sender,endTimestamp));
require(claims[claimID].token == address(0), "already used id");
require(block.timestamp <= endTimestamp && endTimestamp-block.timestamp<tokenSettings.maxLockTime, "invalid ending time");
IERC20(base).safeTransferFrom(msg.sender, address(this), depositAmount);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at this point base can be any contract maliciously provided externally, I don't see how this can be reused later but probably we should sanitize it.

TREASURY = t;
}

function lock(address base, uint256 depositAmount, uint256 endTimestamp) external returns (bytes32 claimID) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What of instead of sending endstamp we send days from now

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What of instead of sending endstamp we send days from now

why that would be better?

Settings memory tokenSettings = lockSettings[base];
IToken iToken = IToken(PROTOCOL.underlyingToLoanPool(base));
claimID = keccak256(abi.encode(address(iToken),msg.sender,endTimestamp));
require(claims[claimID].token == address(0), "already used id");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice to check if base != address(0)

IToken iToken = IToken(PROTOCOL.underlyingToLoanPool(base));
claimID = keccak256(abi.encode(address(iToken),msg.sender,endTimestamp));
require(claims[claimID].token == address(0), "already used id");
require(block.timestamp <= endTimestamp && endTimestamp-block.timestamp<tokenSettings.maxLockTime, "invalid ending time");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why block.timestamp <= endTimestamp it might be <

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the timestamps are the same no issues arise so it is fine to leave within the check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants