@drift-labs/sdk 2.25.3 → 2.26.0-beta.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.
Files changed (90) hide show
  1. package/lib/accounts/pollingUserAccountSubscriber.d.ts +5 -4
  2. package/lib/accounts/pollingUserAccountSubscriber.js +35 -48
  3. package/lib/accounts/pollingUserStatsAccountSubscriber.d.ts +4 -4
  4. package/lib/accounts/pollingUserStatsAccountSubscriber.js +30 -47
  5. package/lib/accounts/types.d.ts +2 -1
  6. package/lib/accounts/webSocketAccountSubscriber.d.ts +1 -1
  7. package/lib/accounts/webSocketAccountSubscriber.js +4 -3
  8. package/lib/accounts/webSocketUserAccountSubscriber.d.ts +1 -0
  9. package/lib/accounts/webSocketUserAccountSubscriber.js +9 -0
  10. package/lib/addresses/pda.d.ts +2 -0
  11. package/lib/addresses/pda.js +8 -1
  12. package/lib/adminClient.d.ts +2 -0
  13. package/lib/adminClient.js +20 -0
  14. package/lib/constants/numericConstants.d.ts +61 -59
  15. package/lib/constants/spotMarkets.d.ts +1 -0
  16. package/lib/dlob/DLOB.d.ts +1 -0
  17. package/lib/dlob/DLOBApiClient.d.ts +14 -0
  18. package/lib/dlob/DLOBApiClient.js +34 -0
  19. package/lib/dlob/DLOBNode.d.ts +1 -0
  20. package/lib/dlob/DLOBSubscriber.d.ts +19 -0
  21. package/lib/dlob/DLOBSubscriber.js +42 -0
  22. package/lib/dlob/NodeList.d.ts +1 -0
  23. package/lib/dlob/types.d.ts +16 -0
  24. package/lib/dlob/types.js +2 -0
  25. package/lib/driftClient.d.ts +14 -10
  26. package/lib/driftClient.js +124 -28
  27. package/lib/examples/loadDlob.js +2 -4
  28. package/lib/factory/bigNum.d.ts +8 -7
  29. package/lib/idl/drift.json +264 -82
  30. package/lib/index.d.ts +2 -0
  31. package/lib/index.js +2 -0
  32. package/lib/math/amm.d.ts +2 -1
  33. package/lib/math/auction.d.ts +1 -0
  34. package/lib/math/conversion.d.ts +2 -1
  35. package/lib/math/funding.d.ts +1 -0
  36. package/lib/math/insurance.d.ts +1 -0
  37. package/lib/math/margin.d.ts +1 -0
  38. package/lib/math/market.d.ts +1 -0
  39. package/lib/math/oracles.d.ts +1 -0
  40. package/lib/math/orders.d.ts +1 -0
  41. package/lib/math/position.d.ts +1 -0
  42. package/lib/math/repeg.d.ts +1 -0
  43. package/lib/math/spotBalance.d.ts +1 -0
  44. package/lib/math/spotMarket.d.ts +1 -0
  45. package/lib/math/spotPosition.d.ts +1 -0
  46. package/lib/math/trade.d.ts +1 -0
  47. package/lib/math/utils.d.ts +1 -0
  48. package/lib/oracles/pythClient.d.ts +2 -1
  49. package/lib/oracles/types.d.ts +1 -0
  50. package/lib/orderParams.d.ts +1 -0
  51. package/lib/serum/serumSubscriber.d.ts +1 -0
  52. package/lib/slot/SlotSubscriber.js +3 -0
  53. package/lib/tokenFaucet.d.ts +1 -0
  54. package/lib/tx/retryTxSender.d.ts +2 -1
  55. package/lib/tx/retryTxSender.js +5 -1
  56. package/lib/tx/types.d.ts +4 -1
  57. package/lib/types.d.ts +12 -0
  58. package/lib/user.d.ts +1 -0
  59. package/lib/userMap/userMap.d.ts +17 -6
  60. package/lib/userMap/userMap.js +74 -46
  61. package/lib/userMap/userStatsMap.d.ts +6 -3
  62. package/lib/userMap/userStatsMap.js +30 -30
  63. package/package.json +2 -1
  64. package/src/accounts/pollingUserAccountSubscriber.ts +51 -63
  65. package/src/accounts/pollingUserStatsAccountSubscriber.ts +46 -62
  66. package/src/accounts/types.ts +2 -1
  67. package/src/accounts/webSocketAccountSubscriber.ts +4 -3
  68. package/src/accounts/webSocketUserAccountSubscriber.ts +10 -0
  69. package/src/addresses/pda.ts +13 -0
  70. package/src/adminClient.ts +34 -0
  71. package/src/dlob/DLOBApiClient.ts +37 -0
  72. package/src/dlob/DLOBSubscriber.ts +57 -0
  73. package/src/dlob/types.ts +20 -0
  74. package/src/driftClient.ts +216 -59
  75. package/src/examples/loadDlob.ts +2 -4
  76. package/src/idl/drift.json +264 -82
  77. package/src/index.ts +2 -0
  78. package/src/slot/SlotSubscriber.ts +4 -0
  79. package/src/tx/retryTxSender.ts +19 -2
  80. package/src/tx/types.ts +13 -0
  81. package/src/types.ts +12 -0
  82. package/src/userMap/userMap.ts +111 -60
  83. package/src/userMap/userStatsMap.ts +43 -44
  84. package/tests/dlob/helpers.ts +3 -1
  85. package/src/assert/assert.js +0 -9
  86. package/src/token/index.js +0 -38
  87. package/src/util/computeUnits.js +0 -27
  88. package/src/util/getTokenAddress.js +0 -9
  89. package/src/util/promiseTimeout.js +0 -14
  90. package/src/util/tps.js +0 -27
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.25.3",
2
+ "version": "2.26.0-beta.0",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
@@ -2293,6 +2293,95 @@
2293
2293
  }
2294
2294
  ]
2295
2295
  },
2296
+ {
2297
+ "name": "initializePhoenixFulfillmentConfig",
2298
+ "accounts": [
2299
+ {
2300
+ "name": "baseSpotMarket",
2301
+ "isMut": false,
2302
+ "isSigner": false
2303
+ },
2304
+ {
2305
+ "name": "quoteSpotMarket",
2306
+ "isMut": false,
2307
+ "isSigner": false
2308
+ },
2309
+ {
2310
+ "name": "state",
2311
+ "isMut": true,
2312
+ "isSigner": false
2313
+ },
2314
+ {
2315
+ "name": "phoenixProgram",
2316
+ "isMut": false,
2317
+ "isSigner": false
2318
+ },
2319
+ {
2320
+ "name": "phoenixMarket",
2321
+ "isMut": false,
2322
+ "isSigner": false
2323
+ },
2324
+ {
2325
+ "name": "driftSigner",
2326
+ "isMut": false,
2327
+ "isSigner": false
2328
+ },
2329
+ {
2330
+ "name": "phoenixFulfillmentConfig",
2331
+ "isMut": true,
2332
+ "isSigner": false
2333
+ },
2334
+ {
2335
+ "name": "admin",
2336
+ "isMut": true,
2337
+ "isSigner": true
2338
+ },
2339
+ {
2340
+ "name": "rent",
2341
+ "isMut": false,
2342
+ "isSigner": false
2343
+ },
2344
+ {
2345
+ "name": "systemProgram",
2346
+ "isMut": false,
2347
+ "isSigner": false
2348
+ }
2349
+ ],
2350
+ "args": [
2351
+ {
2352
+ "name": "marketIndex",
2353
+ "type": "u16"
2354
+ }
2355
+ ]
2356
+ },
2357
+ {
2358
+ "name": "phoenixFulfillmentConfigStatus",
2359
+ "accounts": [
2360
+ {
2361
+ "name": "state",
2362
+ "isMut": false,
2363
+ "isSigner": false
2364
+ },
2365
+ {
2366
+ "name": "phoenixFulfillmentConfig",
2367
+ "isMut": true,
2368
+ "isSigner": false
2369
+ },
2370
+ {
2371
+ "name": "admin",
2372
+ "isMut": true,
2373
+ "isSigner": true
2374
+ }
2375
+ ],
2376
+ "args": [
2377
+ {
2378
+ "name": "status",
2379
+ "type": {
2380
+ "defined": "SpotFulfillmentConfigStatus"
2381
+ }
2382
+ }
2383
+ ]
2384
+ },
2296
2385
  {
2297
2386
  "name": "updateSerumVault",
2298
2387
  "accounts": [
@@ -4002,6 +4091,140 @@
4002
4091
  }
4003
4092
  ],
4004
4093
  "accounts": [
4094
+ {
4095
+ "name": "PhoenixV1FulfillmentConfig",
4096
+ "type": {
4097
+ "kind": "struct",
4098
+ "fields": [
4099
+ {
4100
+ "name": "pubkey",
4101
+ "type": "publicKey"
4102
+ },
4103
+ {
4104
+ "name": "phoenixProgramId",
4105
+ "type": "publicKey"
4106
+ },
4107
+ {
4108
+ "name": "phoenixLogAuthority",
4109
+ "type": "publicKey"
4110
+ },
4111
+ {
4112
+ "name": "phoenixMarket",
4113
+ "type": "publicKey"
4114
+ },
4115
+ {
4116
+ "name": "phoenixBaseVault",
4117
+ "type": "publicKey"
4118
+ },
4119
+ {
4120
+ "name": "phoenixQuoteVault",
4121
+ "type": "publicKey"
4122
+ },
4123
+ {
4124
+ "name": "marketIndex",
4125
+ "type": "u16"
4126
+ },
4127
+ {
4128
+ "name": "fulfillmentType",
4129
+ "type": {
4130
+ "defined": "SpotFulfillmentType"
4131
+ }
4132
+ },
4133
+ {
4134
+ "name": "status",
4135
+ "type": {
4136
+ "defined": "SpotFulfillmentConfigStatus"
4137
+ }
4138
+ },
4139
+ {
4140
+ "name": "padding",
4141
+ "type": {
4142
+ "array": [
4143
+ "u8",
4144
+ 4
4145
+ ]
4146
+ }
4147
+ }
4148
+ ]
4149
+ }
4150
+ },
4151
+ {
4152
+ "name": "SerumV3FulfillmentConfig",
4153
+ "type": {
4154
+ "kind": "struct",
4155
+ "fields": [
4156
+ {
4157
+ "name": "pubkey",
4158
+ "type": "publicKey"
4159
+ },
4160
+ {
4161
+ "name": "serumProgramId",
4162
+ "type": "publicKey"
4163
+ },
4164
+ {
4165
+ "name": "serumMarket",
4166
+ "type": "publicKey"
4167
+ },
4168
+ {
4169
+ "name": "serumRequestQueue",
4170
+ "type": "publicKey"
4171
+ },
4172
+ {
4173
+ "name": "serumEventQueue",
4174
+ "type": "publicKey"
4175
+ },
4176
+ {
4177
+ "name": "serumBids",
4178
+ "type": "publicKey"
4179
+ },
4180
+ {
4181
+ "name": "serumAsks",
4182
+ "type": "publicKey"
4183
+ },
4184
+ {
4185
+ "name": "serumBaseVault",
4186
+ "type": "publicKey"
4187
+ },
4188
+ {
4189
+ "name": "serumQuoteVault",
4190
+ "type": "publicKey"
4191
+ },
4192
+ {
4193
+ "name": "serumOpenOrders",
4194
+ "type": "publicKey"
4195
+ },
4196
+ {
4197
+ "name": "serumSignerNonce",
4198
+ "type": "u64"
4199
+ },
4200
+ {
4201
+ "name": "marketIndex",
4202
+ "type": "u16"
4203
+ },
4204
+ {
4205
+ "name": "fulfillmentType",
4206
+ "type": {
4207
+ "defined": "SpotFulfillmentType"
4208
+ }
4209
+ },
4210
+ {
4211
+ "name": "status",
4212
+ "type": {
4213
+ "defined": "SpotFulfillmentConfigStatus"
4214
+ }
4215
+ },
4216
+ {
4217
+ "name": "padding",
4218
+ "type": {
4219
+ "array": [
4220
+ "u8",
4221
+ 4
4222
+ ]
4223
+ }
4224
+ }
4225
+ ]
4226
+ }
4227
+ },
4005
4228
  {
4006
4229
  "name": "InsuranceFundStake",
4007
4230
  "type": {
@@ -4423,83 +4646,6 @@
4423
4646
  ]
4424
4647
  }
4425
4648
  },
4426
- {
4427
- "name": "SerumV3FulfillmentConfig",
4428
- "type": {
4429
- "kind": "struct",
4430
- "fields": [
4431
- {
4432
- "name": "pubkey",
4433
- "type": "publicKey"
4434
- },
4435
- {
4436
- "name": "serumProgramId",
4437
- "type": "publicKey"
4438
- },
4439
- {
4440
- "name": "serumMarket",
4441
- "type": "publicKey"
4442
- },
4443
- {
4444
- "name": "serumRequestQueue",
4445
- "type": "publicKey"
4446
- },
4447
- {
4448
- "name": "serumEventQueue",
4449
- "type": "publicKey"
4450
- },
4451
- {
4452
- "name": "serumBids",
4453
- "type": "publicKey"
4454
- },
4455
- {
4456
- "name": "serumAsks",
4457
- "type": "publicKey"
4458
- },
4459
- {
4460
- "name": "serumBaseVault",
4461
- "type": "publicKey"
4462
- },
4463
- {
4464
- "name": "serumQuoteVault",
4465
- "type": "publicKey"
4466
- },
4467
- {
4468
- "name": "serumOpenOrders",
4469
- "type": "publicKey"
4470
- },
4471
- {
4472
- "name": "serumSignerNonce",
4473
- "type": "u64"
4474
- },
4475
- {
4476
- "name": "marketIndex",
4477
- "type": "u16"
4478
- },
4479
- {
4480
- "name": "fulfillmentType",
4481
- "type": {
4482
- "defined": "SpotFulfillmentType"
4483
- }
4484
- },
4485
- {
4486
- "name": "status",
4487
- "type": {
4488
- "defined": "SpotFulfillmentConfigStatus"
4489
- }
4490
- },
4491
- {
4492
- "name": "padding",
4493
- "type": {
4494
- "array": [
4495
- "u8",
4496
- 4
4497
- ]
4498
- }
4499
- }
4500
- ]
4501
- }
4502
- },
4503
4649
  {
4504
4650
  "name": "State",
4505
4651
  "type": {
@@ -6212,6 +6358,9 @@
6212
6358
  },
6213
6359
  {
6214
6360
  "name": "Match"
6361
+ },
6362
+ {
6363
+ "name": "PhoenixV1"
6215
6364
  }
6216
6365
  ]
6217
6366
  }
@@ -6462,6 +6611,9 @@
6462
6611
  },
6463
6612
  {
6464
6613
  "name": "NoBorrowLiquidity"
6614
+ },
6615
+ {
6616
+ "name": "OrderFillWithPhoenix"
6465
6617
  }
6466
6618
  ]
6467
6619
  }
@@ -8531,13 +8683,13 @@
8531
8683
  },
8532
8684
  {
8533
8685
  "code": 6142,
8534
- "name": "FailedToFillOnSerum",
8535
- "msg": "FailedToFillOnSerum"
8686
+ "name": "FailedToFillOnExternalMarket",
8687
+ "msg": "FailedToFillOnExternalMarket"
8536
8688
  },
8537
8689
  {
8538
8690
  "code": 6143,
8539
- "name": "InvalidSerumFulfillmentConfig",
8540
- "msg": "InvalidSerumFulfillmentConfig"
8691
+ "name": "InvalidFulfillmentConfig",
8692
+ "msg": "InvalidFulfillmentConfig"
8541
8693
  },
8542
8694
  {
8543
8695
  "code": 6144,
@@ -9028,6 +9180,36 @@
9028
9180
  "code": 6241,
9029
9181
  "name": "InvalidSpotFulfillmentParams",
9030
9182
  "msg": "Invalid Spot Fulfillment Params"
9183
+ },
9184
+ {
9185
+ "code": 6242,
9186
+ "name": "FailedToGetMint",
9187
+ "msg": "Failed to Get Mint"
9188
+ },
9189
+ {
9190
+ "code": 6243,
9191
+ "name": "FailedPhoenixCPI",
9192
+ "msg": "FailedPhoenixCPI"
9193
+ },
9194
+ {
9195
+ "code": 6244,
9196
+ "name": "FailedToDeserializePhoenixMarket",
9197
+ "msg": "FailedToDeserializePhoenixMarket"
9198
+ },
9199
+ {
9200
+ "code": 6245,
9201
+ "name": "InvalidPricePrecision",
9202
+ "msg": "InvalidPricePrecision"
9203
+ },
9204
+ {
9205
+ "code": 6246,
9206
+ "name": "InvalidPhoenixProgram",
9207
+ "msg": "InvalidPhoenixProgram"
9208
+ },
9209
+ {
9210
+ "code": 6247,
9211
+ "name": "InvalidPhoenixMarket",
9212
+ "msg": "InvalidPhoenixMarket"
9031
9213
  }
9032
9214
  ]
9033
9215
  }
package/lib/index.d.ts CHANGED
@@ -64,6 +64,8 @@ export * from './dlob/DLOB';
64
64
  export * from './dlob/DLOBNode';
65
65
  export * from './dlob/DLOBOrders';
66
66
  export * from './dlob/NodeList';
67
+ export * from './dlob/DLOBSubscriber';
68
+ export * from './dlob/types';
67
69
  export * from './userMap/userMap';
68
70
  export * from './userMap/userStatsMap';
69
71
  export * from './math/bankruptcy';
package/lib/index.js CHANGED
@@ -88,6 +88,8 @@ __exportStar(require("./dlob/DLOB"), exports);
88
88
  __exportStar(require("./dlob/DLOBNode"), exports);
89
89
  __exportStar(require("./dlob/DLOBOrders"), exports);
90
90
  __exportStar(require("./dlob/NodeList"), exports);
91
+ __exportStar(require("./dlob/DLOBSubscriber"), exports);
92
+ __exportStar(require("./dlob/types"), exports);
91
93
  __exportStar(require("./userMap/userMap"), exports);
92
94
  __exportStar(require("./userMap/userStatsMap"), exports);
93
95
  __exportStar(require("./math/bankruptcy"), exports);
package/lib/math/amm.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { BN } from '@coral-xyz/anchor';
2
3
  import { AMM, PositionDirection, SwapDirection, PerpMarketAccount } from '../types';
3
4
  import { OraclePriceData } from '../oracles/types';
@@ -86,7 +87,7 @@ export declare function getSwapDirection(inputAssetType: AssetType, positionDire
86
87
  * @param market
87
88
  * @returns cost : Precision PRICE_PRECISION
88
89
  */
89
- export declare function calculateTerminalPrice(market: PerpMarketAccount): any;
90
+ export declare function calculateTerminalPrice(market: PerpMarketAccount): BN;
90
91
  export declare function calculateMaxBaseAssetAmountToTrade(amm: AMM, limit_price: BN, direction: PositionDirection, oraclePriceData?: OraclePriceData, now?: BN): [BN, PositionDirection];
91
92
  export declare function calculateQuoteAssetAmountSwapped(quoteAssetReserves: BN, pegMultiplier: BN, swapDirection: SwapDirection): BN;
92
93
  export declare function calculateMaxBaseAssetAmountFillable(amm: AMM, orderDirection: PositionDirection): BN;
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { Order } from '../types';
2
3
  import { BN } from '../.';
3
4
  export declare function isAuctionComplete(order: Order, slot: number): boolean;
@@ -1 +1,2 @@
1
- export declare const convertToNumber: (bigNumber: BN, precision?: BN) => any;
1
+ import { BN } from '../';
2
+ export declare const convertToNumber: (bigNumber: BN, precision?: BN) => number;
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { BN } from '@coral-xyz/anchor';
2
3
  import { PerpMarketAccount } from '../types';
3
4
  import { OraclePriceData } from '../oracles/types';
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { BN } from '../index';
2
3
  export declare function stakeAmountToShares(amount: BN, totalIfShares: BN, insuranceFundVaultBalance: BN): BN;
3
4
  export declare function unstakeSharesToAmount(nShares: BN, totalIfShares: BN, insuranceFundVaultBalance: BN): BN;
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { BN } from '@coral-xyz/anchor';
2
3
  import { OraclePriceData } from '../oracles/types';
3
4
  import { PerpMarketAccount, PerpPosition } from '..';
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { BN } from '@coral-xyz/anchor';
2
3
  import { PerpMarketAccount, PositionDirection, MarginCategory, SpotMarketAccount } from '../types';
3
4
  import { OraclePriceData } from '../oracles/types';
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { AMM, OracleGuardRails } from '../types';
2
3
  import { OraclePriceData } from '../oracles/types';
3
4
  import { BN, HistoricalOracleData, PerpMarketAccount } from '../index';
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { User } from '../user';
2
3
  import { PerpMarketAccount, AMM, Order } from '../types';
3
4
  import { BN } from '@coral-xyz/anchor';
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { BN, SpotMarketAccount } from '../';
2
3
  import { OraclePriceData } from '../oracles/types';
3
4
  import { PerpMarketAccount, PositionDirection, PerpPosition } from '../types';
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { BN } from '@coral-xyz/anchor';
2
3
  import { AMM } from '../types';
3
4
  /**
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { SpotMarketAccount, SpotBalanceType, MarginCategory } from '../types';
2
3
  import { BN } from '@coral-xyz/anchor';
3
4
  import { OraclePriceData } from '../oracles/types';
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { BN } from '@coral-xyz/anchor';
2
3
  import { MarginCategory, SpotBalanceType, SpotMarketAccount } from '../types';
3
4
  export declare function castNumberToSpotPrecision(value: number, spotMarket: SpotMarketAccount): BN;
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { SpotMarketAccount, SpotPosition } from '../types';
2
3
  import { BN } from '@coral-xyz/anchor';
3
4
  import { OraclePriceData } from '../oracles/types';
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { PerpMarketAccount, PositionDirection, SpotMarketAccount } from '../types';
2
3
  import { BN } from '@coral-xyz/anchor';
3
4
  import { AssetType } from './amm';
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { BN } from '../';
2
3
  export declare function clampBN(x: BN, min: BN, max: BN): BN;
3
4
  export declare const squareRootBN: (n: BN) => BN;
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  /// <reference types="node" />
2
3
  import { Connection, PublicKey } from '@solana/web3.js';
3
4
  import { OracleClient, OraclePriceData } from './types';
@@ -6,7 +7,7 @@ export declare class PythClient implements OracleClient {
6
7
  private connection;
7
8
  private multiple;
8
9
  private stableCoin;
9
- constructor(connection: Connection, multiple?: any, stableCoin?: boolean);
10
+ constructor(connection: Connection, multiple?: BN, stableCoin?: boolean);
10
11
  getOraclePriceData(pricePublicKey: PublicKey): Promise<OraclePriceData>;
11
12
  getOraclePriceDataFromBuffer(buffer: Buffer): OraclePriceData;
12
13
  }
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  /// <reference types="node" />
2
3
  import { BN } from '@coral-xyz/anchor';
3
4
  import { PublicKey } from '@solana/web3.js';
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { OptionalOrderParams, OrderTriggerCondition } from './types';
2
3
  import { BN } from '@coral-xyz/anchor';
3
4
  export declare function getLimitOrderParams(params: Omit<OptionalOrderParams, 'orderType' | 'marketType'> & {
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { Connection, PublicKey } from '@solana/web3.js';
2
3
  import { BulkAccountLoader } from '../accounts/bulkAccountLoader';
3
4
  import { Market, Orderbook } from '@project-serum/serum';
@@ -8,6 +8,9 @@ class SlotSubscriber {
8
8
  this.eventEmitter = new events_1.EventEmitter();
9
9
  }
10
10
  async subscribe() {
11
+ if (this.subscriptionId) {
12
+ return;
13
+ }
11
14
  this.currentSlot = await this.connection.getSlot('confirmed');
12
15
  this.subscriptionId = this.connection.onSlotChange((slotInfo) => {
13
16
  this.currentSlot = slotInfo.slot;
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import * as anchor from '@coral-xyz/anchor';
2
3
  import { AnchorProvider, Program } from '@coral-xyz/anchor';
3
4
  import { AccountInfo } from '@solana/spl-token';
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { TxSender, TxSigAndSlot } from './types';
3
- import { Commitment, ConfirmOptions, RpcResponseAndContext, Signer, SignatureResult, Transaction, TransactionSignature, Connection, TransactionInstruction, AddressLookupTableAccount } from '@solana/web3.js';
3
+ import { Commitment, ConfirmOptions, RpcResponseAndContext, Signer, SignatureResult, Transaction, TransactionSignature, Connection, VersionedTransaction, TransactionInstruction, AddressLookupTableAccount } from '@solana/web3.js';
4
4
  import { AnchorProvider } from '@coral-xyz/anchor';
5
5
  type ResolveReference = {
6
6
  resolve?: () => void;
@@ -13,6 +13,7 @@ export declare class RetryTxSender implements TxSender {
13
13
  constructor(provider: AnchorProvider, timeout?: number, retrySleep?: number, additionalConnections?: Connection[]);
14
14
  send(tx: Transaction, additionalSigners?: Array<Signer>, opts?: ConfirmOptions, preSigned?: boolean): Promise<TxSigAndSlot>;
15
15
  prepareTx(tx: Transaction, additionalSigners: Array<Signer>, opts: ConfirmOptions): Promise<Transaction>;
16
+ getVersionedTransaction(ixs: TransactionInstruction[], lookupTableAccounts: AddressLookupTableAccount[], additionalSigners?: Array<Signer>, opts?: ConfirmOptions): Promise<VersionedTransaction>;
16
17
  sendVersionedTransaction(ixs: TransactionInstruction[], lookupTableAccounts: AddressLookupTableAccount[], additionalSigners?: Array<Signer>, opts?: ConfirmOptions): Promise<TxSigAndSlot>;
17
18
  sendRawTransaction(rawTransaction: Buffer | Uint8Array, opts: ConfirmOptions): Promise<TxSigAndSlot>;
18
19
  confirmTransaction(signature: TransactionSignature, commitment?: Commitment): Promise<RpcResponseAndContext<SignatureResult>>;
@@ -39,7 +39,7 @@ class RetryTxSender {
39
39
  const signedTx = await this.provider.wallet.signTransaction(tx);
40
40
  return signedTx;
41
41
  }
42
- async sendVersionedTransaction(ixs, lookupTableAccounts, additionalSigners, opts) {
42
+ async getVersionedTransaction(ixs, lookupTableAccounts, additionalSigners, opts) {
43
43
  if (additionalSigners === undefined) {
44
44
  additionalSigners = [];
45
45
  }
@@ -52,6 +52,10 @@ class RetryTxSender {
52
52
  instructions: ixs,
53
53
  }).compileToV0Message(lookupTableAccounts);
54
54
  const tx = new web3_js_1.VersionedTransaction(message);
55
+ return tx;
56
+ }
57
+ async sendVersionedTransaction(ixs, lookupTableAccounts, additionalSigners, opts) {
58
+ const tx = await this.getVersionedTransaction(ixs, lookupTableAccounts, additionalSigners, opts);
55
59
  // @ts-ignore
56
60
  tx.sign(additionalSigners.concat(this.provider.wallet.payer));
57
61
  return this.sendRawTransaction(tx.serialize(), opts);
package/lib/tx/types.d.ts CHANGED
@@ -1,5 +1,6 @@
1
+ /// <reference types="node" />
1
2
  import { Provider } from '@coral-xyz/anchor';
2
- import { AddressLookupTableAccount, ConfirmOptions, Signer, Transaction, TransactionInstruction, TransactionSignature } from '@solana/web3.js';
3
+ import { AddressLookupTableAccount, ConfirmOptions, Signer, Transaction, TransactionInstruction, TransactionSignature, VersionedTransaction } from '@solana/web3.js';
3
4
  export type TxSigAndSlot = {
4
5
  txSig: TransactionSignature;
5
6
  slot: number;
@@ -8,4 +9,6 @@ export interface TxSender {
8
9
  provider: Provider;
9
10
  send(tx: Transaction, additionalSigners?: Array<Signer>, opts?: ConfirmOptions, preSigned?: boolean): Promise<TxSigAndSlot>;
10
11
  sendVersionedTransaction(ixs: TransactionInstruction[], lookupTableAccounts: AddressLookupTableAccount[], additionalSigners?: Array<Signer>, opts?: ConfirmOptions): Promise<TxSigAndSlot>;
12
+ getVersionedTransaction(ixs: TransactionInstruction[], lookupTableAccounts: AddressLookupTableAccount[], additionalSigners?: Array<Signer>, opts?: ConfirmOptions): Promise<VersionedTransaction>;
13
+ sendRawTransaction(rawTransaction: Buffer | Uint8Array, opts: ConfirmOptions): Promise<TxSigAndSlot>;
11
14
  }
package/lib/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { PublicKey, Transaction } from '@solana/web3.js';
2
3
  import { BN } from '.';
3
4
  export declare enum ExchangeStatus {
@@ -1021,6 +1022,17 @@ export type SerumV3FulfillmentConfigAccount = {
1021
1022
  serumOpenOrders: PublicKey;
1022
1023
  serumSignerNonce: BN;
1023
1024
  };
1025
+ export type PhoenixV1FulfillmentConfigAccount = {
1026
+ pubkey: PublicKey;
1027
+ phoenixProgramId: PublicKey;
1028
+ phoenixLogAuthority: PublicKey;
1029
+ phoenixMarket: PublicKey;
1030
+ phoenixBaseVault: PublicKey;
1031
+ phoenixQuoteVault: PublicKey;
1032
+ marketIndex: number;
1033
+ fulfillmentType: SpotFulfillmentType;
1034
+ status: SpotFulfillmentStatus;
1035
+ };
1024
1036
  export type ReferrerNameAccount = {
1025
1037
  name: number[];
1026
1038
  user: PublicKey;
package/lib/user.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="bn.js" />
2
3
  import { PublicKey } from '@solana/web3.js';
3
4
  import { EventEmitter } from 'events';
4
5
  import StrictEventEmitter from 'strict-event-emitter-types';