Trial Calculation before deposit

Before actually making a deposit, you'd undoubtedly want to estimate how much premium the investment could yield, the settlement price at maturity, and the additional $DYSN rewards you might receive. In this section, we'll walk through the calculations, focusing on three key aspects:

  1. How to calculate the premium and the strike price used for settlement of a Dual-Investment position.

  2. How to compute the discounted value of a Dual-Investment position before maturity.

  3. How to determine the type of assets (token0 or token1) redeemable after the maturity of a Dual-Investment position.

  4. How to calculate the extra DYSN rewards obtained from a dual-currency transaction.

We'll illustrate these concepts using the WETH-USDC Pair as an example.

WETH-USDC Pair (Polygon zkEVM): 0xEce7244a0e861C841651401fC22cEE577fEE90AF

  • token0 = WETH

  • token1 = USDC

Calculation of Premium & Strike Price

Premium

As the assets stay locked in a pool for a longer duration, investors can expect higher returns. The premium calculation is outlined by the formula below:

For details on the premium calculation mechanism, kindly consult the Dual Investment Premium calculation section in our white paper.

The PremiumCalculator Presented here is a Solidity smart contract that enables you to pre-calculate the principal plus interest based on your input and lock time, providing an overview before making an actual deposit within the pair.

pragma solidity 0.8.17;

interface IPair {
    function getPremium(uint time) external view returns (uint premium);
    function getReserves() external view returns (uint reserve0, uint reserve1);
    function getFeeRatio() external view returns (uint64 _feeRatio0, uint64 _feeRatio1);
}

contract PremiumCalculator {
    uint constant MAX_FEE_RATIO = 2**64;
    uint constant PREMIUM_BASE_UNIT = 1e18;
    address pair = 0xEce7244a0e861C841651401fC22cEE577fEE90AF; // WETH-USDC Pair contract on Polygon zkEVM

    function calculateDeposit0Premium(uint input, uint time) external view returns (uint token0AmtWithPremium, uint token1AmtWithPremium) {
        uint premium = IPair(pair).getPremium(time);
        uint output = virtualSwap0in(input);
        (token0AmtWithPremium, token1AmtWithPremium) = calculatePremium(input, output, premium);
    }

    function calculateDeposit1Premium(uint input, uint time) external view returns (uint token0AmtWithPremium, uint token1AmtWithPremium) {
        uint premium = IPair(pair).getPremium(time);
        uint output = virtualSwap1in(input);
        (token0AmtWithPremium, token1AmtWithPremium) = calculatePremium(output, input, premium);
    }

    function calculatePremium(uint token0Amt, uint token1Amt, uint premium) internal pure returns (uint token0AmtWithPremium, uint token1AmtWithPremium){
        token0AmtWithPremium = token0Amt * (premium + PREMIUM_BASE_UNIT) / PREMIUM_BASE_UNIT;
        token1AmtWithPremium = token1Amt * (premium + PREMIUM_BASE_UNIT) / PREMIUM_BASE_UNIT;
    }

    function virtualSwap0in(uint input) public view returns (uint output) {
        (uint reserve0, uint reserve1) = IPair(pair).getReserves();
        (uint64 _feeRatio0, ) = IPair(pair).getFeeRatio();
        uint fee = uint(_feeRatio0) * input / MAX_FEE_RATIO;
        uint inputLessFee = input - fee;
        output = inputLessFee * reserve1 / (reserve0 + inputLessFee);
    }

    function virtualSwap1in(uint input) public view returns (uint output) {
        (uint reserve0, uint reserve1) = IPair(pair).getReserves();
        (, uint64 _feeRatio1) = IPair(pair).getFeeRatio();
        uint fee = uint(_feeRatio1) * input / MAX_FEE_RATIO;
        uint inputLessFee = input - fee;
        output = inputLessFee * reserve0 / (reserve1 + inputLessFee);
    }
}

To determine the amounts of token and token1 you'll receive after maturity, you can invoke the functions calculateDeposit0Premium and calculateDeposit1Premium. For instance:

The token0AmtWithPremium and token1AmtWithPremium represent the principal plus interest of token0 and token1. The choice of which token you can redeem will be determined by the fair price at maturity.

Strike Price

Continuing from the previous section, you can directly compute the Strike Price using the following formula:

Strike Price= token1AmtWithPremium / token0AmtWithPremium ​

When investors redeem, if the fair price surpasses the strike price, they will receive token1AmtWithPremium of token1. Conversely, if the fair price is lower, they will obtain token0AmtWithPremium of token0. About the details of fair price, please refer to fair price section in our white paper.

The discounted value of your position prior to maturity

First and foremost, it's essential to clarify that the discounted value serves as a reference for estimating the value of your position. The actual redemption of the position can only occur after reaching maturity.

The redeemable fund after maturity will be token0Amt or token1Amt which is calculated in Strike Price, the calculation of the discounted value before the maturity please refer to the below formulas:

Calculation of the discounted value before the maturity

time refers to the remaining time until the position's maturity.

Based on the formula above, we can calculate the discounted value of our position prior maturity. Below is the smart contract which demonstrates the calculation:

To calculate the discounted value of your position, you can call

calculateDeposit0DiscountedValue or calculateDeposit1DiscountedValue .

For example:

The token0DiscountedValue and token1DiscountedValue are the discounted value of token0 and token1.

Determining Token Redemption at Position Maturity

After maturity, the redeemable fund will consist of either token0Amt or token1Amt. The system's decision on which token users can redeem depends on the Strike Price and Fair Price at the maturity date. If, during redemption, the fair price surpasses the strike price, investors will receive token1Amt of token1. Conversely, if the fair price is lower than the strike price, they will receive token0Amt of token0.

Strike Price Formula
Fair Price Formula

Comparing the formula above, we can express it as follows:

Compare the size to decide which token can be redeemed

Upon maturity, we can utilize the above formula, incorporating the current state of pools, to determine which token can be redeemed. In Solidity code, this can be implemented as follows:

Upon maturity, you can invoke the decide function to ascertain which token is eligible for redemption. This determination relies on the prevailing pool conditions, including reserves and fee ratios.

How to Calculate Additional DYSN Rewards in a Dual Investment

Investing in Dual Investment on Dyson Finance allows Dyson members to instantly receive Points, which can later be converted to $DYSN. Below is the flow of conversion process.

About membership, please refer to Membership section in our white paper.

Convert flow:

  • Dual Investment -> localPoint

  • localPoint -> Point

  • Point -> $DYSN

The DysonRewardCalculator contract showcases the calculation for converting a local point generated through dual investment into $DYSN rewards.

To determine the $DYSN reward generated from a dual investment, you can make use of the PremiumCalculator and DysonRewardCalculator contracts. These contracts facilitate the calculation of rewards based on the lock time and input amount in the dual investment.

The dysonReward is the $DYSN reward of your dual investment position.

Last updated