merge ts-client to dev (#538)
* expose perp order type on perp order Signed-off-by: microwavedcola1 <microwavedcola@gmail.com> * v0.9.17 * Fix funding rate method Signed-off-by: microwavedcola1 <microwavedcola@gmail.com> * Fix scrript Signed-off-by: microwavedcola1 <microwavedcola@gmail.com> * v0.9.18 --------- Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
parent
e28fe944c0
commit
227aadfc22
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@blockworks-foundation/mango-v4",
|
||||
"version": "0.9.16",
|
||||
"version": "0.9.18",
|
||||
"description": "Typescript Client for mango-v4 program.",
|
||||
"repository": "https://github.com/blockworks-foundation/mango-v4",
|
||||
"author": {
|
||||
|
|
|
@ -710,7 +710,7 @@ async function main() {
|
|||
// console.log(`sig https://explorer.solana.com/tx/${sig}?cluster=devnet`);
|
||||
|
||||
await perpMarket?.loadEventQueue(client)!;
|
||||
const fr = perpMarket?.getCurrentFundingRate(
|
||||
const fr = perpMarket?.getInstantaneousFundingRateUi(
|
||||
await perpMarket.loadBids(client),
|
||||
await perpMarket.loadAsks(client),
|
||||
);
|
||||
|
|
|
@ -377,9 +377,9 @@ export class PerpMarket {
|
|||
*
|
||||
* @param bids
|
||||
* @param asks
|
||||
* @returns returns funding rate per hour
|
||||
* @returns returns instantaneous funding rate
|
||||
*/
|
||||
public getCurrentFundingRate(bids: BookSide, asks: BookSide): number {
|
||||
public getInstantaneousFundingRate(bids: BookSide, asks: BookSide): number {
|
||||
const MIN_FUNDING = this.minFunding.toNumber();
|
||||
const MAX_FUNDING = this.maxFunding.toNumber();
|
||||
|
||||
|
@ -401,7 +401,22 @@ export class PerpMarket {
|
|||
} else {
|
||||
funding = 0;
|
||||
}
|
||||
return funding / 24 / Math.pow(10, QUOTE_DECIMALS);
|
||||
|
||||
return funding;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Returns instantaneous funding rate for the day. How is it actually applied - funding is
|
||||
* continously applied on every interaction to a perp position. The rate is further multiplied
|
||||
* by the time elapsed since it was last applied (capped to max. 1hr).
|
||||
*
|
||||
* @param bids
|
||||
* @param asks
|
||||
* @returns returns instantaneous funding rate in % form
|
||||
*/
|
||||
public getInstantaneousFundingRateUi(bids: BookSide, asks: BookSide): number {
|
||||
return this.getInstantaneousFundingRate(bids, asks) * 100;
|
||||
}
|
||||
|
||||
public uiPriceToLots(price: number): BN {
|
||||
|
@ -911,6 +926,7 @@ export class PerpOrder {
|
|||
perpMarket.perpMarketIndex,
|
||||
isExpired,
|
||||
isOraclePegged,
|
||||
leafNode.orderType,
|
||||
oraclePeggedProperties,
|
||||
);
|
||||
}
|
||||
|
@ -931,6 +947,7 @@ export class PerpOrder {
|
|||
public perpMarketIndex: number,
|
||||
public isExpired = false,
|
||||
public isOraclePegged = false,
|
||||
public orderType: PerpOrderType,
|
||||
public oraclePeggedProperties?: OraclePeggedProperties,
|
||||
) {}
|
||||
|
||||
|
|
Loading…
Reference in New Issue