@glamsystems/glam-sdk 1.1.0-alpha.2 → 1.1.0-alpha.3

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 (3) hide show
  1. package/index.cjs.js +1084 -299
  2. package/index.esm.js +1063 -300
  3. package/package.json +2 -2
package/index.cjs.js CHANGED
@@ -6,7 +6,7 @@ var splToken = require('@solana/spl-token');
6
6
  var splTokenMetadata = require('@solana/spl-token-metadata');
7
7
  var borsh = require('@coral-xyz/borsh');
8
8
  var bytes = require('@coral-xyz/anchor/dist/cjs/utils/bytes');
9
- require('fzstd');
9
+ var fzstd = require('fzstd');
10
10
  var Decimal = require('decimal.js');
11
11
  var zod = require('zod');
12
12
  var sanctumLstList = require('@glamsystems/sanctum-lst-list');
@@ -26927,7 +26927,7 @@ var ExtLoopscaleIdlJson = {
26927
26927
  var address$a = "G1NTPhharzUz2WsdjBVrczrYjM2USsPMtboHYgdbSpiL";
26928
26928
  var metadata$9 = {
26929
26929
  name: "ext_phoenix",
26930
- version: "0.1.0",
26930
+ version: "0.1.1",
26931
26931
  spec: "0.1.0",
26932
26932
  description: "Phoenix and Ember integration for GLAM Protocol"
26933
26933
  };
@@ -27366,14 +27366,17 @@ var instructions$9 = [
27366
27366
  writable: true
27367
27367
  },
27368
27368
  {
27369
- name: "token_program",
27370
- address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
27369
+ name: "token_program"
27371
27370
  }
27372
27371
  ],
27373
27372
  args: [
27374
27373
  {
27375
- name: "amount",
27376
- type: "u64"
27374
+ name: "deposit_params",
27375
+ type: {
27376
+ defined: {
27377
+ name: "DepositParams"
27378
+ }
27379
+ }
27377
27380
  }
27378
27381
  ]
27379
27382
  },
@@ -27476,8 +27479,12 @@ var instructions$9 = [
27476
27479
  ],
27477
27480
  args: [
27478
27481
  {
27479
- name: "amount",
27480
- type: "u64"
27482
+ name: "params",
27483
+ type: {
27484
+ defined: {
27485
+ name: "DepositFundsInstruction"
27486
+ }
27487
+ }
27481
27488
  }
27482
27489
  ]
27483
27490
  },
@@ -28006,13 +28013,10 @@ var instructions$9 = [
28006
28013
  address: "GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"
28007
28014
  },
28008
28015
  {
28009
- name: "log_authority",
28010
- address: "GdxfTLSsdSY37G6fZoYtdGDSfgFnbT2EmRpuePZxWShS"
28016
+ name: "log_authority"
28011
28017
  },
28012
28018
  {
28013
- name: "global_config",
28014
- writable: true,
28015
- address: "2zskx2iyCvb6Stg7RBZkt1f6MrF4dpYtMG3yMvKwqtUZ"
28019
+ name: "global_config"
28016
28020
  },
28017
28021
  {
28018
28022
  name: "trader_account",
@@ -28037,7 +28041,7 @@ var instructions$9 = [
28037
28041
  {
28038
28042
  name: "set_phoenix_policy",
28039
28043
  docs: [
28040
- "Sets the GLAM Phoenix policy (market allowlist, order size and price-deviation limits) on the vault state."
28044
+ "Sets the GLAM Phoenix policy (market allowlist, order types, and price-deviation limits) on the vault state."
28041
28045
  ],
28042
28046
  discriminator: [
28043
28047
  57,
@@ -28273,15 +28277,19 @@ var instructions$9 = [
28273
28277
  ],
28274
28278
  args: [
28275
28279
  {
28276
- name: "amount",
28277
- type: "u64"
28280
+ name: "params",
28281
+ type: {
28282
+ defined: {
28283
+ name: "TransferCollateralInstruction"
28284
+ }
28285
+ }
28278
28286
  }
28279
28287
  ]
28280
28288
  },
28281
28289
  {
28282
28290
  name: "transfer_collateral_child_to_parent",
28283
28291
  docs: [
28284
- "Sweeps available collateral from a child subaccount back to its parent trader account."
28292
+ "Transfers collateral from a child subaccount back to its parent trader account."
28285
28293
  ],
28286
28294
  discriminator: [
28287
28295
  51,
@@ -28375,7 +28383,16 @@ var instructions$9 = [
28375
28383
  address: "11111111111111111111111111111111"
28376
28384
  }
28377
28385
  ],
28378
- args: []
28386
+ args: [
28387
+ {
28388
+ name: "params",
28389
+ type: {
28390
+ defined: {
28391
+ name: "TransferCollateralChildToParentInstruction"
28392
+ }
28393
+ }
28394
+ }
28395
+ ]
28379
28396
  },
28380
28397
  {
28381
28398
  name: "update_trader_state",
@@ -28595,15 +28612,16 @@ var instructions$9 = [
28595
28612
  writable: true
28596
28613
  },
28597
28614
  {
28598
- name: "token_program",
28599
- address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
28615
+ name: "token_program"
28600
28616
  }
28601
28617
  ],
28602
28618
  args: [
28603
28619
  {
28604
- name: "amount",
28620
+ name: "withdraw_params",
28605
28621
  type: {
28606
- option: "u64"
28622
+ defined: {
28623
+ name: "WithdrawParams"
28624
+ }
28607
28625
  }
28608
28626
  }
28609
28627
  ]
@@ -28707,8 +28725,12 @@ var instructions$9 = [
28707
28725
  ],
28708
28726
  args: [
28709
28727
  {
28710
- name: "amount",
28711
- type: "u64"
28728
+ name: "params",
28729
+ type: {
28730
+ defined: {
28731
+ name: "WithdrawFundsInstruction"
28732
+ }
28733
+ }
28712
28734
  }
28713
28735
  ]
28714
28736
  }
@@ -28873,6 +28895,11 @@ var errors$3 = [
28873
28895
  code: 6028,
28874
28896
  name: "ReferencePriceStale",
28875
28897
  msg: "Phoenix reference price is stale"
28898
+ },
28899
+ {
28900
+ code: 6029,
28901
+ name: "OrderTypeNotAllowed",
28902
+ msg: "Phoenix order type is not allowed by policy"
28876
28903
  }
28877
28904
  ];
28878
28905
  var types$9 = [
@@ -29073,6 +29100,30 @@ var types$9 = [
29073
29100
  ]
29074
29101
  }
29075
29102
  },
29103
+ {
29104
+ name: "DepositFundsInstruction",
29105
+ type: {
29106
+ kind: "struct",
29107
+ fields: [
29108
+ {
29109
+ name: "amount",
29110
+ type: "u64"
29111
+ }
29112
+ ]
29113
+ }
29114
+ },
29115
+ {
29116
+ name: "DepositParams",
29117
+ type: {
29118
+ kind: "struct",
29119
+ fields: [
29120
+ {
29121
+ name: "amount",
29122
+ type: "u64"
29123
+ }
29124
+ ]
29125
+ }
29126
+ },
29076
29127
  {
29077
29128
  name: "EngineField",
29078
29129
  type: {
@@ -30035,32 +30086,49 @@ var types$9 = [
30035
30086
  fields: [
30036
30087
  {
30037
30088
  name: "markets_allowlist",
30089
+ docs: [
30090
+ "Phoenix markets the vault is allowed to trade on. Any order routed to a",
30091
+ "market outside this list is rejected with `MarketNotAllowed`. Capped at",
30092
+ "`MAX_PHOENIX_MARKETS_ALLOWLIST` entries; duplicates and the default",
30093
+ "pubkey are rejected by `validate_for_set`. An empty list disables all",
30094
+ "trading."
30095
+ ],
30038
30096
  type: {
30039
30097
  vec: "pubkey"
30040
30098
  }
30041
30099
  },
30042
30100
  {
30043
- name: "max_order_base_lots",
30044
- type: "u64"
30045
- },
30046
- {
30047
- name: "max_order_quote_lots",
30048
- type: "u64"
30049
- },
30050
- {
30051
- name: "max_price_deviation_bps",
30052
- type: "u16"
30101
+ name: "allowed_order_types",
30102
+ docs: [
30103
+ "Allowed Phoenix `OrderPacketKind` discriminants. Current values are:",
30104
+ "`0 = PostOnly`, `1 = Limit`, and `2 = ImmediateOrCancel`. An empty list",
30105
+ "disables all order placement."
30106
+ ],
30107
+ type: "bytes"
30053
30108
  },
30054
30109
  {
30055
30110
  name: "require_reduce_only_orders",
30111
+ docs: [
30112
+ "When `true`, every order must have the reduce-only flag set; orders",
30113
+ "without it are rejected with `ReduceOnlyRequired`. Use this to lock the",
30114
+ "vault into pure position-unwinding mode."
30115
+ ],
30056
30116
  type: "bool"
30057
30117
  },
30058
30118
  {
30059
- name: "allow_risk_increasing_orders",
30060
- type: "bool"
30119
+ name: "max_price_deviation_bps",
30120
+ docs: [
30121
+ "Maximum allowed deviation in basis points. Retained in policy state for",
30122
+ "future enforcement; currently not checked by order placement."
30123
+ ],
30124
+ type: "u16"
30061
30125
  },
30062
30126
  {
30063
30127
  name: "max_reference_price_age_secs",
30128
+ docs: [
30129
+ "Maximum reference price age in seconds. Retained in policy state for",
30130
+ "future enforcement; currently not checked by order placement."
30131
+ ],
30064
30132
  type: "u32"
30065
30133
  }
30066
30134
  ]
@@ -30380,6 +30448,30 @@ var types$9 = [
30380
30448
  ]
30381
30449
  }
30382
30450
  },
30451
+ {
30452
+ name: "TransferCollateralChildToParentInstruction",
30453
+ type: {
30454
+ kind: "struct",
30455
+ fields: [
30456
+ {
30457
+ name: "amount",
30458
+ type: "u64"
30459
+ }
30460
+ ]
30461
+ }
30462
+ },
30463
+ {
30464
+ name: "TransferCollateralInstruction",
30465
+ type: {
30466
+ kind: "struct",
30467
+ fields: [
30468
+ {
30469
+ name: "amount",
30470
+ type: "u64"
30471
+ }
30472
+ ]
30473
+ }
30474
+ },
30383
30475
  {
30384
30476
  name: "ValuationModel",
30385
30477
  type: {
@@ -30393,38 +30485,49 @@ var types$9 = [
30393
30485
  }
30394
30486
  ]
30395
30487
  }
30396
- }
30397
- ];
30398
- var constants$9 = [
30399
- {
30400
- name: "EMBER_PERM_DEPOSIT",
30401
- type: "u64",
30402
- value: "1"
30403
30488
  },
30404
30489
  {
30405
- name: "EMBER_PERM_WITHDRAW",
30406
- type: "u64",
30407
- value: "2"
30490
+ name: "WithdrawFundsInstruction",
30491
+ type: {
30492
+ kind: "struct",
30493
+ fields: [
30494
+ {
30495
+ name: "amount",
30496
+ type: "u64"
30497
+ }
30498
+ ]
30499
+ }
30408
30500
  },
30409
30501
  {
30410
- name: "PHOENIX_PERM_CANCEL_ORDERS",
30411
- type: "u64",
30412
- value: "32"
30413
- },
30502
+ name: "WithdrawParams",
30503
+ type: {
30504
+ kind: "struct",
30505
+ fields: [
30506
+ {
30507
+ name: "amount",
30508
+ type: {
30509
+ option: "u64"
30510
+ }
30511
+ }
30512
+ ]
30513
+ }
30514
+ }
30515
+ ];
30516
+ var constants$9 = [
30414
30517
  {
30415
- name: "PHOENIX_PERM_CONDITIONAL_ORDERS",
30518
+ name: "PHOENIX_PERM_CANCEL_ORDERS",
30416
30519
  type: "u64",
30417
- value: "256"
30520
+ value: "16"
30418
30521
  },
30419
30522
  {
30420
30523
  name: "PHOENIX_PERM_CREATE_MODIFY_ORDERS",
30421
30524
  type: "u64",
30422
- value: "16"
30525
+ value: "8"
30423
30526
  },
30424
30527
  {
30425
30528
  name: "PHOENIX_PERM_DEPOSIT",
30426
30529
  type: "u64",
30427
- value: "4"
30530
+ value: "2"
30428
30531
  },
30429
30532
  {
30430
30533
  name: "PHOENIX_PERM_INIT_TRADER",
@@ -30434,22 +30537,17 @@ var constants$9 = [
30434
30537
  {
30435
30538
  name: "PHOENIX_PERM_TRANSFER_COLLATERAL",
30436
30539
  type: "u64",
30437
- value: "64"
30540
+ value: "32"
30438
30541
  },
30439
30542
  {
30440
30543
  name: "PHOENIX_PERM_UPDATE_TRADER_STATE",
30441
30544
  type: "u64",
30442
- value: "128"
30545
+ value: "64"
30443
30546
  },
30444
30547
  {
30445
30548
  name: "PHOENIX_PERM_WITHDRAW",
30446
30549
  type: "u64",
30447
- value: "8"
30448
- },
30449
- {
30450
- name: "PROTO_EMBER",
30451
- type: "u16",
30452
- value: "2"
30550
+ value: "4"
30453
30551
  },
30454
30552
  {
30455
30553
  name: "PROTO_PHOENIX",
@@ -55513,7 +55611,7 @@ var ExtLoopscaleIdlJsonStaging = {
55513
55611
  var address = "gstgPL7r9aYedDDsXNtLpr4atYtNvY7zubAWWstqS3L";
55514
55612
  var metadata = {
55515
55613
  name: "ext_phoenix",
55516
- version: "0.1.0",
55614
+ version: "0.1.1",
55517
55615
  spec: "0.1.0",
55518
55616
  description: "Phoenix and Ember integration for GLAM Protocol"
55519
55617
  };
@@ -55952,14 +56050,17 @@ var instructions = [
55952
56050
  writable: true
55953
56051
  },
55954
56052
  {
55955
- name: "token_program",
55956
- address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
56053
+ name: "token_program"
55957
56054
  }
55958
56055
  ],
55959
56056
  args: [
55960
56057
  {
55961
- name: "amount",
55962
- type: "u64"
56058
+ name: "deposit_params",
56059
+ type: {
56060
+ defined: {
56061
+ name: "DepositParams"
56062
+ }
56063
+ }
55963
56064
  }
55964
56065
  ]
55965
56066
  },
@@ -56062,8 +56163,12 @@ var instructions = [
56062
56163
  ],
56063
56164
  args: [
56064
56165
  {
56065
- name: "amount",
56066
- type: "u64"
56166
+ name: "params",
56167
+ type: {
56168
+ defined: {
56169
+ name: "DepositFundsInstruction"
56170
+ }
56171
+ }
56067
56172
  }
56068
56173
  ]
56069
56174
  },
@@ -56592,13 +56697,10 @@ var instructions = [
56592
56697
  address: "gstgptmbgJVi5f8ZmSRVZjZkDQwqKa3xWuUtD5WmJHz"
56593
56698
  },
56594
56699
  {
56595
- name: "log_authority",
56596
- address: "GdxfTLSsdSY37G6fZoYtdGDSfgFnbT2EmRpuePZxWShS"
56700
+ name: "log_authority"
56597
56701
  },
56598
56702
  {
56599
- name: "global_config",
56600
- writable: true,
56601
- address: "2zskx2iyCvb6Stg7RBZkt1f6MrF4dpYtMG3yMvKwqtUZ"
56703
+ name: "global_config"
56602
56704
  },
56603
56705
  {
56604
56706
  name: "trader_account",
@@ -56623,7 +56725,7 @@ var instructions = [
56623
56725
  {
56624
56726
  name: "set_phoenix_policy",
56625
56727
  docs: [
56626
- "Sets the GLAM Phoenix policy (market allowlist, order size and price-deviation limits) on the vault state."
56728
+ "Sets the GLAM Phoenix policy (market allowlist, order types, and price-deviation limits) on the vault state."
56627
56729
  ],
56628
56730
  discriminator: [
56629
56731
  57,
@@ -56859,15 +56961,19 @@ var instructions = [
56859
56961
  ],
56860
56962
  args: [
56861
56963
  {
56862
- name: "amount",
56863
- type: "u64"
56964
+ name: "params",
56965
+ type: {
56966
+ defined: {
56967
+ name: "TransferCollateralInstruction"
56968
+ }
56969
+ }
56864
56970
  }
56865
56971
  ]
56866
56972
  },
56867
56973
  {
56868
56974
  name: "transfer_collateral_child_to_parent",
56869
56975
  docs: [
56870
- "Sweeps available collateral from a child subaccount back to its parent trader account."
56976
+ "Transfers collateral from a child subaccount back to its parent trader account."
56871
56977
  ],
56872
56978
  discriminator: [
56873
56979
  51,
@@ -56961,7 +57067,16 @@ var instructions = [
56961
57067
  address: "11111111111111111111111111111111"
56962
57068
  }
56963
57069
  ],
56964
- args: []
57070
+ args: [
57071
+ {
57072
+ name: "params",
57073
+ type: {
57074
+ defined: {
57075
+ name: "TransferCollateralChildToParentInstruction"
57076
+ }
57077
+ }
57078
+ }
57079
+ ]
56965
57080
  },
56966
57081
  {
56967
57082
  name: "update_trader_state",
@@ -57181,15 +57296,16 @@ var instructions = [
57181
57296
  writable: true
57182
57297
  },
57183
57298
  {
57184
- name: "token_program",
57185
- address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
57299
+ name: "token_program"
57186
57300
  }
57187
57301
  ],
57188
57302
  args: [
57189
57303
  {
57190
- name: "amount",
57304
+ name: "withdraw_params",
57191
57305
  type: {
57192
- option: "u64"
57306
+ defined: {
57307
+ name: "WithdrawParams"
57308
+ }
57193
57309
  }
57194
57310
  }
57195
57311
  ]
@@ -57293,8 +57409,12 @@ var instructions = [
57293
57409
  ],
57294
57410
  args: [
57295
57411
  {
57296
- name: "amount",
57297
- type: "u64"
57412
+ name: "params",
57413
+ type: {
57414
+ defined: {
57415
+ name: "WithdrawFundsInstruction"
57416
+ }
57417
+ }
57298
57418
  }
57299
57419
  ]
57300
57420
  }
@@ -57459,6 +57579,11 @@ var errors = [
57459
57579
  code: 6028,
57460
57580
  name: "ReferencePriceStale",
57461
57581
  msg: "Phoenix reference price is stale"
57582
+ },
57583
+ {
57584
+ code: 6029,
57585
+ name: "OrderTypeNotAllowed",
57586
+ msg: "Phoenix order type is not allowed by policy"
57462
57587
  }
57463
57588
  ];
57464
57589
  var types = [
@@ -57659,6 +57784,30 @@ var types = [
57659
57784
  ]
57660
57785
  }
57661
57786
  },
57787
+ {
57788
+ name: "DepositFundsInstruction",
57789
+ type: {
57790
+ kind: "struct",
57791
+ fields: [
57792
+ {
57793
+ name: "amount",
57794
+ type: "u64"
57795
+ }
57796
+ ]
57797
+ }
57798
+ },
57799
+ {
57800
+ name: "DepositParams",
57801
+ type: {
57802
+ kind: "struct",
57803
+ fields: [
57804
+ {
57805
+ name: "amount",
57806
+ type: "u64"
57807
+ }
57808
+ ]
57809
+ }
57810
+ },
57662
57811
  {
57663
57812
  name: "EngineField",
57664
57813
  type: {
@@ -58621,32 +58770,49 @@ var types = [
58621
58770
  fields: [
58622
58771
  {
58623
58772
  name: "markets_allowlist",
58773
+ docs: [
58774
+ "Phoenix markets the vault is allowed to trade on. Any order routed to a",
58775
+ "market outside this list is rejected with `MarketNotAllowed`. Capped at",
58776
+ "`MAX_PHOENIX_MARKETS_ALLOWLIST` entries; duplicates and the default",
58777
+ "pubkey are rejected by `validate_for_set`. An empty list disables all",
58778
+ "trading."
58779
+ ],
58624
58780
  type: {
58625
58781
  vec: "pubkey"
58626
58782
  }
58627
58783
  },
58628
58784
  {
58629
- name: "max_order_base_lots",
58630
- type: "u64"
58631
- },
58632
- {
58633
- name: "max_order_quote_lots",
58634
- type: "u64"
58635
- },
58636
- {
58637
- name: "max_price_deviation_bps",
58638
- type: "u16"
58785
+ name: "allowed_order_types",
58786
+ docs: [
58787
+ "Allowed Phoenix `OrderPacketKind` discriminants. Current values are:",
58788
+ "`0 = PostOnly`, `1 = Limit`, and `2 = ImmediateOrCancel`. An empty list",
58789
+ "disables all order placement."
58790
+ ],
58791
+ type: "bytes"
58639
58792
  },
58640
58793
  {
58641
58794
  name: "require_reduce_only_orders",
58795
+ docs: [
58796
+ "When `true`, every order must have the reduce-only flag set; orders",
58797
+ "without it are rejected with `ReduceOnlyRequired`. Use this to lock the",
58798
+ "vault into pure position-unwinding mode."
58799
+ ],
58642
58800
  type: "bool"
58643
58801
  },
58644
58802
  {
58645
- name: "allow_risk_increasing_orders",
58646
- type: "bool"
58803
+ name: "max_price_deviation_bps",
58804
+ docs: [
58805
+ "Maximum allowed deviation in basis points. Retained in policy state for",
58806
+ "future enforcement; currently not checked by order placement."
58807
+ ],
58808
+ type: "u16"
58647
58809
  },
58648
58810
  {
58649
58811
  name: "max_reference_price_age_secs",
58812
+ docs: [
58813
+ "Maximum reference price age in seconds. Retained in policy state for",
58814
+ "future enforcement; currently not checked by order placement."
58815
+ ],
58650
58816
  type: "u32"
58651
58817
  }
58652
58818
  ]
@@ -58966,6 +59132,30 @@ var types = [
58966
59132
  ]
58967
59133
  }
58968
59134
  },
59135
+ {
59136
+ name: "TransferCollateralChildToParentInstruction",
59137
+ type: {
59138
+ kind: "struct",
59139
+ fields: [
59140
+ {
59141
+ name: "amount",
59142
+ type: "u64"
59143
+ }
59144
+ ]
59145
+ }
59146
+ },
59147
+ {
59148
+ name: "TransferCollateralInstruction",
59149
+ type: {
59150
+ kind: "struct",
59151
+ fields: [
59152
+ {
59153
+ name: "amount",
59154
+ type: "u64"
59155
+ }
59156
+ ]
59157
+ }
59158
+ },
58969
59159
  {
58970
59160
  name: "ValuationModel",
58971
59161
  type: {
@@ -58979,38 +59169,49 @@ var types = [
58979
59169
  }
58980
59170
  ]
58981
59171
  }
58982
- }
58983
- ];
58984
- var constants = [
58985
- {
58986
- name: "EMBER_PERM_DEPOSIT",
58987
- type: "u64",
58988
- value: "1"
58989
59172
  },
58990
59173
  {
58991
- name: "EMBER_PERM_WITHDRAW",
58992
- type: "u64",
58993
- value: "2"
59174
+ name: "WithdrawFundsInstruction",
59175
+ type: {
59176
+ kind: "struct",
59177
+ fields: [
59178
+ {
59179
+ name: "amount",
59180
+ type: "u64"
59181
+ }
59182
+ ]
59183
+ }
58994
59184
  },
58995
59185
  {
58996
- name: "PHOENIX_PERM_CANCEL_ORDERS",
58997
- type: "u64",
58998
- value: "32"
58999
- },
59186
+ name: "WithdrawParams",
59187
+ type: {
59188
+ kind: "struct",
59189
+ fields: [
59190
+ {
59191
+ name: "amount",
59192
+ type: {
59193
+ option: "u64"
59194
+ }
59195
+ }
59196
+ ]
59197
+ }
59198
+ }
59199
+ ];
59200
+ var constants = [
59000
59201
  {
59001
- name: "PHOENIX_PERM_CONDITIONAL_ORDERS",
59202
+ name: "PHOENIX_PERM_CANCEL_ORDERS",
59002
59203
  type: "u64",
59003
- value: "256"
59204
+ value: "16"
59004
59205
  },
59005
59206
  {
59006
59207
  name: "PHOENIX_PERM_CREATE_MODIFY_ORDERS",
59007
59208
  type: "u64",
59008
- value: "16"
59209
+ value: "8"
59009
59210
  },
59010
59211
  {
59011
59212
  name: "PHOENIX_PERM_DEPOSIT",
59012
59213
  type: "u64",
59013
- value: "4"
59214
+ value: "2"
59014
59215
  },
59015
59216
  {
59016
59217
  name: "PHOENIX_PERM_INIT_TRADER",
@@ -59020,22 +59221,17 @@ var constants = [
59020
59221
  {
59021
59222
  name: "PHOENIX_PERM_TRANSFER_COLLATERAL",
59022
59223
  type: "u64",
59023
- value: "64"
59224
+ value: "32"
59024
59225
  },
59025
59226
  {
59026
59227
  name: "PHOENIX_PERM_UPDATE_TRADER_STATE",
59027
59228
  type: "u64",
59028
- value: "128"
59229
+ value: "64"
59029
59230
  },
59030
59231
  {
59031
59232
  name: "PHOENIX_PERM_WITHDRAW",
59032
59233
  type: "u64",
59033
- value: "8"
59034
- },
59035
- {
59036
- name: "PROTO_EMBER",
59037
- type: "u16",
59038
- value: "2"
59234
+ value: "4"
59039
59235
  },
59040
59236
  {
59041
59237
  name: "PROTO_PHOENIX",
@@ -59194,6 +59390,13 @@ function charsToName(chars) {
59194
59390
  function nameToChars(name, length = 32) {
59195
59391
  return stringToChars(name, length);
59196
59392
  }
59393
+ /**
59394
+ * Returns the first 8 raw SHA-256 bytes for PDA seed derivation.
59395
+ */ async function sha256First8Bytes(chars) {
59396
+ const bytes = Uint8Array.from(chars.filter((byte)=>byte !== 0));
59397
+ const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
59398
+ return Array.from(new Uint8Array(digest).subarray(0, 8));
59399
+ }
59197
59400
  /**
59198
59401
  * Normalizes a base-unit amount into a BN while preserving existing BN values.
59199
59402
  */ function toBnAmount(amount) {
@@ -59446,18 +59649,19 @@ class PhoenixPolicy {
59446
59649
  marketsAllowlist.push(new web3_js.PublicKey(buffer.subarray(offset, offset + 32)));
59447
59650
  offset += 32;
59448
59651
  }
59449
- const maxOrderBaseLots = new anchor.BN(buffer.subarray(offset, offset + 8), "le");
59450
- offset += 8;
59451
- const maxOrderQuoteLots = new anchor.BN(buffer.subarray(offset, offset + 8), "le");
59452
- offset += 8;
59453
- const maxPriceDeviationBps = buffer.readUInt16LE(offset);
59454
- offset += 2;
59652
+ const allowedOrderTypesLen = buffer.readUInt32LE(offset);
59653
+ offset += 4;
59654
+ const allowedOrderTypes = [];
59655
+ for(let i = 0; i < allowedOrderTypesLen; i++){
59656
+ allowedOrderTypes.push(buffer.readUInt8(offset));
59657
+ offset += 1;
59658
+ }
59455
59659
  const requireReduceOnlyOrders = buffer.readUInt8(offset) !== 0;
59456
59660
  offset += 1;
59457
- const allowRiskIncreasingOrders = buffer.readUInt8(offset) !== 0;
59458
- offset += 1;
59661
+ const maxPriceDeviationBps = buffer.readUInt16LE(offset);
59662
+ offset += 2;
59459
59663
  const maxReferencePriceAgeSecs = buffer.length >= offset + 4 ? buffer.readUInt32LE(offset) : 0;
59460
- return new PhoenixPolicy(marketsAllowlist, maxOrderBaseLots, maxOrderQuoteLots, maxPriceDeviationBps, requireReduceOnlyOrders, allowRiskIncreasingOrders, maxReferencePriceAgeSecs);
59664
+ return new PhoenixPolicy(marketsAllowlist, allowedOrderTypes, requireReduceOnlyOrders, maxPriceDeviationBps, maxReferencePriceAgeSecs);
59461
59665
  }
59462
59666
  encode() {
59463
59667
  const allowlistHeader = Buffer.alloc(4);
@@ -59466,18 +59670,18 @@ class PhoenixPolicy {
59466
59670
  for(let i = 0; i < this.marketsAllowlist.length; i++){
59467
59671
  this.marketsAllowlist[i].toBuffer().copy(allowlistBody, i * 32);
59468
59672
  }
59469
- const tail = Buffer.alloc(8 + 8 + 2 + 1 + 1 + 4);
59673
+ const tail = Buffer.alloc(2 + 1 + 4 + 4 + this.allowedOrderTypes.length);
59470
59674
  let off = 0;
59471
- this.maxOrderBaseLots.toArrayLike(Buffer, "le", 8).copy(tail, off);
59472
- off += 8;
59473
- this.maxOrderQuoteLots.toArrayLike(Buffer, "le", 8).copy(tail, off);
59474
- off += 8;
59475
- tail.writeUInt16LE(this.maxPriceDeviationBps, off);
59476
- off += 2;
59675
+ tail.writeUInt32LE(this.allowedOrderTypes.length, off);
59676
+ off += 4;
59677
+ for (const orderType of this.allowedOrderTypes){
59678
+ tail.writeUInt8(orderType, off);
59679
+ off += 1;
59680
+ }
59477
59681
  tail.writeUInt8(this.requireReduceOnlyOrders ? 1 : 0, off);
59478
59682
  off += 1;
59479
- tail.writeUInt8(this.allowRiskIncreasingOrders ? 1 : 0, off);
59480
- off += 1;
59683
+ tail.writeUInt16LE(this.maxPriceDeviationBps, off);
59684
+ off += 2;
59481
59685
  tail.writeUInt32LE(this.maxReferencePriceAgeSecs, off);
59482
59686
  return Buffer.concat([
59483
59687
  allowlistHeader,
@@ -59485,13 +59689,11 @@ class PhoenixPolicy {
59485
59689
  tail
59486
59690
  ]);
59487
59691
  }
59488
- constructor(marketsAllowlist, maxOrderBaseLots, maxOrderQuoteLots, maxPriceDeviationBps, requireReduceOnlyOrders, allowRiskIncreasingOrders, maxReferencePriceAgeSecs = 0){
59692
+ constructor(marketsAllowlist, allowedOrderTypes, requireReduceOnlyOrders, maxPriceDeviationBps, maxReferencePriceAgeSecs = 0){
59489
59693
  this.marketsAllowlist = marketsAllowlist;
59490
- this.maxOrderBaseLots = maxOrderBaseLots;
59491
- this.maxOrderQuoteLots = maxOrderQuoteLots;
59492
- this.maxPriceDeviationBps = maxPriceDeviationBps;
59694
+ this.allowedOrderTypes = allowedOrderTypes;
59493
59695
  this.requireReduceOnlyOrders = requireReduceOnlyOrders;
59494
- this.allowRiskIncreasingOrders = allowRiskIncreasingOrders;
59696
+ this.maxPriceDeviationBps = maxPriceDeviationBps;
59495
59697
  this.maxReferencePriceAgeSecs = maxReferencePriceAgeSecs;
59496
59698
  }
59497
59699
  }
@@ -59713,12 +59915,18 @@ const LOOPSCALE_PROGRAM_ID = new web3_js.PublicKey("1oopBoJG58DgkUVKkEzKgyG9dvRm
59713
59915
  const PHOENIX_PROGRAM_ID = new web3_js.PublicKey("EtrnLzgbS7nMMy5fbD42kXiUzGg8XQzJ972Xtk1cjWih");
59714
59916
  const PHOENIX_LOG_AUTHORITY = new web3_js.PublicKey("GdxfTLSsdSY37G6fZoYtdGDSfgFnbT2EmRpuePZxWShS");
59715
59917
  const PHOENIX_GLOBAL_CONFIG = new web3_js.PublicKey("2zskx2iyCvb6Stg7RBZkt1f6MrF4dpYtMG3yMvKwqtUZ");
59918
+ const PHOENIX_WITHDRAW_QUEUE = new web3_js.PublicKey("3c3NTwpg7yW91FxijkHBXwVH1xUifun3Z8TC5eW5Si3K");
59716
59919
  const EMBER_PROGRAM_ID = new web3_js.PublicKey("EMBERpYNE6ehWmXymZZS2skiFmCa9V5dp14e1iduM5qy");
59717
59920
  /**
59718
59921
  * Protocol bitmask values for ext_phoenix integration.
59719
59922
  * Mirror `SupportedProtocols` in anchor/programs/ext_phoenix/src/state/access.rs.
59720
59923
  */ const PHOENIX_PROTOCOL = 1 << 0;
59721
- const EMBER_PROTOCOL = 1 << 1;
59924
+ /**
59925
+ * Phoenix OrderPacketKind discriminants.
59926
+ * Mirror `OrderPacketKind` variant order in anchor/deps/phoenix/phoenix.json.
59927
+ */ const PHOENIX_ORDER_PACKET_KIND_POST_ONLY = 0;
59928
+ const PHOENIX_ORDER_PACKET_KIND_LIMIT = 1;
59929
+ const PHOENIX_ORDER_PACKET_KIND_IMMEDIATE_OR_CANCEL = 2;
59722
59930
  /**
59723
59931
  * Token ACL (sRFC-37)
59724
59932
  */ const TOKEN_ACL_PROGRAM = new web3_js.PublicKey("TACLkU6CiCdkQN2MjoyDkVg2yAH9zkxiHDsiztQ52TP");
@@ -59970,21 +60178,12 @@ const GLAM_CONFIG_PROGRAM = new web3_js.PublicKey("gConFzxKL9USmwTdJoeQJvfKmqhJ2
59970
60178
  staging: true,
59971
60179
  permissions: {
59972
60180
  [1 << 0]: "InitTrader",
59973
- [1 << 2]: "Deposit",
59974
- [1 << 3]: "Withdraw",
59975
- [1 << 4]: "CreateModifyOrders",
59976
- [1 << 5]: "CancelOrders",
59977
- [1 << 6]: "TransferCollateral",
59978
- [1 << 7]: "UpdateTraderState",
59979
- [1 << 8]: "ConditionalOrders"
59980
- }
59981
- },
59982
- "0000000000000010": {
59983
- name: "Ember",
59984
- staging: true,
59985
- permissions: {
59986
- [1 << 0]: "Deposit",
59987
- [1 << 1]: "Withdraw"
60181
+ [1 << 1]: "Deposit",
60182
+ [1 << 2]: "Withdraw",
60183
+ [1 << 3]: "CreateModifyOrders",
60184
+ [1 << 4]: "CancelOrders",
60185
+ [1 << 5]: "TransferCollateral",
60186
+ [1 << 6]: "UpdateTraderState"
59988
60187
  }
59989
60188
  }
59990
60189
  }
@@ -60230,21 +60429,15 @@ function isHeliusRpc(rpcUrl) {
60230
60429
  function getHeliusApiKey() {
60231
60430
  return process.env.NEXT_PUBLIC_HELIUS_API_KEY || process.env.HELIUS_API_KEY;
60232
60431
  }
60233
- /**
60234
- * Fetches program accounts using Helius getProgramAccountsV2 if available.
60235
- * Otherwise falls back to standard getProgramAccounts with retry logic.
60236
- */ async function getProgramAccounts(connection, programId, config) {
60237
- // 2026-03-02: Helius getProgramAccountsV2 cannot find ALTs, disable it for now
60238
- // if (isHeliusRpc(connection.rpcEndpoint)) {
60239
- // return await getProgramAccountsV2Helius(
60240
- // connection.rpcEndpoint,
60241
- // programId,
60242
- // config,
60243
- // );
60244
- // }
60245
- return await getProgramAccountsWithRetry(connection, programId, config);
60432
+ function getHeliusRpcUrl(apiKey) {
60433
+ const key = apiKey ?? getHeliusApiKey();
60434
+ if (!key) {
60435
+ throw new Error("Helius API key not found");
60436
+ }
60437
+ return `https://mainnet.helius-rpc.com/?api-key=${key}`;
60246
60438
  }
60247
- async function rpcRequest(rpcUrl, method, params) {
60439
+ async function heliusFetch(method, params, options) {
60440
+ const rpcUrl = options?.rpcUrl ?? getHeliusRpcUrl(options?.apiKey);
60248
60441
  const response = await fetch(rpcUrl, {
60249
60442
  method: "POST",
60250
60443
  headers: {
@@ -60257,12 +60450,159 @@ async function rpcRequest(rpcUrl, method, params) {
60257
60450
  params
60258
60451
  })
60259
60452
  });
60453
+ if (!response.ok) {
60454
+ throw new Error(`${method} HTTP error: ${response.status}`);
60455
+ }
60260
60456
  const data = await response.json();
60261
60457
  if (data.error) {
60262
60458
  throw new Error(`${method} RPC error: ${data.error.message}`);
60263
60459
  }
60264
60460
  return data.result;
60265
60461
  }
60462
+ async function getAsset(mint, options) {
60463
+ const result = await heliusFetch("getAsset", {
60464
+ id: mint
60465
+ }, options);
60466
+ return result ?? null;
60467
+ }
60468
+ async function getTokenAccountsByMintResult(mint, options) {
60469
+ const mintStr = typeof mint === "string" ? mint : mint.toBase58();
60470
+ const result = await heliusFetch("getTokenAccounts", {
60471
+ mint: mintStr,
60472
+ ...options?.limit !== undefined && {
60473
+ limit: options.limit
60474
+ },
60475
+ options: {
60476
+ showZeroBalance: options?.showZeroBalance ?? true
60477
+ }
60478
+ }, options);
60479
+ return {
60480
+ token_accounts: result?.token_accounts ?? [],
60481
+ total: result?.total
60482
+ };
60483
+ }
60484
+ async function getTokenAccountsByMint(mint, options) {
60485
+ return (await getTokenAccountsByMintResult(mint, options)).token_accounts;
60486
+ }
60487
+ async function getPriorityFeeEstimate(options) {
60488
+ const { heliusApiKey = getHeliusApiKey(), tx, accountKeys, priorityLevel } = options;
60489
+ if (!heliusApiKey) {
60490
+ console.warn("getPriorityFeeEstimate is called but Helius API key not found");
60491
+ return 0;
60492
+ }
60493
+ if (!tx && !accountKeys) {
60494
+ throw new Error("Either tx or accountKeys must be provided");
60495
+ }
60496
+ const requestOptions = priorityLevel && priorityLevel !== "Recommended" ? {
60497
+ priorityLevel
60498
+ } : {
60499
+ recommended: true
60500
+ };
60501
+ const param = tx ? {
60502
+ transaction: bytes.bs58.encode(tx.serialize())
60503
+ } : {
60504
+ accountKeys
60505
+ };
60506
+ const result = await heliusFetch("getPriorityFeeEstimate", [
60507
+ {
60508
+ ...param,
60509
+ options: requestOptions
60510
+ }
60511
+ ], {
60512
+ apiKey: heliusApiKey
60513
+ });
60514
+ return result.priorityFeeEstimate;
60515
+ }
60516
+ // FIXME: The param `limit` now controls page size, not total results
60517
+ async function heliusGetTransactionsForAddress(rpcUrl, address, options) {
60518
+ const { transactionDetails = "full", limit = 100, before, commitment } = options || {};
60519
+ const allTransactions = [];
60520
+ let result;
60521
+ let paginationToken = before;
60522
+ do {
60523
+ result = await heliusFetch("getTransactionsForAddress", [
60524
+ address.toBase58(),
60525
+ {
60526
+ transactionDetails,
60527
+ limit,
60528
+ ...paginationToken && {
60529
+ paginationToken
60530
+ },
60531
+ ...commitment && {
60532
+ commitment
60533
+ }
60534
+ }
60535
+ ], {
60536
+ rpcUrl
60537
+ });
60538
+ allTransactions.push(...result?.data || []);
60539
+ paginationToken = result?.paginationToken;
60540
+ }while (paginationToken)
60541
+ return allTransactions;
60542
+ }
60543
+ function decodeAccountData(accountData, encoding) {
60544
+ if (encoding === "base64") {
60545
+ return Buffer.from(accountData, "base64");
60546
+ } else if (encoding === "base64+zstd") {
60547
+ const compressed = Buffer.from(accountData, "base64");
60548
+ return Buffer.from(fzstd.decompress(compressed));
60549
+ } else if (encoding === "base58") {
60550
+ return bytes.bs58.decode(accountData);
60551
+ }
60552
+ throw new Error(`Unsupported encoding: ${encoding}`);
60553
+ }
60554
+ async function heliusGetProgramAccountsV2(rpcUrl, programId, config) {
60555
+ const allAccounts = [];
60556
+ let paginationKey = null;
60557
+ do {
60558
+ const result = await heliusFetch("getProgramAccountsV2", [
60559
+ programId.toBase58(),
60560
+ {
60561
+ encoding: config.encoding || "base64",
60562
+ filters: config.filters || [],
60563
+ ...config.limit && {
60564
+ limit: config.limit
60565
+ },
60566
+ ...config.changedSinceSlot && {
60567
+ changedSinceSlot: config.changedSinceSlot
60568
+ },
60569
+ ...paginationKey && {
60570
+ paginationKey
60571
+ }
60572
+ }
60573
+ ], {
60574
+ rpcUrl
60575
+ });
60576
+ for (const { pubkey, account } of result.accounts){
60577
+ const [accountData, encoding] = account.data;
60578
+ allAccounts.push({
60579
+ pubkey: new web3_js.PublicKey(pubkey),
60580
+ account: {
60581
+ ...account,
60582
+ owner: new web3_js.PublicKey(account.owner),
60583
+ data: decodeAccountData(accountData, encoding)
60584
+ }
60585
+ });
60586
+ }
60587
+ paginationKey = result.accounts.length > 0 ? result.paginationKey : null;
60588
+ }while (paginationKey)
60589
+ return allAccounts;
60590
+ }
60591
+
60592
+ /**
60593
+ * Fetches program accounts using Helius getProgramAccountsV2 if available.
60594
+ * Otherwise falls back to standard getProgramAccounts with retry logic.
60595
+ */ async function getProgramAccounts(connection, programId, config) {
60596
+ // 2026-03-02: Helius getProgramAccountsV2 cannot find ALTs, disable it for now
60597
+ // if (isHeliusRpc(connection.rpcEndpoint)) {
60598
+ // return await heliusGetProgramAccountsV2(
60599
+ // connection.rpcEndpoint,
60600
+ // programId,
60601
+ // config,
60602
+ // );
60603
+ // }
60604
+ return await getProgramAccountsWithRetry(connection, programId, config);
60605
+ }
60266
60606
  /**
60267
60607
  * Standard getProgramAccounts with retry logic for transient errors.
60268
60608
  */ async function getProgramAccountsWithRetry(connection, programId, config) {
@@ -60289,7 +60629,7 @@ async function rpcRequest(rpcUrl, method, params) {
60289
60629
  * Otherwise falls back to getSignaturesForAddress + getTransaction.
60290
60630
  */ async function getTransactionsForAddress(connection, address, options) {
60291
60631
  if (isHeliusRpc(connection.rpcEndpoint)) {
60292
- return (await getTransactionsForAddressHelius(connection.rpcEndpoint, address, options)).filter((tx)=>tx !== null);
60632
+ return (await heliusGetTransactionsForAddress(connection.rpcEndpoint, address, options)).filter((tx)=>tx !== null);
60293
60633
  }
60294
60634
  const signatures = await connection.getSignaturesForAddress(address, {
60295
60635
  limit: options?.limit,
@@ -60300,59 +60640,6 @@ async function rpcRequest(rpcUrl, method, params) {
60300
60640
  })));
60301
60641
  return transactions.filter((tx)=>tx !== null);
60302
60642
  }
60303
- // FIXME: The param `limit` now controls page size, not total results
60304
- async function getTransactionsForAddressHelius(rpcUrl, address, options) {
60305
- const { transactionDetails = "full", limit = 100, before, commitment } = options || {};
60306
- const allTransactions = [];
60307
- let result;
60308
- let paginationToken = before;
60309
- do {
60310
- result = await rpcRequest(rpcUrl, "getTransactionsForAddress", [
60311
- address.toBase58(),
60312
- {
60313
- transactionDetails,
60314
- limit,
60315
- ...paginationToken && {
60316
- paginationToken
60317
- },
60318
- ...commitment && {
60319
- commitment
60320
- }
60321
- }
60322
- ]);
60323
- allTransactions.push(...result?.data || []);
60324
- paginationToken = result?.paginationToken;
60325
- }while (paginationToken)
60326
- return allTransactions;
60327
- }
60328
- async function getPriorityFeeEstimate(options) {
60329
- const { heliusApiKey = getHeliusApiKey(), tx, accountKeys, priorityLevel } = options;
60330
- if (!heliusApiKey) {
60331
- console.warn("getPriorityFeeEstimate is called but Helius API key not found");
60332
- return 0;
60333
- }
60334
- if (!tx && !accountKeys) {
60335
- throw new Error("Either tx or accountKeys must be provided");
60336
- }
60337
- const requestOptions = priorityLevel && priorityLevel !== "Recommended" ? {
60338
- priorityLevel
60339
- } : {
60340
- recommended: true
60341
- };
60342
- const param = tx ? {
60343
- transaction: bytes.bs58.encode(tx.serialize())
60344
- } : {
60345
- accountKeys
60346
- };
60347
- const rpcUrl = `https://mainnet.helius-rpc.com/?api-key=${heliusApiKey}`;
60348
- const result = await rpcRequest(rpcUrl, "getPriorityFeeEstimate", [
60349
- {
60350
- ...param,
60351
- options: requestOptions
60352
- }
60353
- ]);
60354
- return result.priorityFeeEstimate;
60355
- }
60356
60643
 
60357
60644
  /**
60358
60645
  * Fetches all the token accounts owned by the specified pubkey.
@@ -61694,6 +61981,66 @@ class JupiterApiClient {
61694
61981
  }
61695
61982
  }
61696
61983
 
61984
+ const DEFAULT_PHOENIX_API_URL = "https://perp-api.phoenix.trade";
61985
+ function normalizePhoenixApiUrl(apiUrl) {
61986
+ return apiUrl.replace(/\/+$/, "");
61987
+ }
61988
+ function publicKeyString(value) {
61989
+ return value instanceof web3_js.PublicKey ? value.toBase58() : value;
61990
+ }
61991
+ class PhoenixApiClient {
61992
+ url(path) {
61993
+ return `${normalizePhoenixApiUrl(this.apiUrl)}${path}`;
61994
+ }
61995
+ async fetchPhoenixSnapshot() {
61996
+ const url = this.url("/v1/exchange/snapshot");
61997
+ const response = await fetch(url);
61998
+ if (!response.ok) {
61999
+ const errorText = await response.text();
62000
+ throw new Error(`Failed to fetch Phoenix exchange snapshot: ${response.status} ${errorText || response.statusText}`);
62001
+ }
62002
+ const snapshot = await response.json();
62003
+ if (!snapshot.exchange || !Array.isArray(snapshot.markets)) {
62004
+ throw new Error(`Unexpected Phoenix snapshot response from ${url}`);
62005
+ }
62006
+ return snapshot;
62007
+ }
62008
+ async fetchTraderView(trader) {
62009
+ const url = this.url(`/v1/view/trader/${publicKeyString(trader)}`);
62010
+ const response = await fetch(url);
62011
+ if (response.status === 404) {
62012
+ return null;
62013
+ }
62014
+ if (!response.ok) {
62015
+ const errorText = await response.text();
62016
+ throw new Error(`Failed to fetch Phoenix trader view: ${response.status} ${errorText || response.statusText}`);
62017
+ }
62018
+ return await response.json();
62019
+ }
62020
+ async fetchTraderState(authority, pdaIndex) {
62021
+ const queryParams = new URLSearchParams({
62022
+ pdaIndex: `${pdaIndex}`
62023
+ });
62024
+ const url = `${this.url(`/trader/${publicKeyString(authority)}/state`)}?${queryParams}`;
62025
+ const response = await fetch(url);
62026
+ if (response.status === 404) {
62027
+ return null;
62028
+ }
62029
+ if (!response.ok) {
62030
+ const errorText = await response.text();
62031
+ throw new Error(`Failed to fetch Phoenix trader state: ${response.status} ${errorText || response.statusText}`);
62032
+ }
62033
+ const state = await response.json();
62034
+ if (!Array.isArray(state.traders)) {
62035
+ throw new Error(`Unexpected Phoenix trader state response from ${url}`);
62036
+ }
62037
+ return state;
62038
+ }
62039
+ constructor(){
62040
+ this.apiUrl = process.env.NEXT_PUBLIC_PHOENIX_API_URL || process.env.PHOENIX_API_URL || DEFAULT_PHOENIX_API_URL;
62041
+ }
62042
+ }
62043
+
61697
62044
  /**
61698
62045
  * Utility class for categorizing external positions by protocol type.
61699
62046
  *
@@ -62834,6 +63181,8 @@ class BaseClient {
62834
63181
  this.staging = resolveStaging(config?.useStaging);
62835
63182
  this.jupiterApiKey = config?.jupiterApiKey;
62836
63183
  this.jupiterApiClient = config?.jupiterApiClient;
63184
+ this.phoenixApiUrl = config?.phoenixApiUrl;
63185
+ this.phoenixApiClient = config?.phoenixApiClient;
62837
63186
  this.blockhashWithCache = new BlockhashWithCache(this.provider);
62838
63187
  }
62839
63188
  }
@@ -62857,7 +63206,7 @@ class BaseClient {
62857
63206
  }
62858
63207
  }
62859
63208
 
62860
- let TxBuilder$h = class TxBuilder extends BaseTxBuilder {
63209
+ let TxBuilder$i = class TxBuilder extends BaseTxBuilder {
62861
63210
  async resolveSwapInstructionContext(options) {
62862
63211
  const glamVault = this.client.base.vaultPda;
62863
63212
  const { quoteParams, quoteResponse } = options;
@@ -63039,14 +63388,14 @@ class JupiterSwapClient {
63039
63388
  this.base = base;
63040
63389
  this.vault = vault;
63041
63390
  this.klend = klend;
63042
- this.txBuilder = new TxBuilder$h(this);
63391
+ this.txBuilder = new TxBuilder$i(this);
63043
63392
  this.jupApi = this.base.jupiterApiClient || new JupiterApiClient({
63044
63393
  apiKey: this.base.jupiterApiKey
63045
63394
  });
63046
63395
  }
63047
63396
  }
63048
63397
 
63049
- let TxBuilder$g = class TxBuilder extends BaseTxBuilder {
63398
+ let TxBuilder$h = class TxBuilder extends BaseTxBuilder {
63050
63399
  async depositIxs(amount, glamSigner) {
63051
63400
  const marinadeState = await this.client.fetchMarinadeState();
63052
63401
  const { mSolMintAddress, marinadeStateAddress } = marinadeState;
@@ -63276,11 +63625,11 @@ class MarinadeClient {
63276
63625
  this.base = base;
63277
63626
  this.stake = stake;
63278
63627
  this.marinadeState = null;
63279
- this.txBuilder = new TxBuilder$g(this);
63628
+ this.txBuilder = new TxBuilder$h(this);
63280
63629
  }
63281
63630
  }
63282
63631
 
63283
- let TxBuilder$f = class TxBuilder extends BaseTxBuilder {
63632
+ let TxBuilder$g = class TxBuilder extends BaseTxBuilder {
63284
63633
  async wrapIxs(amount, glamSigner) {
63285
63634
  const vaultAta = this.client.base.getVaultAta(WSOL);
63286
63635
  const preIx = splToken.createAssociatedTokenAccountIdempotentInstruction(glamSigner, vaultAta, this.client.base.vaultPda, WSOL);
@@ -63538,17 +63887,15 @@ class VaultClient {
63538
63887
  }
63539
63888
  constructor(base){
63540
63889
  this.base = base;
63541
- this.txBuilder = new TxBuilder$f(this);
63890
+ this.txBuilder = new TxBuilder$g(this);
63542
63891
  }
63543
63892
  }
63544
63893
 
63545
- let TxBuilder$e = class TxBuilder extends BaseTxBuilder {
63894
+ let TxBuilder$f = class TxBuilder extends BaseTxBuilder {
63546
63895
  async initializeIx(params, glamSigner) {
63547
63896
  // stateInitKey = hash state name and get first 8 bytes
63548
63897
  // useful for re-computing state account PDA in the future
63549
- const stateInitKey = [
63550
- ...Buffer.from(anchor__namespace.utils.sha256.hash(charsToString(params.name))).subarray(0, 8)
63551
- ];
63898
+ const stateInitKey = await sha256First8Bytes(params.name);
63552
63899
  const created = new CreatedModel({
63553
63900
  key: stateInitKey
63554
63901
  });
@@ -63656,7 +64003,7 @@ class StateClient {
63656
64003
  }
63657
64004
  constructor(base){
63658
64005
  this.base = base;
63659
- this.txBuilder = new TxBuilder$e(this);
64006
+ this.txBuilder = new TxBuilder$f(this);
63660
64007
  }
63661
64008
  }
63662
64009
 
@@ -63965,7 +64312,7 @@ Obligation._layout = borsh.struct([
63965
64312
  borsh.array(borsh.u64(), 93, "padding3")
63966
64313
  ]);
63967
64314
 
63968
- let TxBuilder$d = class TxBuilder extends BaseTxBuilder {
64315
+ let TxBuilder$e = class TxBuilder extends BaseTxBuilder {
63969
64316
  refreshObligationIx(accounts) {
63970
64317
  const keys = [
63971
64318
  {
@@ -64780,11 +65127,11 @@ class KaminoLendingClient {
64780
65127
  this.vault = vault;
64781
65128
  this.reserves = new PkMap();
64782
65129
  this.obligations = new PkMap();
64783
- this.txBuilder = new TxBuilder$d(this);
65130
+ this.txBuilder = new TxBuilder$e(this);
64784
65131
  }
64785
65132
  }
64786
65133
 
64787
- let TxBuilder$c = class TxBuilder extends BaseTxBuilder {
65134
+ let TxBuilder$d = class TxBuilder extends BaseTxBuilder {
64788
65135
  async stakeTx(amount, farmState, txOptions = {}) {
64789
65136
  const glamSigner = txOptions.signer || this.client.base.signer;
64790
65137
  const farms = await this.client.fetchAndParseFarmStates([
@@ -65032,11 +65379,11 @@ class KaminoFarmClient {
65032
65379
  globalConfig.toBuffer(),
65033
65380
  mint.toBuffer()
65034
65381
  ], KAMINO_FARM_PROGRAM)[0];
65035
- this.txBuilder = new TxBuilder$c(this);
65382
+ this.txBuilder = new TxBuilder$d(this);
65036
65383
  }
65037
65384
  }
65038
65385
 
65039
- let TxBuilder$b = class TxBuilder extends BaseTxBuilder {
65386
+ let TxBuilder$c = class TxBuilder extends BaseTxBuilder {
65040
65387
  async depositTx(vault, amount, txOptions = {}) {
65041
65388
  const glamSigner = txOptions.signer || this.client.base.signer;
65042
65389
  const vaultState = await this.client.fetchAndParseVaultState(vault);
@@ -65207,7 +65554,7 @@ class KaminoVaultsClient {
65207
65554
  this.kaminoLending = kaminoLending;
65208
65555
  this.vaultStates = new PkMap();
65209
65556
  this.shareMintToVaultPdaMap = new PkMap();
65210
- this.txBuilder = new TxBuilder$b(this);
65557
+ this.txBuilder = new TxBuilder$c(this);
65211
65558
  }
65212
65559
  }
65213
65560
 
@@ -65324,7 +65671,7 @@ class KaminoVaultsClient {
65324
65671
  ])
65325
65672
  });
65326
65673
  }
65327
- let TxBuilder$a = class TxBuilder extends BaseTxBuilder {
65674
+ let TxBuilder$b = class TxBuilder extends BaseTxBuilder {
65328
65675
  async setTokenAccountsStatesIx(tokenAccounts, frozen, glamSigner) {
65329
65676
  return await this.client.base.mintProgram.methods.setTokenAccountsStates(frozen).accounts({
65330
65677
  glamState: this.client.base.statePda,
@@ -65519,9 +65866,7 @@ let TxBuilder$a = class TxBuilder extends BaseTxBuilder {
65519
65866
  }
65520
65867
  async initializeIxs(initMintParams, stateParams, glamSigner) {
65521
65868
  const decimals = typeof initMintParams.decimals === "number" ? initMintParams.decimals : null;
65522
- const stateInitKey = [
65523
- ...Buffer.from(anchor.utils.sha256.hash(charsToString(initMintParams.name))).subarray(0, 8)
65524
- ];
65869
+ const stateInitKey = await sha256First8Bytes(initMintParams.name);
65525
65870
  const glamState = getStatePda(stateInitKey, glamSigner, this.client.base.protocolProgram.programId);
65526
65871
  const postInstructions = [];
65527
65872
  // If stateParams is provided and is not empty, update the state account as a post instruction
@@ -65929,34 +66274,15 @@ class MintClient {
65929
66274
  return this.getPrice();
65930
66275
  }
65931
66276
  /**
65932
- * Fetches token holders of the GLAM mint using helius RPC
66277
+ * Fetches token holders of the GLAM mint using helius RPC. Falls back to
66278
+ * getHolders if helius API key is not provided or cluster is not mainnet.
65933
66279
  */ async fetchTokenHolders(showZeroBalance = true) {
65934
- // `getTokenAccounts` is a helius only RPC endpoint, we hardcode the URL here
65935
- // in case users choose to use a non-helius RPC. Fall back to getHolders if
65936
- // helius API key is not provided
65937
- const heliusApiKey = process.env.NEXT_PUBLIC_HELIUS_API_KEY || process.env.HELIUS_API_KEY;
65938
- if (!heliusApiKey || this.base.cluster !== exports.ClusterNetwork.Mainnet) {
66280
+ if (!getHeliusApiKey() || this.base.cluster !== exports.ClusterNetwork.Mainnet) {
65939
66281
  return await this.getHolders(showZeroBalance);
65940
66282
  }
65941
- const response = await fetch(`https://mainnet.helius-rpc.com/?api-key=${heliusApiKey}`, {
65942
- method: "POST",
65943
- headers: {
65944
- "Content-Type": "application/json"
65945
- },
65946
- body: JSON.stringify({
65947
- jsonrpc: "2.0",
65948
- id: "1",
65949
- method: "getTokenAccounts",
65950
- params: {
65951
- mint: this.base.mintPda.toBase58(),
65952
- options: {
65953
- showZeroBalance
65954
- }
65955
- }
65956
- })
66283
+ const tokenAccounts = await getTokenAccountsByMint(this.base.mintPda, {
66284
+ showZeroBalance
65957
66285
  });
65958
- const data = await response.json();
65959
- const { token_accounts: tokenAccounts } = data.result;
65960
66286
  const { mint, tokenProgram } = await fetchMintAndTokenProgram(this.base.connection, this.base.mintPda);
65961
66287
  return tokenAccounts.map((ta)=>({
65962
66288
  owner: new web3_js.PublicKey(ta.owner),
@@ -65964,9 +66290,9 @@ class MintClient {
65964
66290
  mint: this.base.mintPda,
65965
66291
  programId: tokenProgram,
65966
66292
  decimals: mint.decimals,
65967
- amount: ta.amount,
65968
- uiAmount: Number(ta.amount) / 10 ** mint.decimals,
65969
- frozen: ta.frozen
66293
+ amount: String(ta.amount),
66294
+ uiAmount: toUiAmount(new anchor.BN(ta.amount), mint.decimals),
66295
+ frozen: Boolean(ta.frozen)
65970
66296
  }));
65971
66297
  }
65972
66298
  // Can be very slow. Use fetchTokenHolders when possible.
@@ -66095,11 +66421,11 @@ class MintClient {
66095
66421
  constructor(base, getPrice){
66096
66422
  this.base = base;
66097
66423
  this.getPrice = getPrice;
66098
- this.txBuilder = new TxBuilder$a(this);
66424
+ this.txBuilder = new TxBuilder$b(this);
66099
66425
  }
66100
66426
  }
66101
66427
 
66102
- let TxBuilder$9 = class TxBuilder extends BaseTxBuilder {
66428
+ let TxBuilder$a = class TxBuilder extends BaseTxBuilder {
66103
66429
  async subscribeIxs(amount, signer) {
66104
66430
  const { baseAssetMint: depositAsset } = await this.client.base.fetchStateModel();
66105
66431
  const mintTo = this.client.base.getMintAta(signer);
@@ -66409,7 +66735,7 @@ class InvestClient {
66409
66735
  }
66410
66736
  constructor(base){
66411
66737
  this.base = base;
66412
- this.txBuilder = new TxBuilder$9(this);
66738
+ this.txBuilder = new TxBuilder$a(this);
66413
66739
  }
66414
66740
  }
66415
66741
 
@@ -66984,7 +67310,7 @@ function resolveRouteAccountPubkey(meta, payer, nonce) {
66984
67310
  }
66985
67311
  throw new Error("Unsupported LayerZero OFT route account placeholder");
66986
67312
  }
66987
- let TxBuilder$8 = class TxBuilder extends BaseTxBuilder {
67313
+ let TxBuilder$9 = class TxBuilder extends BaseTxBuilder {
66988
67314
  async addLayerzeroOftRouteIx(route, signer) {
66989
67315
  return await this.client.base.extBridgeProgram.methods.addLayerzeroOftRoute(normalizeRoute(route)).accountsPartial({
66990
67316
  glamState: this.client.base.statePda,
@@ -67392,7 +67718,7 @@ class BridgeClient {
67392
67718
  }
67393
67719
  constructor(base){
67394
67720
  this.base = base;
67395
- this.txBuilder = new TxBuilder$8(this);
67721
+ this.txBuilder = new TxBuilder$9(this);
67396
67722
  this.oft = new LayerzeroOftBridgeProtocolClient(this);
67397
67723
  }
67398
67724
  }
@@ -68296,7 +68622,7 @@ class PriceClient {
68296
68622
  }
68297
68623
  }
68298
68624
 
68299
- let TxBuilder$7 = class TxBuilder extends BaseTxBuilder {
68625
+ let TxBuilder$8 = class TxBuilder extends BaseTxBuilder {
68300
68626
  async crystallizeFeesIxs(glamSigner) {
68301
68627
  const glamState = this.client.base.statePda;
68302
68628
  const glamMint = this.client.base.mintPda;
@@ -68454,11 +68780,11 @@ class FeesClient {
68454
68780
  constructor(base, price){
68455
68781
  this.base = base;
68456
68782
  this.price = price;
68457
- this.txBuilder = new TxBuilder$7(this);
68783
+ this.txBuilder = new TxBuilder$8(this);
68458
68784
  }
68459
68785
  }
68460
68786
 
68461
- let TxBuilder$6 = class TxBuilder extends BaseTxBuilder {
68787
+ let TxBuilder$7 = class TxBuilder extends BaseTxBuilder {
68462
68788
  async emergencyAccessUpdateIx(args, signer) {
68463
68789
  return await this.client.base.protocolProgram.methods.emergencyAccessUpdate(new EmergencyAccessUpdateArgs(args)).accounts({
68464
68790
  glamState: this.client.base.statePda,
@@ -68623,11 +68949,11 @@ class AccessClient {
68623
68949
  }
68624
68950
  constructor(base){
68625
68951
  this.base = base;
68626
- this.txBuilder = new TxBuilder$6(this);
68952
+ this.txBuilder = new TxBuilder$7(this);
68627
68953
  }
68628
68954
  }
68629
68955
 
68630
- let TxBuilder$5 = class TxBuilder extends BaseTxBuilder {
68956
+ let TxBuilder$6 = class TxBuilder extends BaseTxBuilder {
68631
68957
  async applyStateTimelockIx(glamSigner) {
68632
68958
  return await this.client.base.protocolProgram.methods.updateStateApplyTimelock().accounts({
68633
68959
  glamState: this.client.base.statePda,
@@ -68705,11 +69031,11 @@ class TimelockClient {
68705
69031
  constructor(base, stateClient){
68706
69032
  this.base = base;
68707
69033
  this.stateClient = stateClient;
68708
- this.txBuilder = new TxBuilder$5(this);
69034
+ this.txBuilder = new TxBuilder$6(this);
68709
69035
  }
68710
69036
  }
68711
69037
 
68712
- let TxBuilder$4 = class TxBuilder extends BaseTxBuilder {
69038
+ let TxBuilder$5 = class TxBuilder extends BaseTxBuilder {
68713
69039
  async initializeAndDelegateStakeIxs(vote, amount, glamSigner) {
68714
69040
  const [stakeAccount, createStakeAccountIx] = await this.client.createStakeAccount(glamSigner);
68715
69041
  const glamState = this.client.base.statePda;
@@ -68922,11 +69248,11 @@ class StakeClient {
68922
69248
  }
68923
69249
  constructor(base){
68924
69250
  this.base = base;
68925
- this.txBuilder = new TxBuilder$4(this);
69251
+ this.txBuilder = new TxBuilder$5(this);
68926
69252
  }
68927
69253
  }
68928
69254
 
68929
- let TxBuilder$3 = class TxBuilder extends BaseTxBuilder {
69255
+ let TxBuilder$4 = class TxBuilder extends BaseTxBuilder {
68930
69256
  async depositSolIxs(stakePool, lamports, glamSigner) {
68931
69257
  const { programId: stakePoolProgram, poolMint, withdrawAuthority, feeAccount, tokenProgramId: tokenProgram, reserveStake } = await this.client.getStakePoolAccountData(stakePool);
68932
69258
  const glamVault = this.client.base.vaultPda;
@@ -69124,7 +69450,7 @@ class StakePoolClient {
69124
69450
  this.base = base;
69125
69451
  this.stake = stake;
69126
69452
  this.marinade = marinade;
69127
- this.txBuilder = new TxBuilder$3(this);
69453
+ this.txBuilder = new TxBuilder$4(this);
69128
69454
  }
69129
69455
  }
69130
69456
 
@@ -69174,7 +69500,7 @@ class CctpBridgeEvent {
69174
69500
  this.uiAmount = toUiAmount(this.amount, 6);
69175
69501
  }
69176
69502
  }
69177
- let TxBuilder$2 = class TxBuilder extends BaseTxBuilder {
69503
+ let TxBuilder$3 = class TxBuilder extends BaseTxBuilder {
69178
69504
  /**
69179
69505
  * Returns a transaction that calls CCTP's `depositForBurn` instruction that bridges USDC to another chain.
69180
69506
  * A keypair is generated for the message sent event account, which must be included as a transaction signer.
@@ -69705,7 +70031,7 @@ class CctpClient {
69705
70031
  }
69706
70032
  constructor(base){
69707
70033
  this.base = base;
69708
- this.txBuilder = new TxBuilder$2(this);
70034
+ this.txBuilder = new TxBuilder$3(this);
69709
70035
  }
69710
70036
  }
69711
70037
 
@@ -69723,7 +70049,7 @@ function toReservedBytes(value) {
69723
70049
  }
69724
70050
  return bytes;
69725
70051
  }
69726
- let TxBuilder$1 = class TxBuilder extends BaseTxBuilder {
70052
+ let TxBuilder$2 = class TxBuilder extends BaseTxBuilder {
69727
70053
  async upsertExternalPositionIx(params, signer) {
69728
70054
  return await this.client.base.extEpiProgram.methods.upsertExternalPosition({
69729
70055
  positionId: toFixedArray32(params.positionId, "positionId"),
@@ -69832,7 +70158,7 @@ class EpiClient {
69832
70158
  }
69833
70159
  constructor(base){
69834
70160
  this.base = base;
69835
- this.txBuilder = new TxBuilder$1(this);
70161
+ this.txBuilder = new TxBuilder$2(this);
69836
70162
  }
69837
70163
  }
69838
70164
 
@@ -69854,7 +70180,7 @@ function getLoopscaleLoanPda(borrower, nonce, programId = LOOPSCALE_PROGRAM_ID)
69854
70180
  toBn(nonce).toArrayLike(Buffer, "le", 8)
69855
70181
  ], programId)[0];
69856
70182
  }
69857
- let TxBuilder = class TxBuilder extends BaseTxBuilder {
70183
+ let TxBuilder$1 = class TxBuilder extends BaseTxBuilder {
69858
70184
  async createLoanIx(params, accounts, signer) {
69859
70185
  return await this.client.base.extLoopscaleProgram.methods.createLoan({
69860
70186
  nonce: params.nonce
@@ -70007,9 +70333,440 @@ class LoopscaleClient {
70007
70333
  const tx = await this.txBuilder.borrowPrincipalTx(params, accounts, txOptions);
70008
70334
  return await this.base.sendAndConfirm(tx);
70009
70335
  }
70336
+ constructor(base){
70337
+ this.base = base;
70338
+ this.txBuilder = new TxBuilder$1(this);
70339
+ }
70340
+ }
70341
+
70342
+ function meta(pubkey, isWritable) {
70343
+ return {
70344
+ pubkey: new web3_js.PublicKey(pubkey),
70345
+ isSigner: false,
70346
+ isWritable
70347
+ };
70348
+ }
70349
+ function getPhoenixTraderPda(authority, traderPdaIndex = 0, subaccountIndex = 0) {
70350
+ return web3_js.PublicKey.findProgramAddressSync([
70351
+ Buffer.from("trader"),
70352
+ authority.toBuffer(),
70353
+ Buffer.from([
70354
+ traderPdaIndex,
70355
+ subaccountIndex
70356
+ ])
70357
+ ], PHOENIX_PROGRAM_ID)[0];
70358
+ }
70359
+ function getPhoenixSplineCollectionPda(market) {
70360
+ return web3_js.PublicKey.findProgramAddressSync([
70361
+ Buffer.from("spline"),
70362
+ market.toBuffer()
70363
+ ], PHOENIX_PROGRAM_ID)[0];
70364
+ }
70365
+ function getPhoenixGlobalVaultPda(mint) {
70366
+ return web3_js.PublicKey.findProgramAddressSync([
70367
+ Buffer.from("vault"),
70368
+ mint.toBuffer()
70369
+ ], PHOENIX_PROGRAM_ID)[0];
70370
+ }
70371
+ function getEmberStatePda() {
70372
+ return web3_js.PublicKey.findProgramAddressSync([
70373
+ PHOENIX_PROGRAM_ID.toBuffer(),
70374
+ Buffer.from("state")
70375
+ ], EMBER_PROGRAM_ID)[0];
70376
+ }
70377
+ function getEmberVaultPda() {
70378
+ return web3_js.PublicKey.findProgramAddressSync([
70379
+ PHOENIX_PROGRAM_ID.toBuffer(),
70380
+ Buffer.from("vault")
70381
+ ], EMBER_PROGRAM_ID)[0];
70382
+ }
70383
+ let TxBuilder = class TxBuilder extends BaseTxBuilder {
70384
+ getEmberCpiAccounts(accounts, signer) {
70385
+ return {
70386
+ glamState: this.client.base.statePda,
70387
+ glamVault: this.client.base.vaultPda,
70388
+ glamSigner: signer || this.client.base.signer,
70389
+ integrationAuthority: this.client.getIntegrationAuthorityPda(),
70390
+ cpiProgram: EMBER_PROGRAM_ID,
70391
+ glamProtocolProgram: this.client.base.protocolProgram.programId,
70392
+ systemProgram: web3_js.SystemProgram.programId,
70393
+ emberState: accounts.emberState || this.client.getEmberStatePda(),
70394
+ inputMint: accounts.inputMint,
70395
+ outputMint: accounts.outputMint,
70396
+ inputTokenAccount: accounts.inputTokenAccount || this.client.base.getVaultAta(accounts.inputMint),
70397
+ outputTokenAccount: accounts.outputTokenAccount || this.client.base.getVaultAta(accounts.outputMint, accounts.tokenProgram),
70398
+ emberVault: accounts.emberVault || this.client.getEmberVaultPda(),
70399
+ tokenProgram: accounts.tokenProgram || splToken.TOKEN_PROGRAM_ID
70400
+ };
70401
+ }
70402
+ /**
70403
+ * Account map shared by every ext_phoenix Phoenix-CPI instruction
70404
+ * (`glam_state`, `glam_vault`, `glam_signer`, integration authority,
70405
+ * `cpi_program=Phoenix`, the GLAM protocol program, system program).
70406
+ */ getPhoenixCpiAccounts(signer) {
70407
+ return {
70408
+ glamState: this.client.base.statePda,
70409
+ glamVault: this.client.base.vaultPda,
70410
+ glamSigner: signer || this.client.base.signer,
70411
+ integrationAuthority: this.client.getIntegrationAuthorityPda(),
70412
+ cpiProgram: PHOENIX_PROGRAM_ID,
70413
+ glamProtocolProgram: this.client.base.protocolProgram.programId,
70414
+ systemProgram: web3_js.SystemProgram.programId
70415
+ };
70416
+ }
70417
+ async setPolicyIx(policy, signer) {
70418
+ const policyInput = {
70419
+ marketsAllowlist: policy.marketsAllowlist,
70420
+ allowedOrderTypes: Buffer.from(policy.allowedOrderTypes),
70421
+ maxPriceDeviationBps: policy.maxPriceDeviationBps,
70422
+ requireReduceOnlyOrders: policy.requireReduceOnlyOrders,
70423
+ maxReferencePriceAgeSecs: policy.maxReferencePriceAgeSecs
70424
+ };
70425
+ return await this.client.base.extPhoenixProgram.methods.setPhoenixPolicy(policyInput).accounts({
70426
+ glamState: this.client.base.statePda,
70427
+ glamSigner: signer || this.client.base.signer
70428
+ }).instruction();
70429
+ }
70430
+ async registerTraderIx(params, accounts = {}, signer) {
70431
+ return await this.client.base.extPhoenixProgram.methods.registerTrader(params).accountsPartial({
70432
+ ...this.getPhoenixCpiAccounts(signer),
70433
+ logAuthority: accounts.logAuthority || PHOENIX_LOG_AUTHORITY,
70434
+ globalConfig: accounts.globalConfig || PHOENIX_GLOBAL_CONFIG,
70435
+ traderAccount: accounts.traderAccount || this.client.getTraderPda(params.traderPdaIndex, params.traderSubaccountIndex)
70436
+ }).instruction();
70437
+ }
70438
+ async updateTraderStateIx(accounts, signer) {
70439
+ return await this.client.base.extPhoenixProgram.methods.updateTraderState().accounts(this.getPhoenixCpiAccounts(signer)).remainingAccounts(accounts.remainingAccounts).instruction();
70440
+ }
70441
+ async emberDepositIx(params, accounts, signer) {
70442
+ return await this.client.base.extPhoenixProgram.methods.deposit(params).accounts(this.getEmberCpiAccounts(accounts, signer)).instruction();
70443
+ }
70444
+ async depositFundsIx(params, accounts, signer) {
70445
+ return await this.client.base.extPhoenixProgram.methods.depositFunds(params).accounts(this.getPhoenixCpiAccounts(signer)).remainingAccounts(accounts.remainingAccounts).instruction();
70446
+ }
70447
+ async emberWithdrawIx(params, accounts, signer) {
70448
+ return await this.client.base.extPhoenixProgram.methods.withdraw(params).accounts(this.getEmberCpiAccounts(accounts, signer)).instruction();
70449
+ }
70450
+ async withdrawFundsIx(params, accounts, signer) {
70451
+ return await this.client.base.extPhoenixProgram.methods.withdrawFunds(params).accounts(this.getPhoenixCpiAccounts(signer)).remainingAccounts(accounts.remainingAccounts).instruction();
70452
+ }
70453
+ async placeLimitOrderIx(packet, accounts, signer) {
70454
+ return await this.client.base.extPhoenixProgram.methods.placeLimitOrder(packet).accounts(this.getPhoenixCpiAccounts(signer)).remainingAccounts(accounts.remainingAccounts).instruction();
70455
+ }
70456
+ async placeMarketOrderIx(packet, accounts, signer) {
70457
+ return await this.client.base.extPhoenixProgram.methods.placeMarketOrder(packet).accounts(this.getPhoenixCpiAccounts(signer)).remainingAccounts(accounts.remainingAccounts).instruction();
70458
+ }
70459
+ async placePostOnlyOrderIx(packet, accounts, signer) {
70460
+ return await this.client.base.extPhoenixProgram.methods.placePostOnlyOrder(packet).accounts(this.getPhoenixCpiAccounts(signer)).remainingAccounts(accounts.remainingAccounts).instruction();
70461
+ }
70462
+ async cancelAllIx(accounts, signer) {
70463
+ return await this.client.base.extPhoenixProgram.methods.cancelAll().accounts(this.getPhoenixCpiAccounts(signer)).remainingAccounts(accounts.remainingAccounts).instruction();
70464
+ }
70465
+ async cancelOrdersByIdIx(orderIds, accounts, signer) {
70466
+ return await this.client.base.extPhoenixProgram.methods.cancelOrdersById(orderIds).accounts(this.getPhoenixCpiAccounts(signer)).remainingAccounts(accounts.remainingAccounts).instruction();
70467
+ }
70468
+ async cancelUpToIx(args, accounts, signer) {
70469
+ return await this.client.base.extPhoenixProgram.methods.cancelUpTo(args).accounts(this.getPhoenixCpiAccounts(signer)).remainingAccounts(accounts.remainingAccounts).instruction();
70470
+ }
70471
+ async setPolicyTx(policy, txOptions = {}) {
70472
+ const ix = await this.setPolicyIx(policy, txOptions.signer);
70473
+ return await this.buildVersionedTx([
70474
+ ix
70475
+ ], txOptions);
70476
+ }
70477
+ async registerTraderTx(params, accounts = {}, txOptions = {}) {
70478
+ const ix = await this.registerTraderIx(params, accounts, txOptions.signer);
70479
+ return await this.buildVersionedTx([
70480
+ ix
70481
+ ], txOptions);
70482
+ }
70483
+ async updateTraderStateTx(accounts, txOptions = {}) {
70484
+ const ix = await this.updateTraderStateIx(accounts, txOptions.signer);
70485
+ return await this.buildVersionedTx([
70486
+ ix
70487
+ ], txOptions);
70488
+ }
70489
+ /**
70490
+ * Remaining-accounts list for `deposit_funds` — the vault token account
70491
+ * holding the canonical collateral, the trader PDA, Phoenix's global vault
70492
+ * for that mint, the SPL token program, and the trader-index/active-buffer
70493
+ * chunks from the snapshot.
70494
+ */ getDepositRemainingAccounts(snapshot, indexes = {}) {
70495
+ const mint = new web3_js.PublicKey(snapshot.exchange.canonicalMint);
70496
+ const vaultAta = this.client.base.getVaultAta(mint);
70497
+ return [
70498
+ ...this.client.getPhoenixRemainingPrefix(true),
70499
+ meta(this.client.base.vaultPda, true),
70500
+ meta(vaultAta, true),
70501
+ meta(this.client.getTraderPda(indexes.traderPdaIndex, indexes.subaccountIndex), true),
70502
+ meta(this.client.getGlobalVaultPda(mint), true),
70503
+ meta(splToken.TOKEN_PROGRAM_ID, false),
70504
+ ...snapshot.exchange.globalTraderIndex.map((key)=>meta(key, true)),
70505
+ ...snapshot.exchange.activeTraderBuffer.map((key)=>meta(key, true))
70506
+ ];
70507
+ }
70508
+ /**
70509
+ * Remaining-accounts list for `withdraw_funds`. Same shape as the deposit
70510
+ * variant plus the perp asset map and the global withdraw queue, which the
70511
+ * withdraw path mutates.
70512
+ */ getWithdrawRemainingAccounts(snapshot, indexes = {}) {
70513
+ const mint = new web3_js.PublicKey(snapshot.exchange.canonicalMint);
70514
+ const vaultAta = this.client.base.getVaultAta(mint);
70515
+ return [
70516
+ ...this.client.getPhoenixRemainingPrefix(true),
70517
+ meta(this.client.base.vaultPda, true),
70518
+ meta(this.client.getTraderPda(indexes.traderPdaIndex, indexes.subaccountIndex), true),
70519
+ meta(snapshot.exchange.perpAssetMap, true),
70520
+ meta(this.client.getGlobalVaultPda(mint), true),
70521
+ meta(vaultAta, true),
70522
+ meta(splToken.TOKEN_PROGRAM_ID, false),
70523
+ ...snapshot.exchange.globalTraderIndex.map((key)=>meta(key, true)),
70524
+ ...snapshot.exchange.activeTraderBuffer.map((key)=>meta(key, true)),
70525
+ meta(snapshot.exchange.withdrawQueue, true)
70526
+ ];
70527
+ }
70528
+ async deposit(amount, txOptions = {}) {
70529
+ const snapshot = await this.client.phoenixApi.fetchPhoenixSnapshot();
70530
+ const usdcMint = new web3_js.PublicKey(snapshot.exchange.usdcMint);
70531
+ const canonicalMint = new web3_js.PublicKey(snapshot.exchange.canonicalMint);
70532
+ const ixs = [
70533
+ // create canonical token ata
70534
+ splToken.createAssociatedTokenAccountIdempotentInstruction(txOptions.signer || this.client.base.signer, this.client.base.getVaultAta(canonicalMint), this.client.base.vaultPda, canonicalMint),
70535
+ await this.emberDepositIx({
70536
+ amount
70537
+ }, {
70538
+ inputMint: usdcMint,
70539
+ outputMint: canonicalMint
70540
+ }, txOptions.signer),
70541
+ await this.depositFundsIx({
70542
+ amount
70543
+ }, {
70544
+ remainingAccounts: this.getDepositRemainingAccounts(snapshot)
70545
+ }, txOptions.signer)
70546
+ ];
70547
+ return await this.buildVersionedTx(ixs, txOptions);
70548
+ }
70549
+ async withdraw(amount, txOptions = {}) {
70550
+ const snapshot = await this.client.phoenixApi.fetchPhoenixSnapshot();
70551
+ const usdcMint = new web3_js.PublicKey(snapshot.exchange.usdcMint);
70552
+ const canonicalMint = new web3_js.PublicKey(snapshot.exchange.canonicalMint);
70553
+ const ixs = [
70554
+ // create USDC ata
70555
+ splToken.createAssociatedTokenAccountIdempotentInstruction(txOptions.signer || this.client.base.signer, this.client.base.getVaultAta(usdcMint), this.client.base.vaultPda, usdcMint),
70556
+ await this.withdrawFundsIx({
70557
+ amount
70558
+ }, {
70559
+ remainingAccounts: this.getWithdrawRemainingAccounts(snapshot)
70560
+ }, txOptions.signer),
70561
+ await this.emberWithdrawIx({
70562
+ amount
70563
+ }, {
70564
+ inputMint: usdcMint,
70565
+ outputMint: canonicalMint
70566
+ }, txOptions.signer)
70567
+ ];
70568
+ return await this.buildVersionedTx(ixs, txOptions);
70569
+ }
70570
+ async depositFundsTx(params, accounts, txOptions = {}) {
70571
+ const ix = await this.depositFundsIx(params, accounts, txOptions.signer);
70572
+ return await this.buildVersionedTx([
70573
+ ix
70574
+ ], txOptions);
70575
+ }
70576
+ async withdrawFundsTx(params, accounts, txOptions = {}) {
70577
+ const ix = await this.withdrawFundsIx(params, accounts, txOptions.signer);
70578
+ return await this.buildVersionedTx([
70579
+ ix
70580
+ ], txOptions);
70581
+ }
70582
+ async placeLimitOrderTx(packet, accounts, txOptions = {}) {
70583
+ const ix = await this.placeLimitOrderIx(packet, accounts, txOptions.signer);
70584
+ return await this.buildVersionedTx([
70585
+ ix
70586
+ ], txOptions);
70587
+ }
70588
+ async placeMarketOrderTx(packet, accounts, txOptions = {}) {
70589
+ const ix = await this.placeMarketOrderIx(packet, accounts, txOptions.signer);
70590
+ return await this.buildVersionedTx([
70591
+ ix
70592
+ ], txOptions);
70593
+ }
70594
+ async placePostOnlyOrderTx(packet, accounts, txOptions = {}) {
70595
+ const ix = await this.placePostOnlyOrderIx(packet, accounts, txOptions.signer);
70596
+ return await this.buildVersionedTx([
70597
+ ix
70598
+ ], txOptions);
70599
+ }
70600
+ async cancelAllTx(accounts, txOptions = {}) {
70601
+ const ix = await this.cancelAllIx(accounts, txOptions.signer);
70602
+ return await this.buildVersionedTx([
70603
+ ix
70604
+ ], txOptions);
70605
+ }
70606
+ async cancelOrdersByIdTx(orderIds, accounts, txOptions = {}) {
70607
+ const ix = await this.cancelOrdersByIdIx(orderIds, accounts, txOptions.signer);
70608
+ return await this.buildVersionedTx([
70609
+ ix
70610
+ ], txOptions);
70611
+ }
70612
+ async cancelUpToTx(args, accounts, txOptions = {}) {
70613
+ const ix = await this.cancelUpToIx(args, accounts, txOptions.signer);
70614
+ return await this.buildVersionedTx([
70615
+ ix
70616
+ ], txOptions);
70617
+ }
70618
+ };
70619
+ class PhoenixClient {
70620
+ /** The ext_phoenix program id this client talks to. */ get programId() {
70621
+ return this.base.extPhoenixProgram.programId;
70622
+ }
70623
+ /** Bit flag identifying Phoenix inside the GLAM integration ACL bitmask. */ get protocolBitflag() {
70624
+ return PHOENIX_PROTOCOL;
70625
+ }
70626
+ /** PDA the ext_phoenix program signs CPIs with into Phoenix and Ember. */ getIntegrationAuthorityPda() {
70627
+ return getIntegrationAuthorityPda(this.base.extPhoenixProgram.programId);
70628
+ }
70629
+ /**
70630
+ * PDA of a Phoenix trader account owned by the GLAM vault (defaults to the
70631
+ * vault PDA as authority). `traderPdaIndex` selects the parent trader and
70632
+ * `subaccountIndex` selects a child subaccount under that parent.
70633
+ */ getTraderPda(traderPdaIndex = 0, subaccountIndex = 0, authority = this.base.vaultPda) {
70634
+ return getPhoenixTraderPda(authority, traderPdaIndex, subaccountIndex);
70635
+ }
70636
+ /** PDA of the spline-collection account associated with a Phoenix market. */ getSplineCollectionPda(market) {
70637
+ return getPhoenixSplineCollectionPda(market);
70638
+ }
70639
+ /** PDA of Phoenix's global-vault token account for a given mint. */ getGlobalVaultPda(mint) {
70640
+ return getPhoenixGlobalVaultPda(mint);
70641
+ }
70642
+ /** PDA of the Ember exchange-state account that backs Phoenix conversions. */ getEmberStatePda() {
70643
+ return getEmberStatePda();
70644
+ }
70645
+ /** PDA of Ember's USDC vault that mints/burns canonical collateral. */ getEmberVaultPda() {
70646
+ return getEmberVaultPda();
70647
+ }
70648
+ /**
70649
+ * The three accounts every Phoenix CPI begins with (program, log authority,
70650
+ * global config). `globalConfigWritable` toggles the writable flag on the
70651
+ * global config — set true for instructions that mutate exchange state.
70652
+ */ getPhoenixRemainingPrefix(globalConfigWritable) {
70653
+ return [
70654
+ meta(PHOENIX_PROGRAM_ID, false),
70655
+ meta(PHOENIX_LOG_AUTHORITY, false),
70656
+ meta(PHOENIX_GLOBAL_CONFIG, globalConfigWritable)
70657
+ ];
70658
+ }
70659
+ /**
70660
+ * Remaining-accounts list for place/cancel/order-book CPIs against a single
70661
+ * Phoenix market. Includes the trader PDA, perp asset map, trader indices,
70662
+ * the market itself, and its spline collection.
70663
+ */ getMarketRemainingAccounts(snapshot, market, indexes = {}) {
70664
+ const marketPubkey = new web3_js.PublicKey(market);
70665
+ return [
70666
+ ...this.getPhoenixRemainingPrefix(true),
70667
+ meta(this.base.vaultPda, true),
70668
+ meta(this.getTraderPda(indexes.traderPdaIndex, indexes.subaccountIndex), true),
70669
+ meta(snapshot.exchange.perpAssetMap, true),
70670
+ ...snapshot.exchange.globalTraderIndex.map((key)=>meta(key, true)),
70671
+ ...snapshot.exchange.activeTraderBuffer.map((key)=>meta(key, true)),
70672
+ meta(marketPubkey, true),
70673
+ meta(this.getSplineCollectionPda(marketPubkey), true)
70674
+ ];
70675
+ }
70676
+ /**
70677
+ * Remaining-accounts list for `update_trader_state` — settles funding for
70678
+ * the trader and may evict it from the active-trader buffer once it no
70679
+ * longer holds resting orders.
70680
+ */ getUpdateTraderStateRemainingAccounts(snapshot, indexes = {}) {
70681
+ return [
70682
+ ...this.getPhoenixRemainingPrefix(false),
70683
+ meta(this.getTraderPda(indexes.traderPdaIndex, indexes.subaccountIndex), true),
70684
+ meta(snapshot.exchange.perpAssetMap, false),
70685
+ ...snapshot.exchange.globalTraderIndex.map((key)=>meta(key, true)),
70686
+ ...snapshot.exchange.activeTraderBuffer.map((key)=>meta(key, true))
70687
+ ];
70688
+ }
70689
+ /** Fetches the on-chain PhoenixPolicy stored under this vault, if any. */ async fetchPolicy() {
70690
+ return await this.base.fetchProtocolPolicy(this.programId, PHOENIX_PROTOCOL, PhoenixPolicy);
70691
+ }
70692
+ /** Writes the PhoenixPolicy (market allowlist, order types, etc.). */ async setPolicy(policy, txOptions = {}) {
70693
+ const tx = await this.txBuilder.setPolicyTx(policy, txOptions);
70694
+ return await this.base.sendAndConfirm(tx);
70695
+ }
70696
+ /**
70697
+ * Creates a Phoenix trader account for the vault (parent or child subaccount)
70698
+ * sized to hold `maxPositions`.
70699
+ */ async registerTrader(params, accounts = {}, txOptions = {}) {
70700
+ const tx = await this.txBuilder.registerTraderTx(params, accounts, txOptions);
70701
+ return await this.base.sendAndConfirm(tx);
70702
+ }
70703
+ /**
70704
+ * Settles funding for the vault's trader and may evict it from the active
70705
+ * buffer when no resting orders remain. Idempotent housekeeping call.
70706
+ */ async updateTraderState(accounts, txOptions = {}) {
70707
+ const tx = await this.txBuilder.updateTraderStateTx(accounts, txOptions);
70708
+ return await this.base.sendAndConfirm(tx);
70709
+ }
70710
+ /**
70711
+ * Full deposit flow in one transaction: converts USDC to canonical
70712
+ * collateral via Ember, then deposits the canonical amount into the vault's
70713
+ * Phoenix trader account.
70714
+ */ async deposit(amount, txOptions = {}) {
70715
+ const tx = await this.txBuilder.deposit(new anchor.BN(amount), txOptions);
70716
+ return await this.base.sendAndConfirm(tx);
70717
+ }
70718
+ /**
70719
+ * Full withdraw flow in one transaction: withdraws canonical collateral
70720
+ * from Phoenix and converts it back to USDC via Ember.
70721
+ */ async withdraw(amount, txOptions = {}) {
70722
+ const tx = await this.txBuilder.withdraw(new anchor.BN(amount), txOptions);
70723
+ return await this.base.sendAndConfirm(tx);
70724
+ }
70725
+ /**
70726
+ * Phoenix-only `deposit_funds` (no Ember leg) — moves an already-canonical
70727
+ * token balance from the vault's token account into Phoenix.
70728
+ */ async depositFunds(params, accounts, txOptions = {}) {
70729
+ const tx = await this.txBuilder.depositFundsTx(params, accounts, txOptions);
70730
+ return await this.base.sendAndConfirm(tx);
70731
+ }
70732
+ /**
70733
+ * Phoenix-only `withdraw_funds` (no Ember leg) — pulls canonical collateral
70734
+ * out of Phoenix back to the vault's token account.
70735
+ */ async withdrawFunds(params, accounts, txOptions = {}) {
70736
+ const tx = await this.txBuilder.withdrawFundsTx(params, accounts, txOptions);
70737
+ return await this.base.sendAndConfirm(tx);
70738
+ }
70739
+ /** Places a Phoenix limit order against the market in `accounts`. */ async placeLimitOrder(packet, accounts, txOptions = {}) {
70740
+ const tx = await this.txBuilder.placeLimitOrderTx(packet, accounts, txOptions);
70741
+ return await this.base.sendAndConfirm(tx);
70742
+ }
70743
+ /** Places an immediate-or-cancel market order against the market. */ async placeMarketOrder(packet, accounts, txOptions = {}) {
70744
+ const tx = await this.txBuilder.placeMarketOrderTx(packet, accounts, txOptions);
70745
+ return await this.base.sendAndConfirm(tx);
70746
+ }
70747
+ /** Places a post-only (maker-only) order; rejected if it would cross. */ async placePostOnlyOrder(packet, accounts, txOptions = {}) {
70748
+ const tx = await this.txBuilder.placePostOnlyOrderTx(packet, accounts, txOptions);
70749
+ return await this.base.sendAndConfirm(tx);
70750
+ }
70751
+ /** Cancels all resting orders the vault has on the given market. */ async cancelAll(accounts, txOptions = {}) {
70752
+ const tx = await this.txBuilder.cancelAllTx(accounts, txOptions);
70753
+ return await this.base.sendAndConfirm(tx);
70754
+ }
70755
+ /** Cancels the specific resting orders identified by `orderIds`. */ async cancelOrdersById(orderIds, accounts, txOptions = {}) {
70756
+ const tx = await this.txBuilder.cancelOrdersByIdTx(orderIds, accounts, txOptions);
70757
+ return await this.base.sendAndConfirm(tx);
70758
+ }
70759
+ /**
70760
+ * Cancels up to `num_orders_to_cancel` resting orders on a side, optionally
70761
+ * bounded by a price tick limit.
70762
+ */ async cancelUpTo(args, accounts, txOptions = {}) {
70763
+ const tx = await this.txBuilder.cancelUpToTx(args, accounts, txOptions);
70764
+ return await this.base.sendAndConfirm(tx);
70765
+ }
70010
70766
  constructor(base){
70011
70767
  this.base = base;
70012
70768
  this.txBuilder = new TxBuilder(this);
70769
+ this.phoenixApi = new PhoenixApiClient();
70013
70770
  }
70014
70771
  }
70015
70772
 
@@ -70132,6 +70889,12 @@ class LoopscaleClient {
70132
70889
  }
70133
70890
  return this._loopscale;
70134
70891
  }
70892
+ get phoenix() {
70893
+ if (!this._phoenix) {
70894
+ this._phoenix = new PhoenixClient(this);
70895
+ }
70896
+ return this._phoenix;
70897
+ }
70135
70898
  constructor(config){
70136
70899
  super(config);
70137
70900
  }
@@ -70148,9 +70911,9 @@ exports.CctpBridgeEvent = CctpBridgeEvent;
70148
70911
  exports.CctpClient = CctpClient;
70149
70912
  exports.CctpPolicy = CctpPolicy;
70150
70913
  exports.CreatedModel = CreatedModel;
70914
+ exports.DEFAULT_PHOENIX_API_URL = DEFAULT_PHOENIX_API_URL;
70151
70915
  exports.DelegateAcl = DelegateAcl;
70152
70916
  exports.EMBER_PROGRAM_ID = EMBER_PROGRAM_ID;
70153
- exports.EMBER_PROTOCOL = EMBER_PROTOCOL;
70154
70917
  exports.EmergencyAccessUpdateArgs = EmergencyAccessUpdateArgs;
70155
70918
  exports.EmergencyUpdateMintArgs = EmergencyUpdateMintArgs;
70156
70919
  exports.EpiClient = EpiClient;
@@ -70196,9 +70959,15 @@ exports.MintModel = MintModel;
70196
70959
  exports.MintPolicy = MintPolicy;
70197
70960
  exports.PHOENIX_GLOBAL_CONFIG = PHOENIX_GLOBAL_CONFIG;
70198
70961
  exports.PHOENIX_LOG_AUTHORITY = PHOENIX_LOG_AUTHORITY;
70962
+ exports.PHOENIX_ORDER_PACKET_KIND_IMMEDIATE_OR_CANCEL = PHOENIX_ORDER_PACKET_KIND_IMMEDIATE_OR_CANCEL;
70963
+ exports.PHOENIX_ORDER_PACKET_KIND_LIMIT = PHOENIX_ORDER_PACKET_KIND_LIMIT;
70964
+ exports.PHOENIX_ORDER_PACKET_KIND_POST_ONLY = PHOENIX_ORDER_PACKET_KIND_POST_ONLY;
70199
70965
  exports.PHOENIX_PROGRAM_ID = PHOENIX_PROGRAM_ID;
70200
70966
  exports.PHOENIX_PROTOCOL = PHOENIX_PROTOCOL;
70967
+ exports.PHOENIX_WITHDRAW_QUEUE = PHOENIX_WITHDRAW_QUEUE;
70201
70968
  exports.PeriodType = PeriodType;
70969
+ exports.PhoenixApiClient = PhoenixApiClient;
70970
+ exports.PhoenixClient = PhoenixClient;
70202
70971
  exports.PhoenixPolicy = PhoenixPolicy;
70203
70972
  exports.PkMap = PkMap;
70204
70973
  exports.PkSet = PkSet;
@@ -70275,6 +71044,9 @@ exports.formatBits = formatBits;
70275
71044
  exports.fromUiAmount = fromUiAmount;
70276
71045
  exports.getAccountPolicyPda = getAccountPolicyPda;
70277
71046
  exports.getActiveRegistryTransfers = getActiveRegistryTransfers;
71047
+ exports.getAsset = getAsset;
71048
+ exports.getEmberStatePda = getEmberStatePda;
71049
+ exports.getEmberVaultPda = getEmberVaultPda;
70278
71050
  exports.getEscrowPda = getEscrowPda;
70279
71051
  exports.getExtBridgeIdl = getExtBridgeIdl;
70280
71052
  exports.getExtBridgeProgram = getExtBridgeProgram;
@@ -70313,12 +71085,17 @@ exports.getGlamProtocolIdl = getGlamProtocolIdl;
70313
71085
  exports.getGlamProtocolProgram = getGlamProtocolProgram;
70314
71086
  exports.getGlamProtocolProgramId = getGlamProtocolProgramId;
70315
71087
  exports.getGlobalConfigPda = getGlobalConfigPda;
71088
+ exports.getHeliusApiKey = getHeliusApiKey;
71089
+ exports.getHeliusRpcUrl = getHeliusRpcUrl;
70316
71090
  exports.getIntegrationAuthorityPda = getIntegrationAuthorityPda;
70317
71091
  exports.getLoopscaleEventAuthorityPda = getLoopscaleEventAuthorityPda;
70318
71092
  exports.getLoopscaleLoanPda = getLoopscaleLoanPda;
70319
71093
  exports.getMintPda = getMintPda;
70320
71094
  exports.getOracleName = getOracleName;
70321
71095
  exports.getPermissionNamesFromBitmask = getPermissionNamesFromBitmask;
71096
+ exports.getPhoenixGlobalVaultPda = getPhoenixGlobalVaultPda;
71097
+ exports.getPhoenixSplineCollectionPda = getPhoenixSplineCollectionPda;
71098
+ exports.getPhoenixTraderPda = getPhoenixTraderPda;
70322
71099
  exports.getPriorityFeeEstimate = getPriorityFeeEstimate;
70323
71100
  exports.getProgramAccounts = getProgramAccounts;
70324
71101
  exports.getProgramAccountsWithRetry = getProgramAccountsWithRetry;
@@ -70331,6 +71108,8 @@ exports.getSimulationResult = getSimulationResult;
70331
71108
  exports.getSolAndTokenBalances = getSolAndTokenBalances;
70332
71109
  exports.getStakeAccountsWithStates = getStakeAccountsWithStates;
70333
71110
  exports.getStatePda = getStatePda;
71111
+ exports.getTokenAccountsByMint = getTokenAccountsByMint;
71112
+ exports.getTokenAccountsByMintResult = getTokenAccountsByMintResult;
70334
71113
  exports.getTokenAccountsByOwner = getTokenAccountsByOwner;
70335
71114
  exports.getTokenAclFlagAccountPda = getTokenAclFlagAccountPda;
70336
71115
  exports.getTokenAclGateExtraMetasPda = getTokenAclGateExtraMetasPda;
@@ -70339,10 +71118,15 @@ exports.getTokenAclGateWalletEntryPda = getTokenAclGateWalletEntryPda;
70339
71118
  exports.getTokenAclMintConfigPda = getTokenAclMintConfigPda;
70340
71119
  exports.getTransactionsForAddress = getTransactionsForAddress;
70341
71120
  exports.getVaultPda = getVaultPda;
71121
+ exports.heliusFetch = heliusFetch;
71122
+ exports.heliusGetProgramAccountsV2 = heliusGetProgramAccountsV2;
71123
+ exports.heliusGetTransactionsForAddress = heliusGetTransactionsForAddress;
70342
71124
  exports.hexToBytes = hexToBytes;
71125
+ exports.isHeliusRpc = isHeliusRpc;
70343
71126
  exports.isTokenAclEnabled = isTokenAclEnabled;
70344
71127
  exports.isValidEvmAddress = isValidEvmAddress;
70345
71128
  exports.nameToChars = nameToChars;
71129
+ exports.normalizePhoenixApiUrl = normalizePhoenixApiUrl;
70346
71130
  exports.parseMintAccountInfo = parseMintAccountInfo;
70347
71131
  exports.parsePermissionNames = parsePermissionNames;
70348
71132
  exports.parseProgramLogs = parseProgramLogs;
@@ -70353,6 +71137,7 @@ exports.publicKeyToEvmAddress = publicKeyToEvmAddress;
70353
71137
  exports.resolveErrorCode = resolveErrorCode;
70354
71138
  exports.resolveStaging = resolveStaging;
70355
71139
  exports.resolveStateAclsStaging = resolveStateAclsStaging;
71140
+ exports.sha256First8Bytes = sha256First8Bytes;
70356
71141
  exports.stringToChars = stringToChars;
70357
71142
  exports.toBnAmount = toBnAmount;
70358
71143
  exports.toUiAmount = toUiAmount;