@drift-labs/sdk 2.129.0-beta.6 → 2.129.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/VERSION +1 -1
- package/lib/browser/adminClient.d.ts +2 -2
- package/lib/browser/adminClient.js +7 -9
- package/lib/browser/dlob/orderBookLevels.d.ts +2 -2
- package/lib/browser/dlob/orderBookLevels.js +4 -16
- package/lib/browser/driftClient.d.ts +1 -6
- package/lib/browser/driftClient.js +0 -84
- package/lib/browser/idl/drift.json +18 -29
- package/lib/browser/index.d.ts +0 -1
- package/lib/browser/index.js +0 -1
- package/lib/browser/math/amm.d.ts +9 -9
- package/lib/browser/math/amm.js +23 -26
- package/lib/browser/math/funding.d.ts +5 -5
- package/lib/browser/math/funding.js +11 -20
- package/lib/browser/math/market.d.ts +6 -6
- package/lib/browser/math/market.js +11 -12
- package/lib/browser/math/oracles.d.ts +3 -3
- package/lib/browser/math/oracles.js +8 -8
- package/lib/browser/math/orders.d.ts +4 -4
- package/lib/browser/math/orders.js +8 -8
- package/lib/browser/math/position.d.ts +2 -2
- package/lib/browser/math/position.js +3 -3
- package/lib/browser/math/trade.d.ts +5 -5
- package/lib/browser/math/trade.js +19 -19
- package/lib/browser/oracles/types.d.ts +0 -5
- package/lib/browser/tx/utils.d.ts +0 -2
- package/lib/browser/tx/utils.js +1 -9
- package/lib/browser/types.d.ts +4 -3
- package/lib/browser/user.d.ts +0 -1
- package/lib/browser/user.js +6 -9
- package/lib/node/adminClient.d.ts +2 -2
- package/lib/node/adminClient.d.ts.map +1 -1
- package/lib/node/adminClient.js +7 -9
- package/lib/node/dlob/orderBookLevels.d.ts +2 -2
- package/lib/node/dlob/orderBookLevels.d.ts.map +1 -1
- package/lib/node/dlob/orderBookLevels.js +4 -16
- package/lib/node/driftClient.d.ts +1 -6
- package/lib/node/driftClient.d.ts.map +1 -1
- package/lib/node/driftClient.js +0 -84
- package/lib/node/idl/drift.json +18 -29
- package/lib/node/index.d.ts +0 -1
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +0 -1
- package/lib/node/math/amm.d.ts +9 -9
- package/lib/node/math/amm.d.ts.map +1 -1
- package/lib/node/math/amm.js +23 -26
- package/lib/node/math/funding.d.ts +5 -5
- package/lib/node/math/funding.d.ts.map +1 -1
- package/lib/node/math/funding.js +11 -20
- package/lib/node/math/market.d.ts +6 -6
- package/lib/node/math/market.d.ts.map +1 -1
- package/lib/node/math/market.js +11 -12
- package/lib/node/math/oracles.d.ts +3 -3
- package/lib/node/math/oracles.d.ts.map +1 -1
- package/lib/node/math/oracles.js +8 -8
- package/lib/node/math/orders.d.ts +4 -4
- package/lib/node/math/orders.d.ts.map +1 -1
- package/lib/node/math/orders.js +8 -8
- package/lib/node/math/position.d.ts +2 -2
- package/lib/node/math/position.d.ts.map +1 -1
- package/lib/node/math/position.js +3 -3
- package/lib/node/math/trade.d.ts +5 -5
- package/lib/node/math/trade.d.ts.map +1 -1
- package/lib/node/math/trade.js +19 -19
- package/lib/node/oracles/types.d.ts +0 -5
- package/lib/node/oracles/types.d.ts.map +1 -1
- package/lib/node/tx/utils.d.ts +0 -2
- package/lib/node/tx/utils.d.ts.map +1 -1
- package/lib/node/tx/utils.js +1 -9
- package/lib/node/types.d.ts +4 -3
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/user.d.ts +0 -1
- package/lib/node/user.d.ts.map +1 -1
- package/lib/node/user.js +6 -9
- package/package.json +1 -1
- package/src/adminClient.ts +15 -18
- package/src/dlob/orderBookLevels.ts +5 -18
- package/src/driftClient.ts +2 -121
- package/src/idl/drift.json +19 -30
- package/src/index.ts +0 -1
- package/src/math/amm.ts +25 -30
- package/src/math/funding.ts +12 -26
- package/src/math/market.ts +15 -16
- package/src/math/oracles.ts +13 -9
- package/src/math/orders.ts +9 -13
- package/src/math/position.ts +4 -4
- package/src/math/trade.ts +20 -46
- package/src/oracles/types.ts +0 -6
- package/src/tx/utils.ts +0 -10
- package/src/types.ts +4 -3
- package/src/user.ts +7 -11
- package/lib/browser/oracles/utils.d.ts +0 -6
- package/lib/browser/oracles/utils.js +0 -48
- package/lib/node/oracles/utils.d.ts +0 -7
- package/lib/node/oracles/utils.d.ts.map +0 -1
- package/lib/node/oracles/utils.js +0 -48
- package/src/oracles/utils.ts +0 -60
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.129.0-beta.
|
|
1
|
+
2.129.0-beta.7
|
|
@@ -230,6 +230,6 @@ export declare class AdminClient extends DriftClient {
|
|
|
230
230
|
getUpdateProtectedMakerModeConfigIx(maxUsers: number, reduceOnly: boolean, currentUsers: undefined): Promise<TransactionInstruction>;
|
|
231
231
|
adminDeposit(marketIndex: number, amount: BN, depositUserAccount: PublicKey, adminTokenAccount?: PublicKey): Promise<TransactionSignature>;
|
|
232
232
|
getAdminDepositIx(marketIndex: number, amount: BN, depositUserAccount: PublicKey, adminTokenAccount?: PublicKey): Promise<TransactionInstruction>;
|
|
233
|
-
|
|
234
|
-
|
|
233
|
+
zeroAmmFieldsPrepMmOracleInfo(marketIndex: number): Promise<TransactionSignature>;
|
|
234
|
+
getZeroAmmFieldsPrepMmOracleInfoIx(marketIndex: number): Promise<TransactionInstruction>;
|
|
235
235
|
}
|
|
@@ -2103,19 +2103,17 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
2103
2103
|
},
|
|
2104
2104
|
});
|
|
2105
2105
|
}
|
|
2106
|
-
async
|
|
2107
|
-
const
|
|
2108
|
-
const tx = await this.buildTransaction(
|
|
2106
|
+
async zeroAmmFieldsPrepMmOracleInfo(marketIndex) {
|
|
2107
|
+
const zeroAmmFieldsPrepMmOracleInfoIx = await this.getZeroAmmFieldsPrepMmOracleInfoIx(marketIndex);
|
|
2108
|
+
const tx = await this.buildTransaction(zeroAmmFieldsPrepMmOracleInfoIx);
|
|
2109
2109
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2110
2110
|
return txSig;
|
|
2111
2111
|
}
|
|
2112
|
-
async
|
|
2113
|
-
return await this.program.instruction.
|
|
2112
|
+
async getZeroAmmFieldsPrepMmOracleInfoIx(marketIndex) {
|
|
2113
|
+
return await this.program.instruction.zeroAmmFieldsPrepMmOracleInfo({
|
|
2114
2114
|
accounts: {
|
|
2115
|
-
admin: this.
|
|
2116
|
-
|
|
2117
|
-
: this.wallet.publicKey,
|
|
2118
|
-
state: await this.getStatePublicKey(),
|
|
2115
|
+
admin: this.wallet.publicKey,
|
|
2116
|
+
perpMarket: this.getPerpMarketAccount(marketIndex).pubkey,
|
|
2119
2117
|
},
|
|
2120
2118
|
});
|
|
2121
2119
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="bn.js" />
|
|
2
|
-
import { BN, DLOBNode, OraclePriceData, PerpMarketAccount
|
|
2
|
+
import { BN, DLOBNode, OraclePriceData, PerpMarketAccount } from '..';
|
|
3
3
|
import { PublicKey } from '@solana/web3.js';
|
|
4
4
|
type liquiditySource = 'serum' | 'vamm' | 'dlob' | 'phoenix' | 'openbook' | 'indicative';
|
|
5
5
|
export type L2Level = {
|
|
@@ -36,7 +36,7 @@ export declare function mergeL2LevelGenerators(l2LevelGenerators: Generator<L2Le
|
|
|
36
36
|
export declare function createL2Levels(generator: Generator<L2Level>, depth: number): L2Level[];
|
|
37
37
|
export declare function getVammL2Generator({ marketAccount, oraclePriceData, numOrders, now, topOfBookQuoteAmounts, }: {
|
|
38
38
|
marketAccount: PerpMarketAccount;
|
|
39
|
-
oraclePriceData: OraclePriceData
|
|
39
|
+
oraclePriceData: OraclePriceData;
|
|
40
40
|
numOrders: number;
|
|
41
41
|
now?: BN;
|
|
42
42
|
topOfBookQuoteAmounts?: BN[];
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.uncrossL2 = exports.groupL2 = exports.getVammL2Generator = exports.createL2Levels = exports.mergeL2LevelGenerators = exports.getL2GeneratorFromDLOBNodes = exports.MAJORS_TOP_OF_BOOK_QUOTE_AMOUNTS = exports.DEFAULT_TOP_OF_BOOK_QUOTE_AMOUNTS = void 0;
|
|
4
4
|
const __1 = require("..");
|
|
5
|
-
const utils_1 = require("../oracles/utils");
|
|
6
5
|
exports.DEFAULT_TOP_OF_BOOK_QUOTE_AMOUNTS = [
|
|
7
6
|
new __1.BN(500).mul(__1.QUOTE_PRECISION),
|
|
8
7
|
new __1.BN(1000).mul(__1.QUOTE_PRECISION),
|
|
@@ -95,18 +94,7 @@ function createL2Levels(generator, depth) {
|
|
|
95
94
|
}
|
|
96
95
|
exports.createL2Levels = createL2Levels;
|
|
97
96
|
function getVammL2Generator({ marketAccount, oraclePriceData, numOrders, now = new __1.BN(Math.floor(Date.now() / 1000)), topOfBookQuoteAmounts = [], }) {
|
|
98
|
-
|
|
99
|
-
if ('mmOraclePrice' in mmOraclePriceData) {
|
|
100
|
-
mmOraclePriceData = oraclePriceData;
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
mmOraclePriceData = {
|
|
104
|
-
mmOraclePrice: marketAccount.amm.mmOraclePrice,
|
|
105
|
-
mmOracleSlot: marketAccount.amm.mmOracleSlot,
|
|
106
|
-
oraclePriceData: oraclePriceData,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
const updatedAmm = (0, __1.calculateUpdatedAMM)(marketAccount.amm, mmOraclePriceData);
|
|
97
|
+
const updatedAmm = (0, __1.calculateUpdatedAMM)(marketAccount.amm, oraclePriceData);
|
|
110
98
|
const paused = (0, __1.isOperationPaused)(marketAccount.pausedOperations, __1.PerpOperation.AMM_FILL);
|
|
111
99
|
let [openBids, openAsks] = paused
|
|
112
100
|
? [__1.ZERO, __1.ZERO]
|
|
@@ -115,12 +103,12 @@ function getVammL2Generator({ marketAccount, oraclePriceData, numOrders, now = n
|
|
|
115
103
|
openBids = __1.ZERO;
|
|
116
104
|
if (openAsks.abs().lt(marketAccount.amm.minOrderSize.muln(2)))
|
|
117
105
|
openAsks = __1.ZERO;
|
|
118
|
-
const [bidReserves, askReserves] = (0, __1.calculateSpreadReserves)(updatedAmm,
|
|
106
|
+
const [bidReserves, askReserves] = (0, __1.calculateSpreadReserves)(updatedAmm, oraclePriceData, now, (0, __1.isVariant)(marketAccount.contractType, 'prediction'));
|
|
119
107
|
const numBaseOrders = Math.max(1, numOrders - topOfBookQuoteAmounts.length);
|
|
120
108
|
const commonOpts = {
|
|
121
109
|
numOrders,
|
|
122
110
|
numBaseOrders,
|
|
123
|
-
|
|
111
|
+
oraclePriceData,
|
|
124
112
|
orderTickSize: marketAccount.amm.orderTickSize,
|
|
125
113
|
orderStepSize: marketAccount.amm.orderStepSize,
|
|
126
114
|
pegMultiplier: updatedAmm.pegMultiplier,
|
|
@@ -143,7 +131,7 @@ function getVammL2Generator({ marketAccount, oraclePriceData, numOrders, now = n
|
|
|
143
131
|
const raw = commonOpts.topOfBookQuoteAmounts[count]
|
|
144
132
|
.mul(__1.AMM_TO_QUOTE_PRECISION_RATIO)
|
|
145
133
|
.mul(__1.PRICE_PRECISION)
|
|
146
|
-
.div(
|
|
134
|
+
.div(commonOpts.oraclePriceData.price);
|
|
147
135
|
baseSwap = (0, __1.standardizeBaseAssetAmount)(raw, commonOpts.orderStepSize);
|
|
148
136
|
const remaining = openLiquidity.abs().sub(topSize);
|
|
149
137
|
if (remaining.lt(baseSwap))
|
|
@@ -12,7 +12,7 @@ import { EventEmitter } from 'events';
|
|
|
12
12
|
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
13
13
|
import { DataAndSlot, DriftClientAccountEvents, DriftClientAccountSubscriber } from './accounts/types';
|
|
14
14
|
import { TxSender, TxSigAndSlot } from './tx/types';
|
|
15
|
-
import {
|
|
15
|
+
import { OraclePriceData } from './oracles/types';
|
|
16
16
|
import { DriftClientConfig } from './driftClientConfig';
|
|
17
17
|
import { User } from './user';
|
|
18
18
|
import { UserSubscriptionConfig } from './userConfig';
|
|
@@ -826,7 +826,6 @@ export declare class DriftClient {
|
|
|
826
826
|
getSettleFundingPaymentIx(userAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
|
|
827
827
|
triggerEvent(eventName: keyof DriftClientAccountEvents, data?: any): void;
|
|
828
828
|
getOracleDataForPerpMarket(marketIndex: number): OraclePriceData;
|
|
829
|
-
getMMOracleDataForPerpMarket(marketIndex: number): MMOraclePriceData;
|
|
830
829
|
getOracleDataForSpotMarket(marketIndex: number): OraclePriceData;
|
|
831
830
|
initializeInsuranceFundStake(marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
832
831
|
getInitializeInsuranceFundStakeIx(marketIndex: number): Promise<TransactionInstruction>;
|
|
@@ -951,10 +950,6 @@ export declare class DriftClient {
|
|
|
951
950
|
getUpdateUserProtectedMakerOrdersIx(subAccountId: number, protectedOrders: boolean, authority?: PublicKey): Promise<TransactionInstruction>;
|
|
952
951
|
getPauseSpotMarketDepositWithdrawIx(spotMarketIndex: number): Promise<TransactionInstruction>;
|
|
953
952
|
pauseSpotMarketDepositWithdraw(spotMarketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
954
|
-
updateMmOracleNative(marketIndex: number, oraclePrice: BN, oracleSequenceId: BN): Promise<TransactionSignature>;
|
|
955
|
-
getUpdateMmOracleNativeIx(marketIndex: number, oraclePrice: BN, oracleSequenceId: BN): Promise<TransactionInstruction>;
|
|
956
|
-
updateAmmSpreadAdjustmentNative(marketIndex: number, ammSpreadAdjustment: number): Promise<TransactionSignature>;
|
|
957
|
-
getUpdateAmmSpreadAdjustmentNativeIx(marketIndex: number, ammSpreadAdjustment: number): TransactionInstruction;
|
|
958
953
|
private handleSignedTransaction;
|
|
959
954
|
private handlePreSignedTransaction;
|
|
960
955
|
private isVersionedTransaction;
|
|
@@ -4418,14 +4418,6 @@ class DriftClient {
|
|
|
4418
4418
|
getOracleDataForPerpMarket(marketIndex) {
|
|
4419
4419
|
return this.accountSubscriber.getOraclePriceDataAndSlotForPerpMarket(marketIndex).data;
|
|
4420
4420
|
}
|
|
4421
|
-
getMMOracleDataForPerpMarket(marketIndex) {
|
|
4422
|
-
const perpMarket = this.getPerpMarketAccount(marketIndex);
|
|
4423
|
-
return {
|
|
4424
|
-
mmOraclePrice: perpMarket.amm.mmOraclePrice,
|
|
4425
|
-
mmOracleSlot: perpMarket.amm.mmOracleSlot,
|
|
4426
|
-
oraclePriceData: this.getOracleDataForPerpMarket(marketIndex),
|
|
4427
|
-
};
|
|
4428
|
-
}
|
|
4429
4421
|
getOracleDataForSpotMarket(marketIndex) {
|
|
4430
4422
|
return this.accountSubscriber.getOraclePriceDataAndSlotForSpotMarket(marketIndex).data;
|
|
4431
4423
|
}
|
|
@@ -5164,82 +5156,6 @@ class DriftClient {
|
|
|
5164
5156
|
const { txSig } = await this.sendTransaction(await this.buildTransaction(await this.getPauseSpotMarketDepositWithdrawIx(spotMarketIndex), txParams), [], this.opts);
|
|
5165
5157
|
return txSig;
|
|
5166
5158
|
}
|
|
5167
|
-
async updateMmOracleNative(marketIndex, oraclePrice, oracleSequenceId) {
|
|
5168
|
-
const updateMmOracleIx = await this.getUpdateMmOracleNativeIx(marketIndex, oraclePrice, oracleSequenceId);
|
|
5169
|
-
const tx = await this.buildTransaction(updateMmOracleIx, {
|
|
5170
|
-
computeUnits: 5000,
|
|
5171
|
-
computeUnitsPrice: 0,
|
|
5172
|
-
});
|
|
5173
|
-
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
5174
|
-
return txSig;
|
|
5175
|
-
}
|
|
5176
|
-
async getUpdateMmOracleNativeIx(marketIndex, oraclePrice, oracleSequenceId) {
|
|
5177
|
-
const discriminatorBuffer = (0, utils_2.createNativeInstructionDiscriminatorBuffer)(0);
|
|
5178
|
-
const data = Buffer.alloc(discriminatorBuffer.length + 16);
|
|
5179
|
-
data.set(discriminatorBuffer, 0);
|
|
5180
|
-
data.set(oraclePrice.toArrayLike(Buffer, 'le', 8), 5); // next 8 bytes
|
|
5181
|
-
data.set(oracleSequenceId.toArrayLike(Buffer, 'le', 8), 13); // next 8 bytes
|
|
5182
|
-
// Build the instruction manually
|
|
5183
|
-
return new web3_js_1.TransactionInstruction({
|
|
5184
|
-
programId: this.program.programId,
|
|
5185
|
-
keys: [
|
|
5186
|
-
{
|
|
5187
|
-
pubkey: this.getPerpMarketAccount(marketIndex).pubkey,
|
|
5188
|
-
isWritable: true,
|
|
5189
|
-
isSigner: false,
|
|
5190
|
-
},
|
|
5191
|
-
{
|
|
5192
|
-
pubkey: this.wallet.publicKey,
|
|
5193
|
-
isWritable: false,
|
|
5194
|
-
isSigner: true,
|
|
5195
|
-
},
|
|
5196
|
-
{
|
|
5197
|
-
pubkey: web3_js_1.SYSVAR_CLOCK_PUBKEY,
|
|
5198
|
-
isWritable: false,
|
|
5199
|
-
isSigner: false,
|
|
5200
|
-
},
|
|
5201
|
-
{
|
|
5202
|
-
pubkey: await this.getStatePublicKey(),
|
|
5203
|
-
isWritable: false,
|
|
5204
|
-
isSigner: false,
|
|
5205
|
-
},
|
|
5206
|
-
],
|
|
5207
|
-
data,
|
|
5208
|
-
});
|
|
5209
|
-
}
|
|
5210
|
-
async updateAmmSpreadAdjustmentNative(marketIndex, ammSpreadAdjustment) {
|
|
5211
|
-
const updateMmOracleIx = await this.getUpdateAmmSpreadAdjustmentNativeIx(marketIndex, ammSpreadAdjustment);
|
|
5212
|
-
const tx = await this.buildTransaction(updateMmOracleIx, {
|
|
5213
|
-
computeUnits: 1000,
|
|
5214
|
-
computeUnitsPrice: 0,
|
|
5215
|
-
});
|
|
5216
|
-
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
5217
|
-
return txSig;
|
|
5218
|
-
}
|
|
5219
|
-
getUpdateAmmSpreadAdjustmentNativeIx(marketIndex, ammSpreadAdjustment // i8
|
|
5220
|
-
) {
|
|
5221
|
-
const discriminatorBuffer = (0, utils_2.createNativeInstructionDiscriminatorBuffer)(1);
|
|
5222
|
-
const data = Buffer.alloc(discriminatorBuffer.length + 4);
|
|
5223
|
-
data.set(discriminatorBuffer, 0);
|
|
5224
|
-
data.writeInt8(ammSpreadAdjustment, 5); // next byte
|
|
5225
|
-
// Build the instruction manually
|
|
5226
|
-
return new web3_js_1.TransactionInstruction({
|
|
5227
|
-
programId: this.program.programId,
|
|
5228
|
-
keys: [
|
|
5229
|
-
{
|
|
5230
|
-
pubkey: this.getPerpMarketAccount(marketIndex).pubkey,
|
|
5231
|
-
isWritable: true,
|
|
5232
|
-
isSigner: false,
|
|
5233
|
-
},
|
|
5234
|
-
{
|
|
5235
|
-
pubkey: this.wallet.publicKey,
|
|
5236
|
-
isWritable: false,
|
|
5237
|
-
isSigner: true,
|
|
5238
|
-
},
|
|
5239
|
-
],
|
|
5240
|
-
data,
|
|
5241
|
-
});
|
|
5242
|
-
}
|
|
5243
5159
|
handleSignedTransaction(signedTxs) {
|
|
5244
5160
|
if (this.enableMetricsEvents && this.metricsEventEmitter) {
|
|
5245
5161
|
this.metricsEventEmitter.emit('txSigned', signedTxs);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.
|
|
2
|
+
"version": "2.129.0",
|
|
3
3
|
"name": "drift",
|
|
4
4
|
"instructions": [
|
|
5
5
|
{
|
|
@@ -1461,11 +1461,6 @@
|
|
|
1461
1461
|
"name": "user",
|
|
1462
1462
|
"isMut": true,
|
|
1463
1463
|
"isSigner": false
|
|
1464
|
-
},
|
|
1465
|
-
{
|
|
1466
|
-
"name": "signer",
|
|
1467
|
-
"isMut": false,
|
|
1468
|
-
"isSigner": true
|
|
1469
1464
|
}
|
|
1470
1465
|
],
|
|
1471
1466
|
"args": [
|
|
@@ -6735,10 +6730,6 @@
|
|
|
6735
6730
|
{
|
|
6736
6731
|
"name": "ammInventorySpreadAdjustment",
|
|
6737
6732
|
"type": "i8"
|
|
6738
|
-
},
|
|
6739
|
-
{
|
|
6740
|
-
"name": "referencePriceOffset",
|
|
6741
|
-
"type": "i32"
|
|
6742
6733
|
}
|
|
6743
6734
|
]
|
|
6744
6735
|
},
|
|
@@ -7534,25 +7525,20 @@
|
|
|
7534
7525
|
]
|
|
7535
7526
|
},
|
|
7536
7527
|
{
|
|
7537
|
-
"name": "
|
|
7528
|
+
"name": "zeroAmmFieldsPrepMmOracleInfo",
|
|
7538
7529
|
"accounts": [
|
|
7539
7530
|
{
|
|
7540
7531
|
"name": "admin",
|
|
7541
|
-
"isMut":
|
|
7532
|
+
"isMut": true,
|
|
7542
7533
|
"isSigner": true
|
|
7543
7534
|
},
|
|
7544
7535
|
{
|
|
7545
|
-
"name": "
|
|
7536
|
+
"name": "perpMarket",
|
|
7546
7537
|
"isMut": true,
|
|
7547
7538
|
"isSigner": false
|
|
7548
7539
|
}
|
|
7549
7540
|
],
|
|
7550
|
-
"args": [
|
|
7551
|
-
{
|
|
7552
|
-
"name": "disable",
|
|
7553
|
-
"type": "bool"
|
|
7554
|
-
}
|
|
7555
|
-
]
|
|
7541
|
+
"args": []
|
|
7556
7542
|
}
|
|
7557
7543
|
],
|
|
7558
7544
|
"accounts": [
|
|
@@ -9041,16 +9027,12 @@
|
|
|
9041
9027
|
"name": "maxInitializeUserFee",
|
|
9042
9028
|
"type": "u16"
|
|
9043
9029
|
},
|
|
9044
|
-
{
|
|
9045
|
-
"name": "disableBitFlags",
|
|
9046
|
-
"type": "u8"
|
|
9047
|
-
},
|
|
9048
9030
|
{
|
|
9049
9031
|
"name": "padding",
|
|
9050
9032
|
"type": {
|
|
9051
9033
|
"array": [
|
|
9052
9034
|
"u8",
|
|
9053
|
-
|
|
9035
|
+
10
|
|
9054
9036
|
]
|
|
9055
9037
|
}
|
|
9056
9038
|
}
|
|
@@ -10859,7 +10841,7 @@
|
|
|
10859
10841
|
"type": "u64"
|
|
10860
10842
|
},
|
|
10861
10843
|
{
|
|
10862
|
-
"name": "
|
|
10844
|
+
"name": "maxPositionSize",
|
|
10863
10845
|
"docs": [
|
|
10864
10846
|
"the max base size a single user can have",
|
|
10865
10847
|
"precision: BASE_PRECISION"
|
|
@@ -10947,11 +10929,18 @@
|
|
|
10947
10929
|
"type": "u32"
|
|
10948
10930
|
},
|
|
10949
10931
|
{
|
|
10950
|
-
"name": "
|
|
10932
|
+
"name": "longIntensityCount",
|
|
10951
10933
|
"docs": [
|
|
10952
|
-
"
|
|
10934
|
+
"the count intensity of long fills against AMM"
|
|
10953
10935
|
],
|
|
10954
|
-
"type": "
|
|
10936
|
+
"type": "u32"
|
|
10937
|
+
},
|
|
10938
|
+
{
|
|
10939
|
+
"name": "shortIntensityCount",
|
|
10940
|
+
"docs": [
|
|
10941
|
+
"the count intensity of short fills against AMM"
|
|
10942
|
+
],
|
|
10943
|
+
"type": "u32"
|
|
10955
10944
|
},
|
|
10956
10945
|
{
|
|
10957
10946
|
"name": "maxFillReserveFraction",
|
|
@@ -11033,7 +11022,7 @@
|
|
|
11033
11022
|
"type": "i8"
|
|
11034
11023
|
},
|
|
11035
11024
|
{
|
|
11036
|
-
"name": "
|
|
11025
|
+
"name": "totalFeeEarnedPerLp",
|
|
11037
11026
|
"type": "u64"
|
|
11038
11027
|
},
|
|
11039
11028
|
{
|
package/lib/browser/index.d.ts
CHANGED
|
@@ -89,7 +89,6 @@ export * from './oracles/pythPullClient';
|
|
|
89
89
|
export * from './oracles/pythLazerClient';
|
|
90
90
|
export * from './oracles/switchboardOnDemandClient';
|
|
91
91
|
export * from './oracles/oracleId';
|
|
92
|
-
export * from './oracles/utils';
|
|
93
92
|
export * from './swift/swiftOrderSubscriber';
|
|
94
93
|
export * from './swift/signedMsgUserAccountSubscriber';
|
|
95
94
|
export * from './swift/grpcSignedMsgUserAccountSubscriber';
|
package/lib/browser/index.js
CHANGED
|
@@ -113,7 +113,6 @@ __exportStar(require("./oracles/pythPullClient"), exports);
|
|
|
113
113
|
__exportStar(require("./oracles/pythLazerClient"), exports);
|
|
114
114
|
__exportStar(require("./oracles/switchboardOnDemandClient"), exports);
|
|
115
115
|
__exportStar(require("./oracles/oracleId"), exports);
|
|
116
|
-
__exportStar(require("./oracles/utils"), exports);
|
|
117
116
|
__exportStar(require("./swift/swiftOrderSubscriber"), exports);
|
|
118
117
|
__exportStar(require("./swift/signedMsgUserAccountSubscriber"), exports);
|
|
119
118
|
__exportStar(require("./swift/grpcSignedMsgUserAccountSubscriber"), exports);
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/// <reference types="bn.js" />
|
|
2
2
|
import { BN } from '@coral-xyz/anchor';
|
|
3
3
|
import { AMM, PositionDirection, SwapDirection, PerpMarketAccount } from '../types';
|
|
4
|
-
import {
|
|
4
|
+
import { OraclePriceData } from '../oracles/types';
|
|
5
5
|
export declare function calculatePegFromTargetPrice(targetPrice: BN, baseAssetReserve: BN, quoteAssetReserve: BN): BN;
|
|
6
|
-
export declare function calculateOptimalPegAndBudget(amm: AMM,
|
|
7
|
-
export declare function calculateNewAmm(amm: AMM,
|
|
8
|
-
export declare function calculateUpdatedAMM(amm: AMM,
|
|
9
|
-
export declare function calculateUpdatedAMMSpreadReserves(amm: AMM, direction: PositionDirection,
|
|
6
|
+
export declare function calculateOptimalPegAndBudget(amm: AMM, oraclePriceData: OraclePriceData): [BN, BN, BN, boolean];
|
|
7
|
+
export declare function calculateNewAmm(amm: AMM, oraclePriceData: OraclePriceData): [BN, BN, BN, BN];
|
|
8
|
+
export declare function calculateUpdatedAMM(amm: AMM, oraclePriceData: OraclePriceData): AMM;
|
|
9
|
+
export declare function calculateUpdatedAMMSpreadReserves(amm: AMM, direction: PositionDirection, oraclePriceData: OraclePriceData, isPrediction?: boolean): {
|
|
10
10
|
baseAssetReserve: BN;
|
|
11
11
|
quoteAssetReserve: BN;
|
|
12
12
|
sqrtK: BN;
|
|
13
13
|
newPeg: BN;
|
|
14
14
|
};
|
|
15
|
-
export declare function calculateBidAskPrice(amm: AMM,
|
|
15
|
+
export declare function calculateBidAskPrice(amm: AMM, oraclePriceData: OraclePriceData, withUpdate?: boolean, isPrediction?: boolean): [BN, BN];
|
|
16
16
|
/**
|
|
17
17
|
* Calculates a price given an arbitrary base and quote amount (they must have the same precision)
|
|
18
18
|
*
|
|
@@ -63,9 +63,9 @@ export declare function calculateSpreadBN(baseSpread: number, lastOracleReserveP
|
|
|
63
63
|
longSpread: number;
|
|
64
64
|
shortSpread: number;
|
|
65
65
|
};
|
|
66
|
-
export declare function calculateSpread(amm: AMM,
|
|
66
|
+
export declare function calculateSpread(amm: AMM, oraclePriceData: OraclePriceData, now?: BN, reservePrice?: BN): [number, number];
|
|
67
67
|
export declare function getQuoteAssetReservePredictionMarketBounds(amm: AMM, direction: PositionDirection): [BN, BN];
|
|
68
|
-
export declare function calculateSpreadReserves(amm: AMM,
|
|
68
|
+
export declare function calculateSpreadReserves(amm: AMM, oraclePriceData: OraclePriceData, now?: BN, isPrediction?: boolean): {
|
|
69
69
|
baseAssetReserve: any;
|
|
70
70
|
quoteAssetReserve: any;
|
|
71
71
|
}[];
|
|
@@ -93,6 +93,6 @@ export declare function getSwapDirection(inputAssetType: AssetType, positionDire
|
|
|
93
93
|
* @returns cost : Precision PRICE_PRECISION
|
|
94
94
|
*/
|
|
95
95
|
export declare function calculateTerminalPrice(market: PerpMarketAccount): BN;
|
|
96
|
-
export declare function calculateMaxBaseAssetAmountToTrade(amm: AMM, limit_price: BN, direction: PositionDirection,
|
|
96
|
+
export declare function calculateMaxBaseAssetAmountToTrade(amm: AMM, limit_price: BN, direction: PositionDirection, oraclePriceData?: OraclePriceData, now?: BN, isPrediction?: boolean): [BN, PositionDirection];
|
|
97
97
|
export declare function calculateQuoteAssetAmountSwapped(quoteAssetReserves: BN, pegMultiplier: BN, swapDirection: SwapDirection): BN;
|
|
98
98
|
export declare function calculateMaxBaseAssetAmountFillable(amm: AMM, orderDirection: PositionDirection): BN;
|
package/lib/browser/math/amm.js
CHANGED
|
@@ -8,7 +8,6 @@ const assert_1 = require("../assert/assert");
|
|
|
8
8
|
const __1 = require("..");
|
|
9
9
|
const repeg_1 = require("./repeg");
|
|
10
10
|
const oracles_1 = require("./oracles");
|
|
11
|
-
const utils_1 = require("../oracles/utils");
|
|
12
11
|
function calculatePegFromTargetPrice(targetPrice, baseAssetReserve, quoteAssetReserve) {
|
|
13
12
|
return anchor_1.BN.max(targetPrice
|
|
14
13
|
.mul(baseAssetReserve)
|
|
@@ -17,9 +16,9 @@ function calculatePegFromTargetPrice(targetPrice, baseAssetReserve, quoteAssetRe
|
|
|
17
16
|
.div(numericConstants_1.PRICE_DIV_PEG), numericConstants_1.ONE);
|
|
18
17
|
}
|
|
19
18
|
exports.calculatePegFromTargetPrice = calculatePegFromTargetPrice;
|
|
20
|
-
function calculateOptimalPegAndBudget(amm,
|
|
19
|
+
function calculateOptimalPegAndBudget(amm, oraclePriceData) {
|
|
21
20
|
const reservePriceBefore = calculatePrice(amm.baseAssetReserve, amm.quoteAssetReserve, amm.pegMultiplier);
|
|
22
|
-
const targetPrice =
|
|
21
|
+
const targetPrice = oraclePriceData.price;
|
|
23
22
|
const newPeg = calculatePegFromTargetPrice(targetPrice, amm.baseAssetReserve, amm.quoteAssetReserve);
|
|
24
23
|
const prePegCost = (0, repeg_1.calculateRepegCost)(amm, newPeg);
|
|
25
24
|
const totalFeeLB = amm.totalExchangeFee.div(new anchor_1.BN(2));
|
|
@@ -54,10 +53,10 @@ function calculateOptimalPegAndBudget(amm, mmOraclePriceData) {
|
|
|
54
53
|
return [targetPrice, newPeg, budget, checkLowerBound];
|
|
55
54
|
}
|
|
56
55
|
exports.calculateOptimalPegAndBudget = calculateOptimalPegAndBudget;
|
|
57
|
-
function calculateNewAmm(amm,
|
|
56
|
+
function calculateNewAmm(amm, oraclePriceData) {
|
|
58
57
|
let pKNumer = new anchor_1.BN(1);
|
|
59
58
|
let pKDenom = new anchor_1.BN(1);
|
|
60
|
-
const [targetPrice, _newPeg, budget, _checkLowerBound] = calculateOptimalPegAndBudget(amm,
|
|
59
|
+
const [targetPrice, _newPeg, budget, _checkLowerBound] = calculateOptimalPegAndBudget(amm, oraclePriceData);
|
|
61
60
|
let prePegCost = (0, repeg_1.calculateRepegCost)(amm, _newPeg);
|
|
62
61
|
let newPeg = _newPeg;
|
|
63
62
|
if (prePegCost.gte(budget) && prePegCost.gt(numericConstants_1.ZERO)) {
|
|
@@ -81,12 +80,12 @@ function calculateNewAmm(amm, mmOraclePriceData) {
|
|
|
81
80
|
return [prePegCost, pKNumer, pKDenom, newPeg];
|
|
82
81
|
}
|
|
83
82
|
exports.calculateNewAmm = calculateNewAmm;
|
|
84
|
-
function calculateUpdatedAMM(amm,
|
|
85
|
-
if (amm.curveUpdateIntensity == 0 ||
|
|
83
|
+
function calculateUpdatedAMM(amm, oraclePriceData) {
|
|
84
|
+
if (amm.curveUpdateIntensity == 0 || oraclePriceData === undefined) {
|
|
86
85
|
return amm;
|
|
87
86
|
}
|
|
88
87
|
const newAmm = Object.assign({}, amm);
|
|
89
|
-
const [prepegCost, pKNumer, pKDenom, newPeg] = calculateNewAmm(amm,
|
|
88
|
+
const [prepegCost, pKNumer, pKDenom, newPeg] = calculateNewAmm(amm, oraclePriceData);
|
|
90
89
|
newAmm.baseAssetReserve = newAmm.baseAssetReserve.mul(pKNumer).div(pKDenom);
|
|
91
90
|
newAmm.sqrtK = newAmm.sqrtK.mul(pKNumer).div(pKDenom);
|
|
92
91
|
const invariant = newAmm.sqrtK.mul(newAmm.sqrtK);
|
|
@@ -104,9 +103,9 @@ function calculateUpdatedAMM(amm, mmOraclePriceData) {
|
|
|
104
103
|
return newAmm;
|
|
105
104
|
}
|
|
106
105
|
exports.calculateUpdatedAMM = calculateUpdatedAMM;
|
|
107
|
-
function calculateUpdatedAMMSpreadReserves(amm, direction,
|
|
108
|
-
const newAmm = calculateUpdatedAMM(amm,
|
|
109
|
-
const [shortReserves, longReserves] = calculateSpreadReserves(newAmm,
|
|
106
|
+
function calculateUpdatedAMMSpreadReserves(amm, direction, oraclePriceData, isPrediction = false) {
|
|
107
|
+
const newAmm = calculateUpdatedAMM(amm, oraclePriceData);
|
|
108
|
+
const [shortReserves, longReserves] = calculateSpreadReserves(newAmm, oraclePriceData, undefined, isPrediction);
|
|
110
109
|
const dirReserves = (0, types_1.isVariant)(direction, 'long')
|
|
111
110
|
? longReserves
|
|
112
111
|
: shortReserves;
|
|
@@ -119,15 +118,15 @@ function calculateUpdatedAMMSpreadReserves(amm, direction, mmOraclePriceData, is
|
|
|
119
118
|
return result;
|
|
120
119
|
}
|
|
121
120
|
exports.calculateUpdatedAMMSpreadReserves = calculateUpdatedAMMSpreadReserves;
|
|
122
|
-
function calculateBidAskPrice(amm,
|
|
121
|
+
function calculateBidAskPrice(amm, oraclePriceData, withUpdate = true, isPrediction = false) {
|
|
123
122
|
let newAmm;
|
|
124
123
|
if (withUpdate) {
|
|
125
|
-
newAmm = calculateUpdatedAMM(amm,
|
|
124
|
+
newAmm = calculateUpdatedAMM(amm, oraclePriceData);
|
|
126
125
|
}
|
|
127
126
|
else {
|
|
128
127
|
newAmm = amm;
|
|
129
128
|
}
|
|
130
|
-
const [bidReserves, askReserves] = calculateSpreadReserves(newAmm,
|
|
129
|
+
const [bidReserves, askReserves] = calculateSpreadReserves(newAmm, oraclePriceData, undefined, isPrediction);
|
|
131
130
|
const askPrice = calculatePrice(askReserves.baseAssetReserve, askReserves.quoteAssetReserve, newAmm.pegMultiplier);
|
|
132
131
|
const bidPrice = calculatePrice(bidReserves.baseAssetReserve, bidReserves.quoteAssetReserve, newAmm.pegMultiplier);
|
|
133
132
|
return [bidPrice, askPrice];
|
|
@@ -436,22 +435,21 @@ function calculateSpreadBN(baseSpread, lastOracleReservePriceSpreadPct, lastOrac
|
|
|
436
435
|
return [longSpread, shortSpread];
|
|
437
436
|
}
|
|
438
437
|
exports.calculateSpreadBN = calculateSpreadBN;
|
|
439
|
-
function calculateSpread(amm,
|
|
438
|
+
function calculateSpread(amm, oraclePriceData, now, reservePrice) {
|
|
440
439
|
if (amm.baseSpread == 0 || amm.curveUpdateIntensity == 0) {
|
|
441
440
|
return [amm.baseSpread / 2, amm.baseSpread / 2];
|
|
442
441
|
}
|
|
443
442
|
if (!reservePrice) {
|
|
444
443
|
reservePrice = calculatePrice(amm.baseAssetReserve, amm.quoteAssetReserve, amm.pegMultiplier);
|
|
445
444
|
}
|
|
446
|
-
const
|
|
447
|
-
const targetPrice = oraclePrice || reservePrice;
|
|
445
|
+
const targetPrice = (oraclePriceData === null || oraclePriceData === void 0 ? void 0 : oraclePriceData.price) || reservePrice;
|
|
448
446
|
const targetMarkSpreadPct = reservePrice
|
|
449
447
|
.sub(targetPrice)
|
|
450
448
|
.mul(numericConstants_1.BID_ASK_SPREAD_PRECISION)
|
|
451
449
|
.div(reservePrice);
|
|
452
450
|
now = now || new anchor_1.BN(new Date().getTime() / 1000); //todo
|
|
453
|
-
const liveOracleStd = (0, oracles_1.calculateLiveOracleStd)(amm,
|
|
454
|
-
const confIntervalPct = (0, oracles_1.getNewOracleConfPct)(amm,
|
|
451
|
+
const liveOracleStd = (0, oracles_1.calculateLiveOracleStd)(amm, oraclePriceData, now);
|
|
452
|
+
const confIntervalPct = (0, oracles_1.getNewOracleConfPct)(amm, oraclePriceData, reservePrice, now);
|
|
455
453
|
const spreads = calculateSpreadBN(amm.baseSpread, targetMarkSpreadPct, confIntervalPct, amm.maxSpread, amm.quoteAssetReserve, amm.terminalQuoteAssetReserve, amm.pegMultiplier, amm.baseAssetAmountWithAmm, reservePrice, amm.totalFeeMinusDistributions, amm.netRevenueSinceLastFunding, amm.baseAssetReserve, amm.minBaseAssetReserve, amm.maxBaseAssetReserve, amm.markStd, liveOracleStd, amm.longIntensityVolume, amm.shortIntensityVolume, amm.volume24H, amm.ammInventorySpreadAdjustment);
|
|
456
454
|
let longSpread = spreads[0];
|
|
457
455
|
let shortSpread = spreads[1];
|
|
@@ -489,7 +487,7 @@ function getQuoteAssetReservePredictionMarketBounds(amm, direction) {
|
|
|
489
487
|
return [quoteAssetReserveLowerBound, quoteAssetReserveUpperBound];
|
|
490
488
|
}
|
|
491
489
|
exports.getQuoteAssetReservePredictionMarketBounds = getQuoteAssetReservePredictionMarketBounds;
|
|
492
|
-
function calculateSpreadReserves(amm,
|
|
490
|
+
function calculateSpreadReserves(amm, oraclePriceData, now, isPrediction = false) {
|
|
493
491
|
function calculateSpreadReserve(spread, direction, amm) {
|
|
494
492
|
if (spread === 0) {
|
|
495
493
|
return {
|
|
@@ -531,13 +529,12 @@ function calculateSpreadReserves(amm, mmOraclePriceData, now, isPrediction = fal
|
|
|
531
529
|
const liquidityFractionSigned = liquidityFraction.mul((0, __1.sigNum)(amm.baseAssetAmountWithAmm.add(amm.baseAssetAmountWithUnsettledLp)));
|
|
532
530
|
referencePriceOffset = calculateReferencePriceOffset(reservePrice, amm.last24HAvgFundingRate, liquidityFractionSigned, amm.historicalOracleData.lastOraclePriceTwap5Min, amm.lastMarkPriceTwap5Min, amm.historicalOracleData.lastOraclePriceTwap, amm.lastMarkPriceTwap, maxOffset).toNumber();
|
|
533
531
|
}
|
|
534
|
-
let [longSpread, shortSpread] = calculateSpread(amm,
|
|
532
|
+
let [longSpread, shortSpread] = calculateSpread(amm, oraclePriceData, now, reservePrice);
|
|
535
533
|
const doReferencePricOffsetSmooth = Math.sign(referencePriceOffset) !== Math.sign(amm.referencePriceOffset) &&
|
|
536
534
|
amm.curveUpdateIntensity > 100;
|
|
537
535
|
if (doReferencePricOffsetSmooth) {
|
|
538
|
-
if (
|
|
539
|
-
const slotsPassed =
|
|
540
|
-
amm.lastUpdateSlot.toNumber();
|
|
536
|
+
if (oraclePriceData.slot !== amm.lastUpdateSlot) {
|
|
537
|
+
const slotsPassed = oraclePriceData.slot.toNumber() - amm.lastUpdateSlot.toNumber();
|
|
541
538
|
const fullOffsetDelta = referencePriceOffset - amm.referencePriceOffset;
|
|
542
539
|
const raw = Math.trunc(Math.min(Math.abs(fullOffsetDelta), slotsPassed * 1000) / 10);
|
|
543
540
|
const maxAllowed = Math.abs(amm.referencePriceOffset) || Math.abs(referencePriceOffset);
|
|
@@ -615,7 +612,7 @@ function calculateTerminalPrice(market) {
|
|
|
615
612
|
return terminalPrice;
|
|
616
613
|
}
|
|
617
614
|
exports.calculateTerminalPrice = calculateTerminalPrice;
|
|
618
|
-
function calculateMaxBaseAssetAmountToTrade(amm, limit_price, direction,
|
|
615
|
+
function calculateMaxBaseAssetAmountToTrade(amm, limit_price, direction, oraclePriceData, now, isPrediction = false) {
|
|
619
616
|
const invariant = amm.sqrtK.mul(amm.sqrtK);
|
|
620
617
|
const newBaseAssetReserveSquared = invariant
|
|
621
618
|
.mul(numericConstants_1.PRICE_PRECISION)
|
|
@@ -623,7 +620,7 @@ function calculateMaxBaseAssetAmountToTrade(amm, limit_price, direction, mmOracl
|
|
|
623
620
|
.div(limit_price)
|
|
624
621
|
.div(numericConstants_1.PEG_PRECISION);
|
|
625
622
|
const newBaseAssetReserve = (0, __1.squareRootBN)(newBaseAssetReserveSquared);
|
|
626
|
-
const [shortSpreadReserves, longSpreadReserves] = calculateSpreadReserves(amm,
|
|
623
|
+
const [shortSpreadReserves, longSpreadReserves] = calculateSpreadReserves(amm, oraclePriceData, now, isPrediction);
|
|
627
624
|
const baseAssetReserveBefore = (0, types_1.isVariant)(direction, 'long')
|
|
628
625
|
? longSpreadReserves.baseAssetReserve
|
|
629
626
|
: shortSpreadReserves.baseAssetReserve;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="bn.js" />
|
|
2
2
|
import { BN } from '@coral-xyz/anchor';
|
|
3
3
|
import { PerpMarketAccount } from '../types';
|
|
4
|
-
import {
|
|
4
|
+
import { OraclePriceData } from '../oracles/types';
|
|
5
5
|
/**
|
|
6
6
|
*
|
|
7
7
|
* @param market
|
|
@@ -9,12 +9,12 @@ import { MMOraclePriceData } from '../oracles/types';
|
|
|
9
9
|
* @param periodAdjustment
|
|
10
10
|
* @returns Estimated funding rate. : Precision //TODO-PRECISION
|
|
11
11
|
*/
|
|
12
|
-
export declare function calculateAllEstimatedFundingRate(market: PerpMarketAccount,
|
|
12
|
+
export declare function calculateAllEstimatedFundingRate(market: PerpMarketAccount, oraclePriceData?: OraclePriceData, markPrice?: BN, now?: BN): [BN, BN, BN, BN, BN];
|
|
13
13
|
/**
|
|
14
14
|
* Calculate funding rates in human-readable form. Values will have some lost precision and shouldn't be used in strict accounting.
|
|
15
15
|
* @param period : 'hour' | 'year' :: Use 'hour' for the hourly payment as a percentage, 'year' for the payment as an estimated APR.
|
|
16
16
|
*/
|
|
17
|
-
export declare function calculateFormattedLiveFundingRate(market: PerpMarketAccount,
|
|
17
|
+
export declare function calculateFormattedLiveFundingRate(market: PerpMarketAccount, oraclePriceData: OraclePriceData, period: 'hour' | 'year'): {
|
|
18
18
|
longRate: number;
|
|
19
19
|
shortRate: number;
|
|
20
20
|
fundingRateUnit: string;
|
|
@@ -27,7 +27,7 @@ export declare function calculateFormattedLiveFundingRate(market: PerpMarketAcco
|
|
|
27
27
|
* @param periodAdjustment
|
|
28
28
|
* @returns Estimated funding rate. : Precision //TODO-PRECISION
|
|
29
29
|
*/
|
|
30
|
-
export declare function calculateLongShortFundingRate(market: PerpMarketAccount,
|
|
30
|
+
export declare function calculateLongShortFundingRate(market: PerpMarketAccount, oraclePriceData?: OraclePriceData, markPrice?: BN, now?: BN): [BN, BN];
|
|
31
31
|
/**
|
|
32
32
|
*
|
|
33
33
|
* @param market
|
|
@@ -35,7 +35,7 @@ export declare function calculateLongShortFundingRate(market: PerpMarketAccount,
|
|
|
35
35
|
* @param periodAdjustment
|
|
36
36
|
* @returns Estimated funding rate. : Precision //TODO-PRECISION
|
|
37
37
|
*/
|
|
38
|
-
export declare function calculateLongShortFundingRateAndLiveTwaps(market: PerpMarketAccount,
|
|
38
|
+
export declare function calculateLongShortFundingRateAndLiveTwaps(market: PerpMarketAccount, oraclePriceData?: OraclePriceData, markPrice?: BN, now?: BN): [BN, BN, BN, BN];
|
|
39
39
|
/**
|
|
40
40
|
*
|
|
41
41
|
* @param market
|