@elmntl/jlpd-sdk 0.1.9 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1043 -539
- package/dist/index.d.ts +1043 -539
- package/dist/index.js +1057 -417
- package/dist/index.mjs +1049 -416
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -28,10 +28,12 @@ __export(index_exports, {
|
|
|
28
28
|
FLAG_REBALANCE_DISABLED: () => FLAG_REBALANCE_DISABLED,
|
|
29
29
|
FLAG_WITHDRAWALS_DISABLED: () => FLAG_WITHDRAWALS_DISABLED,
|
|
30
30
|
JLPD_PROGRAM_ID: () => JLPD_PROGRAM_ID,
|
|
31
|
+
JLP_POOL_PUBKEY: () => JLP_POOL_PUBKEY,
|
|
31
32
|
JLP_VAULT_ACCOUNT_SIZE: () => JLP_VAULT_ACCOUNT_SIZE,
|
|
32
33
|
JLP_VAULT_DATA_SIZE: () => JLP_VAULT_DATA_SIZE,
|
|
33
34
|
JLP_VAULT_DISCRIMINATOR: () => JLP_VAULT_DISCRIMINATOR,
|
|
34
35
|
JUPITER_LEND_PROGRAM_ID: () => JUPITER_LEND_PROGRAM_ID,
|
|
36
|
+
JUPITER_PERPS_PROGRAM_ID: () => JUPITER_PERPS_PROGRAM_ID,
|
|
35
37
|
JUPITER_SWAP_PROGRAM_ID: () => JUPITER_SWAP_PROGRAM_ID,
|
|
36
38
|
JUPUSD_POOL: () => JUPUSD_POOL,
|
|
37
39
|
JUP_LEND_PROGRAM_ID: () => JUPITER_LEND_PROGRAM_ID2,
|
|
@@ -47,6 +49,7 @@ __export(index_exports, {
|
|
|
47
49
|
PoolContext: () => PoolContext,
|
|
48
50
|
SEED_JLP_VAULT: () => SEED_JLP_VAULT,
|
|
49
51
|
SEED_STV: () => SEED_STV,
|
|
52
|
+
SEED_WITHDRAW_REQUEST: () => SEED_WITHDRAW_REQUEST,
|
|
50
53
|
STV_ACCOUNT_SIZE: () => STV_ACCOUNT_SIZE,
|
|
51
54
|
STV_DATA_SIZE: () => STV_DATA_SIZE,
|
|
52
55
|
STV_DISCRIMINATOR: () => STV_DISCRIMINATOR,
|
|
@@ -55,6 +58,9 @@ __export(index_exports, {
|
|
|
55
58
|
USDC_POOL: () => USDC_POOL,
|
|
56
59
|
WBTC_POOL: () => WBTC_POOL,
|
|
57
60
|
WETH_POOL: () => WETH_POOL,
|
|
61
|
+
WITHDRAW_REQUEST_ACCOUNT_SIZE: () => WITHDRAW_REQUEST_ACCOUNT_SIZE,
|
|
62
|
+
WITHDRAW_REQUEST_DATA_SIZE: () => WITHDRAW_REQUEST_DATA_SIZE,
|
|
63
|
+
WITHDRAW_REQUEST_DISCRIMINATOR: () => WITHDRAW_REQUEST_DISCRIMINATOR,
|
|
58
64
|
WSOL_POOL: () => WSOL_POOL,
|
|
59
65
|
baseToJlx: () => baseToJlx,
|
|
60
66
|
baseToShares: () => baseToShares,
|
|
@@ -68,23 +74,25 @@ __export(index_exports, {
|
|
|
68
74
|
clearAtaCache: () => clearAtaCache,
|
|
69
75
|
clearPdaCache: () => clearPdaCache,
|
|
70
76
|
createClaimFeesInstruction: () => createClaimFeesInstruction,
|
|
77
|
+
createClaimWithdrawInstruction: () => createClaimWithdrawInstruction,
|
|
71
78
|
createDepositInstruction: () => createDepositInstruction,
|
|
72
79
|
createInitOrUpdateVaultInstruction: () => createInitOrUpdateVaultInstruction,
|
|
73
80
|
createInitializeStvInstruction: () => createInitializeStvInstruction,
|
|
74
81
|
createJupEarnInstruction: () => createJupEarnInstruction,
|
|
75
82
|
createMoveJlxInstruction: () => createMoveJlxInstruction,
|
|
83
|
+
createProcessEpochInstruction: () => createProcessEpochInstruction,
|
|
76
84
|
createProgram: () => createProgram,
|
|
85
|
+
createRequestWithdrawInstruction: () => createRequestWithdrawInstruction,
|
|
77
86
|
createSettleYieldInstruction: () => createSettleYieldInstruction,
|
|
78
87
|
createSwapJlxJlpInstruction: () => createSwapJlxJlpInstruction,
|
|
79
|
-
createSwapJlxJlxInstruction: () => createSwapJlxJlxInstruction,
|
|
80
88
|
createUpdateStvInstruction: () => createUpdateStvInstruction,
|
|
81
|
-
createWithdrawInstruction: () => createWithdrawInstruction,
|
|
82
89
|
deriveAta: () => deriveAta,
|
|
83
90
|
deriveStvAtas: () => deriveStvAtas,
|
|
84
91
|
deriveStvPda: () => deriveStvPda,
|
|
85
92
|
deriveUserAtas: () => deriveUserAtas,
|
|
86
93
|
deriveVaultAtas: () => deriveVaultAtas,
|
|
87
94
|
deriveVaultPda: () => deriveVaultPda,
|
|
95
|
+
deriveWithdrawRequestPda: () => deriveWithdrawRequestPda,
|
|
88
96
|
fetchAddressLookupTables: () => fetchAddressLookupTables,
|
|
89
97
|
fetchJlpRate: () => fetchJlpRate,
|
|
90
98
|
fetchJupiterPriceUsd: () => fetchJupiterPriceUsd,
|
|
@@ -98,6 +106,7 @@ __export(index_exports, {
|
|
|
98
106
|
parseStv: () => parseStv,
|
|
99
107
|
parseSwapRemainingAccounts: () => parseSwapRemainingAccounts,
|
|
100
108
|
parseVault: () => parseVault,
|
|
109
|
+
parseWithdrawRequest: () => parseWithdrawRequest,
|
|
101
110
|
sharesToBase: () => sharesToBase
|
|
102
111
|
});
|
|
103
112
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -204,66 +213,71 @@ var jlp_d_program_default = {
|
|
|
204
213
|
args: []
|
|
205
214
|
},
|
|
206
215
|
{
|
|
207
|
-
name: "
|
|
216
|
+
name: "claim_withdraw",
|
|
208
217
|
docs: [
|
|
209
|
-
"
|
|
210
|
-
"Destructive operation - use only for cleanup/migration",
|
|
218
|
+
"Claim processed withdrawal (epoch-based delayed withdrawal)",
|
|
211
219
|
"",
|
|
212
|
-
"#
|
|
213
|
-
"
|
|
214
|
-
"
|
|
215
|
-
"
|
|
220
|
+
"# Flow",
|
|
221
|
+
"1. Verify request is processed (pps > 0) and claim period reached",
|
|
222
|
+
"2. Transfer base from STV to user",
|
|
223
|
+
"3. Close request's jvX ATA and WithdrawRequest PDA (rent to user)"
|
|
216
224
|
],
|
|
217
225
|
discriminator: [
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
+
232,
|
|
227
|
+
89,
|
|
228
|
+
154,
|
|
229
|
+
117,
|
|
230
|
+
16,
|
|
231
|
+
204,
|
|
232
|
+
182,
|
|
233
|
+
224
|
|
226
234
|
],
|
|
227
235
|
accounts: [
|
|
228
236
|
{
|
|
229
|
-
name: "
|
|
237
|
+
name: "user",
|
|
230
238
|
docs: [
|
|
231
|
-
"
|
|
239
|
+
"User claiming their withdrawal"
|
|
232
240
|
],
|
|
233
241
|
writable: true,
|
|
234
|
-
signer: true
|
|
235
|
-
|
|
236
|
-
|
|
242
|
+
signer: true
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
name: "stv",
|
|
246
|
+
docs: [
|
|
247
|
+
"The STV PDA account (mut for reserved_base update)"
|
|
248
|
+
],
|
|
249
|
+
writable: true
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
name: "base_mint",
|
|
253
|
+
docs: [
|
|
254
|
+
"Base asset mint (for transfer_checked)"
|
|
237
255
|
]
|
|
238
256
|
},
|
|
239
257
|
{
|
|
240
|
-
name: "
|
|
258
|
+
name: "jv_mint",
|
|
241
259
|
docs: [
|
|
242
|
-
"
|
|
260
|
+
"jvX mint (for ATA close verification)"
|
|
261
|
+
]
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
name: "user_base_ata",
|
|
265
|
+
docs: [
|
|
266
|
+
"User's base token destination"
|
|
243
267
|
],
|
|
244
|
-
|
|
245
|
-
seeds: [
|
|
246
|
-
{
|
|
247
|
-
kind: "const",
|
|
248
|
-
value: [
|
|
249
|
-
106,
|
|
250
|
-
108,
|
|
251
|
-
112,
|
|
252
|
-
95,
|
|
253
|
-
118,
|
|
254
|
-
97,
|
|
255
|
-
117,
|
|
256
|
-
108,
|
|
257
|
-
116
|
|
258
|
-
]
|
|
259
|
-
}
|
|
260
|
-
]
|
|
261
|
-
}
|
|
268
|
+
writable: true
|
|
262
269
|
},
|
|
263
270
|
{
|
|
264
|
-
name: "
|
|
271
|
+
name: "stv_base_ata",
|
|
272
|
+
docs: [
|
|
273
|
+
"STV's base ATA (source for base transfer)"
|
|
274
|
+
],
|
|
275
|
+
writable: true
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
name: "withdraw_request",
|
|
265
279
|
docs: [
|
|
266
|
-
"
|
|
280
|
+
"WithdrawRequest PDA - closed after claim (rent to user)"
|
|
267
281
|
],
|
|
268
282
|
writable: true,
|
|
269
283
|
pda: {
|
|
@@ -271,33 +285,49 @@ var jlp_d_program_default = {
|
|
|
271
285
|
{
|
|
272
286
|
kind: "const",
|
|
273
287
|
value: [
|
|
274
|
-
|
|
288
|
+
119,
|
|
289
|
+
105,
|
|
275
290
|
116,
|
|
276
|
-
|
|
291
|
+
104,
|
|
292
|
+
100,
|
|
293
|
+
114,
|
|
294
|
+
97,
|
|
295
|
+
119,
|
|
296
|
+
95,
|
|
297
|
+
114,
|
|
298
|
+
101,
|
|
299
|
+
113,
|
|
300
|
+
117,
|
|
301
|
+
101,
|
|
302
|
+
115,
|
|
303
|
+
116
|
|
277
304
|
]
|
|
278
305
|
},
|
|
279
306
|
{
|
|
280
307
|
kind: "account",
|
|
281
|
-
path: "
|
|
308
|
+
path: "stv"
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
kind: "account",
|
|
312
|
+
path: "user"
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
kind: "account",
|
|
316
|
+
path: "withdraw_request.epoch_id",
|
|
317
|
+
account: "WithdrawRequest"
|
|
282
318
|
}
|
|
283
319
|
]
|
|
284
320
|
}
|
|
285
321
|
},
|
|
286
322
|
{
|
|
287
|
-
name: "
|
|
323
|
+
name: "request_jvx_ata",
|
|
288
324
|
docs: [
|
|
289
|
-
"jvX
|
|
290
|
-
]
|
|
291
|
-
|
|
292
|
-
{
|
|
293
|
-
name: "base_mint",
|
|
294
|
-
docs: [
|
|
295
|
-
"Base asset mint for this STV"
|
|
296
|
-
]
|
|
325
|
+
"Empty jvX ATA owned by WithdrawRequest PDA (to close, rent to user)"
|
|
326
|
+
],
|
|
327
|
+
writable: true
|
|
297
328
|
},
|
|
298
329
|
{
|
|
299
|
-
name: "
|
|
300
|
-
address: "11111111111111111111111111111111"
|
|
330
|
+
name: "token_program"
|
|
301
331
|
}
|
|
302
332
|
],
|
|
303
333
|
args: []
|
|
@@ -559,7 +589,7 @@ var jlp_d_program_default = {
|
|
|
559
589
|
name: "jv_mint",
|
|
560
590
|
docs: [
|
|
561
591
|
"Vault share token mint (jvX) - STV is the mint authority",
|
|
562
|
-
"
|
|
592
|
+
"Uses init_if_needed in case mint exists from a previous STV initialization"
|
|
563
593
|
],
|
|
564
594
|
writable: true,
|
|
565
595
|
signer: true
|
|
@@ -891,6 +921,305 @@ var jlp_d_program_default = {
|
|
|
891
921
|
}
|
|
892
922
|
]
|
|
893
923
|
},
|
|
924
|
+
{
|
|
925
|
+
name: "process_epoch",
|
|
926
|
+
docs: [
|
|
927
|
+
"Process epoch: burn jvX from withdraw requests, record PPS, earmark base",
|
|
928
|
+
"",
|
|
929
|
+
"Permissionless (anyone can call after epoch ends).",
|
|
930
|
+
"Processes WithdrawRequest pairs from remaining_accounts.",
|
|
931
|
+
"Uses epoch_pps for multi-batch consistency.",
|
|
932
|
+
"",
|
|
933
|
+
"# Remaining Accounts",
|
|
934
|
+
"- [0-1]: Jupiter Lend accounts (if jl_mint != base_mint)",
|
|
935
|
+
"- [N..]: pairs of [WithdrawRequest (mut), request_jvx_ata (mut)]"
|
|
936
|
+
],
|
|
937
|
+
discriminator: [
|
|
938
|
+
115,
|
|
939
|
+
194,
|
|
940
|
+
215,
|
|
941
|
+
160,
|
|
942
|
+
113,
|
|
943
|
+
154,
|
|
944
|
+
81,
|
|
945
|
+
5
|
|
946
|
+
],
|
|
947
|
+
accounts: [
|
|
948
|
+
{
|
|
949
|
+
name: "payer",
|
|
950
|
+
docs: [
|
|
951
|
+
"Payer/caller - permissionless (anyone can call after epoch ends)"
|
|
952
|
+
],
|
|
953
|
+
writable: true,
|
|
954
|
+
signer: true
|
|
955
|
+
},
|
|
956
|
+
{
|
|
957
|
+
name: "jlp_vault",
|
|
958
|
+
docs: [
|
|
959
|
+
"The JLP Vault PDA account (for pause checks)"
|
|
960
|
+
]
|
|
961
|
+
},
|
|
962
|
+
{
|
|
963
|
+
name: "stv",
|
|
964
|
+
docs: [
|
|
965
|
+
"The STV PDA account (mut for epoch state + fee crystallization)"
|
|
966
|
+
],
|
|
967
|
+
writable: true
|
|
968
|
+
},
|
|
969
|
+
{
|
|
970
|
+
name: "base_mint",
|
|
971
|
+
docs: [
|
|
972
|
+
"Base asset mint (for NAV calc)"
|
|
973
|
+
]
|
|
974
|
+
},
|
|
975
|
+
{
|
|
976
|
+
name: "jl_mint",
|
|
977
|
+
docs: [
|
|
978
|
+
"jlX mint (for exchange rate)"
|
|
979
|
+
]
|
|
980
|
+
},
|
|
981
|
+
{
|
|
982
|
+
name: "jv_mint",
|
|
983
|
+
docs: [
|
|
984
|
+
"jvX mint (mut for burn - supply decreases)"
|
|
985
|
+
],
|
|
986
|
+
writable: true
|
|
987
|
+
},
|
|
988
|
+
{
|
|
989
|
+
name: "stv_base_ata",
|
|
990
|
+
docs: [
|
|
991
|
+
"STV's base ATA (for NAV)"
|
|
992
|
+
]
|
|
993
|
+
},
|
|
994
|
+
{
|
|
995
|
+
name: "stv_jlx_ata",
|
|
996
|
+
docs: [
|
|
997
|
+
"STV's jlX ATA (for NAV)"
|
|
998
|
+
]
|
|
999
|
+
},
|
|
1000
|
+
{
|
|
1001
|
+
name: "token_program"
|
|
1002
|
+
}
|
|
1003
|
+
],
|
|
1004
|
+
args: []
|
|
1005
|
+
},
|
|
1006
|
+
{
|
|
1007
|
+
name: "request_withdraw",
|
|
1008
|
+
docs: [
|
|
1009
|
+
"Request withdrawal of jvX shares (epoch-based delayed withdrawal)",
|
|
1010
|
+
"",
|
|
1011
|
+
"# Flow",
|
|
1012
|
+
"1. Validate epoch is active and not ended",
|
|
1013
|
+
"2. Create or accumulate into WithdrawRequest PDA for this epoch",
|
|
1014
|
+
"3. Transfer jvX from user to request's escrow ATA",
|
|
1015
|
+
"",
|
|
1016
|
+
"User must wait for process_epoch + claim_withdraw to receive base."
|
|
1017
|
+
],
|
|
1018
|
+
discriminator: [
|
|
1019
|
+
137,
|
|
1020
|
+
95,
|
|
1021
|
+
187,
|
|
1022
|
+
96,
|
|
1023
|
+
250,
|
|
1024
|
+
138,
|
|
1025
|
+
31,
|
|
1026
|
+
182
|
|
1027
|
+
],
|
|
1028
|
+
accounts: [
|
|
1029
|
+
{
|
|
1030
|
+
name: "user",
|
|
1031
|
+
docs: [
|
|
1032
|
+
"User requesting withdrawal"
|
|
1033
|
+
],
|
|
1034
|
+
writable: true,
|
|
1035
|
+
signer: true
|
|
1036
|
+
},
|
|
1037
|
+
{
|
|
1038
|
+
name: "jlp_vault",
|
|
1039
|
+
docs: [
|
|
1040
|
+
"The JLP Vault PDA account (for pause checks)"
|
|
1041
|
+
]
|
|
1042
|
+
},
|
|
1043
|
+
{
|
|
1044
|
+
name: "stv",
|
|
1045
|
+
docs: [
|
|
1046
|
+
"The STV PDA account (for epoch validation)"
|
|
1047
|
+
],
|
|
1048
|
+
writable: true
|
|
1049
|
+
},
|
|
1050
|
+
{
|
|
1051
|
+
name: "jv_mint",
|
|
1052
|
+
docs: [
|
|
1053
|
+
"jvX mint (vault share token)"
|
|
1054
|
+
]
|
|
1055
|
+
},
|
|
1056
|
+
{
|
|
1057
|
+
name: "user_jvx_ata",
|
|
1058
|
+
docs: [
|
|
1059
|
+
"User's jvX token account (source of shares)"
|
|
1060
|
+
],
|
|
1061
|
+
writable: true
|
|
1062
|
+
},
|
|
1063
|
+
{
|
|
1064
|
+
name: "withdraw_request",
|
|
1065
|
+
docs: [
|
|
1066
|
+
"WithdrawRequest PDA - created or accumulated into"
|
|
1067
|
+
],
|
|
1068
|
+
writable: true,
|
|
1069
|
+
pda: {
|
|
1070
|
+
seeds: [
|
|
1071
|
+
{
|
|
1072
|
+
kind: "const",
|
|
1073
|
+
value: [
|
|
1074
|
+
119,
|
|
1075
|
+
105,
|
|
1076
|
+
116,
|
|
1077
|
+
104,
|
|
1078
|
+
100,
|
|
1079
|
+
114,
|
|
1080
|
+
97,
|
|
1081
|
+
119,
|
|
1082
|
+
95,
|
|
1083
|
+
114,
|
|
1084
|
+
101,
|
|
1085
|
+
113,
|
|
1086
|
+
117,
|
|
1087
|
+
101,
|
|
1088
|
+
115,
|
|
1089
|
+
116
|
|
1090
|
+
]
|
|
1091
|
+
},
|
|
1092
|
+
{
|
|
1093
|
+
kind: "account",
|
|
1094
|
+
path: "stv"
|
|
1095
|
+
},
|
|
1096
|
+
{
|
|
1097
|
+
kind: "account",
|
|
1098
|
+
path: "user"
|
|
1099
|
+
},
|
|
1100
|
+
{
|
|
1101
|
+
kind: "arg",
|
|
1102
|
+
path: "epoch_id"
|
|
1103
|
+
}
|
|
1104
|
+
]
|
|
1105
|
+
}
|
|
1106
|
+
},
|
|
1107
|
+
{
|
|
1108
|
+
name: "request_jvx_ata",
|
|
1109
|
+
docs: [
|
|
1110
|
+
"jvX ATA owned by the WithdrawRequest PDA (escrow for shares)"
|
|
1111
|
+
],
|
|
1112
|
+
writable: true,
|
|
1113
|
+
pda: {
|
|
1114
|
+
seeds: [
|
|
1115
|
+
{
|
|
1116
|
+
kind: "account",
|
|
1117
|
+
path: "withdraw_request"
|
|
1118
|
+
},
|
|
1119
|
+
{
|
|
1120
|
+
kind: "const",
|
|
1121
|
+
value: [
|
|
1122
|
+
6,
|
|
1123
|
+
221,
|
|
1124
|
+
246,
|
|
1125
|
+
225,
|
|
1126
|
+
215,
|
|
1127
|
+
101,
|
|
1128
|
+
161,
|
|
1129
|
+
147,
|
|
1130
|
+
217,
|
|
1131
|
+
203,
|
|
1132
|
+
225,
|
|
1133
|
+
70,
|
|
1134
|
+
206,
|
|
1135
|
+
235,
|
|
1136
|
+
121,
|
|
1137
|
+
172,
|
|
1138
|
+
28,
|
|
1139
|
+
180,
|
|
1140
|
+
133,
|
|
1141
|
+
237,
|
|
1142
|
+
95,
|
|
1143
|
+
91,
|
|
1144
|
+
55,
|
|
1145
|
+
145,
|
|
1146
|
+
58,
|
|
1147
|
+
140,
|
|
1148
|
+
245,
|
|
1149
|
+
133,
|
|
1150
|
+
126,
|
|
1151
|
+
255,
|
|
1152
|
+
0,
|
|
1153
|
+
169
|
|
1154
|
+
]
|
|
1155
|
+
},
|
|
1156
|
+
{
|
|
1157
|
+
kind: "account",
|
|
1158
|
+
path: "jv_mint"
|
|
1159
|
+
}
|
|
1160
|
+
],
|
|
1161
|
+
program: {
|
|
1162
|
+
kind: "const",
|
|
1163
|
+
value: [
|
|
1164
|
+
140,
|
|
1165
|
+
151,
|
|
1166
|
+
37,
|
|
1167
|
+
143,
|
|
1168
|
+
78,
|
|
1169
|
+
36,
|
|
1170
|
+
137,
|
|
1171
|
+
241,
|
|
1172
|
+
187,
|
|
1173
|
+
61,
|
|
1174
|
+
16,
|
|
1175
|
+
41,
|
|
1176
|
+
20,
|
|
1177
|
+
142,
|
|
1178
|
+
13,
|
|
1179
|
+
131,
|
|
1180
|
+
11,
|
|
1181
|
+
90,
|
|
1182
|
+
19,
|
|
1183
|
+
153,
|
|
1184
|
+
218,
|
|
1185
|
+
255,
|
|
1186
|
+
16,
|
|
1187
|
+
132,
|
|
1188
|
+
4,
|
|
1189
|
+
142,
|
|
1190
|
+
123,
|
|
1191
|
+
216,
|
|
1192
|
+
219,
|
|
1193
|
+
233,
|
|
1194
|
+
248,
|
|
1195
|
+
89
|
|
1196
|
+
]
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
},
|
|
1200
|
+
{
|
|
1201
|
+
name: "token_program"
|
|
1202
|
+
},
|
|
1203
|
+
{
|
|
1204
|
+
name: "associated_token_program",
|
|
1205
|
+
address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
|
1206
|
+
},
|
|
1207
|
+
{
|
|
1208
|
+
name: "system_program",
|
|
1209
|
+
address: "11111111111111111111111111111111"
|
|
1210
|
+
}
|
|
1211
|
+
],
|
|
1212
|
+
args: [
|
|
1213
|
+
{
|
|
1214
|
+
name: "shares",
|
|
1215
|
+
type: "u64"
|
|
1216
|
+
},
|
|
1217
|
+
{
|
|
1218
|
+
name: "epoch_id",
|
|
1219
|
+
type: "u32"
|
|
1220
|
+
}
|
|
1221
|
+
]
|
|
1222
|
+
},
|
|
894
1223
|
{
|
|
895
1224
|
name: "settle_yield",
|
|
896
1225
|
docs: [
|
|
@@ -902,17 +1231,15 @@ var jlp_d_program_default = {
|
|
|
902
1231
|
"2. Values total base_loaned across all STVs in USD",
|
|
903
1232
|
"3. Distributes surplus (yield) or deficit (bad debt) proportionally",
|
|
904
1233
|
"",
|
|
905
|
-
"# Parameters",
|
|
906
|
-
"- `jlp_rate`: Manager-provided JLP price (8 decimals), cross-checked against Pyth",
|
|
907
|
-
"",
|
|
908
1234
|
"# Security",
|
|
909
1235
|
"- BTC/ETH/SOL prices come from Doves oracles (manipulation-resistant)",
|
|
910
|
-
"- JLP price
|
|
1236
|
+
"- JLP price computed directly from Jupiter Perps Pool account (aumUsd / jlp_supply)",
|
|
911
1237
|
"- Exchange rates come from Jupiter Earn (audited, TWAP-based)",
|
|
912
1238
|
"- Distribution is proportional to each STV's share of total loans",
|
|
913
1239
|
"",
|
|
914
1240
|
"# Accounts",
|
|
915
|
-
"Requires all 5 STVs, 5 staging jlX ATAs, 3 Doves oracles (BTC/ETH/SOL),
|
|
1241
|
+
"Requires all 5 STVs, 5 staging jlX ATAs, 3 Doves oracles (BTC/ETH/SOL),",
|
|
1242
|
+
"Jupiter Perps Pool account, JLP mint account",
|
|
916
1243
|
"",
|
|
917
1244
|
"# Remaining Accounts (15 accounts)",
|
|
918
1245
|
"For exchange rate calculation with time-accrued rewards:",
|
|
@@ -986,7 +1313,10 @@ var jlp_d_program_default = {
|
|
|
986
1313
|
name: "doves_sol_usd"
|
|
987
1314
|
},
|
|
988
1315
|
{
|
|
989
|
-
name: "
|
|
1316
|
+
name: "jlp_pool"
|
|
1317
|
+
},
|
|
1318
|
+
{
|
|
1319
|
+
name: "jlp_mint_account"
|
|
990
1320
|
},
|
|
991
1321
|
{
|
|
992
1322
|
name: "manager",
|
|
@@ -996,16 +1326,7 @@ var jlp_d_program_default = {
|
|
|
996
1326
|
signer: true
|
|
997
1327
|
}
|
|
998
1328
|
],
|
|
999
|
-
args: [
|
|
1000
|
-
{
|
|
1001
|
-
name: "params",
|
|
1002
|
-
type: {
|
|
1003
|
-
defined: {
|
|
1004
|
-
name: "SettleYieldParams"
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
}
|
|
1008
|
-
]
|
|
1329
|
+
args: []
|
|
1009
1330
|
},
|
|
1010
1331
|
{
|
|
1011
1332
|
name: "swap_jlx_to_from_jlp",
|
|
@@ -1145,121 +1466,6 @@ var jlp_d_program_default = {
|
|
|
1145
1466
|
}
|
|
1146
1467
|
}
|
|
1147
1468
|
]
|
|
1148
|
-
},
|
|
1149
|
-
{
|
|
1150
|
-
name: "withdraw",
|
|
1151
|
-
docs: [
|
|
1152
|
-
"Withdraw base asset by burning jvX shares",
|
|
1153
|
-
"",
|
|
1154
|
-
"# Flow",
|
|
1155
|
-
"1. Crystallize fees inline (ensures fair PPS)",
|
|
1156
|
-
"2. Calculate base amount from shares at post-fee PPS",
|
|
1157
|
-
"3. Burn jvX shares from user",
|
|
1158
|
-
"4. Transfer base from STV's base ATA to user",
|
|
1159
|
-
"",
|
|
1160
|
-
"# Note",
|
|
1161
|
-
"Requires sufficient base balance in STV's base ATA.",
|
|
1162
|
-
"Manager must ensure liquidity by converting jlX to base via",
|
|
1163
|
-
"jup_earn_deposit_withdraw instruction before user withdrawals.",
|
|
1164
|
-
"",
|
|
1165
|
-
"Remaining accounts (optional, for exchange rate):",
|
|
1166
|
-
"[0] = Jupiter Lend lending account",
|
|
1167
|
-
"[1] = Jupiter Lend rewards rate model"
|
|
1168
|
-
],
|
|
1169
|
-
discriminator: [
|
|
1170
|
-
183,
|
|
1171
|
-
18,
|
|
1172
|
-
70,
|
|
1173
|
-
156,
|
|
1174
|
-
148,
|
|
1175
|
-
109,
|
|
1176
|
-
161,
|
|
1177
|
-
34
|
|
1178
|
-
],
|
|
1179
|
-
accounts: [
|
|
1180
|
-
{
|
|
1181
|
-
name: "user",
|
|
1182
|
-
docs: [
|
|
1183
|
-
"User performing the withdrawal"
|
|
1184
|
-
],
|
|
1185
|
-
writable: true,
|
|
1186
|
-
signer: true
|
|
1187
|
-
},
|
|
1188
|
-
{
|
|
1189
|
-
name: "jlp_vault",
|
|
1190
|
-
docs: [
|
|
1191
|
-
"The JLP Vault PDA account",
|
|
1192
|
-
"Note: PDA verified in handler via get_pda() to avoid multiple loads"
|
|
1193
|
-
]
|
|
1194
|
-
},
|
|
1195
|
-
{
|
|
1196
|
-
name: "stv",
|
|
1197
|
-
docs: [
|
|
1198
|
-
"The STV PDA account",
|
|
1199
|
-
"Note: PDA verified in handler via get_pda() to avoid multiple loads"
|
|
1200
|
-
],
|
|
1201
|
-
writable: true
|
|
1202
|
-
},
|
|
1203
|
-
{
|
|
1204
|
-
name: "base_mint",
|
|
1205
|
-
docs: [
|
|
1206
|
-
"Base asset mint (underlying token: SOL, BTC, ETH, USDC)"
|
|
1207
|
-
]
|
|
1208
|
-
},
|
|
1209
|
-
{
|
|
1210
|
-
name: "jl_mint",
|
|
1211
|
-
docs: [
|
|
1212
|
-
"jlX mint (Jupiter Lend token) - used for NAV calculation"
|
|
1213
|
-
]
|
|
1214
|
-
},
|
|
1215
|
-
{
|
|
1216
|
-
name: "jv_mint",
|
|
1217
|
-
docs: [
|
|
1218
|
-
"jvX mint (vault share token) - STV is mint authority",
|
|
1219
|
-
"Verified against STV.jv_mint in handler"
|
|
1220
|
-
],
|
|
1221
|
-
writable: true
|
|
1222
|
-
},
|
|
1223
|
-
{
|
|
1224
|
-
name: "user_base_ata",
|
|
1225
|
-
docs: [
|
|
1226
|
-
"User's base asset token account (destination for withdrawal)"
|
|
1227
|
-
],
|
|
1228
|
-
writable: true
|
|
1229
|
-
},
|
|
1230
|
-
{
|
|
1231
|
-
name: "user_jvx_ata",
|
|
1232
|
-
docs: [
|
|
1233
|
-
"User's jvX token account (source - shares to burn)"
|
|
1234
|
-
],
|
|
1235
|
-
writable: true
|
|
1236
|
-
},
|
|
1237
|
-
{
|
|
1238
|
-
name: "stv_base_ata",
|
|
1239
|
-
docs: [
|
|
1240
|
-
"STV's base ATA (source for base tokens to user)"
|
|
1241
|
-
],
|
|
1242
|
-
writable: true
|
|
1243
|
-
},
|
|
1244
|
-
{
|
|
1245
|
-
name: "stv_jlx_ata",
|
|
1246
|
-
docs: [
|
|
1247
|
-
"STV's jlX ATA (used for NAV calculation)"
|
|
1248
|
-
]
|
|
1249
|
-
},
|
|
1250
|
-
{
|
|
1251
|
-
name: "token_program",
|
|
1252
|
-
docs: [
|
|
1253
|
-
"Token program"
|
|
1254
|
-
]
|
|
1255
|
-
}
|
|
1256
|
-
],
|
|
1257
|
-
args: [
|
|
1258
|
-
{
|
|
1259
|
-
name: "shares_to_burn",
|
|
1260
|
-
type: "u64"
|
|
1261
|
-
}
|
|
1262
|
-
]
|
|
1263
1469
|
}
|
|
1264
1470
|
],
|
|
1265
1471
|
accounts: [
|
|
@@ -1288,6 +1494,19 @@ var jlp_d_program_default = {
|
|
|
1288
1494
|
17,
|
|
1289
1495
|
230
|
|
1290
1496
|
]
|
|
1497
|
+
},
|
|
1498
|
+
{
|
|
1499
|
+
name: "WithdrawRequest",
|
|
1500
|
+
discriminator: [
|
|
1501
|
+
186,
|
|
1502
|
+
239,
|
|
1503
|
+
174,
|
|
1504
|
+
191,
|
|
1505
|
+
189,
|
|
1506
|
+
13,
|
|
1507
|
+
47,
|
|
1508
|
+
196
|
|
1509
|
+
]
|
|
1291
1510
|
}
|
|
1292
1511
|
],
|
|
1293
1512
|
events: [
|
|
@@ -1304,6 +1523,32 @@ var jlp_d_program_default = {
|
|
|
1304
1523
|
57
|
|
1305
1524
|
]
|
|
1306
1525
|
},
|
|
1526
|
+
{
|
|
1527
|
+
name: "EpochAdvanced",
|
|
1528
|
+
discriminator: [
|
|
1529
|
+
41,
|
|
1530
|
+
220,
|
|
1531
|
+
14,
|
|
1532
|
+
123,
|
|
1533
|
+
117,
|
|
1534
|
+
70,
|
|
1535
|
+
117,
|
|
1536
|
+
157
|
|
1537
|
+
]
|
|
1538
|
+
},
|
|
1539
|
+
{
|
|
1540
|
+
name: "EpochProcessed",
|
|
1541
|
+
discriminator: [
|
|
1542
|
+
18,
|
|
1543
|
+
238,
|
|
1544
|
+
2,
|
|
1545
|
+
247,
|
|
1546
|
+
238,
|
|
1547
|
+
178,
|
|
1548
|
+
94,
|
|
1549
|
+
138
|
|
1550
|
+
]
|
|
1551
|
+
},
|
|
1307
1552
|
{
|
|
1308
1553
|
name: "FeesClaimSkipped",
|
|
1309
1554
|
discriminator: [
|
|
@@ -1474,16 +1719,29 @@ var jlp_d_program_default = {
|
|
|
1474
1719
|
]
|
|
1475
1720
|
},
|
|
1476
1721
|
{
|
|
1477
|
-
name: "
|
|
1722
|
+
name: "WithdrawClaimed",
|
|
1723
|
+
discriminator: [
|
|
1724
|
+
77,
|
|
1725
|
+
130,
|
|
1726
|
+
89,
|
|
1727
|
+
38,
|
|
1728
|
+
239,
|
|
1729
|
+
172,
|
|
1730
|
+
174,
|
|
1731
|
+
85
|
|
1732
|
+
]
|
|
1733
|
+
},
|
|
1734
|
+
{
|
|
1735
|
+
name: "WithdrawRequested",
|
|
1478
1736
|
discriminator: [
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1737
|
+
114,
|
|
1738
|
+
16,
|
|
1739
|
+
240,
|
|
1740
|
+
206,
|
|
1741
|
+
93,
|
|
1742
|
+
128,
|
|
1743
|
+
151,
|
|
1744
|
+
39
|
|
1487
1745
|
]
|
|
1488
1746
|
}
|
|
1489
1747
|
],
|
|
@@ -1705,8 +1963,8 @@ var jlp_d_program_default = {
|
|
|
1705
1963
|
},
|
|
1706
1964
|
{
|
|
1707
1965
|
code: 6043,
|
|
1708
|
-
name: "
|
|
1709
|
-
msg: "
|
|
1966
|
+
name: "JlpPriceOutOfRange",
|
|
1967
|
+
msg: "JLP price out of reasonable range ($0.50 - $50.00)"
|
|
1710
1968
|
},
|
|
1711
1969
|
{
|
|
1712
1970
|
code: 6044,
|
|
@@ -1717,6 +1975,56 @@ var jlp_d_program_default = {
|
|
|
1717
1975
|
code: 6045,
|
|
1718
1976
|
name: "NotAdmin",
|
|
1719
1977
|
msg: "Unauthorized: not admin"
|
|
1978
|
+
},
|
|
1979
|
+
{
|
|
1980
|
+
code: 6046,
|
|
1981
|
+
name: "TokenAccountNotEmpty",
|
|
1982
|
+
msg: "Token account balance must be zero before closing"
|
|
1983
|
+
},
|
|
1984
|
+
{
|
|
1985
|
+
code: 6047,
|
|
1986
|
+
name: "TokenAccountOwnerMismatch",
|
|
1987
|
+
msg: "Token account not owned by expected PDA"
|
|
1988
|
+
},
|
|
1989
|
+
{
|
|
1990
|
+
code: 6048,
|
|
1991
|
+
name: "EpochEnded",
|
|
1992
|
+
msg: "Epoch has ended - call process_epoch first"
|
|
1993
|
+
},
|
|
1994
|
+
{
|
|
1995
|
+
code: 6049,
|
|
1996
|
+
name: "EpochNotEnded",
|
|
1997
|
+
msg: "Epoch has not ended yet"
|
|
1998
|
+
},
|
|
1999
|
+
{
|
|
2000
|
+
code: 6050,
|
|
2001
|
+
name: "ClaimNotAvailableYet",
|
|
2002
|
+
msg: "Claim not available yet - wait for next epoch"
|
|
2003
|
+
},
|
|
2004
|
+
{
|
|
2005
|
+
code: 6051,
|
|
2006
|
+
name: "InvalidEpochInterval",
|
|
2007
|
+
msg: "Withdraw epoch interval must be > 0"
|
|
2008
|
+
},
|
|
2009
|
+
{
|
|
2010
|
+
code: 6052,
|
|
2011
|
+
name: "ActiveWithdrawReserves",
|
|
2012
|
+
msg: "Cannot update epoch interval with active reserves"
|
|
2013
|
+
},
|
|
2014
|
+
{
|
|
2015
|
+
code: 6053,
|
|
2016
|
+
name: "EpochIdMismatch",
|
|
2017
|
+
msg: "Epoch ID mismatch"
|
|
2018
|
+
},
|
|
2019
|
+
{
|
|
2020
|
+
code: 6054,
|
|
2021
|
+
name: "WithdrawRequestNotProcessed",
|
|
2022
|
+
msg: "Withdraw request not processed yet"
|
|
2023
|
+
},
|
|
2024
|
+
{
|
|
2025
|
+
code: 6055,
|
|
2026
|
+
name: "WithdrawRequestAlreadyProcessed",
|
|
2027
|
+
msg: "Withdraw request already processed"
|
|
1720
2028
|
}
|
|
1721
2029
|
],
|
|
1722
2030
|
types: [
|
|
@@ -1768,6 +2076,62 @@ var jlp_d_program_default = {
|
|
|
1768
2076
|
]
|
|
1769
2077
|
}
|
|
1770
2078
|
},
|
|
2079
|
+
{
|
|
2080
|
+
name: "EpochAdvanced",
|
|
2081
|
+
type: {
|
|
2082
|
+
kind: "struct",
|
|
2083
|
+
fields: [
|
|
2084
|
+
{
|
|
2085
|
+
name: "stv",
|
|
2086
|
+
type: "pubkey"
|
|
2087
|
+
},
|
|
2088
|
+
{
|
|
2089
|
+
name: "new_epoch_id",
|
|
2090
|
+
type: "u32"
|
|
2091
|
+
},
|
|
2092
|
+
{
|
|
2093
|
+
name: "new_next_epoch_ts",
|
|
2094
|
+
type: "u32"
|
|
2095
|
+
}
|
|
2096
|
+
]
|
|
2097
|
+
}
|
|
2098
|
+
},
|
|
2099
|
+
{
|
|
2100
|
+
name: "EpochProcessed",
|
|
2101
|
+
type: {
|
|
2102
|
+
kind: "struct",
|
|
2103
|
+
fields: [
|
|
2104
|
+
{
|
|
2105
|
+
name: "stv",
|
|
2106
|
+
type: "pubkey"
|
|
2107
|
+
},
|
|
2108
|
+
{
|
|
2109
|
+
name: "epoch_id",
|
|
2110
|
+
type: "u32"
|
|
2111
|
+
},
|
|
2112
|
+
{
|
|
2113
|
+
name: "pps",
|
|
2114
|
+
type: "u64"
|
|
2115
|
+
},
|
|
2116
|
+
{
|
|
2117
|
+
name: "total_shares",
|
|
2118
|
+
type: "u64"
|
|
2119
|
+
},
|
|
2120
|
+
{
|
|
2121
|
+
name: "total_base",
|
|
2122
|
+
type: "u64"
|
|
2123
|
+
},
|
|
2124
|
+
{
|
|
2125
|
+
name: "new_epoch_id",
|
|
2126
|
+
type: "u32"
|
|
2127
|
+
},
|
|
2128
|
+
{
|
|
2129
|
+
name: "new_next_epoch_ts",
|
|
2130
|
+
type: "u32"
|
|
2131
|
+
}
|
|
2132
|
+
]
|
|
2133
|
+
}
|
|
2134
|
+
},
|
|
1771
2135
|
{
|
|
1772
2136
|
name: "FeesClaimSkipped",
|
|
1773
2137
|
docs: [
|
|
@@ -1953,6 +2317,13 @@ var jlp_d_program_default = {
|
|
|
1953
2317
|
"Minimum deposit amount in base asset (0 = no minimum)"
|
|
1954
2318
|
],
|
|
1955
2319
|
type: "u64"
|
|
2320
|
+
},
|
|
2321
|
+
{
|
|
2322
|
+
name: "epoch_sec",
|
|
2323
|
+
docs: [
|
|
2324
|
+
"Epoch duration in seconds for delayed withdrawals"
|
|
2325
|
+
],
|
|
2326
|
+
type: "u32"
|
|
1956
2327
|
}
|
|
1957
2328
|
]
|
|
1958
2329
|
}
|
|
@@ -2398,7 +2769,7 @@ var jlp_d_program_default = {
|
|
|
2398
2769
|
docs: [
|
|
2399
2770
|
"STV - Single Token Vault account",
|
|
2400
2771
|
'Seeds: ["stv", base_mint.key().as_ref()]',
|
|
2401
|
-
"Size: 8 (discriminator) +
|
|
2772
|
+
"Size: 8 (discriminator) + 200 (data) = 208 bytes"
|
|
2402
2773
|
],
|
|
2403
2774
|
serialization: "bytemuck",
|
|
2404
2775
|
repr: {
|
|
@@ -2480,6 +2851,50 @@ var jlp_d_program_default = {
|
|
|
2480
2851
|
],
|
|
2481
2852
|
type: "u64"
|
|
2482
2853
|
},
|
|
2854
|
+
{
|
|
2855
|
+
name: "requested_base",
|
|
2856
|
+
docs: [
|
|
2857
|
+
"Estimated base for current epoch's withdrawal requests (reset on process_epoch)",
|
|
2858
|
+
"Manager reads this to know how much to unwind before next epoch"
|
|
2859
|
+
],
|
|
2860
|
+
type: "u64"
|
|
2861
|
+
},
|
|
2862
|
+
{
|
|
2863
|
+
name: "reserved_base",
|
|
2864
|
+
docs: [
|
|
2865
|
+
"Base earmarked for unclaimed withdrawals (+process_epoch, -claim_withdraw)",
|
|
2866
|
+
"Subtracted from NAV so reserved funds don't inflate PPS"
|
|
2867
|
+
],
|
|
2868
|
+
type: "u64"
|
|
2869
|
+
},
|
|
2870
|
+
{
|
|
2871
|
+
name: "epoch_pps",
|
|
2872
|
+
docs: [
|
|
2873
|
+
"PPS locked at first process_epoch batch (0 = not set, reset on epoch advance)"
|
|
2874
|
+
],
|
|
2875
|
+
type: "u64"
|
|
2876
|
+
},
|
|
2877
|
+
{
|
|
2878
|
+
name: "next_epoch_ts",
|
|
2879
|
+
docs: [
|
|
2880
|
+
"Unix timestamp when current epoch ends"
|
|
2881
|
+
],
|
|
2882
|
+
type: "u32"
|
|
2883
|
+
},
|
|
2884
|
+
{
|
|
2885
|
+
name: "epoch_sec",
|
|
2886
|
+
docs: [
|
|
2887
|
+
"Epoch duration in seconds"
|
|
2888
|
+
],
|
|
2889
|
+
type: "u32"
|
|
2890
|
+
},
|
|
2891
|
+
{
|
|
2892
|
+
name: "current_epoch_id",
|
|
2893
|
+
docs: [
|
|
2894
|
+
"Incrementing epoch counter"
|
|
2895
|
+
],
|
|
2896
|
+
type: "u32"
|
|
2897
|
+
},
|
|
2483
2898
|
{
|
|
2484
2899
|
name: "mgmt_fee_bps",
|
|
2485
2900
|
docs: [
|
|
@@ -2514,6 +2929,18 @@ var jlp_d_program_default = {
|
|
|
2514
2929
|
"PDA bump seed"
|
|
2515
2930
|
],
|
|
2516
2931
|
type: "u8"
|
|
2932
|
+
},
|
|
2933
|
+
{
|
|
2934
|
+
name: "_padding",
|
|
2935
|
+
docs: [
|
|
2936
|
+
"Alignment padding"
|
|
2937
|
+
],
|
|
2938
|
+
type: {
|
|
2939
|
+
array: [
|
|
2940
|
+
"u8",
|
|
2941
|
+
4
|
|
2942
|
+
]
|
|
2943
|
+
}
|
|
2517
2944
|
}
|
|
2518
2945
|
]
|
|
2519
2946
|
}
|
|
@@ -2571,25 +2998,6 @@ var jlp_d_program_default = {
|
|
|
2571
2998
|
]
|
|
2572
2999
|
}
|
|
2573
3000
|
},
|
|
2574
|
-
{
|
|
2575
|
-
name: "SettleYieldParams",
|
|
2576
|
-
docs: [
|
|
2577
|
-
"Parameters for settle_yield instruction"
|
|
2578
|
-
],
|
|
2579
|
-
type: {
|
|
2580
|
-
kind: "struct",
|
|
2581
|
-
fields: [
|
|
2582
|
-
{
|
|
2583
|
-
name: "jlp_rate",
|
|
2584
|
-
docs: [
|
|
2585
|
-
"Manager-provided JLP rate (8 decimals, e.g., 450000000 = $4.50)",
|
|
2586
|
-
"Cross-checked against Pyth oracle, must be within 50 bps tolerance"
|
|
2587
|
-
],
|
|
2588
|
-
type: "u64"
|
|
2589
|
-
}
|
|
2590
|
-
]
|
|
2591
|
-
}
|
|
2592
|
-
},
|
|
2593
3001
|
{
|
|
2594
3002
|
name: "SettleYieldSkipped",
|
|
2595
3003
|
docs: [
|
|
@@ -2761,120 +3169,253 @@ var jlp_d_program_default = {
|
|
|
2761
3169
|
name: "JlxToJlp"
|
|
2762
3170
|
},
|
|
2763
3171
|
{
|
|
2764
|
-
name: "JlpToJlx"
|
|
3172
|
+
name: "JlpToJlx"
|
|
3173
|
+
}
|
|
3174
|
+
]
|
|
3175
|
+
}
|
|
3176
|
+
},
|
|
3177
|
+
{
|
|
3178
|
+
name: "SwapJlxJlpParams",
|
|
3179
|
+
docs: [
|
|
3180
|
+
"Parameters for the swap instruction"
|
|
3181
|
+
],
|
|
3182
|
+
type: {
|
|
3183
|
+
kind: "struct",
|
|
3184
|
+
fields: [
|
|
3185
|
+
{
|
|
3186
|
+
name: "stv_index",
|
|
3187
|
+
docs: [
|
|
3188
|
+
"Which STV this JLP belongs to (0-4: BTC, ETH, SOL, USDC, JupUSD)"
|
|
3189
|
+
],
|
|
3190
|
+
type: "u8"
|
|
3191
|
+
},
|
|
3192
|
+
{
|
|
3193
|
+
name: "direction",
|
|
3194
|
+
docs: [
|
|
3195
|
+
"Direction of the swap"
|
|
3196
|
+
],
|
|
3197
|
+
type: {
|
|
3198
|
+
defined: {
|
|
3199
|
+
name: "SwapDirection"
|
|
3200
|
+
}
|
|
3201
|
+
}
|
|
3202
|
+
},
|
|
3203
|
+
{
|
|
3204
|
+
name: "amount_in",
|
|
3205
|
+
docs: [
|
|
3206
|
+
"Amount of input token being swapped"
|
|
3207
|
+
],
|
|
3208
|
+
type: "u64"
|
|
3209
|
+
},
|
|
3210
|
+
{
|
|
3211
|
+
name: "expected_amount_out",
|
|
3212
|
+
docs: [
|
|
3213
|
+
"Expected output amount (used for devnet mock, verified on mainnet)"
|
|
3214
|
+
],
|
|
3215
|
+
type: "u64"
|
|
3216
|
+
},
|
|
3217
|
+
{
|
|
3218
|
+
name: "jupiter_data",
|
|
3219
|
+
docs: [
|
|
3220
|
+
"Jupiter swap instruction data (includes discriminator and route)",
|
|
3221
|
+
"This is obtained from Jupiter API off-chain",
|
|
3222
|
+
"On devnet (with `devnet` feature), this can be empty"
|
|
3223
|
+
],
|
|
3224
|
+
type: "bytes"
|
|
3225
|
+
}
|
|
3226
|
+
]
|
|
3227
|
+
}
|
|
3228
|
+
},
|
|
3229
|
+
{
|
|
3230
|
+
name: "UpdateStvParams",
|
|
3231
|
+
docs: [
|
|
3232
|
+
"Parameters for updating an STV"
|
|
3233
|
+
],
|
|
3234
|
+
type: {
|
|
3235
|
+
kind: "struct",
|
|
3236
|
+
fields: [
|
|
3237
|
+
{
|
|
3238
|
+
name: "mgmt_fee_bps",
|
|
3239
|
+
docs: [
|
|
3240
|
+
"Management fee in basis points (annual)"
|
|
3241
|
+
],
|
|
3242
|
+
type: "u16"
|
|
3243
|
+
},
|
|
3244
|
+
{
|
|
3245
|
+
name: "perf_fee_bps",
|
|
3246
|
+
docs: [
|
|
3247
|
+
"Performance fee in basis points"
|
|
3248
|
+
],
|
|
3249
|
+
type: "u16"
|
|
3250
|
+
},
|
|
3251
|
+
{
|
|
3252
|
+
name: "flags",
|
|
3253
|
+
docs: [
|
|
3254
|
+
"STV state flags"
|
|
3255
|
+
],
|
|
3256
|
+
type: "u16"
|
|
3257
|
+
},
|
|
3258
|
+
{
|
|
3259
|
+
name: "max_deposit",
|
|
3260
|
+
docs: [
|
|
3261
|
+
"Maximum deposit amount in base asset (0 = unlimited)"
|
|
3262
|
+
],
|
|
3263
|
+
type: "u64"
|
|
3264
|
+
},
|
|
3265
|
+
{
|
|
3266
|
+
name: "min_deposit",
|
|
3267
|
+
docs: [
|
|
3268
|
+
"Minimum deposit amount in base asset (0 = no minimum)"
|
|
3269
|
+
],
|
|
3270
|
+
type: "u64"
|
|
3271
|
+
},
|
|
3272
|
+
{
|
|
3273
|
+
name: "jl_mint",
|
|
3274
|
+
docs: [
|
|
3275
|
+
"Optional new jl_mint for migrating base-only pools to Jupiter Lend"
|
|
3276
|
+
],
|
|
3277
|
+
type: {
|
|
3278
|
+
option: "pubkey"
|
|
3279
|
+
}
|
|
3280
|
+
},
|
|
3281
|
+
{
|
|
3282
|
+
name: "pps",
|
|
3283
|
+
docs: [
|
|
3284
|
+
"Override price per share (9 decimals, e.g. 1_000_000_000 = 1.0)"
|
|
3285
|
+
],
|
|
3286
|
+
type: {
|
|
3287
|
+
option: "u64"
|
|
3288
|
+
}
|
|
3289
|
+
},
|
|
3290
|
+
{
|
|
3291
|
+
name: "hwm",
|
|
3292
|
+
docs: [
|
|
3293
|
+
"Override high water mark (9 decimals)"
|
|
3294
|
+
],
|
|
3295
|
+
type: {
|
|
3296
|
+
option: "u64"
|
|
3297
|
+
}
|
|
3298
|
+
},
|
|
3299
|
+
{
|
|
3300
|
+
name: "base_loaned",
|
|
3301
|
+
docs: [
|
|
3302
|
+
"Override base_loaned accounting field"
|
|
3303
|
+
],
|
|
3304
|
+
type: {
|
|
3305
|
+
option: "u64"
|
|
3306
|
+
}
|
|
3307
|
+
},
|
|
3308
|
+
{
|
|
3309
|
+
name: "epoch_sec",
|
|
3310
|
+
docs: [
|
|
3311
|
+
"Optional new epoch duration in seconds"
|
|
3312
|
+
],
|
|
3313
|
+
type: {
|
|
3314
|
+
option: "u32"
|
|
3315
|
+
}
|
|
2765
3316
|
}
|
|
2766
3317
|
]
|
|
2767
3318
|
}
|
|
2768
3319
|
},
|
|
2769
3320
|
{
|
|
2770
|
-
name: "
|
|
2771
|
-
docs: [
|
|
2772
|
-
"Parameters for the swap instruction"
|
|
2773
|
-
],
|
|
3321
|
+
name: "WithdrawClaimed",
|
|
2774
3322
|
type: {
|
|
2775
3323
|
kind: "struct",
|
|
2776
3324
|
fields: [
|
|
2777
3325
|
{
|
|
2778
|
-
name: "
|
|
2779
|
-
|
|
2780
|
-
"Which STV this JLP belongs to (0-4: BTC, ETH, SOL, USDC, JupUSD)"
|
|
2781
|
-
],
|
|
2782
|
-
type: "u8"
|
|
3326
|
+
name: "stv",
|
|
3327
|
+
type: "pubkey"
|
|
2783
3328
|
},
|
|
2784
3329
|
{
|
|
2785
|
-
name: "
|
|
2786
|
-
|
|
2787
|
-
"Direction of the swap"
|
|
2788
|
-
],
|
|
2789
|
-
type: {
|
|
2790
|
-
defined: {
|
|
2791
|
-
name: "SwapDirection"
|
|
2792
|
-
}
|
|
2793
|
-
}
|
|
3330
|
+
name: "user",
|
|
3331
|
+
type: "pubkey"
|
|
2794
3332
|
},
|
|
2795
3333
|
{
|
|
2796
|
-
name: "
|
|
2797
|
-
docs: [
|
|
2798
|
-
"Amount of input token being swapped"
|
|
2799
|
-
],
|
|
3334
|
+
name: "shares",
|
|
2800
3335
|
type: "u64"
|
|
2801
3336
|
},
|
|
2802
3337
|
{
|
|
2803
|
-
name: "
|
|
2804
|
-
docs: [
|
|
2805
|
-
"Expected output amount (used for devnet mock, verified on mainnet)"
|
|
2806
|
-
],
|
|
3338
|
+
name: "base_amount",
|
|
2807
3339
|
type: "u64"
|
|
2808
3340
|
},
|
|
2809
3341
|
{
|
|
2810
|
-
name: "
|
|
2811
|
-
|
|
2812
|
-
"Jupiter swap instruction data (includes discriminator and route)",
|
|
2813
|
-
"This is obtained from Jupiter API off-chain",
|
|
2814
|
-
"On devnet (with `devnet` feature), this can be empty"
|
|
2815
|
-
],
|
|
2816
|
-
type: "bytes"
|
|
3342
|
+
name: "epoch_id",
|
|
3343
|
+
type: "u32"
|
|
2817
3344
|
}
|
|
2818
3345
|
]
|
|
2819
3346
|
}
|
|
2820
3347
|
},
|
|
2821
3348
|
{
|
|
2822
|
-
name: "
|
|
3349
|
+
name: "WithdrawRequest",
|
|
2823
3350
|
docs: [
|
|
2824
|
-
"
|
|
3351
|
+
"WithdrawRequest - Per-user per-epoch withdrawal request",
|
|
3352
|
+
'Seeds: ["withdraw_request", stv.key(), user.key(), &epoch_id.to_le_bytes()]',
|
|
3353
|
+
"",
|
|
3354
|
+
"One PDA per user per STV per epoch. Multiple request_withdraw calls",
|
|
3355
|
+
"in the same epoch accumulate into the same PDA.",
|
|
3356
|
+
"",
|
|
3357
|
+
"Lifecycle:",
|
|
3358
|
+
"1. Created by request_withdraw (user escrows jvX into request's ATA)",
|
|
3359
|
+
"2. Processed by process_epoch (jvX burned, pps + claim_available_after set)",
|
|
3360
|
+
"3. Closed by claim_withdraw (base transferred, PDA + ATA closed)"
|
|
2825
3361
|
],
|
|
2826
3362
|
type: {
|
|
2827
3363
|
kind: "struct",
|
|
2828
3364
|
fields: [
|
|
2829
3365
|
{
|
|
2830
|
-
name: "
|
|
3366
|
+
name: "stv",
|
|
2831
3367
|
docs: [
|
|
2832
|
-
"
|
|
3368
|
+
"Back-reference to the STV"
|
|
2833
3369
|
],
|
|
2834
|
-
type: "
|
|
3370
|
+
type: "pubkey"
|
|
2835
3371
|
},
|
|
2836
3372
|
{
|
|
2837
|
-
name: "
|
|
3373
|
+
name: "user",
|
|
2838
3374
|
docs: [
|
|
2839
|
-
"
|
|
3375
|
+
"The user who requested the withdrawal"
|
|
2840
3376
|
],
|
|
2841
|
-
type: "
|
|
3377
|
+
type: "pubkey"
|
|
2842
3378
|
},
|
|
2843
3379
|
{
|
|
2844
|
-
name: "
|
|
3380
|
+
name: "shares",
|
|
2845
3381
|
docs: [
|
|
2846
|
-
"
|
|
3382
|
+
"Total jvX shares escrowed (accumulated across multiple requests in same epoch)"
|
|
2847
3383
|
],
|
|
2848
|
-
type: "
|
|
3384
|
+
type: "u64"
|
|
2849
3385
|
},
|
|
2850
3386
|
{
|
|
2851
|
-
name: "
|
|
3387
|
+
name: "pps",
|
|
2852
3388
|
docs: [
|
|
2853
|
-
"
|
|
3389
|
+
"PPS at process time (0 = unprocessed)"
|
|
2854
3390
|
],
|
|
2855
3391
|
type: "u64"
|
|
2856
3392
|
},
|
|
2857
3393
|
{
|
|
2858
|
-
name: "
|
|
3394
|
+
name: "epoch_id",
|
|
2859
3395
|
docs: [
|
|
2860
|
-
"
|
|
3396
|
+
"Epoch when request was made"
|
|
2861
3397
|
],
|
|
2862
|
-
type: "
|
|
3398
|
+
type: "u32"
|
|
2863
3399
|
},
|
|
2864
3400
|
{
|
|
2865
|
-
name: "
|
|
3401
|
+
name: "claim_available_after",
|
|
2866
3402
|
docs: [
|
|
2867
|
-
"
|
|
3403
|
+
"Unix timestamp after which claim is available (0 = unprocessed)"
|
|
2868
3404
|
],
|
|
2869
|
-
type:
|
|
2870
|
-
|
|
2871
|
-
|
|
3405
|
+
type: "u32"
|
|
3406
|
+
},
|
|
3407
|
+
{
|
|
3408
|
+
name: "bump",
|
|
3409
|
+
docs: [
|
|
3410
|
+
"PDA bump seed"
|
|
3411
|
+
],
|
|
3412
|
+
type: "u8"
|
|
2872
3413
|
}
|
|
2873
3414
|
]
|
|
2874
3415
|
}
|
|
2875
3416
|
},
|
|
2876
3417
|
{
|
|
2877
|
-
name: "
|
|
3418
|
+
name: "WithdrawRequested",
|
|
2878
3419
|
type: {
|
|
2879
3420
|
kind: "struct",
|
|
2880
3421
|
fields: [
|
|
@@ -2887,19 +3428,16 @@ var jlp_d_program_default = {
|
|
|
2887
3428
|
type: "pubkey"
|
|
2888
3429
|
},
|
|
2889
3430
|
{
|
|
2890
|
-
name: "
|
|
3431
|
+
name: "shares",
|
|
2891
3432
|
type: "u64"
|
|
2892
3433
|
},
|
|
2893
3434
|
{
|
|
2894
|
-
name: "
|
|
2895
|
-
docs: [
|
|
2896
|
-
"Amount of base asset withdrawn"
|
|
2897
|
-
],
|
|
3435
|
+
name: "total_shares",
|
|
2898
3436
|
type: "u64"
|
|
2899
3437
|
},
|
|
2900
3438
|
{
|
|
2901
|
-
name: "
|
|
2902
|
-
type: "
|
|
3439
|
+
name: "epoch_id",
|
|
3440
|
+
type: "u32"
|
|
2903
3441
|
}
|
|
2904
3442
|
]
|
|
2905
3443
|
}
|
|
@@ -2934,6 +3472,7 @@ var JUPITER_SWAP_PROGRAM_ID = new import_web32.PublicKey(
|
|
|
2934
3472
|
);
|
|
2935
3473
|
var SEED_JLP_VAULT = "jlp_vault";
|
|
2936
3474
|
var SEED_STV = "stv";
|
|
3475
|
+
var SEED_WITHDRAW_REQUEST = "withdraw_request";
|
|
2937
3476
|
var FLAG_PAUSED = 1;
|
|
2938
3477
|
var FLAG_DEPOSITS_DISABLED = 2;
|
|
2939
3478
|
var FLAG_WITHDRAWALS_DISABLED = 4;
|
|
@@ -2961,15 +3500,16 @@ var ORACLES = {
|
|
|
2961
3500
|
// Doves oracles (Jupiter Perps oracle system)
|
|
2962
3501
|
DOVES_BTC_USD: new import_web32.PublicKey("4HBbPx9QJdjJ7GUe6bsiJjGybvfpDhQMMPXP1UEa7VT5"),
|
|
2963
3502
|
DOVES_ETH_USD: new import_web32.PublicKey("5URYohbPy32nxK1t3jAHVNfdWY2xTubHiFvLrE3VhXEp"),
|
|
2964
|
-
DOVES_SOL_USD: new import_web32.PublicKey("39cWjvHrpHNz2SbXv6ME4NPhqBDBd4KsjUYv5JkHEAJU")
|
|
2965
|
-
// Pyth oracle for JLP price
|
|
2966
|
-
PYTH_JLP_USD: new import_web32.PublicKey("2TTGSRSezqFzeLUH8JwRUbtN66XLLaymfYsWRTMjfiMw")
|
|
3503
|
+
DOVES_SOL_USD: new import_web32.PublicKey("39cWjvHrpHNz2SbXv6ME4NPhqBDBd4KsjUYv5JkHEAJU")
|
|
2967
3504
|
};
|
|
3505
|
+
var JLP_POOL_PUBKEY = new import_web32.PublicKey("5BUwFW4nRbftYTDMbgxykoFWqWHPzahFSNAaaaJtVKsq");
|
|
3506
|
+
var JUPITER_PERPS_PROGRAM_ID = new import_web32.PublicKey("PERPHjGBqRHArX4DySjwM6UJHiR3sWAatqfdBS2qQJu");
|
|
2968
3507
|
|
|
2969
3508
|
// src/accounts/pdas.ts
|
|
2970
3509
|
var import_web33 = require("@solana/web3.js");
|
|
2971
3510
|
var SEED_JLP_VAULT_BUFFER = Buffer.from(SEED_JLP_VAULT);
|
|
2972
3511
|
var SEED_STV_BUFFER = Buffer.from(SEED_STV);
|
|
3512
|
+
var SEED_WITHDRAW_REQUEST_BUFFER = Buffer.from(SEED_WITHDRAW_REQUEST);
|
|
2973
3513
|
var pdaCache = /* @__PURE__ */ new Map();
|
|
2974
3514
|
function deriveVaultPda(programId) {
|
|
2975
3515
|
const key = `vault:${programId.toBase58()}`;
|
|
@@ -2995,6 +3535,20 @@ function deriveStvPda(baseMint, programId) {
|
|
|
2995
3535
|
}
|
|
2996
3536
|
return cached;
|
|
2997
3537
|
}
|
|
3538
|
+
function deriveWithdrawRequestPda(stvPda, user, epochId, programId) {
|
|
3539
|
+
const key = `wr:${stvPda.toBase58()}:${user.toBase58()}:${epochId}:${programId.toBase58()}`;
|
|
3540
|
+
let cached = pdaCache.get(key);
|
|
3541
|
+
if (!cached) {
|
|
3542
|
+
const epochIdBuffer = Buffer.alloc(4);
|
|
3543
|
+
epochIdBuffer.writeUInt32LE(epochId);
|
|
3544
|
+
cached = import_web33.PublicKey.findProgramAddressSync(
|
|
3545
|
+
[SEED_WITHDRAW_REQUEST_BUFFER, stvPda.toBuffer(), user.toBuffer(), epochIdBuffer],
|
|
3546
|
+
programId
|
|
3547
|
+
);
|
|
3548
|
+
pdaCache.set(key, cached);
|
|
3549
|
+
}
|
|
3550
|
+
return cached;
|
|
3551
|
+
}
|
|
2998
3552
|
function clearPdaCache() {
|
|
2999
3553
|
pdaCache.clear();
|
|
3000
3554
|
}
|
|
@@ -3073,7 +3627,7 @@ function parseVault(data) {
|
|
|
3073
3627
|
// src/accounts/stv.ts
|
|
3074
3628
|
var import_web35 = require("@solana/web3.js");
|
|
3075
3629
|
var import_anchor3 = require("@coral-xyz/anchor");
|
|
3076
|
-
var STV_DATA_SIZE =
|
|
3630
|
+
var STV_DATA_SIZE = 200;
|
|
3077
3631
|
var STV_ACCOUNT_SIZE = 8 + STV_DATA_SIZE;
|
|
3078
3632
|
var STV_DISCRIMINATOR = Buffer.from([
|
|
3079
3633
|
214,
|
|
@@ -3118,6 +3672,18 @@ function parseStv(data) {
|
|
|
3118
3672
|
offset += 8;
|
|
3119
3673
|
const minDeposit = new import_anchor3.BN(data.subarray(offset, offset + 8), "le");
|
|
3120
3674
|
offset += 8;
|
|
3675
|
+
const requestedBase = new import_anchor3.BN(data.subarray(offset, offset + 8), "le");
|
|
3676
|
+
offset += 8;
|
|
3677
|
+
const reservedBase = new import_anchor3.BN(data.subarray(offset, offset + 8), "le");
|
|
3678
|
+
offset += 8;
|
|
3679
|
+
const epochPps = new import_anchor3.BN(data.subarray(offset, offset + 8), "le");
|
|
3680
|
+
offset += 8;
|
|
3681
|
+
const nextEpochTs = data.readUInt32LE(offset);
|
|
3682
|
+
offset += 4;
|
|
3683
|
+
const epochSec = data.readUInt32LE(offset);
|
|
3684
|
+
offset += 4;
|
|
3685
|
+
const currentEpochId = data.readUInt32LE(offset);
|
|
3686
|
+
offset += 4;
|
|
3121
3687
|
const mgmtFeeBps = data.readUInt16LE(offset);
|
|
3122
3688
|
offset += 2;
|
|
3123
3689
|
const perfFeeBps = data.readUInt16LE(offset);
|
|
@@ -3127,7 +3693,6 @@ function parseStv(data) {
|
|
|
3127
3693
|
const version = data.readUInt8(offset);
|
|
3128
3694
|
offset += 1;
|
|
3129
3695
|
const bump = data.readUInt8(offset);
|
|
3130
|
-
offset += 1;
|
|
3131
3696
|
return {
|
|
3132
3697
|
baseMint,
|
|
3133
3698
|
jlMint,
|
|
@@ -3139,6 +3704,12 @@ function parseStv(data) {
|
|
|
3139
3704
|
accruedFeesJlx,
|
|
3140
3705
|
maxDeposit,
|
|
3141
3706
|
minDeposit,
|
|
3707
|
+
requestedBase,
|
|
3708
|
+
reservedBase,
|
|
3709
|
+
epochPps,
|
|
3710
|
+
nextEpochTs,
|
|
3711
|
+
epochSec,
|
|
3712
|
+
currentEpochId,
|
|
3142
3713
|
mgmtFeeBps,
|
|
3143
3714
|
perfFeeBps,
|
|
3144
3715
|
flags,
|
|
@@ -3189,9 +3760,13 @@ var EXCHANGE_RATE_PRECISION_BI = BigInt(EXCHANGE_RATE_PRECISION);
|
|
|
3189
3760
|
var RETURN_PERCENT_PRECISION = EXCHANGE_RATE_PRECISION_BI * 100n;
|
|
3190
3761
|
var SECONDS_PER_YEAR = BigInt(365 * 24 * 60 * 60);
|
|
3191
3762
|
var MAX_REWARDS_RATE = 50n * EXCHANGE_RATE_PRECISION_BI;
|
|
3192
|
-
function calculateNav(stvBaseBalance, stvJlxBalance, exchangeRate, baseLoaned) {
|
|
3763
|
+
function calculateNav(stvBaseBalance, stvJlxBalance, exchangeRate, baseLoaned, reservedBase) {
|
|
3193
3764
|
const jlxValue = stvJlxBalance.mul(new import_anchor4.BN(exchangeRate.toString())).div(EXCHANGE_RATE_PRECISION_BN);
|
|
3194
|
-
|
|
3765
|
+
let nav = stvBaseBalance.add(jlxValue).add(baseLoaned);
|
|
3766
|
+
if (reservedBase && !reservedBase.isZero()) {
|
|
3767
|
+
nav = nav.sub(reservedBase);
|
|
3768
|
+
}
|
|
3769
|
+
return nav;
|
|
3195
3770
|
}
|
|
3196
3771
|
function calculatePps(nav, jvSupply) {
|
|
3197
3772
|
if (jvSupply.isZero()) {
|
|
@@ -3638,7 +4213,8 @@ async function createInitializeStvInstruction(program, params, accounts) {
|
|
|
3638
4213
|
mgmtFeeBps: params.mgmtFeeBps,
|
|
3639
4214
|
perfFeeBps: params.perfFeeBps,
|
|
3640
4215
|
maxDeposit: params.maxDeposit,
|
|
3641
|
-
minDeposit: params.minDeposit
|
|
4216
|
+
minDeposit: params.minDeposit,
|
|
4217
|
+
epochSec: params.epochSec
|
|
3642
4218
|
}).accounts({
|
|
3643
4219
|
admin: accounts.admin,
|
|
3644
4220
|
jlpVault: accounts.jlpVault,
|
|
@@ -3658,7 +4234,8 @@ async function createUpdateStvInstruction(program, params, accounts) {
|
|
|
3658
4234
|
jlMint: params.jlMint,
|
|
3659
4235
|
pps: params.pps,
|
|
3660
4236
|
hwm: params.hwm,
|
|
3661
|
-
baseLoaned: params.baseLoaned
|
|
4237
|
+
baseLoaned: params.baseLoaned,
|
|
4238
|
+
epochSec: params.epochSec
|
|
3662
4239
|
}).accounts({
|
|
3663
4240
|
admin: accounts.admin,
|
|
3664
4241
|
jlpVault: accounts.jlpVault,
|
|
@@ -3682,20 +4259,32 @@ async function createDepositInstruction(program, amount, accounts, remainingAcco
|
|
|
3682
4259
|
tokenProgram: accounts.tokenProgram
|
|
3683
4260
|
}).remainingAccounts(remainingAccounts).instruction();
|
|
3684
4261
|
}
|
|
3685
|
-
async function
|
|
3686
|
-
return await program.methods.
|
|
4262
|
+
async function createRequestWithdrawInstruction(program, params, accounts) {
|
|
4263
|
+
return await program.methods.requestWithdraw(params.shares, params.epochId).accounts({
|
|
3687
4264
|
user: accounts.user,
|
|
3688
4265
|
jlpVault: accounts.jlpVault,
|
|
3689
4266
|
stv: accounts.stv,
|
|
4267
|
+
jvMint: accounts.jvMint,
|
|
4268
|
+
userJvxAta: accounts.userJvxAta,
|
|
4269
|
+
withdrawRequest: accounts.withdrawRequest,
|
|
4270
|
+
requestJvxAta: accounts.requestJvxAta,
|
|
4271
|
+
tokenProgram: accounts.tokenProgram,
|
|
4272
|
+
associatedTokenProgram: accounts.associatedTokenProgram,
|
|
4273
|
+
systemProgram: accounts.systemProgram
|
|
4274
|
+
}).instruction();
|
|
4275
|
+
}
|
|
4276
|
+
async function createClaimWithdrawInstruction(program, accounts) {
|
|
4277
|
+
return await program.methods.claimWithdraw().accounts({
|
|
4278
|
+
user: accounts.user,
|
|
4279
|
+
stv: accounts.stv,
|
|
3690
4280
|
baseMint: accounts.baseMint,
|
|
3691
|
-
jlMint: accounts.jlMint,
|
|
3692
4281
|
jvMint: accounts.jvMint,
|
|
3693
4282
|
userBaseAta: accounts.userBaseAta,
|
|
3694
|
-
userJvxAta: accounts.userJvxAta,
|
|
3695
4283
|
stvBaseAta: accounts.stvBaseAta,
|
|
3696
|
-
|
|
4284
|
+
withdrawRequest: accounts.withdrawRequest,
|
|
4285
|
+
requestJvxAta: accounts.requestJvxAta,
|
|
3697
4286
|
tokenProgram: accounts.tokenProgram
|
|
3698
|
-
}).
|
|
4287
|
+
}).instruction();
|
|
3699
4288
|
}
|
|
3700
4289
|
|
|
3701
4290
|
// src/instructions/manager.ts
|
|
@@ -3737,24 +4326,6 @@ async function createMoveJlxInstruction(program, params, accounts, remainingAcco
|
|
|
3737
4326
|
tokenProgram: accounts.tokenProgram
|
|
3738
4327
|
}).remainingAccounts(remainingAccounts).instruction();
|
|
3739
4328
|
}
|
|
3740
|
-
async function createSwapJlxJlxInstruction(program, params, accounts, remainingAccounts = []) {
|
|
3741
|
-
return await program.methods.swapJlxJlx({
|
|
3742
|
-
fromIndex: params.fromIndex,
|
|
3743
|
-
toIndex: params.toIndex,
|
|
3744
|
-
amountIn: params.amountIn,
|
|
3745
|
-
minOut: params.minOut,
|
|
3746
|
-
jupiterData: params.jupiterData
|
|
3747
|
-
}).accounts({
|
|
3748
|
-
manager: accounts.manager,
|
|
3749
|
-
jlpVault: accounts.jlpVault,
|
|
3750
|
-
fromJlxMint: accounts.fromJlxMint,
|
|
3751
|
-
toJlxMint: accounts.toJlxMint,
|
|
3752
|
-
fromJlxAta: accounts.fromJlxAta,
|
|
3753
|
-
toJlxAta: accounts.toJlxAta,
|
|
3754
|
-
tokenProgram: accounts.tokenProgram,
|
|
3755
|
-
jupiterProgram: accounts.jupiterProgram
|
|
3756
|
-
}).remainingAccounts(remainingAccounts).instruction();
|
|
3757
|
-
}
|
|
3758
4329
|
async function createSwapJlxJlpInstruction(program, params, accounts, remainingAccounts = []) {
|
|
3759
4330
|
return await program.methods.swapJlxToFromJlp({
|
|
3760
4331
|
stvIndex: params.stvIndex,
|
|
@@ -3772,10 +4343,21 @@ async function createSwapJlxJlpInstruction(program, params, accounts, remainingA
|
|
|
3772
4343
|
jupiterProgram: accounts.jupiterProgram
|
|
3773
4344
|
}).remainingAccounts(remainingAccounts).instruction();
|
|
3774
4345
|
}
|
|
4346
|
+
async function createProcessEpochInstruction(program, accounts, remainingAccounts = []) {
|
|
4347
|
+
return await program.methods.processEpoch().accounts({
|
|
4348
|
+
payer: accounts.payer,
|
|
4349
|
+
jlpVault: accounts.jlpVault,
|
|
4350
|
+
stv: accounts.stv,
|
|
4351
|
+
baseMint: accounts.baseMint,
|
|
4352
|
+
jlMint: accounts.jlMint,
|
|
4353
|
+
jvMint: accounts.jvMint,
|
|
4354
|
+
stvBaseAta: accounts.stvBaseAta,
|
|
4355
|
+
stvJlxAta: accounts.stvJlxAta,
|
|
4356
|
+
tokenProgram: accounts.tokenProgram
|
|
4357
|
+
}).remainingAccounts(remainingAccounts).instruction();
|
|
4358
|
+
}
|
|
3775
4359
|
async function createSettleYieldInstruction(program, params, accounts, remainingAccounts = []) {
|
|
3776
|
-
return await program.methods.settleYield({
|
|
3777
|
-
jlpRate: params.jlpRate
|
|
3778
|
-
}).accounts({
|
|
4360
|
+
return await program.methods.settleYield().accounts({
|
|
3779
4361
|
jlpVault: accounts.jlpVault,
|
|
3780
4362
|
vaultJlpAta: accounts.vaultJlpAta,
|
|
3781
4363
|
stv0: accounts.stvBtc,
|
|
@@ -3791,7 +4373,8 @@ async function createSettleYieldInstruction(program, params, accounts, remaining
|
|
|
3791
4373
|
dovesBtcUsd: accounts.oracleBtc,
|
|
3792
4374
|
dovesEthUsd: accounts.oracleEth,
|
|
3793
4375
|
dovesSolUsd: accounts.oracleSol,
|
|
3794
|
-
|
|
4376
|
+
jlpPool: accounts.jlpPool,
|
|
4377
|
+
jlpMintAccount: accounts.jlpMintAccount,
|
|
3795
4378
|
manager: accounts.manager
|
|
3796
4379
|
}).remainingAccounts(remainingAccounts).instruction();
|
|
3797
4380
|
}
|
|
@@ -4062,8 +4645,8 @@ var PoolContext = class {
|
|
|
4062
4645
|
}).compileToV0Message();
|
|
4063
4646
|
return new import_web39.VersionedTransaction(message);
|
|
4064
4647
|
}
|
|
4065
|
-
//
|
|
4066
|
-
async
|
|
4648
|
+
// Request withdrawal: escrow jvX shares for the current epoch
|
|
4649
|
+
async requestWithdraw(params) {
|
|
4067
4650
|
if (params.shares.isZero() || params.shares.isNeg()) {
|
|
4068
4651
|
throw new JlpdClientError("Withdraw shares must be positive");
|
|
4069
4652
|
}
|
|
@@ -4072,28 +4655,66 @@ var PoolContext = class {
|
|
|
4072
4655
|
this.client.connection.getLatestBlockhash("confirmed")
|
|
4073
4656
|
]);
|
|
4074
4657
|
if (!stv) throw new JlpdClientError("STV not found");
|
|
4658
|
+
const epochId = stv.currentEpochId;
|
|
4659
|
+
const [withdrawRequestPda] = deriveWithdrawRequestPda(
|
|
4660
|
+
this.stvPda,
|
|
4661
|
+
params.user,
|
|
4662
|
+
epochId,
|
|
4663
|
+
this.client.programId
|
|
4664
|
+
);
|
|
4665
|
+
const requestJvxAta = (0, import_spl_token5.getAssociatedTokenAddressSync)(stv.jvMint, withdrawRequestPda, true);
|
|
4075
4666
|
const userAtas = deriveUserAtas(this.pool.mint, stv.jvMint, params.user);
|
|
4076
|
-
const
|
|
4077
|
-
const ix = await createWithdrawInstruction(
|
|
4667
|
+
const ix = await createRequestWithdrawInstruction(
|
|
4078
4668
|
this.client.program,
|
|
4079
|
-
params.shares,
|
|
4669
|
+
{ shares: params.shares, epochId },
|
|
4080
4670
|
{
|
|
4081
4671
|
user: params.user,
|
|
4082
4672
|
jlpVault: this.client.vaultPda,
|
|
4083
4673
|
stv: this.stvPda,
|
|
4674
|
+
jvMint: stv.jvMint,
|
|
4675
|
+
userJvxAta: userAtas.jvxAta,
|
|
4676
|
+
withdrawRequest: withdrawRequestPda,
|
|
4677
|
+
requestJvxAta,
|
|
4678
|
+
tokenProgram: import_spl_token5.TOKEN_PROGRAM_ID,
|
|
4679
|
+
associatedTokenProgram: import_spl_token5.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
4680
|
+
systemProgram: import_web39.SystemProgram.programId
|
|
4681
|
+
}
|
|
4682
|
+
);
|
|
4683
|
+
const message = new import_web39.TransactionMessage({
|
|
4684
|
+
payerKey: params.user,
|
|
4685
|
+
recentBlockhash: blockhash,
|
|
4686
|
+
instructions: [ix]
|
|
4687
|
+
}).compileToV0Message();
|
|
4688
|
+
return new import_web39.VersionedTransaction(message);
|
|
4689
|
+
}
|
|
4690
|
+
// Claim withdrawal: receive base tokens for a processed WithdrawRequest
|
|
4691
|
+
async claimWithdraw(params) {
|
|
4692
|
+
const [stv, { blockhash }] = await Promise.all([
|
|
4693
|
+
this.client.fetchStv(this.pool.mint),
|
|
4694
|
+
this.client.connection.getLatestBlockhash("confirmed")
|
|
4695
|
+
]);
|
|
4696
|
+
if (!stv) throw new JlpdClientError("STV not found");
|
|
4697
|
+
const [withdrawRequestPda] = deriveWithdrawRequestPda(
|
|
4698
|
+
this.stvPda,
|
|
4699
|
+
params.user,
|
|
4700
|
+
params.epochId,
|
|
4701
|
+
this.client.programId
|
|
4702
|
+
);
|
|
4703
|
+
const requestJvxAta = (0, import_spl_token5.getAssociatedTokenAddressSync)(stv.jvMint, withdrawRequestPda, true);
|
|
4704
|
+
const userAtas = deriveUserAtas(this.pool.mint, stv.jvMint, params.user);
|
|
4705
|
+
const ix = await createClaimWithdrawInstruction(
|
|
4706
|
+
this.client.program,
|
|
4707
|
+
{
|
|
4708
|
+
user: params.user,
|
|
4709
|
+
stv: this.stvPda,
|
|
4084
4710
|
baseMint: this.pool.mint,
|
|
4085
|
-
jlMint: this.pool.fTokenMint,
|
|
4086
4711
|
jvMint: stv.jvMint,
|
|
4087
4712
|
userBaseAta: userAtas.baseAta,
|
|
4088
|
-
userJvxAta: userAtas.jvxAta,
|
|
4089
4713
|
stvBaseAta: this.stvBaseAta,
|
|
4090
|
-
|
|
4714
|
+
withdrawRequest: withdrawRequestPda,
|
|
4715
|
+
requestJvxAta,
|
|
4091
4716
|
tokenProgram: import_spl_token5.TOKEN_PROGRAM_ID
|
|
4092
|
-
}
|
|
4093
|
-
erAccounts ? [
|
|
4094
|
-
{ pubkey: erAccounts.lending, isSigner: false, isWritable: false },
|
|
4095
|
-
{ pubkey: erAccounts.rewardsRateModel, isSigner: false, isWritable: false }
|
|
4096
|
-
] : []
|
|
4717
|
+
}
|
|
4097
4718
|
);
|
|
4098
4719
|
const message = new import_web39.TransactionMessage({
|
|
4099
4720
|
payerKey: params.user,
|
|
@@ -4197,7 +4818,8 @@ var PoolContext = class {
|
|
|
4197
4818
|
jlMint: params.jlMint ?? null,
|
|
4198
4819
|
pps: params.pps ?? null,
|
|
4199
4820
|
hwm: params.hwm ?? null,
|
|
4200
|
-
baseLoaned: params.baseLoaned ?? null
|
|
4821
|
+
baseLoaned: params.baseLoaned ?? null,
|
|
4822
|
+
epochSec: params.epochSec ?? null
|
|
4201
4823
|
},
|
|
4202
4824
|
{
|
|
4203
4825
|
admin: params.admin,
|
|
@@ -4284,83 +4906,6 @@ var SwapContext = class {
|
|
|
4284
4906
|
}).compileToV0Message(params.quote.addressLookupTables);
|
|
4285
4907
|
return new import_web39.VersionedTransaction(message);
|
|
4286
4908
|
}
|
|
4287
|
-
// Get a quote for jlX <-> jlX swap
|
|
4288
|
-
async quoteJlxJlx(params) {
|
|
4289
|
-
const fromPoolConfig = getPoolByName(params.fromPool);
|
|
4290
|
-
const toPoolConfig = getPoolByName(params.toPool);
|
|
4291
|
-
if (!fromPoolConfig) throw new JlpdClientError(`Unknown pool: ${params.fromPool}`);
|
|
4292
|
-
if (!toPoolConfig) throw new JlpdClientError(`Unknown pool: ${params.toPool}`);
|
|
4293
|
-
const inputMint = fromPoolConfig.fTokenMint;
|
|
4294
|
-
const outputMint = toPoolConfig.fTokenMint;
|
|
4295
|
-
const quote = await getJupiterQuote(
|
|
4296
|
-
inputMint,
|
|
4297
|
-
outputMint,
|
|
4298
|
-
BigInt(params.amountIn.toString()),
|
|
4299
|
-
params.slippageBps ?? 30,
|
|
4300
|
-
40,
|
|
4301
|
-
this.client.jupiterApiKey
|
|
4302
|
-
);
|
|
4303
|
-
const swapIxs = await getJupiterSwapInstructions(quote, this.client.vaultPda, this.client.jupiterApiKey);
|
|
4304
|
-
const remainingAccounts = parseSwapRemainingAccounts(swapIxs.swapInstruction);
|
|
4305
|
-
const alts = await fetchAddressLookupTables(
|
|
4306
|
-
this.client.connection,
|
|
4307
|
-
swapIxs.addressLookupTableAddresses
|
|
4308
|
-
);
|
|
4309
|
-
return {
|
|
4310
|
-
inputMint,
|
|
4311
|
-
outputMint,
|
|
4312
|
-
inAmount: new import_anchor6.BN(quote.inAmount),
|
|
4313
|
-
outAmount: new import_anchor6.BN(quote.outAmount),
|
|
4314
|
-
minOutAmount: new import_anchor6.BN(quote.otherAmountThreshold),
|
|
4315
|
-
priceImpactPct: parseFloat(quote.priceImpactPct),
|
|
4316
|
-
route: quote.routePlan.map((r) => r.swapInfo.label || "unknown"),
|
|
4317
|
-
jupiterData: Buffer.from(swapIxs.swapInstruction.data, "base64"),
|
|
4318
|
-
remainingAccounts,
|
|
4319
|
-
addressLookupTables: alts,
|
|
4320
|
-
computeUnitLimit: swapIxs.computeUnitLimit ?? 6e5
|
|
4321
|
-
};
|
|
4322
|
-
}
|
|
4323
|
-
// Build jlX <-> jlX swap transaction
|
|
4324
|
-
async swapJlxJlx(params) {
|
|
4325
|
-
const fromPoolConfig = getPoolByName(params.fromPool);
|
|
4326
|
-
const toPoolConfig = getPoolByName(params.toPool);
|
|
4327
|
-
if (!fromPoolConfig) throw new JlpdClientError(`Unknown pool: ${params.fromPool}`);
|
|
4328
|
-
if (!toPoolConfig) throw new JlpdClientError(`Unknown pool: ${params.toPool}`);
|
|
4329
|
-
const fromPoolCtx = this.client.pool(params.fromPool);
|
|
4330
|
-
const toPoolCtx = this.client.pool(params.toPool);
|
|
4331
|
-
const computeIx = import_web39.ComputeBudgetProgram.setComputeUnitLimit({
|
|
4332
|
-
units: params.quote.computeUnitLimit
|
|
4333
|
-
});
|
|
4334
|
-
const jupiterProgram = JUPITER_SWAP_PROGRAM_ID;
|
|
4335
|
-
const swapIx = await createSwapJlxJlxInstruction(
|
|
4336
|
-
this.client.program,
|
|
4337
|
-
{
|
|
4338
|
-
fromIndex: fromPoolConfig.stvIndex,
|
|
4339
|
-
toIndex: toPoolConfig.stvIndex,
|
|
4340
|
-
amountIn: params.amountIn,
|
|
4341
|
-
minOut: params.minOut,
|
|
4342
|
-
jupiterData: params.quote.jupiterData
|
|
4343
|
-
},
|
|
4344
|
-
{
|
|
4345
|
-
manager: params.manager,
|
|
4346
|
-
jlpVault: this.client.vaultPda,
|
|
4347
|
-
fromJlxMint: fromPoolConfig.fTokenMint,
|
|
4348
|
-
toJlxMint: toPoolConfig.fTokenMint,
|
|
4349
|
-
fromJlxAta: fromPoolCtx.vaultStagingAta,
|
|
4350
|
-
toJlxAta: toPoolCtx.vaultStagingAta,
|
|
4351
|
-
tokenProgram: import_spl_token5.TOKEN_PROGRAM_ID,
|
|
4352
|
-
jupiterProgram
|
|
4353
|
-
},
|
|
4354
|
-
params.quote.remainingAccounts
|
|
4355
|
-
);
|
|
4356
|
-
const { blockhash } = await this.client.connection.getLatestBlockhash("confirmed");
|
|
4357
|
-
const message = new import_web39.TransactionMessage({
|
|
4358
|
-
payerKey: params.manager,
|
|
4359
|
-
recentBlockhash: blockhash,
|
|
4360
|
-
instructions: [computeIx, swapIx]
|
|
4361
|
-
}).compileToV0Message(params.quote.addressLookupTables);
|
|
4362
|
-
return new import_web39.VersionedTransaction(message);
|
|
4363
|
-
}
|
|
4364
4909
|
};
|
|
4365
4910
|
var AdminContext = class {
|
|
4366
4911
|
constructor(client) {
|
|
@@ -4398,7 +4943,8 @@ var AdminContext = class {
|
|
|
4398
4943
|
mgmtFeeBps: params.mgmtFeeBps,
|
|
4399
4944
|
perfFeeBps: params.perfFeeBps,
|
|
4400
4945
|
maxDeposit: params.maxDeposit,
|
|
4401
|
-
minDeposit: params.minDeposit
|
|
4946
|
+
minDeposit: params.minDeposit,
|
|
4947
|
+
epochSec: params.withdrawEpochSec
|
|
4402
4948
|
},
|
|
4403
4949
|
{
|
|
4404
4950
|
admin: params.admin,
|
|
@@ -4411,6 +4957,46 @@ var AdminContext = class {
|
|
|
4411
4957
|
);
|
|
4412
4958
|
return this.client.buildTransaction(params.admin, [ix]);
|
|
4413
4959
|
}
|
|
4960
|
+
// Process epoch for a pool (manager operation)
|
|
4961
|
+
async processEpoch(params) {
|
|
4962
|
+
const pool = getPoolByName(params.poolName);
|
|
4963
|
+
if (!pool) throw new JlpdClientError(`Unknown pool: ${params.poolName}`);
|
|
4964
|
+
const [stvPda] = deriveStvPda(pool.mint, this.client.programId);
|
|
4965
|
+
const stv = await this.client.fetchStv(pool.mint);
|
|
4966
|
+
if (!stv) throw new JlpdClientError(`STV not found for pool: ${params.poolName}`);
|
|
4967
|
+
const stvAtas = deriveStvAtas(pool.mint, pool.fTokenMint, stvPda);
|
|
4968
|
+
const erAccounts = pool.hasJupiterLend ? buildExchangeRateAccounts(pool) : null;
|
|
4969
|
+
const remainingAccounts = [];
|
|
4970
|
+
if (erAccounts) {
|
|
4971
|
+
remainingAccounts.push(
|
|
4972
|
+
{ pubkey: erAccounts.lending, isSigner: false, isWritable: false },
|
|
4973
|
+
{ pubkey: erAccounts.rewardsRateModel, isSigner: false, isWritable: false }
|
|
4974
|
+
);
|
|
4975
|
+
}
|
|
4976
|
+
for (const wrPubkey of params.withdrawRequests) {
|
|
4977
|
+
const requestJvxAta = (0, import_spl_token5.getAssociatedTokenAddressSync)(stv.jvMint, wrPubkey, true);
|
|
4978
|
+
remainingAccounts.push(
|
|
4979
|
+
{ pubkey: wrPubkey, isSigner: false, isWritable: true },
|
|
4980
|
+
{ pubkey: requestJvxAta, isSigner: false, isWritable: true }
|
|
4981
|
+
);
|
|
4982
|
+
}
|
|
4983
|
+
const ix = await createProcessEpochInstruction(
|
|
4984
|
+
this.client.program,
|
|
4985
|
+
{
|
|
4986
|
+
payer: params.payer,
|
|
4987
|
+
jlpVault: this.client.vaultPda,
|
|
4988
|
+
stv: stvPda,
|
|
4989
|
+
baseMint: pool.mint,
|
|
4990
|
+
jlMint: pool.fTokenMint,
|
|
4991
|
+
jvMint: stv.jvMint,
|
|
4992
|
+
stvBaseAta: stvAtas.baseAta,
|
|
4993
|
+
stvJlxAta: stvAtas.jlxAta,
|
|
4994
|
+
tokenProgram: import_spl_token5.TOKEN_PROGRAM_ID
|
|
4995
|
+
},
|
|
4996
|
+
remainingAccounts
|
|
4997
|
+
);
|
|
4998
|
+
return this.client.buildTransaction(params.payer, [ix]);
|
|
4999
|
+
}
|
|
4414
5000
|
// Settle yield across all STVs
|
|
4415
5001
|
async settleYield(params) {
|
|
4416
5002
|
const poolNames = ["BTC", "ETH", "SOL", "USDC", "JupUSD"];
|
|
@@ -4441,7 +5027,7 @@ var AdminContext = class {
|
|
|
4441
5027
|
const remainingAccounts = [...lendingAccounts, ...rewardsAccounts, ...mintAccounts];
|
|
4442
5028
|
const ix = await createSettleYieldInstruction(
|
|
4443
5029
|
this.client.program,
|
|
4444
|
-
{
|
|
5030
|
+
{},
|
|
4445
5031
|
{
|
|
4446
5032
|
manager: params.manager,
|
|
4447
5033
|
jlpVault: this.client.vaultPda,
|
|
@@ -4460,13 +5046,58 @@ var AdminContext = class {
|
|
|
4460
5046
|
oracleBtc: ORACLES.DOVES_BTC_USD,
|
|
4461
5047
|
oracleEth: ORACLES.DOVES_ETH_USD,
|
|
4462
5048
|
oracleSol: ORACLES.DOVES_SOL_USD,
|
|
4463
|
-
|
|
5049
|
+
jlpPool: JLP_POOL_PUBKEY,
|
|
5050
|
+
jlpMintAccount: MINTS.JLP
|
|
4464
5051
|
},
|
|
4465
5052
|
remainingAccounts
|
|
4466
5053
|
);
|
|
4467
5054
|
return this.client.buildTransaction(params.manager, [ix]);
|
|
4468
5055
|
}
|
|
4469
5056
|
};
|
|
5057
|
+
|
|
5058
|
+
// src/accounts/withdraw_request.ts
|
|
5059
|
+
var import_web310 = require("@solana/web3.js");
|
|
5060
|
+
var import_anchor7 = require("@coral-xyz/anchor");
|
|
5061
|
+
var WITHDRAW_REQUEST_DATA_SIZE = 89;
|
|
5062
|
+
var WITHDRAW_REQUEST_ACCOUNT_SIZE = 8 + WITHDRAW_REQUEST_DATA_SIZE;
|
|
5063
|
+
var WITHDRAW_REQUEST_DISCRIMINATOR = Buffer.from([
|
|
5064
|
+
186,
|
|
5065
|
+
239,
|
|
5066
|
+
174,
|
|
5067
|
+
191,
|
|
5068
|
+
189,
|
|
5069
|
+
13,
|
|
5070
|
+
47,
|
|
5071
|
+
196
|
|
5072
|
+
]);
|
|
5073
|
+
function parseWithdrawRequest(data) {
|
|
5074
|
+
if (data.length < WITHDRAW_REQUEST_ACCOUNT_SIZE) {
|
|
5075
|
+
throw new Error(
|
|
5076
|
+
`Invalid WithdrawRequest data size: expected ${WITHDRAW_REQUEST_ACCOUNT_SIZE}, got ${data.length}`
|
|
5077
|
+
);
|
|
5078
|
+
}
|
|
5079
|
+
const discriminator = data.subarray(0, 8);
|
|
5080
|
+
if (!discriminator.equals(WITHDRAW_REQUEST_DISCRIMINATOR)) {
|
|
5081
|
+
throw new Error(
|
|
5082
|
+
`Invalid WithdrawRequest discriminator: expected ${WITHDRAW_REQUEST_DISCRIMINATOR.toString("hex")}, got ${discriminator.toString("hex")}`
|
|
5083
|
+
);
|
|
5084
|
+
}
|
|
5085
|
+
let offset = 8;
|
|
5086
|
+
const stv = new import_web310.PublicKey(data.subarray(offset, offset + 32));
|
|
5087
|
+
offset += 32;
|
|
5088
|
+
const user = new import_web310.PublicKey(data.subarray(offset, offset + 32));
|
|
5089
|
+
offset += 32;
|
|
5090
|
+
const shares = new import_anchor7.BN(data.subarray(offset, offset + 8), "le");
|
|
5091
|
+
offset += 8;
|
|
5092
|
+
const pps = new import_anchor7.BN(data.subarray(offset, offset + 8), "le");
|
|
5093
|
+
offset += 8;
|
|
5094
|
+
const epochId = data.readUInt32LE(offset);
|
|
5095
|
+
offset += 4;
|
|
5096
|
+
const claimAvailableAfter = data.readUInt32LE(offset);
|
|
5097
|
+
offset += 4;
|
|
5098
|
+
const bump = data.readUInt8(offset);
|
|
5099
|
+
return { stv, user, shares, pps, epochId, claimAvailableAfter, bump };
|
|
5100
|
+
}
|
|
4470
5101
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4471
5102
|
0 && (module.exports = {
|
|
4472
5103
|
AdminContext,
|
|
@@ -4477,10 +5108,12 @@ var AdminContext = class {
|
|
|
4477
5108
|
FLAG_REBALANCE_DISABLED,
|
|
4478
5109
|
FLAG_WITHDRAWALS_DISABLED,
|
|
4479
5110
|
JLPD_PROGRAM_ID,
|
|
5111
|
+
JLP_POOL_PUBKEY,
|
|
4480
5112
|
JLP_VAULT_ACCOUNT_SIZE,
|
|
4481
5113
|
JLP_VAULT_DATA_SIZE,
|
|
4482
5114
|
JLP_VAULT_DISCRIMINATOR,
|
|
4483
5115
|
JUPITER_LEND_PROGRAM_ID,
|
|
5116
|
+
JUPITER_PERPS_PROGRAM_ID,
|
|
4484
5117
|
JUPITER_SWAP_PROGRAM_ID,
|
|
4485
5118
|
JUPUSD_POOL,
|
|
4486
5119
|
JUP_LEND_PROGRAM_ID,
|
|
@@ -4496,6 +5129,7 @@ var AdminContext = class {
|
|
|
4496
5129
|
PoolContext,
|
|
4497
5130
|
SEED_JLP_VAULT,
|
|
4498
5131
|
SEED_STV,
|
|
5132
|
+
SEED_WITHDRAW_REQUEST,
|
|
4499
5133
|
STV_ACCOUNT_SIZE,
|
|
4500
5134
|
STV_DATA_SIZE,
|
|
4501
5135
|
STV_DISCRIMINATOR,
|
|
@@ -4504,6 +5138,9 @@ var AdminContext = class {
|
|
|
4504
5138
|
USDC_POOL,
|
|
4505
5139
|
WBTC_POOL,
|
|
4506
5140
|
WETH_POOL,
|
|
5141
|
+
WITHDRAW_REQUEST_ACCOUNT_SIZE,
|
|
5142
|
+
WITHDRAW_REQUEST_DATA_SIZE,
|
|
5143
|
+
WITHDRAW_REQUEST_DISCRIMINATOR,
|
|
4507
5144
|
WSOL_POOL,
|
|
4508
5145
|
baseToJlx,
|
|
4509
5146
|
baseToShares,
|
|
@@ -4517,23 +5154,25 @@ var AdminContext = class {
|
|
|
4517
5154
|
clearAtaCache,
|
|
4518
5155
|
clearPdaCache,
|
|
4519
5156
|
createClaimFeesInstruction,
|
|
5157
|
+
createClaimWithdrawInstruction,
|
|
4520
5158
|
createDepositInstruction,
|
|
4521
5159
|
createInitOrUpdateVaultInstruction,
|
|
4522
5160
|
createInitializeStvInstruction,
|
|
4523
5161
|
createJupEarnInstruction,
|
|
4524
5162
|
createMoveJlxInstruction,
|
|
5163
|
+
createProcessEpochInstruction,
|
|
4525
5164
|
createProgram,
|
|
5165
|
+
createRequestWithdrawInstruction,
|
|
4526
5166
|
createSettleYieldInstruction,
|
|
4527
5167
|
createSwapJlxJlpInstruction,
|
|
4528
|
-
createSwapJlxJlxInstruction,
|
|
4529
5168
|
createUpdateStvInstruction,
|
|
4530
|
-
createWithdrawInstruction,
|
|
4531
5169
|
deriveAta,
|
|
4532
5170
|
deriveStvAtas,
|
|
4533
5171
|
deriveStvPda,
|
|
4534
5172
|
deriveUserAtas,
|
|
4535
5173
|
deriveVaultAtas,
|
|
4536
5174
|
deriveVaultPda,
|
|
5175
|
+
deriveWithdrawRequestPda,
|
|
4537
5176
|
fetchAddressLookupTables,
|
|
4538
5177
|
fetchJlpRate,
|
|
4539
5178
|
fetchJupiterPriceUsd,
|
|
@@ -4547,5 +5186,6 @@ var AdminContext = class {
|
|
|
4547
5186
|
parseStv,
|
|
4548
5187
|
parseSwapRemainingAccounts,
|
|
4549
5188
|
parseVault,
|
|
5189
|
+
parseWithdrawRequest,
|
|
4550
5190
|
sharesToBase
|
|
4551
5191
|
});
|