SDK FAQ

How can I stream account/position updates?

How can i calculate funding rate in the contract? What about %? What about % APR?

to convert FundingRateRecord . fundingRate to APR %

funding rate is in 10e14, the unit is quote amount (USDC) owned for each single base asset amount to convert to APR % you need to divide by the oracle_twap (1e10) and then multiply 365.25*24

example: so if BTC funding = 6.2 thats 6.2 usdc per BTC 6.2/44000 365.25 24 = % APR

is there a way to debug what the custom program errors mean? (i'm getting custom program error: 0x1774 when trying to liquidate)

convert 0x1774 to decimal (= 6004)

check idl (clearing_house.json) in repo: https://github.com/drift-labs/protocol-v1/blob/master/sdk/src/idl/clearing_house.json { "code": 6004, "name": "SufficientCollateral", "msg": "Sufficient collateral" }

so the user has sufficient collateral to not be liquidated. its most likely that another liquidator already (partially/fully) liquidated them

ο»Ώ