API
YFX is currently deployed on Arbitrum One, you can directly call the smart contract to trade, buy YLP, sell YLP.
Contracts for YFX V3
Arbitrum
InviteManager: 0x0A1c07bd77Ff45743af42b579962C2C36e777f01
Periphery: 0xEae658B32300ff8544bb03d1b8762466a5e99433
Insurance Fund: 0x4177EA126f6B87A9D83Cb3292548086D1a971303
MarketPriceFeed: 0x7e5151fe2ec125b7C732cb3728046D3025D75a0c
Markets:
BTC_USD(USDC): 0xe7F0dac16278388FBB1f4aFa409c512333c28F78
ETH_USD(USDC): 0x7f597c44101Ee16fc48Dc7BD37fCAA21A5bFDA91
ARB_USD(USDC): 0x749140688891A97103c15119D2deeebAe8516d6b
ETH_USD(ETH): 0x0472686084b7d756E992d32EdA2613aeF99cf9dE
ARB_USD(ARB): 0xC0927411896B350c6318673f0dd75b7e422c8551
Add Liquidity(Buy YLP)
To add liquidity to a pool:
Approve the Router contract for the base token and amount you would like to add for liquidity
Call Router.addLiquidity with parameters to add USDC pools or other ERC20 pools
_pool: pool address
_amount: base token amount you would like to spend
isStakeLp: true if automatically to stake LP for earn (to be online)
_deadline: request deadline timestamp
Call Router.addLiquidityETH with parameters to add ETH pools
_pool: pool address
_amount: base token amount you would like to spend, should be less than transaction value
isStakeLp: true if automatically to stake LP for earn (to be online)
_deadline: request deadline timestamp for price protection
Remove Liquidity ( Sell YLP)
To remove liquidity from a pool:
Call Router.removeLiquidity with parameters to remove liquidity from USDC pools or other ERC20 pools:
_pool: pool address
_liquidity: how much liquidity you would like to remove
isUnstake: should unstake staked LP from earn (to be online)
_deadline: request deadline timestamp for price protection
Call Router.removeLiquidityETH to remove liquidity from ETH pools, parameters are the same as above.
Open Position
To open a position:
Approve the Router contract for the margin asset token and amount you would like to spend as the initial margin
Call Router.takerOpen or takerOpenETH with parameters:
Close Position
To Close a position:
Call Router.takerClose with parameters:
Liquidate
Everyone can liquidate other positions that should be liquidated. Liquidation keeper can get 2USDC reward each time.
To run a liquidation keeper, you should:
Trace positions. You can trace positions by our subgraph or listen contract event.
Call Periphery.getPositionStatus to check if the position can be liquidated. Return value with
true
means this position can be liquidated.Call Router.liquidateByCommunity to execute liquidation.
Call Vault.collectExecutedFee to get liquidation bonus.
Get Position Info
To get your position information:
Call Market.getPositionId to get position id
_taker: position owner address
_direction: 1: long, -1: short
Call Market.getPosition with the position id
Last updated