@mstable/protocol
Version:
mStable Contracts
63 lines (61 loc) • 2.73 kB
TypeScript
import { Signer } from "@ethersproject/abstract-signer";
import { ContractTransaction } from "ethers";
import { BN } from "@utils/math";
import { RevenueSplitBuyBack } from "types/generated";
import { EncodedPaths } from "@utils/peripheral/uniswap";
export interface MAssetSwap {
address: string;
bAssetMinSlippage: number;
rewardMinSlippage: number;
mAssetMinBalance: number | BN;
}
export interface MainParams {
revenueSplitBuyBack: RevenueSplitBuyBack;
mAssets: MAssetSwap[];
swapFees: number[];
blockNumber: number | string;
}
export interface BuyBackRewardsParams extends MainParams {
minBassetsAmounts: BN[];
minRewardsAmounts: BN[];
uniswapPaths: EncodedPaths[];
}
/**
* Calculate the minBassetsAmounts, minRewardsAmounts and uniswapPaths to execute on the buyback rewards.
*
* @param {Signer} signer
* @param {MainParams} params
* - mAssets: Addresses of mAssets that are to be sold for rewards. eg mUSD and mBTC.
* - revenueSplitBuyBackAddress: The address of the revenue split buy back contract.;
* @return {Promise<BuyBackRewardsParams>}
* - minBassetsAmounts Minimum amount of bAsset tokens to receive for each redeem of mAssets.
* The amount uses the decimal places of the bAsset.
* Example 1: Redeeming 10,000 mUSD with a min 2% slippage to USDC which has 6 decimal places
* minBassetsAmounts = 10,000 mAssets * slippage 0.98 * USDC decimals 1e6 =
* 1e4 * 0.98 * 1e6 = 1e10 * 0.98 = 98e8
*
* Example 2: Redeeming 1 mBTC with a min 5% slippage to WBTC which has 8 decimal places
* minBassetsAmounts = 1 mAsset * slippage 0.95 * WBTC decimals 1e8 =
* 0.95 * 1e8 = 95e6
*
* - minRewardsAmounts Minimum amount of reward tokens received from the sale of bAssets.
* The amount uses the decimal places of the rewards token.
* Example 1: Swapping 10,000 USDC with a min 1% slippage to MTA which has 18 decimal places
* minRewardsAmounts = 10,000 USDC * slippage 0.99 * MTA decimals 1e18 * MTA/USD rate 1.2
* = 1e4 * 0.99 * 1e18 * 1.2 = 1e22 * 0.99 = 99e20
*
* Example 1: Swapping 1 WBTC with a min 3% slippage to MTA which has 18 decimal places
* minRewardsAmounts = 1 WBTC * slippage 0.97 * MTA decimals 1e18 * MTA/BTC rate 0.00001
* = 1 * 0.97 * 1e18 * 0.00001 = 0.97 * 1e13 = 97e11
*
* - uniswapPaths The Uniswap V3 bytes encoded paths.
*/
export declare const calculateBuyBackRewardsQuote: (signer: Signer, params: MainParams) => Promise<BuyBackRewardsParams>;
/**
* Execute the buyback rewards of different mAssets.
*
* @param {Signer} signer
* @param {MainParams} params
* @return {*} {Promise<ContractTransaction>}
*/
export declare const splitBuyBackRewards: (signer: Signer, params: MainParams) => Promise<ContractTransaction>;