Rebase funding rate
Funding rate in CEX is determined by the positive or negative spread between the mark price and the index price and is charged from the counterparty. The amount of funding rate charged per user is based on the size of positions held by the user.
Qilin V2 has fully adapted the funding rate design for the on-chain environment. On Qilin V2, the funding rate is charged from the direction of the unmatched positions and is triggered by any action (trading, LP, liquidation, margin adding, etc.). The amount of funding rate is determined by the size of the unmatched position. Funding rate payments are sent to the LP. The amount of the funding rate charged from each user is based on the number of positions and the size of the positions held by the user. The collection interval for is one block, and a rebase mechanism is used for collection.
Mathematical expressions:
ΣL: size of the sum of all the long positions
ΣS: size of the sum of all the short positions
P: current price
LP: sum of the total asset value in the liquidity pool
RT: long-short threshold (system parameter)
RC: rebase constant (system parameter)
ΔBlock: block height difference from the previous rebase
ΣRL: accumulative of long rebase
ΣRS: accumulative of short rebase

Funding fee:

Any action on Qilin (liquidity provision/removal, position opening/closing, adding liquidity, liquidation, etc) triggers the condition check for rebase:
When the condition is satisfied, the rebase accumulative is calculated:
And the rebase accumulative is updated respectively for long and short:
Then the funding fee is calculated using the rebase accumulative before the trigger and the latest accumulative:

Funding rate:

When L > S,
When S > L,
Copy link