Smart Contract Interaction

Mint YToken using Primary Asset

  1. Since our vault follows ERC 4626 stadard, YToken can be minted instantly using Primary Asset YToken directly by calling deposit function on Vault contract.

    function deposit(uint256 assets, address receiver) public virtual returns (uint256) {
        uint256 maxAssets = maxDeposit(receiver);
        if (assets > maxAssets) {
            revert ERC4626ExceededMaxDeposit(receiver, assets, maxAssets);
        }

        uint256 shares = previewDeposit(assets);
        _deposit(_msgSender(), receiver, assets, shares);

        return shares;
    }

Redeem YToken to Primary Asset

  1. Redeeming YTokens for the primary asset token, can be done by calling redeem function on the Vault contract.

  2. The Vault contract then places a redeem request on the Manager contract on behalf of the user.

  3. Redeem requests are processed in a queue by the Keeper bot after a cooldown period.

Mint YToken using non-Primary Asset via Manager

  1. Users who want to mint YTokens using non-primary assets can do so by calling the deposit function on the Manager contract (along with passing _referralCode if they have any).

  2. Upon deposit, the user receives a receipt NFT as confirmation of the order placement.

  3. This request is then picked up by the Keeper bot, which sends a transaction on-chain to burn the receipt NFT and mint YTokens to the user's address.

Redeem YToken using non-Primary Asset via Manager

  1. Users can also place a redeem request for YUSD through the Manager contract.

  2. These requests are maintained in a queue until the cooldown period is complete.

  3. Once the cooldown period ends, the Keeper bot processes the redeem request and transfers the underlying asset to the user.

Last updated