Function create(ERC20 underlying_, uint48 expiry_, uint256 amount_)
NO UNIT-TEST or at least not direct test
Intended behavior.
This function allows any user to get the
amountvalue of theBondtokens in exchange forunderlying_ERC1155 tokens.
Negative behavior.
Shouldn’t
mintamountof tokens if a smaller quantity ofunderlying_tokens was deposited.Shouldn’t
mintthetokenIdtokens iftokenMetadata[tokenId]doesn't exist because otherwise, it would be possible to deposit dummy tokens and then create metadata with a real token and withdraw it. Also, it means that no one should be able to edit already created items oftokenMetadata[tokenId].Should be rejected if the caller doesn't have enough
underlying_tokens.Should be rejected if the caller doesn't get the expected value of
Bondtokens. there is no such check here, but since the fee percentage is unlimited and can be changed at any time, the caller may not agree with the withdrawn fee value. we could add a slippage check here, just as in the other BondFixedExpiryTeller.Shouldn’t emit expired
bondTokenssince that means that they’ve vested already.
Preconditions.
tokenMetadata[tokenId]should be already created for currentunderlying_andexpiry_values.the caller should have enough
underlying_tokens to pay for a deposit.the correct
tokenIdshould be minted (calculated based on the pair between thepayoutToken, expiry.should make sure that
expiryis not in the past? as in, the bondToken pair had already vested?
Postconditions.
underlying_.balanceOf(BondFixedTermTeller) >=oldBalance+amountBondFixedTermTeller.balanceOf(msg.sender) ≤ balanceBefore+payout
Inputs.
ERC20 underlying_ : controlled (!), it can be any address of ERC20 token, there is should exist
tokenMetadatafor this token address andexpiryvalue, but it is possible to do overdeployfunction.uint48 expiry : controlled (!)
uint256 amount_ : controlled (!)
Examine all function calls the function makes.
a. Call to
uint256 tokenId = getTokenId(underlying_, expiry_);What is controllable? (callee, params, return value):
underlying_, expiry_are controllableIf return value controllable, how is it used and how can it go wrong?
tokenIdshould be unique for correspondingunderlying_, expiry_valuesWhat happens if it reverts or tries to reenter? No problem
b. Call to
_mintToken(msg.sender, tokenId, amount_)see_handlePayout._mintTokendescription