Function: _executeDiscountAndLock(uint256 assets, uint256 assetsDeposited, uint256 shares, uint32 lockDuration, address receiver)
Internal function called by both depositWithDiscountAndLock and mintWithDiscountAndLock to share logic.
Inputs
assetsControl: Amount of assets equal in value to the
sharesto mint.Constraints: Must be less than
assetsDeposited.Impact: Used to calculate
assetsDiscount.
assetsDepositedControl: Must be calculated from
lockDurationand the intended discount.Constraints: None.
Impact: Amount of assets to actually transfer.
sharesControl: Must correspond to
assetsusing current share price.Constraints: None.
Impact: Amount of shares to mint.
lockDurationControl: Arbitrary.
Constraints: Must cause nonzero discount.
Impact: Duration before NFT can be redeemed.
receiverControl: Arbitrary.
Constraints: None.
Impact: Receiver of the NFT.
Function call analysis
The call to
OstiumLockedDepositNft.mintcan cause reentrancy due to the use of_safeMint, sincereceivercould be a user-controlled contract that implementsIERC721Receiver.onERC721Received. However, except for theDepositLockedevent, there is no logic after this call in either this function or its parent, which means the only possible negative effect is that off-chain actors watching the event may be confused about DepositLocked occurring after Transfer or whatnot.