Skip to main content

Withdraw Long Term Orders Proceeds

The Withdraw Long Term Orders Proceeds action means traders withdraw proceeds from the long-term swap orders. Notice that the proceeds tokens still lie in the pool contract, recorded by OrderPool rewardFactor and can then be withdrawn by the trader with an extra withdraw action.

Suppose a trader submit a long-term order swap X for Y. At any time, usually after order has expired, if the order has expired, we calculate the reward factor at time of expiry. If order has not yet expired, we use current reward factor, and update the reward factor at time of Order Execution (effectively submit a new long-term order).

//If order has expired, we need to calculate the reward factor at expiry
totalProceeds = (rewardFactorAtExpiry - rewardFactorAtSubmission) * orderSellRate
//If order has not yet expired, we just adjust the start
totalProceeds = (rewardFactor - rewardFactorAtSubmission) * orderSellRate