Place Long Term Order
Details on how to place long term order
How to place long term order?
Using API
Long term order can be placed by calling JoinPool on the balancer vault. Here is how JoinPool looks like:
You can find complete details here. All the details remains same as JoinPool, only changes are in the way userData in JoinPoolRequest is constructed.
API request param details
Here is a sample way to create userData
in javascript.
The first parameter in the request data is always 4
, which corresponds to the place long term order(PLACE_LONG_TERM_ORDER) JoinKind. Other request parameter details are as follows:
tokenInIndex
: This is the index of the pool token user wants to sell. Check this Vault API to get list of tokens and corresponding token index to use.tokenOutIndex
: This is the index of the pool token user wants to buy. Check this Vault API to get list of tokens and corresponding token index to use.amountIn
: This is the token amount of tokenInIndex to be sold.numberOfBlockIntervals
: This the number of block intervals for which the order will be active in the AMM. See here for details on how this will impact the order time.
LongTermOrderPlaced
LongTermOrderPlaced
LongTermOrderPlaced
event is emitted when the order is placed successfully.
Details available in the events:
orderId
: Represents the id of the order in the contract, this can be used to withdraw, cancel or to get the long term order details.buyTokenIndex
: This is the index of the pool token user wants to buy. Check this Vault API to get list of tokens and corresponding token index to use.sellTokenIndex
: This is the index of the pool token placed for sell. Check this Vault API to get list of tokens and corresponding token index to use.saleRate
: This represents the sale rate per block of the sell token.owner
: The details of the user placing the order.expirationBlock
: The block at which the order will expire.
Order life time
Details on how the order life is calculated
Place transaction using UI
Go to app.longswap.xyz.
Go to Long Term Swap tab.
Choose pair, amounts, duration.
(One time) approve Balancer vault to spend your tokens.
Place a Long term order.
Once the order is placed, it should show up in the orders list in the same tab.
Last updated