@drift-labs/sdk 2.129.0-beta.2 → 2.129.0-beta.4
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 +6 -2
- package/lib/browser/adminClient.js +86 -7
- package/lib/browser/dlob/orderBookLevels.d.ts +2 -2
- package/lib/browser/dlob/orderBookLevels.js +16 -4
- package/lib/browser/driftClient.d.ts +2 -1
- package/lib/browser/driftClient.js +8 -0
- package/lib/browser/idl/drift.json +28 -17
- package/lib/browser/math/amm.d.ts +9 -9
- package/lib/browser/math/amm.js +45 -21
- package/lib/browser/math/funding.d.ts +5 -5
- package/lib/browser/math/funding.js +20 -11
- package/lib/browser/math/market.d.ts +6 -6
- package/lib/browser/math/market.js +12 -11
- 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 +5 -0
- package/lib/browser/oracles/utils.d.ts +6 -0
- package/lib/browser/oracles/utils.js +48 -0
- package/lib/browser/tx/utils.d.ts +2 -0
- package/lib/browser/tx/utils.js +9 -1
- package/lib/browser/types.d.ts +3 -4
- package/lib/browser/user.d.ts +1 -0
- package/lib/browser/user.js +9 -6
- package/lib/node/adminClient.d.ts +6 -2
- package/lib/node/adminClient.d.ts.map +1 -1
- package/lib/node/adminClient.js +86 -7
- 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 +16 -4
- package/lib/node/driftClient.d.ts +2 -1
- package/lib/node/driftClient.d.ts.map +1 -1
- package/lib/node/driftClient.js +8 -0
- package/lib/node/idl/drift.json +28 -17
- 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 +45 -21
- 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 +20 -11
- 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 +12 -11
- 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 +5 -0
- package/lib/node/oracles/types.d.ts.map +1 -1
- package/lib/node/oracles/utils.d.ts +7 -0
- package/lib/node/oracles/utils.d.ts.map +1 -0
- package/lib/node/oracles/utils.js +48 -0
- package/lib/node/tx/utils.d.ts +2 -0
- package/lib/node/tx/utils.d.ts.map +1 -1
- package/lib/node/tx/utils.js +9 -1
- package/lib/node/types.d.ts +3 -4
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/user.d.ts +1 -0
- package/lib/node/user.d.ts.map +1 -1
- package/lib/node/user.js +9 -6
- package/package.json +1 -1
- package/src/adminClient.ts +124 -13
- package/src/dlob/orderBookLevels.ts +18 -5
- package/src/driftClient.ts +10 -1
- package/src/idl/drift.json +29 -18
- package/src/math/amm.ts +59 -24
- package/src/math/funding.ts +26 -12
- package/src/math/market.ts +16 -15
- package/src/math/oracles.ts +9 -13
- package/src/math/orders.ts +13 -9
- package/src/math/position.ts +4 -4
- package/src/math/trade.ts +46 -20
- package/src/oracles/types.ts +6 -0
- package/src/oracles/utils.ts +60 -0
- package/src/tx/utils.ts +10 -0
- package/src/types.ts +3 -4
- package/src/user.ts +11 -7
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.129.0-beta.
|
|
1
|
+
2.129.0-beta.4
|
|
@@ -230,6 +230,10 @@ 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
|
+
updateMmOracleNative(marketIndex: number, oraclePrice: BN, oracleSequenceId: BN): Promise<TransactionSignature>;
|
|
234
|
+
getUpdateMmOracleNativeIx(marketIndex: number, oraclePrice: BN, oracleSequenceId: BN): Promise<TransactionInstruction>;
|
|
235
|
+
updateAmmSpreadAdjustmentNative(marketIndex: number, ammSpreadAdjustment: number): Promise<TransactionSignature>;
|
|
236
|
+
getUpdateAmmSpreadAdjustmentNativeIx(marketIndex: number, ammSpreadAdjustment: number): TransactionInstruction;
|
|
237
|
+
updateDisableBitFlagsMMOracle(disable: boolean): Promise<TransactionSignature>;
|
|
238
|
+
getUpdateDisableBitFlagsMMOracleIx(disable: boolean): Promise<TransactionInstruction>;
|
|
235
239
|
}
|
|
@@ -40,6 +40,7 @@ const phoenix_sdk_1 = require("@ellipsis-labs/phoenix-sdk");
|
|
|
40
40
|
const config_1 = require("./config");
|
|
41
41
|
const pythOracleUtils_1 = require("./util/pythOracleUtils");
|
|
42
42
|
const txConstants_1 = require("./constants/txConstants");
|
|
43
|
+
const utils_2 = require("./tx/utils");
|
|
43
44
|
const OPENBOOK_PROGRAM_ID = new web3_js_1.PublicKey('opnb2LAfJYbRMAHHvqjCwQxanZn7ReEHp1k81EohpZb');
|
|
44
45
|
class AdminClient extends driftClient_1.DriftClient {
|
|
45
46
|
async initialize(usdcMint, _adminControlsPrices) {
|
|
@@ -2103,17 +2104,95 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
2103
2104
|
},
|
|
2104
2105
|
});
|
|
2105
2106
|
}
|
|
2106
|
-
async
|
|
2107
|
-
const
|
|
2108
|
-
const tx = await this.buildTransaction(
|
|
2107
|
+
async updateMmOracleNative(marketIndex, oraclePrice, oracleSequenceId) {
|
|
2108
|
+
const updateMmOracleIx = await this.getUpdateMmOracleNativeIx(marketIndex, oraclePrice, oracleSequenceId);
|
|
2109
|
+
const tx = await this.buildTransaction(updateMmOracleIx, {
|
|
2110
|
+
computeUnits: 5000,
|
|
2111
|
+
computeUnitsPrice: 0,
|
|
2112
|
+
});
|
|
2109
2113
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2110
2114
|
return txSig;
|
|
2111
2115
|
}
|
|
2112
|
-
async
|
|
2113
|
-
|
|
2116
|
+
async getUpdateMmOracleNativeIx(marketIndex, oraclePrice, oracleSequenceId) {
|
|
2117
|
+
const discriminatorBuffer = (0, utils_2.createNativeInstructionDiscriminatorBuffer)(0);
|
|
2118
|
+
const data = Buffer.alloc(discriminatorBuffer.length + 16);
|
|
2119
|
+
data.set(discriminatorBuffer, 0);
|
|
2120
|
+
data.set(oraclePrice.toArrayLike(Buffer, 'le', 8), 5); // next 8 bytes
|
|
2121
|
+
data.set(oracleSequenceId.toArrayLike(Buffer, 'le', 8), 13); // next 8 bytes
|
|
2122
|
+
// Build the instruction manually
|
|
2123
|
+
return new web3_js_1.TransactionInstruction({
|
|
2124
|
+
programId: this.program.programId,
|
|
2125
|
+
keys: [
|
|
2126
|
+
{
|
|
2127
|
+
pubkey: this.getPerpMarketAccount(marketIndex).pubkey,
|
|
2128
|
+
isWritable: true,
|
|
2129
|
+
isSigner: false,
|
|
2130
|
+
},
|
|
2131
|
+
{
|
|
2132
|
+
pubkey: this.wallet.publicKey,
|
|
2133
|
+
isWritable: false,
|
|
2134
|
+
isSigner: true,
|
|
2135
|
+
},
|
|
2136
|
+
{
|
|
2137
|
+
pubkey: web3_js_1.SYSVAR_CLOCK_PUBKEY,
|
|
2138
|
+
isWritable: false,
|
|
2139
|
+
isSigner: false,
|
|
2140
|
+
},
|
|
2141
|
+
{
|
|
2142
|
+
pubkey: await this.getStatePublicKey(),
|
|
2143
|
+
isWritable: false,
|
|
2144
|
+
isSigner: false,
|
|
2145
|
+
},
|
|
2146
|
+
],
|
|
2147
|
+
data,
|
|
2148
|
+
});
|
|
2149
|
+
}
|
|
2150
|
+
async updateAmmSpreadAdjustmentNative(marketIndex, ammSpreadAdjustment) {
|
|
2151
|
+
const updateMmOracleIx = await this.getUpdateAmmSpreadAdjustmentNativeIx(marketIndex, ammSpreadAdjustment);
|
|
2152
|
+
const tx = await this.buildTransaction(updateMmOracleIx, {
|
|
2153
|
+
computeUnits: 1000,
|
|
2154
|
+
computeUnitsPrice: 0,
|
|
2155
|
+
});
|
|
2156
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2157
|
+
return txSig;
|
|
2158
|
+
}
|
|
2159
|
+
getUpdateAmmSpreadAdjustmentNativeIx(marketIndex, ammSpreadAdjustment // i8
|
|
2160
|
+
) {
|
|
2161
|
+
const discriminatorBuffer = (0, utils_2.createNativeInstructionDiscriminatorBuffer)(1);
|
|
2162
|
+
const data = Buffer.alloc(discriminatorBuffer.length + 4);
|
|
2163
|
+
data.set(discriminatorBuffer, 0);
|
|
2164
|
+
data.writeInt8(ammSpreadAdjustment, 5); // next byte
|
|
2165
|
+
// Build the instruction manually
|
|
2166
|
+
return new web3_js_1.TransactionInstruction({
|
|
2167
|
+
programId: this.program.programId,
|
|
2168
|
+
keys: [
|
|
2169
|
+
{
|
|
2170
|
+
pubkey: this.getPerpMarketAccount(marketIndex).pubkey,
|
|
2171
|
+
isWritable: true,
|
|
2172
|
+
isSigner: false,
|
|
2173
|
+
},
|
|
2174
|
+
{
|
|
2175
|
+
pubkey: this.wallet.publicKey,
|
|
2176
|
+
isWritable: false,
|
|
2177
|
+
isSigner: true,
|
|
2178
|
+
},
|
|
2179
|
+
],
|
|
2180
|
+
data,
|
|
2181
|
+
});
|
|
2182
|
+
}
|
|
2183
|
+
async updateDisableBitFlagsMMOracle(disable) {
|
|
2184
|
+
const updateDisableBitFlagsMMOracleIx = await this.getUpdateDisableBitFlagsMMOracleIx(disable);
|
|
2185
|
+
const tx = await this.buildTransaction(updateDisableBitFlagsMMOracleIx);
|
|
2186
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2187
|
+
return txSig;
|
|
2188
|
+
}
|
|
2189
|
+
async getUpdateDisableBitFlagsMMOracleIx(disable) {
|
|
2190
|
+
return await this.program.instruction.updateDisableBitflagsMmOracle(disable, {
|
|
2114
2191
|
accounts: {
|
|
2115
|
-
admin: this.
|
|
2116
|
-
|
|
2192
|
+
admin: this.isSubscribed
|
|
2193
|
+
? this.getStateAccount().admin
|
|
2194
|
+
: this.wallet.publicKey,
|
|
2195
|
+
state: await this.getStatePublicKey(),
|
|
2117
2196
|
},
|
|
2118
2197
|
});
|
|
2119
2198
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="bn.js" />
|
|
2
|
-
import { BN, DLOBNode, OraclePriceData, PerpMarketAccount } from '..';
|
|
2
|
+
import { BN, DLOBNode, OraclePriceData, PerpMarketAccount, MMOraclePriceData } 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 | MMOraclePriceData;
|
|
40
40
|
numOrders: number;
|
|
41
41
|
now?: BN;
|
|
42
42
|
topOfBookQuoteAmounts?: BN[];
|
|
@@ -2,6 +2,7 @@
|
|
|
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");
|
|
5
6
|
exports.DEFAULT_TOP_OF_BOOK_QUOTE_AMOUNTS = [
|
|
6
7
|
new __1.BN(500).mul(__1.QUOTE_PRECISION),
|
|
7
8
|
new __1.BN(1000).mul(__1.QUOTE_PRECISION),
|
|
@@ -94,7 +95,18 @@ function createL2Levels(generator, depth) {
|
|
|
94
95
|
}
|
|
95
96
|
exports.createL2Levels = createL2Levels;
|
|
96
97
|
function getVammL2Generator({ marketAccount, oraclePriceData, numOrders, now = new __1.BN(Math.floor(Date.now() / 1000)), topOfBookQuoteAmounts = [], }) {
|
|
97
|
-
|
|
98
|
+
let mmOraclePriceData;
|
|
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);
|
|
98
110
|
const paused = (0, __1.isOperationPaused)(marketAccount.pausedOperations, __1.PerpOperation.AMM_FILL);
|
|
99
111
|
let [openBids, openAsks] = paused
|
|
100
112
|
? [__1.ZERO, __1.ZERO]
|
|
@@ -103,12 +115,12 @@ function getVammL2Generator({ marketAccount, oraclePriceData, numOrders, now = n
|
|
|
103
115
|
openBids = __1.ZERO;
|
|
104
116
|
if (openAsks.abs().lt(marketAccount.amm.minOrderSize.muln(2)))
|
|
105
117
|
openAsks = __1.ZERO;
|
|
106
|
-
const [bidReserves, askReserves] = (0, __1.calculateSpreadReserves)(updatedAmm,
|
|
118
|
+
const [bidReserves, askReserves] = (0, __1.calculateSpreadReserves)(updatedAmm, mmOraclePriceData, now, (0, __1.isVariant)(marketAccount.contractType, 'prediction'));
|
|
107
119
|
const numBaseOrders = Math.max(1, numOrders - topOfBookQuoteAmounts.length);
|
|
108
120
|
const commonOpts = {
|
|
109
121
|
numOrders,
|
|
110
122
|
numBaseOrders,
|
|
111
|
-
|
|
123
|
+
mmOraclePriceData,
|
|
112
124
|
orderTickSize: marketAccount.amm.orderTickSize,
|
|
113
125
|
orderStepSize: marketAccount.amm.orderStepSize,
|
|
114
126
|
pegMultiplier: updatedAmm.pegMultiplier,
|
|
@@ -131,7 +143,7 @@ function getVammL2Generator({ marketAccount, oraclePriceData, numOrders, now = n
|
|
|
131
143
|
const raw = commonOpts.topOfBookQuoteAmounts[count]
|
|
132
144
|
.mul(__1.AMM_TO_QUOTE_PRECISION_RATIO)
|
|
133
145
|
.mul(__1.PRICE_PRECISION)
|
|
134
|
-
.div(commonOpts.
|
|
146
|
+
.div((0, utils_1.getOraclePriceFromMMOracleData)(commonOpts.mmOraclePriceData));
|
|
135
147
|
baseSwap = (0, __1.standardizeBaseAssetAmount)(raw, commonOpts.orderStepSize);
|
|
136
148
|
const remaining = openLiquidity.abs().sub(topSize);
|
|
137
149
|
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 { OraclePriceData } from './oracles/types';
|
|
15
|
+
import { MMOraclePriceData, OraclePriceData } from './oracles/types';
|
|
16
16
|
import { DriftClientConfig } from './driftClientConfig';
|
|
17
17
|
import { User } from './user';
|
|
18
18
|
import { UserSubscriptionConfig } from './userConfig';
|
|
@@ -826,6 +826,7 @@ 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;
|
|
829
830
|
getOracleDataForSpotMarket(marketIndex: number): OraclePriceData;
|
|
830
831
|
initializeInsuranceFundStake(marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
831
832
|
getInitializeInsuranceFundStakeIx(marketIndex: number): Promise<TransactionInstruction>;
|
|
@@ -4418,6 +4418,14 @@ 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
|
+
}
|
|
4421
4429
|
getOracleDataForSpotMarket(marketIndex) {
|
|
4422
4430
|
return this.accountSubscriber.getOraclePriceDataAndSlotForSpotMarket(marketIndex).data;
|
|
4423
4431
|
}
|
|
@@ -1461,6 +1461,11 @@
|
|
|
1461
1461
|
"name": "user",
|
|
1462
1462
|
"isMut": true,
|
|
1463
1463
|
"isSigner": false
|
|
1464
|
+
},
|
|
1465
|
+
{
|
|
1466
|
+
"name": "signer",
|
|
1467
|
+
"isMut": false,
|
|
1468
|
+
"isSigner": true
|
|
1464
1469
|
}
|
|
1465
1470
|
],
|
|
1466
1471
|
"args": [
|
|
@@ -6730,6 +6735,10 @@
|
|
|
6730
6735
|
{
|
|
6731
6736
|
"name": "ammInventorySpreadAdjustment",
|
|
6732
6737
|
"type": "i8"
|
|
6738
|
+
},
|
|
6739
|
+
{
|
|
6740
|
+
"name": "referencePriceOffset",
|
|
6741
|
+
"type": "i32"
|
|
6733
6742
|
}
|
|
6734
6743
|
]
|
|
6735
6744
|
},
|
|
@@ -7525,20 +7534,25 @@
|
|
|
7525
7534
|
]
|
|
7526
7535
|
},
|
|
7527
7536
|
{
|
|
7528
|
-
"name": "
|
|
7537
|
+
"name": "updateDisableBitflagsMmOracle",
|
|
7529
7538
|
"accounts": [
|
|
7530
7539
|
{
|
|
7531
7540
|
"name": "admin",
|
|
7532
|
-
"isMut":
|
|
7541
|
+
"isMut": false,
|
|
7533
7542
|
"isSigner": true
|
|
7534
7543
|
},
|
|
7535
7544
|
{
|
|
7536
|
-
"name": "
|
|
7545
|
+
"name": "state",
|
|
7537
7546
|
"isMut": true,
|
|
7538
7547
|
"isSigner": false
|
|
7539
7548
|
}
|
|
7540
7549
|
],
|
|
7541
|
-
"args": [
|
|
7550
|
+
"args": [
|
|
7551
|
+
{
|
|
7552
|
+
"name": "disable",
|
|
7553
|
+
"type": "bool"
|
|
7554
|
+
}
|
|
7555
|
+
]
|
|
7542
7556
|
}
|
|
7543
7557
|
],
|
|
7544
7558
|
"accounts": [
|
|
@@ -9027,12 +9041,16 @@
|
|
|
9027
9041
|
"name": "maxInitializeUserFee",
|
|
9028
9042
|
"type": "u16"
|
|
9029
9043
|
},
|
|
9044
|
+
{
|
|
9045
|
+
"name": "disableBitFlags",
|
|
9046
|
+
"type": "u8"
|
|
9047
|
+
},
|
|
9030
9048
|
{
|
|
9031
9049
|
"name": "padding",
|
|
9032
9050
|
"type": {
|
|
9033
9051
|
"array": [
|
|
9034
9052
|
"u8",
|
|
9035
|
-
|
|
9053
|
+
9
|
|
9036
9054
|
]
|
|
9037
9055
|
}
|
|
9038
9056
|
}
|
|
@@ -10841,7 +10859,7 @@
|
|
|
10841
10859
|
"type": "u64"
|
|
10842
10860
|
},
|
|
10843
10861
|
{
|
|
10844
|
-
"name": "
|
|
10862
|
+
"name": "mmOracleSlot",
|
|
10845
10863
|
"docs": [
|
|
10846
10864
|
"the max base size a single user can have",
|
|
10847
10865
|
"precision: BASE_PRECISION"
|
|
@@ -10929,18 +10947,11 @@
|
|
|
10929
10947
|
"type": "u32"
|
|
10930
10948
|
},
|
|
10931
10949
|
{
|
|
10932
|
-
"name": "
|
|
10950
|
+
"name": "mmOraclePrice",
|
|
10933
10951
|
"docs": [
|
|
10934
|
-
"
|
|
10952
|
+
"MM oracle price"
|
|
10935
10953
|
],
|
|
10936
|
-
"type": "
|
|
10937
|
-
},
|
|
10938
|
-
{
|
|
10939
|
-
"name": "shortIntensityCount",
|
|
10940
|
-
"docs": [
|
|
10941
|
-
"the count intensity of short fills against AMM"
|
|
10942
|
-
],
|
|
10943
|
-
"type": "u32"
|
|
10954
|
+
"type": "i64"
|
|
10944
10955
|
},
|
|
10945
10956
|
{
|
|
10946
10957
|
"name": "maxFillReserveFraction",
|
|
@@ -11022,7 +11033,7 @@
|
|
|
11022
11033
|
"type": "i8"
|
|
11023
11034
|
},
|
|
11024
11035
|
{
|
|
11025
|
-
"name": "
|
|
11036
|
+
"name": "mmOracleSequenceId",
|
|
11026
11037
|
"type": "u64"
|
|
11027
11038
|
},
|
|
11028
11039
|
{
|
|
@@ -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 { MMOraclePriceData } 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, mmOraclePriceData: MMOraclePriceData): [BN, BN, BN, boolean];
|
|
7
|
+
export declare function calculateNewAmm(amm: AMM, mmOraclePriceData: MMOraclePriceData): [BN, BN, BN, BN];
|
|
8
|
+
export declare function calculateUpdatedAMM(amm: AMM, mmOraclePriceData: MMOraclePriceData): AMM;
|
|
9
|
+
export declare function calculateUpdatedAMMSpreadReserves(amm: AMM, direction: PositionDirection, mmOraclePriceData: MMOraclePriceData, 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, mmOraclePriceData: MMOraclePriceData, 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, mmOraclePriceData: MMOraclePriceData, 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, mmOraclePriceData: MMOraclePriceData, 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, mmOraclePriceData?: MMOraclePriceData, 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,6 +8,7 @@ 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");
|
|
11
12
|
function calculatePegFromTargetPrice(targetPrice, baseAssetReserve, quoteAssetReserve) {
|
|
12
13
|
return anchor_1.BN.max(targetPrice
|
|
13
14
|
.mul(baseAssetReserve)
|
|
@@ -16,9 +17,9 @@ function calculatePegFromTargetPrice(targetPrice, baseAssetReserve, quoteAssetRe
|
|
|
16
17
|
.div(numericConstants_1.PRICE_DIV_PEG), numericConstants_1.ONE);
|
|
17
18
|
}
|
|
18
19
|
exports.calculatePegFromTargetPrice = calculatePegFromTargetPrice;
|
|
19
|
-
function calculateOptimalPegAndBudget(amm,
|
|
20
|
+
function calculateOptimalPegAndBudget(amm, mmOraclePriceData) {
|
|
20
21
|
const reservePriceBefore = calculatePrice(amm.baseAssetReserve, amm.quoteAssetReserve, amm.pegMultiplier);
|
|
21
|
-
const targetPrice =
|
|
22
|
+
const targetPrice = (0, utils_1.getOraclePriceFromMMOracleData)(mmOraclePriceData);
|
|
22
23
|
const newPeg = calculatePegFromTargetPrice(targetPrice, amm.baseAssetReserve, amm.quoteAssetReserve);
|
|
23
24
|
const prePegCost = (0, repeg_1.calculateRepegCost)(amm, newPeg);
|
|
24
25
|
const totalFeeLB = amm.totalExchangeFee.div(new anchor_1.BN(2));
|
|
@@ -53,10 +54,10 @@ function calculateOptimalPegAndBudget(amm, oraclePriceData) {
|
|
|
53
54
|
return [targetPrice, newPeg, budget, checkLowerBound];
|
|
54
55
|
}
|
|
55
56
|
exports.calculateOptimalPegAndBudget = calculateOptimalPegAndBudget;
|
|
56
|
-
function calculateNewAmm(amm,
|
|
57
|
+
function calculateNewAmm(amm, mmOraclePriceData) {
|
|
57
58
|
let pKNumer = new anchor_1.BN(1);
|
|
58
59
|
let pKDenom = new anchor_1.BN(1);
|
|
59
|
-
const [targetPrice, _newPeg, budget, _checkLowerBound] = calculateOptimalPegAndBudget(amm,
|
|
60
|
+
const [targetPrice, _newPeg, budget, _checkLowerBound] = calculateOptimalPegAndBudget(amm, mmOraclePriceData);
|
|
60
61
|
let prePegCost = (0, repeg_1.calculateRepegCost)(amm, _newPeg);
|
|
61
62
|
let newPeg = _newPeg;
|
|
62
63
|
if (prePegCost.gte(budget) && prePegCost.gt(numericConstants_1.ZERO)) {
|
|
@@ -80,12 +81,12 @@ function calculateNewAmm(amm, oraclePriceData) {
|
|
|
80
81
|
return [prePegCost, pKNumer, pKDenom, newPeg];
|
|
81
82
|
}
|
|
82
83
|
exports.calculateNewAmm = calculateNewAmm;
|
|
83
|
-
function calculateUpdatedAMM(amm,
|
|
84
|
-
if (amm.curveUpdateIntensity == 0 ||
|
|
84
|
+
function calculateUpdatedAMM(amm, mmOraclePriceData) {
|
|
85
|
+
if (amm.curveUpdateIntensity == 0 || mmOraclePriceData === undefined) {
|
|
85
86
|
return amm;
|
|
86
87
|
}
|
|
87
88
|
const newAmm = Object.assign({}, amm);
|
|
88
|
-
const [prepegCost, pKNumer, pKDenom, newPeg] = calculateNewAmm(amm,
|
|
89
|
+
const [prepegCost, pKNumer, pKDenom, newPeg] = calculateNewAmm(amm, mmOraclePriceData);
|
|
89
90
|
newAmm.baseAssetReserve = newAmm.baseAssetReserve.mul(pKNumer).div(pKDenom);
|
|
90
91
|
newAmm.sqrtK = newAmm.sqrtK.mul(pKNumer).div(pKDenom);
|
|
91
92
|
const invariant = newAmm.sqrtK.mul(newAmm.sqrtK);
|
|
@@ -103,9 +104,9 @@ function calculateUpdatedAMM(amm, oraclePriceData) {
|
|
|
103
104
|
return newAmm;
|
|
104
105
|
}
|
|
105
106
|
exports.calculateUpdatedAMM = calculateUpdatedAMM;
|
|
106
|
-
function calculateUpdatedAMMSpreadReserves(amm, direction,
|
|
107
|
-
const newAmm = calculateUpdatedAMM(amm,
|
|
108
|
-
const [shortReserves, longReserves] = calculateSpreadReserves(newAmm,
|
|
107
|
+
function calculateUpdatedAMMSpreadReserves(amm, direction, mmOraclePriceData, isPrediction = false) {
|
|
108
|
+
const newAmm = calculateUpdatedAMM(amm, mmOraclePriceData);
|
|
109
|
+
const [shortReserves, longReserves] = calculateSpreadReserves(newAmm, mmOraclePriceData, undefined, isPrediction);
|
|
109
110
|
const dirReserves = (0, types_1.isVariant)(direction, 'long')
|
|
110
111
|
? longReserves
|
|
111
112
|
: shortReserves;
|
|
@@ -118,15 +119,15 @@ function calculateUpdatedAMMSpreadReserves(amm, direction, oraclePriceData, isPr
|
|
|
118
119
|
return result;
|
|
119
120
|
}
|
|
120
121
|
exports.calculateUpdatedAMMSpreadReserves = calculateUpdatedAMMSpreadReserves;
|
|
121
|
-
function calculateBidAskPrice(amm,
|
|
122
|
+
function calculateBidAskPrice(amm, mmOraclePriceData, withUpdate = true, isPrediction = false) {
|
|
122
123
|
let newAmm;
|
|
123
124
|
if (withUpdate) {
|
|
124
|
-
newAmm = calculateUpdatedAMM(amm,
|
|
125
|
+
newAmm = calculateUpdatedAMM(amm, mmOraclePriceData);
|
|
125
126
|
}
|
|
126
127
|
else {
|
|
127
128
|
newAmm = amm;
|
|
128
129
|
}
|
|
129
|
-
const [bidReserves, askReserves] = calculateSpreadReserves(newAmm,
|
|
130
|
+
const [bidReserves, askReserves] = calculateSpreadReserves(newAmm, mmOraclePriceData, undefined, isPrediction);
|
|
130
131
|
const askPrice = calculatePrice(askReserves.baseAssetReserve, askReserves.quoteAssetReserve, newAmm.pegMultiplier);
|
|
131
132
|
const bidPrice = calculatePrice(bidReserves.baseAssetReserve, bidReserves.quoteAssetReserve, newAmm.pegMultiplier);
|
|
132
133
|
return [bidPrice, askPrice];
|
|
@@ -435,21 +436,22 @@ function calculateSpreadBN(baseSpread, lastOracleReservePriceSpreadPct, lastOrac
|
|
|
435
436
|
return [longSpread, shortSpread];
|
|
436
437
|
}
|
|
437
438
|
exports.calculateSpreadBN = calculateSpreadBN;
|
|
438
|
-
function calculateSpread(amm,
|
|
439
|
+
function calculateSpread(amm, mmOraclePriceData, now, reservePrice) {
|
|
439
440
|
if (amm.baseSpread == 0 || amm.curveUpdateIntensity == 0) {
|
|
440
441
|
return [amm.baseSpread / 2, amm.baseSpread / 2];
|
|
441
442
|
}
|
|
442
443
|
if (!reservePrice) {
|
|
443
444
|
reservePrice = calculatePrice(amm.baseAssetReserve, amm.quoteAssetReserve, amm.pegMultiplier);
|
|
444
445
|
}
|
|
445
|
-
const
|
|
446
|
+
const oraclePrice = (0, utils_1.getOraclePriceFromMMOracleData)(mmOraclePriceData);
|
|
447
|
+
const targetPrice = oraclePrice || reservePrice;
|
|
446
448
|
const targetMarkSpreadPct = reservePrice
|
|
447
449
|
.sub(targetPrice)
|
|
448
450
|
.mul(numericConstants_1.BID_ASK_SPREAD_PRECISION)
|
|
449
451
|
.div(reservePrice);
|
|
450
452
|
now = now || new anchor_1.BN(new Date().getTime() / 1000); //todo
|
|
451
|
-
const liveOracleStd = (0, oracles_1.calculateLiveOracleStd)(amm,
|
|
452
|
-
const confIntervalPct = (0, oracles_1.getNewOracleConfPct)(amm,
|
|
453
|
+
const liveOracleStd = (0, oracles_1.calculateLiveOracleStd)(amm, oraclePrice, now);
|
|
454
|
+
const confIntervalPct = (0, oracles_1.getNewOracleConfPct)(amm, (0, utils_1.getOracleConfidenceFromMMOracleData)(mmOraclePriceData), reservePrice, now);
|
|
453
455
|
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);
|
|
454
456
|
let longSpread = spreads[0];
|
|
455
457
|
let shortSpread = spreads[1];
|
|
@@ -487,7 +489,7 @@ function getQuoteAssetReservePredictionMarketBounds(amm, direction) {
|
|
|
487
489
|
return [quoteAssetReserveLowerBound, quoteAssetReserveUpperBound];
|
|
488
490
|
}
|
|
489
491
|
exports.getQuoteAssetReservePredictionMarketBounds = getQuoteAssetReservePredictionMarketBounds;
|
|
490
|
-
function calculateSpreadReserves(amm,
|
|
492
|
+
function calculateSpreadReserves(amm, mmOraclePriceData, now, isPrediction = false) {
|
|
491
493
|
function calculateSpreadReserve(spread, direction, amm) {
|
|
492
494
|
if (spread === 0) {
|
|
493
495
|
return {
|
|
@@ -529,7 +531,29 @@ function calculateSpreadReserves(amm, oraclePriceData, now, isPrediction = false
|
|
|
529
531
|
const liquidityFractionSigned = liquidityFraction.mul((0, __1.sigNum)(amm.baseAssetAmountWithAmm.add(amm.baseAssetAmountWithUnsettledLp)));
|
|
530
532
|
referencePriceOffset = calculateReferencePriceOffset(reservePrice, amm.last24HAvgFundingRate, liquidityFractionSigned, amm.historicalOracleData.lastOraclePriceTwap5Min, amm.lastMarkPriceTwap5Min, amm.historicalOracleData.lastOraclePriceTwap, amm.lastMarkPriceTwap, maxOffset).toNumber();
|
|
531
533
|
}
|
|
532
|
-
|
|
534
|
+
let [longSpread, shortSpread] = calculateSpread(amm, mmOraclePriceData, now, reservePrice);
|
|
535
|
+
const doReferencePricOffsetSmooth = Math.sign(referencePriceOffset) !== Math.sign(amm.referencePriceOffset) &&
|
|
536
|
+
amm.curveUpdateIntensity > 100;
|
|
537
|
+
if (doReferencePricOffsetSmooth) {
|
|
538
|
+
if (mmOraclePriceData.oraclePriceData.slot !== amm.lastUpdateSlot) {
|
|
539
|
+
const slotsPassed = mmOraclePriceData.oraclePriceData.slot.toNumber() -
|
|
540
|
+
amm.lastUpdateSlot.toNumber();
|
|
541
|
+
const fullOffsetDelta = referencePriceOffset - amm.referencePriceOffset;
|
|
542
|
+
const raw = Math.trunc(Math.min(Math.abs(fullOffsetDelta), slotsPassed * 1000) / 10);
|
|
543
|
+
const maxAllowed = Math.abs(amm.referencePriceOffset) || Math.abs(referencePriceOffset);
|
|
544
|
+
const magnitude = Math.min(Math.max(raw, 10), maxAllowed);
|
|
545
|
+
const referencePriceDelta = Math.sign(fullOffsetDelta) * magnitude;
|
|
546
|
+
referencePriceOffset = amm.referencePriceOffset + referencePriceDelta;
|
|
547
|
+
if (referencePriceDelta < 0) {
|
|
548
|
+
longSpread += Math.abs(referencePriceDelta);
|
|
549
|
+
shortSpread += Math.abs(referencePriceOffset);
|
|
550
|
+
}
|
|
551
|
+
else {
|
|
552
|
+
shortSpread += Math.abs(referencePriceDelta);
|
|
553
|
+
longSpread += Math.abs(referencePriceOffset);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
533
557
|
const askReserves = calculateSpreadReserve(longSpread + referencePriceOffset, types_1.PositionDirection.LONG, amm);
|
|
534
558
|
const bidReserves = calculateSpreadReserve(-shortSpread + referencePriceOffset, types_1.PositionDirection.SHORT, amm);
|
|
535
559
|
return [bidReserves, askReserves];
|
|
@@ -591,7 +615,7 @@ function calculateTerminalPrice(market) {
|
|
|
591
615
|
return terminalPrice;
|
|
592
616
|
}
|
|
593
617
|
exports.calculateTerminalPrice = calculateTerminalPrice;
|
|
594
|
-
function calculateMaxBaseAssetAmountToTrade(amm, limit_price, direction,
|
|
618
|
+
function calculateMaxBaseAssetAmountToTrade(amm, limit_price, direction, mmOraclePriceData, now, isPrediction = false) {
|
|
595
619
|
const invariant = amm.sqrtK.mul(amm.sqrtK);
|
|
596
620
|
const newBaseAssetReserveSquared = invariant
|
|
597
621
|
.mul(numericConstants_1.PRICE_PRECISION)
|
|
@@ -599,7 +623,7 @@ function calculateMaxBaseAssetAmountToTrade(amm, limit_price, direction, oracleP
|
|
|
599
623
|
.div(limit_price)
|
|
600
624
|
.div(numericConstants_1.PEG_PRECISION);
|
|
601
625
|
const newBaseAssetReserve = (0, __1.squareRootBN)(newBaseAssetReserveSquared);
|
|
602
|
-
const [shortSpreadReserves, longSpreadReserves] = calculateSpreadReserves(amm,
|
|
626
|
+
const [shortSpreadReserves, longSpreadReserves] = calculateSpreadReserves(amm, mmOraclePriceData, now, isPrediction);
|
|
603
627
|
const baseAssetReserveBefore = (0, types_1.isVariant)(direction, 'long')
|
|
604
628
|
? longSpreadReserves.baseAssetReserve
|
|
605
629
|
: 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 { MMOraclePriceData } from '../oracles/types';
|
|
5
5
|
/**
|
|
6
6
|
*
|
|
7
7
|
* @param market
|
|
@@ -9,12 +9,12 @@ import { OraclePriceData } 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, mmOraclePriceData?: MMOraclePriceData, 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, mmOraclePriceData: MMOraclePriceData, 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, mmOraclePriceData?: MMOraclePriceData, 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, mmOraclePriceData?: MMOraclePriceData, markPrice?: BN, now?: BN): [BN, BN, BN, BN];
|
|
39
39
|
/**
|
|
40
40
|
*
|
|
41
41
|
* @param market
|