@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.
- package/index.cjs.js +1084 -299
- package/index.esm.js +1063 -300
- package/package.json +2 -2
package/index.esm.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as anchor from '@coral-xyz/anchor';
|
|
2
|
-
import { Program, BN
|
|
2
|
+
import { Program, BN } from '@coral-xyz/anchor';
|
|
3
3
|
import { PublicKey, AddressLookupTableAccount, StakeProgram, LAMPORTS_PER_SOL, ComputeBudgetProgram, AddressLookupTableProgram, SystemProgram, VersionedTransaction, TransactionMessage, Connection, Transaction, TransactionInstruction, SYSVAR_CLOCK_PUBKEY, Keypair, SYSVAR_RENT_PUBKEY, SYSVAR_INSTRUCTIONS_PUBKEY, STAKE_CONFIG_ID } from '@solana/web3.js';
|
|
4
4
|
import { TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID, unpackMint, AccountLayout, getAssociatedTokenAddressSync, ASSOCIATED_TOKEN_PROGRAM_ID, getExtensionData, ExtensionType, getTransferHook, getAccount, TokenAccountNotFoundError, createAssociatedTokenAccountIdempotentInstruction, createSyncNativeInstruction, createTransferCheckedInstruction, unpackAccount, createCloseAccountInstruction } from '@solana/spl-token';
|
|
5
5
|
import { unpack } from '@solana/spl-token-metadata';
|
|
6
6
|
import * as borsh from '@coral-xyz/borsh';
|
|
7
7
|
import { struct, u32, u64, option, vec, publicKey, u8, array, u16, i8, u128, i64 } from '@coral-xyz/borsh';
|
|
8
8
|
import { bs58 } from '@coral-xyz/anchor/dist/cjs/utils/bytes';
|
|
9
|
-
import 'fzstd';
|
|
9
|
+
import { decompress } from 'fzstd';
|
|
10
10
|
import Decimal from 'decimal.js';
|
|
11
11
|
import { z } from 'zod';
|
|
12
12
|
import { LstList } from '@glamsystems/sanctum-lst-list';
|
|
@@ -26907,7 +26907,7 @@ var ExtLoopscaleIdlJson = {
|
|
|
26907
26907
|
var address$a = "G1NTPhharzUz2WsdjBVrczrYjM2USsPMtboHYgdbSpiL";
|
|
26908
26908
|
var metadata$9 = {
|
|
26909
26909
|
name: "ext_phoenix",
|
|
26910
|
-
version: "0.1.
|
|
26910
|
+
version: "0.1.1",
|
|
26911
26911
|
spec: "0.1.0",
|
|
26912
26912
|
description: "Phoenix and Ember integration for GLAM Protocol"
|
|
26913
26913
|
};
|
|
@@ -27346,14 +27346,17 @@ var instructions$9 = [
|
|
|
27346
27346
|
writable: true
|
|
27347
27347
|
},
|
|
27348
27348
|
{
|
|
27349
|
-
name: "token_program"
|
|
27350
|
-
address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
|
|
27349
|
+
name: "token_program"
|
|
27351
27350
|
}
|
|
27352
27351
|
],
|
|
27353
27352
|
args: [
|
|
27354
27353
|
{
|
|
27355
|
-
name: "
|
|
27356
|
-
type:
|
|
27354
|
+
name: "deposit_params",
|
|
27355
|
+
type: {
|
|
27356
|
+
defined: {
|
|
27357
|
+
name: "DepositParams"
|
|
27358
|
+
}
|
|
27359
|
+
}
|
|
27357
27360
|
}
|
|
27358
27361
|
]
|
|
27359
27362
|
},
|
|
@@ -27456,8 +27459,12 @@ var instructions$9 = [
|
|
|
27456
27459
|
],
|
|
27457
27460
|
args: [
|
|
27458
27461
|
{
|
|
27459
|
-
name: "
|
|
27460
|
-
type:
|
|
27462
|
+
name: "params",
|
|
27463
|
+
type: {
|
|
27464
|
+
defined: {
|
|
27465
|
+
name: "DepositFundsInstruction"
|
|
27466
|
+
}
|
|
27467
|
+
}
|
|
27461
27468
|
}
|
|
27462
27469
|
]
|
|
27463
27470
|
},
|
|
@@ -27986,13 +27993,10 @@ var instructions$9 = [
|
|
|
27986
27993
|
address: "GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"
|
|
27987
27994
|
},
|
|
27988
27995
|
{
|
|
27989
|
-
name: "log_authority"
|
|
27990
|
-
address: "GdxfTLSsdSY37G6fZoYtdGDSfgFnbT2EmRpuePZxWShS"
|
|
27996
|
+
name: "log_authority"
|
|
27991
27997
|
},
|
|
27992
27998
|
{
|
|
27993
|
-
name: "global_config"
|
|
27994
|
-
writable: true,
|
|
27995
|
-
address: "2zskx2iyCvb6Stg7RBZkt1f6MrF4dpYtMG3yMvKwqtUZ"
|
|
27999
|
+
name: "global_config"
|
|
27996
28000
|
},
|
|
27997
28001
|
{
|
|
27998
28002
|
name: "trader_account",
|
|
@@ -28017,7 +28021,7 @@ var instructions$9 = [
|
|
|
28017
28021
|
{
|
|
28018
28022
|
name: "set_phoenix_policy",
|
|
28019
28023
|
docs: [
|
|
28020
|
-
"Sets the GLAM Phoenix policy (market allowlist, order
|
|
28024
|
+
"Sets the GLAM Phoenix policy (market allowlist, order types, and price-deviation limits) on the vault state."
|
|
28021
28025
|
],
|
|
28022
28026
|
discriminator: [
|
|
28023
28027
|
57,
|
|
@@ -28253,15 +28257,19 @@ var instructions$9 = [
|
|
|
28253
28257
|
],
|
|
28254
28258
|
args: [
|
|
28255
28259
|
{
|
|
28256
|
-
name: "
|
|
28257
|
-
type:
|
|
28260
|
+
name: "params",
|
|
28261
|
+
type: {
|
|
28262
|
+
defined: {
|
|
28263
|
+
name: "TransferCollateralInstruction"
|
|
28264
|
+
}
|
|
28265
|
+
}
|
|
28258
28266
|
}
|
|
28259
28267
|
]
|
|
28260
28268
|
},
|
|
28261
28269
|
{
|
|
28262
28270
|
name: "transfer_collateral_child_to_parent",
|
|
28263
28271
|
docs: [
|
|
28264
|
-
"
|
|
28272
|
+
"Transfers collateral from a child subaccount back to its parent trader account."
|
|
28265
28273
|
],
|
|
28266
28274
|
discriminator: [
|
|
28267
28275
|
51,
|
|
@@ -28355,7 +28363,16 @@ var instructions$9 = [
|
|
|
28355
28363
|
address: "11111111111111111111111111111111"
|
|
28356
28364
|
}
|
|
28357
28365
|
],
|
|
28358
|
-
args: [
|
|
28366
|
+
args: [
|
|
28367
|
+
{
|
|
28368
|
+
name: "params",
|
|
28369
|
+
type: {
|
|
28370
|
+
defined: {
|
|
28371
|
+
name: "TransferCollateralChildToParentInstruction"
|
|
28372
|
+
}
|
|
28373
|
+
}
|
|
28374
|
+
}
|
|
28375
|
+
]
|
|
28359
28376
|
},
|
|
28360
28377
|
{
|
|
28361
28378
|
name: "update_trader_state",
|
|
@@ -28575,15 +28592,16 @@ var instructions$9 = [
|
|
|
28575
28592
|
writable: true
|
|
28576
28593
|
},
|
|
28577
28594
|
{
|
|
28578
|
-
name: "token_program"
|
|
28579
|
-
address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
|
|
28595
|
+
name: "token_program"
|
|
28580
28596
|
}
|
|
28581
28597
|
],
|
|
28582
28598
|
args: [
|
|
28583
28599
|
{
|
|
28584
|
-
name: "
|
|
28600
|
+
name: "withdraw_params",
|
|
28585
28601
|
type: {
|
|
28586
|
-
|
|
28602
|
+
defined: {
|
|
28603
|
+
name: "WithdrawParams"
|
|
28604
|
+
}
|
|
28587
28605
|
}
|
|
28588
28606
|
}
|
|
28589
28607
|
]
|
|
@@ -28687,8 +28705,12 @@ var instructions$9 = [
|
|
|
28687
28705
|
],
|
|
28688
28706
|
args: [
|
|
28689
28707
|
{
|
|
28690
|
-
name: "
|
|
28691
|
-
type:
|
|
28708
|
+
name: "params",
|
|
28709
|
+
type: {
|
|
28710
|
+
defined: {
|
|
28711
|
+
name: "WithdrawFundsInstruction"
|
|
28712
|
+
}
|
|
28713
|
+
}
|
|
28692
28714
|
}
|
|
28693
28715
|
]
|
|
28694
28716
|
}
|
|
@@ -28853,6 +28875,11 @@ var errors$3 = [
|
|
|
28853
28875
|
code: 6028,
|
|
28854
28876
|
name: "ReferencePriceStale",
|
|
28855
28877
|
msg: "Phoenix reference price is stale"
|
|
28878
|
+
},
|
|
28879
|
+
{
|
|
28880
|
+
code: 6029,
|
|
28881
|
+
name: "OrderTypeNotAllowed",
|
|
28882
|
+
msg: "Phoenix order type is not allowed by policy"
|
|
28856
28883
|
}
|
|
28857
28884
|
];
|
|
28858
28885
|
var types$9 = [
|
|
@@ -29053,6 +29080,30 @@ var types$9 = [
|
|
|
29053
29080
|
]
|
|
29054
29081
|
}
|
|
29055
29082
|
},
|
|
29083
|
+
{
|
|
29084
|
+
name: "DepositFundsInstruction",
|
|
29085
|
+
type: {
|
|
29086
|
+
kind: "struct",
|
|
29087
|
+
fields: [
|
|
29088
|
+
{
|
|
29089
|
+
name: "amount",
|
|
29090
|
+
type: "u64"
|
|
29091
|
+
}
|
|
29092
|
+
]
|
|
29093
|
+
}
|
|
29094
|
+
},
|
|
29095
|
+
{
|
|
29096
|
+
name: "DepositParams",
|
|
29097
|
+
type: {
|
|
29098
|
+
kind: "struct",
|
|
29099
|
+
fields: [
|
|
29100
|
+
{
|
|
29101
|
+
name: "amount",
|
|
29102
|
+
type: "u64"
|
|
29103
|
+
}
|
|
29104
|
+
]
|
|
29105
|
+
}
|
|
29106
|
+
},
|
|
29056
29107
|
{
|
|
29057
29108
|
name: "EngineField",
|
|
29058
29109
|
type: {
|
|
@@ -30015,32 +30066,49 @@ var types$9 = [
|
|
|
30015
30066
|
fields: [
|
|
30016
30067
|
{
|
|
30017
30068
|
name: "markets_allowlist",
|
|
30069
|
+
docs: [
|
|
30070
|
+
"Phoenix markets the vault is allowed to trade on. Any order routed to a",
|
|
30071
|
+
"market outside this list is rejected with `MarketNotAllowed`. Capped at",
|
|
30072
|
+
"`MAX_PHOENIX_MARKETS_ALLOWLIST` entries; duplicates and the default",
|
|
30073
|
+
"pubkey are rejected by `validate_for_set`. An empty list disables all",
|
|
30074
|
+
"trading."
|
|
30075
|
+
],
|
|
30018
30076
|
type: {
|
|
30019
30077
|
vec: "pubkey"
|
|
30020
30078
|
}
|
|
30021
30079
|
},
|
|
30022
30080
|
{
|
|
30023
|
-
name: "
|
|
30024
|
-
|
|
30025
|
-
|
|
30026
|
-
|
|
30027
|
-
|
|
30028
|
-
|
|
30029
|
-
|
|
30030
|
-
{
|
|
30031
|
-
name: "max_price_deviation_bps",
|
|
30032
|
-
type: "u16"
|
|
30081
|
+
name: "allowed_order_types",
|
|
30082
|
+
docs: [
|
|
30083
|
+
"Allowed Phoenix `OrderPacketKind` discriminants. Current values are:",
|
|
30084
|
+
"`0 = PostOnly`, `1 = Limit`, and `2 = ImmediateOrCancel`. An empty list",
|
|
30085
|
+
"disables all order placement."
|
|
30086
|
+
],
|
|
30087
|
+
type: "bytes"
|
|
30033
30088
|
},
|
|
30034
30089
|
{
|
|
30035
30090
|
name: "require_reduce_only_orders",
|
|
30091
|
+
docs: [
|
|
30092
|
+
"When `true`, every order must have the reduce-only flag set; orders",
|
|
30093
|
+
"without it are rejected with `ReduceOnlyRequired`. Use this to lock the",
|
|
30094
|
+
"vault into pure position-unwinding mode."
|
|
30095
|
+
],
|
|
30036
30096
|
type: "bool"
|
|
30037
30097
|
},
|
|
30038
30098
|
{
|
|
30039
|
-
name: "
|
|
30040
|
-
|
|
30099
|
+
name: "max_price_deviation_bps",
|
|
30100
|
+
docs: [
|
|
30101
|
+
"Maximum allowed deviation in basis points. Retained in policy state for",
|
|
30102
|
+
"future enforcement; currently not checked by order placement."
|
|
30103
|
+
],
|
|
30104
|
+
type: "u16"
|
|
30041
30105
|
},
|
|
30042
30106
|
{
|
|
30043
30107
|
name: "max_reference_price_age_secs",
|
|
30108
|
+
docs: [
|
|
30109
|
+
"Maximum reference price age in seconds. Retained in policy state for",
|
|
30110
|
+
"future enforcement; currently not checked by order placement."
|
|
30111
|
+
],
|
|
30044
30112
|
type: "u32"
|
|
30045
30113
|
}
|
|
30046
30114
|
]
|
|
@@ -30360,6 +30428,30 @@ var types$9 = [
|
|
|
30360
30428
|
]
|
|
30361
30429
|
}
|
|
30362
30430
|
},
|
|
30431
|
+
{
|
|
30432
|
+
name: "TransferCollateralChildToParentInstruction",
|
|
30433
|
+
type: {
|
|
30434
|
+
kind: "struct",
|
|
30435
|
+
fields: [
|
|
30436
|
+
{
|
|
30437
|
+
name: "amount",
|
|
30438
|
+
type: "u64"
|
|
30439
|
+
}
|
|
30440
|
+
]
|
|
30441
|
+
}
|
|
30442
|
+
},
|
|
30443
|
+
{
|
|
30444
|
+
name: "TransferCollateralInstruction",
|
|
30445
|
+
type: {
|
|
30446
|
+
kind: "struct",
|
|
30447
|
+
fields: [
|
|
30448
|
+
{
|
|
30449
|
+
name: "amount",
|
|
30450
|
+
type: "u64"
|
|
30451
|
+
}
|
|
30452
|
+
]
|
|
30453
|
+
}
|
|
30454
|
+
},
|
|
30363
30455
|
{
|
|
30364
30456
|
name: "ValuationModel",
|
|
30365
30457
|
type: {
|
|
@@ -30373,38 +30465,49 @@ var types$9 = [
|
|
|
30373
30465
|
}
|
|
30374
30466
|
]
|
|
30375
30467
|
}
|
|
30376
|
-
}
|
|
30377
|
-
];
|
|
30378
|
-
var constants$9 = [
|
|
30379
|
-
{
|
|
30380
|
-
name: "EMBER_PERM_DEPOSIT",
|
|
30381
|
-
type: "u64",
|
|
30382
|
-
value: "1"
|
|
30383
30468
|
},
|
|
30384
30469
|
{
|
|
30385
|
-
name: "
|
|
30386
|
-
type:
|
|
30387
|
-
|
|
30470
|
+
name: "WithdrawFundsInstruction",
|
|
30471
|
+
type: {
|
|
30472
|
+
kind: "struct",
|
|
30473
|
+
fields: [
|
|
30474
|
+
{
|
|
30475
|
+
name: "amount",
|
|
30476
|
+
type: "u64"
|
|
30477
|
+
}
|
|
30478
|
+
]
|
|
30479
|
+
}
|
|
30388
30480
|
},
|
|
30389
30481
|
{
|
|
30390
|
-
name: "
|
|
30391
|
-
type:
|
|
30392
|
-
|
|
30393
|
-
|
|
30482
|
+
name: "WithdrawParams",
|
|
30483
|
+
type: {
|
|
30484
|
+
kind: "struct",
|
|
30485
|
+
fields: [
|
|
30486
|
+
{
|
|
30487
|
+
name: "amount",
|
|
30488
|
+
type: {
|
|
30489
|
+
option: "u64"
|
|
30490
|
+
}
|
|
30491
|
+
}
|
|
30492
|
+
]
|
|
30493
|
+
}
|
|
30494
|
+
}
|
|
30495
|
+
];
|
|
30496
|
+
var constants$9 = [
|
|
30394
30497
|
{
|
|
30395
|
-
name: "
|
|
30498
|
+
name: "PHOENIX_PERM_CANCEL_ORDERS",
|
|
30396
30499
|
type: "u64",
|
|
30397
|
-
value: "
|
|
30500
|
+
value: "16"
|
|
30398
30501
|
},
|
|
30399
30502
|
{
|
|
30400
30503
|
name: "PHOENIX_PERM_CREATE_MODIFY_ORDERS",
|
|
30401
30504
|
type: "u64",
|
|
30402
|
-
value: "
|
|
30505
|
+
value: "8"
|
|
30403
30506
|
},
|
|
30404
30507
|
{
|
|
30405
30508
|
name: "PHOENIX_PERM_DEPOSIT",
|
|
30406
30509
|
type: "u64",
|
|
30407
|
-
value: "
|
|
30510
|
+
value: "2"
|
|
30408
30511
|
},
|
|
30409
30512
|
{
|
|
30410
30513
|
name: "PHOENIX_PERM_INIT_TRADER",
|
|
@@ -30414,22 +30517,17 @@ var constants$9 = [
|
|
|
30414
30517
|
{
|
|
30415
30518
|
name: "PHOENIX_PERM_TRANSFER_COLLATERAL",
|
|
30416
30519
|
type: "u64",
|
|
30417
|
-
value: "
|
|
30520
|
+
value: "32"
|
|
30418
30521
|
},
|
|
30419
30522
|
{
|
|
30420
30523
|
name: "PHOENIX_PERM_UPDATE_TRADER_STATE",
|
|
30421
30524
|
type: "u64",
|
|
30422
|
-
value: "
|
|
30525
|
+
value: "64"
|
|
30423
30526
|
},
|
|
30424
30527
|
{
|
|
30425
30528
|
name: "PHOENIX_PERM_WITHDRAW",
|
|
30426
30529
|
type: "u64",
|
|
30427
|
-
value: "
|
|
30428
|
-
},
|
|
30429
|
-
{
|
|
30430
|
-
name: "PROTO_EMBER",
|
|
30431
|
-
type: "u16",
|
|
30432
|
-
value: "2"
|
|
30530
|
+
value: "4"
|
|
30433
30531
|
},
|
|
30434
30532
|
{
|
|
30435
30533
|
name: "PROTO_PHOENIX",
|
|
@@ -55493,7 +55591,7 @@ var ExtLoopscaleIdlJsonStaging = {
|
|
|
55493
55591
|
var address = "gstgPL7r9aYedDDsXNtLpr4atYtNvY7zubAWWstqS3L";
|
|
55494
55592
|
var metadata = {
|
|
55495
55593
|
name: "ext_phoenix",
|
|
55496
|
-
version: "0.1.
|
|
55594
|
+
version: "0.1.1",
|
|
55497
55595
|
spec: "0.1.0",
|
|
55498
55596
|
description: "Phoenix and Ember integration for GLAM Protocol"
|
|
55499
55597
|
};
|
|
@@ -55932,14 +56030,17 @@ var instructions = [
|
|
|
55932
56030
|
writable: true
|
|
55933
56031
|
},
|
|
55934
56032
|
{
|
|
55935
|
-
name: "token_program"
|
|
55936
|
-
address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
|
|
56033
|
+
name: "token_program"
|
|
55937
56034
|
}
|
|
55938
56035
|
],
|
|
55939
56036
|
args: [
|
|
55940
56037
|
{
|
|
55941
|
-
name: "
|
|
55942
|
-
type:
|
|
56038
|
+
name: "deposit_params",
|
|
56039
|
+
type: {
|
|
56040
|
+
defined: {
|
|
56041
|
+
name: "DepositParams"
|
|
56042
|
+
}
|
|
56043
|
+
}
|
|
55943
56044
|
}
|
|
55944
56045
|
]
|
|
55945
56046
|
},
|
|
@@ -56042,8 +56143,12 @@ var instructions = [
|
|
|
56042
56143
|
],
|
|
56043
56144
|
args: [
|
|
56044
56145
|
{
|
|
56045
|
-
name: "
|
|
56046
|
-
type:
|
|
56146
|
+
name: "params",
|
|
56147
|
+
type: {
|
|
56148
|
+
defined: {
|
|
56149
|
+
name: "DepositFundsInstruction"
|
|
56150
|
+
}
|
|
56151
|
+
}
|
|
56047
56152
|
}
|
|
56048
56153
|
]
|
|
56049
56154
|
},
|
|
@@ -56572,13 +56677,10 @@ var instructions = [
|
|
|
56572
56677
|
address: "gstgptmbgJVi5f8ZmSRVZjZkDQwqKa3xWuUtD5WmJHz"
|
|
56573
56678
|
},
|
|
56574
56679
|
{
|
|
56575
|
-
name: "log_authority"
|
|
56576
|
-
address: "GdxfTLSsdSY37G6fZoYtdGDSfgFnbT2EmRpuePZxWShS"
|
|
56680
|
+
name: "log_authority"
|
|
56577
56681
|
},
|
|
56578
56682
|
{
|
|
56579
|
-
name: "global_config"
|
|
56580
|
-
writable: true,
|
|
56581
|
-
address: "2zskx2iyCvb6Stg7RBZkt1f6MrF4dpYtMG3yMvKwqtUZ"
|
|
56683
|
+
name: "global_config"
|
|
56582
56684
|
},
|
|
56583
56685
|
{
|
|
56584
56686
|
name: "trader_account",
|
|
@@ -56603,7 +56705,7 @@ var instructions = [
|
|
|
56603
56705
|
{
|
|
56604
56706
|
name: "set_phoenix_policy",
|
|
56605
56707
|
docs: [
|
|
56606
|
-
"Sets the GLAM Phoenix policy (market allowlist, order
|
|
56708
|
+
"Sets the GLAM Phoenix policy (market allowlist, order types, and price-deviation limits) on the vault state."
|
|
56607
56709
|
],
|
|
56608
56710
|
discriminator: [
|
|
56609
56711
|
57,
|
|
@@ -56839,15 +56941,19 @@ var instructions = [
|
|
|
56839
56941
|
],
|
|
56840
56942
|
args: [
|
|
56841
56943
|
{
|
|
56842
|
-
name: "
|
|
56843
|
-
type:
|
|
56944
|
+
name: "params",
|
|
56945
|
+
type: {
|
|
56946
|
+
defined: {
|
|
56947
|
+
name: "TransferCollateralInstruction"
|
|
56948
|
+
}
|
|
56949
|
+
}
|
|
56844
56950
|
}
|
|
56845
56951
|
]
|
|
56846
56952
|
},
|
|
56847
56953
|
{
|
|
56848
56954
|
name: "transfer_collateral_child_to_parent",
|
|
56849
56955
|
docs: [
|
|
56850
|
-
"
|
|
56956
|
+
"Transfers collateral from a child subaccount back to its parent trader account."
|
|
56851
56957
|
],
|
|
56852
56958
|
discriminator: [
|
|
56853
56959
|
51,
|
|
@@ -56941,7 +57047,16 @@ var instructions = [
|
|
|
56941
57047
|
address: "11111111111111111111111111111111"
|
|
56942
57048
|
}
|
|
56943
57049
|
],
|
|
56944
|
-
args: [
|
|
57050
|
+
args: [
|
|
57051
|
+
{
|
|
57052
|
+
name: "params",
|
|
57053
|
+
type: {
|
|
57054
|
+
defined: {
|
|
57055
|
+
name: "TransferCollateralChildToParentInstruction"
|
|
57056
|
+
}
|
|
57057
|
+
}
|
|
57058
|
+
}
|
|
57059
|
+
]
|
|
56945
57060
|
},
|
|
56946
57061
|
{
|
|
56947
57062
|
name: "update_trader_state",
|
|
@@ -57161,15 +57276,16 @@ var instructions = [
|
|
|
57161
57276
|
writable: true
|
|
57162
57277
|
},
|
|
57163
57278
|
{
|
|
57164
|
-
name: "token_program"
|
|
57165
|
-
address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
|
|
57279
|
+
name: "token_program"
|
|
57166
57280
|
}
|
|
57167
57281
|
],
|
|
57168
57282
|
args: [
|
|
57169
57283
|
{
|
|
57170
|
-
name: "
|
|
57284
|
+
name: "withdraw_params",
|
|
57171
57285
|
type: {
|
|
57172
|
-
|
|
57286
|
+
defined: {
|
|
57287
|
+
name: "WithdrawParams"
|
|
57288
|
+
}
|
|
57173
57289
|
}
|
|
57174
57290
|
}
|
|
57175
57291
|
]
|
|
@@ -57273,8 +57389,12 @@ var instructions = [
|
|
|
57273
57389
|
],
|
|
57274
57390
|
args: [
|
|
57275
57391
|
{
|
|
57276
|
-
name: "
|
|
57277
|
-
type:
|
|
57392
|
+
name: "params",
|
|
57393
|
+
type: {
|
|
57394
|
+
defined: {
|
|
57395
|
+
name: "WithdrawFundsInstruction"
|
|
57396
|
+
}
|
|
57397
|
+
}
|
|
57278
57398
|
}
|
|
57279
57399
|
]
|
|
57280
57400
|
}
|
|
@@ -57439,6 +57559,11 @@ var errors = [
|
|
|
57439
57559
|
code: 6028,
|
|
57440
57560
|
name: "ReferencePriceStale",
|
|
57441
57561
|
msg: "Phoenix reference price is stale"
|
|
57562
|
+
},
|
|
57563
|
+
{
|
|
57564
|
+
code: 6029,
|
|
57565
|
+
name: "OrderTypeNotAllowed",
|
|
57566
|
+
msg: "Phoenix order type is not allowed by policy"
|
|
57442
57567
|
}
|
|
57443
57568
|
];
|
|
57444
57569
|
var types = [
|
|
@@ -57639,6 +57764,30 @@ var types = [
|
|
|
57639
57764
|
]
|
|
57640
57765
|
}
|
|
57641
57766
|
},
|
|
57767
|
+
{
|
|
57768
|
+
name: "DepositFundsInstruction",
|
|
57769
|
+
type: {
|
|
57770
|
+
kind: "struct",
|
|
57771
|
+
fields: [
|
|
57772
|
+
{
|
|
57773
|
+
name: "amount",
|
|
57774
|
+
type: "u64"
|
|
57775
|
+
}
|
|
57776
|
+
]
|
|
57777
|
+
}
|
|
57778
|
+
},
|
|
57779
|
+
{
|
|
57780
|
+
name: "DepositParams",
|
|
57781
|
+
type: {
|
|
57782
|
+
kind: "struct",
|
|
57783
|
+
fields: [
|
|
57784
|
+
{
|
|
57785
|
+
name: "amount",
|
|
57786
|
+
type: "u64"
|
|
57787
|
+
}
|
|
57788
|
+
]
|
|
57789
|
+
}
|
|
57790
|
+
},
|
|
57642
57791
|
{
|
|
57643
57792
|
name: "EngineField",
|
|
57644
57793
|
type: {
|
|
@@ -58601,32 +58750,49 @@ var types = [
|
|
|
58601
58750
|
fields: [
|
|
58602
58751
|
{
|
|
58603
58752
|
name: "markets_allowlist",
|
|
58753
|
+
docs: [
|
|
58754
|
+
"Phoenix markets the vault is allowed to trade on. Any order routed to a",
|
|
58755
|
+
"market outside this list is rejected with `MarketNotAllowed`. Capped at",
|
|
58756
|
+
"`MAX_PHOENIX_MARKETS_ALLOWLIST` entries; duplicates and the default",
|
|
58757
|
+
"pubkey are rejected by `validate_for_set`. An empty list disables all",
|
|
58758
|
+
"trading."
|
|
58759
|
+
],
|
|
58604
58760
|
type: {
|
|
58605
58761
|
vec: "pubkey"
|
|
58606
58762
|
}
|
|
58607
58763
|
},
|
|
58608
58764
|
{
|
|
58609
|
-
name: "
|
|
58610
|
-
|
|
58611
|
-
|
|
58612
|
-
|
|
58613
|
-
|
|
58614
|
-
|
|
58615
|
-
|
|
58616
|
-
{
|
|
58617
|
-
name: "max_price_deviation_bps",
|
|
58618
|
-
type: "u16"
|
|
58765
|
+
name: "allowed_order_types",
|
|
58766
|
+
docs: [
|
|
58767
|
+
"Allowed Phoenix `OrderPacketKind` discriminants. Current values are:",
|
|
58768
|
+
"`0 = PostOnly`, `1 = Limit`, and `2 = ImmediateOrCancel`. An empty list",
|
|
58769
|
+
"disables all order placement."
|
|
58770
|
+
],
|
|
58771
|
+
type: "bytes"
|
|
58619
58772
|
},
|
|
58620
58773
|
{
|
|
58621
58774
|
name: "require_reduce_only_orders",
|
|
58775
|
+
docs: [
|
|
58776
|
+
"When `true`, every order must have the reduce-only flag set; orders",
|
|
58777
|
+
"without it are rejected with `ReduceOnlyRequired`. Use this to lock the",
|
|
58778
|
+
"vault into pure position-unwinding mode."
|
|
58779
|
+
],
|
|
58622
58780
|
type: "bool"
|
|
58623
58781
|
},
|
|
58624
58782
|
{
|
|
58625
|
-
name: "
|
|
58626
|
-
|
|
58783
|
+
name: "max_price_deviation_bps",
|
|
58784
|
+
docs: [
|
|
58785
|
+
"Maximum allowed deviation in basis points. Retained in policy state for",
|
|
58786
|
+
"future enforcement; currently not checked by order placement."
|
|
58787
|
+
],
|
|
58788
|
+
type: "u16"
|
|
58627
58789
|
},
|
|
58628
58790
|
{
|
|
58629
58791
|
name: "max_reference_price_age_secs",
|
|
58792
|
+
docs: [
|
|
58793
|
+
"Maximum reference price age in seconds. Retained in policy state for",
|
|
58794
|
+
"future enforcement; currently not checked by order placement."
|
|
58795
|
+
],
|
|
58630
58796
|
type: "u32"
|
|
58631
58797
|
}
|
|
58632
58798
|
]
|
|
@@ -58946,6 +59112,30 @@ var types = [
|
|
|
58946
59112
|
]
|
|
58947
59113
|
}
|
|
58948
59114
|
},
|
|
59115
|
+
{
|
|
59116
|
+
name: "TransferCollateralChildToParentInstruction",
|
|
59117
|
+
type: {
|
|
59118
|
+
kind: "struct",
|
|
59119
|
+
fields: [
|
|
59120
|
+
{
|
|
59121
|
+
name: "amount",
|
|
59122
|
+
type: "u64"
|
|
59123
|
+
}
|
|
59124
|
+
]
|
|
59125
|
+
}
|
|
59126
|
+
},
|
|
59127
|
+
{
|
|
59128
|
+
name: "TransferCollateralInstruction",
|
|
59129
|
+
type: {
|
|
59130
|
+
kind: "struct",
|
|
59131
|
+
fields: [
|
|
59132
|
+
{
|
|
59133
|
+
name: "amount",
|
|
59134
|
+
type: "u64"
|
|
59135
|
+
}
|
|
59136
|
+
]
|
|
59137
|
+
}
|
|
59138
|
+
},
|
|
58949
59139
|
{
|
|
58950
59140
|
name: "ValuationModel",
|
|
58951
59141
|
type: {
|
|
@@ -58959,38 +59149,49 @@ var types = [
|
|
|
58959
59149
|
}
|
|
58960
59150
|
]
|
|
58961
59151
|
}
|
|
58962
|
-
}
|
|
58963
|
-
];
|
|
58964
|
-
var constants = [
|
|
58965
|
-
{
|
|
58966
|
-
name: "EMBER_PERM_DEPOSIT",
|
|
58967
|
-
type: "u64",
|
|
58968
|
-
value: "1"
|
|
58969
59152
|
},
|
|
58970
59153
|
{
|
|
58971
|
-
name: "
|
|
58972
|
-
type:
|
|
58973
|
-
|
|
59154
|
+
name: "WithdrawFundsInstruction",
|
|
59155
|
+
type: {
|
|
59156
|
+
kind: "struct",
|
|
59157
|
+
fields: [
|
|
59158
|
+
{
|
|
59159
|
+
name: "amount",
|
|
59160
|
+
type: "u64"
|
|
59161
|
+
}
|
|
59162
|
+
]
|
|
59163
|
+
}
|
|
58974
59164
|
},
|
|
58975
59165
|
{
|
|
58976
|
-
name: "
|
|
58977
|
-
type:
|
|
58978
|
-
|
|
58979
|
-
|
|
59166
|
+
name: "WithdrawParams",
|
|
59167
|
+
type: {
|
|
59168
|
+
kind: "struct",
|
|
59169
|
+
fields: [
|
|
59170
|
+
{
|
|
59171
|
+
name: "amount",
|
|
59172
|
+
type: {
|
|
59173
|
+
option: "u64"
|
|
59174
|
+
}
|
|
59175
|
+
}
|
|
59176
|
+
]
|
|
59177
|
+
}
|
|
59178
|
+
}
|
|
59179
|
+
];
|
|
59180
|
+
var constants = [
|
|
58980
59181
|
{
|
|
58981
|
-
name: "
|
|
59182
|
+
name: "PHOENIX_PERM_CANCEL_ORDERS",
|
|
58982
59183
|
type: "u64",
|
|
58983
|
-
value: "
|
|
59184
|
+
value: "16"
|
|
58984
59185
|
},
|
|
58985
59186
|
{
|
|
58986
59187
|
name: "PHOENIX_PERM_CREATE_MODIFY_ORDERS",
|
|
58987
59188
|
type: "u64",
|
|
58988
|
-
value: "
|
|
59189
|
+
value: "8"
|
|
58989
59190
|
},
|
|
58990
59191
|
{
|
|
58991
59192
|
name: "PHOENIX_PERM_DEPOSIT",
|
|
58992
59193
|
type: "u64",
|
|
58993
|
-
value: "
|
|
59194
|
+
value: "2"
|
|
58994
59195
|
},
|
|
58995
59196
|
{
|
|
58996
59197
|
name: "PHOENIX_PERM_INIT_TRADER",
|
|
@@ -59000,22 +59201,17 @@ var constants = [
|
|
|
59000
59201
|
{
|
|
59001
59202
|
name: "PHOENIX_PERM_TRANSFER_COLLATERAL",
|
|
59002
59203
|
type: "u64",
|
|
59003
|
-
value: "
|
|
59204
|
+
value: "32"
|
|
59004
59205
|
},
|
|
59005
59206
|
{
|
|
59006
59207
|
name: "PHOENIX_PERM_UPDATE_TRADER_STATE",
|
|
59007
59208
|
type: "u64",
|
|
59008
|
-
value: "
|
|
59209
|
+
value: "64"
|
|
59009
59210
|
},
|
|
59010
59211
|
{
|
|
59011
59212
|
name: "PHOENIX_PERM_WITHDRAW",
|
|
59012
59213
|
type: "u64",
|
|
59013
|
-
value: "
|
|
59014
|
-
},
|
|
59015
|
-
{
|
|
59016
|
-
name: "PROTO_EMBER",
|
|
59017
|
-
type: "u16",
|
|
59018
|
-
value: "2"
|
|
59214
|
+
value: "4"
|
|
59019
59215
|
},
|
|
59020
59216
|
{
|
|
59021
59217
|
name: "PROTO_PHOENIX",
|
|
@@ -59174,6 +59370,13 @@ function charsToName(chars) {
|
|
|
59174
59370
|
function nameToChars(name, length = 32) {
|
|
59175
59371
|
return stringToChars(name, length);
|
|
59176
59372
|
}
|
|
59373
|
+
/**
|
|
59374
|
+
* Returns the first 8 raw SHA-256 bytes for PDA seed derivation.
|
|
59375
|
+
*/ async function sha256First8Bytes(chars) {
|
|
59376
|
+
const bytes = Uint8Array.from(chars.filter((byte)=>byte !== 0));
|
|
59377
|
+
const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
|
|
59378
|
+
return Array.from(new Uint8Array(digest).subarray(0, 8));
|
|
59379
|
+
}
|
|
59177
59380
|
/**
|
|
59178
59381
|
* Normalizes a base-unit amount into a BN while preserving existing BN values.
|
|
59179
59382
|
*/ function toBnAmount(amount) {
|
|
@@ -59426,18 +59629,19 @@ class PhoenixPolicy {
|
|
|
59426
59629
|
marketsAllowlist.push(new PublicKey(buffer.subarray(offset, offset + 32)));
|
|
59427
59630
|
offset += 32;
|
|
59428
59631
|
}
|
|
59429
|
-
const
|
|
59430
|
-
offset +=
|
|
59431
|
-
const
|
|
59432
|
-
|
|
59433
|
-
|
|
59434
|
-
|
|
59632
|
+
const allowedOrderTypesLen = buffer.readUInt32LE(offset);
|
|
59633
|
+
offset += 4;
|
|
59634
|
+
const allowedOrderTypes = [];
|
|
59635
|
+
for(let i = 0; i < allowedOrderTypesLen; i++){
|
|
59636
|
+
allowedOrderTypes.push(buffer.readUInt8(offset));
|
|
59637
|
+
offset += 1;
|
|
59638
|
+
}
|
|
59435
59639
|
const requireReduceOnlyOrders = buffer.readUInt8(offset) !== 0;
|
|
59436
59640
|
offset += 1;
|
|
59437
|
-
const
|
|
59438
|
-
offset +=
|
|
59641
|
+
const maxPriceDeviationBps = buffer.readUInt16LE(offset);
|
|
59642
|
+
offset += 2;
|
|
59439
59643
|
const maxReferencePriceAgeSecs = buffer.length >= offset + 4 ? buffer.readUInt32LE(offset) : 0;
|
|
59440
|
-
return new PhoenixPolicy(marketsAllowlist,
|
|
59644
|
+
return new PhoenixPolicy(marketsAllowlist, allowedOrderTypes, requireReduceOnlyOrders, maxPriceDeviationBps, maxReferencePriceAgeSecs);
|
|
59441
59645
|
}
|
|
59442
59646
|
encode() {
|
|
59443
59647
|
const allowlistHeader = Buffer.alloc(4);
|
|
@@ -59446,18 +59650,18 @@ class PhoenixPolicy {
|
|
|
59446
59650
|
for(let i = 0; i < this.marketsAllowlist.length; i++){
|
|
59447
59651
|
this.marketsAllowlist[i].toBuffer().copy(allowlistBody, i * 32);
|
|
59448
59652
|
}
|
|
59449
|
-
const tail = Buffer.alloc(
|
|
59653
|
+
const tail = Buffer.alloc(2 + 1 + 4 + 4 + this.allowedOrderTypes.length);
|
|
59450
59654
|
let off = 0;
|
|
59451
|
-
this.
|
|
59452
|
-
off +=
|
|
59453
|
-
|
|
59454
|
-
|
|
59455
|
-
|
|
59456
|
-
|
|
59655
|
+
tail.writeUInt32LE(this.allowedOrderTypes.length, off);
|
|
59656
|
+
off += 4;
|
|
59657
|
+
for (const orderType of this.allowedOrderTypes){
|
|
59658
|
+
tail.writeUInt8(orderType, off);
|
|
59659
|
+
off += 1;
|
|
59660
|
+
}
|
|
59457
59661
|
tail.writeUInt8(this.requireReduceOnlyOrders ? 1 : 0, off);
|
|
59458
59662
|
off += 1;
|
|
59459
|
-
tail.
|
|
59460
|
-
off +=
|
|
59663
|
+
tail.writeUInt16LE(this.maxPriceDeviationBps, off);
|
|
59664
|
+
off += 2;
|
|
59461
59665
|
tail.writeUInt32LE(this.maxReferencePriceAgeSecs, off);
|
|
59462
59666
|
return Buffer.concat([
|
|
59463
59667
|
allowlistHeader,
|
|
@@ -59465,13 +59669,11 @@ class PhoenixPolicy {
|
|
|
59465
59669
|
tail
|
|
59466
59670
|
]);
|
|
59467
59671
|
}
|
|
59468
|
-
constructor(marketsAllowlist,
|
|
59672
|
+
constructor(marketsAllowlist, allowedOrderTypes, requireReduceOnlyOrders, maxPriceDeviationBps, maxReferencePriceAgeSecs = 0){
|
|
59469
59673
|
this.marketsAllowlist = marketsAllowlist;
|
|
59470
|
-
this.
|
|
59471
|
-
this.maxOrderQuoteLots = maxOrderQuoteLots;
|
|
59472
|
-
this.maxPriceDeviationBps = maxPriceDeviationBps;
|
|
59674
|
+
this.allowedOrderTypes = allowedOrderTypes;
|
|
59473
59675
|
this.requireReduceOnlyOrders = requireReduceOnlyOrders;
|
|
59474
|
-
this.
|
|
59676
|
+
this.maxPriceDeviationBps = maxPriceDeviationBps;
|
|
59475
59677
|
this.maxReferencePriceAgeSecs = maxReferencePriceAgeSecs;
|
|
59476
59678
|
}
|
|
59477
59679
|
}
|
|
@@ -59693,12 +59895,18 @@ const LOOPSCALE_PROGRAM_ID = new PublicKey("1oopBoJG58DgkUVKkEzKgyG9dvRmpgeEm1AV
|
|
|
59693
59895
|
const PHOENIX_PROGRAM_ID = new PublicKey("EtrnLzgbS7nMMy5fbD42kXiUzGg8XQzJ972Xtk1cjWih");
|
|
59694
59896
|
const PHOENIX_LOG_AUTHORITY = new PublicKey("GdxfTLSsdSY37G6fZoYtdGDSfgFnbT2EmRpuePZxWShS");
|
|
59695
59897
|
const PHOENIX_GLOBAL_CONFIG = new PublicKey("2zskx2iyCvb6Stg7RBZkt1f6MrF4dpYtMG3yMvKwqtUZ");
|
|
59898
|
+
const PHOENIX_WITHDRAW_QUEUE = new PublicKey("3c3NTwpg7yW91FxijkHBXwVH1xUifun3Z8TC5eW5Si3K");
|
|
59696
59899
|
const EMBER_PROGRAM_ID = new PublicKey("EMBERpYNE6ehWmXymZZS2skiFmCa9V5dp14e1iduM5qy");
|
|
59697
59900
|
/**
|
|
59698
59901
|
* Protocol bitmask values for ext_phoenix integration.
|
|
59699
59902
|
* Mirror `SupportedProtocols` in anchor/programs/ext_phoenix/src/state/access.rs.
|
|
59700
59903
|
*/ const PHOENIX_PROTOCOL = 1 << 0;
|
|
59701
|
-
|
|
59904
|
+
/**
|
|
59905
|
+
* Phoenix OrderPacketKind discriminants.
|
|
59906
|
+
* Mirror `OrderPacketKind` variant order in anchor/deps/phoenix/phoenix.json.
|
|
59907
|
+
*/ const PHOENIX_ORDER_PACKET_KIND_POST_ONLY = 0;
|
|
59908
|
+
const PHOENIX_ORDER_PACKET_KIND_LIMIT = 1;
|
|
59909
|
+
const PHOENIX_ORDER_PACKET_KIND_IMMEDIATE_OR_CANCEL = 2;
|
|
59702
59910
|
/**
|
|
59703
59911
|
* Token ACL (sRFC-37)
|
|
59704
59912
|
*/ const TOKEN_ACL_PROGRAM = new PublicKey("TACLkU6CiCdkQN2MjoyDkVg2yAH9zkxiHDsiztQ52TP");
|
|
@@ -59950,21 +60158,12 @@ const GLAM_CONFIG_PROGRAM = new PublicKey("gConFzxKL9USmwTdJoeQJvfKmqhJ2CyUaXTyQ
|
|
|
59950
60158
|
staging: true,
|
|
59951
60159
|
permissions: {
|
|
59952
60160
|
[1 << 0]: "InitTrader",
|
|
59953
|
-
[1 <<
|
|
59954
|
-
[1 <<
|
|
59955
|
-
[1 <<
|
|
59956
|
-
[1 <<
|
|
59957
|
-
[1 <<
|
|
59958
|
-
[1 <<
|
|
59959
|
-
[1 << 8]: "ConditionalOrders"
|
|
59960
|
-
}
|
|
59961
|
-
},
|
|
59962
|
-
"0000000000000010": {
|
|
59963
|
-
name: "Ember",
|
|
59964
|
-
staging: true,
|
|
59965
|
-
permissions: {
|
|
59966
|
-
[1 << 0]: "Deposit",
|
|
59967
|
-
[1 << 1]: "Withdraw"
|
|
60161
|
+
[1 << 1]: "Deposit",
|
|
60162
|
+
[1 << 2]: "Withdraw",
|
|
60163
|
+
[1 << 3]: "CreateModifyOrders",
|
|
60164
|
+
[1 << 4]: "CancelOrders",
|
|
60165
|
+
[1 << 5]: "TransferCollateral",
|
|
60166
|
+
[1 << 6]: "UpdateTraderState"
|
|
59968
60167
|
}
|
|
59969
60168
|
}
|
|
59970
60169
|
}
|
|
@@ -60210,21 +60409,15 @@ function isHeliusRpc(rpcUrl) {
|
|
|
60210
60409
|
function getHeliusApiKey() {
|
|
60211
60410
|
return process.env.NEXT_PUBLIC_HELIUS_API_KEY || process.env.HELIUS_API_KEY;
|
|
60212
60411
|
}
|
|
60213
|
-
|
|
60214
|
-
|
|
60215
|
-
|
|
60216
|
-
|
|
60217
|
-
|
|
60218
|
-
|
|
60219
|
-
// return await getProgramAccountsV2Helius(
|
|
60220
|
-
// connection.rpcEndpoint,
|
|
60221
|
-
// programId,
|
|
60222
|
-
// config,
|
|
60223
|
-
// );
|
|
60224
|
-
// }
|
|
60225
|
-
return await getProgramAccountsWithRetry(connection, programId, config);
|
|
60412
|
+
function getHeliusRpcUrl(apiKey) {
|
|
60413
|
+
const key = apiKey ?? getHeliusApiKey();
|
|
60414
|
+
if (!key) {
|
|
60415
|
+
throw new Error("Helius API key not found");
|
|
60416
|
+
}
|
|
60417
|
+
return `https://mainnet.helius-rpc.com/?api-key=${key}`;
|
|
60226
60418
|
}
|
|
60227
|
-
async function
|
|
60419
|
+
async function heliusFetch(method, params, options) {
|
|
60420
|
+
const rpcUrl = options?.rpcUrl ?? getHeliusRpcUrl(options?.apiKey);
|
|
60228
60421
|
const response = await fetch(rpcUrl, {
|
|
60229
60422
|
method: "POST",
|
|
60230
60423
|
headers: {
|
|
@@ -60237,12 +60430,159 @@ async function rpcRequest(rpcUrl, method, params) {
|
|
|
60237
60430
|
params
|
|
60238
60431
|
})
|
|
60239
60432
|
});
|
|
60433
|
+
if (!response.ok) {
|
|
60434
|
+
throw new Error(`${method} HTTP error: ${response.status}`);
|
|
60435
|
+
}
|
|
60240
60436
|
const data = await response.json();
|
|
60241
60437
|
if (data.error) {
|
|
60242
60438
|
throw new Error(`${method} RPC error: ${data.error.message}`);
|
|
60243
60439
|
}
|
|
60244
60440
|
return data.result;
|
|
60245
60441
|
}
|
|
60442
|
+
async function getAsset(mint, options) {
|
|
60443
|
+
const result = await heliusFetch("getAsset", {
|
|
60444
|
+
id: mint
|
|
60445
|
+
}, options);
|
|
60446
|
+
return result ?? null;
|
|
60447
|
+
}
|
|
60448
|
+
async function getTokenAccountsByMintResult(mint, options) {
|
|
60449
|
+
const mintStr = typeof mint === "string" ? mint : mint.toBase58();
|
|
60450
|
+
const result = await heliusFetch("getTokenAccounts", {
|
|
60451
|
+
mint: mintStr,
|
|
60452
|
+
...options?.limit !== undefined && {
|
|
60453
|
+
limit: options.limit
|
|
60454
|
+
},
|
|
60455
|
+
options: {
|
|
60456
|
+
showZeroBalance: options?.showZeroBalance ?? true
|
|
60457
|
+
}
|
|
60458
|
+
}, options);
|
|
60459
|
+
return {
|
|
60460
|
+
token_accounts: result?.token_accounts ?? [],
|
|
60461
|
+
total: result?.total
|
|
60462
|
+
};
|
|
60463
|
+
}
|
|
60464
|
+
async function getTokenAccountsByMint(mint, options) {
|
|
60465
|
+
return (await getTokenAccountsByMintResult(mint, options)).token_accounts;
|
|
60466
|
+
}
|
|
60467
|
+
async function getPriorityFeeEstimate(options) {
|
|
60468
|
+
const { heliusApiKey = getHeliusApiKey(), tx, accountKeys, priorityLevel } = options;
|
|
60469
|
+
if (!heliusApiKey) {
|
|
60470
|
+
console.warn("getPriorityFeeEstimate is called but Helius API key not found");
|
|
60471
|
+
return 0;
|
|
60472
|
+
}
|
|
60473
|
+
if (!tx && !accountKeys) {
|
|
60474
|
+
throw new Error("Either tx or accountKeys must be provided");
|
|
60475
|
+
}
|
|
60476
|
+
const requestOptions = priorityLevel && priorityLevel !== "Recommended" ? {
|
|
60477
|
+
priorityLevel
|
|
60478
|
+
} : {
|
|
60479
|
+
recommended: true
|
|
60480
|
+
};
|
|
60481
|
+
const param = tx ? {
|
|
60482
|
+
transaction: bs58.encode(tx.serialize())
|
|
60483
|
+
} : {
|
|
60484
|
+
accountKeys
|
|
60485
|
+
};
|
|
60486
|
+
const result = await heliusFetch("getPriorityFeeEstimate", [
|
|
60487
|
+
{
|
|
60488
|
+
...param,
|
|
60489
|
+
options: requestOptions
|
|
60490
|
+
}
|
|
60491
|
+
], {
|
|
60492
|
+
apiKey: heliusApiKey
|
|
60493
|
+
});
|
|
60494
|
+
return result.priorityFeeEstimate;
|
|
60495
|
+
}
|
|
60496
|
+
// FIXME: The param `limit` now controls page size, not total results
|
|
60497
|
+
async function heliusGetTransactionsForAddress(rpcUrl, address, options) {
|
|
60498
|
+
const { transactionDetails = "full", limit = 100, before, commitment } = options || {};
|
|
60499
|
+
const allTransactions = [];
|
|
60500
|
+
let result;
|
|
60501
|
+
let paginationToken = before;
|
|
60502
|
+
do {
|
|
60503
|
+
result = await heliusFetch("getTransactionsForAddress", [
|
|
60504
|
+
address.toBase58(),
|
|
60505
|
+
{
|
|
60506
|
+
transactionDetails,
|
|
60507
|
+
limit,
|
|
60508
|
+
...paginationToken && {
|
|
60509
|
+
paginationToken
|
|
60510
|
+
},
|
|
60511
|
+
...commitment && {
|
|
60512
|
+
commitment
|
|
60513
|
+
}
|
|
60514
|
+
}
|
|
60515
|
+
], {
|
|
60516
|
+
rpcUrl
|
|
60517
|
+
});
|
|
60518
|
+
allTransactions.push(...result?.data || []);
|
|
60519
|
+
paginationToken = result?.paginationToken;
|
|
60520
|
+
}while (paginationToken)
|
|
60521
|
+
return allTransactions;
|
|
60522
|
+
}
|
|
60523
|
+
function decodeAccountData(accountData, encoding) {
|
|
60524
|
+
if (encoding === "base64") {
|
|
60525
|
+
return Buffer.from(accountData, "base64");
|
|
60526
|
+
} else if (encoding === "base64+zstd") {
|
|
60527
|
+
const compressed = Buffer.from(accountData, "base64");
|
|
60528
|
+
return Buffer.from(decompress(compressed));
|
|
60529
|
+
} else if (encoding === "base58") {
|
|
60530
|
+
return bs58.decode(accountData);
|
|
60531
|
+
}
|
|
60532
|
+
throw new Error(`Unsupported encoding: ${encoding}`);
|
|
60533
|
+
}
|
|
60534
|
+
async function heliusGetProgramAccountsV2(rpcUrl, programId, config) {
|
|
60535
|
+
const allAccounts = [];
|
|
60536
|
+
let paginationKey = null;
|
|
60537
|
+
do {
|
|
60538
|
+
const result = await heliusFetch("getProgramAccountsV2", [
|
|
60539
|
+
programId.toBase58(),
|
|
60540
|
+
{
|
|
60541
|
+
encoding: config.encoding || "base64",
|
|
60542
|
+
filters: config.filters || [],
|
|
60543
|
+
...config.limit && {
|
|
60544
|
+
limit: config.limit
|
|
60545
|
+
},
|
|
60546
|
+
...config.changedSinceSlot && {
|
|
60547
|
+
changedSinceSlot: config.changedSinceSlot
|
|
60548
|
+
},
|
|
60549
|
+
...paginationKey && {
|
|
60550
|
+
paginationKey
|
|
60551
|
+
}
|
|
60552
|
+
}
|
|
60553
|
+
], {
|
|
60554
|
+
rpcUrl
|
|
60555
|
+
});
|
|
60556
|
+
for (const { pubkey, account } of result.accounts){
|
|
60557
|
+
const [accountData, encoding] = account.data;
|
|
60558
|
+
allAccounts.push({
|
|
60559
|
+
pubkey: new PublicKey(pubkey),
|
|
60560
|
+
account: {
|
|
60561
|
+
...account,
|
|
60562
|
+
owner: new PublicKey(account.owner),
|
|
60563
|
+
data: decodeAccountData(accountData, encoding)
|
|
60564
|
+
}
|
|
60565
|
+
});
|
|
60566
|
+
}
|
|
60567
|
+
paginationKey = result.accounts.length > 0 ? result.paginationKey : null;
|
|
60568
|
+
}while (paginationKey)
|
|
60569
|
+
return allAccounts;
|
|
60570
|
+
}
|
|
60571
|
+
|
|
60572
|
+
/**
|
|
60573
|
+
* Fetches program accounts using Helius getProgramAccountsV2 if available.
|
|
60574
|
+
* Otherwise falls back to standard getProgramAccounts with retry logic.
|
|
60575
|
+
*/ async function getProgramAccounts(connection, programId, config) {
|
|
60576
|
+
// 2026-03-02: Helius getProgramAccountsV2 cannot find ALTs, disable it for now
|
|
60577
|
+
// if (isHeliusRpc(connection.rpcEndpoint)) {
|
|
60578
|
+
// return await heliusGetProgramAccountsV2(
|
|
60579
|
+
// connection.rpcEndpoint,
|
|
60580
|
+
// programId,
|
|
60581
|
+
// config,
|
|
60582
|
+
// );
|
|
60583
|
+
// }
|
|
60584
|
+
return await getProgramAccountsWithRetry(connection, programId, config);
|
|
60585
|
+
}
|
|
60246
60586
|
/**
|
|
60247
60587
|
* Standard getProgramAccounts with retry logic for transient errors.
|
|
60248
60588
|
*/ async function getProgramAccountsWithRetry(connection, programId, config) {
|
|
@@ -60269,7 +60609,7 @@ async function rpcRequest(rpcUrl, method, params) {
|
|
|
60269
60609
|
* Otherwise falls back to getSignaturesForAddress + getTransaction.
|
|
60270
60610
|
*/ async function getTransactionsForAddress(connection, address, options) {
|
|
60271
60611
|
if (isHeliusRpc(connection.rpcEndpoint)) {
|
|
60272
|
-
return (await
|
|
60612
|
+
return (await heliusGetTransactionsForAddress(connection.rpcEndpoint, address, options)).filter((tx)=>tx !== null);
|
|
60273
60613
|
}
|
|
60274
60614
|
const signatures = await connection.getSignaturesForAddress(address, {
|
|
60275
60615
|
limit: options?.limit,
|
|
@@ -60280,59 +60620,6 @@ async function rpcRequest(rpcUrl, method, params) {
|
|
|
60280
60620
|
})));
|
|
60281
60621
|
return transactions.filter((tx)=>tx !== null);
|
|
60282
60622
|
}
|
|
60283
|
-
// FIXME: The param `limit` now controls page size, not total results
|
|
60284
|
-
async function getTransactionsForAddressHelius(rpcUrl, address, options) {
|
|
60285
|
-
const { transactionDetails = "full", limit = 100, before, commitment } = options || {};
|
|
60286
|
-
const allTransactions = [];
|
|
60287
|
-
let result;
|
|
60288
|
-
let paginationToken = before;
|
|
60289
|
-
do {
|
|
60290
|
-
result = await rpcRequest(rpcUrl, "getTransactionsForAddress", [
|
|
60291
|
-
address.toBase58(),
|
|
60292
|
-
{
|
|
60293
|
-
transactionDetails,
|
|
60294
|
-
limit,
|
|
60295
|
-
...paginationToken && {
|
|
60296
|
-
paginationToken
|
|
60297
|
-
},
|
|
60298
|
-
...commitment && {
|
|
60299
|
-
commitment
|
|
60300
|
-
}
|
|
60301
|
-
}
|
|
60302
|
-
]);
|
|
60303
|
-
allTransactions.push(...result?.data || []);
|
|
60304
|
-
paginationToken = result?.paginationToken;
|
|
60305
|
-
}while (paginationToken)
|
|
60306
|
-
return allTransactions;
|
|
60307
|
-
}
|
|
60308
|
-
async function getPriorityFeeEstimate(options) {
|
|
60309
|
-
const { heliusApiKey = getHeliusApiKey(), tx, accountKeys, priorityLevel } = options;
|
|
60310
|
-
if (!heliusApiKey) {
|
|
60311
|
-
console.warn("getPriorityFeeEstimate is called but Helius API key not found");
|
|
60312
|
-
return 0;
|
|
60313
|
-
}
|
|
60314
|
-
if (!tx && !accountKeys) {
|
|
60315
|
-
throw new Error("Either tx or accountKeys must be provided");
|
|
60316
|
-
}
|
|
60317
|
-
const requestOptions = priorityLevel && priorityLevel !== "Recommended" ? {
|
|
60318
|
-
priorityLevel
|
|
60319
|
-
} : {
|
|
60320
|
-
recommended: true
|
|
60321
|
-
};
|
|
60322
|
-
const param = tx ? {
|
|
60323
|
-
transaction: bs58.encode(tx.serialize())
|
|
60324
|
-
} : {
|
|
60325
|
-
accountKeys
|
|
60326
|
-
};
|
|
60327
|
-
const rpcUrl = `https://mainnet.helius-rpc.com/?api-key=${heliusApiKey}`;
|
|
60328
|
-
const result = await rpcRequest(rpcUrl, "getPriorityFeeEstimate", [
|
|
60329
|
-
{
|
|
60330
|
-
...param,
|
|
60331
|
-
options: requestOptions
|
|
60332
|
-
}
|
|
60333
|
-
]);
|
|
60334
|
-
return result.priorityFeeEstimate;
|
|
60335
|
-
}
|
|
60336
60623
|
|
|
60337
60624
|
/**
|
|
60338
60625
|
* Fetches all the token accounts owned by the specified pubkey.
|
|
@@ -61674,6 +61961,66 @@ class JupiterApiClient {
|
|
|
61674
61961
|
}
|
|
61675
61962
|
}
|
|
61676
61963
|
|
|
61964
|
+
const DEFAULT_PHOENIX_API_URL = "https://perp-api.phoenix.trade";
|
|
61965
|
+
function normalizePhoenixApiUrl(apiUrl) {
|
|
61966
|
+
return apiUrl.replace(/\/+$/, "");
|
|
61967
|
+
}
|
|
61968
|
+
function publicKeyString(value) {
|
|
61969
|
+
return value instanceof PublicKey ? value.toBase58() : value;
|
|
61970
|
+
}
|
|
61971
|
+
class PhoenixApiClient {
|
|
61972
|
+
url(path) {
|
|
61973
|
+
return `${normalizePhoenixApiUrl(this.apiUrl)}${path}`;
|
|
61974
|
+
}
|
|
61975
|
+
async fetchPhoenixSnapshot() {
|
|
61976
|
+
const url = this.url("/v1/exchange/snapshot");
|
|
61977
|
+
const response = await fetch(url);
|
|
61978
|
+
if (!response.ok) {
|
|
61979
|
+
const errorText = await response.text();
|
|
61980
|
+
throw new Error(`Failed to fetch Phoenix exchange snapshot: ${response.status} ${errorText || response.statusText}`);
|
|
61981
|
+
}
|
|
61982
|
+
const snapshot = await response.json();
|
|
61983
|
+
if (!snapshot.exchange || !Array.isArray(snapshot.markets)) {
|
|
61984
|
+
throw new Error(`Unexpected Phoenix snapshot response from ${url}`);
|
|
61985
|
+
}
|
|
61986
|
+
return snapshot;
|
|
61987
|
+
}
|
|
61988
|
+
async fetchTraderView(trader) {
|
|
61989
|
+
const url = this.url(`/v1/view/trader/${publicKeyString(trader)}`);
|
|
61990
|
+
const response = await fetch(url);
|
|
61991
|
+
if (response.status === 404) {
|
|
61992
|
+
return null;
|
|
61993
|
+
}
|
|
61994
|
+
if (!response.ok) {
|
|
61995
|
+
const errorText = await response.text();
|
|
61996
|
+
throw new Error(`Failed to fetch Phoenix trader view: ${response.status} ${errorText || response.statusText}`);
|
|
61997
|
+
}
|
|
61998
|
+
return await response.json();
|
|
61999
|
+
}
|
|
62000
|
+
async fetchTraderState(authority, pdaIndex) {
|
|
62001
|
+
const queryParams = new URLSearchParams({
|
|
62002
|
+
pdaIndex: `${pdaIndex}`
|
|
62003
|
+
});
|
|
62004
|
+
const url = `${this.url(`/trader/${publicKeyString(authority)}/state`)}?${queryParams}`;
|
|
62005
|
+
const response = await fetch(url);
|
|
62006
|
+
if (response.status === 404) {
|
|
62007
|
+
return null;
|
|
62008
|
+
}
|
|
62009
|
+
if (!response.ok) {
|
|
62010
|
+
const errorText = await response.text();
|
|
62011
|
+
throw new Error(`Failed to fetch Phoenix trader state: ${response.status} ${errorText || response.statusText}`);
|
|
62012
|
+
}
|
|
62013
|
+
const state = await response.json();
|
|
62014
|
+
if (!Array.isArray(state.traders)) {
|
|
62015
|
+
throw new Error(`Unexpected Phoenix trader state response from ${url}`);
|
|
62016
|
+
}
|
|
62017
|
+
return state;
|
|
62018
|
+
}
|
|
62019
|
+
constructor(){
|
|
62020
|
+
this.apiUrl = process.env.NEXT_PUBLIC_PHOENIX_API_URL || process.env.PHOENIX_API_URL || DEFAULT_PHOENIX_API_URL;
|
|
62021
|
+
}
|
|
62022
|
+
}
|
|
62023
|
+
|
|
61677
62024
|
/**
|
|
61678
62025
|
* Utility class for categorizing external positions by protocol type.
|
|
61679
62026
|
*
|
|
@@ -62814,6 +63161,8 @@ class BaseClient {
|
|
|
62814
63161
|
this.staging = resolveStaging(config?.useStaging);
|
|
62815
63162
|
this.jupiterApiKey = config?.jupiterApiKey;
|
|
62816
63163
|
this.jupiterApiClient = config?.jupiterApiClient;
|
|
63164
|
+
this.phoenixApiUrl = config?.phoenixApiUrl;
|
|
63165
|
+
this.phoenixApiClient = config?.phoenixApiClient;
|
|
62817
63166
|
this.blockhashWithCache = new BlockhashWithCache(this.provider);
|
|
62818
63167
|
}
|
|
62819
63168
|
}
|
|
@@ -62837,7 +63186,7 @@ class BaseClient {
|
|
|
62837
63186
|
}
|
|
62838
63187
|
}
|
|
62839
63188
|
|
|
62840
|
-
let TxBuilder$
|
|
63189
|
+
let TxBuilder$i = class TxBuilder extends BaseTxBuilder {
|
|
62841
63190
|
async resolveSwapInstructionContext(options) {
|
|
62842
63191
|
const glamVault = this.client.base.vaultPda;
|
|
62843
63192
|
const { quoteParams, quoteResponse } = options;
|
|
@@ -63019,14 +63368,14 @@ class JupiterSwapClient {
|
|
|
63019
63368
|
this.base = base;
|
|
63020
63369
|
this.vault = vault;
|
|
63021
63370
|
this.klend = klend;
|
|
63022
|
-
this.txBuilder = new TxBuilder$
|
|
63371
|
+
this.txBuilder = new TxBuilder$i(this);
|
|
63023
63372
|
this.jupApi = this.base.jupiterApiClient || new JupiterApiClient({
|
|
63024
63373
|
apiKey: this.base.jupiterApiKey
|
|
63025
63374
|
});
|
|
63026
63375
|
}
|
|
63027
63376
|
}
|
|
63028
63377
|
|
|
63029
|
-
let TxBuilder$
|
|
63378
|
+
let TxBuilder$h = class TxBuilder extends BaseTxBuilder {
|
|
63030
63379
|
async depositIxs(amount, glamSigner) {
|
|
63031
63380
|
const marinadeState = await this.client.fetchMarinadeState();
|
|
63032
63381
|
const { mSolMintAddress, marinadeStateAddress } = marinadeState;
|
|
@@ -63256,11 +63605,11 @@ class MarinadeClient {
|
|
|
63256
63605
|
this.base = base;
|
|
63257
63606
|
this.stake = stake;
|
|
63258
63607
|
this.marinadeState = null;
|
|
63259
|
-
this.txBuilder = new TxBuilder$
|
|
63608
|
+
this.txBuilder = new TxBuilder$h(this);
|
|
63260
63609
|
}
|
|
63261
63610
|
}
|
|
63262
63611
|
|
|
63263
|
-
let TxBuilder$
|
|
63612
|
+
let TxBuilder$g = class TxBuilder extends BaseTxBuilder {
|
|
63264
63613
|
async wrapIxs(amount, glamSigner) {
|
|
63265
63614
|
const vaultAta = this.client.base.getVaultAta(WSOL);
|
|
63266
63615
|
const preIx = createAssociatedTokenAccountIdempotentInstruction(glamSigner, vaultAta, this.client.base.vaultPda, WSOL);
|
|
@@ -63518,17 +63867,15 @@ class VaultClient {
|
|
|
63518
63867
|
}
|
|
63519
63868
|
constructor(base){
|
|
63520
63869
|
this.base = base;
|
|
63521
|
-
this.txBuilder = new TxBuilder$
|
|
63870
|
+
this.txBuilder = new TxBuilder$g(this);
|
|
63522
63871
|
}
|
|
63523
63872
|
}
|
|
63524
63873
|
|
|
63525
|
-
let TxBuilder$
|
|
63874
|
+
let TxBuilder$f = class TxBuilder extends BaseTxBuilder {
|
|
63526
63875
|
async initializeIx(params, glamSigner) {
|
|
63527
63876
|
// stateInitKey = hash state name and get first 8 bytes
|
|
63528
63877
|
// useful for re-computing state account PDA in the future
|
|
63529
|
-
const stateInitKey =
|
|
63530
|
-
...Buffer.from(anchor.utils.sha256.hash(charsToString(params.name))).subarray(0, 8)
|
|
63531
|
-
];
|
|
63878
|
+
const stateInitKey = await sha256First8Bytes(params.name);
|
|
63532
63879
|
const created = new CreatedModel({
|
|
63533
63880
|
key: stateInitKey
|
|
63534
63881
|
});
|
|
@@ -63636,7 +63983,7 @@ class StateClient {
|
|
|
63636
63983
|
}
|
|
63637
63984
|
constructor(base){
|
|
63638
63985
|
this.base = base;
|
|
63639
|
-
this.txBuilder = new TxBuilder$
|
|
63986
|
+
this.txBuilder = new TxBuilder$f(this);
|
|
63640
63987
|
}
|
|
63641
63988
|
}
|
|
63642
63989
|
|
|
@@ -63945,7 +64292,7 @@ Obligation._layout = struct([
|
|
|
63945
64292
|
array(u64(), 93, "padding3")
|
|
63946
64293
|
]);
|
|
63947
64294
|
|
|
63948
|
-
let TxBuilder$
|
|
64295
|
+
let TxBuilder$e = class TxBuilder extends BaseTxBuilder {
|
|
63949
64296
|
refreshObligationIx(accounts) {
|
|
63950
64297
|
const keys = [
|
|
63951
64298
|
{
|
|
@@ -64760,11 +65107,11 @@ class KaminoLendingClient {
|
|
|
64760
65107
|
this.vault = vault;
|
|
64761
65108
|
this.reserves = new PkMap();
|
|
64762
65109
|
this.obligations = new PkMap();
|
|
64763
|
-
this.txBuilder = new TxBuilder$
|
|
65110
|
+
this.txBuilder = new TxBuilder$e(this);
|
|
64764
65111
|
}
|
|
64765
65112
|
}
|
|
64766
65113
|
|
|
64767
|
-
let TxBuilder$
|
|
65114
|
+
let TxBuilder$d = class TxBuilder extends BaseTxBuilder {
|
|
64768
65115
|
async stakeTx(amount, farmState, txOptions = {}) {
|
|
64769
65116
|
const glamSigner = txOptions.signer || this.client.base.signer;
|
|
64770
65117
|
const farms = await this.client.fetchAndParseFarmStates([
|
|
@@ -65012,11 +65359,11 @@ class KaminoFarmClient {
|
|
|
65012
65359
|
globalConfig.toBuffer(),
|
|
65013
65360
|
mint.toBuffer()
|
|
65014
65361
|
], KAMINO_FARM_PROGRAM)[0];
|
|
65015
|
-
this.txBuilder = new TxBuilder$
|
|
65362
|
+
this.txBuilder = new TxBuilder$d(this);
|
|
65016
65363
|
}
|
|
65017
65364
|
}
|
|
65018
65365
|
|
|
65019
|
-
let TxBuilder$
|
|
65366
|
+
let TxBuilder$c = class TxBuilder extends BaseTxBuilder {
|
|
65020
65367
|
async depositTx(vault, amount, txOptions = {}) {
|
|
65021
65368
|
const glamSigner = txOptions.signer || this.client.base.signer;
|
|
65022
65369
|
const vaultState = await this.client.fetchAndParseVaultState(vault);
|
|
@@ -65187,7 +65534,7 @@ class KaminoVaultsClient {
|
|
|
65187
65534
|
this.kaminoLending = kaminoLending;
|
|
65188
65535
|
this.vaultStates = new PkMap();
|
|
65189
65536
|
this.shareMintToVaultPdaMap = new PkMap();
|
|
65190
|
-
this.txBuilder = new TxBuilder$
|
|
65537
|
+
this.txBuilder = new TxBuilder$c(this);
|
|
65191
65538
|
}
|
|
65192
65539
|
}
|
|
65193
65540
|
|
|
@@ -65304,7 +65651,7 @@ class KaminoVaultsClient {
|
|
|
65304
65651
|
])
|
|
65305
65652
|
});
|
|
65306
65653
|
}
|
|
65307
|
-
let TxBuilder$
|
|
65654
|
+
let TxBuilder$b = class TxBuilder extends BaseTxBuilder {
|
|
65308
65655
|
async setTokenAccountsStatesIx(tokenAccounts, frozen, glamSigner) {
|
|
65309
65656
|
return await this.client.base.mintProgram.methods.setTokenAccountsStates(frozen).accounts({
|
|
65310
65657
|
glamState: this.client.base.statePda,
|
|
@@ -65499,9 +65846,7 @@ let TxBuilder$a = class TxBuilder extends BaseTxBuilder {
|
|
|
65499
65846
|
}
|
|
65500
65847
|
async initializeIxs(initMintParams, stateParams, glamSigner) {
|
|
65501
65848
|
const decimals = typeof initMintParams.decimals === "number" ? initMintParams.decimals : null;
|
|
65502
|
-
const stateInitKey =
|
|
65503
|
-
...Buffer.from(utils.sha256.hash(charsToString(initMintParams.name))).subarray(0, 8)
|
|
65504
|
-
];
|
|
65849
|
+
const stateInitKey = await sha256First8Bytes(initMintParams.name);
|
|
65505
65850
|
const glamState = getStatePda(stateInitKey, glamSigner, this.client.base.protocolProgram.programId);
|
|
65506
65851
|
const postInstructions = [];
|
|
65507
65852
|
// If stateParams is provided and is not empty, update the state account as a post instruction
|
|
@@ -65909,34 +66254,15 @@ class MintClient {
|
|
|
65909
66254
|
return this.getPrice();
|
|
65910
66255
|
}
|
|
65911
66256
|
/**
|
|
65912
|
-
* Fetches token holders of the GLAM mint using helius RPC
|
|
66257
|
+
* Fetches token holders of the GLAM mint using helius RPC. Falls back to
|
|
66258
|
+
* getHolders if helius API key is not provided or cluster is not mainnet.
|
|
65913
66259
|
*/ async fetchTokenHolders(showZeroBalance = true) {
|
|
65914
|
-
|
|
65915
|
-
// in case users choose to use a non-helius RPC. Fall back to getHolders if
|
|
65916
|
-
// helius API key is not provided
|
|
65917
|
-
const heliusApiKey = process.env.NEXT_PUBLIC_HELIUS_API_KEY || process.env.HELIUS_API_KEY;
|
|
65918
|
-
if (!heliusApiKey || this.base.cluster !== ClusterNetwork.Mainnet) {
|
|
66260
|
+
if (!getHeliusApiKey() || this.base.cluster !== ClusterNetwork.Mainnet) {
|
|
65919
66261
|
return await this.getHolders(showZeroBalance);
|
|
65920
66262
|
}
|
|
65921
|
-
const
|
|
65922
|
-
|
|
65923
|
-
headers: {
|
|
65924
|
-
"Content-Type": "application/json"
|
|
65925
|
-
},
|
|
65926
|
-
body: JSON.stringify({
|
|
65927
|
-
jsonrpc: "2.0",
|
|
65928
|
-
id: "1",
|
|
65929
|
-
method: "getTokenAccounts",
|
|
65930
|
-
params: {
|
|
65931
|
-
mint: this.base.mintPda.toBase58(),
|
|
65932
|
-
options: {
|
|
65933
|
-
showZeroBalance
|
|
65934
|
-
}
|
|
65935
|
-
}
|
|
65936
|
-
})
|
|
66263
|
+
const tokenAccounts = await getTokenAccountsByMint(this.base.mintPda, {
|
|
66264
|
+
showZeroBalance
|
|
65937
66265
|
});
|
|
65938
|
-
const data = await response.json();
|
|
65939
|
-
const { token_accounts: tokenAccounts } = data.result;
|
|
65940
66266
|
const { mint, tokenProgram } = await fetchMintAndTokenProgram(this.base.connection, this.base.mintPda);
|
|
65941
66267
|
return tokenAccounts.map((ta)=>({
|
|
65942
66268
|
owner: new PublicKey(ta.owner),
|
|
@@ -65944,9 +66270,9 @@ class MintClient {
|
|
|
65944
66270
|
mint: this.base.mintPda,
|
|
65945
66271
|
programId: tokenProgram,
|
|
65946
66272
|
decimals: mint.decimals,
|
|
65947
|
-
amount: ta.amount,
|
|
65948
|
-
uiAmount:
|
|
65949
|
-
frozen: ta.frozen
|
|
66273
|
+
amount: String(ta.amount),
|
|
66274
|
+
uiAmount: toUiAmount(new BN(ta.amount), mint.decimals),
|
|
66275
|
+
frozen: Boolean(ta.frozen)
|
|
65950
66276
|
}));
|
|
65951
66277
|
}
|
|
65952
66278
|
// Can be very slow. Use fetchTokenHolders when possible.
|
|
@@ -66075,11 +66401,11 @@ class MintClient {
|
|
|
66075
66401
|
constructor(base, getPrice){
|
|
66076
66402
|
this.base = base;
|
|
66077
66403
|
this.getPrice = getPrice;
|
|
66078
|
-
this.txBuilder = new TxBuilder$
|
|
66404
|
+
this.txBuilder = new TxBuilder$b(this);
|
|
66079
66405
|
}
|
|
66080
66406
|
}
|
|
66081
66407
|
|
|
66082
|
-
let TxBuilder$
|
|
66408
|
+
let TxBuilder$a = class TxBuilder extends BaseTxBuilder {
|
|
66083
66409
|
async subscribeIxs(amount, signer) {
|
|
66084
66410
|
const { baseAssetMint: depositAsset } = await this.client.base.fetchStateModel();
|
|
66085
66411
|
const mintTo = this.client.base.getMintAta(signer);
|
|
@@ -66389,7 +66715,7 @@ class InvestClient {
|
|
|
66389
66715
|
}
|
|
66390
66716
|
constructor(base){
|
|
66391
66717
|
this.base = base;
|
|
66392
|
-
this.txBuilder = new TxBuilder$
|
|
66718
|
+
this.txBuilder = new TxBuilder$a(this);
|
|
66393
66719
|
}
|
|
66394
66720
|
}
|
|
66395
66721
|
|
|
@@ -66964,7 +67290,7 @@ function resolveRouteAccountPubkey(meta, payer, nonce) {
|
|
|
66964
67290
|
}
|
|
66965
67291
|
throw new Error("Unsupported LayerZero OFT route account placeholder");
|
|
66966
67292
|
}
|
|
66967
|
-
let TxBuilder$
|
|
67293
|
+
let TxBuilder$9 = class TxBuilder extends BaseTxBuilder {
|
|
66968
67294
|
async addLayerzeroOftRouteIx(route, signer) {
|
|
66969
67295
|
return await this.client.base.extBridgeProgram.methods.addLayerzeroOftRoute(normalizeRoute(route)).accountsPartial({
|
|
66970
67296
|
glamState: this.client.base.statePda,
|
|
@@ -67372,7 +67698,7 @@ class BridgeClient {
|
|
|
67372
67698
|
}
|
|
67373
67699
|
constructor(base){
|
|
67374
67700
|
this.base = base;
|
|
67375
|
-
this.txBuilder = new TxBuilder$
|
|
67701
|
+
this.txBuilder = new TxBuilder$9(this);
|
|
67376
67702
|
this.oft = new LayerzeroOftBridgeProtocolClient(this);
|
|
67377
67703
|
}
|
|
67378
67704
|
}
|
|
@@ -68276,7 +68602,7 @@ class PriceClient {
|
|
|
68276
68602
|
}
|
|
68277
68603
|
}
|
|
68278
68604
|
|
|
68279
|
-
let TxBuilder$
|
|
68605
|
+
let TxBuilder$8 = class TxBuilder extends BaseTxBuilder {
|
|
68280
68606
|
async crystallizeFeesIxs(glamSigner) {
|
|
68281
68607
|
const glamState = this.client.base.statePda;
|
|
68282
68608
|
const glamMint = this.client.base.mintPda;
|
|
@@ -68434,11 +68760,11 @@ class FeesClient {
|
|
|
68434
68760
|
constructor(base, price){
|
|
68435
68761
|
this.base = base;
|
|
68436
68762
|
this.price = price;
|
|
68437
|
-
this.txBuilder = new TxBuilder$
|
|
68763
|
+
this.txBuilder = new TxBuilder$8(this);
|
|
68438
68764
|
}
|
|
68439
68765
|
}
|
|
68440
68766
|
|
|
68441
|
-
let TxBuilder$
|
|
68767
|
+
let TxBuilder$7 = class TxBuilder extends BaseTxBuilder {
|
|
68442
68768
|
async emergencyAccessUpdateIx(args, signer) {
|
|
68443
68769
|
return await this.client.base.protocolProgram.methods.emergencyAccessUpdate(new EmergencyAccessUpdateArgs(args)).accounts({
|
|
68444
68770
|
glamState: this.client.base.statePda,
|
|
@@ -68603,11 +68929,11 @@ class AccessClient {
|
|
|
68603
68929
|
}
|
|
68604
68930
|
constructor(base){
|
|
68605
68931
|
this.base = base;
|
|
68606
|
-
this.txBuilder = new TxBuilder$
|
|
68932
|
+
this.txBuilder = new TxBuilder$7(this);
|
|
68607
68933
|
}
|
|
68608
68934
|
}
|
|
68609
68935
|
|
|
68610
|
-
let TxBuilder$
|
|
68936
|
+
let TxBuilder$6 = class TxBuilder extends BaseTxBuilder {
|
|
68611
68937
|
async applyStateTimelockIx(glamSigner) {
|
|
68612
68938
|
return await this.client.base.protocolProgram.methods.updateStateApplyTimelock().accounts({
|
|
68613
68939
|
glamState: this.client.base.statePda,
|
|
@@ -68685,11 +69011,11 @@ class TimelockClient {
|
|
|
68685
69011
|
constructor(base, stateClient){
|
|
68686
69012
|
this.base = base;
|
|
68687
69013
|
this.stateClient = stateClient;
|
|
68688
|
-
this.txBuilder = new TxBuilder$
|
|
69014
|
+
this.txBuilder = new TxBuilder$6(this);
|
|
68689
69015
|
}
|
|
68690
69016
|
}
|
|
68691
69017
|
|
|
68692
|
-
let TxBuilder$
|
|
69018
|
+
let TxBuilder$5 = class TxBuilder extends BaseTxBuilder {
|
|
68693
69019
|
async initializeAndDelegateStakeIxs(vote, amount, glamSigner) {
|
|
68694
69020
|
const [stakeAccount, createStakeAccountIx] = await this.client.createStakeAccount(glamSigner);
|
|
68695
69021
|
const glamState = this.client.base.statePda;
|
|
@@ -68902,11 +69228,11 @@ class StakeClient {
|
|
|
68902
69228
|
}
|
|
68903
69229
|
constructor(base){
|
|
68904
69230
|
this.base = base;
|
|
68905
|
-
this.txBuilder = new TxBuilder$
|
|
69231
|
+
this.txBuilder = new TxBuilder$5(this);
|
|
68906
69232
|
}
|
|
68907
69233
|
}
|
|
68908
69234
|
|
|
68909
|
-
let TxBuilder$
|
|
69235
|
+
let TxBuilder$4 = class TxBuilder extends BaseTxBuilder {
|
|
68910
69236
|
async depositSolIxs(stakePool, lamports, glamSigner) {
|
|
68911
69237
|
const { programId: stakePoolProgram, poolMint, withdrawAuthority, feeAccount, tokenProgramId: tokenProgram, reserveStake } = await this.client.getStakePoolAccountData(stakePool);
|
|
68912
69238
|
const glamVault = this.client.base.vaultPda;
|
|
@@ -69104,7 +69430,7 @@ class StakePoolClient {
|
|
|
69104
69430
|
this.base = base;
|
|
69105
69431
|
this.stake = stake;
|
|
69106
69432
|
this.marinade = marinade;
|
|
69107
|
-
this.txBuilder = new TxBuilder$
|
|
69433
|
+
this.txBuilder = new TxBuilder$4(this);
|
|
69108
69434
|
}
|
|
69109
69435
|
}
|
|
69110
69436
|
|
|
@@ -69154,7 +69480,7 @@ class CctpBridgeEvent {
|
|
|
69154
69480
|
this.uiAmount = toUiAmount(this.amount, 6);
|
|
69155
69481
|
}
|
|
69156
69482
|
}
|
|
69157
|
-
let TxBuilder$
|
|
69483
|
+
let TxBuilder$3 = class TxBuilder extends BaseTxBuilder {
|
|
69158
69484
|
/**
|
|
69159
69485
|
* Returns a transaction that calls CCTP's `depositForBurn` instruction that bridges USDC to another chain.
|
|
69160
69486
|
* A keypair is generated for the message sent event account, which must be included as a transaction signer.
|
|
@@ -69685,7 +70011,7 @@ class CctpClient {
|
|
|
69685
70011
|
}
|
|
69686
70012
|
constructor(base){
|
|
69687
70013
|
this.base = base;
|
|
69688
|
-
this.txBuilder = new TxBuilder$
|
|
70014
|
+
this.txBuilder = new TxBuilder$3(this);
|
|
69689
70015
|
}
|
|
69690
70016
|
}
|
|
69691
70017
|
|
|
@@ -69703,7 +70029,7 @@ function toReservedBytes(value) {
|
|
|
69703
70029
|
}
|
|
69704
70030
|
return bytes;
|
|
69705
70031
|
}
|
|
69706
|
-
let TxBuilder$
|
|
70032
|
+
let TxBuilder$2 = class TxBuilder extends BaseTxBuilder {
|
|
69707
70033
|
async upsertExternalPositionIx(params, signer) {
|
|
69708
70034
|
return await this.client.base.extEpiProgram.methods.upsertExternalPosition({
|
|
69709
70035
|
positionId: toFixedArray32(params.positionId, "positionId"),
|
|
@@ -69812,7 +70138,7 @@ class EpiClient {
|
|
|
69812
70138
|
}
|
|
69813
70139
|
constructor(base){
|
|
69814
70140
|
this.base = base;
|
|
69815
|
-
this.txBuilder = new TxBuilder$
|
|
70141
|
+
this.txBuilder = new TxBuilder$2(this);
|
|
69816
70142
|
}
|
|
69817
70143
|
}
|
|
69818
70144
|
|
|
@@ -69834,7 +70160,7 @@ function getLoopscaleLoanPda(borrower, nonce, programId = LOOPSCALE_PROGRAM_ID)
|
|
|
69834
70160
|
toBn(nonce).toArrayLike(Buffer, "le", 8)
|
|
69835
70161
|
], programId)[0];
|
|
69836
70162
|
}
|
|
69837
|
-
let TxBuilder = class TxBuilder extends BaseTxBuilder {
|
|
70163
|
+
let TxBuilder$1 = class TxBuilder extends BaseTxBuilder {
|
|
69838
70164
|
async createLoanIx(params, accounts, signer) {
|
|
69839
70165
|
return await this.client.base.extLoopscaleProgram.methods.createLoan({
|
|
69840
70166
|
nonce: params.nonce
|
|
@@ -69987,9 +70313,440 @@ class LoopscaleClient {
|
|
|
69987
70313
|
const tx = await this.txBuilder.borrowPrincipalTx(params, accounts, txOptions);
|
|
69988
70314
|
return await this.base.sendAndConfirm(tx);
|
|
69989
70315
|
}
|
|
70316
|
+
constructor(base){
|
|
70317
|
+
this.base = base;
|
|
70318
|
+
this.txBuilder = new TxBuilder$1(this);
|
|
70319
|
+
}
|
|
70320
|
+
}
|
|
70321
|
+
|
|
70322
|
+
function meta(pubkey, isWritable) {
|
|
70323
|
+
return {
|
|
70324
|
+
pubkey: new PublicKey(pubkey),
|
|
70325
|
+
isSigner: false,
|
|
70326
|
+
isWritable
|
|
70327
|
+
};
|
|
70328
|
+
}
|
|
70329
|
+
function getPhoenixTraderPda(authority, traderPdaIndex = 0, subaccountIndex = 0) {
|
|
70330
|
+
return PublicKey.findProgramAddressSync([
|
|
70331
|
+
Buffer.from("trader"),
|
|
70332
|
+
authority.toBuffer(),
|
|
70333
|
+
Buffer.from([
|
|
70334
|
+
traderPdaIndex,
|
|
70335
|
+
subaccountIndex
|
|
70336
|
+
])
|
|
70337
|
+
], PHOENIX_PROGRAM_ID)[0];
|
|
70338
|
+
}
|
|
70339
|
+
function getPhoenixSplineCollectionPda(market) {
|
|
70340
|
+
return PublicKey.findProgramAddressSync([
|
|
70341
|
+
Buffer.from("spline"),
|
|
70342
|
+
market.toBuffer()
|
|
70343
|
+
], PHOENIX_PROGRAM_ID)[0];
|
|
70344
|
+
}
|
|
70345
|
+
function getPhoenixGlobalVaultPda(mint) {
|
|
70346
|
+
return PublicKey.findProgramAddressSync([
|
|
70347
|
+
Buffer.from("vault"),
|
|
70348
|
+
mint.toBuffer()
|
|
70349
|
+
], PHOENIX_PROGRAM_ID)[0];
|
|
70350
|
+
}
|
|
70351
|
+
function getEmberStatePda() {
|
|
70352
|
+
return PublicKey.findProgramAddressSync([
|
|
70353
|
+
PHOENIX_PROGRAM_ID.toBuffer(),
|
|
70354
|
+
Buffer.from("state")
|
|
70355
|
+
], EMBER_PROGRAM_ID)[0];
|
|
70356
|
+
}
|
|
70357
|
+
function getEmberVaultPda() {
|
|
70358
|
+
return PublicKey.findProgramAddressSync([
|
|
70359
|
+
PHOENIX_PROGRAM_ID.toBuffer(),
|
|
70360
|
+
Buffer.from("vault")
|
|
70361
|
+
], EMBER_PROGRAM_ID)[0];
|
|
70362
|
+
}
|
|
70363
|
+
let TxBuilder = class TxBuilder extends BaseTxBuilder {
|
|
70364
|
+
getEmberCpiAccounts(accounts, signer) {
|
|
70365
|
+
return {
|
|
70366
|
+
glamState: this.client.base.statePda,
|
|
70367
|
+
glamVault: this.client.base.vaultPda,
|
|
70368
|
+
glamSigner: signer || this.client.base.signer,
|
|
70369
|
+
integrationAuthority: this.client.getIntegrationAuthorityPda(),
|
|
70370
|
+
cpiProgram: EMBER_PROGRAM_ID,
|
|
70371
|
+
glamProtocolProgram: this.client.base.protocolProgram.programId,
|
|
70372
|
+
systemProgram: SystemProgram.programId,
|
|
70373
|
+
emberState: accounts.emberState || this.client.getEmberStatePda(),
|
|
70374
|
+
inputMint: accounts.inputMint,
|
|
70375
|
+
outputMint: accounts.outputMint,
|
|
70376
|
+
inputTokenAccount: accounts.inputTokenAccount || this.client.base.getVaultAta(accounts.inputMint),
|
|
70377
|
+
outputTokenAccount: accounts.outputTokenAccount || this.client.base.getVaultAta(accounts.outputMint, accounts.tokenProgram),
|
|
70378
|
+
emberVault: accounts.emberVault || this.client.getEmberVaultPda(),
|
|
70379
|
+
tokenProgram: accounts.tokenProgram || TOKEN_PROGRAM_ID
|
|
70380
|
+
};
|
|
70381
|
+
}
|
|
70382
|
+
/**
|
|
70383
|
+
* Account map shared by every ext_phoenix Phoenix-CPI instruction
|
|
70384
|
+
* (`glam_state`, `glam_vault`, `glam_signer`, integration authority,
|
|
70385
|
+
* `cpi_program=Phoenix`, the GLAM protocol program, system program).
|
|
70386
|
+
*/ getPhoenixCpiAccounts(signer) {
|
|
70387
|
+
return {
|
|
70388
|
+
glamState: this.client.base.statePda,
|
|
70389
|
+
glamVault: this.client.base.vaultPda,
|
|
70390
|
+
glamSigner: signer || this.client.base.signer,
|
|
70391
|
+
integrationAuthority: this.client.getIntegrationAuthorityPda(),
|
|
70392
|
+
cpiProgram: PHOENIX_PROGRAM_ID,
|
|
70393
|
+
glamProtocolProgram: this.client.base.protocolProgram.programId,
|
|
70394
|
+
systemProgram: SystemProgram.programId
|
|
70395
|
+
};
|
|
70396
|
+
}
|
|
70397
|
+
async setPolicyIx(policy, signer) {
|
|
70398
|
+
const policyInput = {
|
|
70399
|
+
marketsAllowlist: policy.marketsAllowlist,
|
|
70400
|
+
allowedOrderTypes: Buffer.from(policy.allowedOrderTypes),
|
|
70401
|
+
maxPriceDeviationBps: policy.maxPriceDeviationBps,
|
|
70402
|
+
requireReduceOnlyOrders: policy.requireReduceOnlyOrders,
|
|
70403
|
+
maxReferencePriceAgeSecs: policy.maxReferencePriceAgeSecs
|
|
70404
|
+
};
|
|
70405
|
+
return await this.client.base.extPhoenixProgram.methods.setPhoenixPolicy(policyInput).accounts({
|
|
70406
|
+
glamState: this.client.base.statePda,
|
|
70407
|
+
glamSigner: signer || this.client.base.signer
|
|
70408
|
+
}).instruction();
|
|
70409
|
+
}
|
|
70410
|
+
async registerTraderIx(params, accounts = {}, signer) {
|
|
70411
|
+
return await this.client.base.extPhoenixProgram.methods.registerTrader(params).accountsPartial({
|
|
70412
|
+
...this.getPhoenixCpiAccounts(signer),
|
|
70413
|
+
logAuthority: accounts.logAuthority || PHOENIX_LOG_AUTHORITY,
|
|
70414
|
+
globalConfig: accounts.globalConfig || PHOENIX_GLOBAL_CONFIG,
|
|
70415
|
+
traderAccount: accounts.traderAccount || this.client.getTraderPda(params.traderPdaIndex, params.traderSubaccountIndex)
|
|
70416
|
+
}).instruction();
|
|
70417
|
+
}
|
|
70418
|
+
async updateTraderStateIx(accounts, signer) {
|
|
70419
|
+
return await this.client.base.extPhoenixProgram.methods.updateTraderState().accounts(this.getPhoenixCpiAccounts(signer)).remainingAccounts(accounts.remainingAccounts).instruction();
|
|
70420
|
+
}
|
|
70421
|
+
async emberDepositIx(params, accounts, signer) {
|
|
70422
|
+
return await this.client.base.extPhoenixProgram.methods.deposit(params).accounts(this.getEmberCpiAccounts(accounts, signer)).instruction();
|
|
70423
|
+
}
|
|
70424
|
+
async depositFundsIx(params, accounts, signer) {
|
|
70425
|
+
return await this.client.base.extPhoenixProgram.methods.depositFunds(params).accounts(this.getPhoenixCpiAccounts(signer)).remainingAccounts(accounts.remainingAccounts).instruction();
|
|
70426
|
+
}
|
|
70427
|
+
async emberWithdrawIx(params, accounts, signer) {
|
|
70428
|
+
return await this.client.base.extPhoenixProgram.methods.withdraw(params).accounts(this.getEmberCpiAccounts(accounts, signer)).instruction();
|
|
70429
|
+
}
|
|
70430
|
+
async withdrawFundsIx(params, accounts, signer) {
|
|
70431
|
+
return await this.client.base.extPhoenixProgram.methods.withdrawFunds(params).accounts(this.getPhoenixCpiAccounts(signer)).remainingAccounts(accounts.remainingAccounts).instruction();
|
|
70432
|
+
}
|
|
70433
|
+
async placeLimitOrderIx(packet, accounts, signer) {
|
|
70434
|
+
return await this.client.base.extPhoenixProgram.methods.placeLimitOrder(packet).accounts(this.getPhoenixCpiAccounts(signer)).remainingAccounts(accounts.remainingAccounts).instruction();
|
|
70435
|
+
}
|
|
70436
|
+
async placeMarketOrderIx(packet, accounts, signer) {
|
|
70437
|
+
return await this.client.base.extPhoenixProgram.methods.placeMarketOrder(packet).accounts(this.getPhoenixCpiAccounts(signer)).remainingAccounts(accounts.remainingAccounts).instruction();
|
|
70438
|
+
}
|
|
70439
|
+
async placePostOnlyOrderIx(packet, accounts, signer) {
|
|
70440
|
+
return await this.client.base.extPhoenixProgram.methods.placePostOnlyOrder(packet).accounts(this.getPhoenixCpiAccounts(signer)).remainingAccounts(accounts.remainingAccounts).instruction();
|
|
70441
|
+
}
|
|
70442
|
+
async cancelAllIx(accounts, signer) {
|
|
70443
|
+
return await this.client.base.extPhoenixProgram.methods.cancelAll().accounts(this.getPhoenixCpiAccounts(signer)).remainingAccounts(accounts.remainingAccounts).instruction();
|
|
70444
|
+
}
|
|
70445
|
+
async cancelOrdersByIdIx(orderIds, accounts, signer) {
|
|
70446
|
+
return await this.client.base.extPhoenixProgram.methods.cancelOrdersById(orderIds).accounts(this.getPhoenixCpiAccounts(signer)).remainingAccounts(accounts.remainingAccounts).instruction();
|
|
70447
|
+
}
|
|
70448
|
+
async cancelUpToIx(args, accounts, signer) {
|
|
70449
|
+
return await this.client.base.extPhoenixProgram.methods.cancelUpTo(args).accounts(this.getPhoenixCpiAccounts(signer)).remainingAccounts(accounts.remainingAccounts).instruction();
|
|
70450
|
+
}
|
|
70451
|
+
async setPolicyTx(policy, txOptions = {}) {
|
|
70452
|
+
const ix = await this.setPolicyIx(policy, txOptions.signer);
|
|
70453
|
+
return await this.buildVersionedTx([
|
|
70454
|
+
ix
|
|
70455
|
+
], txOptions);
|
|
70456
|
+
}
|
|
70457
|
+
async registerTraderTx(params, accounts = {}, txOptions = {}) {
|
|
70458
|
+
const ix = await this.registerTraderIx(params, accounts, txOptions.signer);
|
|
70459
|
+
return await this.buildVersionedTx([
|
|
70460
|
+
ix
|
|
70461
|
+
], txOptions);
|
|
70462
|
+
}
|
|
70463
|
+
async updateTraderStateTx(accounts, txOptions = {}) {
|
|
70464
|
+
const ix = await this.updateTraderStateIx(accounts, txOptions.signer);
|
|
70465
|
+
return await this.buildVersionedTx([
|
|
70466
|
+
ix
|
|
70467
|
+
], txOptions);
|
|
70468
|
+
}
|
|
70469
|
+
/**
|
|
70470
|
+
* Remaining-accounts list for `deposit_funds` — the vault token account
|
|
70471
|
+
* holding the canonical collateral, the trader PDA, Phoenix's global vault
|
|
70472
|
+
* for that mint, the SPL token program, and the trader-index/active-buffer
|
|
70473
|
+
* chunks from the snapshot.
|
|
70474
|
+
*/ getDepositRemainingAccounts(snapshot, indexes = {}) {
|
|
70475
|
+
const mint = new PublicKey(snapshot.exchange.canonicalMint);
|
|
70476
|
+
const vaultAta = this.client.base.getVaultAta(mint);
|
|
70477
|
+
return [
|
|
70478
|
+
...this.client.getPhoenixRemainingPrefix(true),
|
|
70479
|
+
meta(this.client.base.vaultPda, true),
|
|
70480
|
+
meta(vaultAta, true),
|
|
70481
|
+
meta(this.client.getTraderPda(indexes.traderPdaIndex, indexes.subaccountIndex), true),
|
|
70482
|
+
meta(this.client.getGlobalVaultPda(mint), true),
|
|
70483
|
+
meta(TOKEN_PROGRAM_ID, false),
|
|
70484
|
+
...snapshot.exchange.globalTraderIndex.map((key)=>meta(key, true)),
|
|
70485
|
+
...snapshot.exchange.activeTraderBuffer.map((key)=>meta(key, true))
|
|
70486
|
+
];
|
|
70487
|
+
}
|
|
70488
|
+
/**
|
|
70489
|
+
* Remaining-accounts list for `withdraw_funds`. Same shape as the deposit
|
|
70490
|
+
* variant plus the perp asset map and the global withdraw queue, which the
|
|
70491
|
+
* withdraw path mutates.
|
|
70492
|
+
*/ getWithdrawRemainingAccounts(snapshot, indexes = {}) {
|
|
70493
|
+
const mint = new PublicKey(snapshot.exchange.canonicalMint);
|
|
70494
|
+
const vaultAta = this.client.base.getVaultAta(mint);
|
|
70495
|
+
return [
|
|
70496
|
+
...this.client.getPhoenixRemainingPrefix(true),
|
|
70497
|
+
meta(this.client.base.vaultPda, true),
|
|
70498
|
+
meta(this.client.getTraderPda(indexes.traderPdaIndex, indexes.subaccountIndex), true),
|
|
70499
|
+
meta(snapshot.exchange.perpAssetMap, true),
|
|
70500
|
+
meta(this.client.getGlobalVaultPda(mint), true),
|
|
70501
|
+
meta(vaultAta, true),
|
|
70502
|
+
meta(TOKEN_PROGRAM_ID, false),
|
|
70503
|
+
...snapshot.exchange.globalTraderIndex.map((key)=>meta(key, true)),
|
|
70504
|
+
...snapshot.exchange.activeTraderBuffer.map((key)=>meta(key, true)),
|
|
70505
|
+
meta(snapshot.exchange.withdrawQueue, true)
|
|
70506
|
+
];
|
|
70507
|
+
}
|
|
70508
|
+
async deposit(amount, txOptions = {}) {
|
|
70509
|
+
const snapshot = await this.client.phoenixApi.fetchPhoenixSnapshot();
|
|
70510
|
+
const usdcMint = new PublicKey(snapshot.exchange.usdcMint);
|
|
70511
|
+
const canonicalMint = new PublicKey(snapshot.exchange.canonicalMint);
|
|
70512
|
+
const ixs = [
|
|
70513
|
+
// create canonical token ata
|
|
70514
|
+
createAssociatedTokenAccountIdempotentInstruction(txOptions.signer || this.client.base.signer, this.client.base.getVaultAta(canonicalMint), this.client.base.vaultPda, canonicalMint),
|
|
70515
|
+
await this.emberDepositIx({
|
|
70516
|
+
amount
|
|
70517
|
+
}, {
|
|
70518
|
+
inputMint: usdcMint,
|
|
70519
|
+
outputMint: canonicalMint
|
|
70520
|
+
}, txOptions.signer),
|
|
70521
|
+
await this.depositFundsIx({
|
|
70522
|
+
amount
|
|
70523
|
+
}, {
|
|
70524
|
+
remainingAccounts: this.getDepositRemainingAccounts(snapshot)
|
|
70525
|
+
}, txOptions.signer)
|
|
70526
|
+
];
|
|
70527
|
+
return await this.buildVersionedTx(ixs, txOptions);
|
|
70528
|
+
}
|
|
70529
|
+
async withdraw(amount, txOptions = {}) {
|
|
70530
|
+
const snapshot = await this.client.phoenixApi.fetchPhoenixSnapshot();
|
|
70531
|
+
const usdcMint = new PublicKey(snapshot.exchange.usdcMint);
|
|
70532
|
+
const canonicalMint = new PublicKey(snapshot.exchange.canonicalMint);
|
|
70533
|
+
const ixs = [
|
|
70534
|
+
// create USDC ata
|
|
70535
|
+
createAssociatedTokenAccountIdempotentInstruction(txOptions.signer || this.client.base.signer, this.client.base.getVaultAta(usdcMint), this.client.base.vaultPda, usdcMint),
|
|
70536
|
+
await this.withdrawFundsIx({
|
|
70537
|
+
amount
|
|
70538
|
+
}, {
|
|
70539
|
+
remainingAccounts: this.getWithdrawRemainingAccounts(snapshot)
|
|
70540
|
+
}, txOptions.signer),
|
|
70541
|
+
await this.emberWithdrawIx({
|
|
70542
|
+
amount
|
|
70543
|
+
}, {
|
|
70544
|
+
inputMint: usdcMint,
|
|
70545
|
+
outputMint: canonicalMint
|
|
70546
|
+
}, txOptions.signer)
|
|
70547
|
+
];
|
|
70548
|
+
return await this.buildVersionedTx(ixs, txOptions);
|
|
70549
|
+
}
|
|
70550
|
+
async depositFundsTx(params, accounts, txOptions = {}) {
|
|
70551
|
+
const ix = await this.depositFundsIx(params, accounts, txOptions.signer);
|
|
70552
|
+
return await this.buildVersionedTx([
|
|
70553
|
+
ix
|
|
70554
|
+
], txOptions);
|
|
70555
|
+
}
|
|
70556
|
+
async withdrawFundsTx(params, accounts, txOptions = {}) {
|
|
70557
|
+
const ix = await this.withdrawFundsIx(params, accounts, txOptions.signer);
|
|
70558
|
+
return await this.buildVersionedTx([
|
|
70559
|
+
ix
|
|
70560
|
+
], txOptions);
|
|
70561
|
+
}
|
|
70562
|
+
async placeLimitOrderTx(packet, accounts, txOptions = {}) {
|
|
70563
|
+
const ix = await this.placeLimitOrderIx(packet, accounts, txOptions.signer);
|
|
70564
|
+
return await this.buildVersionedTx([
|
|
70565
|
+
ix
|
|
70566
|
+
], txOptions);
|
|
70567
|
+
}
|
|
70568
|
+
async placeMarketOrderTx(packet, accounts, txOptions = {}) {
|
|
70569
|
+
const ix = await this.placeMarketOrderIx(packet, accounts, txOptions.signer);
|
|
70570
|
+
return await this.buildVersionedTx([
|
|
70571
|
+
ix
|
|
70572
|
+
], txOptions);
|
|
70573
|
+
}
|
|
70574
|
+
async placePostOnlyOrderTx(packet, accounts, txOptions = {}) {
|
|
70575
|
+
const ix = await this.placePostOnlyOrderIx(packet, accounts, txOptions.signer);
|
|
70576
|
+
return await this.buildVersionedTx([
|
|
70577
|
+
ix
|
|
70578
|
+
], txOptions);
|
|
70579
|
+
}
|
|
70580
|
+
async cancelAllTx(accounts, txOptions = {}) {
|
|
70581
|
+
const ix = await this.cancelAllIx(accounts, txOptions.signer);
|
|
70582
|
+
return await this.buildVersionedTx([
|
|
70583
|
+
ix
|
|
70584
|
+
], txOptions);
|
|
70585
|
+
}
|
|
70586
|
+
async cancelOrdersByIdTx(orderIds, accounts, txOptions = {}) {
|
|
70587
|
+
const ix = await this.cancelOrdersByIdIx(orderIds, accounts, txOptions.signer);
|
|
70588
|
+
return await this.buildVersionedTx([
|
|
70589
|
+
ix
|
|
70590
|
+
], txOptions);
|
|
70591
|
+
}
|
|
70592
|
+
async cancelUpToTx(args, accounts, txOptions = {}) {
|
|
70593
|
+
const ix = await this.cancelUpToIx(args, accounts, txOptions.signer);
|
|
70594
|
+
return await this.buildVersionedTx([
|
|
70595
|
+
ix
|
|
70596
|
+
], txOptions);
|
|
70597
|
+
}
|
|
70598
|
+
};
|
|
70599
|
+
class PhoenixClient {
|
|
70600
|
+
/** The ext_phoenix program id this client talks to. */ get programId() {
|
|
70601
|
+
return this.base.extPhoenixProgram.programId;
|
|
70602
|
+
}
|
|
70603
|
+
/** Bit flag identifying Phoenix inside the GLAM integration ACL bitmask. */ get protocolBitflag() {
|
|
70604
|
+
return PHOENIX_PROTOCOL;
|
|
70605
|
+
}
|
|
70606
|
+
/** PDA the ext_phoenix program signs CPIs with into Phoenix and Ember. */ getIntegrationAuthorityPda() {
|
|
70607
|
+
return getIntegrationAuthorityPda(this.base.extPhoenixProgram.programId);
|
|
70608
|
+
}
|
|
70609
|
+
/**
|
|
70610
|
+
* PDA of a Phoenix trader account owned by the GLAM vault (defaults to the
|
|
70611
|
+
* vault PDA as authority). `traderPdaIndex` selects the parent trader and
|
|
70612
|
+
* `subaccountIndex` selects a child subaccount under that parent.
|
|
70613
|
+
*/ getTraderPda(traderPdaIndex = 0, subaccountIndex = 0, authority = this.base.vaultPda) {
|
|
70614
|
+
return getPhoenixTraderPda(authority, traderPdaIndex, subaccountIndex);
|
|
70615
|
+
}
|
|
70616
|
+
/** PDA of the spline-collection account associated with a Phoenix market. */ getSplineCollectionPda(market) {
|
|
70617
|
+
return getPhoenixSplineCollectionPda(market);
|
|
70618
|
+
}
|
|
70619
|
+
/** PDA of Phoenix's global-vault token account for a given mint. */ getGlobalVaultPda(mint) {
|
|
70620
|
+
return getPhoenixGlobalVaultPda(mint);
|
|
70621
|
+
}
|
|
70622
|
+
/** PDA of the Ember exchange-state account that backs Phoenix conversions. */ getEmberStatePda() {
|
|
70623
|
+
return getEmberStatePda();
|
|
70624
|
+
}
|
|
70625
|
+
/** PDA of Ember's USDC vault that mints/burns canonical collateral. */ getEmberVaultPda() {
|
|
70626
|
+
return getEmberVaultPda();
|
|
70627
|
+
}
|
|
70628
|
+
/**
|
|
70629
|
+
* The three accounts every Phoenix CPI begins with (program, log authority,
|
|
70630
|
+
* global config). `globalConfigWritable` toggles the writable flag on the
|
|
70631
|
+
* global config — set true for instructions that mutate exchange state.
|
|
70632
|
+
*/ getPhoenixRemainingPrefix(globalConfigWritable) {
|
|
70633
|
+
return [
|
|
70634
|
+
meta(PHOENIX_PROGRAM_ID, false),
|
|
70635
|
+
meta(PHOENIX_LOG_AUTHORITY, false),
|
|
70636
|
+
meta(PHOENIX_GLOBAL_CONFIG, globalConfigWritable)
|
|
70637
|
+
];
|
|
70638
|
+
}
|
|
70639
|
+
/**
|
|
70640
|
+
* Remaining-accounts list for place/cancel/order-book CPIs against a single
|
|
70641
|
+
* Phoenix market. Includes the trader PDA, perp asset map, trader indices,
|
|
70642
|
+
* the market itself, and its spline collection.
|
|
70643
|
+
*/ getMarketRemainingAccounts(snapshot, market, indexes = {}) {
|
|
70644
|
+
const marketPubkey = new PublicKey(market);
|
|
70645
|
+
return [
|
|
70646
|
+
...this.getPhoenixRemainingPrefix(true),
|
|
70647
|
+
meta(this.base.vaultPda, true),
|
|
70648
|
+
meta(this.getTraderPda(indexes.traderPdaIndex, indexes.subaccountIndex), true),
|
|
70649
|
+
meta(snapshot.exchange.perpAssetMap, true),
|
|
70650
|
+
...snapshot.exchange.globalTraderIndex.map((key)=>meta(key, true)),
|
|
70651
|
+
...snapshot.exchange.activeTraderBuffer.map((key)=>meta(key, true)),
|
|
70652
|
+
meta(marketPubkey, true),
|
|
70653
|
+
meta(this.getSplineCollectionPda(marketPubkey), true)
|
|
70654
|
+
];
|
|
70655
|
+
}
|
|
70656
|
+
/**
|
|
70657
|
+
* Remaining-accounts list for `update_trader_state` — settles funding for
|
|
70658
|
+
* the trader and may evict it from the active-trader buffer once it no
|
|
70659
|
+
* longer holds resting orders.
|
|
70660
|
+
*/ getUpdateTraderStateRemainingAccounts(snapshot, indexes = {}) {
|
|
70661
|
+
return [
|
|
70662
|
+
...this.getPhoenixRemainingPrefix(false),
|
|
70663
|
+
meta(this.getTraderPda(indexes.traderPdaIndex, indexes.subaccountIndex), true),
|
|
70664
|
+
meta(snapshot.exchange.perpAssetMap, false),
|
|
70665
|
+
...snapshot.exchange.globalTraderIndex.map((key)=>meta(key, true)),
|
|
70666
|
+
...snapshot.exchange.activeTraderBuffer.map((key)=>meta(key, true))
|
|
70667
|
+
];
|
|
70668
|
+
}
|
|
70669
|
+
/** Fetches the on-chain PhoenixPolicy stored under this vault, if any. */ async fetchPolicy() {
|
|
70670
|
+
return await this.base.fetchProtocolPolicy(this.programId, PHOENIX_PROTOCOL, PhoenixPolicy);
|
|
70671
|
+
}
|
|
70672
|
+
/** Writes the PhoenixPolicy (market allowlist, order types, etc.). */ async setPolicy(policy, txOptions = {}) {
|
|
70673
|
+
const tx = await this.txBuilder.setPolicyTx(policy, txOptions);
|
|
70674
|
+
return await this.base.sendAndConfirm(tx);
|
|
70675
|
+
}
|
|
70676
|
+
/**
|
|
70677
|
+
* Creates a Phoenix trader account for the vault (parent or child subaccount)
|
|
70678
|
+
* sized to hold `maxPositions`.
|
|
70679
|
+
*/ async registerTrader(params, accounts = {}, txOptions = {}) {
|
|
70680
|
+
const tx = await this.txBuilder.registerTraderTx(params, accounts, txOptions);
|
|
70681
|
+
return await this.base.sendAndConfirm(tx);
|
|
70682
|
+
}
|
|
70683
|
+
/**
|
|
70684
|
+
* Settles funding for the vault's trader and may evict it from the active
|
|
70685
|
+
* buffer when no resting orders remain. Idempotent housekeeping call.
|
|
70686
|
+
*/ async updateTraderState(accounts, txOptions = {}) {
|
|
70687
|
+
const tx = await this.txBuilder.updateTraderStateTx(accounts, txOptions);
|
|
70688
|
+
return await this.base.sendAndConfirm(tx);
|
|
70689
|
+
}
|
|
70690
|
+
/**
|
|
70691
|
+
* Full deposit flow in one transaction: converts USDC to canonical
|
|
70692
|
+
* collateral via Ember, then deposits the canonical amount into the vault's
|
|
70693
|
+
* Phoenix trader account.
|
|
70694
|
+
*/ async deposit(amount, txOptions = {}) {
|
|
70695
|
+
const tx = await this.txBuilder.deposit(new BN(amount), txOptions);
|
|
70696
|
+
return await this.base.sendAndConfirm(tx);
|
|
70697
|
+
}
|
|
70698
|
+
/**
|
|
70699
|
+
* Full withdraw flow in one transaction: withdraws canonical collateral
|
|
70700
|
+
* from Phoenix and converts it back to USDC via Ember.
|
|
70701
|
+
*/ async withdraw(amount, txOptions = {}) {
|
|
70702
|
+
const tx = await this.txBuilder.withdraw(new BN(amount), txOptions);
|
|
70703
|
+
return await this.base.sendAndConfirm(tx);
|
|
70704
|
+
}
|
|
70705
|
+
/**
|
|
70706
|
+
* Phoenix-only `deposit_funds` (no Ember leg) — moves an already-canonical
|
|
70707
|
+
* token balance from the vault's token account into Phoenix.
|
|
70708
|
+
*/ async depositFunds(params, accounts, txOptions = {}) {
|
|
70709
|
+
const tx = await this.txBuilder.depositFundsTx(params, accounts, txOptions);
|
|
70710
|
+
return await this.base.sendAndConfirm(tx);
|
|
70711
|
+
}
|
|
70712
|
+
/**
|
|
70713
|
+
* Phoenix-only `withdraw_funds` (no Ember leg) — pulls canonical collateral
|
|
70714
|
+
* out of Phoenix back to the vault's token account.
|
|
70715
|
+
*/ async withdrawFunds(params, accounts, txOptions = {}) {
|
|
70716
|
+
const tx = await this.txBuilder.withdrawFundsTx(params, accounts, txOptions);
|
|
70717
|
+
return await this.base.sendAndConfirm(tx);
|
|
70718
|
+
}
|
|
70719
|
+
/** Places a Phoenix limit order against the market in `accounts`. */ async placeLimitOrder(packet, accounts, txOptions = {}) {
|
|
70720
|
+
const tx = await this.txBuilder.placeLimitOrderTx(packet, accounts, txOptions);
|
|
70721
|
+
return await this.base.sendAndConfirm(tx);
|
|
70722
|
+
}
|
|
70723
|
+
/** Places an immediate-or-cancel market order against the market. */ async placeMarketOrder(packet, accounts, txOptions = {}) {
|
|
70724
|
+
const tx = await this.txBuilder.placeMarketOrderTx(packet, accounts, txOptions);
|
|
70725
|
+
return await this.base.sendAndConfirm(tx);
|
|
70726
|
+
}
|
|
70727
|
+
/** Places a post-only (maker-only) order; rejected if it would cross. */ async placePostOnlyOrder(packet, accounts, txOptions = {}) {
|
|
70728
|
+
const tx = await this.txBuilder.placePostOnlyOrderTx(packet, accounts, txOptions);
|
|
70729
|
+
return await this.base.sendAndConfirm(tx);
|
|
70730
|
+
}
|
|
70731
|
+
/** Cancels all resting orders the vault has on the given market. */ async cancelAll(accounts, txOptions = {}) {
|
|
70732
|
+
const tx = await this.txBuilder.cancelAllTx(accounts, txOptions);
|
|
70733
|
+
return await this.base.sendAndConfirm(tx);
|
|
70734
|
+
}
|
|
70735
|
+
/** Cancels the specific resting orders identified by `orderIds`. */ async cancelOrdersById(orderIds, accounts, txOptions = {}) {
|
|
70736
|
+
const tx = await this.txBuilder.cancelOrdersByIdTx(orderIds, accounts, txOptions);
|
|
70737
|
+
return await this.base.sendAndConfirm(tx);
|
|
70738
|
+
}
|
|
70739
|
+
/**
|
|
70740
|
+
* Cancels up to `num_orders_to_cancel` resting orders on a side, optionally
|
|
70741
|
+
* bounded by a price tick limit.
|
|
70742
|
+
*/ async cancelUpTo(args, accounts, txOptions = {}) {
|
|
70743
|
+
const tx = await this.txBuilder.cancelUpToTx(args, accounts, txOptions);
|
|
70744
|
+
return await this.base.sendAndConfirm(tx);
|
|
70745
|
+
}
|
|
69990
70746
|
constructor(base){
|
|
69991
70747
|
this.base = base;
|
|
69992
70748
|
this.txBuilder = new TxBuilder(this);
|
|
70749
|
+
this.phoenixApi = new PhoenixApiClient();
|
|
69993
70750
|
}
|
|
69994
70751
|
}
|
|
69995
70752
|
|
|
@@ -70112,9 +70869,15 @@ class LoopscaleClient {
|
|
|
70112
70869
|
}
|
|
70113
70870
|
return this._loopscale;
|
|
70114
70871
|
}
|
|
70872
|
+
get phoenix() {
|
|
70873
|
+
if (!this._phoenix) {
|
|
70874
|
+
this._phoenix = new PhoenixClient(this);
|
|
70875
|
+
}
|
|
70876
|
+
return this._phoenix;
|
|
70877
|
+
}
|
|
70115
70878
|
constructor(config){
|
|
70116
70879
|
super(config);
|
|
70117
70880
|
}
|
|
70118
70881
|
}
|
|
70119
70882
|
|
|
70120
|
-
export { ALT_PROGRAM_ID, ASSETS_MAINNET, BaseClient, BaseTxBuilder, BlockhashWithCache, BridgeClient, CCTP_DOMAIN_MAPPING, CctpBridgeEvent, CctpClient, CctpPolicy, ClusterNetwork, CreatedModel, DelegateAcl, EMBER_PROGRAM_ID,
|
|
70883
|
+
export { ALT_PROGRAM_ID, ASSETS_MAINNET, BaseClient, BaseTxBuilder, BlockhashWithCache, BridgeClient, CCTP_DOMAIN_MAPPING, CctpBridgeEvent, CctpClient, CctpPolicy, ClusterNetwork, CreatedModel, DEFAULT_PHOENIX_API_URL, DelegateAcl, EMBER_PROGRAM_ID, EmergencyAccessUpdateArgs, EmergencyUpdateMintArgs, EpiClient, Fraction, GLAM_CONFIG_PROGRAM, GLAM_REFERRER, GlamClient, GlamError, GlobalConfig, Holding, IntegrationAcl, IntegrationPermissions, JITO_TIP_DEFAULT, JUP, JUPITER_API_DEFAULT, JUPITER_PROGRAM_ID, JupTokenList, JupiterApiClient, JupiterSwapClient, JupiterSwapPolicy, KAMINO_FARM_PROGRAM, KAMINO_LENDING_PROGRAM, KAMINO_OBTRIGATION_SIZE, KAMINO_RESERVE_SIZE, KAMINO_VAULTS_PROGRAM, KAMINO_VAULT_STATE_SIZE, KaminoLendingPolicy, KaminoVaultsPolicy, LAYERZERO_OFT_PROTOCOL, LOOPSCALE_BS_AUTH, LOOPSCALE_PROGRAM_ID, LayerzeroOftPolicy, LoopscaleClient, LoopscalePolicy, MARINADE_NATIVE_STAKE_AUTHORITY, MARINADE_PROGRAM_ID, MEMO_PROGRAM, MESSAGE_TRANSMITTER_V2, METEORA_POSITION_SIZE, MSOL, MintIdlModel, MintModel, MintPolicy, PHOENIX_GLOBAL_CONFIG, PHOENIX_LOG_AUTHORITY, PHOENIX_ORDER_PACKET_KIND_IMMEDIATE_OR_CANCEL, PHOENIX_ORDER_PACKET_KIND_LIMIT, PHOENIX_ORDER_PACKET_KIND_POST_ONLY, PHOENIX_PROGRAM_ID, PHOENIX_PROTOCOL, PHOENIX_WITHDRAW_QUEUE, PeriodType, PhoenixApiClient, PhoenixClient, PhoenixPolicy, PkMap, PkSet, PositionCategorizer, PriceClient, PriceDenom, ProtocolPermissions, ProtocolPolicy, RequestType, RouteManagementMode, SANCTUM_STAKE_POOL_PROGRAM_ID, SEED_ACCOUNT_POLICY, SEED_BRIDGE_REGISTRY, SEED_BRIDGE_SESSION, SEED_BRIDGE_TRANSFER_RECORD, SEED_ESCROW, SEED_EXTRA_ACCOUNT_METAS, SEED_GLOBAL_CONFIG, SEED_INTEGRATION_AUTHORITY, SEED_METADATA, SEED_MINT, SEED_OBSERVATION_STATE, SEED_REQUEST_QUEUE, SEED_STATE, SEED_VAULT, STAKE_ACCOUNT_SIZE, STAKE_POOLS, STAKE_POOLS_MAP, StateAccountType, StateIdlModel, StateModel, TOKEN_ACL_GATE_PROGRAM, TOKEN_ACL_PROGRAM, TOKEN_MESSENGER_MINTER_V2, TRANSFER_HOOK_PROGRAM, TimeUnit, TimelockClient, TokenAclListConfig, TokenAclMintConfig, TokenAclWalletEntry, TransferPolicy, TransferRateLimitPolicy, USDC, USDC_DEVNET, USDT, VaultHoldings, VoteAuthorize, WSOL, bfToDecimal, buildComputeBudgetInstructions, buildCreateAltInstructions, buildExtendAltInstructions, bytesToHex, charsToName, charsToString, collectVaultLookupTableAddresses, compareDelegateAcls, compareIntegrationAcls, comparePublicKeyArrays, deriveLayerzeroNoncePda, deriveOftAuxiliaryAccount, deriveOftAuxiliaryAccountSeed, evmAddressToBytes32, evmAddressToPublicKey, extractFailedProgramId, fetchAddressLookupTableAccounts, fetchGlobalConfig, fetchMintAndTokenProgram, fetchMintsAndTokenPrograms, fetchOnchainAssetMetas, findGlamLookupTables, findStakeAccounts, formatBits, fromUiAmount, getAccountPolicyPda, getActiveRegistryTransfers, getAsset, getEmberStatePda, getEmberVaultPda, getEscrowPda, getExtBridgeIdl, getExtBridgeProgram, getExtBridgeProgramId, getExtCctpIdl, getExtCctpProgram, getExtCctpProgramId, getExtDriftProgramId, getExtEpiIdl, getExtEpiProgram, getExtEpiProgramId, getExtKaminoIdl, getExtKaminoProgram, getExtKaminoProgramId, getExtLoopscaleIdl, getExtLoopscaleProgram, getExtLoopscaleProgramId, getExtMarinadeIdl, getExtMarinadeProgram, getExtMarinadeProgramId, getExtPhoenixIdl, getExtPhoenixProgram, getExtPhoenixProgramId, getExtSplIdl, getExtSplProgram, getExtSplProgramId, getExtStakePoolIdl, getExtStakePoolProgram, getExtStakePoolProgramId, getExtraMetasPda, getGlamConfigProgram, getGlamMintIdl, getGlamMintProgram, getGlamMintProgramId, getGlamProtocolIdl, getGlamProtocolProgram, getGlamProtocolProgramId, getGlobalConfigPda, getHeliusApiKey, getHeliusRpcUrl, getIntegrationAuthorityPda, getLoopscaleEventAuthorityPda, getLoopscaleLoanPda, getMintPda, getOracleName, getPermissionNamesFromBitmask, getPhoenixGlobalVaultPda, getPhoenixSplineCollectionPda, getPhoenixTraderPda, getPriorityFeeEstimate, getProgramAccounts, getProgramAccountsWithRetry, getProgramAndBitflagByProtocolName, getProtocolNameByProgramAndBitflag, getProtocolNamesFromBitmask, getProtocolsAndPermissions, getRequestQueuePda, getSimulationResult, getSolAndTokenBalances, getStakeAccountsWithStates, getStatePda, getTokenAccountsByMint, getTokenAccountsByMintResult, getTokenAccountsByOwner, getTokenAclFlagAccountPda, getTokenAclGateExtraMetasPda, getTokenAclGateListConfigPda, getTokenAclGateWalletEntryPda, getTokenAclMintConfigPda, getTransactionsForAddress, getVaultPda, heliusFetch, heliusGetProgramAccountsV2, heliusGetTransactionsForAddress, hexToBytes, isHeliusRpc, isTokenAclEnabled, isValidEvmAddress, nameToChars, normalizePhoenixApiUrl, parseMintAccountInfo, parsePermissionNames, parseProgramLogs, parseProtocolPermissionsBitmask, parseProtocolsBitmask, parseTxError, publicKeyToEvmAddress, resolveErrorCode, resolveStaging, resolveStateAclsStaging, sha256First8Bytes, stringToChars, toBnAmount, toUiAmount };
|