🟒mint_with_mercurial_vault_depository

Permissionless - Callable for collateral amount input larger than 0 and below global cap and depository cap when minting is enabled

Flow

  • Checks

    • Anchor IDL accounts checks

    • Validates: non-zero collateral_amount

    • Validates: mint_disabled is false for the depository

  • Handler

    • Calculates the possible precision loss on transferred LP token amounts

    • Deposits collateral_amount from user collateral's ATA to mercurial token vault in return for the LP tokens through CPI: mercurial_vault::cpi::deposit

    • Calculates the LP token minted by comparing the balance change of depository_lp_token_vault

    • Checks if the LP token minted is not below the collateral_amount considering the possible precision loss, abort with slippage error otherwise

    • Calculates the total mint fee based on the amount of the LP token minted

    • Checks if the redeemable amount (same as the LP token minted) after deducting the mint fee is positive

    • Mint the redeemable amount (less fee) of redeemable_mint to the user

    • Updates the accounting in both depository and controller

Parameters

collateral_amount the amount of collateral to be processed through minting

Accounts in

Last updated

Was this helpful?