@drift-labs/sdk 2.86.0-beta.2 → 2.86.0-beta.21

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.
@@ -66,8 +66,8 @@ exports.MainnetSpotMarkets = [
66
66
  {
67
67
  symbol: 'mSOL',
68
68
  marketIndex: 2,
69
- oracle: new web3_js_1.PublicKey('E4v1BBgoso9s64TQvmyownAVJbhbEPGyzA3qn4n46qj9'),
70
- oracleSource: __1.OracleSource.PYTH,
69
+ oracle: new web3_js_1.PublicKey('FAq7hqjn7FWGXKDwJHzsXGgBcydGTcK4kziJpAGWXjDb'),
70
+ oracleSource: __1.OracleSource.PYTH_PULL,
71
71
  mint: new web3_js_1.PublicKey('mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So'),
72
72
  precision: new __1.BN(10).pow(numericConstants_1.NINE),
73
73
  precisionExp: numericConstants_1.NINE,
@@ -101,7 +101,7 @@ exports.MainnetSpotMarkets = [
101
101
  symbol: 'USDT',
102
102
  marketIndex: 5,
103
103
  oracle: new web3_js_1.PublicKey('3vxLXJqLqF3JG5TCbYycbKWRBbCJQLxQmBGCkyqEEefL'),
104
- oracleSource: __1.OracleSource.PYTH_STABLE_COIN,
104
+ oracleSource: __1.OracleSource.PYTH,
105
105
  mint: new web3_js_1.PublicKey('Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB'),
106
106
  precision: numericConstants_1.QUOTE_PRECISION,
107
107
  precisionExp: numericConstants_1.QUOTE_PRECISION_EXP,
@@ -135,8 +135,8 @@ exports.MainnetSpotMarkets = [
135
135
  {
136
136
  symbol: 'bSOL',
137
137
  marketIndex: 8,
138
- oracle: new web3_js_1.PublicKey('AFrYBhb5wKQtxRS9UA9YRS4V3dwFm7SqmS6DHKq6YVgo'),
139
- oracleSource: __1.OracleSource.PYTH,
138
+ oracle: new web3_js_1.PublicKey('BmDWPMsytWmYkh9n6o7m79eVshVYf2B5GVaqQ2EWKnGH'),
139
+ oracleSource: __1.OracleSource.PYTH_PULL,
140
140
  mint: new web3_js_1.PublicKey('bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1'),
141
141
  precision: new __1.BN(10).pow(numericConstants_1.NINE),
142
142
  precisionExp: numericConstants_1.NINE,
@@ -146,8 +146,8 @@ exports.MainnetSpotMarkets = [
146
146
  {
147
147
  symbol: 'JTO',
148
148
  marketIndex: 9,
149
- oracle: new web3_js_1.PublicKey('D8UUgr8a3aR3yUeHLu7v8FWK7E8Y5sSU7qrYBXUJXBQ5'),
150
- oracleSource: __1.OracleSource.PYTH,
149
+ oracle: new web3_js_1.PublicKey('Ffq6ACJ17NAgaxC6ocfMzVXL3K61qxB2xHg6WUawWPfP'),
150
+ oracleSource: __1.OracleSource.PYTH_PULL,
151
151
  mint: new web3_js_1.PublicKey('jtojtomepa8beP8AuQc6eXt5FriJwfFMwQx2v2f9mCL'),
152
152
  precision: new __1.BN(10).pow(numericConstants_1.NINE),
153
153
  precisionExp: numericConstants_1.NINE,
@@ -182,8 +182,8 @@ exports.MainnetSpotMarkets = [
182
182
  {
183
183
  symbol: 'RNDR',
184
184
  marketIndex: 12,
185
- oracle: new web3_js_1.PublicKey('CYGfrBJB9HgLf9iZyN4aH5HvUAi2htQ4MjPxeXMf4Egn'),
186
- oracleSource: __1.OracleSource.PYTH,
185
+ oracle: new web3_js_1.PublicKey('F3mPHRtJqqq57JPDBmUwUVhpyPLmjE5dAzDfpVgpFkug'),
186
+ oracleSource: __1.OracleSource.PYTH_PULL,
187
187
  mint: new web3_js_1.PublicKey('rndrizKT3MK1iimdxRdWabcF7Zg7AR5T4nud4EkHBof'),
188
188
  precision: new __1.BN(10).pow(numericConstants_1.EIGHT),
189
189
  precisionExp: numericConstants_1.EIGHT,
@@ -194,8 +194,8 @@ exports.MainnetSpotMarkets = [
194
194
  {
195
195
  symbol: 'W',
196
196
  marketIndex: 13,
197
- oracle: new web3_js_1.PublicKey('H9j8CT1bFiWHaZUPMooEaxMRHdWdJ5T9CzFn41z96JHW'),
198
- oracleSource: __1.OracleSource.PYTH,
197
+ oracle: new web3_js_1.PublicKey('4HbitGsdcFbtFotmYscikQFAAKJ3nYx4t7sV7fTvsk8U'),
198
+ oracleSource: __1.OracleSource.PYTH_PULL,
199
199
  mint: new web3_js_1.PublicKey('85VBFQZC9TZkfaptBWjvUw7YbZjy52A6mjtPGjstQAmQ'),
200
200
  precision: new __1.BN(10).pow(numericConstants_1.SIX),
201
201
  precisionExp: numericConstants_1.SIX,
@@ -206,8 +206,8 @@ exports.MainnetSpotMarkets = [
206
206
  {
207
207
  symbol: 'TNSR',
208
208
  marketIndex: 14,
209
- oracle: new web3_js_1.PublicKey('7Cfyymx49ipGsgEsCA2XygAB2DUsan4C6Cyb5c8oR5st'),
210
- oracleSource: __1.OracleSource.SWITCHBOARD,
209
+ oracle: new web3_js_1.PublicKey('13jpjpVyU5hGpjsZ4HzCcmBo85wze4N8Au7U6cC3GMip'),
210
+ oracleSource: __1.OracleSource.PYTH_PULL,
211
211
  mint: new web3_js_1.PublicKey('TNSRxcUxoT9xBG3de7PiJyTDYu7kskLqcpddxnEJAS6'),
212
212
  precision: new __1.BN(10).pow(numericConstants_1.NINE),
213
213
  precisionExp: numericConstants_1.NINE,
@@ -230,8 +230,8 @@ exports.MainnetSpotMarkets = [
230
230
  {
231
231
  symbol: 'INF',
232
232
  marketIndex: 16,
233
- oracle: new web3_js_1.PublicKey('6AQHz9mpGNjyVafcWdqzzgsJq14Cs8gG6MiQKmdAgCuP'),
234
- oracleSource: __1.OracleSource.SWITCHBOARD,
233
+ oracle: new web3_js_1.PublicKey('B7RUYg2zF6UdUSHv2RmpnriPVJccYWojgFydNS1NY5F8'),
234
+ oracleSource: __1.OracleSource.PYTH_PULL,
235
235
  mint: new web3_js_1.PublicKey('5oVNBeEEQvYi1cX3ir8Dx5n1P7pdxydbGF2X4TxVusJm'),
236
236
  precision: new __1.BN(10).pow(numericConstants_1.NINE),
237
237
  precisionExp: numericConstants_1.NINE,
@@ -251,12 +251,13 @@ exports.MainnetSpotMarkets = [
251
251
  {
252
252
  symbol: 'USDY',
253
253
  marketIndex: 18,
254
- oracle: new web3_js_1.PublicKey('DiqUGbq5CV8Tjcae1whjrX97qPo6gU7BKAvKNFc2vrX8'),
255
- oracleSource: __1.OracleSource.SWITCHBOARD,
254
+ oracle: new web3_js_1.PublicKey('BPTQgHV4y2x4jvKPPkkd9aS8jY7L3DGZBwjEZC8Vm27o'),
255
+ oracleSource: __1.OracleSource.PYTH_PULL,
256
256
  mint: new web3_js_1.PublicKey('A1KLoBrKBde8Ty9qtNQUtq3C2ortoC3u7twggz7sEto6'),
257
257
  precision: new __1.BN(10).pow(numericConstants_1.SIX),
258
258
  precisionExp: numericConstants_1.SIX,
259
259
  launchTs: 1718811089000,
260
+ pythFeedId: '0xe393449f6aff8a4b6d3e1165a7c9ebec103685f3b41e60db4277b5b6d10e7326',
260
261
  },
261
262
  {
262
263
  symbol: 'JLP',
@@ -271,7 +272,7 @@ exports.MainnetSpotMarkets = [
271
272
  {
272
273
  symbol: 'POPCAT',
273
274
  marketIndex: 20,
274
- oracle: new web3_js_1.PublicKey('2stQe1XLGkuTZ22gQrgZKsb93iG9mWXSLfANMPRjs5Ky'),
275
+ oracle: new web3_js_1.PublicKey('3GjpjC8TWsPqjyFSiR7saGxgzD8zqYJNsBnWpenZPEBy'),
275
276
  oracleSource: __1.OracleSource.SWITCHBOARD,
276
277
  mint: new web3_js_1.PublicKey('7GCihgDB8fe6KNjn2MYtkzZcRjQy3t9GHdC8uHYmW2hr'),
277
278
  precision: new __1.BN(10).pow(numericConstants_1.NINE),
@@ -2244,6 +2244,42 @@
2244
2244
  ],
2245
2245
  "args": []
2246
2246
  },
2247
+ {
2248
+ "name": "updateUserGovTokenInsuranceStake",
2249
+ "accounts": [
2250
+ {
2251
+ "name": "state",
2252
+ "isMut": false,
2253
+ "isSigner": false
2254
+ },
2255
+ {
2256
+ "name": "spotMarket",
2257
+ "isMut": false,
2258
+ "isSigner": false
2259
+ },
2260
+ {
2261
+ "name": "insuranceFundStake",
2262
+ "isMut": true,
2263
+ "isSigner": false
2264
+ },
2265
+ {
2266
+ "name": "userStats",
2267
+ "isMut": true,
2268
+ "isSigner": false
2269
+ },
2270
+ {
2271
+ "name": "authority",
2272
+ "isMut": false,
2273
+ "isSigner": true
2274
+ },
2275
+ {
2276
+ "name": "insuranceFundVault",
2277
+ "isMut": true,
2278
+ "isSigner": false
2279
+ }
2280
+ ],
2281
+ "args": []
2282
+ },
2247
2283
  {
2248
2284
  "name": "initializeInsuranceFundStake",
2249
2285
  "accounts": [
@@ -5079,6 +5115,155 @@
5079
5115
  }
5080
5116
  ]
5081
5117
  },
5118
+ {
5119
+ "name": "updatePerpMarketFuel",
5120
+ "accounts": [
5121
+ {
5122
+ "name": "admin",
5123
+ "isMut": false,
5124
+ "isSigner": true
5125
+ },
5126
+ {
5127
+ "name": "state",
5128
+ "isMut": false,
5129
+ "isSigner": false
5130
+ },
5131
+ {
5132
+ "name": "perpMarket",
5133
+ "isMut": true,
5134
+ "isSigner": false
5135
+ }
5136
+ ],
5137
+ "args": [
5138
+ {
5139
+ "name": "fuelBoostTaker",
5140
+ "type": {
5141
+ "option": "u8"
5142
+ }
5143
+ },
5144
+ {
5145
+ "name": "fuelBoostMaker",
5146
+ "type": {
5147
+ "option": "u8"
5148
+ }
5149
+ },
5150
+ {
5151
+ "name": "fuelBoostPosition",
5152
+ "type": {
5153
+ "option": "u8"
5154
+ }
5155
+ }
5156
+ ]
5157
+ },
5158
+ {
5159
+ "name": "updateSpotMarketFuel",
5160
+ "accounts": [
5161
+ {
5162
+ "name": "admin",
5163
+ "isMut": false,
5164
+ "isSigner": true
5165
+ },
5166
+ {
5167
+ "name": "state",
5168
+ "isMut": false,
5169
+ "isSigner": false
5170
+ },
5171
+ {
5172
+ "name": "spotMarket",
5173
+ "isMut": true,
5174
+ "isSigner": false
5175
+ }
5176
+ ],
5177
+ "args": [
5178
+ {
5179
+ "name": "fuelBoostDeposits",
5180
+ "type": {
5181
+ "option": "u8"
5182
+ }
5183
+ },
5184
+ {
5185
+ "name": "fuelBoostBorrows",
5186
+ "type": {
5187
+ "option": "u8"
5188
+ }
5189
+ },
5190
+ {
5191
+ "name": "fuelBoostTaker",
5192
+ "type": {
5193
+ "option": "u8"
5194
+ }
5195
+ },
5196
+ {
5197
+ "name": "fuelBoostMaker",
5198
+ "type": {
5199
+ "option": "u8"
5200
+ }
5201
+ },
5202
+ {
5203
+ "name": "fuelBoostInsurance",
5204
+ "type": {
5205
+ "option": "u8"
5206
+ }
5207
+ }
5208
+ ]
5209
+ },
5210
+ {
5211
+ "name": "initUserFuel",
5212
+ "accounts": [
5213
+ {
5214
+ "name": "admin",
5215
+ "isMut": false,
5216
+ "isSigner": true
5217
+ },
5218
+ {
5219
+ "name": "state",
5220
+ "isMut": false,
5221
+ "isSigner": false
5222
+ },
5223
+ {
5224
+ "name": "user",
5225
+ "isMut": true,
5226
+ "isSigner": false
5227
+ },
5228
+ {
5229
+ "name": "userStats",
5230
+ "isMut": true,
5231
+ "isSigner": false
5232
+ }
5233
+ ],
5234
+ "args": [
5235
+ {
5236
+ "name": "fuelBoostDeposits",
5237
+ "type": {
5238
+ "option": "u32"
5239
+ }
5240
+ },
5241
+ {
5242
+ "name": "fuelBoostBorrows",
5243
+ "type": {
5244
+ "option": "u32"
5245
+ }
5246
+ },
5247
+ {
5248
+ "name": "fuelBoostTaker",
5249
+ "type": {
5250
+ "option": "u32"
5251
+ }
5252
+ },
5253
+ {
5254
+ "name": "fuelBoostMaker",
5255
+ "type": {
5256
+ "option": "u32"
5257
+ }
5258
+ },
5259
+ {
5260
+ "name": "fuelBoostInsurance",
5261
+ "type": {
5262
+ "option": "u32"
5263
+ }
5264
+ }
5265
+ ]
5266
+ },
5082
5267
  {
5083
5268
  "name": "updateAdmin",
5084
5269
  "accounts": [
@@ -5918,12 +6103,36 @@
5918
6103
  ],
5919
6104
  "type": "i16"
5920
6105
  },
6106
+ {
6107
+ "name": "fuelBoostPosition",
6108
+ "docs": [
6109
+ "fuel multiplier for perp funding",
6110
+ "precision: 10"
6111
+ ],
6112
+ "type": "u8"
6113
+ },
6114
+ {
6115
+ "name": "fuelBoostTaker",
6116
+ "docs": [
6117
+ "fuel multiplier for perp taker",
6118
+ "precision: 10"
6119
+ ],
6120
+ "type": "u8"
6121
+ },
6122
+ {
6123
+ "name": "fuelBoostMaker",
6124
+ "docs": [
6125
+ "fuel multiplier for perp maker",
6126
+ "precision: 10"
6127
+ ],
6128
+ "type": "u8"
6129
+ },
5921
6130
  {
5922
6131
  "name": "padding",
5923
6132
  "type": {
5924
6133
  "array": [
5925
6134
  "u8",
5926
- 46
6135
+ 43
5927
6136
  ]
5928
6137
  }
5929
6138
  }
@@ -6376,12 +6585,52 @@
6376
6585
  ],
6377
6586
  "type": "u8"
6378
6587
  },
6588
+ {
6589
+ "name": "fuelBoostDeposits",
6590
+ "docs": [
6591
+ "fuel multiplier for spot deposits",
6592
+ "precision: 10"
6593
+ ],
6594
+ "type": "u8"
6595
+ },
6596
+ {
6597
+ "name": "fuelBoostBorrows",
6598
+ "docs": [
6599
+ "fuel multiplier for spot borrows",
6600
+ "precision: 10"
6601
+ ],
6602
+ "type": "u8"
6603
+ },
6604
+ {
6605
+ "name": "fuelBoostTaker",
6606
+ "docs": [
6607
+ "fuel multiplier for spot taker",
6608
+ "precision: 10"
6609
+ ],
6610
+ "type": "u8"
6611
+ },
6612
+ {
6613
+ "name": "fuelBoostMaker",
6614
+ "docs": [
6615
+ "fuel multiplier for spot maker",
6616
+ "precision: 10"
6617
+ ],
6618
+ "type": "u8"
6619
+ },
6620
+ {
6621
+ "name": "fuelBoostInsurance",
6622
+ "docs": [
6623
+ "fuel multiplier for spot insurance stake",
6624
+ "precision: 10"
6625
+ ],
6626
+ "type": "u8"
6627
+ },
6379
6628
  {
6380
6629
  "name": "padding",
6381
6630
  "type": {
6382
6631
  "array": [
6383
6632
  "u8",
6384
- 47
6633
+ 42
6385
6634
  ]
6386
6635
  }
6387
6636
  }
@@ -6729,12 +6978,25 @@
6729
6978
  ],
6730
6979
  "type": "bool"
6731
6980
  },
6981
+ {
6982
+ "name": "padding1",
6983
+ "type": {
6984
+ "array": [
6985
+ "u8",
6986
+ 5
6987
+ ]
6988
+ }
6989
+ },
6990
+ {
6991
+ "name": "lastFuelBonusUpdateTs",
6992
+ "type": "u32"
6993
+ },
6732
6994
  {
6733
6995
  "name": "padding",
6734
6996
  "type": {
6735
6997
  "array": [
6736
6998
  "u8",
6737
- 21
6999
+ 12
6738
7000
  ]
6739
7001
  }
6740
7002
  }
@@ -6855,12 +7117,77 @@
6855
7117
  "name": "disableUpdatePerpBidAskTwap",
6856
7118
  "type": "bool"
6857
7119
  },
7120
+ {
7121
+ "name": "padding1",
7122
+ "type": {
7123
+ "array": [
7124
+ "u8",
7125
+ 2
7126
+ ]
7127
+ }
7128
+ },
7129
+ {
7130
+ "name": "fuelInsurance",
7131
+ "docs": [
7132
+ "accumulated fuel for token amounts of insurance"
7133
+ ],
7134
+ "type": "u32"
7135
+ },
7136
+ {
7137
+ "name": "fuelDeposits",
7138
+ "docs": [
7139
+ "accumulated fuel for notional of deposits"
7140
+ ],
7141
+ "type": "u32"
7142
+ },
7143
+ {
7144
+ "name": "fuelBorrows",
7145
+ "docs": [
7146
+ "accumulate fuel bonus for notional of borrows"
7147
+ ],
7148
+ "type": "u32"
7149
+ },
7150
+ {
7151
+ "name": "fuelPositions",
7152
+ "docs": [
7153
+ "accumulated fuel for perp open interest"
7154
+ ],
7155
+ "type": "u32"
7156
+ },
7157
+ {
7158
+ "name": "fuelTaker",
7159
+ "docs": [
7160
+ "accumulate fuel bonus for taker volume"
7161
+ ],
7162
+ "type": "u32"
7163
+ },
7164
+ {
7165
+ "name": "fuelMaker",
7166
+ "docs": [
7167
+ "accumulate fuel bonus for maker volume"
7168
+ ],
7169
+ "type": "u32"
7170
+ },
7171
+ {
7172
+ "name": "ifStakedGovTokenAmount",
7173
+ "docs": [
7174
+ "The amount of tokens staked in the governance spot markets if"
7175
+ ],
7176
+ "type": "u64"
7177
+ },
7178
+ {
7179
+ "name": "lastFuelIfBonusUpdateTs",
7180
+ "docs": [
7181
+ "last unix ts user stats data was used to update if fuel (u32 to save space)"
7182
+ ],
7183
+ "type": "u32"
7184
+ },
6858
7185
  {
6859
7186
  "name": "padding",
6860
7187
  "type": {
6861
7188
  "array": [
6862
7189
  "u8",
6863
- 50
7190
+ 12
6864
7191
  ]
6865
7192
  }
6866
7193
  }
package/lib/index.d.ts CHANGED
@@ -64,6 +64,7 @@ export * from './slot/SlotSubscriber';
64
64
  export * from './wallet';
65
65
  export * from './types';
66
66
  export * from './math/utils';
67
+ export * from './math/fuel';
67
68
  export * from './config';
68
69
  export * from './constants/numericConstants';
69
70
  export * from './serum/serumSubscriber';
package/lib/index.js CHANGED
@@ -87,6 +87,7 @@ __exportStar(require("./slot/SlotSubscriber"), exports);
87
87
  __exportStar(require("./wallet"), exports);
88
88
  __exportStar(require("./types"), exports);
89
89
  __exportStar(require("./math/utils"), exports);
90
+ __exportStar(require("./math/fuel"), exports);
90
91
  __exportStar(require("./config"), exports);
91
92
  __exportStar(require("./constants/numericConstants"), exports);
92
93
  __exportStar(require("./serum/serumSubscriber"), exports);
@@ -0,0 +1,6 @@
1
+ /// <reference types="bn.js" />
2
+ import { BN } from '@coral-xyz/anchor';
3
+ import { SpotMarketAccount, PerpMarketAccount } from '..';
4
+ export declare function calculateInsuranceFuelBonus(spotMarket: SpotMarketAccount, tokenStakeAmount: BN, fuelBonusNumerator: BN): BN;
5
+ export declare function calculateSpotFuelBonus(spotMarket: SpotMarketAccount, signedTokenValue: BN, fuelBonusNumerator: BN): BN;
6
+ export declare function calculatePerpFuelBonus(perpMarket: PerpMarketAccount, baseAssetValue: BN, fuelBonusNumerator: BN): BN;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calculatePerpFuelBonus = exports.calculateSpotFuelBonus = exports.calculateInsuranceFuelBonus = void 0;
4
+ const anchor_1 = require("@coral-xyz/anchor");
5
+ const numericConstants_1 = require("../constants/numericConstants");
6
+ function calculateInsuranceFuelBonus(spotMarket, tokenStakeAmount, fuelBonusNumerator) {
7
+ const result = tokenStakeAmount
8
+ .abs()
9
+ .mul(fuelBonusNumerator)
10
+ .mul(new anchor_1.BN(spotMarket.fuelBoostInsurance))
11
+ .div(numericConstants_1.FUEL_WINDOW)
12
+ .div(numericConstants_1.QUOTE_PRECISION.div(new anchor_1.BN(10)));
13
+ return result;
14
+ }
15
+ exports.calculateInsuranceFuelBonus = calculateInsuranceFuelBonus;
16
+ function calculateSpotFuelBonus(spotMarket, signedTokenValue, fuelBonusNumerator) {
17
+ let result;
18
+ if (signedTokenValue.abs().lte(numericConstants_1.QUOTE_PRECISION)) {
19
+ result = numericConstants_1.ZERO;
20
+ }
21
+ else if (signedTokenValue.gt(new anchor_1.BN(0))) {
22
+ result = signedTokenValue
23
+ .abs()
24
+ .mul(fuelBonusNumerator)
25
+ .mul(new anchor_1.BN(spotMarket.fuelBoostDeposits))
26
+ .div(numericConstants_1.FUEL_WINDOW)
27
+ .div(numericConstants_1.QUOTE_PRECISION.div(new anchor_1.BN(10)));
28
+ }
29
+ else {
30
+ result = signedTokenValue
31
+ .abs()
32
+ .mul(fuelBonusNumerator)
33
+ .mul(new anchor_1.BN(spotMarket.fuelBoostBorrows))
34
+ .div(numericConstants_1.FUEL_WINDOW)
35
+ .div(numericConstants_1.QUOTE_PRECISION.div(new anchor_1.BN(10)));
36
+ }
37
+ return result;
38
+ }
39
+ exports.calculateSpotFuelBonus = calculateSpotFuelBonus;
40
+ function calculatePerpFuelBonus(perpMarket, baseAssetValue, fuelBonusNumerator) {
41
+ let result;
42
+ if (baseAssetValue.abs().lte(numericConstants_1.QUOTE_PRECISION)) {
43
+ result = new anchor_1.BN(0);
44
+ }
45
+ else {
46
+ result = baseAssetValue
47
+ .abs()
48
+ .mul(fuelBonusNumerator)
49
+ .mul(new anchor_1.BN(perpMarket.fuelBoostPosition))
50
+ .div(numericConstants_1.FUEL_WINDOW)
51
+ .div(numericConstants_1.QUOTE_PRECISION.div(new anchor_1.BN(10)));
52
+ }
53
+ return result;
54
+ }
55
+ exports.calculatePerpFuelBonus = calculatePerpFuelBonus;
package/lib/types.d.ts CHANGED
@@ -731,6 +731,9 @@ export type PerpMarketAccount = {
731
731
  quoteSpotMarketIndex: number;
732
732
  feeAdjustment: number;
733
733
  pausedOperations: number;
734
+ fuelBoostTaker: number;
735
+ fuelBoostMaker: number;
736
+ fuelBoostPosition: number;
734
737
  };
735
738
  export type HistoricalOracleData = {
736
739
  lastOraclePrice: BN;
@@ -812,6 +815,11 @@ export type SpotMarketAccount = {
812
815
  ifPausedOperations: number;
813
816
  maxTokenBorrowsFraction: number;
814
817
  minBorrowRate: number;
818
+ fuelBoostDeposits: number;
819
+ fuelBoostBorrows: number;
820
+ fuelBoostTaker: number;
821
+ fuelBoostMaker: number;
822
+ fuelBoostInsurance: number;
815
823
  };
816
824
  export type PoolBalance = {
817
825
  scaledBalance: BN;
@@ -939,6 +947,14 @@ export type UserStatsAccount = {
939
947
  isReferrer: boolean;
940
948
  authority: PublicKey;
941
949
  ifStakedQuoteAssetAmount: BN;
950
+ lastFuelBonusUpdateTs: number;
951
+ fuelInsurance: number;
952
+ fuelDeposits: number;
953
+ fuelBorrows: number;
954
+ fuelPositions: number;
955
+ fuelTaker: number;
956
+ fuelMaker: number;
957
+ ifStakedGovTokenAmount: BN;
942
958
  };
943
959
  export type UserAccount = {
944
960
  authority: PublicKey;
@@ -967,6 +983,7 @@ export type UserAccount = {
967
983
  hasOpenOrder: boolean;
968
984
  openAuctions: number;
969
985
  hasOpenAuction: boolean;
986
+ lastFuelBonusUpdateTs: number;
970
987
  };
971
988
  export type SpotPosition = {
972
989
  marketIndex: number;
package/lib/user.d.ts CHANGED
@@ -136,6 +136,14 @@ export declare class User {
136
136
  * @returns : Precision QUOTE_PRECISION
137
137
  */
138
138
  getUnrealizedFundingPNL(marketIndex?: number): BN;
139
+ getFuelBonus(now: BN, includeSettled?: boolean, includeUnsettled?: boolean): {
140
+ depositFuel: BN;
141
+ borrowFuel: BN;
142
+ positionFuel: BN;
143
+ takerFuel: BN;
144
+ makerFuel: BN;
145
+ insuranceFuel: BN;
146
+ };
139
147
  getSpotMarketAssetAndLiabilityValue(marketIndex?: number, marginCategory?: MarginCategory, liquidationBuffer?: BN, includeOpenOrders?: boolean, strict?: boolean, now?: BN): {
140
148
  totalAssetValue: BN;
141
149
  totalLiabilityValue: BN;