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
Boba: 0x40e21b8837dF1858A5e9f75B3d859A404d0E6361
Kovan: 0xC2caEb68a7D00a33131816113ddaeC51501F90a1
Mumbai: 0x3320073DAd6a20Ee090B80B9AF1ec58d4EB37cdC
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:
Name | Type | Description |
---|---|---|
usdcForArb | uint | Portion of supplied USDC to use for arbitrage. Will be deposited along with profits. |
tokensToBuyForArb | uint | If buying+redeeming to arb pools, amount of tokens. See arbitrage() . |
router | IUniswapV2Router02 | Address of Uniswap, Quickswap, etc. router. |
priceDeviation_ | FixedPoint.Unsigned calldata | Fraction: maximum % difference between long+short and collateralPerPair |
lsp | LongShortPair | LongShortPair for the target dominance pair. |
usdcSignature | Signature calldata | Optional. EIP-712 (v,r,s) signature for USDC. |
amount | uint | How much USDC to supply. |
longStaking | Staking | Optional. Staking contract for long LP token. |
shortStaking | Staking | Optional. Staking contract for short LP token. |
deadline | uint | Timestamp 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:
Name | Type | Description |
---|---|---|
priceDeviation_ | FixedPoint.Unsigned calldata | maximum % difference between long+short and collateralPerPair |
lsp | LongShortPair | LongShortPair for the target dominance pair. |
longLPAmount | uint | Long LP tokens to redeem. |
shortLPAmount | uint | Short LP tokens to redeem. |
router | IUniswapV2Router02 | Address of Uniswap, Quickswap, etc. router. |
deadline | uint | Timestamp beyond which tx will revert. |
longSignature | Signature calldata | Optional: EIP-712 (v,r,s) signature. |
shortSignature | Signature calldata | Optional: EIP-712 (v,r,s) signature. |
withdrawMode | WithdrawMode | Action 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:
Name | Type | Description |
---|---|---|
amount | uint | USDC to use for arbitrage. |
tokensToBuy | uint | Number of tokens to buy and redeem. If 0, mint and sell with supplied USDC. |
lsp | LongShortPair | LongShortPair for the target dominance pair |
router | IUniswapV2Router02 | Address of Uniswap, Quickswap, etc. router. |
deadline | uint | Timestamp beyond which tx will revert. |
usdcSignature | Signature calldata | Optional: 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:
Name | Type | Description |
---|---|---|
factory | IUniswapV2Factory | Address of Uniswap, Quickswap, etc. router. |
lsp | LongShortPair | LongShortPair for the target dominance pair |
longStaking | Staking | Optional. Staking contract for long LP token. |
shortStaking | Staking | Optional. Staking contract for short LP token. |
user | address | Address 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
- UMA: LSP interaction
- Uniswap: Router02
- UMA: FixedPoint