Skip to main content

Vault

The Vault allows a user to create() synthetic tokens and add them to a liquidity pool, or to withdraw pooled tokens and redeem for USDC with redeem() or settle(). It executes Liquidity>Deposit and Liquidity>Withdraw actions in the Domination Finance dapp.

Deployed Instances

Ethereum: 0xD3a0e00f11A91DA9797eEf5B74dF8fc325FC50e0
Polygon: 0x514b3C2761Edc2487F320392EDF094d65E20C9Ee
Kovan: 0x506761cb582Cb3dEE79c7720F8C5d6caC0EcE710
Mumbai: 0xf6C756b39620b62b6c3676969F9f40621e3cB718

Functions

deposit

function deposit(
uint usdcForArb,
uint tokensToBuyForArb,
IUniswapV2Router02 router,
FixedPoint.Unsigned calldata priceDeviation_,
LongShortPair lsp,
Signature calldata usdcSignature,
uint amount,
Staking longStaking,
Staking shortStaking,
uint deadline
) public

Deposit USDC into the vault. Convert it all into LSP liquidity.

Parameters:

NameTypeDescription
usdcForArbuintPortion of supplied USDC to use for arbitrage. Will be deposited along with profits.
tokensToBuyForArbuintIf buying+redeeming to arb pools, amount of tokens. See arbitrage().
routerIUniswapV2Router02Address of Uniswap, Quickswap, etc. router.
priceDeviation_FixedPoint.Unsigned calldataFraction: maximum % difference between long+short and collateralPerPair
lspLongShortPairLongShortPair for the target dominance pair.
usdcSignatureSignature calldataOptional. EIP-712 (v,r,s) signature for USDC.
amountuintHow much USDC to supply.
longStakingStakingOptional. Staking contract for long LP token.
shortStakingStakingOptional. Staking contract for short LP token.
deadlineuintTimestamp beyond which tx will revert.

withdraw

Redeem both long and short LP tokens and optionally exchange for USDC.

function withdraw(
FixedPoint.Unsigned calldata priceDeviation_,
LongShortPair lsp,
uint longLPAmount,
uint shortLPAmount,
IUniswapV2Router02 router,
uint deadline,
Signature calldata longSignature,
Signature calldata shortSignature,
WithdrawMode withdrawMode,
) public

Parameters:

NameTypeDescription
priceDeviation_FixedPoint.Unsigned calldatamaximum % difference between long+short and collateralPerPair
lspLongShortPairLongShortPair for the target dominance pair.
longLPAmountuintLong LP tokens to redeem.
shortLPAmountuintShort LP tokens to redeem.
routerIUniswapV2Router02Address of Uniswap, Quickswap, etc. router.
deadlineuintTimestamp beyond which tx will revert.
longSignatureSignature calldataOptional: EIP-712 (v,r,s) signature.
shortSignatureSignature calldataOptional: EIP-712 (v,r,s) signature.
withdrawModeWithdrawModeAction to take with redeemed synths. See WithdrawMode.

arbitrage

Arbitrage a pair's pools. Use supplied USDC to mint tokens and then sell them, or buy tokens and then redeem them 1:1. Return USDC + profits to sender. See Tutorial/Arbitrage.

Caller must specify the arbitrage amount; Domination Finance calculates this off-chain. This function will revert if the arbitrage was not profitable.

function arbitrage(
uint amount,
uint tokensToBuy,
LongShortPair lsp,
IUniswapV2Router02 router,
uint deadline,
Signature calldata usdcSignature,
) external

Parameters:

NameTypeDescription
amountuintUSDC to use for arbitrage.
tokensToBuyuintNumber of tokens to buy and redeem. If 0, mint and sell with supplied USDC.
lspLongShortPairLongShortPair for the target dominance pair
routerIUniswapV2Router02Address of Uniswap, Quickswap, etc. router.
deadlineuintTimestamp beyond which tx will revert.
usdcSignatureSignature calldataOptional: EIP-712 (v,r,s) signature.

depositedFor

Check the market value of a user's LSP liquidity, in USDC.

function depositedFor(
IUniswapV2Factory factory,
LongShortPair lsp,
Staking longStaking,
Staking shortStaking,
address user
) public view returns (uint)

Parameters:

NameTypeDescription
factoryIUniswapV2FactoryAddress of Uniswap, Quickswap, etc. router.
lspLongShortPairLongShortPair for the target dominance pair
longStakingStakingOptional. Staking contract for long LP token.
shortStakingStakingOptional. Staking contract for short LP token.
useraddressAddress of user

Structs

Signature

An EIP-712 signature for use with LP token or USDC permits.

struct Signature {
uint8 v;
bytes32 r;
bytes32 s;
}

WithdrawMode

What a withdraw() should do with the withdrawn tokens.

enum WithdrawMode { Basic, Redeem, Settle }
  • Basic: Return all tokens to the caller
  • Redeem: redeem() as many synthetic tokens as possible. Return resulting USDC and any excess tokens. redeem() exchanges an equal number of long and short tokens for the USDC collateral used to mint them.
  • Settle: settle() to exchange it all for USDC at the index price. Only available after LSP expiration.

FixedPoint.Unsigned

An unsigned fixed-point number used to represent price deviation.

struct Unsigned {
uint256 rawValue;
}

The value of the number is given by rawValue times 1e18. For instance, a price deviation of 5% (0.05) is represented by 50000000000000000. For more on price deviation, see Tutorial/Price Deviation.

Audit

Our Vault has been audited by Zokyo, a venture studio that builds, secures, and funds crypto, DeFi, and NFT companies.

See Also