@perena/vault-sdk 1.0.49 → 1.0.52
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/README.md +4 -3
- package/dist/browser/nest.d.mts +26 -1
- package/dist/browser/nest.mjs +195 -17
- package/dist/index.d.ts +364 -16
- package/dist/index.js +1644 -902
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -149,7 +149,7 @@ var require_compat = __commonJS({
|
|
|
149
149
|
exports2.fromWeb3PublicKey = fromWeb3PublicKey;
|
|
150
150
|
exports2.toWeb3PublicKey = toWeb3PublicKey;
|
|
151
151
|
exports2.asWeb3PublicKey = asWeb3PublicKey2;
|
|
152
|
-
exports2.toKitInstruction =
|
|
152
|
+
exports2.toKitInstruction = toKitInstruction37;
|
|
153
153
|
exports2.fromKitInstruction = fromKitInstruction3;
|
|
154
154
|
var kit_1 = require("@solana/kit");
|
|
155
155
|
var web3_js_1 = require("@solana/web3.js");
|
|
@@ -165,7 +165,7 @@ var require_compat = __commonJS({
|
|
|
165
165
|
exports2.toAddress = fromWeb3PublicKey;
|
|
166
166
|
exports2.fromWeb3Pk = fromWeb3PublicKey;
|
|
167
167
|
exports2.toWeb3Pk = toWeb3PublicKey;
|
|
168
|
-
function
|
|
168
|
+
function toKitInstruction37(ix) {
|
|
169
169
|
return {
|
|
170
170
|
programAddress: ix.programId.toBase58(),
|
|
171
171
|
data: new Uint8Array(ix.data),
|
|
@@ -194,10 +194,10 @@ var require_ata = __commonJS({
|
|
|
194
194
|
"../common/dist/utils/accounts/ata.js"(exports2) {
|
|
195
195
|
"use strict";
|
|
196
196
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
197
|
-
exports2.getAtaAddress =
|
|
197
|
+
exports2.getAtaAddress = getAtaAddress21;
|
|
198
198
|
var spl_token_1 = require("@solana/spl-token");
|
|
199
199
|
var compat_1 = require_compat();
|
|
200
|
-
function
|
|
200
|
+
function getAtaAddress21(mint, owner, tokenProgram, allowOwnerOffCurve = true) {
|
|
201
201
|
const ata = (0, spl_token_1.getAssociatedTokenAddressSync)((0, compat_1.toWeb3PublicKey)(mint), (0, compat_1.toWeb3PublicKey)(owner), allowOwnerOffCurve, (0, compat_1.toWeb3PublicKey)(tokenProgram), spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
|
|
202
202
|
return ata.toBase58();
|
|
203
203
|
}
|
|
@@ -253,9 +253,9 @@ var require_meta = __commonJS({
|
|
|
253
253
|
exports2.toCustomAccountMeta = toCustomAccountMeta;
|
|
254
254
|
exports2.toCustomAccountMetaFromWeb3AccountMeta = toCustomAccountMetaFromWeb3AccountMeta;
|
|
255
255
|
var roles_1 = require_roles();
|
|
256
|
-
function toCustomAccountMeta(
|
|
256
|
+
function toCustomAccountMeta(address16, isWritable, requiredAtaDetails, isSigner) {
|
|
257
257
|
const role = (0, roles_1.getAccountRole)(isWritable ?? false, isSigner ?? false);
|
|
258
|
-
return { address:
|
|
258
|
+
return { address: address16, role, isRequiredAta: requiredAtaDetails };
|
|
259
259
|
}
|
|
260
260
|
function toCustomAccountMetaFromWeb3AccountMeta(web3AccountMeta) {
|
|
261
261
|
return toCustomAccountMeta(web3AccountMeta.pubkey.toBase58(), web3AccountMeta.isWritable, void 0, web3AccountMeta.isSigner);
|
|
@@ -1236,8 +1236,8 @@ var require_cpiClient = __commonJS({
|
|
|
1236
1236
|
var kit_1 = require("@solana/kit");
|
|
1237
1237
|
var common_1 = require_dist();
|
|
1238
1238
|
var constants_1 = require_constants3();
|
|
1239
|
-
function account(
|
|
1240
|
-
return { address:
|
|
1239
|
+
function account(address16, role) {
|
|
1240
|
+
return { address: address16, role };
|
|
1241
1241
|
}
|
|
1242
1242
|
function requiredAddress(value, label) {
|
|
1243
1243
|
if (!value) {
|
|
@@ -1326,7 +1326,7 @@ var require_cpiClient = __commonJS({
|
|
|
1326
1326
|
});
|
|
1327
1327
|
const bankAndOracleRemainingAccounts = [
|
|
1328
1328
|
account(this.accounts.bank, kit_1.AccountRole.READONLY),
|
|
1329
|
-
...this.accounts.oracleAccounts.map((
|
|
1329
|
+
...this.accounts.oracleAccounts.map((address16) => account(address16, kit_1.AccountRole.READONLY))
|
|
1330
1330
|
];
|
|
1331
1331
|
return {
|
|
1332
1332
|
cpiType: params.cpiType ?? common_1.CpiTypes.MARGINFI_WITHDRAW,
|
|
@@ -1391,13 +1391,13 @@ var require_positions = __commonJS({
|
|
|
1391
1391
|
"../../node_modules/.pnpm/marginfi@file+typescript+marginfi_bufferutil@4.1.0_fastestsmallesttextencoderdecoder@1._7432de83e22e4bcea0493cabf074a552/node_modules/marginfi/dist/positions.js"(exports2) {
|
|
1392
1392
|
"use strict";
|
|
1393
1393
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1394
|
-
exports2.parseBankPksFromMarginfiAccount =
|
|
1395
|
-
exports2.createMarginfiReadClient =
|
|
1394
|
+
exports2.parseBankPksFromMarginfiAccount = parseBankPksFromMarginfiAccount4;
|
|
1395
|
+
exports2.createMarginfiReadClient = createMarginfiReadClient4;
|
|
1396
1396
|
exports2.readMarginfiBankBalance = readMarginfiBankBalance2;
|
|
1397
1397
|
exports2.readAllMarginfiBalances = readAllMarginfiBalances2;
|
|
1398
1398
|
var web3_js_1 = require("@solana/web3.js");
|
|
1399
1399
|
var marginfi_client_v2_1 = require("@mrgnlabs/marginfi-client-v2");
|
|
1400
|
-
function
|
|
1400
|
+
function parseBankPksFromMarginfiAccount4(data) {
|
|
1401
1401
|
const DISCRIMINATOR = 8;
|
|
1402
1402
|
const LENDING_ACCOUNT_OFFSET = DISCRIMINATOR + 32 + 32;
|
|
1403
1403
|
const BALANCE_SIZE = 104;
|
|
@@ -1414,7 +1414,7 @@ var require_positions = __commonJS({
|
|
|
1414
1414
|
}
|
|
1415
1415
|
return out;
|
|
1416
1416
|
}
|
|
1417
|
-
async function
|
|
1417
|
+
async function createMarginfiReadClient4(connection, preloadedBankAddresses = []) {
|
|
1418
1418
|
return marginfi_client_v2_1.MarginfiClient.fetch((0, marginfi_client_v2_1.getConfig)("production"), void 0, connection, {
|
|
1419
1419
|
preloadedBankAddresses,
|
|
1420
1420
|
// Balance readers use on-chain shares and bank addresses, not metadata.
|
|
@@ -2978,12 +2978,12 @@ var require_routePreInstructions = __commonJS({
|
|
|
2978
2978
|
if (existingAta.value) {
|
|
2979
2979
|
continue;
|
|
2980
2980
|
}
|
|
2981
|
-
instructions2.push(
|
|
2981
|
+
instructions2.push(toKitInstruction37((0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(new web3_js_1.PublicKey(payer), new web3_js_1.PublicKey(ata), new web3_js_1.PublicKey(user), new web3_js_1.PublicKey(mint), new web3_js_1.PublicKey(tokenProgram), spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID)));
|
|
2982
2982
|
postSuccessCacheInvalidations.push({ address: ata });
|
|
2983
2983
|
}
|
|
2984
2984
|
return { instructions: instructions2, postSuccessCacheInvalidations };
|
|
2985
2985
|
}
|
|
2986
|
-
function
|
|
2986
|
+
function toKitInstruction37(ix) {
|
|
2987
2987
|
return {
|
|
2988
2988
|
programAddress: ix.programId.toBase58(),
|
|
2989
2989
|
accounts: ix.keys.map((account) => ({
|
|
@@ -3302,7 +3302,7 @@ __export(index_exports, {
|
|
|
3302
3302
|
DEFAULT_JUNIOR_WITHDRAWAL_LOCKUP_SECS: () => DEFAULT_JUNIOR_WITHDRAWAL_LOCKUP_SECS,
|
|
3303
3303
|
DEFAULT_MAX_ACCEPTABLE_APY_BPS: () => DEFAULT_MAX_ACCEPTABLE_APY_BPS,
|
|
3304
3304
|
DEFAULT_MAX_ACCOUNTS: () => DEFAULT_MAX_ACCOUNTS,
|
|
3305
|
-
DEFAULT_MINTS: () =>
|
|
3305
|
+
DEFAULT_MINTS: () => import_common63.DEFAULT_MINTS,
|
|
3306
3306
|
DEFAULT_MIN_AMOUNT_UI: () => DEFAULT_MIN_AMOUNT_UI,
|
|
3307
3307
|
DEFAULT_ORACLE_STALENESS_THRESHOLD_SECS: () => DEFAULT_ORACLE_STALENESS_THRESHOLD_SECS,
|
|
3308
3308
|
DEFAULT_PRICE_ORACLE_ACCOUNT: () => DEFAULT_PRICE_ORACLE_ACCOUNT,
|
|
@@ -3311,7 +3311,9 @@ __export(index_exports, {
|
|
|
3311
3311
|
DEFAULT_REBALANCE_BAND_BPS: () => DEFAULT_REBALANCE_BAND_BPS,
|
|
3312
3312
|
DEFAULT_SLIPPAGE_BPS: () => DEFAULT_SLIPPAGE_BPS,
|
|
3313
3313
|
DEFAULT_TARGET_LOCAL_BPS: () => DEFAULT_TARGET_LOCAL_BPS,
|
|
3314
|
+
DEFAULT_TARGET_LOCAL_USDC_TVL_BPS: () => DEFAULT_TARGET_LOCAL_USDC_TVL_BPS,
|
|
3314
3315
|
DEFAULT_VAULT_ID: () => DEFAULT_VAULT_ID,
|
|
3316
|
+
DepositCuratorFeesBuilder: () => DepositCuratorFeesBuilder,
|
|
3315
3317
|
DisableCircuitBreakerBuilder: () => DisableCircuitBreakerBuilder,
|
|
3316
3318
|
DistributeIncentiveBuilder: () => DistributeIncentiveBuilder,
|
|
3317
3319
|
DistributeIncentiveV3Builder: () => DistributeIncentiveV3Builder,
|
|
@@ -3341,6 +3343,7 @@ __export(index_exports, {
|
|
|
3341
3343
|
MANAGER_WALLET_NAV_DROP_TRIGGER_BPS: () => MANAGER_WALLET_NAV_DROP_TRIGGER_BPS,
|
|
3342
3344
|
MANAGER_WALLET_NAV_TOLERANCE_BPS: () => MANAGER_WALLET_NAV_TOLERANCE_BPS,
|
|
3343
3345
|
MAX_APY_ANCHOR_WINDOW_SECS: () => MAX_APY_ANCHOR_WINDOW_SECS,
|
|
3346
|
+
MAX_APY_PREVIOUS_ANCHOR_AGE_SECS: () => MAX_APY_PREVIOUS_ANCHOR_AGE_SECS,
|
|
3344
3347
|
MAX_BALANCE_CHANGE_BPS: () => MAX_BALANCE_CHANGE_BPS,
|
|
3345
3348
|
MAX_CONSENSUS_SIGNERS: () => MAX_CONSENSUS_SIGNERS,
|
|
3346
3349
|
MAX_INCENTIVE_RECIPIENTS: () => MAX_INCENTIVE_RECIPIENTS,
|
|
@@ -3351,7 +3354,7 @@ __export(index_exports, {
|
|
|
3351
3354
|
ManagerRedepositAssetBuilder: () => ManagerRedepositAssetBuilder,
|
|
3352
3355
|
ManagerWithdrawAssetBuilder: () => ManagerWithdrawAssetBuilder,
|
|
3353
3356
|
MarginfiPositionProvider: () => MarginfiPositionProvider,
|
|
3354
|
-
MintRegistry: () =>
|
|
3357
|
+
MintRegistry: () => import_common63.MintRegistry,
|
|
3355
3358
|
MockYieldTracker: () => MockYieldTracker,
|
|
3356
3359
|
NEST_API_BASE_URL: () => import_nest2.NEST_API_BASE_URL,
|
|
3357
3360
|
NEST_RWA_SHARE_MINT: () => NEST_RWA_SHARE_MINT,
|
|
@@ -3373,6 +3376,7 @@ __export(index_exports, {
|
|
|
3373
3376
|
ReportIncentiveV3Builder: () => ReportIncentiveV3Builder,
|
|
3374
3377
|
RequestJuniorTrancheWithdrawBuilder: () => RequestJuniorTrancheWithdrawBuilder,
|
|
3375
3378
|
RpcManagerWalletBalanceSource: () => RpcManagerWalletBalanceSource,
|
|
3379
|
+
RpcMpcWalletBalanceSource: () => RpcMpcWalletBalanceSource,
|
|
3376
3380
|
SHARE_DECIMALS: () => SHARE_DECIMALS,
|
|
3377
3381
|
SYSTEM_PROGRAM: () => SYSTEM_PROGRAM,
|
|
3378
3382
|
SetAssetPriceOracleBuilder: () => SetAssetPriceOracleBuilder,
|
|
@@ -3412,6 +3416,7 @@ __export(index_exports, {
|
|
|
3412
3416
|
VaultClient: () => VaultClient,
|
|
3413
3417
|
VaultQuoteClient: () => VaultQuoteClient,
|
|
3414
3418
|
VaultReallocationBuilder: () => VaultReallocationBuilder,
|
|
3419
|
+
WITHDRAWABLE_RESERVE_FLOOR_BPS: () => WITHDRAWABLE_RESERVE_FLOOR_BPS,
|
|
3415
3420
|
WithdrawalQueueService: () => WithdrawalQueueService,
|
|
3416
3421
|
accountingUnitPriceToUsd: () => accountingUnitPriceToUsd,
|
|
3417
3422
|
addCashflowUpdate: () => addCashflowUpdate,
|
|
@@ -3421,6 +3426,7 @@ __export(index_exports, {
|
|
|
3421
3426
|
assertNoUnconfirmedYieldPayments: () => assertNoUnconfirmedYieldPayments,
|
|
3422
3427
|
buildHoldingUpdate: () => buildHoldingUpdate,
|
|
3423
3428
|
buildMarginfiWithdrawInteraction: () => buildMarginfiWithdrawInteraction,
|
|
3429
|
+
buildNestDepositRequest: () => buildNestDepositRequest,
|
|
3424
3430
|
buildNestWithdrawalRequest: () => buildNestWithdrawalRequest,
|
|
3425
3431
|
buildUpdates: () => buildUpdates,
|
|
3426
3432
|
candidateGrossNav: () => candidateGrossNav,
|
|
@@ -3435,6 +3441,7 @@ __export(index_exports, {
|
|
|
3435
3441
|
createVaultClient: () => createVaultClient,
|
|
3436
3442
|
createYieldPayment: () => createYieldPayment,
|
|
3437
3443
|
dateToStr: () => dateToStr,
|
|
3444
|
+
decodeNestDepositRequest: () => decodeNestDepositRequest,
|
|
3438
3445
|
decodeNestWithdrawalRequest: () => decodeNestWithdrawalRequest,
|
|
3439
3446
|
decodePendingConsensusSigners: () => decodePendingConsensusSigners,
|
|
3440
3447
|
defaultKeypairPath: () => defaultKeypairPath,
|
|
@@ -3484,7 +3491,7 @@ __export(index_exports, {
|
|
|
3484
3491
|
makeProvider: () => makeProvider,
|
|
3485
3492
|
managerReconciliationStateKey: () => managerReconciliationStateKey,
|
|
3486
3493
|
mintTokensTo: () => mintTokensTo,
|
|
3487
|
-
mints: () =>
|
|
3494
|
+
mints: () => import_common63.mints,
|
|
3488
3495
|
mostFrequent: () => mostFrequent,
|
|
3489
3496
|
parseExternalLiquidityRefs: () => parseExternalLiquidityRefs,
|
|
3490
3497
|
planRebalance: () => planRebalance,
|
|
@@ -3586,16 +3593,16 @@ var USD_STAR_PRINCIPAL_MINT = (0, import_kit.address)(
|
|
|
3586
3593
|
var import_fs = __toESM(require("fs"));
|
|
3587
3594
|
var import_os = __toESM(require("os"));
|
|
3588
3595
|
var import_path = __toESM(require("path"));
|
|
3589
|
-
var
|
|
3590
|
-
var
|
|
3596
|
+
var import_core21 = require("@anchor-lang/core");
|
|
3597
|
+
var import_web324 = require("@solana/web3.js");
|
|
3591
3598
|
var import_kit10 = require("@solana/kit");
|
|
3592
|
-
var
|
|
3599
|
+
var import_common44 = __toESM(require_dist());
|
|
3593
3600
|
|
|
3594
3601
|
// src/client/client.ts
|
|
3595
|
-
var
|
|
3602
|
+
var import_core20 = require("@anchor-lang/core");
|
|
3596
3603
|
var import_kit9 = require("@solana/kit");
|
|
3597
|
-
var
|
|
3598
|
-
var
|
|
3604
|
+
var import_web323 = require("@solana/web3.js");
|
|
3605
|
+
var import_common43 = __toESM(require_dist());
|
|
3599
3606
|
|
|
3600
3607
|
// src/idl/vault.ts
|
|
3601
3608
|
var IDL = {
|
|
@@ -4446,6 +4453,184 @@ var IDL = {
|
|
|
4446
4453
|
}
|
|
4447
4454
|
]
|
|
4448
4455
|
},
|
|
4456
|
+
{
|
|
4457
|
+
name: "deposit_curator_fees",
|
|
4458
|
+
discriminator: [180, 215, 34, 119, 191, 100, 32, 220],
|
|
4459
|
+
accounts: [
|
|
4460
|
+
{
|
|
4461
|
+
name: "curator",
|
|
4462
|
+
docs: [
|
|
4463
|
+
"May also be a curator PDA signing through CPI (for example Squads)."
|
|
4464
|
+
],
|
|
4465
|
+
writable: true,
|
|
4466
|
+
signer: true
|
|
4467
|
+
},
|
|
4468
|
+
{
|
|
4469
|
+
name: "vault",
|
|
4470
|
+
writable: true
|
|
4471
|
+
},
|
|
4472
|
+
{
|
|
4473
|
+
name: "vault_oracle",
|
|
4474
|
+
writable: true
|
|
4475
|
+
},
|
|
4476
|
+
{
|
|
4477
|
+
name: "share_mint"
|
|
4478
|
+
},
|
|
4479
|
+
{
|
|
4480
|
+
name: "vault_tranche_state",
|
|
4481
|
+
writable: true,
|
|
4482
|
+
optional: true
|
|
4483
|
+
},
|
|
4484
|
+
{
|
|
4485
|
+
name: "junior_tranche_share_mint",
|
|
4486
|
+
optional: true
|
|
4487
|
+
},
|
|
4488
|
+
{
|
|
4489
|
+
name: "senior_tranche_share_mint",
|
|
4490
|
+
optional: true
|
|
4491
|
+
},
|
|
4492
|
+
{
|
|
4493
|
+
name: "usdc_mint",
|
|
4494
|
+
address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
|
|
4495
|
+
},
|
|
4496
|
+
{
|
|
4497
|
+
name: "curator_usdc_ata",
|
|
4498
|
+
writable: true,
|
|
4499
|
+
pda: {
|
|
4500
|
+
seeds: [
|
|
4501
|
+
{
|
|
4502
|
+
kind: "account",
|
|
4503
|
+
path: "curator"
|
|
4504
|
+
},
|
|
4505
|
+
{
|
|
4506
|
+
kind: "account",
|
|
4507
|
+
path: "token_program"
|
|
4508
|
+
},
|
|
4509
|
+
{
|
|
4510
|
+
kind: "account",
|
|
4511
|
+
path: "usdc_mint"
|
|
4512
|
+
}
|
|
4513
|
+
],
|
|
4514
|
+
program: {
|
|
4515
|
+
kind: "const",
|
|
4516
|
+
value: [
|
|
4517
|
+
140,
|
|
4518
|
+
151,
|
|
4519
|
+
37,
|
|
4520
|
+
143,
|
|
4521
|
+
78,
|
|
4522
|
+
36,
|
|
4523
|
+
137,
|
|
4524
|
+
241,
|
|
4525
|
+
187,
|
|
4526
|
+
61,
|
|
4527
|
+
16,
|
|
4528
|
+
41,
|
|
4529
|
+
20,
|
|
4530
|
+
142,
|
|
4531
|
+
13,
|
|
4532
|
+
131,
|
|
4533
|
+
11,
|
|
4534
|
+
90,
|
|
4535
|
+
19,
|
|
4536
|
+
153,
|
|
4537
|
+
218,
|
|
4538
|
+
255,
|
|
4539
|
+
16,
|
|
4540
|
+
132,
|
|
4541
|
+
4,
|
|
4542
|
+
142,
|
|
4543
|
+
123,
|
|
4544
|
+
216,
|
|
4545
|
+
219,
|
|
4546
|
+
233,
|
|
4547
|
+
248,
|
|
4548
|
+
89
|
|
4549
|
+
]
|
|
4550
|
+
}
|
|
4551
|
+
}
|
|
4552
|
+
},
|
|
4553
|
+
{
|
|
4554
|
+
name: "vault_usdc_ata",
|
|
4555
|
+
writable: true,
|
|
4556
|
+
pda: {
|
|
4557
|
+
seeds: [
|
|
4558
|
+
{
|
|
4559
|
+
kind: "account",
|
|
4560
|
+
path: "vault"
|
|
4561
|
+
},
|
|
4562
|
+
{
|
|
4563
|
+
kind: "account",
|
|
4564
|
+
path: "token_program"
|
|
4565
|
+
},
|
|
4566
|
+
{
|
|
4567
|
+
kind: "account",
|
|
4568
|
+
path: "usdc_mint"
|
|
4569
|
+
}
|
|
4570
|
+
],
|
|
4571
|
+
program: {
|
|
4572
|
+
kind: "const",
|
|
4573
|
+
value: [
|
|
4574
|
+
140,
|
|
4575
|
+
151,
|
|
4576
|
+
37,
|
|
4577
|
+
143,
|
|
4578
|
+
78,
|
|
4579
|
+
36,
|
|
4580
|
+
137,
|
|
4581
|
+
241,
|
|
4582
|
+
187,
|
|
4583
|
+
61,
|
|
4584
|
+
16,
|
|
4585
|
+
41,
|
|
4586
|
+
20,
|
|
4587
|
+
142,
|
|
4588
|
+
13,
|
|
4589
|
+
131,
|
|
4590
|
+
11,
|
|
4591
|
+
90,
|
|
4592
|
+
19,
|
|
4593
|
+
153,
|
|
4594
|
+
218,
|
|
4595
|
+
255,
|
|
4596
|
+
16,
|
|
4597
|
+
132,
|
|
4598
|
+
4,
|
|
4599
|
+
142,
|
|
4600
|
+
123,
|
|
4601
|
+
216,
|
|
4602
|
+
219,
|
|
4603
|
+
233,
|
|
4604
|
+
248,
|
|
4605
|
+
89
|
|
4606
|
+
]
|
|
4607
|
+
}
|
|
4608
|
+
}
|
|
4609
|
+
},
|
|
4610
|
+
{
|
|
4611
|
+
name: "token_program",
|
|
4612
|
+
address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
|
|
4613
|
+
},
|
|
4614
|
+
{
|
|
4615
|
+
name: "associated_token_program",
|
|
4616
|
+
address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
|
4617
|
+
},
|
|
4618
|
+
{
|
|
4619
|
+
name: "system_program",
|
|
4620
|
+
address: "11111111111111111111111111111111"
|
|
4621
|
+
}
|
|
4622
|
+
],
|
|
4623
|
+
args: [
|
|
4624
|
+
{
|
|
4625
|
+
name: "args",
|
|
4626
|
+
type: {
|
|
4627
|
+
defined: {
|
|
4628
|
+
name: "DepositCuratorFeesArgs"
|
|
4629
|
+
}
|
|
4630
|
+
}
|
|
4631
|
+
}
|
|
4632
|
+
]
|
|
4633
|
+
},
|
|
4449
4634
|
{
|
|
4450
4635
|
name: "disable_circuit_breaker",
|
|
4451
4636
|
discriminator: [200, 37, 34, 37, 19, 156, 178, 253],
|
|
@@ -10004,6 +10189,10 @@ var IDL = {
|
|
|
10004
10189
|
}
|
|
10005
10190
|
],
|
|
10006
10191
|
events: [
|
|
10192
|
+
{
|
|
10193
|
+
name: "CuratorFeesDeposited",
|
|
10194
|
+
discriminator: [61, 40, 69, 224, 253, 73, 224, 46]
|
|
10195
|
+
},
|
|
10007
10196
|
{
|
|
10008
10197
|
name: "IncentiveClaimed",
|
|
10009
10198
|
discriminator: [93, 82, 106, 244, 88, 183, 241, 75]
|
|
@@ -10042,6 +10231,11 @@ var IDL = {
|
|
|
10042
10231
|
}
|
|
10043
10232
|
],
|
|
10044
10233
|
errors: [
|
|
10234
|
+
{
|
|
10235
|
+
code: 13048,
|
|
10236
|
+
name: "MinimumCuratorFeeSharesNotMet",
|
|
10237
|
+
msg: "Deposited USDC credits fewer curator shares than the requested minimum"
|
|
10238
|
+
},
|
|
10045
10239
|
{
|
|
10046
10240
|
code: 14001,
|
|
10047
10241
|
name: "Unauthorized",
|
|
@@ -10616,6 +10810,56 @@ var IDL = {
|
|
|
10616
10810
|
]
|
|
10617
10811
|
}
|
|
10618
10812
|
},
|
|
10813
|
+
{
|
|
10814
|
+
name: "CuratorFeesDeposited",
|
|
10815
|
+
type: {
|
|
10816
|
+
kind: "struct",
|
|
10817
|
+
fields: [
|
|
10818
|
+
{
|
|
10819
|
+
name: "vault",
|
|
10820
|
+
type: "pubkey"
|
|
10821
|
+
},
|
|
10822
|
+
{
|
|
10823
|
+
name: "curator",
|
|
10824
|
+
type: "pubkey"
|
|
10825
|
+
},
|
|
10826
|
+
{
|
|
10827
|
+
name: "usdc_amount",
|
|
10828
|
+
type: "u64"
|
|
10829
|
+
},
|
|
10830
|
+
{
|
|
10831
|
+
name: "accounting_amount",
|
|
10832
|
+
type: "u64"
|
|
10833
|
+
},
|
|
10834
|
+
{
|
|
10835
|
+
name: "curator_shares",
|
|
10836
|
+
type: "u64"
|
|
10837
|
+
}
|
|
10838
|
+
]
|
|
10839
|
+
}
|
|
10840
|
+
},
|
|
10841
|
+
{
|
|
10842
|
+
name: "DepositCuratorFeesArgs",
|
|
10843
|
+
type: {
|
|
10844
|
+
kind: "struct",
|
|
10845
|
+
fields: [
|
|
10846
|
+
{
|
|
10847
|
+
name: "amount",
|
|
10848
|
+
docs: [
|
|
10849
|
+
"USDC atomic units transferred from the curator (six decimals)."
|
|
10850
|
+
],
|
|
10851
|
+
type: "u64"
|
|
10852
|
+
},
|
|
10853
|
+
{
|
|
10854
|
+
name: "min_shares_out",
|
|
10855
|
+
docs: [
|
|
10856
|
+
"Minimum newly credited curator shares; checked at execution-time NAV."
|
|
10857
|
+
],
|
|
10858
|
+
type: "u64"
|
|
10859
|
+
}
|
|
10860
|
+
]
|
|
10861
|
+
}
|
|
10862
|
+
},
|
|
10619
10863
|
{
|
|
10620
10864
|
name: "ExternalLiquiditySlot",
|
|
10621
10865
|
serialization: "bytemuck",
|
|
@@ -14917,38 +15161,115 @@ var DistributeIncentiveV3Builder = class extends DistributeIncentiveBuilder {
|
|
|
14917
15161
|
}
|
|
14918
15162
|
};
|
|
14919
15163
|
|
|
14920
|
-
// src/client/builders/
|
|
15164
|
+
// src/client/builders/depositCuratorFees.ts
|
|
15165
|
+
var import_core3 = require("@anchor-lang/core");
|
|
14921
15166
|
var import_spl_token4 = require("@solana/spl-token");
|
|
14922
15167
|
var import_web37 = require("@solana/web3.js");
|
|
14923
15168
|
var import_common9 = __toESM(require_dist());
|
|
14924
|
-
|
|
15169
|
+
function validateAmounts(args) {
|
|
15170
|
+
if (args.amount <= 0n || args.amount > 0xffffffffffffffffn)
|
|
15171
|
+
throw new RangeError("amount must be a positive u64 in USDC atomic units");
|
|
15172
|
+
const min = args.minSharesOut ?? 0n;
|
|
15173
|
+
if (min < 0n || min > 0xffffffffffffffffn)
|
|
15174
|
+
throw new RangeError("minSharesOut must fit u64");
|
|
15175
|
+
}
|
|
15176
|
+
var DepositCuratorFeesBuilder = class extends VaultBuilderBase {
|
|
14925
15177
|
async getIx(args) {
|
|
14926
|
-
|
|
14927
|
-
|
|
14928
|
-
|
|
15178
|
+
validateAmounts(args);
|
|
15179
|
+
return this.program.methods.depositCuratorFees({
|
|
15180
|
+
amount: new import_core3.BN(args.amount.toString()),
|
|
15181
|
+
minSharesOut: new import_core3.BN((args.minSharesOut ?? 0n).toString())
|
|
15182
|
+
}).accountsStrict({
|
|
15183
|
+
curator: (0, import_common9.toWeb3Pk)(args.curator),
|
|
14929
15184
|
vault: (0, import_common9.toWeb3Pk)(args.vault),
|
|
14930
|
-
|
|
14931
|
-
|
|
14932
|
-
|
|
14933
|
-
|
|
14934
|
-
|
|
15185
|
+
vaultOracle: (0, import_common9.toWeb3Pk)(args.vaultOracle),
|
|
15186
|
+
shareMint: (0, import_common9.toWeb3Pk)(args.shareMint),
|
|
15187
|
+
vaultTrancheState: args.vaultTrancheState ? (0, import_common9.toWeb3Pk)(args.vaultTrancheState) : null,
|
|
15188
|
+
juniorTrancheShareMint: args.juniorTrancheShareMint ? (0, import_common9.toWeb3Pk)(args.juniorTrancheShareMint) : null,
|
|
15189
|
+
seniorTrancheShareMint: args.seniorTrancheShareMint ? (0, import_common9.toWeb3Pk)(args.seniorTrancheShareMint) : null,
|
|
15190
|
+
usdcMint: (0, import_common9.toWeb3Pk)(USDC_MINT),
|
|
15191
|
+
curatorUsdcAta: (0, import_common9.toWeb3Pk)(args.curatorUsdcAta),
|
|
15192
|
+
vaultUsdcAta: (0, import_common9.toWeb3Pk)(args.vaultUsdcAta),
|
|
15193
|
+
tokenProgram: import_spl_token4.TOKEN_PROGRAM_ID,
|
|
14935
15194
|
associatedTokenProgram: import_spl_token4.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
14936
15195
|
systemProgram: import_web37.SystemProgram.programId
|
|
14937
15196
|
}).instruction().then(import_common9.toKitInstruction);
|
|
14938
15197
|
}
|
|
14939
|
-
async deriveIxArgs(
|
|
14940
|
-
|
|
14941
|
-
const [
|
|
14942
|
-
|
|
14943
|
-
|
|
14944
|
-
|
|
14945
|
-
|
|
15198
|
+
async deriveIxArgs(args) {
|
|
15199
|
+
validateAmounts(args);
|
|
15200
|
+
const [vaultOracle] = await this.pda.deriveVaultOraclePda(args.vault);
|
|
15201
|
+
const vault = await this.account.fetchVault(args.vault, { fresh: true });
|
|
15202
|
+
const vaultTrancheState = await resolveVaultTrancheState(
|
|
15203
|
+
this.account,
|
|
15204
|
+
this.pda,
|
|
15205
|
+
args.vault,
|
|
15206
|
+
void 0
|
|
15207
|
+
);
|
|
15208
|
+
const tranche = vaultTrancheState ? await this.account.fetchVaultTrancheState(vaultTrancheState, {
|
|
15209
|
+
fresh: true
|
|
15210
|
+
}) : null;
|
|
15211
|
+
const tokenProgram = (0, import_common9.fromWeb3Pk)(import_spl_token4.TOKEN_PROGRAM_ID);
|
|
15212
|
+
return {
|
|
15213
|
+
...args,
|
|
15214
|
+
vaultOracle,
|
|
15215
|
+
shareMint: (0, import_common9.fromWeb3Pk)(vault.mint),
|
|
15216
|
+
vaultTrancheState,
|
|
15217
|
+
juniorTrancheShareMint: tranche ? (0, import_common9.fromWeb3Pk)(tranche.config.juniorMint) : null,
|
|
15218
|
+
seniorTrancheShareMint: tranche ? (0, import_common9.fromWeb3Pk)(tranche.config.seniorMint) : null,
|
|
15219
|
+
curatorUsdcAta: (0, import_common9.getAtaAddress)(
|
|
15220
|
+
USDC_MINT,
|
|
15221
|
+
args.curator,
|
|
15222
|
+
tokenProgram,
|
|
15223
|
+
true
|
|
14946
15224
|
),
|
|
14947
|
-
|
|
14948
|
-
|
|
14949
|
-
|
|
14950
|
-
|
|
14951
|
-
|
|
15225
|
+
vaultUsdcAta: (0, import_common9.getAtaAddress)(USDC_MINT, args.vault, tokenProgram, true)
|
|
15226
|
+
};
|
|
15227
|
+
}
|
|
15228
|
+
async buildPlanExtras(args) {
|
|
15229
|
+
return {
|
|
15230
|
+
postSuccessCacheInvalidations: [
|
|
15231
|
+
{
|
|
15232
|
+
vaultPda: args.vault,
|
|
15233
|
+
vaultOraclePda: args.vaultOracle,
|
|
15234
|
+
vaultTrancheStatePda: args.vaultTrancheState ?? void 0
|
|
15235
|
+
}
|
|
15236
|
+
]
|
|
15237
|
+
};
|
|
15238
|
+
}
|
|
15239
|
+
};
|
|
15240
|
+
|
|
15241
|
+
// src/client/builders/cancelJuniorTrancheWithdraw.ts
|
|
15242
|
+
var import_spl_token5 = require("@solana/spl-token");
|
|
15243
|
+
var import_web38 = require("@solana/web3.js");
|
|
15244
|
+
var import_common10 = __toESM(require_dist());
|
|
15245
|
+
var CancelJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
15246
|
+
async getIx(args) {
|
|
15247
|
+
return this.program.methods.cancelJuniorTrancheWithdraw().accountsPartial({
|
|
15248
|
+
user: (0, import_common10.toWeb3Pk)(args.user),
|
|
15249
|
+
payer: (0, import_common10.toWeb3Pk)(args.payer),
|
|
15250
|
+
vault: (0, import_common10.toWeb3Pk)(args.vault),
|
|
15251
|
+
withdrawalQueue: (0, import_common10.toWeb3Pk)(args.withdrawalQueue),
|
|
15252
|
+
inputMint: (0, import_common10.toWeb3Pk)(args.inputMint),
|
|
15253
|
+
userInputAta: (0, import_common10.toWeb3Pk)(args.userInputAta),
|
|
15254
|
+
queueInputAta: (0, import_common10.toWeb3Pk)(args.queueInputAta),
|
|
15255
|
+
shareTokenProgram: (0, import_common10.toWeb3Pk)(args.shareTokenProgram),
|
|
15256
|
+
associatedTokenProgram: import_spl_token5.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
15257
|
+
systemProgram: import_web38.SystemProgram.programId
|
|
15258
|
+
}).instruction().then(import_common10.toKitInstruction);
|
|
15259
|
+
}
|
|
15260
|
+
async deriveIxArgs(txArgs) {
|
|
15261
|
+
const payer = txArgs.payer ?? txArgs.user;
|
|
15262
|
+
const [[withdrawalQueue], juniorShare] = await Promise.all([
|
|
15263
|
+
this.pda.deriveVaultTrancheWithdrawalQueuePda(
|
|
15264
|
+
txArgs.vault,
|
|
15265
|
+
txArgs.user,
|
|
15266
|
+
txArgs.queueId
|
|
15267
|
+
),
|
|
15268
|
+
resolveTrancheShare(
|
|
15269
|
+
this.account,
|
|
15270
|
+
txArgs.vault,
|
|
15271
|
+
{ junior: {} },
|
|
15272
|
+
{
|
|
14952
15273
|
mint: txArgs.juniorShareMint,
|
|
14953
15274
|
tokenProgram: txArgs.shareTokenProgram
|
|
14954
15275
|
}
|
|
@@ -14963,8 +15284,8 @@ var CancelJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
14963
15284
|
withdrawalQueue: queuePda,
|
|
14964
15285
|
inputMint: juniorShareMint,
|
|
14965
15286
|
shareTokenProgram,
|
|
14966
|
-
userInputAta: txArgs.userInputAta ?? (0,
|
|
14967
|
-
queueInputAta: (0,
|
|
15287
|
+
userInputAta: txArgs.userInputAta ?? (0, import_common10.getAtaAddress)(juniorShareMint, txArgs.user, shareTokenProgram),
|
|
15288
|
+
queueInputAta: (0, import_common10.getAtaAddress)(
|
|
14968
15289
|
juniorShareMint,
|
|
14969
15290
|
queuePda,
|
|
14970
15291
|
shareTokenProgram,
|
|
@@ -14982,19 +15303,19 @@ var CancelJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
14982
15303
|
};
|
|
14983
15304
|
|
|
14984
15305
|
// src/client/builders/createAssetHolding.ts
|
|
14985
|
-
var
|
|
15306
|
+
var import_common11 = __toESM(require_dist());
|
|
14986
15307
|
var CreateAssetHoldingBuilder = class extends VaultBuilderBase {
|
|
14987
15308
|
async getIx(args) {
|
|
14988
15309
|
return this.program.methods.createAssetHolding({
|
|
14989
15310
|
priceOracleType: args.args.priceOracleType,
|
|
14990
|
-
priceOracleAccount: (0,
|
|
15311
|
+
priceOracleAccount: (0, import_common11.toWeb3Pk)(args.args.priceOracleAccount)
|
|
14991
15312
|
}).accountsPartial({
|
|
14992
|
-
hwManager: (0,
|
|
14993
|
-
vault: (0,
|
|
14994
|
-
vaultOracle: (0,
|
|
14995
|
-
mint: (0,
|
|
14996
|
-
tokenProgram: (0,
|
|
14997
|
-
}).instruction().then(
|
|
15313
|
+
hwManager: (0, import_common11.toWeb3Pk)(args.hwManager),
|
|
15314
|
+
vault: (0, import_common11.toWeb3Pk)(args.vault),
|
|
15315
|
+
vaultOracle: (0, import_common11.toWeb3Pk)(args.vaultOracle),
|
|
15316
|
+
mint: (0, import_common11.toWeb3Pk)(args.mint),
|
|
15317
|
+
tokenProgram: (0, import_common11.toWeb3Pk)(args.tokenProgram)
|
|
15318
|
+
}).instruction().then(import_common11.toKitInstruction);
|
|
14998
15319
|
}
|
|
14999
15320
|
async deriveIxArgs(txArgs) {
|
|
15000
15321
|
const [vaultOracle] = await this.pda.deriveVaultOraclePda(txArgs.vault);
|
|
@@ -15020,15 +15341,15 @@ var CreateAssetHoldingBuilder = class extends VaultBuilderBase {
|
|
|
15020
15341
|
};
|
|
15021
15342
|
|
|
15022
15343
|
// src/client/builders/removeAssetHolding.ts
|
|
15023
|
-
var
|
|
15344
|
+
var import_common12 = __toESM(require_dist());
|
|
15024
15345
|
var RemoveAssetHoldingBuilder = class extends VaultBuilderBase {
|
|
15025
15346
|
async getIx(args) {
|
|
15026
15347
|
return this.program.methods.removeAssetHolding().accountsPartial({
|
|
15027
|
-
hwManager: (0,
|
|
15028
|
-
vault: (0,
|
|
15029
|
-
vaultOracle: (0,
|
|
15030
|
-
mint: (0,
|
|
15031
|
-
}).instruction().then(
|
|
15348
|
+
hwManager: (0, import_common12.toWeb3Pk)(args.hwManager),
|
|
15349
|
+
vault: (0, import_common12.toWeb3Pk)(args.vault),
|
|
15350
|
+
vaultOracle: (0, import_common12.toWeb3Pk)(args.vaultOracle),
|
|
15351
|
+
mint: (0, import_common12.toWeb3Pk)(args.mint)
|
|
15352
|
+
}).instruction().then(import_common12.toKitInstruction);
|
|
15032
15353
|
}
|
|
15033
15354
|
async deriveIxArgs(txArgs) {
|
|
15034
15355
|
const [vaultOracle] = await this.pda.deriveVaultOraclePda(txArgs.vault);
|
|
@@ -15049,16 +15370,16 @@ var RemoveAssetHoldingBuilder = class extends VaultBuilderBase {
|
|
|
15049
15370
|
};
|
|
15050
15371
|
|
|
15051
15372
|
// src/client/builders/updateConsensusSigners.ts
|
|
15052
|
-
var
|
|
15373
|
+
var import_common13 = __toESM(require_dist());
|
|
15053
15374
|
var UpdateConsensusSignersBuilder = class extends VaultBuilderBase {
|
|
15054
15375
|
async getIx(args) {
|
|
15055
15376
|
return this.program.methods.updateConsensusSigners({
|
|
15056
|
-
signers: args.args.signers.map(
|
|
15377
|
+
signers: args.args.signers.map(import_common13.toWeb3Pk)
|
|
15057
15378
|
}).accountsPartial({
|
|
15058
|
-
curator: (0,
|
|
15059
|
-
vault: (0,
|
|
15060
|
-
vaultOracle: (0,
|
|
15061
|
-
}).instruction().then(
|
|
15379
|
+
curator: (0, import_common13.toWeb3Pk)(args.curator),
|
|
15380
|
+
vault: (0, import_common13.toWeb3Pk)(args.vault),
|
|
15381
|
+
vaultOracle: (0, import_common13.toWeb3Pk)(args.vaultOracle)
|
|
15382
|
+
}).instruction().then(import_common13.toKitInstruction);
|
|
15062
15383
|
}
|
|
15063
15384
|
async deriveIxArgs(txArgs) {
|
|
15064
15385
|
const [vaultOracle] = await this.pda.deriveVaultOraclePda(txArgs.vault);
|
|
@@ -15079,9 +15400,9 @@ var UpdateConsensusSignersBuilder = class extends VaultBuilderBase {
|
|
|
15079
15400
|
};
|
|
15080
15401
|
|
|
15081
15402
|
// src/client/builders/createTrancheState.ts
|
|
15082
|
-
var
|
|
15083
|
-
var
|
|
15084
|
-
var
|
|
15403
|
+
var import_core4 = require("@anchor-lang/core");
|
|
15404
|
+
var import_web39 = require("@solana/web3.js");
|
|
15405
|
+
var import_common14 = __toESM(require_dist());
|
|
15085
15406
|
var CreateTrancheStateBuilder = class extends VaultBuilderBase {
|
|
15086
15407
|
async getIx(args) {
|
|
15087
15408
|
return this.program.methods.vaultCreateTrancheState({
|
|
@@ -15093,18 +15414,18 @@ var CreateTrancheStateBuilder = class extends VaultBuilderBase {
|
|
|
15093
15414
|
juniorDepositCap: args.juniorDepositCap,
|
|
15094
15415
|
forMigration: args.forMigration
|
|
15095
15416
|
}).accountsPartial({
|
|
15096
|
-
curator: (0,
|
|
15097
|
-
vault: (0,
|
|
15098
|
-
vaultTrancheState: (0,
|
|
15099
|
-
juniorShareMint: (0,
|
|
15100
|
-
seniorShareMint: (0,
|
|
15417
|
+
curator: (0, import_common14.toWeb3Pk)(args.curator),
|
|
15418
|
+
vault: (0, import_common14.toWeb3Pk)(args.vault),
|
|
15419
|
+
vaultTrancheState: (0, import_common14.toWeb3Pk)(args.vaultTrancheState),
|
|
15420
|
+
juniorShareMint: (0, import_common14.toWeb3Pk)(args.juniorShareMint),
|
|
15421
|
+
seniorShareMint: (0, import_common14.toWeb3Pk)(args.seniorShareMint),
|
|
15101
15422
|
// Optional on-chain: required only on the organic path, where the
|
|
15102
15423
|
// program enforces a fresh NAV before enabling tranching. Left null on
|
|
15103
15424
|
// the migration path so Anchor resolves it to the program ID.
|
|
15104
|
-
vaultOracle: args.vaultOracle ? (0,
|
|
15105
|
-
tokenProgram: (0,
|
|
15106
|
-
systemProgram:
|
|
15107
|
-
}).instruction().then(
|
|
15425
|
+
vaultOracle: args.vaultOracle ? (0, import_common14.toWeb3Pk)(args.vaultOracle) : null,
|
|
15426
|
+
tokenProgram: (0, import_common14.toWeb3Pk)(args.tokenProgram),
|
|
15427
|
+
systemProgram: import_web39.SystemProgram.programId
|
|
15428
|
+
}).instruction().then(import_common14.toKitInstruction);
|
|
15108
15429
|
}
|
|
15109
15430
|
async deriveIxArgs(txArgs) {
|
|
15110
15431
|
const [vaultTrancheState] = await this.pda.deriveVaultTrancheStatePda(
|
|
@@ -15133,10 +15454,10 @@ var CreateTrancheStateBuilder = class extends VaultBuilderBase {
|
|
|
15133
15454
|
juniorFloorApyBps: txArgs.juniorFloorApyBps ?? 0,
|
|
15134
15455
|
earlyUnstakeFeeBps: txArgs.earlyUnstakeFeeBps ?? DEFAULT_JUNIOR_EARLY_UNSTAKE_FEE_BPS,
|
|
15135
15456
|
standardUnstakeFeeBps: txArgs.standardUnstakeFeeBps ?? DEFAULT_JUNIOR_STANDARD_UNSTAKE_FEE_BPS,
|
|
15136
|
-
targetLockupDurationSecs: new
|
|
15457
|
+
targetLockupDurationSecs: new import_core4.BN(
|
|
15137
15458
|
(txArgs.targetLockupDurationSecs ?? DEFAULT_JUNIOR_WITHDRAWAL_LOCKUP_SECS).toString()
|
|
15138
15459
|
),
|
|
15139
|
-
juniorDepositCap: new
|
|
15460
|
+
juniorDepositCap: new import_core4.BN((txArgs.juniorDepositCap ?? 0n).toString()),
|
|
15140
15461
|
forMigration,
|
|
15141
15462
|
tokenProgram: txArgs.tokenProgram ?? TOKEN_PROGRAM_ID
|
|
15142
15463
|
};
|
|
@@ -15151,13 +15472,13 @@ var CreateTrancheStateBuilder = class extends VaultBuilderBase {
|
|
|
15151
15472
|
};
|
|
15152
15473
|
|
|
15153
15474
|
// src/client/builders/activateCircuitBreaker.ts
|
|
15154
|
-
var
|
|
15475
|
+
var import_common15 = __toESM(require_dist());
|
|
15155
15476
|
var ActivateCircuitBreakerBuilder = class extends VaultBuilderBase {
|
|
15156
15477
|
async getIx(args) {
|
|
15157
15478
|
return this.program.methods.activateCircuitBreaker().accountsPartial({
|
|
15158
|
-
cbTrigger: (0,
|
|
15159
|
-
vault: (0,
|
|
15160
|
-
}).instruction().then(
|
|
15479
|
+
cbTrigger: (0, import_common15.toWeb3Pk)(args.cbTrigger),
|
|
15480
|
+
vault: (0, import_common15.toWeb3Pk)(args.vault)
|
|
15481
|
+
}).instruction().then(import_common15.toKitInstruction);
|
|
15161
15482
|
}
|
|
15162
15483
|
async deriveIxArgs(txArgs) {
|
|
15163
15484
|
return txArgs;
|
|
@@ -15170,34 +15491,34 @@ var ActivateCircuitBreakerBuilder = class extends VaultBuilderBase {
|
|
|
15170
15491
|
};
|
|
15171
15492
|
|
|
15172
15493
|
// src/client/builders/createVault.ts
|
|
15173
|
-
var
|
|
15494
|
+
var import_core6 = require("@anchor-lang/core");
|
|
15174
15495
|
var import_token = require("@solana-program/token");
|
|
15175
|
-
var
|
|
15176
|
-
var
|
|
15177
|
-
var
|
|
15496
|
+
var import_spl_token6 = require("@solana/spl-token");
|
|
15497
|
+
var import_web310 = require("@solana/web3.js");
|
|
15498
|
+
var import_common17 = __toESM(require_dist());
|
|
15178
15499
|
|
|
15179
15500
|
// src/client/builders/anchorArgs.ts
|
|
15180
|
-
var
|
|
15181
|
-
var
|
|
15501
|
+
var import_core5 = require("@anchor-lang/core");
|
|
15502
|
+
var import_common16 = __toESM(require_dist());
|
|
15182
15503
|
function toAnchorCreateVaultParams(params) {
|
|
15183
15504
|
return {
|
|
15184
15505
|
...params,
|
|
15185
|
-
hwManager: (0,
|
|
15186
|
-
cbTrigger: (0,
|
|
15187
|
-
feeCollector: (0,
|
|
15188
|
-
baseAssetMint: (0,
|
|
15189
|
-
basePriceOracleAccount: (0,
|
|
15190
|
-
consensusSigners: params.consensusSigners.map(
|
|
15506
|
+
hwManager: (0, import_common16.toWeb3Pk)(params.hwManager),
|
|
15507
|
+
cbTrigger: (0, import_common16.toWeb3Pk)(params.cbTrigger),
|
|
15508
|
+
feeCollector: (0, import_common16.toWeb3Pk)(params.feeCollector),
|
|
15509
|
+
baseAssetMint: (0, import_common16.toWeb3Pk)(params.baseAssetMint),
|
|
15510
|
+
basePriceOracleAccount: (0, import_common16.toWeb3Pk)(params.basePriceOracleAccount),
|
|
15511
|
+
consensusSigners: params.consensusSigners.map(import_common16.toWeb3Pk)
|
|
15191
15512
|
};
|
|
15192
15513
|
}
|
|
15193
15514
|
function toAnchorSetVaultConfigArgs(args) {
|
|
15194
15515
|
return {
|
|
15195
|
-
manager: args.manager ? (0,
|
|
15196
|
-
hwManager: args.hwManager ? (0,
|
|
15197
|
-
cbTrigger: args.cbTrigger ? (0,
|
|
15198
|
-
fulfiller: args.fulfiller ? (0,
|
|
15199
|
-
feeCollector: args.feeCollector ? (0,
|
|
15200
|
-
newCurator: args.newCurator ? (0,
|
|
15516
|
+
manager: args.manager ? (0, import_common16.toWeb3Pk)(args.manager) : null,
|
|
15517
|
+
hwManager: args.hwManager ? (0, import_common16.toWeb3Pk)(args.hwManager) : null,
|
|
15518
|
+
cbTrigger: args.cbTrigger ? (0, import_common16.toWeb3Pk)(args.cbTrigger) : null,
|
|
15519
|
+
fulfiller: args.fulfiller ? (0, import_common16.toWeb3Pk)(args.fulfiller) : null,
|
|
15520
|
+
feeCollector: args.feeCollector ? (0, import_common16.toWeb3Pk)(args.feeCollector) : null,
|
|
15521
|
+
newCurator: args.newCurator ? (0, import_common16.toWeb3Pk)(args.newCurator) : null,
|
|
15201
15522
|
mintFeeBps: args.mintFeeBps,
|
|
15202
15523
|
burnFeeBps: args.burnFeeBps,
|
|
15203
15524
|
performanceFeeBps: args.performanceFeeBps,
|
|
@@ -15214,9 +15535,9 @@ function toAnchorSetVaultConfigArgs(args) {
|
|
|
15214
15535
|
function toAnchorConsensusUpdates(updates) {
|
|
15215
15536
|
return updates.map((update) => ({
|
|
15216
15537
|
holdingIndex: update.holdingIndex,
|
|
15217
|
-
mint: update.mint ? (0,
|
|
15218
|
-
price: new
|
|
15219
|
-
externalAmount: new
|
|
15538
|
+
mint: update.mint ? (0, import_common16.toWeb3Pk)(update.mint) : null,
|
|
15539
|
+
price: new import_core5.BN(update.price.toString()),
|
|
15540
|
+
externalAmount: new import_core5.BN(update.externalAmount.toString())
|
|
15220
15541
|
}));
|
|
15221
15542
|
}
|
|
15222
15543
|
|
|
@@ -15224,16 +15545,16 @@ function toAnchorConsensusUpdates(updates) {
|
|
|
15224
15545
|
var CreateVaultBuilder = class extends VaultBuilderBase {
|
|
15225
15546
|
async getIx(args) {
|
|
15226
15547
|
return this.program.methods.createVault(toAnchorCreateVaultParams(args.params)).accountsPartial({
|
|
15227
|
-
curator: (0,
|
|
15228
|
-
vault: (0,
|
|
15229
|
-
vaultOracle: (0,
|
|
15230
|
-
feeVault: (0,
|
|
15231
|
-
shareMint: (0,
|
|
15232
|
-
assetMint: (0,
|
|
15233
|
-
assetTokenProgram: (0,
|
|
15234
|
-
tokenProgram: (0,
|
|
15235
|
-
systemProgram:
|
|
15236
|
-
}).instruction().then(
|
|
15548
|
+
curator: (0, import_common17.toWeb3Pk)(args.curator),
|
|
15549
|
+
vault: (0, import_common17.toWeb3Pk)(args.vault),
|
|
15550
|
+
vaultOracle: (0, import_common17.toWeb3Pk)(args.vaultOracle),
|
|
15551
|
+
feeVault: (0, import_common17.toWeb3Pk)(args.feeVault),
|
|
15552
|
+
shareMint: (0, import_common17.toWeb3Pk)(args.shareMint),
|
|
15553
|
+
assetMint: (0, import_common17.toWeb3Pk)(args.assetMint),
|
|
15554
|
+
assetTokenProgram: (0, import_common17.toWeb3Pk)(args.assetTokenProgram),
|
|
15555
|
+
tokenProgram: (0, import_common17.toWeb3Pk)(args.shareTokenProgram ?? TOKEN_PROGRAM_ID),
|
|
15556
|
+
systemProgram: import_web310.SystemProgram.programId
|
|
15557
|
+
}).instruction().then(import_common17.toKitInstruction);
|
|
15237
15558
|
}
|
|
15238
15559
|
async deriveIxArgs(txArgs) {
|
|
15239
15560
|
const vaultId = txArgs.vaultId ?? DEFAULT_VAULT_ID;
|
|
@@ -15262,11 +15583,11 @@ var CreateVaultBuilder = class extends VaultBuilderBase {
|
|
|
15262
15583
|
performanceFeeBps: txArgs.performanceFeeBps ?? 0,
|
|
15263
15584
|
fixedApyBps: txArgs.fixedApyBps ?? 0,
|
|
15264
15585
|
maxApyBps: txArgs.maxApyBps ?? DEFAULT_MAX_ACCEPTABLE_APY_BPS,
|
|
15265
|
-
tvlLimit: new
|
|
15586
|
+
tvlLimit: new import_core6.BN((txArgs.tvlLimit ?? 0n).toString()),
|
|
15266
15587
|
lossesEnabled: txArgs.lossesEnabled ?? false,
|
|
15267
15588
|
initialMintSharePrice: null,
|
|
15268
15589
|
basePriceOracleType: txArgs.basePriceOracleType ?? 1,
|
|
15269
|
-
basePrice: new
|
|
15590
|
+
basePrice: new import_core6.BN(
|
|
15270
15591
|
(txArgs.basePrice ?? 10n ** BigInt(accountingDecimals)).toString()
|
|
15271
15592
|
),
|
|
15272
15593
|
basePriceOracleAccount: txArgs.basePriceOracleAccount ?? DEFAULT_PRICE_ORACLE_ACCOUNT,
|
|
@@ -15278,42 +15599,42 @@ var CreateVaultBuilder = class extends VaultBuilderBase {
|
|
|
15278
15599
|
async getTx(txArgs) {
|
|
15279
15600
|
const args = await this.deriveIxArgs(txArgs);
|
|
15280
15601
|
const createIx = await this.getIx(args);
|
|
15281
|
-
const payer = (0,
|
|
15282
|
-
const assetMint = (0,
|
|
15283
|
-
const assetTokenProgram = (0,
|
|
15284
|
-
const vaultAssetAta = (0,
|
|
15602
|
+
const payer = (0, import_common17.toWeb3Pk)(args.curator);
|
|
15603
|
+
const assetMint = (0, import_common17.toWeb3Pk)(args.assetMint);
|
|
15604
|
+
const assetTokenProgram = (0, import_common17.toWeb3Pk)(args.assetTokenProgram);
|
|
15605
|
+
const vaultAssetAta = (0, import_common17.getAtaAddress)(
|
|
15285
15606
|
args.assetMint,
|
|
15286
15607
|
args.vault,
|
|
15287
15608
|
args.assetTokenProgram,
|
|
15288
15609
|
true
|
|
15289
15610
|
);
|
|
15290
|
-
const feeVaultAta = (0,
|
|
15611
|
+
const feeVaultAta = (0, import_common17.getAtaAddress)(
|
|
15291
15612
|
args.assetMint,
|
|
15292
15613
|
args.feeVault,
|
|
15293
15614
|
args.assetTokenProgram,
|
|
15294
15615
|
true
|
|
15295
15616
|
);
|
|
15296
|
-
const createVaultAssetAta = (0,
|
|
15617
|
+
const createVaultAssetAta = (0, import_spl_token6.createAssociatedTokenAccountIdempotentInstruction)(
|
|
15297
15618
|
payer,
|
|
15298
|
-
(0,
|
|
15299
|
-
(0,
|
|
15619
|
+
(0, import_common17.toWeb3Pk)(vaultAssetAta),
|
|
15620
|
+
(0, import_common17.toWeb3Pk)(args.vault),
|
|
15300
15621
|
assetMint,
|
|
15301
15622
|
assetTokenProgram,
|
|
15302
|
-
|
|
15623
|
+
import_spl_token6.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
15303
15624
|
);
|
|
15304
|
-
const createFeeVaultAta = (0,
|
|
15625
|
+
const createFeeVaultAta = (0, import_spl_token6.createAssociatedTokenAccountIdempotentInstruction)(
|
|
15305
15626
|
payer,
|
|
15306
|
-
(0,
|
|
15307
|
-
(0,
|
|
15627
|
+
(0, import_common17.toWeb3Pk)(feeVaultAta),
|
|
15628
|
+
(0, import_common17.toWeb3Pk)(args.feeVault),
|
|
15308
15629
|
assetMint,
|
|
15309
15630
|
assetTokenProgram,
|
|
15310
|
-
|
|
15631
|
+
import_spl_token6.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
15311
15632
|
);
|
|
15312
15633
|
return {
|
|
15313
15634
|
instructions: [
|
|
15314
15635
|
createIx,
|
|
15315
|
-
(0,
|
|
15316
|
-
(0,
|
|
15636
|
+
(0, import_common17.toKitInstruction)(createVaultAssetAta),
|
|
15637
|
+
(0, import_common17.toKitInstruction)(createFeeVaultAta)
|
|
15317
15638
|
],
|
|
15318
15639
|
postSuccessCacheInvalidations: [
|
|
15319
15640
|
{ vaultPda: args.vault, vaultOraclePda: args.vaultOracle }
|
|
@@ -15323,16 +15644,16 @@ var CreateVaultBuilder = class extends VaultBuilderBase {
|
|
|
15323
15644
|
};
|
|
15324
15645
|
|
|
15325
15646
|
// src/client/builders/initializeVaultRoles.ts
|
|
15326
|
-
var
|
|
15647
|
+
var import_common18 = __toESM(require_dist());
|
|
15327
15648
|
var InitializeVaultRolesBuilder = class extends VaultBuilderBase {
|
|
15328
15649
|
async getIx(args) {
|
|
15329
15650
|
return this.program.methods.initializeVaultRoles({
|
|
15330
|
-
manager: (0,
|
|
15331
|
-
fulfiller: (0,
|
|
15651
|
+
manager: (0, import_common18.toWeb3Pk)(args.args.manager),
|
|
15652
|
+
fulfiller: (0, import_common18.toWeb3Pk)(args.args.fulfiller)
|
|
15332
15653
|
}).accountsPartial({
|
|
15333
|
-
curator: (0,
|
|
15334
|
-
vault: (0,
|
|
15335
|
-
}).instruction().then(
|
|
15654
|
+
curator: (0, import_common18.toWeb3Pk)(args.curator),
|
|
15655
|
+
vault: (0, import_common18.toWeb3Pk)(args.vault)
|
|
15656
|
+
}).instruction().then(import_common18.toKitInstruction);
|
|
15336
15657
|
}
|
|
15337
15658
|
async deriveIxArgs(txArgs) {
|
|
15338
15659
|
return {
|
|
@@ -15352,13 +15673,13 @@ var InitializeVaultRolesBuilder = class extends VaultBuilderBase {
|
|
|
15352
15673
|
};
|
|
15353
15674
|
|
|
15354
15675
|
// src/client/builders/disableCircuitBreaker.ts
|
|
15355
|
-
var
|
|
15676
|
+
var import_common19 = __toESM(require_dist());
|
|
15356
15677
|
var DisableCircuitBreakerBuilder = class extends VaultBuilderBase {
|
|
15357
15678
|
async getIx(args) {
|
|
15358
15679
|
return this.program.methods.disableCircuitBreaker().accountsPartial({
|
|
15359
|
-
curator: (0,
|
|
15360
|
-
vault: (0,
|
|
15361
|
-
}).instruction().then(
|
|
15680
|
+
curator: (0, import_common19.toWeb3Pk)(args.curator),
|
|
15681
|
+
vault: (0, import_common19.toWeb3Pk)(args.vault)
|
|
15682
|
+
}).instruction().then(import_common19.toKitInstruction);
|
|
15362
15683
|
}
|
|
15363
15684
|
async deriveIxArgs(txArgs) {
|
|
15364
15685
|
return txArgs;
|
|
@@ -15371,15 +15692,15 @@ var DisableCircuitBreakerBuilder = class extends VaultBuilderBase {
|
|
|
15371
15692
|
};
|
|
15372
15693
|
|
|
15373
15694
|
// src/client/builders/setVaultConfig.ts
|
|
15374
|
-
var
|
|
15375
|
-
var
|
|
15695
|
+
var import_core7 = require("@anchor-lang/core");
|
|
15696
|
+
var import_common20 = __toESM(require_dist());
|
|
15376
15697
|
var SetVaultConfigBuilder = class extends VaultBuilderBase {
|
|
15377
15698
|
async getIx(args) {
|
|
15378
15699
|
return this.program.methods.setVaultConfig(toAnchorSetVaultConfigArgs(args.args)).accountsPartial({
|
|
15379
|
-
curator: (0,
|
|
15380
|
-
vault: (0,
|
|
15381
|
-
vaultOracle: args.vaultOracle ? (0,
|
|
15382
|
-
}).instruction().then(
|
|
15700
|
+
curator: (0, import_common20.toWeb3Pk)(args.curator),
|
|
15701
|
+
vault: (0, import_common20.toWeb3Pk)(args.vault),
|
|
15702
|
+
vaultOracle: args.vaultOracle ? (0, import_common20.toWeb3Pk)(args.vaultOracle) : null
|
|
15703
|
+
}).instruction().then(import_common20.toKitInstruction);
|
|
15383
15704
|
}
|
|
15384
15705
|
async deriveIxArgs(txArgs) {
|
|
15385
15706
|
const [derivedVaultOracle] = await this.pda.deriveVaultOraclePda(
|
|
@@ -15401,28 +15722,28 @@ var SetVaultConfigBuilder = class extends VaultBuilderBase {
|
|
|
15401
15722
|
performanceFeeBps: txArgs.performanceFeeBps ?? null,
|
|
15402
15723
|
fixedApyBps: txArgs.fixedApyBps ?? null,
|
|
15403
15724
|
maxApyBps: txArgs.maxApyBps ?? null,
|
|
15404
|
-
tvlLimit: txArgs.tvlLimit !== void 0 ? new
|
|
15725
|
+
tvlLimit: txArgs.tvlLimit !== void 0 ? new import_core7.BN(txArgs.tvlLimit.toString()) : null,
|
|
15405
15726
|
lossesEnabled: txArgs.lossesEnabled ?? null,
|
|
15406
|
-
priceStalenessThresholdSecs: txArgs.priceStalenessThresholdSecs !== void 0 ? new
|
|
15727
|
+
priceStalenessThresholdSecs: txArgs.priceStalenessThresholdSecs !== void 0 ? new import_core7.BN(txArgs.priceStalenessThresholdSecs.toString()) : null,
|
|
15407
15728
|
userBurnLimit: txArgs.userBurnLimit !== void 0 ? {
|
|
15408
|
-
windowLimit: new
|
|
15729
|
+
windowLimit: new import_core7.BN(
|
|
15409
15730
|
txArgs.userBurnLimit.windowLimit.toString()
|
|
15410
15731
|
),
|
|
15411
|
-
windowDurationSeconds: new
|
|
15732
|
+
windowDurationSeconds: new import_core7.BN(
|
|
15412
15733
|
txArgs.userBurnLimit.windowDurationSeconds.toString()
|
|
15413
15734
|
)
|
|
15414
15735
|
} : null,
|
|
15415
15736
|
managerPullLimit: txArgs.managerPullLimit !== void 0 ? {
|
|
15416
|
-
windowLimit: new
|
|
15737
|
+
windowLimit: new import_core7.BN(
|
|
15417
15738
|
txArgs.managerPullLimit.windowLimit.toString()
|
|
15418
15739
|
),
|
|
15419
|
-
windowDurationSeconds: new
|
|
15740
|
+
windowDurationSeconds: new import_core7.BN(
|
|
15420
15741
|
txArgs.managerPullLimit.windowDurationSeconds.toString()
|
|
15421
15742
|
)
|
|
15422
15743
|
} : null,
|
|
15423
15744
|
rebalanceLimit: txArgs.rebalanceLimit !== void 0 ? {
|
|
15424
15745
|
windowLimitBps: txArgs.rebalanceLimit.windowLimitBps,
|
|
15425
|
-
windowDurationSeconds: new
|
|
15746
|
+
windowDurationSeconds: new import_core7.BN(
|
|
15426
15747
|
txArgs.rebalanceLimit.windowDurationSeconds.toString()
|
|
15427
15748
|
)
|
|
15428
15749
|
} : null
|
|
@@ -15437,14 +15758,14 @@ var SetVaultConfigBuilder = class extends VaultBuilderBase {
|
|
|
15437
15758
|
};
|
|
15438
15759
|
|
|
15439
15760
|
// src/client/builders/setProtocolFee.ts
|
|
15440
|
-
var
|
|
15761
|
+
var import_common21 = __toESM(require_dist());
|
|
15441
15762
|
var SetProtocolFeeBuilder = class extends VaultBuilderBase {
|
|
15442
15763
|
async getIx(args) {
|
|
15443
15764
|
return this.program.methods.setProtocolFee({ protocolFeeBps: args.args.protocolFeeBps }).accountsPartial({
|
|
15444
|
-
protocolAuthority: (0,
|
|
15445
|
-
vault: (0,
|
|
15446
|
-
vaultOracle: args.vaultOracle ? (0,
|
|
15447
|
-
}).instruction().then(
|
|
15765
|
+
protocolAuthority: (0, import_common21.toWeb3Pk)(args.protocolAuthority),
|
|
15766
|
+
vault: (0, import_common21.toWeb3Pk)(args.vault),
|
|
15767
|
+
vaultOracle: args.vaultOracle ? (0, import_common21.toWeb3Pk)(args.vaultOracle) : null
|
|
15768
|
+
}).instruction().then(import_common21.toKitInstruction);
|
|
15448
15769
|
}
|
|
15449
15770
|
async deriveIxArgs(txArgs) {
|
|
15450
15771
|
const [derivedVaultOracle] = await this.pda.deriveVaultOraclePda(
|
|
@@ -15468,13 +15789,13 @@ var SetProtocolFeeBuilder = class extends VaultBuilderBase {
|
|
|
15468
15789
|
};
|
|
15469
15790
|
|
|
15470
15791
|
// src/client/builders/crankNav.ts
|
|
15471
|
-
var
|
|
15792
|
+
var import_spl_token7 = require("@solana/spl-token");
|
|
15472
15793
|
var import_kit6 = require("@solana/kit");
|
|
15473
|
-
var
|
|
15474
|
-
var
|
|
15794
|
+
var import_web311 = require("@solana/web3.js");
|
|
15795
|
+
var import_common23 = __toESM(require_dist());
|
|
15475
15796
|
|
|
15476
15797
|
// src/client/builders/feeCollector.ts
|
|
15477
|
-
var
|
|
15798
|
+
var import_common22 = __toESM(require_dist());
|
|
15478
15799
|
function resolveProtocolFeeRecipient(override) {
|
|
15479
15800
|
return override ?? PROTOCOL_FEE_RECIPIENT;
|
|
15480
15801
|
}
|
|
@@ -15483,14 +15804,14 @@ async function resolveVaultFeeCollector(account, vault, override) {
|
|
|
15483
15804
|
return override;
|
|
15484
15805
|
}
|
|
15485
15806
|
const vaultState = await account.fetchVault(vault);
|
|
15486
|
-
return (0,
|
|
15807
|
+
return (0, import_common22.fromWeb3Pk)(vaultState.roles.feeCollector);
|
|
15487
15808
|
}
|
|
15488
15809
|
function baseAssetMintFromVault(vaultState) {
|
|
15489
15810
|
const baseHolding = vaultState.holdings.find((holding) => holding.isBase);
|
|
15490
15811
|
if (!baseHolding) {
|
|
15491
15812
|
throw new Error("Vault has no base asset holding");
|
|
15492
15813
|
}
|
|
15493
|
-
return (0,
|
|
15814
|
+
return (0, import_common22.fromWeb3Pk)(baseHolding.mint);
|
|
15494
15815
|
}
|
|
15495
15816
|
async function resolveVaultBaseAssetMint(account, vault, override) {
|
|
15496
15817
|
if (override) {
|
|
@@ -15505,7 +15826,7 @@ async function resolveFeeAssetTokenProgram(account, vault, feeAssetMint, overrid
|
|
|
15505
15826
|
}
|
|
15506
15827
|
const vaultState = await account.fetchVault(vault);
|
|
15507
15828
|
const holding = vaultState.holdings.find(
|
|
15508
|
-
(entry) => (0,
|
|
15829
|
+
(entry) => (0, import_common22.fromWeb3Pk)(entry.mint) === feeAssetMint
|
|
15509
15830
|
);
|
|
15510
15831
|
if (!holding) {
|
|
15511
15832
|
return TOKEN_PROGRAM_ID;
|
|
@@ -15517,21 +15838,21 @@ async function resolveFeeAssetTokenProgram(account, vault, feeAssetMint, overrid
|
|
|
15517
15838
|
var CrankNavBuilder = class extends VaultBuilderBase {
|
|
15518
15839
|
async getIx(args) {
|
|
15519
15840
|
return this.program.methods.crankNav().accountsPartial({
|
|
15520
|
-
cranker: (0,
|
|
15521
|
-
vault: (0,
|
|
15522
|
-
vaultOracle: (0,
|
|
15523
|
-
vaultTrancheState: args.vaultTrancheState ? (0,
|
|
15524
|
-
shareMint: (0,
|
|
15525
|
-
juniorTrancheShareMint: args.juniorTrancheShareMint ? (0,
|
|
15526
|
-
seniorTrancheShareMint: args.seniorTrancheShareMint ? (0,
|
|
15527
|
-
feeAssetMint: (0,
|
|
15528
|
-
vaultFeeAssetAta: (0,
|
|
15529
|
-
feeVault: (0,
|
|
15530
|
-
feeVaultAta: (0,
|
|
15531
|
-
feeAssetTokenProgram: (0,
|
|
15532
|
-
associatedTokenProgram:
|
|
15533
|
-
systemProgram:
|
|
15534
|
-
}).instruction().then(
|
|
15841
|
+
cranker: (0, import_common23.toWeb3Pk)(args.cranker),
|
|
15842
|
+
vault: (0, import_common23.toWeb3Pk)(args.vault),
|
|
15843
|
+
vaultOracle: (0, import_common23.toWeb3Pk)(args.vaultOracle),
|
|
15844
|
+
vaultTrancheState: args.vaultTrancheState ? (0, import_common23.toWeb3Pk)(args.vaultTrancheState) : null,
|
|
15845
|
+
shareMint: (0, import_common23.toWeb3Pk)(args.shareMint),
|
|
15846
|
+
juniorTrancheShareMint: args.juniorTrancheShareMint ? (0, import_common23.toWeb3Pk)(args.juniorTrancheShareMint) : null,
|
|
15847
|
+
seniorTrancheShareMint: args.seniorTrancheShareMint ? (0, import_common23.toWeb3Pk)(args.seniorTrancheShareMint) : null,
|
|
15848
|
+
feeAssetMint: (0, import_common23.toWeb3Pk)(args.feeAssetMint),
|
|
15849
|
+
vaultFeeAssetAta: (0, import_common23.toWeb3Pk)(args.vaultFeeAssetAta),
|
|
15850
|
+
feeVault: (0, import_common23.toWeb3Pk)(args.feeVault),
|
|
15851
|
+
feeVaultAta: (0, import_common23.toWeb3Pk)(args.feeVaultAta),
|
|
15852
|
+
feeAssetTokenProgram: (0, import_common23.toWeb3Pk)(args.feeAssetTokenProgram),
|
|
15853
|
+
associatedTokenProgram: import_spl_token7.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
15854
|
+
systemProgram: import_web311.SystemProgram.programId
|
|
15855
|
+
}).instruction().then(import_common23.toKitInstruction);
|
|
15535
15856
|
}
|
|
15536
15857
|
async deriveIxArgs(txArgs) {
|
|
15537
15858
|
const [vaultOracle] = await this.pda.deriveVaultOraclePda(txArgs.vault);
|
|
@@ -15581,13 +15902,13 @@ var CrankNavBuilder = class extends VaultBuilderBase {
|
|
|
15581
15902
|
seniorTrancheShareMint,
|
|
15582
15903
|
feeAssetMint,
|
|
15583
15904
|
feeVault,
|
|
15584
|
-
vaultFeeAssetAta: (0,
|
|
15905
|
+
vaultFeeAssetAta: (0, import_common23.getAtaAddress)(
|
|
15585
15906
|
feeAssetMint,
|
|
15586
15907
|
txArgs.vault,
|
|
15587
15908
|
feeAssetTokenProgram,
|
|
15588
15909
|
true
|
|
15589
15910
|
),
|
|
15590
|
-
feeVaultAta: (0,
|
|
15911
|
+
feeVaultAta: (0, import_common23.getAtaAddress)(
|
|
15591
15912
|
feeAssetMint,
|
|
15592
15913
|
feeVault,
|
|
15593
15914
|
feeAssetTokenProgram,
|
|
@@ -15597,25 +15918,25 @@ var CrankNavBuilder = class extends VaultBuilderBase {
|
|
|
15597
15918
|
};
|
|
15598
15919
|
}
|
|
15599
15920
|
async buildPreambleInstructions(args) {
|
|
15600
|
-
const payer = (0,
|
|
15921
|
+
const payer = (0, import_common23.toWeb3Pk)(args.cranker);
|
|
15601
15922
|
return [
|
|
15602
|
-
(0,
|
|
15923
|
+
(0, import_spl_token7.createAssociatedTokenAccountIdempotentInstruction)(
|
|
15603
15924
|
payer,
|
|
15604
|
-
(0,
|
|
15605
|
-
(0,
|
|
15606
|
-
(0,
|
|
15607
|
-
(0,
|
|
15608
|
-
|
|
15925
|
+
(0, import_common23.toWeb3Pk)(args.vaultFeeAssetAta),
|
|
15926
|
+
(0, import_common23.toWeb3Pk)(args.vault),
|
|
15927
|
+
(0, import_common23.toWeb3Pk)(args.feeAssetMint),
|
|
15928
|
+
(0, import_common23.toWeb3Pk)(args.feeAssetTokenProgram),
|
|
15929
|
+
import_spl_token7.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
15609
15930
|
),
|
|
15610
|
-
(0,
|
|
15931
|
+
(0, import_spl_token7.createAssociatedTokenAccountIdempotentInstruction)(
|
|
15611
15932
|
payer,
|
|
15612
|
-
(0,
|
|
15613
|
-
(0,
|
|
15614
|
-
(0,
|
|
15615
|
-
(0,
|
|
15616
|
-
|
|
15933
|
+
(0, import_common23.toWeb3Pk)(args.feeVaultAta),
|
|
15934
|
+
(0, import_common23.toWeb3Pk)(args.feeVault),
|
|
15935
|
+
(0, import_common23.toWeb3Pk)(args.feeAssetMint),
|
|
15936
|
+
(0, import_common23.toWeb3Pk)(args.feeAssetTokenProgram),
|
|
15937
|
+
import_spl_token7.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
15617
15938
|
)
|
|
15618
|
-
].map(
|
|
15939
|
+
].map(import_common23.toKitInstruction);
|
|
15619
15940
|
}
|
|
15620
15941
|
async buildPlanExtras(args) {
|
|
15621
15942
|
return {
|
|
@@ -15641,29 +15962,29 @@ var CrankNavBuilder = class extends VaultBuilderBase {
|
|
|
15641
15962
|
};
|
|
15642
15963
|
|
|
15643
15964
|
// src/client/builders/crankPerformanceFees.ts
|
|
15644
|
-
var
|
|
15645
|
-
var
|
|
15646
|
-
var
|
|
15965
|
+
var import_spl_token8 = require("@solana/spl-token");
|
|
15966
|
+
var import_web312 = require("@solana/web3.js");
|
|
15967
|
+
var import_common24 = __toESM(require_dist());
|
|
15647
15968
|
var CrankPerformanceFeesBuilder = class extends VaultBuilderBase {
|
|
15648
15969
|
async getIx(args) {
|
|
15649
15970
|
return this.program.methods.crankPerformanceFees().accountsPartial({
|
|
15650
|
-
cranker: (0,
|
|
15651
|
-
vault: (0,
|
|
15652
|
-
shareMint: (0,
|
|
15653
|
-
feeCollector: (0,
|
|
15654
|
-
feeCollectorShareAta: (0,
|
|
15655
|
-
protocolFeeCollector: (0,
|
|
15656
|
-
protocolFeeCollectorShareAta: (0,
|
|
15971
|
+
cranker: (0, import_common24.toWeb3Pk)(args.cranker),
|
|
15972
|
+
vault: (0, import_common24.toWeb3Pk)(args.vault),
|
|
15973
|
+
shareMint: (0, import_common24.toWeb3Pk)(args.shareMint),
|
|
15974
|
+
feeCollector: (0, import_common24.toWeb3Pk)(args.feeCollector),
|
|
15975
|
+
feeCollectorShareAta: (0, import_common24.toWeb3Pk)(args.feeCollectorShareAta),
|
|
15976
|
+
protocolFeeCollector: (0, import_common24.toWeb3Pk)(args.protocolFeeCollector),
|
|
15977
|
+
protocolFeeCollectorShareAta: (0, import_common24.toWeb3Pk)(
|
|
15657
15978
|
args.protocolFeeCollectorShareAta
|
|
15658
15979
|
),
|
|
15659
|
-
shareTokenProgram: (0,
|
|
15660
|
-
associatedTokenProgram:
|
|
15661
|
-
systemProgram:
|
|
15662
|
-
}).instruction().then(
|
|
15980
|
+
shareTokenProgram: (0, import_common24.toWeb3Pk)(args.shareTokenProgram),
|
|
15981
|
+
associatedTokenProgram: import_spl_token8.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
15982
|
+
systemProgram: import_web312.SystemProgram.programId
|
|
15983
|
+
}).instruction().then(import_common24.toKitInstruction);
|
|
15663
15984
|
}
|
|
15664
15985
|
async deriveIxArgs(txArgs) {
|
|
15665
15986
|
const vaultState = await this.account.fetchVault(txArgs.vault);
|
|
15666
|
-
const shareMint = (0,
|
|
15987
|
+
const shareMint = (0, import_common24.fromWeb3Pk)(vaultState.mint);
|
|
15667
15988
|
const shareTokenProgram = txArgs.shareTokenProgram ?? tokenProgramAddressFromIdlEnum(vaultState.mintTokenProgram);
|
|
15668
15989
|
const feeCollector = await resolveVaultFeeCollector(
|
|
15669
15990
|
this.account,
|
|
@@ -15680,7 +16001,7 @@ var CrankPerformanceFeesBuilder = class extends VaultBuilderBase {
|
|
|
15680
16001
|
feeCollector,
|
|
15681
16002
|
// The vault fee collector is a role that is routinely a Squads vault
|
|
15682
16003
|
// (off-curve PDA), so allow an off-curve owner here too.
|
|
15683
|
-
feeCollectorShareAta: (0,
|
|
16004
|
+
feeCollectorShareAta: (0, import_common24.getAtaAddress)(
|
|
15684
16005
|
shareMint,
|
|
15685
16006
|
feeCollector,
|
|
15686
16007
|
shareTokenProgram,
|
|
@@ -15690,7 +16011,7 @@ var CrankPerformanceFeesBuilder = class extends VaultBuilderBase {
|
|
|
15690
16011
|
// The protocol fee recipient is a hardcoded protocol-controlled address
|
|
15691
16012
|
// that may be off-curve (e.g. a PDA / multisig vault), so allow an
|
|
15692
16013
|
// off-curve owner when deriving its ATA.
|
|
15693
|
-
protocolFeeCollectorShareAta: (0,
|
|
16014
|
+
protocolFeeCollectorShareAta: (0, import_common24.getAtaAddress)(
|
|
15694
16015
|
shareMint,
|
|
15695
16016
|
protocolFeeCollector,
|
|
15696
16017
|
shareTokenProgram,
|
|
@@ -15716,7 +16037,7 @@ var CrankPerformanceFeesBuilder = class extends VaultBuilderBase {
|
|
|
15716
16037
|
};
|
|
15717
16038
|
|
|
15718
16039
|
// src/client/builders/setExternalLiquidity.ts
|
|
15719
|
-
var
|
|
16040
|
+
var import_common25 = __toESM(require_dist());
|
|
15720
16041
|
function toExternalLiquiditySource(source) {
|
|
15721
16042
|
switch (source) {
|
|
15722
16043
|
case 0:
|
|
@@ -15732,11 +16053,11 @@ var SetExternalLiquidityBuilder = class extends VaultBuilderBase {
|
|
|
15732
16053
|
return this.program.methods.setExternalLiquidity({
|
|
15733
16054
|
index: args.args.index,
|
|
15734
16055
|
source: args.args.source,
|
|
15735
|
-
userAccount: (0,
|
|
16056
|
+
userAccount: (0, import_common25.toWeb3Pk)(args.args.userAccount)
|
|
15736
16057
|
}).accountsPartial({
|
|
15737
|
-
curator: (0,
|
|
15738
|
-
vault: (0,
|
|
15739
|
-
}).instruction().then(
|
|
16058
|
+
curator: (0, import_common25.toWeb3Pk)(args.curator),
|
|
16059
|
+
vault: (0, import_common25.toWeb3Pk)(args.vault)
|
|
16060
|
+
}).instruction().then(import_common25.toKitInstruction);
|
|
15740
16061
|
}
|
|
15741
16062
|
async deriveIxArgs(txArgs) {
|
|
15742
16063
|
return {
|
|
@@ -15757,16 +16078,16 @@ var SetExternalLiquidityBuilder = class extends VaultBuilderBase {
|
|
|
15757
16078
|
};
|
|
15758
16079
|
|
|
15759
16080
|
// src/client/builders/setManagerWithdrawDestination.ts
|
|
15760
|
-
var
|
|
16081
|
+
var import_common26 = __toESM(require_dist());
|
|
15761
16082
|
var SetManagerWithdrawDestinationBuilder = class extends VaultBuilderBase {
|
|
15762
16083
|
async getIx(args) {
|
|
15763
16084
|
return this.program.methods.setManagerWithdrawDestination({
|
|
15764
16085
|
slot: args.args.slot,
|
|
15765
|
-
address: (0,
|
|
16086
|
+
address: (0, import_common26.toWeb3Pk)(args.args.address)
|
|
15766
16087
|
}).accountsPartial({
|
|
15767
|
-
curator: (0,
|
|
15768
|
-
vault: (0,
|
|
15769
|
-
}).instruction().then(
|
|
16088
|
+
curator: (0, import_common26.toWeb3Pk)(args.curator),
|
|
16089
|
+
vault: (0, import_common26.toWeb3Pk)(args.vault)
|
|
16090
|
+
}).instruction().then(import_common26.toKitInstruction);
|
|
15770
16091
|
}
|
|
15771
16092
|
async deriveIxArgs(txArgs) {
|
|
15772
16093
|
return {
|
|
@@ -15786,17 +16107,17 @@ var SetManagerWithdrawDestinationBuilder = class extends VaultBuilderBase {
|
|
|
15786
16107
|
};
|
|
15787
16108
|
|
|
15788
16109
|
// src/client/builders/setAssetPriceOracle.ts
|
|
15789
|
-
var
|
|
16110
|
+
var import_common27 = __toESM(require_dist());
|
|
15790
16111
|
var SetAssetPriceOracleBuilder = class extends VaultBuilderBase {
|
|
15791
16112
|
async getIx(args) {
|
|
15792
16113
|
return this.program.methods.setAssetPriceOracle({
|
|
15793
|
-
mint: (0,
|
|
16114
|
+
mint: (0, import_common27.toWeb3Pk)(args.args.mint),
|
|
15794
16115
|
priceOracleType: args.args.priceOracleType,
|
|
15795
|
-
priceOracleAccount: (0,
|
|
16116
|
+
priceOracleAccount: (0, import_common27.toWeb3Pk)(args.args.priceOracleAccount)
|
|
15796
16117
|
}).accountsPartial({
|
|
15797
|
-
curator: (0,
|
|
15798
|
-
vault: (0,
|
|
15799
|
-
}).instruction().then(
|
|
16118
|
+
curator: (0, import_common27.toWeb3Pk)(args.curator),
|
|
16119
|
+
vault: (0, import_common27.toWeb3Pk)(args.vault)
|
|
16120
|
+
}).instruction().then(import_common27.toKitInstruction);
|
|
15800
16121
|
}
|
|
15801
16122
|
async deriveIxArgs(txArgs) {
|
|
15802
16123
|
return {
|
|
@@ -15817,19 +16138,19 @@ var SetAssetPriceOracleBuilder = class extends VaultBuilderBase {
|
|
|
15817
16138
|
};
|
|
15818
16139
|
|
|
15819
16140
|
// src/client/builders/updateAssetPrice.ts
|
|
15820
|
-
var
|
|
15821
|
-
var
|
|
16141
|
+
var import_core8 = require("@anchor-lang/core");
|
|
16142
|
+
var import_common28 = __toESM(require_dist());
|
|
15822
16143
|
var DEFAULT_PRICE_MAX_AGE_SECS = 90n;
|
|
15823
16144
|
var UpdateAssetPriceBuilder = class extends VaultBuilderBase {
|
|
15824
16145
|
async getIx(args) {
|
|
15825
16146
|
return this.program.methods.updateAssetPrice({
|
|
15826
|
-
mint: (0,
|
|
16147
|
+
mint: (0, import_common28.toWeb3Pk)(args.args.mint),
|
|
15827
16148
|
maxAgeSecs: args.args.maxAgeSecs
|
|
15828
16149
|
}).accountsPartial({
|
|
15829
|
-
updater: (0,
|
|
15830
|
-
vault: (0,
|
|
15831
|
-
oracleAccount: (0,
|
|
15832
|
-
}).instruction().then(
|
|
16150
|
+
updater: (0, import_common28.toWeb3Pk)(args.updater),
|
|
16151
|
+
vault: (0, import_common28.toWeb3Pk)(args.vault),
|
|
16152
|
+
oracleAccount: (0, import_common28.toWeb3Pk)(args.oracleAccount)
|
|
16153
|
+
}).instruction().then(import_common28.toKitInstruction);
|
|
15833
16154
|
}
|
|
15834
16155
|
async deriveIxArgs(txArgs) {
|
|
15835
16156
|
return {
|
|
@@ -15838,7 +16159,7 @@ var UpdateAssetPriceBuilder = class extends VaultBuilderBase {
|
|
|
15838
16159
|
oracleAccount: txArgs.oracleAccount,
|
|
15839
16160
|
args: {
|
|
15840
16161
|
mint: txArgs.mint,
|
|
15841
|
-
maxAgeSecs: new
|
|
16162
|
+
maxAgeSecs: new import_core8.BN(
|
|
15842
16163
|
(txArgs.maxAgeSecs ?? DEFAULT_PRICE_MAX_AGE_SECS).toString()
|
|
15843
16164
|
)
|
|
15844
16165
|
}
|
|
@@ -15861,18 +16182,18 @@ var UpdateAssetPriceBuilder = class extends VaultBuilderBase {
|
|
|
15861
16182
|
};
|
|
15862
16183
|
|
|
15863
16184
|
// src/client/builders/updateConsensusOracle.ts
|
|
15864
|
-
var
|
|
16185
|
+
var import_common29 = __toESM(require_dist());
|
|
15865
16186
|
var UpdateConsensusOracleBuilder = class extends VaultBuilderBase {
|
|
15866
16187
|
async getIx(args) {
|
|
15867
16188
|
return this.program.methods.updateConsensusOracle({
|
|
15868
16189
|
updates: toAnchorConsensusUpdates(args.updates)
|
|
15869
16190
|
}).accountsPartial({
|
|
15870
|
-
signer: (0,
|
|
15871
|
-
vault: (0,
|
|
15872
|
-
vaultOracle: (0,
|
|
15873
|
-
assetMint: args.assetMint ? (0,
|
|
15874
|
-
assetTokenProgram: args.assetTokenProgram ? (0,
|
|
15875
|
-
}).instruction().then(
|
|
16191
|
+
signer: (0, import_common29.toWeb3Pk)(args.signer),
|
|
16192
|
+
vault: (0, import_common29.toWeb3Pk)(args.vault),
|
|
16193
|
+
vaultOracle: (0, import_common29.toWeb3Pk)(args.vaultOracle),
|
|
16194
|
+
assetMint: args.assetMint ? (0, import_common29.toWeb3Pk)(args.assetMint) : null,
|
|
16195
|
+
assetTokenProgram: args.assetTokenProgram ? (0, import_common29.toWeb3Pk)(args.assetTokenProgram) : null
|
|
16196
|
+
}).instruction().then(import_common29.toKitInstruction);
|
|
15876
16197
|
}
|
|
15877
16198
|
async deriveIxArgs(txArgs) {
|
|
15878
16199
|
const [derivedVaultOracle] = await this.pda.deriveVaultOraclePda(
|
|
@@ -15916,25 +16237,25 @@ var UpdateConsensusOracleBuilder = class extends VaultBuilderBase {
|
|
|
15916
16237
|
};
|
|
15917
16238
|
|
|
15918
16239
|
// src/client/builders/executeShareSwap.ts
|
|
15919
|
-
var
|
|
15920
|
-
var
|
|
15921
|
-
var
|
|
15922
|
-
var
|
|
16240
|
+
var import_core9 = require("@anchor-lang/core");
|
|
16241
|
+
var import_spl_token9 = require("@solana/spl-token");
|
|
16242
|
+
var import_web313 = require("@solana/web3.js");
|
|
16243
|
+
var import_common30 = __toESM(require_dist());
|
|
15923
16244
|
var ExecuteShareSwapBuilder = class extends VaultBuilderBase {
|
|
15924
16245
|
getIxAccounts(args) {
|
|
15925
16246
|
return {
|
|
15926
|
-
user: (0,
|
|
15927
|
-
vault: (0,
|
|
15928
|
-
vaultOracle: (0,
|
|
15929
|
-
vaultTrancheState: (0,
|
|
15930
|
-
shareMint: (0,
|
|
15931
|
-
trancheShareMint: (0,
|
|
15932
|
-
userShareAta: (0,
|
|
15933
|
-
userTrancheShareAta: (0,
|
|
15934
|
-
shareTokenProgram: (0,
|
|
15935
|
-
trancheShareTokenProgram: (0,
|
|
15936
|
-
associatedTokenProgram:
|
|
15937
|
-
systemProgram:
|
|
16247
|
+
user: (0, import_common30.toWeb3Pk)(args.user),
|
|
16248
|
+
vault: (0, import_common30.toWeb3Pk)(args.vault),
|
|
16249
|
+
vaultOracle: (0, import_common30.toWeb3Pk)(args.vaultOracle),
|
|
16250
|
+
vaultTrancheState: (0, import_common30.toWeb3Pk)(args.vaultTrancheState),
|
|
16251
|
+
shareMint: (0, import_common30.toWeb3Pk)(args.shareMint),
|
|
16252
|
+
trancheShareMint: (0, import_common30.toWeb3Pk)(args.trancheShareMint),
|
|
16253
|
+
userShareAta: (0, import_common30.toWeb3Pk)(args.userShareAta),
|
|
16254
|
+
userTrancheShareAta: (0, import_common30.toWeb3Pk)(args.userTrancheShareAta),
|
|
16255
|
+
shareTokenProgram: (0, import_common30.toWeb3Pk)(args.shareTokenProgram),
|
|
16256
|
+
trancheShareTokenProgram: (0, import_common30.toWeb3Pk)(args.trancheShareTokenProgram),
|
|
16257
|
+
associatedTokenProgram: import_spl_token9.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
16258
|
+
systemProgram: import_web313.SystemProgram.programId
|
|
15938
16259
|
};
|
|
15939
16260
|
}
|
|
15940
16261
|
getIxData(args) {
|
|
@@ -15945,7 +16266,7 @@ var ExecuteShareSwapBuilder = class extends VaultBuilderBase {
|
|
|
15945
16266
|
}
|
|
15946
16267
|
async getIx(args) {
|
|
15947
16268
|
const data = this.getIxData(args);
|
|
15948
|
-
return this.program.methods.executeShareSwap(data.kind, data.shareAmount).accountsPartial(this.getIxAccounts(args)).instruction().then(
|
|
16269
|
+
return this.program.methods.executeShareSwap(data.kind, data.shareAmount).accountsPartial(this.getIxAccounts(args)).instruction().then(import_common30.toKitInstruction);
|
|
15949
16270
|
}
|
|
15950
16271
|
async deriveIxArgs(txArgs) {
|
|
15951
16272
|
const [
|
|
@@ -15976,11 +16297,11 @@ var ExecuteShareSwapBuilder = class extends VaultBuilderBase {
|
|
|
15976
16297
|
shareMint,
|
|
15977
16298
|
trancheShareMint,
|
|
15978
16299
|
kind: txArgs.kind,
|
|
15979
|
-
shareAmount: new
|
|
16300
|
+
shareAmount: new import_core9.BN(txArgs.shareAmount.toString()),
|
|
15980
16301
|
shareTokenProgram,
|
|
15981
16302
|
trancheShareTokenProgram,
|
|
15982
|
-
userShareAta: (0,
|
|
15983
|
-
userTrancheShareAta: (0,
|
|
16303
|
+
userShareAta: (0, import_common30.getAtaAddress)(shareMint, txArgs.user, shareTokenProgram),
|
|
16304
|
+
userTrancheShareAta: (0, import_common30.getAtaAddress)(
|
|
15984
16305
|
trancheShareMint,
|
|
15985
16306
|
txArgs.user,
|
|
15986
16307
|
trancheShareTokenProgram
|
|
@@ -15988,16 +16309,16 @@ var ExecuteShareSwapBuilder = class extends VaultBuilderBase {
|
|
|
15988
16309
|
};
|
|
15989
16310
|
}
|
|
15990
16311
|
async buildPreambleInstructions(args) {
|
|
15991
|
-
const payer = (0,
|
|
15992
|
-
const createUserTrancheShareAta = (0,
|
|
16312
|
+
const payer = (0, import_common30.toWeb3Pk)(args.user);
|
|
16313
|
+
const createUserTrancheShareAta = (0, import_spl_token9.createAssociatedTokenAccountIdempotentInstruction)(
|
|
15993
16314
|
payer,
|
|
15994
|
-
(0,
|
|
16315
|
+
(0, import_common30.toWeb3Pk)(args.userTrancheShareAta),
|
|
15995
16316
|
payer,
|
|
15996
|
-
(0,
|
|
15997
|
-
(0,
|
|
15998
|
-
|
|
16317
|
+
(0, import_common30.toWeb3Pk)(args.trancheShareMint),
|
|
16318
|
+
(0, import_common30.toWeb3Pk)(args.trancheShareTokenProgram),
|
|
16319
|
+
import_spl_token9.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
15999
16320
|
);
|
|
16000
|
-
return [createUserTrancheShareAta].map(
|
|
16321
|
+
return [createUserTrancheShareAta].map(import_common30.toKitInstruction);
|
|
16001
16322
|
}
|
|
16002
16323
|
async buildPlanExtras(args) {
|
|
16003
16324
|
return {
|
|
@@ -16019,25 +16340,25 @@ var ExecuteShareSwapBuilder = class extends VaultBuilderBase {
|
|
|
16019
16340
|
};
|
|
16020
16341
|
|
|
16021
16342
|
// src/client/builders/executeDeposit.ts
|
|
16022
|
-
var
|
|
16023
|
-
var
|
|
16024
|
-
var
|
|
16343
|
+
var import_core10 = require("@anchor-lang/core");
|
|
16344
|
+
var import_spl_token10 = require("@solana/spl-token");
|
|
16345
|
+
var import_common31 = __toESM(require_dist());
|
|
16025
16346
|
var ExecuteDepositBuilder = class extends VaultBuilderBase {
|
|
16026
16347
|
getIxAccounts(args) {
|
|
16027
16348
|
return {
|
|
16028
|
-
user: (0,
|
|
16029
|
-
vault: (0,
|
|
16030
|
-
vaultOracle: (0,
|
|
16031
|
-
vaultTrancheState: args.vaultTrancheState ? (0,
|
|
16032
|
-
assetMint: (0,
|
|
16033
|
-
shareMint: (0,
|
|
16034
|
-
userAssetAta: (0,
|
|
16035
|
-
vaultAssetAta: (0,
|
|
16036
|
-
feeVault: (0,
|
|
16037
|
-
feeVaultAta: (0,
|
|
16038
|
-
userShareAta: (0,
|
|
16039
|
-
assetTokenProgram: (0,
|
|
16040
|
-
shareTokenProgram: (0,
|
|
16349
|
+
user: (0, import_common31.toWeb3Pk)(args.user),
|
|
16350
|
+
vault: (0, import_common31.toWeb3Pk)(args.vault),
|
|
16351
|
+
vaultOracle: (0, import_common31.toWeb3Pk)(args.vaultOracle),
|
|
16352
|
+
vaultTrancheState: args.vaultTrancheState ? (0, import_common31.toWeb3Pk)(args.vaultTrancheState) : null,
|
|
16353
|
+
assetMint: (0, import_common31.toWeb3Pk)(args.assetMint),
|
|
16354
|
+
shareMint: (0, import_common31.toWeb3Pk)(args.shareMint),
|
|
16355
|
+
userAssetAta: (0, import_common31.toWeb3Pk)(args.userAssetAta),
|
|
16356
|
+
vaultAssetAta: (0, import_common31.toWeb3Pk)(args.vaultAssetAta),
|
|
16357
|
+
feeVault: (0, import_common31.toWeb3Pk)(args.feeVault),
|
|
16358
|
+
feeVaultAta: (0, import_common31.toWeb3Pk)(args.feeVaultAta),
|
|
16359
|
+
userShareAta: (0, import_common31.toWeb3Pk)(args.userShareAta),
|
|
16360
|
+
assetTokenProgram: (0, import_common31.toWeb3Pk)(args.assetTokenProgram),
|
|
16361
|
+
shareTokenProgram: (0, import_common31.toWeb3Pk)(args.shareTokenProgram)
|
|
16041
16362
|
};
|
|
16042
16363
|
}
|
|
16043
16364
|
getIxData(args) {
|
|
@@ -16054,7 +16375,7 @@ var ExecuteDepositBuilder = class extends VaultBuilderBase {
|
|
|
16054
16375
|
) : this.program.methods.executeDeposit(data.amount);
|
|
16055
16376
|
return methods.accountsPartial(
|
|
16056
16377
|
this.getIxAccounts(args)
|
|
16057
|
-
).instruction().then(
|
|
16378
|
+
).instruction().then(import_common31.toKitInstruction);
|
|
16058
16379
|
}
|
|
16059
16380
|
async deriveIxArgs(txArgs) {
|
|
16060
16381
|
const connection = this.program.provider.connection;
|
|
@@ -16093,61 +16414,61 @@ var ExecuteDepositBuilder = class extends VaultBuilderBase {
|
|
|
16093
16414
|
vaultTrancheState,
|
|
16094
16415
|
assetMint: txArgs.assetMint,
|
|
16095
16416
|
shareMint: txArgs.shareMint,
|
|
16096
|
-
amount: new
|
|
16417
|
+
amount: new import_core10.BN(txArgs.amount.toString()),
|
|
16097
16418
|
addressSeeds: txArgs.addressSeeds,
|
|
16098
16419
|
assetTokenProgram,
|
|
16099
16420
|
shareTokenProgram,
|
|
16100
|
-
userAssetAta: txArgs.userAssetAta ?? (0,
|
|
16101
|
-
vaultAssetAta: (0,
|
|
16421
|
+
userAssetAta: txArgs.userAssetAta ?? (0, import_common31.getAtaAddress)(txArgs.assetMint, txArgs.user, assetTokenProgram),
|
|
16422
|
+
vaultAssetAta: (0, import_common31.getAtaAddress)(
|
|
16102
16423
|
txArgs.assetMint,
|
|
16103
16424
|
txArgs.vault,
|
|
16104
16425
|
assetTokenProgram,
|
|
16105
16426
|
true
|
|
16106
16427
|
),
|
|
16107
16428
|
feeVault,
|
|
16108
|
-
feeVaultAta: (0,
|
|
16429
|
+
feeVaultAta: (0, import_common31.getAtaAddress)(
|
|
16109
16430
|
txArgs.assetMint,
|
|
16110
16431
|
feeVault,
|
|
16111
16432
|
assetTokenProgram,
|
|
16112
16433
|
true
|
|
16113
16434
|
),
|
|
16114
|
-
userShareAta: txArgs.userShareAta ?? (0,
|
|
16435
|
+
userShareAta: txArgs.userShareAta ?? (0, import_common31.getAtaAddress)(txArgs.shareMint, txArgs.user, shareTokenProgram)
|
|
16115
16436
|
};
|
|
16116
16437
|
}
|
|
16117
16438
|
async buildPreambleInstructions(args) {
|
|
16118
|
-
const payer = (0,
|
|
16119
|
-
const createVaultAssetAta = (0,
|
|
16439
|
+
const payer = (0, import_common31.toWeb3Pk)(args.user);
|
|
16440
|
+
const createVaultAssetAta = (0, import_spl_token10.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16120
16441
|
payer,
|
|
16121
|
-
(0,
|
|
16122
|
-
(0,
|
|
16123
|
-
(0,
|
|
16124
|
-
(0,
|
|
16125
|
-
|
|
16442
|
+
(0, import_common31.toWeb3Pk)(args.vaultAssetAta),
|
|
16443
|
+
(0, import_common31.toWeb3Pk)(args.vault),
|
|
16444
|
+
(0, import_common31.toWeb3Pk)(args.assetMint),
|
|
16445
|
+
(0, import_common31.toWeb3Pk)(args.assetTokenProgram),
|
|
16446
|
+
import_spl_token10.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16126
16447
|
);
|
|
16127
|
-
const createFeeVaultAta = (0,
|
|
16448
|
+
const createFeeVaultAta = (0, import_spl_token10.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16128
16449
|
payer,
|
|
16129
|
-
(0,
|
|
16130
|
-
(0,
|
|
16131
|
-
(0,
|
|
16132
|
-
(0,
|
|
16133
|
-
|
|
16450
|
+
(0, import_common31.toWeb3Pk)(args.feeVaultAta),
|
|
16451
|
+
(0, import_common31.toWeb3Pk)(args.feeVault),
|
|
16452
|
+
(0, import_common31.toWeb3Pk)(args.assetMint),
|
|
16453
|
+
(0, import_common31.toWeb3Pk)(args.assetTokenProgram),
|
|
16454
|
+
import_spl_token10.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16134
16455
|
);
|
|
16135
|
-
const defaultUserShareAta = (0,
|
|
16456
|
+
const defaultUserShareAta = (0, import_common31.getAtaAddress)(
|
|
16136
16457
|
args.shareMint,
|
|
16137
16458
|
args.user,
|
|
16138
16459
|
args.shareTokenProgram
|
|
16139
16460
|
);
|
|
16140
|
-
const createUserShareAta = (0,
|
|
16141
|
-
(0,
|
|
16142
|
-
) ? (0,
|
|
16461
|
+
const createUserShareAta = (0, import_common31.toWeb3Pk)(args.userShareAta).equals(
|
|
16462
|
+
(0, import_common31.toWeb3Pk)(defaultUserShareAta)
|
|
16463
|
+
) ? (0, import_spl_token10.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16143
16464
|
payer,
|
|
16144
|
-
(0,
|
|
16465
|
+
(0, import_common31.toWeb3Pk)(args.userShareAta),
|
|
16145
16466
|
payer,
|
|
16146
|
-
(0,
|
|
16147
|
-
(0,
|
|
16148
|
-
|
|
16467
|
+
(0, import_common31.toWeb3Pk)(args.shareMint),
|
|
16468
|
+
(0, import_common31.toWeb3Pk)(args.shareTokenProgram),
|
|
16469
|
+
import_spl_token10.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16149
16470
|
) : null;
|
|
16150
|
-
return [createVaultAssetAta, createFeeVaultAta, createUserShareAta].filter((ix) => ix != null).map(
|
|
16471
|
+
return [createVaultAssetAta, createFeeVaultAta, createUserShareAta].filter((ix) => ix != null).map(import_common31.toKitInstruction);
|
|
16151
16472
|
}
|
|
16152
16473
|
async buildPlanExtras(args) {
|
|
16153
16474
|
return {
|
|
@@ -16167,28 +16488,28 @@ var ExecuteDepositBuilder = class extends VaultBuilderBase {
|
|
|
16167
16488
|
};
|
|
16168
16489
|
|
|
16169
16490
|
// src/client/builders/executeTrancheDeposit.ts
|
|
16170
|
-
var
|
|
16171
|
-
var
|
|
16172
|
-
var
|
|
16173
|
-
var
|
|
16491
|
+
var import_core11 = require("@anchor-lang/core");
|
|
16492
|
+
var import_spl_token11 = require("@solana/spl-token");
|
|
16493
|
+
var import_web314 = require("@solana/web3.js");
|
|
16494
|
+
var import_common32 = __toESM(require_dist());
|
|
16174
16495
|
var ExecuteTrancheDepositBuilder = class extends VaultBuilderBase {
|
|
16175
16496
|
getIxAccounts(args) {
|
|
16176
16497
|
return {
|
|
16177
|
-
user: (0,
|
|
16178
|
-
vault: (0,
|
|
16179
|
-
vaultOracle: (0,
|
|
16180
|
-
vaultTrancheState: (0,
|
|
16181
|
-
assetMint: (0,
|
|
16182
|
-
trancheShareMint: (0,
|
|
16183
|
-
userAssetAta: (0,
|
|
16184
|
-
vaultAssetAta: (0,
|
|
16185
|
-
feeVault: (0,
|
|
16186
|
-
feeVaultAta: (0,
|
|
16187
|
-
userTrancheShareAta: (0,
|
|
16188
|
-
assetTokenProgram: (0,
|
|
16189
|
-
shareTokenProgram: (0,
|
|
16190
|
-
associatedTokenProgram:
|
|
16191
|
-
systemProgram:
|
|
16498
|
+
user: (0, import_common32.toWeb3Pk)(args.user),
|
|
16499
|
+
vault: (0, import_common32.toWeb3Pk)(args.vault),
|
|
16500
|
+
vaultOracle: (0, import_common32.toWeb3Pk)(args.vaultOracle),
|
|
16501
|
+
vaultTrancheState: (0, import_common32.toWeb3Pk)(args.vaultTrancheState),
|
|
16502
|
+
assetMint: (0, import_common32.toWeb3Pk)(args.assetMint),
|
|
16503
|
+
trancheShareMint: (0, import_common32.toWeb3Pk)(args.trancheShareMint),
|
|
16504
|
+
userAssetAta: (0, import_common32.toWeb3Pk)(args.userAssetAta),
|
|
16505
|
+
vaultAssetAta: (0, import_common32.toWeb3Pk)(args.vaultAssetAta),
|
|
16506
|
+
feeVault: (0, import_common32.toWeb3Pk)(args.feeVault),
|
|
16507
|
+
feeVaultAta: (0, import_common32.toWeb3Pk)(args.feeVaultAta),
|
|
16508
|
+
userTrancheShareAta: (0, import_common32.toWeb3Pk)(args.userTrancheShareAta),
|
|
16509
|
+
assetTokenProgram: (0, import_common32.toWeb3Pk)(args.assetTokenProgram),
|
|
16510
|
+
shareTokenProgram: (0, import_common32.toWeb3Pk)(args.shareTokenProgram),
|
|
16511
|
+
associatedTokenProgram: import_spl_token11.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
16512
|
+
systemProgram: import_web314.SystemProgram.programId
|
|
16192
16513
|
};
|
|
16193
16514
|
}
|
|
16194
16515
|
getIxData(args) {
|
|
@@ -16207,7 +16528,7 @@ var ExecuteTrancheDepositBuilder = class extends VaultBuilderBase {
|
|
|
16207
16528
|
) : this.program.methods.executeTrancheDeposit(data.kind, data.amount);
|
|
16208
16529
|
return methods.accountsPartial(
|
|
16209
16530
|
this.getIxAccounts(args)
|
|
16210
|
-
).instruction().then(
|
|
16531
|
+
).instruction().then(import_common32.toKitInstruction);
|
|
16211
16532
|
}
|
|
16212
16533
|
async deriveIxArgs(txArgs) {
|
|
16213
16534
|
const connection = this.program.provider.connection;
|
|
@@ -16236,29 +16557,29 @@ var ExecuteTrancheDepositBuilder = class extends VaultBuilderBase {
|
|
|
16236
16557
|
assetMint: txArgs.assetMint,
|
|
16237
16558
|
trancheShareMint,
|
|
16238
16559
|
kind: txArgs.kind,
|
|
16239
|
-
amount: new
|
|
16560
|
+
amount: new import_core11.BN(txArgs.amount.toString()),
|
|
16240
16561
|
addressSeeds: txArgs.addressSeeds,
|
|
16241
16562
|
assetTokenProgram,
|
|
16242
16563
|
shareTokenProgram,
|
|
16243
|
-
userAssetAta: (0,
|
|
16564
|
+
userAssetAta: (0, import_common32.getAtaAddress)(
|
|
16244
16565
|
txArgs.assetMint,
|
|
16245
16566
|
txArgs.user,
|
|
16246
16567
|
assetTokenProgram
|
|
16247
16568
|
),
|
|
16248
|
-
vaultAssetAta: (0,
|
|
16569
|
+
vaultAssetAta: (0, import_common32.getAtaAddress)(
|
|
16249
16570
|
txArgs.assetMint,
|
|
16250
16571
|
txArgs.vault,
|
|
16251
16572
|
assetTokenProgram,
|
|
16252
16573
|
true
|
|
16253
16574
|
),
|
|
16254
16575
|
feeVault,
|
|
16255
|
-
feeVaultAta: (0,
|
|
16576
|
+
feeVaultAta: (0, import_common32.getAtaAddress)(
|
|
16256
16577
|
txArgs.assetMint,
|
|
16257
16578
|
feeVault,
|
|
16258
16579
|
assetTokenProgram,
|
|
16259
16580
|
true
|
|
16260
16581
|
),
|
|
16261
|
-
userTrancheShareAta: (0,
|
|
16582
|
+
userTrancheShareAta: (0, import_common32.getAtaAddress)(
|
|
16262
16583
|
trancheShareMint,
|
|
16263
16584
|
txArgs.user,
|
|
16264
16585
|
shareTokenProgram
|
|
@@ -16266,33 +16587,33 @@ var ExecuteTrancheDepositBuilder = class extends VaultBuilderBase {
|
|
|
16266
16587
|
};
|
|
16267
16588
|
}
|
|
16268
16589
|
async buildPreambleInstructions(args) {
|
|
16269
|
-
const payer = (0,
|
|
16270
|
-
const createVaultAssetAta = (0,
|
|
16590
|
+
const payer = (0, import_common32.toWeb3Pk)(args.user);
|
|
16591
|
+
const createVaultAssetAta = (0, import_spl_token11.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16271
16592
|
payer,
|
|
16272
|
-
(0,
|
|
16273
|
-
(0,
|
|
16274
|
-
(0,
|
|
16275
|
-
(0,
|
|
16276
|
-
|
|
16593
|
+
(0, import_common32.toWeb3Pk)(args.vaultAssetAta),
|
|
16594
|
+
(0, import_common32.toWeb3Pk)(args.vault),
|
|
16595
|
+
(0, import_common32.toWeb3Pk)(args.assetMint),
|
|
16596
|
+
(0, import_common32.toWeb3Pk)(args.assetTokenProgram),
|
|
16597
|
+
import_spl_token11.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16277
16598
|
);
|
|
16278
|
-
const createUserShareAta = (0,
|
|
16599
|
+
const createUserShareAta = (0, import_spl_token11.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16279
16600
|
payer,
|
|
16280
|
-
(0,
|
|
16601
|
+
(0, import_common32.toWeb3Pk)(args.userTrancheShareAta),
|
|
16281
16602
|
payer,
|
|
16282
|
-
(0,
|
|
16283
|
-
(0,
|
|
16284
|
-
|
|
16603
|
+
(0, import_common32.toWeb3Pk)(args.trancheShareMint),
|
|
16604
|
+
(0, import_common32.toWeb3Pk)(args.shareTokenProgram),
|
|
16605
|
+
import_spl_token11.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16285
16606
|
);
|
|
16286
|
-
const createFeeVaultAta = (0,
|
|
16607
|
+
const createFeeVaultAta = (0, import_spl_token11.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16287
16608
|
payer,
|
|
16288
|
-
(0,
|
|
16289
|
-
(0,
|
|
16290
|
-
(0,
|
|
16291
|
-
(0,
|
|
16292
|
-
|
|
16609
|
+
(0, import_common32.toWeb3Pk)(args.feeVaultAta),
|
|
16610
|
+
(0, import_common32.toWeb3Pk)(args.feeVault),
|
|
16611
|
+
(0, import_common32.toWeb3Pk)(args.assetMint),
|
|
16612
|
+
(0, import_common32.toWeb3Pk)(args.assetTokenProgram),
|
|
16613
|
+
import_spl_token11.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16293
16614
|
);
|
|
16294
16615
|
return [createVaultAssetAta, createFeeVaultAta, createUserShareAta].map(
|
|
16295
|
-
|
|
16616
|
+
import_common32.toKitInstruction
|
|
16296
16617
|
);
|
|
16297
16618
|
}
|
|
16298
16619
|
async buildPlanExtras(args) {
|
|
@@ -16315,27 +16636,27 @@ var ExecuteTrancheDepositBuilder = class extends VaultBuilderBase {
|
|
|
16315
16636
|
};
|
|
16316
16637
|
|
|
16317
16638
|
// src/client/builders/executeTrancheWithdraw.ts
|
|
16318
|
-
var
|
|
16319
|
-
var
|
|
16320
|
-
var
|
|
16321
|
-
var
|
|
16639
|
+
var import_core12 = require("@anchor-lang/core");
|
|
16640
|
+
var import_spl_token12 = require("@solana/spl-token");
|
|
16641
|
+
var import_web316 = require("@solana/web3.js");
|
|
16642
|
+
var import_common34 = __toESM(require_dist());
|
|
16322
16643
|
|
|
16323
16644
|
// src/client/builders/externalLiquidity.ts
|
|
16324
16645
|
var import_kit7 = require("@solana/kit");
|
|
16325
|
-
var
|
|
16326
|
-
var
|
|
16646
|
+
var import_web315 = require("@solana/web3.js");
|
|
16647
|
+
var import_common33 = __toESM(require_dist());
|
|
16327
16648
|
var import_marginfi = __toESM(require_dist2());
|
|
16328
16649
|
function parseMarginfiSlot(slot) {
|
|
16329
16650
|
const data = slot?.data;
|
|
16330
16651
|
if (!data || data.length < 40) return null;
|
|
16331
16652
|
if (data[0] !== 1) return null;
|
|
16332
16653
|
const pubkeyBytes = new Uint8Array(data.slice(8, 40));
|
|
16333
|
-
const userAccount = new
|
|
16654
|
+
const userAccount = new import_web315.PublicKey(pubkeyBytes).toBase58();
|
|
16334
16655
|
return { userAccount };
|
|
16335
16656
|
}
|
|
16336
16657
|
function toWeb3AccountMeta(account) {
|
|
16337
16658
|
return {
|
|
16338
|
-
pubkey: new
|
|
16659
|
+
pubkey: new import_web315.PublicKey(account.address),
|
|
16339
16660
|
isWritable: account.role === import_kit7.AccountRole.WRITABLE || account.role === import_kit7.AccountRole.WRITABLE_SIGNER,
|
|
16340
16661
|
isSigner: account.role === import_kit7.AccountRole.READONLY_SIGNER || account.role === import_kit7.AccountRole.WRITABLE_SIGNER
|
|
16341
16662
|
};
|
|
@@ -16374,7 +16695,7 @@ function resolveExternalWithdraw({
|
|
|
16374
16695
|
};
|
|
16375
16696
|
}
|
|
16376
16697
|
const marginfiClient = new import_marginfi.CpiClient({ accounts: marginfiAccounts });
|
|
16377
|
-
const withdrawRefs = (0,
|
|
16698
|
+
const withdrawRefs = (0, import_common33.createCpiRefs)([
|
|
16378
16699
|
marginfiClient.withdraw_cpi({
|
|
16379
16700
|
marginfiAccount: slot0.userAccount,
|
|
16380
16701
|
authority: vault,
|
|
@@ -16394,14 +16715,14 @@ function buildMarginfiWithdrawInteraction(args) {
|
|
|
16394
16715
|
`No Marginfi market is configured for asset mint ${args.assetMint}`
|
|
16395
16716
|
);
|
|
16396
16717
|
}
|
|
16397
|
-
const vaultAssetAta = (0,
|
|
16718
|
+
const vaultAssetAta = (0, import_common33.getAtaAddress)(
|
|
16398
16719
|
args.assetMint,
|
|
16399
16720
|
args.vault,
|
|
16400
16721
|
marginfiAccounts.tokenProgram,
|
|
16401
16722
|
true
|
|
16402
16723
|
);
|
|
16403
16724
|
const marginfiClient = new import_marginfi.CpiClient({ accounts: marginfiAccounts });
|
|
16404
|
-
const withdraw = (0,
|
|
16725
|
+
const withdraw = (0, import_common33.createCpiRefs)([
|
|
16405
16726
|
marginfiClient.withdraw_cpi({
|
|
16406
16727
|
marginfiAccount: args.marginfiAccount,
|
|
16407
16728
|
authority: args.vault,
|
|
@@ -16425,19 +16746,19 @@ function buildMarginfiWithdrawInteraction(args) {
|
|
|
16425
16746
|
var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
16426
16747
|
getIxAccounts(args) {
|
|
16427
16748
|
return {
|
|
16428
|
-
user: (0,
|
|
16429
|
-
vault: (0,
|
|
16430
|
-
vaultOracle: (0,
|
|
16431
|
-
vaultTrancheState: (0,
|
|
16432
|
-
assetMint: (0,
|
|
16433
|
-
trancheShareMint: (0,
|
|
16434
|
-
userAssetAta: (0,
|
|
16435
|
-
vaultAssetAta: (0,
|
|
16436
|
-
userTrancheShareAta: (0,
|
|
16437
|
-
assetTokenProgram: (0,
|
|
16438
|
-
shareTokenProgram: (0,
|
|
16439
|
-
associatedTokenProgram:
|
|
16440
|
-
systemProgram:
|
|
16749
|
+
user: (0, import_common34.toWeb3Pk)(args.user),
|
|
16750
|
+
vault: (0, import_common34.toWeb3Pk)(args.vault),
|
|
16751
|
+
vaultOracle: (0, import_common34.toWeb3Pk)(args.vaultOracle),
|
|
16752
|
+
vaultTrancheState: (0, import_common34.toWeb3Pk)(args.vaultTrancheState),
|
|
16753
|
+
assetMint: (0, import_common34.toWeb3Pk)(args.assetMint),
|
|
16754
|
+
trancheShareMint: (0, import_common34.toWeb3Pk)(args.trancheShareMint),
|
|
16755
|
+
userAssetAta: (0, import_common34.toWeb3Pk)(args.userAssetAta),
|
|
16756
|
+
vaultAssetAta: (0, import_common34.toWeb3Pk)(args.vaultAssetAta),
|
|
16757
|
+
userTrancheShareAta: (0, import_common34.toWeb3Pk)(args.userTrancheShareAta),
|
|
16758
|
+
assetTokenProgram: (0, import_common34.toWeb3Pk)(args.assetTokenProgram),
|
|
16759
|
+
shareTokenProgram: (0, import_common34.toWeb3Pk)(args.shareTokenProgram),
|
|
16760
|
+
associatedTokenProgram: import_spl_token12.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
16761
|
+
systemProgram: import_web316.SystemProgram.programId
|
|
16441
16762
|
};
|
|
16442
16763
|
}
|
|
16443
16764
|
getIxData(args) {
|
|
@@ -16474,7 +16795,7 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16474
16795
|
);
|
|
16475
16796
|
return methods.accountsPartial(
|
|
16476
16797
|
this.getIxAccounts(args)
|
|
16477
|
-
).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(
|
|
16798
|
+
).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(import_common34.toKitInstruction);
|
|
16478
16799
|
}
|
|
16479
16800
|
async deriveIxArgs(txArgs) {
|
|
16480
16801
|
const connection = this.program.provider.connection;
|
|
@@ -16495,7 +16816,7 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16495
16816
|
txArgs.assetTokenProgram
|
|
16496
16817
|
);
|
|
16497
16818
|
const { mint: trancheShareMint, tokenProgram: shareTokenProgram } = trancheShare;
|
|
16498
|
-
const vaultAssetAta = (0,
|
|
16819
|
+
const vaultAssetAta = (0, import_common34.getAtaAddress)(
|
|
16499
16820
|
txArgs.assetMint,
|
|
16500
16821
|
txArgs.vault,
|
|
16501
16822
|
assetTokenProgram,
|
|
@@ -16520,17 +16841,17 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16520
16841
|
assetMint: txArgs.assetMint,
|
|
16521
16842
|
trancheShareMint,
|
|
16522
16843
|
kind: txArgs.kind,
|
|
16523
|
-
shareAmount: new
|
|
16844
|
+
shareAmount: new import_core12.BN(txArgs.shareAmount.toString()),
|
|
16524
16845
|
addressSeeds: txArgs.addressSeeds,
|
|
16525
16846
|
assetTokenProgram,
|
|
16526
16847
|
shareTokenProgram,
|
|
16527
|
-
userAssetAta: (0,
|
|
16848
|
+
userAssetAta: (0, import_common34.getAtaAddress)(
|
|
16528
16849
|
txArgs.assetMint,
|
|
16529
16850
|
txArgs.user,
|
|
16530
16851
|
assetTokenProgram
|
|
16531
16852
|
),
|
|
16532
16853
|
vaultAssetAta,
|
|
16533
|
-
userTrancheShareAta: (0,
|
|
16854
|
+
userTrancheShareAta: (0, import_common34.getAtaAddress)(
|
|
16534
16855
|
trancheShareMint,
|
|
16535
16856
|
txArgs.user,
|
|
16536
16857
|
shareTokenProgram
|
|
@@ -16544,16 +16865,16 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16544
16865
|
return txArgs.lookupTables;
|
|
16545
16866
|
}
|
|
16546
16867
|
async buildPreambleInstructions(args) {
|
|
16547
|
-
const payer = (0,
|
|
16548
|
-
const createUserAssetAta = (0,
|
|
16868
|
+
const payer = (0, import_common34.toWeb3Pk)(args.user);
|
|
16869
|
+
const createUserAssetAta = (0, import_spl_token12.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16549
16870
|
payer,
|
|
16550
|
-
(0,
|
|
16871
|
+
(0, import_common34.toWeb3Pk)(args.userAssetAta),
|
|
16551
16872
|
payer,
|
|
16552
|
-
(0,
|
|
16553
|
-
(0,
|
|
16554
|
-
|
|
16873
|
+
(0, import_common34.toWeb3Pk)(args.assetMint),
|
|
16874
|
+
(0, import_common34.toWeb3Pk)(args.assetTokenProgram),
|
|
16875
|
+
import_spl_token12.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16555
16876
|
);
|
|
16556
|
-
return [createUserAssetAta].map(
|
|
16877
|
+
return [createUserAssetAta].map(import_common34.toKitInstruction);
|
|
16557
16878
|
}
|
|
16558
16879
|
async buildPlanExtras(args) {
|
|
16559
16880
|
return {
|
|
@@ -16565,25 +16886,25 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16565
16886
|
};
|
|
16566
16887
|
|
|
16567
16888
|
// src/client/builders/executeWithdraw.ts
|
|
16568
|
-
var
|
|
16569
|
-
var
|
|
16570
|
-
var
|
|
16889
|
+
var import_core13 = require("@anchor-lang/core");
|
|
16890
|
+
var import_spl_token13 = require("@solana/spl-token");
|
|
16891
|
+
var import_common35 = __toESM(require_dist());
|
|
16571
16892
|
var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
16572
16893
|
getIxAccounts(args) {
|
|
16573
16894
|
return {
|
|
16574
|
-
user: (0,
|
|
16575
|
-
vault: (0,
|
|
16576
|
-
vaultOracle: (0,
|
|
16577
|
-
vaultTrancheState: args.vaultTrancheState ? (0,
|
|
16578
|
-
assetMint: (0,
|
|
16579
|
-
shareMint: (0,
|
|
16580
|
-
userAssetAta: (0,
|
|
16581
|
-
vaultAssetAta: (0,
|
|
16582
|
-
feeVault: (0,
|
|
16583
|
-
feeVaultAta: (0,
|
|
16584
|
-
userShareAta: (0,
|
|
16585
|
-
assetTokenProgram: (0,
|
|
16586
|
-
shareTokenProgram: (0,
|
|
16895
|
+
user: (0, import_common35.toWeb3Pk)(args.user),
|
|
16896
|
+
vault: (0, import_common35.toWeb3Pk)(args.vault),
|
|
16897
|
+
vaultOracle: (0, import_common35.toWeb3Pk)(args.vaultOracle),
|
|
16898
|
+
vaultTrancheState: args.vaultTrancheState ? (0, import_common35.toWeb3Pk)(args.vaultTrancheState) : null,
|
|
16899
|
+
assetMint: (0, import_common35.toWeb3Pk)(args.assetMint),
|
|
16900
|
+
shareMint: (0, import_common35.toWeb3Pk)(args.shareMint),
|
|
16901
|
+
userAssetAta: (0, import_common35.toWeb3Pk)(args.userAssetAta),
|
|
16902
|
+
vaultAssetAta: (0, import_common35.toWeb3Pk)(args.vaultAssetAta),
|
|
16903
|
+
feeVault: (0, import_common35.toWeb3Pk)(args.feeVault),
|
|
16904
|
+
feeVaultAta: (0, import_common35.toWeb3Pk)(args.feeVaultAta),
|
|
16905
|
+
userShareAta: (0, import_common35.toWeb3Pk)(args.userShareAta),
|
|
16906
|
+
assetTokenProgram: (0, import_common35.toWeb3Pk)(args.assetTokenProgram),
|
|
16907
|
+
shareTokenProgram: (0, import_common35.toWeb3Pk)(args.shareTokenProgram)
|
|
16587
16908
|
};
|
|
16588
16909
|
}
|
|
16589
16910
|
getIxData(args) {
|
|
@@ -16613,7 +16934,7 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16613
16934
|
) : this.program.methods.executeWithdraw(data.shareAmount);
|
|
16614
16935
|
return methods.accountsPartial(
|
|
16615
16936
|
this.getIxAccounts(args)
|
|
16616
|
-
).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(
|
|
16937
|
+
).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(import_common35.toKitInstruction);
|
|
16617
16938
|
}
|
|
16618
16939
|
async deriveIxArgs(txArgs) {
|
|
16619
16940
|
const connection = this.program.provider.connection;
|
|
@@ -16647,7 +16968,7 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16647
16968
|
),
|
|
16648
16969
|
this.account.fetchVault(txArgs.vault)
|
|
16649
16970
|
]);
|
|
16650
|
-
const vaultAssetAta = (0,
|
|
16971
|
+
const vaultAssetAta = (0, import_common35.getAtaAddress)(
|
|
16651
16972
|
txArgs.assetMint,
|
|
16652
16973
|
txArgs.vault,
|
|
16653
16974
|
assetTokenProgram,
|
|
@@ -16671,19 +16992,19 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16671
16992
|
vaultTrancheState: vaultTrancheState ?? null,
|
|
16672
16993
|
assetMint: txArgs.assetMint,
|
|
16673
16994
|
shareMint: txArgs.shareMint,
|
|
16674
|
-
shareAmount: new
|
|
16995
|
+
shareAmount: new import_core13.BN(txArgs.shareAmount.toString()),
|
|
16675
16996
|
assetTokenProgram,
|
|
16676
16997
|
shareTokenProgram,
|
|
16677
|
-
userAssetAta: txArgs.userAssetAta ?? (0,
|
|
16998
|
+
userAssetAta: txArgs.userAssetAta ?? (0, import_common35.getAtaAddress)(txArgs.assetMint, txArgs.user, assetTokenProgram),
|
|
16678
16999
|
vaultAssetAta,
|
|
16679
17000
|
feeVault,
|
|
16680
|
-
feeVaultAta: (0,
|
|
17001
|
+
feeVaultAta: (0, import_common35.getAtaAddress)(
|
|
16681
17002
|
txArgs.assetMint,
|
|
16682
17003
|
feeVault,
|
|
16683
17004
|
assetTokenProgram,
|
|
16684
17005
|
true
|
|
16685
17006
|
),
|
|
16686
|
-
userShareAta: txArgs.userShareAta ?? (0,
|
|
17007
|
+
userShareAta: txArgs.userShareAta ?? (0, import_common35.getAtaAddress)(txArgs.shareMint, txArgs.user, shareTokenProgram),
|
|
16687
17008
|
externalWithdrawIxRefs,
|
|
16688
17009
|
externalLiquiditySource,
|
|
16689
17010
|
externalWithdrawAccounts,
|
|
@@ -16694,31 +17015,31 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16694
17015
|
return txArgs.lookupTables;
|
|
16695
17016
|
}
|
|
16696
17017
|
async buildPreambleInstructions(args) {
|
|
16697
|
-
const defaultUserAssetAta = (0,
|
|
17018
|
+
const defaultUserAssetAta = (0, import_common35.getAtaAddress)(
|
|
16698
17019
|
args.assetMint,
|
|
16699
17020
|
args.user,
|
|
16700
17021
|
args.assetTokenProgram
|
|
16701
17022
|
);
|
|
16702
|
-
const payer = (0,
|
|
16703
|
-
const createUserAssetAta = (0,
|
|
16704
|
-
(0,
|
|
16705
|
-
) ? (0,
|
|
17023
|
+
const payer = (0, import_common35.toWeb3Pk)(args.user);
|
|
17024
|
+
const createUserAssetAta = (0, import_common35.toWeb3Pk)(args.userAssetAta).equals(
|
|
17025
|
+
(0, import_common35.toWeb3Pk)(defaultUserAssetAta)
|
|
17026
|
+
) ? (0, import_spl_token13.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16706
17027
|
payer,
|
|
16707
|
-
(0,
|
|
17028
|
+
(0, import_common35.toWeb3Pk)(args.userAssetAta),
|
|
16708
17029
|
payer,
|
|
16709
|
-
(0,
|
|
16710
|
-
(0,
|
|
16711
|
-
|
|
17030
|
+
(0, import_common35.toWeb3Pk)(args.assetMint),
|
|
17031
|
+
(0, import_common35.toWeb3Pk)(args.assetTokenProgram),
|
|
17032
|
+
import_spl_token13.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16712
17033
|
) : null;
|
|
16713
|
-
const createFeeVaultAta = (0,
|
|
17034
|
+
const createFeeVaultAta = (0, import_spl_token13.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16714
17035
|
payer,
|
|
16715
|
-
(0,
|
|
16716
|
-
(0,
|
|
16717
|
-
(0,
|
|
16718
|
-
(0,
|
|
16719
|
-
|
|
17036
|
+
(0, import_common35.toWeb3Pk)(args.feeVaultAta),
|
|
17037
|
+
(0, import_common35.toWeb3Pk)(args.feeVault),
|
|
17038
|
+
(0, import_common35.toWeb3Pk)(args.assetMint),
|
|
17039
|
+
(0, import_common35.toWeb3Pk)(args.assetTokenProgram),
|
|
17040
|
+
import_spl_token13.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16720
17041
|
);
|
|
16721
|
-
return [createUserAssetAta, createFeeVaultAta].filter((ix) => ix != null).map(
|
|
17042
|
+
return [createUserAssetAta, createFeeVaultAta].filter((ix) => ix != null).map(import_common35.toKitInstruction);
|
|
16722
17043
|
}
|
|
16723
17044
|
async buildPlanExtras(args) {
|
|
16724
17045
|
return {
|
|
@@ -16728,9 +17049,9 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16728
17049
|
};
|
|
16729
17050
|
|
|
16730
17051
|
// src/client/builders/fulfillJuniorTrancheWithdraw.ts
|
|
16731
|
-
var
|
|
16732
|
-
var
|
|
16733
|
-
var
|
|
17052
|
+
var import_spl_token14 = require("@solana/spl-token");
|
|
17053
|
+
var import_web317 = require("@solana/web3.js");
|
|
17054
|
+
var import_common36 = __toESM(require_dist());
|
|
16734
17055
|
var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
16735
17056
|
async getIx(args) {
|
|
16736
17057
|
const externalWithdrawIxRefs = args.externalWithdrawIxRefs ?? null;
|
|
@@ -16744,24 +17065,24 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16744
17065
|
externalLiquiditySource
|
|
16745
17066
|
);
|
|
16746
17067
|
return methods.accountsPartial({
|
|
16747
|
-
signer: (0,
|
|
16748
|
-
owner: (0,
|
|
16749
|
-
queuePayer: (0,
|
|
16750
|
-
vault: (0,
|
|
16751
|
-
vaultOracle: (0,
|
|
16752
|
-
vaultTrancheState: (0,
|
|
16753
|
-
withdrawalQueue: (0,
|
|
16754
|
-
outputMint: (0,
|
|
16755
|
-
inputMint: (0,
|
|
16756
|
-
ownerInputAta: (0,
|
|
16757
|
-
ownerOutputAta: (0,
|
|
16758
|
-
vaultOutputAta: (0,
|
|
16759
|
-
queueInputAta: (0,
|
|
16760
|
-
assetTokenProgram: (0,
|
|
16761
|
-
shareTokenProgram: (0,
|
|
16762
|
-
associatedTokenProgram:
|
|
16763
|
-
systemProgram:
|
|
16764
|
-
}).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(
|
|
17068
|
+
signer: (0, import_common36.toWeb3Pk)(args.signer),
|
|
17069
|
+
owner: (0, import_common36.toWeb3Pk)(args.owner),
|
|
17070
|
+
queuePayer: (0, import_common36.toWeb3Pk)(args.queuePayer),
|
|
17071
|
+
vault: (0, import_common36.toWeb3Pk)(args.vault),
|
|
17072
|
+
vaultOracle: (0, import_common36.toWeb3Pk)(args.vaultOracle),
|
|
17073
|
+
vaultTrancheState: (0, import_common36.toWeb3Pk)(args.vaultTrancheState),
|
|
17074
|
+
withdrawalQueue: (0, import_common36.toWeb3Pk)(args.withdrawalQueue),
|
|
17075
|
+
outputMint: (0, import_common36.toWeb3Pk)(args.outputMint),
|
|
17076
|
+
inputMint: (0, import_common36.toWeb3Pk)(args.inputMint),
|
|
17077
|
+
ownerInputAta: (0, import_common36.toWeb3Pk)(args.ownerInputAta),
|
|
17078
|
+
ownerOutputAta: (0, import_common36.toWeb3Pk)(args.ownerOutputAta),
|
|
17079
|
+
vaultOutputAta: (0, import_common36.toWeb3Pk)(args.vaultOutputAta),
|
|
17080
|
+
queueInputAta: (0, import_common36.toWeb3Pk)(args.queueInputAta),
|
|
17081
|
+
assetTokenProgram: (0, import_common36.toWeb3Pk)(args.assetTokenProgram),
|
|
17082
|
+
shareTokenProgram: (0, import_common36.toWeb3Pk)(args.shareTokenProgram),
|
|
17083
|
+
associatedTokenProgram: import_spl_token14.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
17084
|
+
systemProgram: import_web317.SystemProgram.programId
|
|
17085
|
+
}).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(import_common36.toKitInstruction);
|
|
16765
17086
|
}
|
|
16766
17087
|
async deriveIxArgs(txArgs) {
|
|
16767
17088
|
const connection = this.program.provider.connection;
|
|
@@ -16802,7 +17123,7 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16802
17123
|
]);
|
|
16803
17124
|
const { mint: juniorShareMint, tokenProgram: shareTokenProgram } = juniorShare;
|
|
16804
17125
|
const queuePda = txArgs.withdrawalQueue ?? withdrawalQueue;
|
|
16805
|
-
const vaultOutputAta = (0,
|
|
17126
|
+
const vaultOutputAta = (0, import_common36.getAtaAddress)(
|
|
16806
17127
|
txArgs.assetMint,
|
|
16807
17128
|
txArgs.vault,
|
|
16808
17129
|
assetTokenProgram,
|
|
@@ -16831,14 +17152,14 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16831
17152
|
inputMint: juniorShareMint,
|
|
16832
17153
|
assetTokenProgram,
|
|
16833
17154
|
shareTokenProgram,
|
|
16834
|
-
ownerInputAta: txArgs.ownerInputAta ?? (0,
|
|
16835
|
-
ownerOutputAta: (0,
|
|
17155
|
+
ownerInputAta: txArgs.ownerInputAta ?? (0, import_common36.getAtaAddress)(juniorShareMint, txArgs.owner, shareTokenProgram),
|
|
17156
|
+
ownerOutputAta: (0, import_common36.getAtaAddress)(
|
|
16836
17157
|
txArgs.assetMint,
|
|
16837
17158
|
txArgs.owner,
|
|
16838
17159
|
assetTokenProgram
|
|
16839
17160
|
),
|
|
16840
17161
|
vaultOutputAta,
|
|
16841
|
-
queueInputAta: (0,
|
|
17162
|
+
queueInputAta: (0, import_common36.getAtaAddress)(
|
|
16842
17163
|
juniorShareMint,
|
|
16843
17164
|
queuePda,
|
|
16844
17165
|
shareTokenProgram,
|
|
@@ -16854,23 +17175,23 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16854
17175
|
return txArgs.lookupTables;
|
|
16855
17176
|
}
|
|
16856
17177
|
async buildPreambleInstructions(args) {
|
|
16857
|
-
const defaultOwnerInputAta = (0,
|
|
17178
|
+
const defaultOwnerInputAta = (0, import_common36.getAtaAddress)(
|
|
16858
17179
|
args.inputMint,
|
|
16859
17180
|
args.owner,
|
|
16860
17181
|
args.shareTokenProgram
|
|
16861
17182
|
);
|
|
16862
|
-
if (!(0,
|
|
17183
|
+
if (!(0, import_common36.toWeb3Pk)(args.ownerInputAta).equals((0, import_common36.toWeb3Pk)(defaultOwnerInputAta))) {
|
|
16863
17184
|
return [];
|
|
16864
17185
|
}
|
|
16865
17186
|
return [
|
|
16866
|
-
(0,
|
|
16867
|
-
(0,
|
|
16868
|
-
(0,
|
|
16869
|
-
(0,
|
|
16870
|
-
(0,
|
|
16871
|
-
(0,
|
|
16872
|
-
(0,
|
|
16873
|
-
|
|
17187
|
+
(0, import_common36.toKitInstruction)(
|
|
17188
|
+
(0, import_spl_token14.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17189
|
+
(0, import_common36.toWeb3Pk)(args.signer),
|
|
17190
|
+
(0, import_common36.toWeb3Pk)(args.ownerInputAta),
|
|
17191
|
+
(0, import_common36.toWeb3Pk)(args.owner),
|
|
17192
|
+
(0, import_common36.toWeb3Pk)(args.inputMint),
|
|
17193
|
+
(0, import_common36.toWeb3Pk)(args.shareTokenProgram),
|
|
17194
|
+
import_spl_token14.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16874
17195
|
)
|
|
16875
17196
|
)
|
|
16876
17197
|
];
|
|
@@ -16889,8 +17210,8 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16889
17210
|
};
|
|
16890
17211
|
|
|
16891
17212
|
// src/client/builders/updateTrancheConfig.ts
|
|
16892
|
-
var
|
|
16893
|
-
var
|
|
17213
|
+
var import_core14 = require("@anchor-lang/core");
|
|
17214
|
+
var import_common37 = __toESM(require_dist());
|
|
16894
17215
|
var UpdateTrancheConfigBuilder = class extends VaultBuilderBase {
|
|
16895
17216
|
async getIx(args) {
|
|
16896
17217
|
return this.program.methods.vaultUpdateTrancheConfig({
|
|
@@ -16901,11 +17222,11 @@ var UpdateTrancheConfigBuilder = class extends VaultBuilderBase {
|
|
|
16901
17222
|
targetLockupDurationSecs: args.targetLockupDurationSecs,
|
|
16902
17223
|
juniorDepositCap: args.juniorDepositCap
|
|
16903
17224
|
}).accountsPartial({
|
|
16904
|
-
curator: (0,
|
|
16905
|
-
vault: (0,
|
|
16906
|
-
vaultTrancheState: (0,
|
|
16907
|
-
vaultOracle: (0,
|
|
16908
|
-
}).instruction().then(
|
|
17225
|
+
curator: (0, import_common37.toWeb3Pk)(args.curator),
|
|
17226
|
+
vault: (0, import_common37.toWeb3Pk)(args.vault),
|
|
17227
|
+
vaultTrancheState: (0, import_common37.toWeb3Pk)(args.vaultTrancheState),
|
|
17228
|
+
vaultOracle: (0, import_common37.toWeb3Pk)(args.vaultOracle)
|
|
17229
|
+
}).instruction().then(import_common37.toKitInstruction);
|
|
16909
17230
|
}
|
|
16910
17231
|
async deriveIxArgs(txArgs) {
|
|
16911
17232
|
const [vaultTrancheState] = await this.pda.deriveVaultTrancheStatePda(
|
|
@@ -16921,8 +17242,8 @@ var UpdateTrancheConfigBuilder = class extends VaultBuilderBase {
|
|
|
16921
17242
|
juniorFloorApyBps: txArgs.juniorFloorApyBps ?? null,
|
|
16922
17243
|
earlyUnstakeFeeBps: txArgs.earlyUnstakeFeeBps ?? null,
|
|
16923
17244
|
standardUnstakeFeeBps: txArgs.standardUnstakeFeeBps ?? null,
|
|
16924
|
-
targetLockupDurationSecs: txArgs.targetLockupDurationSecs === void 0 ? null : new
|
|
16925
|
-
juniorDepositCap: txArgs.juniorDepositCap === void 0 ? null : new
|
|
17245
|
+
targetLockupDurationSecs: txArgs.targetLockupDurationSecs === void 0 ? null : new import_core14.BN(txArgs.targetLockupDurationSecs.toString()),
|
|
17246
|
+
juniorDepositCap: txArgs.juniorDepositCap === void 0 ? null : new import_core14.BN(txArgs.juniorDepositCap.toString())
|
|
16926
17247
|
};
|
|
16927
17248
|
}
|
|
16928
17249
|
async buildPlanExtras(args) {
|
|
@@ -16935,25 +17256,25 @@ var UpdateTrancheConfigBuilder = class extends VaultBuilderBase {
|
|
|
16935
17256
|
};
|
|
16936
17257
|
|
|
16937
17258
|
// src/client/builders/managerRedepositAsset.ts
|
|
16938
|
-
var
|
|
16939
|
-
var
|
|
16940
|
-
var
|
|
16941
|
-
var
|
|
17259
|
+
var import_core15 = require("@anchor-lang/core");
|
|
17260
|
+
var import_spl_token15 = require("@solana/spl-token");
|
|
17261
|
+
var import_web318 = require("@solana/web3.js");
|
|
17262
|
+
var import_common38 = __toESM(require_dist());
|
|
16942
17263
|
var ManagerRedepositAssetBuilder = class extends VaultBuilderBase {
|
|
16943
17264
|
async getIx(args) {
|
|
16944
17265
|
return this.program.methods.managerRedepositAsset({
|
|
16945
17266
|
depositAmount: args.depositAmount,
|
|
16946
17267
|
externalAmount: args.externalAmount
|
|
16947
17268
|
}).accountsPartial({
|
|
16948
|
-
manager: (0,
|
|
16949
|
-
vault: (0,
|
|
16950
|
-
assetMint: (0,
|
|
16951
|
-
vaultAssetAta: (0,
|
|
16952
|
-
managerAssetAta: (0,
|
|
16953
|
-
assetTokenProgram: (0,
|
|
16954
|
-
associatedTokenProgram:
|
|
16955
|
-
systemProgram:
|
|
16956
|
-
}).instruction().then(
|
|
17269
|
+
manager: (0, import_common38.toWeb3Pk)(args.manager),
|
|
17270
|
+
vault: (0, import_common38.toWeb3Pk)(args.vault),
|
|
17271
|
+
assetMint: (0, import_common38.toWeb3Pk)(args.assetMint),
|
|
17272
|
+
vaultAssetAta: (0, import_common38.toWeb3Pk)(args.vaultAssetAta),
|
|
17273
|
+
managerAssetAta: (0, import_common38.toWeb3Pk)(args.managerAssetAta),
|
|
17274
|
+
assetTokenProgram: (0, import_common38.toWeb3Pk)(args.assetTokenProgram),
|
|
17275
|
+
associatedTokenProgram: import_spl_token15.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
17276
|
+
systemProgram: import_web318.SystemProgram.programId
|
|
17277
|
+
}).instruction().then(import_common38.toKitInstruction);
|
|
16957
17278
|
}
|
|
16958
17279
|
async deriveIxArgs(txArgs) {
|
|
16959
17280
|
const connection = this.program.provider.connection;
|
|
@@ -16967,10 +17288,10 @@ var ManagerRedepositAssetBuilder = class extends VaultBuilderBase {
|
|
|
16967
17288
|
manager: txArgs.manager,
|
|
16968
17289
|
vault: txArgs.vault,
|
|
16969
17290
|
assetMint: txArgs.assetMint,
|
|
16970
|
-
depositAmount: new
|
|
16971
|
-
externalAmount: new
|
|
17291
|
+
depositAmount: new import_core15.BN(txArgs.depositAmount.toString()),
|
|
17292
|
+
externalAmount: new import_core15.BN(externalAmount.toString()),
|
|
16972
17293
|
assetTokenProgram,
|
|
16973
|
-
vaultAssetAta: (0,
|
|
17294
|
+
vaultAssetAta: (0, import_common38.getAtaAddress)(
|
|
16974
17295
|
txArgs.assetMint,
|
|
16975
17296
|
txArgs.vault,
|
|
16976
17297
|
assetTokenProgram,
|
|
@@ -16978,7 +17299,7 @@ var ManagerRedepositAssetBuilder = class extends VaultBuilderBase {
|
|
|
16978
17299
|
),
|
|
16979
17300
|
// The manager may be a PDA (e.g. a Squads vault), so allow off-curve
|
|
16980
17301
|
// owners when deriving its ATA.
|
|
16981
|
-
managerAssetAta: (0,
|
|
17302
|
+
managerAssetAta: (0, import_common38.getAtaAddress)(
|
|
16982
17303
|
txArgs.assetMint,
|
|
16983
17304
|
txArgs.manager,
|
|
16984
17305
|
assetTokenProgram,
|
|
@@ -16994,23 +17315,23 @@ var ManagerRedepositAssetBuilder = class extends VaultBuilderBase {
|
|
|
16994
17315
|
};
|
|
16995
17316
|
|
|
16996
17317
|
// src/client/builders/managerWithdrawAsset.ts
|
|
16997
|
-
var
|
|
16998
|
-
var
|
|
16999
|
-
var
|
|
17000
|
-
var
|
|
17318
|
+
var import_core16 = require("@anchor-lang/core");
|
|
17319
|
+
var import_spl_token16 = require("@solana/spl-token");
|
|
17320
|
+
var import_web319 = require("@solana/web3.js");
|
|
17321
|
+
var import_common39 = __toESM(require_dist());
|
|
17001
17322
|
var ManagerWithdrawAssetBuilder = class extends VaultBuilderBase {
|
|
17002
17323
|
async getIx(args) {
|
|
17003
|
-
return this.program.methods.managerWithdrawAsset(args.amount).accountsPartial({
|
|
17004
|
-
manager: (0,
|
|
17005
|
-
vault: (0,
|
|
17006
|
-
assetMint: (0,
|
|
17007
|
-
vaultAssetAta: (0,
|
|
17008
|
-
destination: (0,
|
|
17009
|
-
destinationAssetAta: (0,
|
|
17010
|
-
assetTokenProgram: (0,
|
|
17011
|
-
associatedTokenProgram:
|
|
17012
|
-
systemProgram:
|
|
17013
|
-
}).instruction().then(
|
|
17324
|
+
return this.program.methods.managerWithdrawAsset(args.amount).accountsPartial({
|
|
17325
|
+
manager: (0, import_common39.toWeb3Pk)(args.manager),
|
|
17326
|
+
vault: (0, import_common39.toWeb3Pk)(args.vault),
|
|
17327
|
+
assetMint: (0, import_common39.toWeb3Pk)(args.assetMint),
|
|
17328
|
+
vaultAssetAta: (0, import_common39.toWeb3Pk)(args.vaultAssetAta),
|
|
17329
|
+
destination: (0, import_common39.toWeb3Pk)(args.destination),
|
|
17330
|
+
destinationAssetAta: (0, import_common39.toWeb3Pk)(args.destinationAssetAta),
|
|
17331
|
+
assetTokenProgram: (0, import_common39.toWeb3Pk)(args.assetTokenProgram),
|
|
17332
|
+
associatedTokenProgram: import_spl_token16.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
17333
|
+
systemProgram: import_web319.SystemProgram.programId
|
|
17334
|
+
}).instruction().then(import_common39.toKitInstruction);
|
|
17014
17335
|
}
|
|
17015
17336
|
async deriveIxArgs(txArgs) {
|
|
17016
17337
|
const connection = this.program.provider.connection;
|
|
@@ -17025,15 +17346,15 @@ var ManagerWithdrawAssetBuilder = class extends VaultBuilderBase {
|
|
|
17025
17346
|
vault: txArgs.vault,
|
|
17026
17347
|
assetMint: txArgs.assetMint,
|
|
17027
17348
|
destination,
|
|
17028
|
-
amount: new
|
|
17349
|
+
amount: new import_core16.BN(txArgs.amount.toString()),
|
|
17029
17350
|
assetTokenProgram,
|
|
17030
|
-
vaultAssetAta: (0,
|
|
17351
|
+
vaultAssetAta: (0, import_common39.getAtaAddress)(
|
|
17031
17352
|
txArgs.assetMint,
|
|
17032
17353
|
txArgs.vault,
|
|
17033
17354
|
assetTokenProgram,
|
|
17034
17355
|
true
|
|
17035
17356
|
),
|
|
17036
|
-
destinationAssetAta: (0,
|
|
17357
|
+
destinationAssetAta: (0, import_common39.getAtaAddress)(
|
|
17037
17358
|
txArgs.assetMint,
|
|
17038
17359
|
destination,
|
|
17039
17360
|
assetTokenProgram,
|
|
@@ -17050,18 +17371,18 @@ var ManagerWithdrawAssetBuilder = class extends VaultBuilderBase {
|
|
|
17050
17371
|
};
|
|
17051
17372
|
|
|
17052
17373
|
// src/client/builders/protocolInteraction.ts
|
|
17053
|
-
var
|
|
17374
|
+
var import_core17 = require("@anchor-lang/core");
|
|
17054
17375
|
var import_kit8 = require("@solana/kit");
|
|
17055
|
-
var
|
|
17056
|
-
var
|
|
17057
|
-
var
|
|
17376
|
+
var import_spl_token17 = require("@solana/spl-token");
|
|
17377
|
+
var import_web320 = require("@solana/web3.js");
|
|
17378
|
+
var import_common40 = __toESM(require_dist());
|
|
17058
17379
|
var DEFAULT_PYTH_PRICE_MAX_AGE_SECS = 90n;
|
|
17059
17380
|
function toAssetPriceOracleConfig(args) {
|
|
17060
17381
|
return {
|
|
17061
17382
|
priceOracleType: args?.priceOracleType ?? { none: {} },
|
|
17062
|
-
initialPrice: new
|
|
17383
|
+
initialPrice: new import_core17.BN((args?.initialPrice ?? 0n).toString()),
|
|
17063
17384
|
priceOracleAccount: args?.priceOracleAccount ?? DEFAULT_PRICE_ORACLE_ACCOUNT,
|
|
17064
|
-
pythMaxAgeSecs: new
|
|
17385
|
+
pythMaxAgeSecs: new import_core17.BN(
|
|
17065
17386
|
(args?.pythMaxAgeSecs ?? DEFAULT_PYTH_PRICE_MAX_AGE_SECS).toString()
|
|
17066
17387
|
)
|
|
17067
17388
|
};
|
|
@@ -17069,12 +17390,12 @@ function toAssetPriceOracleConfig(args) {
|
|
|
17069
17390
|
function toAnchorAssetPriceOracleConfig(config) {
|
|
17070
17391
|
return {
|
|
17071
17392
|
...config,
|
|
17072
|
-
priceOracleAccount: (0,
|
|
17393
|
+
priceOracleAccount: (0, import_common40.toWeb3Pk)(config.priceOracleAccount)
|
|
17073
17394
|
};
|
|
17074
17395
|
}
|
|
17075
17396
|
function toWeb3AccountMeta2(account) {
|
|
17076
17397
|
return {
|
|
17077
|
-
pubkey: new
|
|
17398
|
+
pubkey: new import_web320.PublicKey(account.address),
|
|
17078
17399
|
isWritable: account.role === import_kit8.AccountRole.WRITABLE || account.role === import_kit8.AccountRole.WRITABLE_SIGNER,
|
|
17079
17400
|
isSigner: account.role === import_kit8.AccountRole.READONLY_SIGNER || account.role === import_kit8.AccountRole.WRITABLE_SIGNER
|
|
17080
17401
|
};
|
|
@@ -17083,14 +17404,14 @@ var ProtocolInteractionBuilder = class extends VaultBuilderBase {
|
|
|
17083
17404
|
async getIx(args) {
|
|
17084
17405
|
return this.program.methods.protocolInteraction(args.refs, {
|
|
17085
17406
|
externalLiquidityIndex: args.externalLiquidityIndex,
|
|
17086
|
-
affectedAssetMint: args.affectedAssetMint ? (0,
|
|
17407
|
+
affectedAssetMint: args.affectedAssetMint ? (0, import_common40.toWeb3Pk)(args.affectedAssetMint) : null
|
|
17087
17408
|
}).accountsPartial({
|
|
17088
|
-
hwManager: (0,
|
|
17089
|
-
vault: (0,
|
|
17090
|
-
affectedAssetMint: args.affectedAssetMint ? (0,
|
|
17091
|
-
affectedVaultAta: args.affectedVaultAta ? (0,
|
|
17092
|
-
affectedTokenProgram: args.affectedTokenProgram ? (0,
|
|
17093
|
-
}).remainingAccounts(args.accounts.map(toWeb3AccountMeta2)).instruction().then(
|
|
17409
|
+
hwManager: (0, import_common40.toWeb3Pk)(args.hwManager),
|
|
17410
|
+
vault: (0, import_common40.toWeb3Pk)(args.vault),
|
|
17411
|
+
affectedAssetMint: args.affectedAssetMint ? (0, import_common40.toWeb3Pk)(args.affectedAssetMint) : null,
|
|
17412
|
+
affectedVaultAta: args.affectedVaultAta ? (0, import_common40.toWeb3Pk)(args.affectedVaultAta) : null,
|
|
17413
|
+
affectedTokenProgram: args.affectedTokenProgram ? (0, import_common40.toWeb3Pk)(args.affectedTokenProgram) : null
|
|
17414
|
+
}).remainingAccounts(args.accounts.map(toWeb3AccountMeta2)).instruction().then(import_common40.toKitInstruction);
|
|
17094
17415
|
}
|
|
17095
17416
|
async deriveIxArgs(txArgs) {
|
|
17096
17417
|
const affectedTokenProgram = txArgs.affectedAssetMint ? txArgs.affectedTokenProgram ?? TOKEN_PROGRAM_ID : null;
|
|
@@ -17102,7 +17423,7 @@ var ProtocolInteractionBuilder = class extends VaultBuilderBase {
|
|
|
17102
17423
|
accounts: txArgs.accounts,
|
|
17103
17424
|
affectedAssetMint: txArgs.affectedAssetMint ?? null,
|
|
17104
17425
|
affectedTokenProgram,
|
|
17105
|
-
affectedVaultAta: txArgs.affectedAssetMint && affectedTokenProgram ? (0,
|
|
17426
|
+
affectedVaultAta: txArgs.affectedAssetMint && affectedTokenProgram ? (0, import_common40.getAtaAddress)(
|
|
17106
17427
|
txArgs.affectedAssetMint,
|
|
17107
17428
|
txArgs.vault,
|
|
17108
17429
|
affectedTokenProgram,
|
|
@@ -17121,18 +17442,18 @@ var JupiterSwapBuilder = class extends VaultBuilderBase {
|
|
|
17121
17442
|
args.destinationPriceOracle
|
|
17122
17443
|
)
|
|
17123
17444
|
}).accountsPartial({
|
|
17124
|
-
hwManager: (0,
|
|
17125
|
-
vault: (0,
|
|
17126
|
-
sourceMint: (0,
|
|
17127
|
-
destinationMint: (0,
|
|
17128
|
-
vaultSourceAta: (0,
|
|
17129
|
-
vaultDestinationAta: (0,
|
|
17130
|
-
sourceTokenProgram: (0,
|
|
17131
|
-
destinationTokenProgram: (0,
|
|
17132
|
-
destinationOracleAccount: args.destinationOracleAccount ? (0,
|
|
17133
|
-
vaultOracle: (0,
|
|
17134
|
-
vaultTrancheState: args.vaultTrancheState ? (0,
|
|
17135
|
-
}).remainingAccounts(args.accounts.map(toWeb3AccountMeta2)).instruction().then(
|
|
17445
|
+
hwManager: (0, import_common40.toWeb3Pk)(args.hwManager),
|
|
17446
|
+
vault: (0, import_common40.toWeb3Pk)(args.vault),
|
|
17447
|
+
sourceMint: (0, import_common40.toWeb3Pk)(args.sourceMint),
|
|
17448
|
+
destinationMint: (0, import_common40.toWeb3Pk)(args.destinationMint),
|
|
17449
|
+
vaultSourceAta: (0, import_common40.toWeb3Pk)(args.vaultSourceAta),
|
|
17450
|
+
vaultDestinationAta: (0, import_common40.toWeb3Pk)(args.vaultDestinationAta),
|
|
17451
|
+
sourceTokenProgram: (0, import_common40.toWeb3Pk)(args.sourceTokenProgram),
|
|
17452
|
+
destinationTokenProgram: (0, import_common40.toWeb3Pk)(args.destinationTokenProgram),
|
|
17453
|
+
destinationOracleAccount: args.destinationOracleAccount ? (0, import_common40.toWeb3Pk)(args.destinationOracleAccount) : null,
|
|
17454
|
+
vaultOracle: (0, import_common40.toWeb3Pk)(args.vaultOracle),
|
|
17455
|
+
vaultTrancheState: args.vaultTrancheState ? (0, import_common40.toWeb3Pk)(args.vaultTrancheState) : null
|
|
17456
|
+
}).remainingAccounts(args.accounts.map(toWeb3AccountMeta2)).instruction().then(import_common40.toKitInstruction);
|
|
17136
17457
|
}
|
|
17137
17458
|
async deriveIxArgs(txArgs) {
|
|
17138
17459
|
const sourceTokenProgram = txArgs.sourceTokenProgram ?? TOKEN_PROGRAM_ID;
|
|
@@ -17153,13 +17474,13 @@ var JupiterSwapBuilder = class extends VaultBuilderBase {
|
|
|
17153
17474
|
accounts: txArgs.accounts,
|
|
17154
17475
|
sourceTokenProgram,
|
|
17155
17476
|
destinationTokenProgram,
|
|
17156
|
-
vaultSourceAta: (0,
|
|
17477
|
+
vaultSourceAta: (0, import_common40.getAtaAddress)(
|
|
17157
17478
|
txArgs.sourceMint,
|
|
17158
17479
|
txArgs.vault,
|
|
17159
17480
|
sourceTokenProgram,
|
|
17160
17481
|
true
|
|
17161
17482
|
),
|
|
17162
|
-
vaultDestinationAta: (0,
|
|
17483
|
+
vaultDestinationAta: (0, import_common40.getAtaAddress)(
|
|
17163
17484
|
txArgs.destinationMint,
|
|
17164
17485
|
txArgs.vault,
|
|
17165
17486
|
destinationTokenProgram,
|
|
@@ -17168,24 +17489,24 @@ var JupiterSwapBuilder = class extends VaultBuilderBase {
|
|
|
17168
17489
|
};
|
|
17169
17490
|
}
|
|
17170
17491
|
async buildPreambleInstructions(args) {
|
|
17171
|
-
const payer = (0,
|
|
17172
|
-
const createSourceAta = (0,
|
|
17492
|
+
const payer = (0, import_common40.toWeb3Pk)(args.hwManager);
|
|
17493
|
+
const createSourceAta = (0, import_spl_token17.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17173
17494
|
payer,
|
|
17174
|
-
(0,
|
|
17175
|
-
(0,
|
|
17176
|
-
(0,
|
|
17177
|
-
(0,
|
|
17178
|
-
|
|
17495
|
+
(0, import_common40.toWeb3Pk)(args.vaultSourceAta),
|
|
17496
|
+
(0, import_common40.toWeb3Pk)(args.vault),
|
|
17497
|
+
(0, import_common40.toWeb3Pk)(args.sourceMint),
|
|
17498
|
+
(0, import_common40.toWeb3Pk)(args.sourceTokenProgram),
|
|
17499
|
+
import_spl_token17.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
17179
17500
|
);
|
|
17180
|
-
const createDestinationAta = (0,
|
|
17501
|
+
const createDestinationAta = (0, import_spl_token17.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17181
17502
|
payer,
|
|
17182
|
-
(0,
|
|
17183
|
-
(0,
|
|
17184
|
-
(0,
|
|
17185
|
-
(0,
|
|
17186
|
-
|
|
17503
|
+
(0, import_common40.toWeb3Pk)(args.vaultDestinationAta),
|
|
17504
|
+
(0, import_common40.toWeb3Pk)(args.vault),
|
|
17505
|
+
(0, import_common40.toWeb3Pk)(args.destinationMint),
|
|
17506
|
+
(0, import_common40.toWeb3Pk)(args.destinationTokenProgram),
|
|
17507
|
+
import_spl_token17.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
17187
17508
|
);
|
|
17188
|
-
return [createSourceAta, createDestinationAta].map(
|
|
17509
|
+
return [createSourceAta, createDestinationAta].map(import_common40.toKitInstruction);
|
|
17189
17510
|
}
|
|
17190
17511
|
async buildLookupTables(_args, txArgs) {
|
|
17191
17512
|
return txArgs.lookupTables;
|
|
@@ -17218,27 +17539,27 @@ var JupiterSwapBuilder = class extends VaultBuilderBase {
|
|
|
17218
17539
|
};
|
|
17219
17540
|
|
|
17220
17541
|
// src/client/builders/requestJuniorTrancheWithdraw.ts
|
|
17221
|
-
var
|
|
17222
|
-
var
|
|
17223
|
-
var
|
|
17224
|
-
var
|
|
17542
|
+
var import_core18 = require("@anchor-lang/core");
|
|
17543
|
+
var import_spl_token18 = require("@solana/spl-token");
|
|
17544
|
+
var import_web321 = require("@solana/web3.js");
|
|
17545
|
+
var import_common41 = __toESM(require_dist());
|
|
17225
17546
|
var RequestJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
17226
17547
|
async getIx(args) {
|
|
17227
17548
|
return this.program.methods.requestJuniorTrancheWithdraw(args.queueId, args.shareAmount).accountsPartial({
|
|
17228
|
-
user: (0,
|
|
17229
|
-
payer: (0,
|
|
17230
|
-
vault: (0,
|
|
17231
|
-
vaultOracle: (0,
|
|
17232
|
-
vaultTrancheState: (0,
|
|
17233
|
-
withdrawalQueue: (0,
|
|
17234
|
-
outputMint: (0,
|
|
17235
|
-
inputMint: (0,
|
|
17236
|
-
userInputAta: (0,
|
|
17237
|
-
queueInputAta: (0,
|
|
17238
|
-
shareTokenProgram: (0,
|
|
17239
|
-
associatedTokenProgram:
|
|
17240
|
-
systemProgram:
|
|
17241
|
-
}).instruction().then(
|
|
17549
|
+
user: (0, import_common41.toWeb3Pk)(args.user),
|
|
17550
|
+
payer: (0, import_common41.toWeb3Pk)(args.payer),
|
|
17551
|
+
vault: (0, import_common41.toWeb3Pk)(args.vault),
|
|
17552
|
+
vaultOracle: (0, import_common41.toWeb3Pk)(args.vaultOracle),
|
|
17553
|
+
vaultTrancheState: (0, import_common41.toWeb3Pk)(args.vaultTrancheState),
|
|
17554
|
+
withdrawalQueue: (0, import_common41.toWeb3Pk)(args.withdrawalQueue),
|
|
17555
|
+
outputMint: (0, import_common41.toWeb3Pk)(args.outputMint),
|
|
17556
|
+
inputMint: (0, import_common41.toWeb3Pk)(args.inputMint),
|
|
17557
|
+
userInputAta: (0, import_common41.toWeb3Pk)(args.userInputAta),
|
|
17558
|
+
queueInputAta: (0, import_common41.toWeb3Pk)(args.queueInputAta),
|
|
17559
|
+
shareTokenProgram: (0, import_common41.toWeb3Pk)(args.shareTokenProgram),
|
|
17560
|
+
associatedTokenProgram: import_spl_token18.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
17561
|
+
systemProgram: import_web321.SystemProgram.programId
|
|
17562
|
+
}).instruction().then(import_common41.toKitInstruction);
|
|
17242
17563
|
}
|
|
17243
17564
|
async deriveIxArgs(txArgs) {
|
|
17244
17565
|
const payer = txArgs.payer ?? txArgs.user;
|
|
@@ -17272,10 +17593,10 @@ var RequestJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
17272
17593
|
outputMint: txArgs.assetMint,
|
|
17273
17594
|
inputMint: juniorShareMint,
|
|
17274
17595
|
queueId: txArgs.queueId,
|
|
17275
|
-
shareAmount: new
|
|
17596
|
+
shareAmount: new import_core18.BN(txArgs.shareAmount.toString()),
|
|
17276
17597
|
shareTokenProgram,
|
|
17277
|
-
userInputAta: txArgs.userInputAta ?? (0,
|
|
17278
|
-
queueInputAta: (0,
|
|
17598
|
+
userInputAta: txArgs.userInputAta ?? (0, import_common41.getAtaAddress)(juniorShareMint, txArgs.user, shareTokenProgram),
|
|
17599
|
+
queueInputAta: (0, import_common41.getAtaAddress)(
|
|
17279
17600
|
juniorShareMint,
|
|
17280
17601
|
queuePda,
|
|
17281
17602
|
shareTokenProgram,
|
|
@@ -17297,17 +17618,17 @@ var RequestJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
17297
17618
|
};
|
|
17298
17619
|
|
|
17299
17620
|
// src/client/builders/vaultReallocation.ts
|
|
17300
|
-
var
|
|
17301
|
-
var
|
|
17302
|
-
var
|
|
17303
|
-
var
|
|
17621
|
+
var import_core19 = require("@anchor-lang/core");
|
|
17622
|
+
var import_spl_token19 = require("@solana/spl-token");
|
|
17623
|
+
var import_web322 = require("@solana/web3.js");
|
|
17624
|
+
var import_common42 = __toESM(require_dist());
|
|
17304
17625
|
var DEFAULT_PYTH_PRICE_MAX_AGE_SECS2 = 90n;
|
|
17305
17626
|
function toAssetPriceOracleConfig2(args) {
|
|
17306
17627
|
return {
|
|
17307
17628
|
priceOracleType: args?.priceOracleType ?? { none: {} },
|
|
17308
|
-
initialPrice: new
|
|
17629
|
+
initialPrice: new import_core19.BN((args?.initialPrice ?? 0n).toString()),
|
|
17309
17630
|
priceOracleAccount: args?.priceOracleAccount ?? DEFAULT_PRICE_ORACLE_ACCOUNT,
|
|
17310
|
-
pythMaxAgeSecs: new
|
|
17631
|
+
pythMaxAgeSecs: new import_core19.BN(
|
|
17311
17632
|
(args?.pythMaxAgeSecs ?? DEFAULT_PYTH_PRICE_MAX_AGE_SECS2).toString()
|
|
17312
17633
|
)
|
|
17313
17634
|
};
|
|
@@ -17315,7 +17636,7 @@ function toAssetPriceOracleConfig2(args) {
|
|
|
17315
17636
|
function toAnchorAssetPriceOracleConfig2(config) {
|
|
17316
17637
|
return {
|
|
17317
17638
|
...config,
|
|
17318
|
-
priceOracleAccount: (0,
|
|
17639
|
+
priceOracleAccount: (0, import_common42.toWeb3Pk)(config.priceOracleAccount)
|
|
17319
17640
|
};
|
|
17320
17641
|
}
|
|
17321
17642
|
var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
@@ -17324,35 +17645,35 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
17324
17645
|
amount: args.amount,
|
|
17325
17646
|
assetPriceOracle: toAnchorAssetPriceOracleConfig2(args.assetPriceOracle)
|
|
17326
17647
|
}).accountsPartial({
|
|
17327
|
-
manager: (0,
|
|
17328
|
-
allocationVault: (0,
|
|
17329
|
-
sourceVault: args.sourceVault ? (0,
|
|
17330
|
-
sourceVaultOracle: args.sourceVaultOracle ? (0,
|
|
17331
|
-
destinationVault: (0,
|
|
17332
|
-
destinationVaultOracle: (0,
|
|
17333
|
-
mint: (0,
|
|
17334
|
-
sourceShareMint: args.sourceShareMint ? (0,
|
|
17335
|
-
destinationShareMint: (0,
|
|
17336
|
-
allocationMintAta: (0,
|
|
17337
|
-
sourceVaultMintAta: args.sourceVaultMintAta ? (0,
|
|
17338
|
-
destinationVaultMintAta: (0,
|
|
17339
|
-
destinationFeeVault: (0,
|
|
17340
|
-
destinationFeeVaultMintAta: (0,
|
|
17341
|
-
allocationSourceShareAta: args.allocationSourceShareAta ? (0,
|
|
17342
|
-
allocationDestinationShareAta: (0,
|
|
17648
|
+
manager: (0, import_common42.toWeb3Pk)(args.manager),
|
|
17649
|
+
allocationVault: (0, import_common42.toWeb3Pk)(args.allocationVault),
|
|
17650
|
+
sourceVault: args.sourceVault ? (0, import_common42.toWeb3Pk)(args.sourceVault) : null,
|
|
17651
|
+
sourceVaultOracle: args.sourceVaultOracle ? (0, import_common42.toWeb3Pk)(args.sourceVaultOracle) : null,
|
|
17652
|
+
destinationVault: (0, import_common42.toWeb3Pk)(args.destinationVault),
|
|
17653
|
+
destinationVaultOracle: (0, import_common42.toWeb3Pk)(args.destinationVaultOracle),
|
|
17654
|
+
mint: (0, import_common42.toWeb3Pk)(args.mint),
|
|
17655
|
+
sourceShareMint: args.sourceShareMint ? (0, import_common42.toWeb3Pk)(args.sourceShareMint) : null,
|
|
17656
|
+
destinationShareMint: (0, import_common42.toWeb3Pk)(args.destinationShareMint),
|
|
17657
|
+
allocationMintAta: (0, import_common42.toWeb3Pk)(args.allocationMintAta),
|
|
17658
|
+
sourceVaultMintAta: args.sourceVaultMintAta ? (0, import_common42.toWeb3Pk)(args.sourceVaultMintAta) : null,
|
|
17659
|
+
destinationVaultMintAta: (0, import_common42.toWeb3Pk)(args.destinationVaultMintAta),
|
|
17660
|
+
destinationFeeVault: (0, import_common42.toWeb3Pk)(args.destinationFeeVault),
|
|
17661
|
+
destinationFeeVaultMintAta: (0, import_common42.toWeb3Pk)(args.destinationFeeVaultMintAta),
|
|
17662
|
+
allocationSourceShareAta: args.allocationSourceShareAta ? (0, import_common42.toWeb3Pk)(args.allocationSourceShareAta) : null,
|
|
17663
|
+
allocationDestinationShareAta: (0, import_common42.toWeb3Pk)(
|
|
17343
17664
|
args.allocationDestinationShareAta
|
|
17344
17665
|
),
|
|
17345
|
-
sourceVaultTrancheState: args.sourceVaultTrancheState ? (0,
|
|
17346
|
-
destinationVaultTrancheState: args.destinationVaultTrancheState ? (0,
|
|
17347
|
-
assetOracleAccount: args.assetOracleAccount ? (0,
|
|
17348
|
-
assetTokenProgram: (0,
|
|
17349
|
-
sourceShareTokenProgram: (0,
|
|
17350
|
-
destinationShareTokenProgram: (0,
|
|
17666
|
+
sourceVaultTrancheState: args.sourceVaultTrancheState ? (0, import_common42.toWeb3Pk)(args.sourceVaultTrancheState) : null,
|
|
17667
|
+
destinationVaultTrancheState: args.destinationVaultTrancheState ? (0, import_common42.toWeb3Pk)(args.destinationVaultTrancheState) : null,
|
|
17668
|
+
assetOracleAccount: args.assetOracleAccount ? (0, import_common42.toWeb3Pk)(args.assetOracleAccount) : null,
|
|
17669
|
+
assetTokenProgram: (0, import_common42.toWeb3Pk)(args.assetTokenProgram),
|
|
17670
|
+
sourceShareTokenProgram: (0, import_common42.toWeb3Pk)(args.sourceShareTokenProgram),
|
|
17671
|
+
destinationShareTokenProgram: (0, import_common42.toWeb3Pk)(
|
|
17351
17672
|
args.destinationShareTokenProgram
|
|
17352
17673
|
),
|
|
17353
|
-
associatedTokenProgram:
|
|
17354
|
-
systemProgram:
|
|
17355
|
-
}).instruction().then(
|
|
17674
|
+
associatedTokenProgram: import_spl_token19.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
17675
|
+
systemProgram: import_web322.SystemProgram.programId
|
|
17676
|
+
}).instruction().then(import_common42.toKitInstruction);
|
|
17356
17677
|
}
|
|
17357
17678
|
async deriveIxArgs(txArgs) {
|
|
17358
17679
|
const assetTokenProgram = txArgs.assetTokenProgram ?? TOKEN_PROGRAM_ID;
|
|
@@ -17377,7 +17698,7 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
17377
17698
|
mint: txArgs.mint,
|
|
17378
17699
|
sourceShareMint,
|
|
17379
17700
|
destinationShareMint: txArgs.destinationShareMint,
|
|
17380
|
-
amount: new
|
|
17701
|
+
amount: new import_core19.BN(txArgs.amount.toString()),
|
|
17381
17702
|
assetPriceOracle: toAssetPriceOracleConfig2(txArgs.assetPriceOracle),
|
|
17382
17703
|
sourceVaultTrancheState: txArgs.sourceVaultTrancheState ?? null,
|
|
17383
17704
|
destinationVaultTrancheState: txArgs.destinationVaultTrancheState ?? null,
|
|
@@ -17385,33 +17706,33 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
17385
17706
|
assetTokenProgram,
|
|
17386
17707
|
sourceShareTokenProgram,
|
|
17387
17708
|
destinationShareTokenProgram,
|
|
17388
|
-
allocationMintAta: (0,
|
|
17709
|
+
allocationMintAta: (0, import_common42.getAtaAddress)(
|
|
17389
17710
|
txArgs.mint,
|
|
17390
17711
|
txArgs.allocationVault,
|
|
17391
17712
|
assetTokenProgram,
|
|
17392
17713
|
true
|
|
17393
17714
|
),
|
|
17394
|
-
sourceVaultMintAta: sourceVault ? (0,
|
|
17395
|
-
destinationVaultMintAta: (0,
|
|
17715
|
+
sourceVaultMintAta: sourceVault ? (0, import_common42.getAtaAddress)(txArgs.mint, sourceVault, assetTokenProgram, true) : null,
|
|
17716
|
+
destinationVaultMintAta: (0, import_common42.getAtaAddress)(
|
|
17396
17717
|
txArgs.mint,
|
|
17397
17718
|
txArgs.destinationVault,
|
|
17398
17719
|
assetTokenProgram,
|
|
17399
17720
|
true
|
|
17400
17721
|
),
|
|
17401
17722
|
destinationFeeVault,
|
|
17402
|
-
destinationFeeVaultMintAta: (0,
|
|
17723
|
+
destinationFeeVaultMintAta: (0, import_common42.getAtaAddress)(
|
|
17403
17724
|
txArgs.mint,
|
|
17404
17725
|
destinationFeeVault,
|
|
17405
17726
|
assetTokenProgram,
|
|
17406
17727
|
true
|
|
17407
17728
|
),
|
|
17408
|
-
allocationSourceShareAta: sourceShareMint && sourceVault ? (0,
|
|
17729
|
+
allocationSourceShareAta: sourceShareMint && sourceVault ? (0, import_common42.getAtaAddress)(
|
|
17409
17730
|
sourceShareMint,
|
|
17410
17731
|
txArgs.allocationVault,
|
|
17411
17732
|
sourceShareTokenProgram,
|
|
17412
17733
|
true
|
|
17413
17734
|
) : null,
|
|
17414
|
-
allocationDestinationShareAta: (0,
|
|
17735
|
+
allocationDestinationShareAta: (0, import_common42.getAtaAddress)(
|
|
17415
17736
|
txArgs.destinationShareMint,
|
|
17416
17737
|
txArgs.allocationVault,
|
|
17417
17738
|
destinationShareTokenProgram,
|
|
@@ -17420,62 +17741,62 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
17420
17741
|
};
|
|
17421
17742
|
}
|
|
17422
17743
|
async buildPreambleInstructions(args) {
|
|
17423
|
-
const payer = (0,
|
|
17744
|
+
const payer = (0, import_common42.toWeb3Pk)(args.manager);
|
|
17424
17745
|
const instructions2 = [
|
|
17425
|
-
(0,
|
|
17746
|
+
(0, import_spl_token19.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17426
17747
|
payer,
|
|
17427
|
-
(0,
|
|
17428
|
-
(0,
|
|
17429
|
-
(0,
|
|
17430
|
-
(0,
|
|
17431
|
-
|
|
17748
|
+
(0, import_common42.toWeb3Pk)(args.allocationMintAta),
|
|
17749
|
+
(0, import_common42.toWeb3Pk)(args.allocationVault),
|
|
17750
|
+
(0, import_common42.toWeb3Pk)(args.mint),
|
|
17751
|
+
(0, import_common42.toWeb3Pk)(args.assetTokenProgram),
|
|
17752
|
+
import_spl_token19.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
17432
17753
|
),
|
|
17433
|
-
(0,
|
|
17754
|
+
(0, import_spl_token19.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17434
17755
|
payer,
|
|
17435
|
-
(0,
|
|
17436
|
-
(0,
|
|
17437
|
-
(0,
|
|
17438
|
-
(0,
|
|
17439
|
-
|
|
17756
|
+
(0, import_common42.toWeb3Pk)(args.destinationVaultMintAta),
|
|
17757
|
+
(0, import_common42.toWeb3Pk)(args.destinationVault),
|
|
17758
|
+
(0, import_common42.toWeb3Pk)(args.mint),
|
|
17759
|
+
(0, import_common42.toWeb3Pk)(args.assetTokenProgram),
|
|
17760
|
+
import_spl_token19.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
17440
17761
|
),
|
|
17441
|
-
(0,
|
|
17762
|
+
(0, import_spl_token19.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17442
17763
|
payer,
|
|
17443
|
-
(0,
|
|
17444
|
-
(0,
|
|
17445
|
-
(0,
|
|
17446
|
-
(0,
|
|
17447
|
-
|
|
17764
|
+
(0, import_common42.toWeb3Pk)(args.destinationFeeVaultMintAta),
|
|
17765
|
+
(0, import_common42.toWeb3Pk)(args.destinationFeeVault),
|
|
17766
|
+
(0, import_common42.toWeb3Pk)(args.mint),
|
|
17767
|
+
(0, import_common42.toWeb3Pk)(args.assetTokenProgram),
|
|
17768
|
+
import_spl_token19.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
17448
17769
|
),
|
|
17449
|
-
(0,
|
|
17770
|
+
(0, import_spl_token19.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17450
17771
|
payer,
|
|
17451
|
-
(0,
|
|
17452
|
-
(0,
|
|
17453
|
-
(0,
|
|
17454
|
-
(0,
|
|
17455
|
-
|
|
17772
|
+
(0, import_common42.toWeb3Pk)(args.allocationDestinationShareAta),
|
|
17773
|
+
(0, import_common42.toWeb3Pk)(args.allocationVault),
|
|
17774
|
+
(0, import_common42.toWeb3Pk)(args.destinationShareMint),
|
|
17775
|
+
(0, import_common42.toWeb3Pk)(args.destinationShareTokenProgram),
|
|
17776
|
+
import_spl_token19.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
17456
17777
|
)
|
|
17457
17778
|
];
|
|
17458
17779
|
if (args.sourceVault && args.sourceShareMint && args.sourceVaultMintAta && args.allocationSourceShareAta) {
|
|
17459
17780
|
instructions2.push(
|
|
17460
|
-
(0,
|
|
17781
|
+
(0, import_spl_token19.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17461
17782
|
payer,
|
|
17462
|
-
(0,
|
|
17463
|
-
(0,
|
|
17464
|
-
(0,
|
|
17465
|
-
(0,
|
|
17466
|
-
|
|
17783
|
+
(0, import_common42.toWeb3Pk)(args.sourceVaultMintAta),
|
|
17784
|
+
(0, import_common42.toWeb3Pk)(args.sourceVault),
|
|
17785
|
+
(0, import_common42.toWeb3Pk)(args.mint),
|
|
17786
|
+
(0, import_common42.toWeb3Pk)(args.assetTokenProgram),
|
|
17787
|
+
import_spl_token19.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
17467
17788
|
),
|
|
17468
|
-
(0,
|
|
17789
|
+
(0, import_spl_token19.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17469
17790
|
payer,
|
|
17470
|
-
(0,
|
|
17471
|
-
(0,
|
|
17472
|
-
(0,
|
|
17473
|
-
(0,
|
|
17474
|
-
|
|
17791
|
+
(0, import_common42.toWeb3Pk)(args.allocationSourceShareAta),
|
|
17792
|
+
(0, import_common42.toWeb3Pk)(args.allocationVault),
|
|
17793
|
+
(0, import_common42.toWeb3Pk)(args.sourceShareMint),
|
|
17794
|
+
(0, import_common42.toWeb3Pk)(args.sourceShareTokenProgram),
|
|
17795
|
+
import_spl_token19.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
17475
17796
|
)
|
|
17476
17797
|
);
|
|
17477
17798
|
}
|
|
17478
|
-
return instructions2.map(
|
|
17799
|
+
return instructions2.map(import_common42.toKitInstruction);
|
|
17479
17800
|
}
|
|
17480
17801
|
async buildPlanExtras(args) {
|
|
17481
17802
|
return {
|
|
@@ -17513,6 +17834,7 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
17513
17834
|
// src/client/transaction.ts
|
|
17514
17835
|
var TransactionClient = class {
|
|
17515
17836
|
constructor(context) {
|
|
17837
|
+
this.depositCuratorFees = new DepositCuratorFeesBuilder(context);
|
|
17516
17838
|
this.createIncentiveV3 = new CreateIncentiveV3Builder(context);
|
|
17517
17839
|
this.addIncentiveRecipientV3 = new AddIncentiveRecipientV3Builder(context);
|
|
17518
17840
|
this.setIncentiveLimitsV3 = new SetIncentiveLimitsV3Builder(context);
|
|
@@ -17573,7 +17895,7 @@ var VaultClient = class {
|
|
|
17573
17895
|
this.provider = provider;
|
|
17574
17896
|
this.skipSimulation = options.skipSimulation ?? false;
|
|
17575
17897
|
const idl = { ...IDL, address: programId };
|
|
17576
|
-
this.program = new
|
|
17898
|
+
this.program = new import_core20.Program(idl, provider);
|
|
17577
17899
|
this.pda = new PdaClient((0, import_kit9.address)(this.program.programId.toBase58()));
|
|
17578
17900
|
const rpc = createRpcFromConnection(provider.connection);
|
|
17579
17901
|
this.account = new AccountClient(this.program, this.pda, rpc);
|
|
@@ -17595,8 +17917,8 @@ var VaultClient = class {
|
|
|
17595
17917
|
*/
|
|
17596
17918
|
async sendTransaction(payer, plan, extraSigners = []) {
|
|
17597
17919
|
const { blockhash, lastValidBlockHeight } = await this.provider.connection.getLatestBlockhash("confirmed");
|
|
17598
|
-
const tx = new
|
|
17599
|
-
...plan.instructions.map(
|
|
17920
|
+
const tx = new import_web323.Transaction().add(
|
|
17921
|
+
...plan.instructions.map(import_common43.fromKitInstruction)
|
|
17600
17922
|
);
|
|
17601
17923
|
tx.feePayer = payer.publicKey;
|
|
17602
17924
|
tx.recentBlockhash = blockhash;
|
|
@@ -17630,13 +17952,13 @@ var VaultClient = class {
|
|
|
17630
17952
|
const { blockhash } = await this.provider.connection.getLatestBlockhash(
|
|
17631
17953
|
"confirmed"
|
|
17632
17954
|
);
|
|
17633
|
-
const lookupTableAccounts = plan.lookupTables?.length ? await (0,
|
|
17634
|
-
const message2 = new
|
|
17955
|
+
const lookupTableAccounts = plan.lookupTables?.length ? await (0, import_common43.fetchLookupTables)(this.provider.connection, plan.lookupTables) : [];
|
|
17956
|
+
const message2 = new import_web323.TransactionMessage({
|
|
17635
17957
|
payerKey: payer.publicKey,
|
|
17636
17958
|
recentBlockhash: blockhash,
|
|
17637
|
-
instructions: plan.instructions.map(
|
|
17959
|
+
instructions: plan.instructions.map(import_common43.fromKitInstruction)
|
|
17638
17960
|
}).compileToV0Message(lookupTableAccounts);
|
|
17639
|
-
const tx = new
|
|
17961
|
+
const tx = new import_web323.VersionedTransaction(message2);
|
|
17640
17962
|
const result = await this.provider.connection.simulateTransaction(tx, {
|
|
17641
17963
|
sigVerify: false,
|
|
17642
17964
|
commitment: "processed"
|
|
@@ -17710,7 +18032,7 @@ function resolveKeypairPath(keypairPath) {
|
|
|
17710
18032
|
}
|
|
17711
18033
|
function loadKeypair(keypairPath) {
|
|
17712
18034
|
const raw = import_fs.default.readFileSync(resolveKeypairPath(keypairPath), "utf-8");
|
|
17713
|
-
return
|
|
18035
|
+
return import_web324.Keypair.fromSecretKey(new Uint8Array(JSON.parse(raw)));
|
|
17714
18036
|
}
|
|
17715
18037
|
var ENV_AGNOSTIC_ROLES = /* @__PURE__ */ new Set(["fulfiller", "rebalancer"]);
|
|
17716
18038
|
function defaultKeypairPath(env, role = "vault") {
|
|
@@ -17721,8 +18043,8 @@ function defaultKeypairPath(env, role = "vault") {
|
|
|
17721
18043
|
}
|
|
17722
18044
|
function createVaultClient(env, opts = {}) {
|
|
17723
18045
|
const payer = opts.keypair ?? loadKeypair(opts.keypairPath ?? defaultKeypairPath(env, opts.role));
|
|
17724
|
-
const connection = new
|
|
17725
|
-
const provider = new
|
|
18046
|
+
const connection = new import_web324.Connection(opts.rpcUrl ?? getRpcUrl(env), "confirmed");
|
|
18047
|
+
const provider = new import_core21.AnchorProvider(connection, new import_core21.Wallet(payer), {
|
|
17726
18048
|
commitment: "confirmed"
|
|
17727
18049
|
});
|
|
17728
18050
|
const client = new VaultClient(
|
|
@@ -17735,11 +18057,11 @@ function createVaultClient(env, opts = {}) {
|
|
|
17735
18057
|
client,
|
|
17736
18058
|
provider,
|
|
17737
18059
|
payer,
|
|
17738
|
-
signer: (0,
|
|
18060
|
+
signer: (0, import_common44.fromWeb3Pk)(payer.publicKey)
|
|
17739
18061
|
};
|
|
17740
18062
|
}
|
|
17741
18063
|
function keypairAddress(keypairPath) {
|
|
17742
|
-
return (0,
|
|
18064
|
+
return (0, import_common44.fromWeb3Pk)(loadKeypair(keypairPath).publicKey);
|
|
17743
18065
|
}
|
|
17744
18066
|
|
|
17745
18067
|
// src/utils/math.ts
|
|
@@ -17753,16 +18075,16 @@ function fromUiAmount(amount, decimals) {
|
|
|
17753
18075
|
}
|
|
17754
18076
|
|
|
17755
18077
|
// src/utils/provider.ts
|
|
17756
|
-
var
|
|
18078
|
+
var import_core22 = require("@anchor-lang/core");
|
|
17757
18079
|
function makeProvider(connection, payer) {
|
|
17758
|
-
return new
|
|
18080
|
+
return new import_core22.AnchorProvider(connection, new import_core22.Wallet(payer), {
|
|
17759
18081
|
commitment: "confirmed"
|
|
17760
18082
|
});
|
|
17761
18083
|
}
|
|
17762
18084
|
|
|
17763
18085
|
// src/utils/squads.ts
|
|
17764
18086
|
var squads = __toESM(require("@sqds/multisig"));
|
|
17765
|
-
var
|
|
18087
|
+
var import_web325 = require("@solana/web3.js");
|
|
17766
18088
|
var SQUADS_SIMULATION_COMMITMENT = "processed";
|
|
17767
18089
|
var SquadsProposalExecutionSimulationError = class extends Error {
|
|
17768
18090
|
constructor(transactionError, logs, unitsConsumed) {
|
|
@@ -17786,8 +18108,8 @@ function validateVaultIndex(vaultIndex) {
|
|
|
17786
18108
|
}
|
|
17787
18109
|
function resolveSquadsWalletRoute(route) {
|
|
17788
18110
|
validateVaultIndex(route.vaultIndex);
|
|
17789
|
-
const wallet = new
|
|
17790
|
-
const multisigPda = new
|
|
18111
|
+
const wallet = new import_web325.PublicKey(route.wallet);
|
|
18112
|
+
const multisigPda = new import_web325.PublicKey(route.multisigPda);
|
|
17791
18113
|
const [vaultPda] = squads.getVaultPda({
|
|
17792
18114
|
multisigPda,
|
|
17793
18115
|
index: route.vaultIndex
|
|
@@ -17795,7 +18117,7 @@ function resolveSquadsWalletRoute(route) {
|
|
|
17795
18117
|
return { ...route, wallet, multisigPda, vaultPda };
|
|
17796
18118
|
}
|
|
17797
18119
|
function findSquadsWalletRoute(wallet, routes) {
|
|
17798
|
-
const walletKey = typeof wallet === "string" ? new
|
|
18120
|
+
const walletKey = typeof wallet === "string" ? new import_web325.PublicKey(wallet) : wallet;
|
|
17799
18121
|
const route = routes.find(
|
|
17800
18122
|
(candidate) => candidate.wallet === walletKey.toBase58()
|
|
17801
18123
|
);
|
|
@@ -17813,18 +18135,18 @@ function validateSquadsWalletRoutes(routes) {
|
|
|
17813
18135
|
}
|
|
17814
18136
|
}
|
|
17815
18137
|
function vaultAuthorityForWallet(wallet, routes) {
|
|
17816
|
-
const walletKey = typeof wallet === "string" ? new
|
|
18138
|
+
const walletKey = typeof wallet === "string" ? new import_web325.PublicKey(wallet) : wallet;
|
|
17817
18139
|
return findSquadsWalletRoute(walletKey, routes)?.vaultPda ?? walletKey;
|
|
17818
18140
|
}
|
|
17819
18141
|
async function simulateSquadsProposalExecution(args) {
|
|
17820
18142
|
const { connection, feePayer, instructions: instructions2 } = args;
|
|
17821
18143
|
const recentBlockhash = args.recentBlockhash ?? (await connection.getLatestBlockhash(SQUADS_SIMULATION_COMMITMENT)).blockhash;
|
|
17822
|
-
const message2 = new
|
|
18144
|
+
const message2 = new import_web325.TransactionMessage({
|
|
17823
18145
|
payerKey: feePayer,
|
|
17824
18146
|
recentBlockhash,
|
|
17825
18147
|
instructions: [...instructions2]
|
|
17826
18148
|
}).compileToV0Message(args.addressLookupTableAccounts);
|
|
17827
|
-
const transaction = new
|
|
18149
|
+
const transaction = new import_web325.VersionedTransaction(message2);
|
|
17828
18150
|
const { value } = await connection.simulateTransaction(transaction, {
|
|
17829
18151
|
sigVerify: false,
|
|
17830
18152
|
commitment: SQUADS_SIMULATION_COMMITMENT,
|
|
@@ -17840,12 +18162,16 @@ async function simulateSquadsProposalExecution(args) {
|
|
|
17840
18162
|
return value;
|
|
17841
18163
|
}
|
|
17842
18164
|
async function prepareVaultTransaction(args) {
|
|
17843
|
-
const { connection, proposer
|
|
18165
|
+
const { connection, proposer } = args;
|
|
18166
|
+
let instructions2 = [...args.instructions];
|
|
18167
|
+
const ephemeralKeys = args.ephemeralSignerKeys ?? [];
|
|
17844
18168
|
const route = findSquadsWalletRoute(proposer, args.squadsRoutes ?? []);
|
|
17845
18169
|
if (!route) {
|
|
18170
|
+
if (ephemeralKeys.length)
|
|
18171
|
+
throw new Error("Ephemeral signers require a Squads route");
|
|
17846
18172
|
return {
|
|
17847
18173
|
kind: "direct",
|
|
17848
|
-
transaction: new
|
|
18174
|
+
transaction: new import_web325.Transaction().add(...instructions2),
|
|
17849
18175
|
authority: proposer
|
|
17850
18176
|
};
|
|
17851
18177
|
}
|
|
@@ -17870,6 +18196,44 @@ async function prepareVaultTransaction(args) {
|
|
|
17870
18196
|
);
|
|
17871
18197
|
}
|
|
17872
18198
|
const transactionIndex = BigInt(multisig.transactionIndex.toString()) + 1n;
|
|
18199
|
+
if (ephemeralKeys.length > 255 || new Set(ephemeralKeys.map(String)).size !== ephemeralKeys.length) {
|
|
18200
|
+
throw new Error("Invalid Squads ephemeral signer keys");
|
|
18201
|
+
}
|
|
18202
|
+
const [transactionPda] = squads.getTransactionPda({
|
|
18203
|
+
multisigPda: route.multisigPda,
|
|
18204
|
+
index: transactionIndex
|
|
18205
|
+
});
|
|
18206
|
+
const replacements = /* @__PURE__ */ new Map();
|
|
18207
|
+
ephemeralKeys.forEach((key, index) => {
|
|
18208
|
+
if (key.equals(proposer) || key.equals(route.vaultPda) || !instructions2.some(
|
|
18209
|
+
(ix) => ix.keys.some((meta) => meta.isSigner && meta.pubkey.equals(key))
|
|
18210
|
+
) || instructions2.some(
|
|
18211
|
+
(ix) => ix.programId.equals(key) || ix.data.includes(key.toBuffer())
|
|
18212
|
+
)) {
|
|
18213
|
+
throw new Error(
|
|
18214
|
+
"Ephemeral signer must be a separate account-meta signer, never embedded in instruction data"
|
|
18215
|
+
);
|
|
18216
|
+
}
|
|
18217
|
+
replacements.set(
|
|
18218
|
+
key.toBase58(),
|
|
18219
|
+
squads.getEphemeralSignerPda({
|
|
18220
|
+
transactionPda,
|
|
18221
|
+
ephemeralSignerIndex: index
|
|
18222
|
+
})[0]
|
|
18223
|
+
);
|
|
18224
|
+
});
|
|
18225
|
+
if (replacements.size) {
|
|
18226
|
+
instructions2 = instructions2.map(
|
|
18227
|
+
(ix) => new import_web325.TransactionInstruction({
|
|
18228
|
+
programId: ix.programId,
|
|
18229
|
+
data: ix.data,
|
|
18230
|
+
keys: ix.keys.map((meta) => ({
|
|
18231
|
+
...meta,
|
|
18232
|
+
pubkey: replacements.get(meta.pubkey.toBase58()) ?? meta.pubkey
|
|
18233
|
+
}))
|
|
18234
|
+
})
|
|
18235
|
+
);
|
|
18236
|
+
}
|
|
17873
18237
|
const { blockhash } = await connection.getLatestBlockhash("confirmed");
|
|
17874
18238
|
if (!args.skipSimulation) {
|
|
17875
18239
|
await simulateSquadsProposalExecution({
|
|
@@ -17880,7 +18244,7 @@ async function prepareVaultTransaction(args) {
|
|
|
17880
18244
|
addressLookupTableAccounts: args.addressLookupTableAccounts
|
|
17881
18245
|
});
|
|
17882
18246
|
}
|
|
17883
|
-
const transactionMessage = new
|
|
18247
|
+
const transactionMessage = new import_web325.TransactionMessage({
|
|
17884
18248
|
payerKey: route.vaultPda,
|
|
17885
18249
|
recentBlockhash: blockhash,
|
|
17886
18250
|
instructions: [...instructions2]
|
|
@@ -17890,7 +18254,7 @@ async function prepareVaultTransaction(args) {
|
|
|
17890
18254
|
transactionIndex,
|
|
17891
18255
|
creator: proposer,
|
|
17892
18256
|
vaultIndex: route.vaultIndex,
|
|
17893
|
-
ephemeralSigners:
|
|
18257
|
+
ephemeralSigners: ephemeralKeys.length,
|
|
17894
18258
|
transactionMessage,
|
|
17895
18259
|
addressLookupTableAccounts: args.addressLookupTableAccounts,
|
|
17896
18260
|
memo: route.memo
|
|
@@ -17910,7 +18274,7 @@ async function prepareVaultTransaction(args) {
|
|
|
17910
18274
|
});
|
|
17911
18275
|
return {
|
|
17912
18276
|
kind: "squads",
|
|
17913
|
-
transaction: new
|
|
18277
|
+
transaction: new import_web325.Transaction().add(
|
|
17914
18278
|
createVaultTransactionIx,
|
|
17915
18279
|
createProposalIx
|
|
17916
18280
|
),
|
|
@@ -17925,16 +18289,16 @@ async function prepareVaultTransaction(args) {
|
|
|
17925
18289
|
|
|
17926
18290
|
// src/utils/squadsBuffer.ts
|
|
17927
18291
|
var squads2 = __toESM(require("@sqds/multisig"));
|
|
17928
|
-
var
|
|
18292
|
+
var import_web326 = require("@solana/web3.js");
|
|
17929
18293
|
var PacketSize = 1232;
|
|
17930
18294
|
var BufferChunkSize = 700;
|
|
17931
18295
|
var MaxBufferSize = 4e3;
|
|
17932
18296
|
async function prepareSquadsProposalUpload(args) {
|
|
17933
18297
|
const { connection, proposer, prepared } = args;
|
|
17934
18298
|
const transaction = prepared.transaction;
|
|
17935
|
-
const sizeProbe = new
|
|
18299
|
+
const sizeProbe = new import_web326.Transaction({
|
|
17936
18300
|
feePayer: proposer,
|
|
17937
|
-
recentBlockhash:
|
|
18301
|
+
recentBlockhash: import_web326.PublicKey.default.toBase58()
|
|
17938
18302
|
}).add(...transaction.instructions);
|
|
17939
18303
|
let fits = false;
|
|
17940
18304
|
try {
|
|
@@ -17954,7 +18318,7 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
17954
18318
|
let bufferPda;
|
|
17955
18319
|
let bufferIndex = 0;
|
|
17956
18320
|
for (; bufferIndex <= 255; bufferIndex++) {
|
|
17957
|
-
const [candidate] =
|
|
18321
|
+
const [candidate] = import_web326.PublicKey.findProgramAddressSync(
|
|
17958
18322
|
[
|
|
17959
18323
|
Buffer.from("multisig"),
|
|
17960
18324
|
prepared.multisigPda.toBuffer(),
|
|
@@ -17982,7 +18346,7 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
17982
18346
|
creator: proposer
|
|
17983
18347
|
};
|
|
17984
18348
|
const setupTransactions = [
|
|
17985
|
-
new
|
|
18349
|
+
new import_web326.Transaction().add(
|
|
17986
18350
|
squads2.generated.createTransactionBufferCreateInstruction(
|
|
17987
18351
|
{
|
|
17988
18352
|
...accounts2,
|
|
@@ -18002,7 +18366,7 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
18002
18366
|
];
|
|
18003
18367
|
for (let offset = BufferChunkSize; offset < bytes.length; offset += BufferChunkSize) {
|
|
18004
18368
|
setupTransactions.push(
|
|
18005
|
-
new
|
|
18369
|
+
new import_web326.Transaction().add(
|
|
18006
18370
|
squads2.generated.createTransactionBufferExtendInstruction(accounts2, {
|
|
18007
18371
|
args: { buffer: bytes.slice(offset, offset + BufferChunkSize) }
|
|
18008
18372
|
})
|
|
@@ -18015,7 +18379,7 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
18015
18379
|
vaultTransactionCreateItemTransaction: prepared.vaultTransactionPda,
|
|
18016
18380
|
vaultTransactionCreateItemCreator: proposer,
|
|
18017
18381
|
vaultTransactionCreateItemRentPayer: proposer,
|
|
18018
|
-
vaultTransactionCreateItemSystemProgram:
|
|
18382
|
+
vaultTransactionCreateItemSystemProgram: import_web326.SystemProgram.programId,
|
|
18019
18383
|
transactionBuffer: bufferPda,
|
|
18020
18384
|
creator: proposer
|
|
18021
18385
|
},
|
|
@@ -18027,7 +18391,7 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
18027
18391
|
).isWritable = true;
|
|
18028
18392
|
return {
|
|
18029
18393
|
setupTransactions,
|
|
18030
|
-
proposalTransaction: new
|
|
18394
|
+
proposalTransaction: new import_web326.Transaction().add(
|
|
18031
18395
|
finalize,
|
|
18032
18396
|
...transaction.instructions.slice(1)
|
|
18033
18397
|
),
|
|
@@ -18037,21 +18401,21 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
18037
18401
|
}
|
|
18038
18402
|
|
|
18039
18403
|
// src/utils/token.ts
|
|
18040
|
-
var
|
|
18041
|
-
var
|
|
18042
|
-
var
|
|
18043
|
-
async function createTokenMintIxs(connection, payer, authority, decimals, tokenProgram =
|
|
18044
|
-
const mint =
|
|
18045
|
-
const lamports = await (0,
|
|
18404
|
+
var import_spl_token20 = require("@solana/spl-token");
|
|
18405
|
+
var import_web327 = require("@solana/web3.js");
|
|
18406
|
+
var import_common45 = __toESM(require_dist());
|
|
18407
|
+
async function createTokenMintIxs(connection, payer, authority, decimals, tokenProgram = import_spl_token20.TOKEN_2022_PROGRAM_ID) {
|
|
18408
|
+
const mint = import_web327.Keypair.generate();
|
|
18409
|
+
const lamports = await (0, import_spl_token20.getMinimumBalanceForRentExemptMint)(connection);
|
|
18046
18410
|
const ixs = [
|
|
18047
|
-
|
|
18411
|
+
import_web327.SystemProgram.createAccount({
|
|
18048
18412
|
fromPubkey: payer,
|
|
18049
18413
|
newAccountPubkey: mint.publicKey,
|
|
18050
|
-
space:
|
|
18414
|
+
space: import_spl_token20.MINT_SIZE,
|
|
18051
18415
|
lamports,
|
|
18052
18416
|
programId: tokenProgram
|
|
18053
18417
|
}),
|
|
18054
|
-
(0,
|
|
18418
|
+
(0, import_spl_token20.createInitializeMint2Instruction)(
|
|
18055
18419
|
mint.publicKey,
|
|
18056
18420
|
decimals,
|
|
18057
18421
|
authority,
|
|
@@ -18061,7 +18425,7 @@ async function createTokenMintIxs(connection, payer, authority, decimals, tokenP
|
|
|
18061
18425
|
];
|
|
18062
18426
|
return { mint, ixs };
|
|
18063
18427
|
}
|
|
18064
|
-
async function createTokenMint(connection, payer, decimals, tokenProgram =
|
|
18428
|
+
async function createTokenMint(connection, payer, decimals, tokenProgram = import_spl_token20.TOKEN_2022_PROGRAM_ID) {
|
|
18065
18429
|
const { mint, ixs } = await createTokenMintIxs(
|
|
18066
18430
|
connection,
|
|
18067
18431
|
payer.publicKey,
|
|
@@ -18070,7 +18434,7 @@ async function createTokenMint(connection, payer, decimals, tokenProgram = impor
|
|
|
18070
18434
|
tokenProgram
|
|
18071
18435
|
);
|
|
18072
18436
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
|
|
18073
|
-
const tx = new
|
|
18437
|
+
const tx = new import_web327.Transaction().add(...ixs);
|
|
18074
18438
|
tx.feePayer = payer.publicKey;
|
|
18075
18439
|
tx.recentBlockhash = blockhash;
|
|
18076
18440
|
tx.sign(payer, mint);
|
|
@@ -18083,24 +18447,24 @@ async function createTokenMint(connection, payer, decimals, tokenProgram = impor
|
|
|
18083
18447
|
);
|
|
18084
18448
|
return mint.publicKey;
|
|
18085
18449
|
}
|
|
18086
|
-
async function mintTokensTo(connection, payer, mint, destination, amount, tokenProgram =
|
|
18087
|
-
const tokenProgramPk = (0,
|
|
18088
|
-
const ata = (0,
|
|
18450
|
+
async function mintTokensTo(connection, payer, mint, destination, amount, tokenProgram = import_spl_token20.TOKEN_2022_PROGRAM_ID, allowOwnerOffCurve = true) {
|
|
18451
|
+
const tokenProgramPk = (0, import_common45.asWeb3PublicKey)(tokenProgram);
|
|
18452
|
+
const ata = (0, import_spl_token20.getAssociatedTokenAddressSync)(
|
|
18089
18453
|
mint,
|
|
18090
18454
|
destination,
|
|
18091
18455
|
allowOwnerOffCurve,
|
|
18092
18456
|
tokenProgramPk
|
|
18093
18457
|
);
|
|
18094
18458
|
const ixs = [
|
|
18095
|
-
(0,
|
|
18459
|
+
(0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
|
|
18096
18460
|
payer.publicKey,
|
|
18097
18461
|
ata,
|
|
18098
18462
|
destination,
|
|
18099
18463
|
mint,
|
|
18100
18464
|
tokenProgramPk,
|
|
18101
|
-
|
|
18465
|
+
import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
18102
18466
|
),
|
|
18103
|
-
(0,
|
|
18467
|
+
(0, import_spl_token20.createMintToInstruction)(
|
|
18104
18468
|
mint,
|
|
18105
18469
|
ata,
|
|
18106
18470
|
payer.publicKey,
|
|
@@ -18109,12 +18473,12 @@ async function mintTokensTo(connection, payer, mint, destination, amount, tokenP
|
|
|
18109
18473
|
tokenProgramPk
|
|
18110
18474
|
)
|
|
18111
18475
|
];
|
|
18112
|
-
const tx = new
|
|
18476
|
+
const tx = new import_web327.Transaction().add(...ixs);
|
|
18113
18477
|
await connection.sendTransaction(tx, [payer]);
|
|
18114
18478
|
}
|
|
18115
18479
|
|
|
18116
18480
|
// src/utils/yieldApi.ts
|
|
18117
|
-
var
|
|
18481
|
+
var import_core23 = require("@anchor-lang/core");
|
|
18118
18482
|
var YIELD_API_BASE = process.env.YIELD_API_BASE ?? "https://yield-tracker.perena.org";
|
|
18119
18483
|
async function yieldApiReq(endpoint, reqType, bodyData, options) {
|
|
18120
18484
|
const headers = {
|
|
@@ -18440,7 +18804,7 @@ async function getTrackedValue(accountName) {
|
|
|
18440
18804
|
return trackedValueFromResponse(await getYield(accountName));
|
|
18441
18805
|
}
|
|
18442
18806
|
async function getTotalYield(accountNames, start, end) {
|
|
18443
|
-
let totalYield = new
|
|
18807
|
+
let totalYield = new import_core23.BN(0);
|
|
18444
18808
|
for (const accountName of accountNames) {
|
|
18445
18809
|
const res = await getYield(accountName, start, end);
|
|
18446
18810
|
if (isNavAccountValue(res)) {
|
|
@@ -18449,7 +18813,7 @@ async function getTotalYield(accountNames, start, end) {
|
|
|
18449
18813
|
);
|
|
18450
18814
|
}
|
|
18451
18815
|
console.log(res);
|
|
18452
|
-
totalYield = totalYield.add(new
|
|
18816
|
+
totalYield = totalYield.add(new import_core23.BN(res.total_yield));
|
|
18453
18817
|
}
|
|
18454
18818
|
return totalYield;
|
|
18455
18819
|
}
|
|
@@ -18466,7 +18830,7 @@ async function getTotalOutstandingYield(accountNames, start, end) {
|
|
|
18466
18830
|
}
|
|
18467
18831
|
return total;
|
|
18468
18832
|
}
|
|
18469
|
-
async function getTotalTrackedValue(accountNames, start, end) {
|
|
18833
|
+
async function getTotalTrackedValue(accountNames, start, end, onAccountValue) {
|
|
18470
18834
|
let totalValue = 0;
|
|
18471
18835
|
let principal = 0;
|
|
18472
18836
|
let outstandingYield = 0;
|
|
@@ -18476,12 +18840,13 @@ async function getTotalTrackedValue(accountNames, start, end) {
|
|
|
18476
18840
|
totalValue += tracked.totalValue;
|
|
18477
18841
|
principal += tracked.principal;
|
|
18478
18842
|
outstandingYield += tracked.outstandingYield;
|
|
18843
|
+
onAccountValue?.(accountName, tracked);
|
|
18479
18844
|
}
|
|
18480
18845
|
return { totalValue, principal, outstandingYield };
|
|
18481
18846
|
}
|
|
18482
18847
|
|
|
18483
18848
|
// src/services/withdrawalQueueService.ts
|
|
18484
|
-
var
|
|
18849
|
+
var import_common46 = __toESM(require_dist());
|
|
18485
18850
|
function bnToBigInt(value) {
|
|
18486
18851
|
return BigInt(value.toString());
|
|
18487
18852
|
}
|
|
@@ -18502,7 +18867,7 @@ var WithdrawalQueueService = class {
|
|
|
18502
18867
|
const program = this.client.program.account;
|
|
18503
18868
|
const accounts2 = await program.vaultWithdrawalQueue.all();
|
|
18504
18869
|
return accounts2.map(
|
|
18505
|
-
(entry) => this.toSnapshot((0,
|
|
18870
|
+
(entry) => this.toSnapshot((0, import_common46.fromWeb3Pk)(entry.publicKey), entry.account)
|
|
18506
18871
|
);
|
|
18507
18872
|
}
|
|
18508
18873
|
/** Withdrawal queues for a single vault. */
|
|
@@ -18543,7 +18908,7 @@ var WithdrawalQueueService = class {
|
|
|
18543
18908
|
async fulfill(signer, queue) {
|
|
18544
18909
|
const plan = await this.client.tx.fulfillJuniorTrancheWithdraw.getTx({
|
|
18545
18910
|
owner: queue.owner,
|
|
18546
|
-
signer: (0,
|
|
18911
|
+
signer: (0, import_common46.fromWeb3Pk)(signer.publicKey),
|
|
18547
18912
|
queuePayer: queue.payer,
|
|
18548
18913
|
vault: queue.vault,
|
|
18549
18914
|
withdrawalQueue: queue.pda,
|
|
@@ -18597,12 +18962,12 @@ var WithdrawalQueueService = class {
|
|
|
18597
18962
|
const a = account;
|
|
18598
18963
|
return {
|
|
18599
18964
|
pda,
|
|
18600
|
-
vault: (0,
|
|
18601
|
-
owner: (0,
|
|
18602
|
-
payer: (0,
|
|
18965
|
+
vault: (0, import_common46.fromWeb3Pk)(a.parties.vault),
|
|
18966
|
+
owner: (0, import_common46.fromWeb3Pk)(a.parties.owner),
|
|
18967
|
+
payer: (0, import_common46.fromWeb3Pk)(a.parties.payer),
|
|
18603
18968
|
queueId: a.header.queueId,
|
|
18604
|
-
inputMint: (0,
|
|
18605
|
-
outputMint: (0,
|
|
18969
|
+
inputMint: (0, import_common46.fromWeb3Pk)(a.mints.inputMint),
|
|
18970
|
+
outputMint: (0, import_common46.fromWeb3Pk)(a.mints.outputMint),
|
|
18606
18971
|
inputAmount: bnToBigInt(a.request.inputAmount),
|
|
18607
18972
|
requestTs: bnToNumber(a.request.requestTs),
|
|
18608
18973
|
expiryTs: bnToNumber(a.request.expiryTs)
|
|
@@ -18612,7 +18977,7 @@ var WithdrawalQueueService = class {
|
|
|
18612
18977
|
|
|
18613
18978
|
// src/services/oracleService.ts
|
|
18614
18979
|
var import_kit11 = require("@solana/kit");
|
|
18615
|
-
var
|
|
18980
|
+
var import_common47 = __toESM(require_dist());
|
|
18616
18981
|
var SYSTEM_PROGRAM2 = "11111111111111111111111111111111";
|
|
18617
18982
|
var DEFAULT_PRICE_STALENESS_THRESHOLD_SECS2 = 86400n;
|
|
18618
18983
|
var PRICE_ORACLE_TYPES_BY_INDEX2 = [
|
|
@@ -18676,7 +19041,7 @@ var OracleService = class {
|
|
|
18676
19041
|
*/
|
|
18677
19042
|
async updateAssetConsensusPrice(signer, args, log) {
|
|
18678
19043
|
const plan = await this.client.tx.updateConsensusOracle.getTx({
|
|
18679
|
-
signer: (0,
|
|
19044
|
+
signer: (0, import_common47.fromWeb3Pk)(signer.publicKey),
|
|
18680
19045
|
vault: args.vault,
|
|
18681
19046
|
updates: args.updates,
|
|
18682
19047
|
assetMint: args.assetMint,
|
|
@@ -18692,7 +19057,7 @@ var OracleService = class {
|
|
|
18692
19057
|
/** Settle the vault NAV from its current holdings (permissionless). */
|
|
18693
19058
|
async crankNav(cranker, args, log) {
|
|
18694
19059
|
const plan = await this.client.tx.crankNav.getTx({
|
|
18695
|
-
cranker: (0,
|
|
19060
|
+
cranker: (0, import_common47.fromWeb3Pk)(cranker.publicKey),
|
|
18696
19061
|
vault: args.vault,
|
|
18697
19062
|
vaultTrancheState: args.vaultTrancheState
|
|
18698
19063
|
});
|
|
@@ -18765,7 +19130,7 @@ var OracleService = class {
|
|
|
18765
19130
|
/** Re-price one live-oracle holding from its bound Pyth/nested-vault account. */
|
|
18766
19131
|
async refreshAssetPrice(updater, args, log) {
|
|
18767
19132
|
const plan = await this.client.tx.updateAssetPrice.getTx({
|
|
18768
|
-
updater: (0,
|
|
19133
|
+
updater: (0, import_common47.fromWeb3Pk)(updater.publicKey),
|
|
18769
19134
|
vault: args.vault,
|
|
18770
19135
|
mint: args.mint,
|
|
18771
19136
|
oracleAccount: args.oracleAccount,
|
|
@@ -18861,11 +19226,11 @@ function toBigInt2(value) {
|
|
|
18861
19226
|
}
|
|
18862
19227
|
|
|
18863
19228
|
// src/services/consensusOracle/utils/holdings.ts
|
|
18864
|
-
var
|
|
18865
|
-
var
|
|
19229
|
+
var import_web328 = require("@solana/web3.js");
|
|
19230
|
+
var import_common48 = __toESM(require_dist());
|
|
18866
19231
|
function selectReportableHoldings(holdings, excludedMints = /* @__PURE__ */ new Set()) {
|
|
18867
19232
|
return holdings.map((holding, holdingIndex) => ({ holding, holdingIndex })).filter(({ holding }) => {
|
|
18868
|
-
const mint = (0,
|
|
19233
|
+
const mint = (0, import_common48.fromWeb3Pk)(holding.mint);
|
|
18869
19234
|
return mint !== SYSTEM_PROGRAM && !excludedMints.has(mint.toString()) && REPORTABLE_ORACLE_VARIANTS.has(
|
|
18870
19235
|
variantName2(holding.priceOracleType).toLowerCase()
|
|
18871
19236
|
);
|
|
@@ -18900,7 +19265,7 @@ function parseExternalLiquidityRefs(vaultState) {
|
|
|
18900
19265
|
if (!data || data.length < 40) continue;
|
|
18901
19266
|
if (data[0] !== 1) continue;
|
|
18902
19267
|
const pubkeyBytes = new Uint8Array(data.slice(8, 40));
|
|
18903
|
-
const userAccount = new
|
|
19268
|
+
const userAccount = new import_web328.PublicKey(pubkeyBytes).toBase58();
|
|
18904
19269
|
refs.push({
|
|
18905
19270
|
kind: "marginfi",
|
|
18906
19271
|
mint: "",
|
|
@@ -19126,17 +19491,18 @@ function formatBpsAsPercent(bps) {
|
|
|
19126
19491
|
}
|
|
19127
19492
|
|
|
19128
19493
|
// src/services/consensusOracle/pipeline/dryRunSettlement.ts
|
|
19129
|
-
var
|
|
19130
|
-
var
|
|
19494
|
+
var import_web330 = require("@solana/web3.js");
|
|
19495
|
+
var import_common49 = __toESM(require_dist());
|
|
19131
19496
|
|
|
19132
19497
|
// src/services/consensusOracle/settlement/settlementSimulator.ts
|
|
19133
19498
|
var import_kit12 = require("@solana/kit");
|
|
19134
|
-
var
|
|
19499
|
+
var import_web329 = require("@solana/web3.js");
|
|
19135
19500
|
var DEFAULT_SHARE_PRICE = 1000000n;
|
|
19136
19501
|
var BPS_DENOMINATOR3 = 10000n;
|
|
19137
19502
|
var NAV_LOSS_TOLERANCE_BPS = 25n;
|
|
19138
19503
|
var SECONDS_PER_YEAR = 31536000n;
|
|
19139
19504
|
var MAX_APY_ANCHOR_WINDOW_SECS = 604800n;
|
|
19505
|
+
var MAX_APY_PREVIOUS_ANCHOR_AGE_SECS = 2n * MAX_APY_ANCHOR_WINDOW_SECS;
|
|
19140
19506
|
var DEFAULT_STALENESS_SECS = 86400n;
|
|
19141
19507
|
var CONSENSUS_MAX_DIFF_BPS = 8n;
|
|
19142
19508
|
var MIN_CONSENSUS_SIGNERS = 2;
|
|
@@ -19334,7 +19700,7 @@ function applyConsensus(holdings, entries, nowTs, stalenessThresholdSecs) {
|
|
|
19334
19700
|
continue;
|
|
19335
19701
|
}
|
|
19336
19702
|
const reports = entries.filter(
|
|
19337
|
-
(entry) => entry.signer !==
|
|
19703
|
+
(entry) => entry.signer !== import_web329.PublicKey.default.toBase58() && isFresh(entry.lastUpdateTs, nowTs, stalenessThresholdSecs) && (entry.prices[index] ?? 0n) > 0n
|
|
19338
19704
|
);
|
|
19339
19705
|
const usesConsensusPrice = holding.priceOracleType === "consensusoracle";
|
|
19340
19706
|
const prices = reports.map((entry) => entry.prices[index] ?? 0n);
|
|
@@ -19409,7 +19775,9 @@ function settleVault(args) {
|
|
|
19409
19775
|
};
|
|
19410
19776
|
timestampSource = hasFixedAnchor ? "legacy fixed-APY anchor (initialization)" : "current share-price observation (initialization)";
|
|
19411
19777
|
}
|
|
19412
|
-
const
|
|
19778
|
+
const hasPreviousForShortWindow = args.nowTs - maxApyAnchor.timestamp < MAX_APY_ANCHOR_WINDOW_SECS && maxApyAnchor.previousSharePrice > 0n && maxApyAnchor.previousTimestamp > 0n;
|
|
19779
|
+
const previousTooOld = args.nowTs - maxApyAnchor.previousTimestamp > MAX_APY_PREVIOUS_ANCHOR_AGE_SECS;
|
|
19780
|
+
const usePrevious = hasPreviousForShortWindow && !previousTooOld;
|
|
19413
19781
|
const priorApyValue = usePrevious ? maxApyAnchor.previousSharePrice : maxApyAnchor.sharePrice;
|
|
19414
19782
|
const priorTs = usePrevious ? maxApyAnchor.previousTimestamp : maxApyAnchor.timestamp;
|
|
19415
19783
|
if (usePrevious) timestampSource = "apy.max_apy_anchor.previous_timestamp";
|
|
@@ -19497,6 +19865,7 @@ function settleVault(args) {
|
|
|
19497
19865
|
priorTs,
|
|
19498
19866
|
timestampSource,
|
|
19499
19867
|
checkpointTs: maxApyAnchor.timestamp,
|
|
19868
|
+
ignoredPreviousCheckpointTs: hasPreviousForShortWindow && previousTooOld ? maxApyAnchor.previousTimestamp : void 0,
|
|
19500
19869
|
nowTs: args.nowTs,
|
|
19501
19870
|
elapsedSecs,
|
|
19502
19871
|
impliedApyMicroBps: rateAvailable ? numerator * 1000000n / denominator : void 0,
|
|
@@ -19832,7 +20201,7 @@ function decodeOracleData(data, nowTs) {
|
|
|
19832
20201
|
(_, holdingIndex) => readU64(data, offset + EXTERNAL_OFFSET + holdingIndex * 8)
|
|
19833
20202
|
);
|
|
19834
20203
|
entries.push({
|
|
19835
|
-
signer: new
|
|
20204
|
+
signer: new import_web329.PublicKey(signerBytes).toBase58(),
|
|
19836
20205
|
lastUpdateTs: readI64(data, offset + 32),
|
|
19837
20206
|
prices,
|
|
19838
20207
|
externalAmounts
|
|
@@ -19847,7 +20216,7 @@ function decodeOracleData(data, nowTs) {
|
|
|
19847
20216
|
data.slice(pendingOffset + index * 32, pendingOffset + (index + 1) * 32)
|
|
19848
20217
|
);
|
|
19849
20218
|
entries[index] = {
|
|
19850
|
-
signer: index < pendingCount ? new
|
|
20219
|
+
signer: index < pendingCount ? new import_web329.PublicKey(signerBytes).toBase58() : import_web329.PublicKey.default.toBase58(),
|
|
19851
20220
|
lastUpdateTs: 0n,
|
|
19852
20221
|
prices: Array(MAX_HOLDINGS).fill(0n),
|
|
19853
20222
|
externalAmounts: Array(MAX_HOLDINGS).fill(0n)
|
|
@@ -19875,7 +20244,7 @@ function decodeHolding(value) {
|
|
|
19875
20244
|
externalAmount: bigint(holding.externalAmount),
|
|
19876
20245
|
price: bigint(holding.price),
|
|
19877
20246
|
lastUpdateTs: bigint(holding.lastUpdateTs),
|
|
19878
|
-
cleared: mintString ===
|
|
20247
|
+
cleared: mintString === import_web329.PublicKey.default.toBase58()
|
|
19879
20248
|
};
|
|
19880
20249
|
}
|
|
19881
20250
|
function decodeTrancheState(decoded, args, warnings, blockers) {
|
|
@@ -20250,17 +20619,22 @@ function formatRealizedApy(apy) {
|
|
|
20250
20619
|
apy.priorValue,
|
|
20251
20620
|
6
|
|
20252
20621
|
)} [${apy.priorValue}] -> ${apy.nextValue === void 0 ? "unavailable (zero supply)" : `${formatUnits(apy.nextValue, 6)} [${apy.nextValue}]`}`,
|
|
20253
|
-
` weekly checkpoints: every 604800s (7 days); previous checkpoint
|
|
20622
|
+
` weekly checkpoints: every 604800s (7 days); previous checkpoint used only when at most 14 days old; latest=${apy.checkpointTs}`,
|
|
20254
20623
|
` observation window: ${formatUnits(
|
|
20255
20624
|
apy.elapsedSecs * 1000000n / 86400n,
|
|
20256
20625
|
6
|
|
20257
|
-
)} days${apy.elapsedSecs < MAX_APY_ANCHOR_WINDOW_SECS ? " (
|
|
20626
|
+
)} days${apy.elapsedSecs < MAX_APY_ANCHOR_WINDOW_SECS ? " (short observation window: less than 7 days)" : ""}`,
|
|
20258
20627
|
` timestamp: ${apy.priorTs} from ${apy.timestampSource}; settlement time estimate=${apy.nowTs}; elapsed=${apy.elapsedSecs}s`,
|
|
20259
20628
|
` configured max: ${apy.maxApyBps}bps (${formatUnits(
|
|
20260
20629
|
BigInt(apy.maxApyBps),
|
|
20261
20630
|
2
|
|
20262
20631
|
)}%); regular HWM: ${apy.hwmBefore} -> ${apy.hwmAfter}`
|
|
20263
20632
|
];
|
|
20633
|
+
if (apy.ignoredPreviousCheckpointTs !== void 0) {
|
|
20634
|
+
lines.push(
|
|
20635
|
+
` previous checkpoint ${apy.ignoredPreviousCheckpointTs} ignored (older than 14 days); using the latest checkpoint`
|
|
20636
|
+
);
|
|
20637
|
+
}
|
|
20264
20638
|
if (apy.impliedApyMicroBps !== void 0) {
|
|
20265
20639
|
lines.push(
|
|
20266
20640
|
` implied APY (linear annualization): ${formatUnits(
|
|
@@ -20340,11 +20714,11 @@ async function simulateDryRunSettlement({
|
|
|
20340
20714
|
client.account.fetchVaultOracleForVault(vault, { fresh: true }),
|
|
20341
20715
|
tranchingEnabled ? client.account.fetchVaultTrancheStateForVault(vault, { fresh: true }) : Promise.resolve(void 0)
|
|
20342
20716
|
]);
|
|
20343
|
-
const mintKeys = [new
|
|
20717
|
+
const mintKeys = [new import_web330.PublicKey(vaultState.mint)];
|
|
20344
20718
|
if (trancheState) {
|
|
20345
20719
|
mintKeys.push(
|
|
20346
|
-
new
|
|
20347
|
-
new
|
|
20720
|
+
new import_web330.PublicKey(trancheState.config.juniorMint),
|
|
20721
|
+
new import_web330.PublicKey(trancheState.config.seniorMint)
|
|
20348
20722
|
);
|
|
20349
20723
|
}
|
|
20350
20724
|
const mintAccounts = await client.provider.connection.getMultipleAccountsInfo(
|
|
@@ -20360,7 +20734,7 @@ async function simulateDryRunSettlement({
|
|
|
20360
20734
|
oracleData: oracleState.data,
|
|
20361
20735
|
trancheState,
|
|
20362
20736
|
updates,
|
|
20363
|
-
signer: (0,
|
|
20737
|
+
signer: (0, import_common49.fromWeb3Pk)(signer.publicKey),
|
|
20364
20738
|
nowTs: nowSecs,
|
|
20365
20739
|
physicalShareSupply: supplies[0],
|
|
20366
20740
|
physicalJuniorSupply: tranchingEnabled ? supplies[1] : void 0,
|
|
@@ -20369,7 +20743,7 @@ async function simulateDryRunSettlement({
|
|
|
20369
20743
|
}
|
|
20370
20744
|
|
|
20371
20745
|
// src/services/consensusOracle/pipeline/holdingUpdates.ts
|
|
20372
|
-
var
|
|
20746
|
+
var import_common50 = __toESM(require_dist());
|
|
20373
20747
|
async function buildUpdates(yieldTracker, reportableHoldings, inputs) {
|
|
20374
20748
|
const updates = [];
|
|
20375
20749
|
for (const entry of reportableHoldings) {
|
|
@@ -20379,7 +20753,7 @@ async function buildUpdates(yieldTracker, reportableHoldings, inputs) {
|
|
|
20379
20753
|
}
|
|
20380
20754
|
async function buildHoldingUpdate(yieldTracker, entry, inputs) {
|
|
20381
20755
|
const { holding, holdingIndex } = entry;
|
|
20382
|
-
const mint = (0,
|
|
20756
|
+
const mint = (0, import_common50.fromWeb3Pk)(holding.mint);
|
|
20383
20757
|
const mintKey = mint.toString();
|
|
20384
20758
|
const oracleType = variantName2(holding.priceOracleType).toLowerCase();
|
|
20385
20759
|
let usd;
|
|
@@ -20441,14 +20815,14 @@ async function resolveTrackedAmounts(yieldTracker, cfg, decimals) {
|
|
|
20441
20815
|
);
|
|
20442
20816
|
}
|
|
20443
20817
|
return {
|
|
20444
|
-
trackedValueAmount: tracked.totalValue > 0 ? (0,
|
|
20445
|
-
principalAmount: tracked.principal > 0 ? (0,
|
|
20446
|
-
yieldAmount: tracked.outstandingYield > 0 ? (0,
|
|
20818
|
+
trackedValueAmount: tracked.totalValue > 0 ? (0, import_common50.fromUiAmount)(tracked.totalValue, decimals) : 0n,
|
|
20819
|
+
principalAmount: tracked.principal > 0 ? (0, import_common50.fromUiAmount)(tracked.principal, decimals) : 0n,
|
|
20820
|
+
yieldAmount: tracked.outstandingYield > 0 ? (0, import_common50.fromUiAmount)(tracked.outstandingYield, decimals) : 0n
|
|
20447
20821
|
};
|
|
20448
20822
|
}
|
|
20449
20823
|
|
|
20450
20824
|
// src/services/consensusOracle/pipeline/livePriceRefresh.ts
|
|
20451
|
-
var
|
|
20825
|
+
var import_common51 = __toESM(require_dist());
|
|
20452
20826
|
async function refreshLiveOraclePrices({
|
|
20453
20827
|
oracle,
|
|
20454
20828
|
signer,
|
|
@@ -20467,7 +20841,7 @@ async function refreshLiveOraclePrices({
|
|
|
20467
20841
|
for (const holding of vaultState.holdings) {
|
|
20468
20842
|
const oracleType = variantName2(holding.priceOracleType).toLowerCase();
|
|
20469
20843
|
if (!LIVE_ORACLE_VARIANTS.has(oracleType)) continue;
|
|
20470
|
-
const mint = (0,
|
|
20844
|
+
const mint = (0, import_common51.fromWeb3Pk)(holding.mint);
|
|
20471
20845
|
if (mint.toString() === SYSTEM_PROGRAM) continue;
|
|
20472
20846
|
const activeAmount = toBigInt2(holding.localAmount) + toBigInt2(holding.externalAmount);
|
|
20473
20847
|
if (activeAmount === 0n) continue;
|
|
@@ -20482,7 +20856,7 @@ async function refreshLiveOraclePrices({
|
|
|
20482
20856
|
);
|
|
20483
20857
|
continue;
|
|
20484
20858
|
}
|
|
20485
|
-
const oracleAccount = (0,
|
|
20859
|
+
const oracleAccount = (0, import_common51.fromWeb3Pk)(holding.priceOracleAccount);
|
|
20486
20860
|
if (oracleAccount.toString() === SYSTEM_PROGRAM) {
|
|
20487
20861
|
log(
|
|
20488
20862
|
`vault ${vault}: cannot refresh ${mint}; ${oracleType} holding has no oracle account`
|
|
@@ -20506,7 +20880,7 @@ async function refreshLiveOraclePrices({
|
|
|
20506
20880
|
}
|
|
20507
20881
|
|
|
20508
20882
|
// src/services/consensusOracle/pipeline/managerWalletReconciliation.ts
|
|
20509
|
-
var
|
|
20883
|
+
var import_common52 = __toESM(require_dist());
|
|
20510
20884
|
|
|
20511
20885
|
// src/services/consensusOracle/sources/nestPriceSource.ts
|
|
20512
20886
|
var import_kit13 = require("@solana/kit");
|
|
@@ -20551,13 +20925,13 @@ function candidateGrossNav(state, updates) {
|
|
|
20551
20925
|
const byIndex = /* @__PURE__ */ new Map();
|
|
20552
20926
|
for (const update of updates) {
|
|
20553
20927
|
const holding = state.holdings[update.holdingIndex];
|
|
20554
|
-
if (!holding || (0,
|
|
20928
|
+
if (!holding || (0, import_common52.fromWeb3Pk)(holding.mint) !== update.mint || holding.decimals !== update.decimals || byIndex.has(update.holdingIndex)) {
|
|
20555
20929
|
throw new Error(`Invalid NAV update for holding #${update.holdingIndex}`);
|
|
20556
20930
|
}
|
|
20557
20931
|
byIndex.set(update.holdingIndex, update);
|
|
20558
20932
|
}
|
|
20559
20933
|
return state.holdings.reduce((nav, holding, index) => {
|
|
20560
|
-
if ((0,
|
|
20934
|
+
if ((0, import_common52.fromWeb3Pk)(holding.mint) === SYSTEM_PROGRAM) return nav;
|
|
20561
20935
|
const update = byIndex.get(index);
|
|
20562
20936
|
const local = toBigInt2(holding.localAmount);
|
|
20563
20937
|
const external = update?.externalAmount ?? toBigInt2(holding.externalAmount);
|
|
@@ -20595,12 +20969,13 @@ async function reconcileManagerWalletBalances({
|
|
|
20595
20969
|
vaultState,
|
|
20596
20970
|
updates,
|
|
20597
20971
|
source,
|
|
20972
|
+
mpcSource,
|
|
20598
20973
|
log = () => {
|
|
20599
20974
|
}
|
|
20600
20975
|
}) {
|
|
20601
20976
|
const previousNav = previousPhysicalNav(vaultState);
|
|
20602
20977
|
if (updates.some(
|
|
20603
|
-
(update) => (update.managerWalletAmount ?? 0n) !== 0n || (update.pendingNestAmount ?? 0n) !== 0n
|
|
20978
|
+
(update) => (update.managerWalletAmount ?? 0n) !== 0n || (update.mpcWalletAmount ?? 0n) !== 0n || (update.mpcMarginfiAmount ?? 0n) !== 0n || (update.pendingNestAmount ?? 0n) !== 0n
|
|
20604
20979
|
)) {
|
|
20605
20980
|
throw new Error("Manager reconciliation requires fresh source amounts");
|
|
20606
20981
|
}
|
|
@@ -20632,30 +21007,49 @@ async function reconcileManagerWalletBalances({
|
|
|
20632
21007
|
throw new Error("Duplicate base mint in manager reconciliation");
|
|
20633
21008
|
}
|
|
20634
21009
|
if (vaultState.holdings.some(
|
|
20635
|
-
(holding) => coerceBool3(holding.isBase) && !mints2.includes((0,
|
|
21010
|
+
(holding) => coerceBool3(holding.isBase) && !mints2.includes((0, import_common52.fromWeb3Pk)(holding.mint))
|
|
20636
21011
|
)) {
|
|
20637
21012
|
throw new Error(
|
|
20638
21013
|
"Cannot reconcile all vault base assets with oracle reports"
|
|
20639
21014
|
);
|
|
20640
21015
|
}
|
|
20641
|
-
const manager = (0,
|
|
21016
|
+
const manager = (0, import_common52.fromWeb3Pk)(vaultState.roles.manager);
|
|
20642
21017
|
if (manager === SYSTEM_PROGRAM || manager === vault) {
|
|
20643
21018
|
throw new Error("Invalid manager wallet for NAV reconciliation");
|
|
20644
21019
|
}
|
|
20645
21020
|
log(
|
|
20646
21021
|
`vault ${vault}: NAV ${candidateNav} is at least 0.1% below ${previousNav}; checking manager ${manager}`
|
|
20647
21022
|
);
|
|
20648
|
-
const amounts = await
|
|
21023
|
+
const [amounts, mpc] = await Promise.all([
|
|
21024
|
+
source.fetchBalances(manager, mints2),
|
|
21025
|
+
mpcSource?.fetchBalances(vault, manager, mints2)
|
|
21026
|
+
]);
|
|
21027
|
+
if (mpc && [manager, vault, SYSTEM_PROGRAM].includes(mpc.wallet)) {
|
|
21028
|
+
throw new Error("Invalid MPC wallet for NAV reconciliation");
|
|
21029
|
+
}
|
|
21030
|
+
const balance = (value, label) => {
|
|
21031
|
+
if (typeof value !== "bigint" || value < 0n || value > U64_MAX) {
|
|
21032
|
+
throw new Error(`Invalid ${label} base-asset balance for reconciliation`);
|
|
21033
|
+
}
|
|
21034
|
+
return value;
|
|
21035
|
+
};
|
|
20649
21036
|
const adjusted = updates.map((update) => {
|
|
20650
21037
|
if (!mints2.includes(update.mint)) return update;
|
|
20651
|
-
const amount = amounts.get(update.mint) ?? 0n;
|
|
20652
|
-
|
|
20653
|
-
|
|
20654
|
-
|
|
21038
|
+
const amount = balance(amounts.get(update.mint) ?? 0n, "manager");
|
|
21039
|
+
const mpcTokens = balance(mpc?.tokens.get(update.mint) ?? 0n, "MPC token");
|
|
21040
|
+
const mpcMarginfi = balance(
|
|
21041
|
+
mpc?.marginfi.get(update.mint) ?? 0n,
|
|
21042
|
+
"MPC Marginfi"
|
|
21043
|
+
);
|
|
21044
|
+
if (mpc)
|
|
21045
|
+
log(
|
|
21046
|
+
`vault ${vault}: MPC ${mpc.wallet} mint ${update.mint}: tokens=${mpcTokens} marginfi=${mpcMarginfi}`
|
|
21047
|
+
);
|
|
20655
21048
|
return {
|
|
20656
21049
|
...update,
|
|
20657
21050
|
managerWalletAmount: amount,
|
|
20658
|
-
|
|
21051
|
+
...mpc ? { mpcWalletAmount: mpcTokens, mpcMarginfiAmount: mpcMarginfi } : {},
|
|
21052
|
+
externalAmount: update.externalAmount + amount + mpcTokens + mpcMarginfi
|
|
20659
21053
|
};
|
|
20660
21054
|
});
|
|
20661
21055
|
const adjustedNav = candidateGrossNav(vaultState, adjusted);
|
|
@@ -20663,7 +21057,7 @@ async function reconcileManagerWalletBalances({
|
|
|
20663
21057
|
const absoluteDelta = delta < 0n ? -delta : delta;
|
|
20664
21058
|
const accepted = adjustedNav > candidateNav && absoluteDelta * BPS <= previousNav * MANAGER_WALLET_NAV_TOLERANCE_BPS;
|
|
20665
21059
|
log(
|
|
20666
|
-
`vault ${vault}: manager wallet ${accepted ? "accepted" : "rejected"}; adjusted NAV ${adjustedNav}, previous NAV ${previousNav}, allowed difference \xB10.05%`
|
|
21060
|
+
`vault ${vault}: manager${mpc ? " + MPC wallets" : " wallet"} ${accepted ? "accepted" : "rejected"}; adjusted NAV ${adjustedNav}, previous NAV ${previousNav}, allowed difference \xB10.05%`
|
|
20667
21061
|
);
|
|
20668
21062
|
return {
|
|
20669
21063
|
accepted,
|
|
@@ -20675,10 +21069,10 @@ async function reconcileManagerWalletBalances({
|
|
|
20675
21069
|
}
|
|
20676
21070
|
function managerReconciliationStateKey(state) {
|
|
20677
21071
|
return JSON.stringify({
|
|
20678
|
-
manager: (0,
|
|
21072
|
+
manager: (0, import_common52.fromWeb3Pk)(state.roles.manager),
|
|
20679
21073
|
previousNav: previousPhysicalNav(state).toString(),
|
|
20680
21074
|
holdings: state.holdings.map((holding) => [
|
|
20681
|
-
(0,
|
|
21075
|
+
(0, import_common52.fromWeb3Pk)(holding.mint),
|
|
20682
21076
|
holding.decimals,
|
|
20683
21077
|
variantName2(holding.priceOracleType),
|
|
20684
21078
|
coerceBool3(holding.isBase),
|
|
@@ -20690,14 +21084,14 @@ function managerReconciliationStateKey(state) {
|
|
|
20690
21084
|
}
|
|
20691
21085
|
|
|
20692
21086
|
// src/services/consensusOracle/pipeline/pricingInputs.ts
|
|
20693
|
-
var
|
|
21087
|
+
var import_common53 = __toESM(require_dist());
|
|
20694
21088
|
async function gatherPricingInputs(deps, target, vaultState, reportableHoldings, log = () => {
|
|
20695
21089
|
}) {
|
|
20696
21090
|
const consensusMints = reportableHoldings.filter(
|
|
20697
21091
|
({ holding }) => variantName2(holding.priceOracleType).toLowerCase() === CONSENSUS_ORACLE_VARIANT
|
|
20698
|
-
).map(({ holding }) => (0,
|
|
21092
|
+
).map(({ holding }) => (0, import_common53.fromWeb3Pk)(holding.mint));
|
|
20699
21093
|
const baseHolding = vaultState.holdings.find((h) => coerceBool3(h.isBase));
|
|
20700
|
-
const baseMint = baseHolding ? (0,
|
|
21094
|
+
const baseMint = baseHolding ? (0, import_common53.fromWeb3Pk)(baseHolding.mint) : consensusMints[0];
|
|
20701
21095
|
if (!baseMint) {
|
|
20702
21096
|
throw new Error(`vault has no holdings \u2014 cannot determine base asset`);
|
|
20703
21097
|
}
|
|
@@ -20781,11 +21175,11 @@ function reconcilePositionSnapshots(snapshots, vault, log) {
|
|
|
20781
21175
|
}
|
|
20782
21176
|
|
|
20783
21177
|
// src/services/consensusOracle/pipeline/receiptMints.ts
|
|
20784
|
-
var
|
|
21178
|
+
var import_common54 = __toESM(require_dist());
|
|
20785
21179
|
async function fetchReceiptMints(client, vault, vaultState) {
|
|
20786
21180
|
const receiptMints = /* @__PURE__ */ new Set();
|
|
20787
21181
|
if (vaultState.mint) {
|
|
20788
|
-
receiptMints.add((0,
|
|
21182
|
+
receiptMints.add((0, import_common54.fromWeb3Pk)(vaultState.mint).toString());
|
|
20789
21183
|
}
|
|
20790
21184
|
if (!coerceBool3(vaultState.tranchingEnabled)) return receiptMints;
|
|
20791
21185
|
const trancheState = await client.account.fetchVaultTrancheStateForVault(
|
|
@@ -20793,19 +21187,19 @@ async function fetchReceiptMints(client, vault, vaultState) {
|
|
|
20793
21187
|
{ fresh: true }
|
|
20794
21188
|
);
|
|
20795
21189
|
receiptMints.add(
|
|
20796
|
-
(0,
|
|
21190
|
+
(0, import_common54.fromWeb3Pk)(trancheState.config.juniorMint).toString()
|
|
20797
21191
|
);
|
|
20798
21192
|
receiptMints.add(
|
|
20799
|
-
(0,
|
|
21193
|
+
(0, import_common54.fromWeb3Pk)(trancheState.config.seniorMint).toString()
|
|
20800
21194
|
);
|
|
20801
21195
|
return receiptMints;
|
|
20802
21196
|
}
|
|
20803
21197
|
|
|
20804
21198
|
// src/services/consensusOracle/pipeline/settlement.ts
|
|
20805
|
-
var
|
|
21199
|
+
var import_common56 = __toESM(require_dist());
|
|
20806
21200
|
|
|
20807
21201
|
// src/services/consensusOracle/pipeline/yieldAccounts.ts
|
|
20808
|
-
var
|
|
21202
|
+
var import_common55 = __toESM(require_dist());
|
|
20809
21203
|
async function assertNoUnconfirmedYieldPayments(yieldTracker, target) {
|
|
20810
21204
|
const accountNames = [
|
|
20811
21205
|
...new Set(
|
|
@@ -20847,7 +21241,7 @@ async function withDiscoveredYieldAccounts(yieldTracker, target, vaultState, exc
|
|
|
20847
21241
|
);
|
|
20848
21242
|
if (namesToAttach.length === 0) return target;
|
|
20849
21243
|
const baseHolding = vaultState.holdings.find((holding) => {
|
|
20850
|
-
const mint = (0,
|
|
21244
|
+
const mint = (0, import_common55.fromWeb3Pk)(holding.mint).toString();
|
|
20851
21245
|
return coerceBool3(holding.isBase) && !excludedMints.has(mint);
|
|
20852
21246
|
});
|
|
20853
21247
|
if (!baseHolding) {
|
|
@@ -20855,7 +21249,7 @@ async function withDiscoveredYieldAccounts(yieldTracker, target, vaultState, exc
|
|
|
20855
21249
|
`vault ${target.vault}: tagged yield accounts found but no base holding is available`
|
|
20856
21250
|
);
|
|
20857
21251
|
}
|
|
20858
|
-
const baseMint = (0,
|
|
21252
|
+
const baseMint = (0, import_common55.fromWeb3Pk)(baseHolding.mint);
|
|
20859
21253
|
const holdings = [...target.holdings ?? []];
|
|
20860
21254
|
const existingIndex = holdings.findIndex(
|
|
20861
21255
|
(holding) => holding.mint.toString() === baseMint.toString()
|
|
@@ -20895,7 +21289,7 @@ async function settleVault2({
|
|
|
20895
21289
|
log(`vault ${vault}: submitting ${updates.length} consensus asset update(s)`);
|
|
20896
21290
|
for (const update of updates) {
|
|
20897
21291
|
log(
|
|
20898
|
-
` holding #${update.holdingIndex} ${update.mint}: price=${update.price} external_amount=${update.externalAmount} [pendingNest=${update.pendingNestAmount ?? 0n} managerWallet=${update.managerWalletAmount ?? 0n} lp=${update.lpAmount} tracked=${update.trackedValueAmount} principal=${update.trackedPrincipalAmount} yield=${update.yieldAmount}]`
|
|
21292
|
+
` holding #${update.holdingIndex} ${update.mint}: price=${update.price} external_amount=${update.externalAmount} [pendingNest=${update.pendingNestAmount ?? 0n} managerWallet=${update.managerWalletAmount ?? 0n} mpcWallet=${update.mpcWalletAmount ?? 0n} mpcMarginfi=${update.mpcMarginfiAmount ?? 0n} lp=${update.lpAmount} tracked=${update.trackedValueAmount} principal=${update.trackedPrincipalAmount} yield=${update.yieldAmount}]`
|
|
20899
21293
|
);
|
|
20900
21294
|
}
|
|
20901
21295
|
try {
|
|
@@ -20958,7 +21352,7 @@ async function logProspectiveApy({
|
|
|
20958
21352
|
);
|
|
20959
21353
|
const prospectiveNav = vaultState.holdings.reduce(
|
|
20960
21354
|
(sum, holding, holdingIndex) => {
|
|
20961
|
-
const mint = (0,
|
|
21355
|
+
const mint = (0, import_common56.fromWeb3Pk)(holding.mint).toString();
|
|
20962
21356
|
if (mint === SYSTEM_PROGRAM) return sum;
|
|
20963
21357
|
const update = updatesByIndex.get(holdingIndex);
|
|
20964
21358
|
const localAmount = toBigInt2(holding.localAmount);
|
|
@@ -21046,8 +21440,8 @@ var LivePriceSource = class {
|
|
|
21046
21440
|
};
|
|
21047
21441
|
|
|
21048
21442
|
// src/services/consensusOracle/sources/managerWalletBalanceSource.ts
|
|
21049
|
-
var
|
|
21050
|
-
var
|
|
21443
|
+
var import_web331 = require("@solana/web3.js");
|
|
21444
|
+
var import_spl_token21 = require("@solana/spl-token");
|
|
21051
21445
|
var RpcManagerWalletBalanceSource = class {
|
|
21052
21446
|
constructor(connection) {
|
|
21053
21447
|
this.connection = connection;
|
|
@@ -21055,8 +21449,8 @@ var RpcManagerWalletBalanceSource = class {
|
|
|
21055
21449
|
async fetchBalances(manager, mints2) {
|
|
21056
21450
|
const wanted = new Set(mints2);
|
|
21057
21451
|
if (wanted.size === 0) return /* @__PURE__ */ new Map();
|
|
21058
|
-
const owner = new
|
|
21059
|
-
const programs = [
|
|
21452
|
+
const owner = new import_web331.PublicKey(manager);
|
|
21453
|
+
const programs = [import_spl_token21.TOKEN_PROGRAM_ID, import_spl_token21.TOKEN_2022_PROGRAM_ID];
|
|
21060
21454
|
const responses = await Promise.all(
|
|
21061
21455
|
programs.map(
|
|
21062
21456
|
(programId) => this.connection.getParsedTokenAccountsByOwner(
|
|
@@ -21098,6 +21492,124 @@ var RpcManagerWalletBalanceSource = class {
|
|
|
21098
21492
|
}
|
|
21099
21493
|
};
|
|
21100
21494
|
|
|
21495
|
+
// src/services/consensusOracle/sources/mpcWalletBalanceSource.ts
|
|
21496
|
+
var import_web332 = require("@solana/web3.js");
|
|
21497
|
+
|
|
21498
|
+
// src/services/consensusOracle/sources/mpcMarginfiDeposits.ts
|
|
21499
|
+
var import_kit14 = require("@solana/kit");
|
|
21500
|
+
var import_marginfi_client_v2 = require("@mrgnlabs/marginfi-client-v2");
|
|
21501
|
+
var import_marginfi2 = __toESM(require_dist2());
|
|
21502
|
+
async function readMarginfiDepositsForAuthority(connection, authority, mints2) {
|
|
21503
|
+
const wanted = new Set(mints2.map((mint) => mint.toBase58()));
|
|
21504
|
+
if (wanted.size === 0) return /* @__PURE__ */ new Map();
|
|
21505
|
+
const config = (0, import_marginfi_client_v2.getConfig)("production");
|
|
21506
|
+
const discriminator = import_marginfi_client_v2.MARGINFI_IDL.accounts.find(
|
|
21507
|
+
(account) => account.name.toLowerCase() === "marginfiaccount"
|
|
21508
|
+
).discriminator;
|
|
21509
|
+
const records = await connection.getProgramAccounts(config.programId, {
|
|
21510
|
+
commitment: "confirmed",
|
|
21511
|
+
filters: [
|
|
21512
|
+
{
|
|
21513
|
+
memcmp: {
|
|
21514
|
+
offset: 0,
|
|
21515
|
+
bytes: (0, import_kit14.getBase58Decoder)().decode(new Uint8Array(discriminator))
|
|
21516
|
+
}
|
|
21517
|
+
},
|
|
21518
|
+
{ memcmp: { offset: 8, bytes: config.groupPk.toBase58() } },
|
|
21519
|
+
{ memcmp: { offset: 40, bytes: authority.toBase58() } }
|
|
21520
|
+
]
|
|
21521
|
+
});
|
|
21522
|
+
if (records.length === 0) return /* @__PURE__ */ new Map();
|
|
21523
|
+
const seen = /* @__PURE__ */ new Set();
|
|
21524
|
+
const bankKeys = /* @__PURE__ */ new Map();
|
|
21525
|
+
for (const { pubkey: pubkey2, account } of records) {
|
|
21526
|
+
const key = pubkey2.toBase58();
|
|
21527
|
+
if (seen.has(key) || !account.owner.equals(config.programId) || account.data.length < 72 + 16 * 104 || !account.data.subarray(0, 8).equals(Buffer.from(discriminator)) || !account.data.subarray(8, 40).equals(config.groupPk.toBuffer()) || !account.data.subarray(40, 72).equals(authority.toBuffer())) {
|
|
21528
|
+
throw new Error(`Invalid or duplicate MPC Marginfi account ${key}`);
|
|
21529
|
+
}
|
|
21530
|
+
seen.add(key);
|
|
21531
|
+
for (const bank of (0, import_marginfi2.parseBankPksFromMarginfiAccount)(account.data))
|
|
21532
|
+
bankKeys.set(bank.toBase58(), bank);
|
|
21533
|
+
}
|
|
21534
|
+
const client = await (0, import_marginfi2.createMarginfiReadClient)(connection, [
|
|
21535
|
+
...bankKeys.values()
|
|
21536
|
+
]);
|
|
21537
|
+
const accounts2 = records.map(({ pubkey: pubkey2, account }) => {
|
|
21538
|
+
const key = pubkey2.toBase58();
|
|
21539
|
+
const decoded = import_marginfi_client_v2.MarginfiAccount.fromAccountDataRaw(
|
|
21540
|
+
pubkey2,
|
|
21541
|
+
account.data,
|
|
21542
|
+
client.program.idl
|
|
21543
|
+
);
|
|
21544
|
+
if (!decoded.authority.equals(authority) || !decoded.group.equals(config.groupPk)) {
|
|
21545
|
+
throw new Error(`Invalid MPC Marginfi authority or group for ${key}`);
|
|
21546
|
+
}
|
|
21547
|
+
for (const balance of decoded.activeBalances) {
|
|
21548
|
+
if (!balance.liabilityShares.isZero()) {
|
|
21549
|
+
throw new Error(`MPC Marginfi account has borrowing: ${key}`);
|
|
21550
|
+
}
|
|
21551
|
+
}
|
|
21552
|
+
return decoded;
|
|
21553
|
+
});
|
|
21554
|
+
const amounts = /* @__PURE__ */ new Map();
|
|
21555
|
+
for (const account of accounts2) {
|
|
21556
|
+
for (const balance of account.activeBalances) {
|
|
21557
|
+
const bank = client.getBankByPk(balance.bankPk);
|
|
21558
|
+
if (!bank)
|
|
21559
|
+
throw new Error(`MPC Marginfi bank not found: ${balance.bankPk}`);
|
|
21560
|
+
const mint = bank.mint.toBase58();
|
|
21561
|
+
if (!wanted.has(mint)) continue;
|
|
21562
|
+
const quantity = balance.computeQuantity(bank).assets;
|
|
21563
|
+
if (!quantity.isFinite() || quantity.isNegative()) {
|
|
21564
|
+
throw new Error(`Invalid MPC Marginfi deposit for ${mint}`);
|
|
21565
|
+
}
|
|
21566
|
+
const amount = BigInt(quantity.toFixed(0, 3));
|
|
21567
|
+
const total = (amounts.get(mint) ?? 0n) + amount;
|
|
21568
|
+
if (total > 0xffffffffffffffffn)
|
|
21569
|
+
throw new Error(`MPC Marginfi deposit exceeds u64: ${mint}`);
|
|
21570
|
+
amounts.set(mint, total);
|
|
21571
|
+
}
|
|
21572
|
+
}
|
|
21573
|
+
return amounts;
|
|
21574
|
+
}
|
|
21575
|
+
|
|
21576
|
+
// src/services/consensusOracle/sources/mpcWalletBalanceSource.ts
|
|
21577
|
+
var RpcMpcWalletBalanceSource = class {
|
|
21578
|
+
constructor(connection, bindings) {
|
|
21579
|
+
this.connection = connection;
|
|
21580
|
+
const entries = /* @__PURE__ */ new Map();
|
|
21581
|
+
const wallets = /* @__PURE__ */ new Set();
|
|
21582
|
+
for (const binding of bindings) {
|
|
21583
|
+
const { vault, manager, wallet } = binding;
|
|
21584
|
+
for (const key of [vault, manager, wallet]) new import_web332.PublicKey(key);
|
|
21585
|
+
if (entries.has(vault) || wallets.has(wallet) || wallet === manager || wallet === vault || wallet === import_web332.PublicKey.default.toBase58())
|
|
21586
|
+
throw new Error("Invalid or duplicate MPC wallet binding");
|
|
21587
|
+
entries.set(vault, { ...binding });
|
|
21588
|
+
wallets.add(wallet);
|
|
21589
|
+
}
|
|
21590
|
+
this.bindings = entries;
|
|
21591
|
+
this.tokens = new RpcManagerWalletBalanceSource(connection);
|
|
21592
|
+
}
|
|
21593
|
+
async fetchBalances(vault, manager, mints2) {
|
|
21594
|
+
const binding = this.bindings.get(vault);
|
|
21595
|
+
if (!binding) return void 0;
|
|
21596
|
+
if (binding.manager !== manager) {
|
|
21597
|
+
throw new Error(
|
|
21598
|
+
`MPC wallet binding no longer matches manager for ${vault}`
|
|
21599
|
+
);
|
|
21600
|
+
}
|
|
21601
|
+
const [tokens, deposits] = await Promise.all([
|
|
21602
|
+
this.tokens.fetchBalances(binding.wallet, mints2),
|
|
21603
|
+
readMarginfiDepositsForAuthority(
|
|
21604
|
+
this.connection,
|
|
21605
|
+
new import_web332.PublicKey(binding.wallet),
|
|
21606
|
+
mints2.map((mint) => new import_web332.PublicKey(mint))
|
|
21607
|
+
)
|
|
21608
|
+
]);
|
|
21609
|
+
return { wallet: binding.wallet, tokens, marginfi: deposits };
|
|
21610
|
+
}
|
|
21611
|
+
};
|
|
21612
|
+
|
|
21101
21613
|
// src/services/consensusOracle/positions/externalPositions.ts
|
|
21102
21614
|
var ExternalPositionRegistry = class {
|
|
21103
21615
|
constructor(providers = [], log = () => {
|
|
@@ -21133,12 +21645,12 @@ var StaticPositionProvider = class {
|
|
|
21133
21645
|
};
|
|
21134
21646
|
|
|
21135
21647
|
// src/services/consensusOracle/positions/kaminoPositionProvider.ts
|
|
21136
|
-
var
|
|
21137
|
-
var
|
|
21648
|
+
var import_kit15 = require("@solana/kit");
|
|
21649
|
+
var import_web333 = require("@solana/web3.js");
|
|
21138
21650
|
var import_klend_sdk = require("@kamino-finance/klend-sdk");
|
|
21139
21651
|
async function readKaminoBalance(manager, vault, sharesHolder) {
|
|
21140
21652
|
const userShares = await manager.getUserSharesBalanceSingleVault(
|
|
21141
|
-
(0,
|
|
21653
|
+
(0, import_kit15.address)(sharesHolder.toBase58()),
|
|
21142
21654
|
vault
|
|
21143
21655
|
);
|
|
21144
21656
|
const tokensPerShare = await manager.getTokensPerShareSingleVault(vault);
|
|
@@ -21154,7 +21666,7 @@ var KaminoPositionProvider = class {
|
|
|
21154
21666
|
async positionsFor(ctx) {
|
|
21155
21667
|
const refs = ctx.refs.filter((r) => r.kind === "kamino");
|
|
21156
21668
|
if (refs.length === 0) return [];
|
|
21157
|
-
const rpc = (0,
|
|
21669
|
+
const rpc = (0, import_kit15.createSolanaRpc)(this.rpcUrl);
|
|
21158
21670
|
const slotDuration = await (0, import_klend_sdk.getMedianSlotDurationInMsFromLastEpochs)();
|
|
21159
21671
|
const manager = new import_klend_sdk.KaminoManager(rpc, slotDuration);
|
|
21160
21672
|
const out = [];
|
|
@@ -21167,11 +21679,11 @@ var KaminoPositionProvider = class {
|
|
|
21167
21679
|
);
|
|
21168
21680
|
continue;
|
|
21169
21681
|
}
|
|
21170
|
-
const kVault = new import_klend_sdk.KaminoVault(rpc, (0,
|
|
21682
|
+
const kVault = new import_klend_sdk.KaminoVault(rpc, (0, import_kit15.address)(vaultState));
|
|
21171
21683
|
const amount = await readKaminoBalance(
|
|
21172
21684
|
manager,
|
|
21173
21685
|
kVault,
|
|
21174
|
-
new
|
|
21686
|
+
new import_web333.PublicKey(sharesHolder)
|
|
21175
21687
|
);
|
|
21176
21688
|
out.push({ mint: ref.mint, amount });
|
|
21177
21689
|
}
|
|
@@ -21180,8 +21692,8 @@ var KaminoPositionProvider = class {
|
|
|
21180
21692
|
};
|
|
21181
21693
|
|
|
21182
21694
|
// src/services/consensusOracle/positions/marginfiPositionProvider.ts
|
|
21183
|
-
var
|
|
21184
|
-
var
|
|
21695
|
+
var import_web334 = require("@solana/web3.js");
|
|
21696
|
+
var import_marginfi3 = __toESM(require_dist2());
|
|
21185
21697
|
var MarginfiPositionProvider = class {
|
|
21186
21698
|
constructor(connection, log = () => {
|
|
21187
21699
|
}) {
|
|
@@ -21191,14 +21703,14 @@ var MarginfiPositionProvider = class {
|
|
|
21191
21703
|
async positionsFor(ctx) {
|
|
21192
21704
|
const refs = ctx.refs.filter((r) => r.kind === "marginfi");
|
|
21193
21705
|
if (refs.length === 0) return [];
|
|
21194
|
-
const explicitBanks = refs.map((r) => r.marginfiBank).filter(Boolean).map((bank) => new
|
|
21195
|
-
const autoAccountPks = refs.filter((r) => !r.marginfiBank).map((r) => r.marginfiAccount).filter(Boolean).map((account) => new
|
|
21706
|
+
const explicitBanks = refs.map((r) => r.marginfiBank).filter(Boolean).map((bank) => new import_web334.PublicKey(bank));
|
|
21707
|
+
const autoAccountPks = refs.filter((r) => !r.marginfiBank).map((r) => r.marginfiAccount).filter(Boolean).map((account) => new import_web334.PublicKey(account));
|
|
21196
21708
|
const autoBanks = [];
|
|
21197
21709
|
for (const accountPk of autoAccountPks) {
|
|
21198
21710
|
try {
|
|
21199
21711
|
const info = await this.connection.getAccountInfo(accountPk);
|
|
21200
21712
|
if (info) {
|
|
21201
|
-
autoBanks.push(...(0,
|
|
21713
|
+
autoBanks.push(...(0, import_marginfi3.parseBankPksFromMarginfiAccount)(info.data));
|
|
21202
21714
|
}
|
|
21203
21715
|
} catch (err) {
|
|
21204
21716
|
this.log(
|
|
@@ -21206,7 +21718,7 @@ var MarginfiPositionProvider = class {
|
|
|
21206
21718
|
);
|
|
21207
21719
|
}
|
|
21208
21720
|
}
|
|
21209
|
-
const client = await (0,
|
|
21721
|
+
const client = await (0, import_marginfi3.createMarginfiReadClient)(this.connection, [
|
|
21210
21722
|
...explicitBanks,
|
|
21211
21723
|
...autoBanks
|
|
21212
21724
|
]);
|
|
@@ -21219,16 +21731,16 @@ var MarginfiPositionProvider = class {
|
|
|
21219
21731
|
}
|
|
21220
21732
|
const bank = ref.marginfiBank;
|
|
21221
21733
|
if (bank) {
|
|
21222
|
-
const amount = await (0,
|
|
21734
|
+
const amount = await (0, import_marginfi3.readMarginfiBankBalance)(
|
|
21223
21735
|
client,
|
|
21224
|
-
new
|
|
21225
|
-
new
|
|
21736
|
+
new import_web334.PublicKey(account),
|
|
21737
|
+
new import_web334.PublicKey(bank)
|
|
21226
21738
|
);
|
|
21227
21739
|
out.push({ mint: ref.mint, amount });
|
|
21228
21740
|
} else {
|
|
21229
|
-
const balances = await (0,
|
|
21741
|
+
const balances = await (0, import_marginfi3.readAllMarginfiBalances)(
|
|
21230
21742
|
client,
|
|
21231
|
-
new
|
|
21743
|
+
new import_web334.PublicKey(account)
|
|
21232
21744
|
);
|
|
21233
21745
|
for (const { mint, amount } of balances) {
|
|
21234
21746
|
out.push({ mint: mint.toBase58(), amount });
|
|
@@ -21428,6 +21940,16 @@ var MockYieldTracker = class {
|
|
|
21428
21940
|
}
|
|
21429
21941
|
};
|
|
21430
21942
|
|
|
21943
|
+
// src/services/consensusOracle/runtime/mpcWallets.ts
|
|
21944
|
+
var import_kit16 = require("@solana/kit");
|
|
21945
|
+
var MPC_WALLETS = [
|
|
21946
|
+
{
|
|
21947
|
+
vault: (0, import_kit16.address)("ECJGrTZ6QYMEwiEAnL4oReWF126uc22e9Lojy9qyCjHT"),
|
|
21948
|
+
manager: (0, import_kit16.address)("4jMRBkpWrfhhwFYTwG3o7hmsXQwbJUwdyUX8htB6KwLJ"),
|
|
21949
|
+
wallet: (0, import_kit16.address)("4EXphBhAWcm8NHEENzURiJBPtMPsg2PoXWf95E6sRyfB")
|
|
21950
|
+
}
|
|
21951
|
+
];
|
|
21952
|
+
|
|
21431
21953
|
// src/services/consensusOracle/runtime/liveConsensusOracleDeps.ts
|
|
21432
21954
|
var YIELD_TRACKER_DECIMALS = 6;
|
|
21433
21955
|
function createLiveConsensusOracleDeps(connection, opts = {}) {
|
|
@@ -21436,6 +21958,7 @@ function createLiveConsensusOracleDeps(connection, opts = {}) {
|
|
|
21436
21958
|
const deps = {
|
|
21437
21959
|
priceSource: new LivePriceSource(),
|
|
21438
21960
|
managerWalletBalances: new RpcManagerWalletBalanceSource(connection),
|
|
21961
|
+
mpcWalletBalances: new RpcMpcWalletBalanceSource(connection, MPC_WALLETS),
|
|
21439
21962
|
yieldTracker: {
|
|
21440
21963
|
async getAccountNamesForVault(vault) {
|
|
21441
21964
|
const accounts2 = await getAccounts();
|
|
@@ -21446,7 +21969,19 @@ function createLiveConsensusOracleDeps(connection, opts = {}) {
|
|
|
21446
21969
|
return raw / 10 ** YIELD_TRACKER_DECIMALS;
|
|
21447
21970
|
},
|
|
21448
21971
|
async getTotalTrackedValue(accountNames, start, end) {
|
|
21449
|
-
const tracked = await getTotalTrackedValue(
|
|
21972
|
+
const tracked = await getTotalTrackedValue(
|
|
21973
|
+
accountNames,
|
|
21974
|
+
start,
|
|
21975
|
+
end,
|
|
21976
|
+
(accountName, value) => {
|
|
21977
|
+
const amount = (raw) => `${(raw / 10 ** YIELD_TRACKER_DECIMALS).toFixed(
|
|
21978
|
+
YIELD_TRACKER_DECIMALS
|
|
21979
|
+
)} USDC [raw=${raw}]`;
|
|
21980
|
+
log(
|
|
21981
|
+
` yield tracker account ${JSON.stringify(accountName)} (${value.valuationModel}): value=${amount(value.totalValue)}` + (value.valuationModel === "apr" ? ` principal=${amount(value.principal)} outstandingYield=${amount(value.outstandingYield)}` : "")
|
|
21982
|
+
);
|
|
21983
|
+
}
|
|
21984
|
+
);
|
|
21450
21985
|
return {
|
|
21451
21986
|
totalValue: tracked.totalValue / 10 ** YIELD_TRACKER_DECIMALS,
|
|
21452
21987
|
principal: tracked.principal / 10 ** YIELD_TRACKER_DECIMALS,
|
|
@@ -21469,7 +22004,7 @@ function createLiveConsensusOracleDeps(connection, opts = {}) {
|
|
|
21469
22004
|
}
|
|
21470
22005
|
|
|
21471
22006
|
// src/services/consensusOracle/consensusOracleService.ts
|
|
21472
|
-
var
|
|
22007
|
+
var import_common57 = __toESM(require_dist());
|
|
21473
22008
|
var ConsensusOracleService = class {
|
|
21474
22009
|
constructor(client, deps) {
|
|
21475
22010
|
this.client = client;
|
|
@@ -21505,7 +22040,7 @@ var ConsensusOracleService = class {
|
|
|
21505
22040
|
receiptMints
|
|
21506
22041
|
);
|
|
21507
22042
|
const filteredCount = vaultState.holdings.filter(
|
|
21508
|
-
(holding) => receiptMints.has((0,
|
|
22043
|
+
(holding) => receiptMints.has((0, import_common57.fromWeb3Pk)(holding.mint).toString())
|
|
21509
22044
|
).length;
|
|
21510
22045
|
if (filteredCount > 0) {
|
|
21511
22046
|
log(
|
|
@@ -21545,6 +22080,7 @@ var ConsensusOracleService = class {
|
|
|
21545
22080
|
vaultState,
|
|
21546
22081
|
updates: sourcedUpdates,
|
|
21547
22082
|
source: this.deps.managerWalletBalances,
|
|
22083
|
+
mpcSource: this.deps.mpcWalletBalances,
|
|
21548
22084
|
log
|
|
21549
22085
|
});
|
|
21550
22086
|
const updates = reconciliation.updates;
|
|
@@ -21616,13 +22152,14 @@ var ConsensusOracleService = class {
|
|
|
21616
22152
|
vault: target.vault,
|
|
21617
22153
|
vaultState: freshState,
|
|
21618
22154
|
updates: sourcedUpdates,
|
|
21619
|
-
source: this.deps.managerWalletBalances
|
|
22155
|
+
source: this.deps.managerWalletBalances,
|
|
22156
|
+
mpcSource: this.deps.mpcWalletBalances
|
|
21620
22157
|
});
|
|
21621
22158
|
if (!fresh.accepted || fresh.updates.some(
|
|
21622
|
-
(update, index) => update.externalAmount !== updates[index].externalAmount
|
|
22159
|
+
(update, index) => update.externalAmount !== updates[index].externalAmount || update.managerWalletAmount !== updates[index].managerWalletAmount || update.mpcWalletAmount !== updates[index].mpcWalletAmount || update.mpcMarginfiAmount !== updates[index].mpcMarginfiAmount
|
|
21623
22160
|
)) {
|
|
21624
22161
|
throw new Error(
|
|
21625
|
-
"Manager wallet changed during reconciliation; retry with fresh inputs"
|
|
22162
|
+
"Manager wallet changed or MPC balances changed during reconciliation; retry with fresh inputs"
|
|
21626
22163
|
);
|
|
21627
22164
|
}
|
|
21628
22165
|
} : void 0
|
|
@@ -21724,12 +22261,13 @@ async function runLiveConsensusOracle(env, oracleSigner, opts = {}) {
|
|
|
21724
22261
|
}
|
|
21725
22262
|
|
|
21726
22263
|
// src/services/externalLiquidityIntegrityService.ts
|
|
21727
|
-
var
|
|
21728
|
-
var
|
|
21729
|
-
var
|
|
21730
|
-
var
|
|
22264
|
+
var import_kit17 = require("@solana/kit");
|
|
22265
|
+
var import_web335 = require("@solana/web3.js");
|
|
22266
|
+
var import_common58 = __toESM(require_dist());
|
|
22267
|
+
var import_marginfi4 = __toESM(require_dist2());
|
|
21731
22268
|
var DEFAULT_MIN_AMOUNT_UI = 1;
|
|
21732
22269
|
var DEFAULT_TARGET_LOCAL_BPS = 50;
|
|
22270
|
+
var DEFAULT_TARGET_LOCAL_USDC_TVL_BPS = 150;
|
|
21733
22271
|
var DEFAULT_REBALANCE_BAND_BPS = 2e3;
|
|
21734
22272
|
var BPS_DENOMINATOR4 = 10000n;
|
|
21735
22273
|
function toRawAmount(uiAmount, decimals) {
|
|
@@ -21748,7 +22286,7 @@ function parseActiveSlots(externalLiquidity) {
|
|
|
21748
22286
|
if (discriminant === 0) continue;
|
|
21749
22287
|
if (discriminant !== 1) continue;
|
|
21750
22288
|
const pubkeyBytes = new Uint8Array(data.slice(8, 40));
|
|
21751
|
-
const userAccount = (0,
|
|
22289
|
+
const userAccount = (0, import_common58.toAddress)(new import_web335.PublicKey(pubkeyBytes));
|
|
21752
22290
|
results.push({ index: i, source: "marginfi", userAccount });
|
|
21753
22291
|
}
|
|
21754
22292
|
return results;
|
|
@@ -21773,11 +22311,12 @@ function planRebalance(params) {
|
|
|
21773
22311
|
localAmount,
|
|
21774
22312
|
externalAmount,
|
|
21775
22313
|
targetLocalBps,
|
|
22314
|
+
targetLocalAmount,
|
|
21776
22315
|
rebalanceBandBps,
|
|
21777
22316
|
minRaw
|
|
21778
22317
|
} = params;
|
|
21779
22318
|
const total = localAmount + externalAmount;
|
|
21780
|
-
const targetLocal = total * BigInt(Math.round(targetLocalBps)) / BPS_DENOMINATOR4;
|
|
22319
|
+
const targetLocal = targetLocalAmount ?? total * BigInt(Math.round(targetLocalBps)) / BPS_DENOMINATOR4;
|
|
21781
22320
|
const band = targetLocal * BigInt(Math.round(rebalanceBandBps)) / BPS_DENOMINATOR4;
|
|
21782
22321
|
const threshold = band > minRaw ? band : minRaw;
|
|
21783
22322
|
if (localAmount > targetLocal) {
|
|
@@ -21805,6 +22344,7 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
21805
22344
|
const dryRun = opts.dryRun ?? false;
|
|
21806
22345
|
const minAmountUi = opts.minAmountUi ?? DEFAULT_MIN_AMOUNT_UI;
|
|
21807
22346
|
const targetLocalBps = opts.targetLocalBps ?? DEFAULT_TARGET_LOCAL_BPS;
|
|
22347
|
+
const targetLocalUsdcTvlBps = opts.targetLocalUsdcTvlBps ?? DEFAULT_TARGET_LOCAL_USDC_TVL_BPS;
|
|
21808
22348
|
const rebalanceBandBps = opts.rebalanceBandBps ?? DEFAULT_REBALANCE_BAND_BPS;
|
|
21809
22349
|
if (dryRun) {
|
|
21810
22350
|
log(
|
|
@@ -21812,7 +22352,12 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
21812
22352
|
);
|
|
21813
22353
|
}
|
|
21814
22354
|
log(`Minimum rebalance: ${minAmountUi} token(s) (~$${minAmountUi})`);
|
|
21815
|
-
log(
|
|
22355
|
+
log(
|
|
22356
|
+
`Target local USDC: ${targetLocalUsdcTvlBps / 100}% of total vault TVL`
|
|
22357
|
+
);
|
|
22358
|
+
log(
|
|
22359
|
+
`Target local share: ${targetLocalBps / 100}% of each non-USDC holding`
|
|
22360
|
+
);
|
|
21816
22361
|
log(
|
|
21817
22362
|
`Rebalance band: ${rebalanceBandBps / 100}% of target (${targetLocalBps * (1 - rebalanceBandBps / 1e4) / 100}%\u2013${targetLocalBps * (1 + rebalanceBandBps / 1e4) / 100}% of holding)`
|
|
21818
22363
|
);
|
|
@@ -21832,7 +22377,13 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
21832
22377
|
vaultState,
|
|
21833
22378
|
hwManager,
|
|
21834
22379
|
log,
|
|
21835
|
-
{
|
|
22380
|
+
{
|
|
22381
|
+
dryRun,
|
|
22382
|
+
minAmountUi,
|
|
22383
|
+
targetLocalBps,
|
|
22384
|
+
targetLocalUsdcTvlBps,
|
|
22385
|
+
rebalanceBandBps
|
|
22386
|
+
}
|
|
21836
22387
|
);
|
|
21837
22388
|
summary.vaultsProcessed++;
|
|
21838
22389
|
summary.totalDeposited += result.deposited;
|
|
@@ -21850,6 +22401,7 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
21850
22401
|
const dryRun = opts.dryRun ?? false;
|
|
21851
22402
|
const minAmountUi = opts.minAmountUi ?? DEFAULT_MIN_AMOUNT_UI;
|
|
21852
22403
|
const targetLocalBps = opts.targetLocalBps ?? DEFAULT_TARGET_LOCAL_BPS;
|
|
22404
|
+
const targetLocalUsdcTvlBps = opts.targetLocalUsdcTvlBps ?? DEFAULT_TARGET_LOCAL_USDC_TVL_BPS;
|
|
21853
22405
|
const rebalanceBandBps = opts.rebalanceBandBps ?? DEFAULT_REBALANCE_BAND_BPS;
|
|
21854
22406
|
const result = {
|
|
21855
22407
|
vault,
|
|
@@ -21864,8 +22416,8 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
21864
22416
|
result.skipped++;
|
|
21865
22417
|
return result;
|
|
21866
22418
|
}
|
|
21867
|
-
const hwManagerAddress = (0,
|
|
21868
|
-
const vaultPk = new
|
|
22419
|
+
const hwManagerAddress = (0, import_common58.fromWeb3Pk)(hwManager.publicKey);
|
|
22420
|
+
const vaultPk = new import_web335.PublicKey(vault.toString());
|
|
21869
22421
|
const registeredHwManager = pubkeyStr(
|
|
21870
22422
|
vaultState.roles.hwManager
|
|
21871
22423
|
);
|
|
@@ -21893,15 +22445,32 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
21893
22445
|
continue;
|
|
21894
22446
|
}
|
|
21895
22447
|
for (const holding of holdings) {
|
|
21896
|
-
const mintAddress = (0,
|
|
22448
|
+
const mintAddress = (0, import_kit17.address)(pubkeyStr(holding.mint));
|
|
21897
22449
|
const localAmount = toBigInt3(holding.localAmount);
|
|
21898
22450
|
const externalAmount = toBigInt3(holding.externalAmount);
|
|
21899
22451
|
const decimals = Number(holding.decimals ?? 0);
|
|
21900
22452
|
const minRaw = toRawAmount(minAmountUi, decimals);
|
|
22453
|
+
let targetLocalAmount;
|
|
22454
|
+
if (mintAddress === import_common58.USDC_MINT) {
|
|
22455
|
+
const tvl = toBigInt3(vaultState.accounting.tvl);
|
|
22456
|
+
const price = toBigInt3(holding.price);
|
|
22457
|
+
const stalenessThreshold = Number(toBigInt3(vaultState.config.priceStalenessThresholdSecs)) || DEFAULT_PRICE_STALENESS_THRESHOLD_SECS;
|
|
22458
|
+
if (tvl <= 0n || price <= 0n || Math.floor(Date.now() / 1e3) - Number(toBigInt3(holding.lastUpdateTs)) > stalenessThreshold) {
|
|
22459
|
+
log(
|
|
22460
|
+
`Vault ${vault}: cannot size local USDC target without TVL and a fresh USDC price \u2014 skipping`
|
|
22461
|
+
);
|
|
22462
|
+
result.skipped++;
|
|
22463
|
+
continue;
|
|
22464
|
+
}
|
|
22465
|
+
const numerator = tvl * BigInt(Math.round(targetLocalUsdcTvlBps)) * 10n ** BigInt(decimals);
|
|
22466
|
+
const denominator = BPS_DENOMINATOR4 * price;
|
|
22467
|
+
targetLocalAmount = (numerator + denominator - 1n) / denominator;
|
|
22468
|
+
}
|
|
21901
22469
|
const plan = planRebalance({
|
|
21902
22470
|
localAmount,
|
|
21903
22471
|
externalAmount,
|
|
21904
22472
|
targetLocalBps,
|
|
22473
|
+
targetLocalAmount,
|
|
21905
22474
|
rebalanceBandBps,
|
|
21906
22475
|
minRaw
|
|
21907
22476
|
});
|
|
@@ -21915,7 +22484,7 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
21915
22484
|
result.skipped++;
|
|
21916
22485
|
continue;
|
|
21917
22486
|
}
|
|
21918
|
-
const marginfiAccounts = (0,
|
|
22487
|
+
const marginfiAccounts = (0, import_marginfi4.marginfiAccountsForMint)(mintAddress);
|
|
21919
22488
|
if (!marginfiAccounts) {
|
|
21920
22489
|
log(
|
|
21921
22490
|
`Vault ${vault} slot ${slot.index}: mint ${mintAddress} has no Marginfi bank configured \u2014 skipping`
|
|
@@ -21982,17 +22551,17 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
21982
22551
|
log = () => {
|
|
21983
22552
|
}
|
|
21984
22553
|
} = params;
|
|
21985
|
-
const marginfiClient = new
|
|
22554
|
+
const marginfiClient = new import_marginfi4.CpiClient({
|
|
21986
22555
|
accounts: marginfiAccounts
|
|
21987
22556
|
});
|
|
21988
|
-
const { getAtaAddress:
|
|
21989
|
-
const vaultAta =
|
|
22557
|
+
const { getAtaAddress: getAtaAddress21 } = await Promise.resolve().then(() => __toESM(require_dist()));
|
|
22558
|
+
const vaultAta = getAtaAddress21(
|
|
21990
22559
|
mintAddress,
|
|
21991
22560
|
vault,
|
|
21992
22561
|
marginfiAccounts.tokenProgram,
|
|
21993
22562
|
true
|
|
21994
22563
|
);
|
|
21995
|
-
const cpiRefs = (0,
|
|
22564
|
+
const cpiRefs = (0, import_common58.createCpiRefs)([
|
|
21996
22565
|
direction === "deposit" ? marginfiClient.deposit_cpi({
|
|
21997
22566
|
marginfiAccount: slot.userAccount,
|
|
21998
22567
|
authority: vault,
|
|
@@ -22043,15 +22612,16 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
22043
22612
|
};
|
|
22044
22613
|
|
|
22045
22614
|
// src/services/idleLiquidityService.ts
|
|
22046
|
-
var
|
|
22047
|
-
var
|
|
22048
|
-
var
|
|
22049
|
-
var
|
|
22050
|
-
var
|
|
22615
|
+
var import_kit18 = require("@solana/kit");
|
|
22616
|
+
var import_spl_token22 = require("@solana/spl-token");
|
|
22617
|
+
var import_marginfi_client_v22 = require("@mrgnlabs/marginfi-client-v2");
|
|
22618
|
+
var import_web336 = require("@solana/web3.js");
|
|
22619
|
+
var import_common59 = __toESM(require_dist());
|
|
22051
22620
|
var import_jupiter2 = __toESM(require_dist4());
|
|
22052
|
-
var
|
|
22621
|
+
var import_marginfi5 = __toESM(require_dist2());
|
|
22053
22622
|
var IDLE_RESERVE_FLOOR_BPS = 400;
|
|
22054
22623
|
var IDLE_RESERVE_TARGET_BPS = 500;
|
|
22624
|
+
var WITHDRAWABLE_RESERVE_FLOOR_BPS = 150;
|
|
22055
22625
|
var DEFAULT_SLIPPAGE_BPS = 30;
|
|
22056
22626
|
var DEFAULT_CU_PRICE_MICRO_LAMPORTS = 1e4;
|
|
22057
22627
|
var DEFAULT_MAX_ACCOUNTS = 20;
|
|
@@ -22141,13 +22711,13 @@ var IdleLiquidityService = class {
|
|
|
22141
22711
|
return { ...base, status: "insufficient-pst", reason };
|
|
22142
22712
|
}
|
|
22143
22713
|
const jupiter = new import_jupiter2.JupiterSwapClient(
|
|
22144
|
-
(0,
|
|
22714
|
+
(0, import_kit18.createSolanaRpc)(this.client.provider.connection.rpcEndpoint)
|
|
22145
22715
|
);
|
|
22146
22716
|
let quote;
|
|
22147
22717
|
try {
|
|
22148
22718
|
quote = await jupiter.getQuote({
|
|
22149
|
-
inputMint:
|
|
22150
|
-
outputMint:
|
|
22719
|
+
inputMint: import_common59.PST_MINT,
|
|
22720
|
+
outputMint: import_common59.USDC_MINT,
|
|
22151
22721
|
amount: pstInput,
|
|
22152
22722
|
slippageBps: opts.slippageBps ?? DEFAULT_SLIPPAGE_BPS,
|
|
22153
22723
|
maxAccounts: DEFAULT_MAX_ACCOUNTS
|
|
@@ -22193,45 +22763,53 @@ var IdleLiquidityService = class {
|
|
|
22193
22763
|
/** Read only the two locations that constitute the idle USDC reserve. */
|
|
22194
22764
|
async fetchIdleUsdc(vault, vaultState) {
|
|
22195
22765
|
const connection = this.client.provider.connection;
|
|
22196
|
-
const vaultPk = new
|
|
22197
|
-
const usdcMint = new
|
|
22198
|
-
const ata = (0,
|
|
22766
|
+
const vaultPk = new import_web336.PublicKey(vault);
|
|
22767
|
+
const usdcMint = new import_web336.PublicKey(import_common59.USDC_MINT);
|
|
22768
|
+
const ata = (0, import_spl_token22.getAssociatedTokenAddressSync)(usdcMint, vaultPk, true);
|
|
22199
22769
|
const tokenInfo = await connection.getAccountInfo(ata, "confirmed");
|
|
22200
22770
|
let localAmount = 0n;
|
|
22201
22771
|
if (tokenInfo) {
|
|
22202
|
-
const tokenAccount = (0,
|
|
22772
|
+
const tokenAccount = (0, import_spl_token22.unpackAccount)(ata, tokenInfo, import_spl_token22.TOKEN_PROGRAM_ID);
|
|
22203
22773
|
if (!tokenAccount.mint.equals(usdcMint) || !tokenAccount.owner.equals(vaultPk) || !tokenAccount.isInitialized) {
|
|
22204
22774
|
throw new Error(`Invalid vault USDC token account: ${ata.toBase58()}`);
|
|
22205
22775
|
}
|
|
22206
22776
|
localAmount = tokenAccount.amount;
|
|
22207
22777
|
}
|
|
22208
|
-
const
|
|
22209
|
-
|
|
22210
|
-
|
|
22778
|
+
const slotIndex = vaultState.externalLiquidity.findIndex(
|
|
22779
|
+
(slot) => slot.data[0] === 1
|
|
22780
|
+
);
|
|
22781
|
+
if (slotIndex === -1) {
|
|
22782
|
+
return {
|
|
22783
|
+
localAmount,
|
|
22784
|
+
marginfiAmount: 0n,
|
|
22785
|
+
withdrawableMarginfiAmount: 0n,
|
|
22786
|
+
slotIndex
|
|
22787
|
+
};
|
|
22211
22788
|
}
|
|
22212
|
-
|
|
22213
|
-
if (data
|
|
22214
|
-
throw new Error(
|
|
22789
|
+
const data = vaultState.externalLiquidity[slotIndex].data;
|
|
22790
|
+
if (data.length < 40) {
|
|
22791
|
+
throw new Error(`Invalid Project0 external-liquidity slot ${slotIndex}`);
|
|
22215
22792
|
}
|
|
22216
|
-
const positionPk = new
|
|
22793
|
+
const positionPk = new import_web336.PublicKey(new Uint8Array(data.slice(8, 40)));
|
|
22217
22794
|
const positionInfo = await connection.getAccountInfo(
|
|
22218
22795
|
positionPk,
|
|
22219
22796
|
"confirmed"
|
|
22220
22797
|
);
|
|
22221
|
-
if (!positionInfo || !positionInfo.owner.equals(new
|
|
22798
|
+
if (!positionInfo || !positionInfo.owner.equals(new import_web336.PublicKey(import_marginfi5.MARGINFI_PROGRAM_ID))) {
|
|
22222
22799
|
throw new Error(
|
|
22223
|
-
`Invalid
|
|
22800
|
+
`Invalid Project0 slot-${slotIndex} account: ${positionPk.toBase58()}`
|
|
22224
22801
|
);
|
|
22225
22802
|
}
|
|
22226
|
-
const marginfi = await (0,
|
|
22803
|
+
const marginfi = await (0, import_marginfi5.createMarginfiReadClient)(
|
|
22227
22804
|
connection,
|
|
22228
|
-
(0,
|
|
22805
|
+
(0, import_marginfi5.parseBankPksFromMarginfiAccount)(positionInfo.data)
|
|
22229
22806
|
);
|
|
22230
|
-
const position = await
|
|
22807
|
+
const position = await import_marginfi_client_v22.MarginfiAccountWrapper.fetch(positionPk, marginfi);
|
|
22231
22808
|
if (!position.authority.equals(vaultPk)) {
|
|
22232
|
-
throw new Error(
|
|
22809
|
+
throw new Error(`Project0 slot-${slotIndex} authority is not the vault`);
|
|
22233
22810
|
}
|
|
22234
22811
|
let marginfiAmount = 0n;
|
|
22812
|
+
let withdrawableMarginfiAmount = 0n;
|
|
22235
22813
|
for (const balance of position.activeBalances) {
|
|
22236
22814
|
const bank = marginfi.getBankByPk(balance.bankPk);
|
|
22237
22815
|
if (!bank) {
|
|
@@ -22240,11 +22818,22 @@ var IdleLiquidityService = class {
|
|
|
22240
22818
|
);
|
|
22241
22819
|
}
|
|
22242
22820
|
if (!bank.mint.equals(usdcMint)) continue;
|
|
22243
|
-
|
|
22821
|
+
const deposited = BigInt(
|
|
22244
22822
|
balance.computeQuantity(bank).assets.toFixed(0, 1)
|
|
22245
22823
|
);
|
|
22824
|
+
const available = BigInt(
|
|
22825
|
+
bank.getTotalAssetQuantity().minus(bank.getTotalLiabilityQuantity()).toFixed(0, 1)
|
|
22826
|
+
);
|
|
22827
|
+
const bankLiquidity = available > 0n ? available : 0n;
|
|
22828
|
+
marginfiAmount += deposited;
|
|
22829
|
+
withdrawableMarginfiAmount += deposited < bankLiquidity ? deposited : bankLiquidity;
|
|
22246
22830
|
}
|
|
22247
|
-
return {
|
|
22831
|
+
return {
|
|
22832
|
+
localAmount,
|
|
22833
|
+
marginfiAmount,
|
|
22834
|
+
withdrawableMarginfiAmount,
|
|
22835
|
+
slotIndex
|
|
22836
|
+
};
|
|
22248
22837
|
}
|
|
22249
22838
|
/**
|
|
22250
22839
|
* Decide whether a top-up is warranted. Returns either a terminal `result`
|
|
@@ -22259,6 +22848,8 @@ var IdleLiquidityService = class {
|
|
|
22259
22848
|
tvl,
|
|
22260
22849
|
idleValue: 0n,
|
|
22261
22850
|
idleBps: 0,
|
|
22851
|
+
withdrawableValue: 0n,
|
|
22852
|
+
withdrawableBps: 0,
|
|
22262
22853
|
shortfallUsdc: 0n,
|
|
22263
22854
|
pstSpent: 0n,
|
|
22264
22855
|
usdcReceived: 0n
|
|
@@ -22268,8 +22859,8 @@ var IdleLiquidityService = class {
|
|
|
22268
22859
|
log(`Vault ${vault}: ${reason} \u2014 skipping`);
|
|
22269
22860
|
return { result: { ...empty, status: "no-tvl", reason } };
|
|
22270
22861
|
}
|
|
22271
|
-
const usdc = findHolding2(vaultState,
|
|
22272
|
-
const pst = findHolding2(vaultState,
|
|
22862
|
+
const usdc = findHolding2(vaultState, import_common59.USDC_MINT);
|
|
22863
|
+
const pst = findHolding2(vaultState, import_common59.PST_MINT);
|
|
22273
22864
|
if (!usdc || !pst) {
|
|
22274
22865
|
const reason = `vault has no ${usdc ? "PST" : "USDC"} holding`;
|
|
22275
22866
|
log(`Vault ${vault}: ${reason} \u2014 skipping`);
|
|
@@ -22303,7 +22894,16 @@ var IdleLiquidityService = class {
|
|
|
22303
22894
|
const idleAmount = balances.localAmount + balances.marginfiAmount;
|
|
22304
22895
|
const idleValue = holdingValue2(usdc, idleAmount);
|
|
22305
22896
|
const idleBps = Number(idleValue * 10000n / tvl);
|
|
22306
|
-
const
|
|
22897
|
+
const withdrawableAmount = balances.localAmount + balances.withdrawableMarginfiAmount;
|
|
22898
|
+
const withdrawableValue = holdingValue2(usdc, withdrawableAmount);
|
|
22899
|
+
const withdrawableBps = Number(withdrawableValue * 10000n / tvl);
|
|
22900
|
+
const base = {
|
|
22901
|
+
...empty,
|
|
22902
|
+
idleValue,
|
|
22903
|
+
idleBps,
|
|
22904
|
+
withdrawableValue,
|
|
22905
|
+
withdrawableBps
|
|
22906
|
+
};
|
|
22307
22907
|
log(
|
|
22308
22908
|
`Vault ${vault}: idle USDC ${formatUi2(
|
|
22309
22909
|
idleAmount,
|
|
@@ -22311,13 +22911,21 @@ var IdleLiquidityService = class {
|
|
|
22311
22911
|
)} (vault token account ${formatUi2(
|
|
22312
22912
|
balances.localAmount,
|
|
22313
22913
|
usdc.decimals
|
|
22314
|
-
)} +
|
|
22914
|
+
)} + Project0 slot ${balances.slotIndex} ${formatUi2(
|
|
22315
22915
|
balances.marginfiAmount,
|
|
22316
22916
|
usdc.decimals
|
|
22317
22917
|
)}) = ${idleBps}bps of TVL (floor ${IDLE_RESERVE_FLOOR_BPS}bps, target ${IDLE_RESERVE_TARGET_BPS}bps)`
|
|
22318
22918
|
);
|
|
22319
|
-
|
|
22320
|
-
|
|
22919
|
+
log(
|
|
22920
|
+
`Vault ${vault}: withdrawable USDC ${formatUi2(
|
|
22921
|
+
withdrawableAmount,
|
|
22922
|
+
usdc.decimals
|
|
22923
|
+
)} = ${withdrawableBps}bps of TVL (floor ${WITHDRAWABLE_RESERVE_FLOOR_BPS}bps)`
|
|
22924
|
+
);
|
|
22925
|
+
const idleBelowFloor = idleBps < IDLE_RESERVE_FLOOR_BPS;
|
|
22926
|
+
const withdrawableBelowFloor = withdrawableBps < WITHDRAWABLE_RESERVE_FLOOR_BPS;
|
|
22927
|
+
if (!idleBelowFloor && !withdrawableBelowFloor) {
|
|
22928
|
+
const reason = `idle USDC ${idleBps}bps and withdrawable USDC ${withdrawableBps}bps are at or above their floors`;
|
|
22321
22929
|
return { result: { ...base, status: "above-floor", reason } };
|
|
22322
22930
|
}
|
|
22323
22931
|
for (const [name, holding] of [
|
|
@@ -22330,8 +22938,11 @@ var IdleLiquidityService = class {
|
|
|
22330
22938
|
return { result: { ...base, status: "rebalance-cooldown", reason } };
|
|
22331
22939
|
}
|
|
22332
22940
|
}
|
|
22333
|
-
const targetValue = tvl * BigInt(IDLE_RESERVE_TARGET_BPS) / 10000n;
|
|
22334
|
-
|
|
22941
|
+
const targetValue = (tvl * BigInt(IDLE_RESERVE_TARGET_BPS) + 9999n) / 10000n;
|
|
22942
|
+
const withdrawableTargetValue = (tvl * BigInt(WITHDRAWABLE_RESERVE_FLOOR_BPS) + 9999n) / 10000n;
|
|
22943
|
+
const idleShortfall = idleBelowFloor ? targetValue - idleValue : 0n;
|
|
22944
|
+
const withdrawableShortfall = withdrawableBelowFloor ? withdrawableTargetValue - withdrawableValue : 0n;
|
|
22945
|
+
let shortfallValue = idleShortfall > withdrawableShortfall ? idleShortfall : withdrawableShortfall;
|
|
22335
22946
|
const allowance = this.remainingRebalanceAllowance(vaultState, tvl, now);
|
|
22336
22947
|
if (allowance !== void 0 && allowance < shortfallValue) {
|
|
22337
22948
|
if (allowance === 0n) {
|
|
@@ -22344,7 +22955,7 @@ var IdleLiquidityService = class {
|
|
|
22344
22955
|
);
|
|
22345
22956
|
shortfallValue = allowance;
|
|
22346
22957
|
}
|
|
22347
|
-
const shortfallUsdc = shortfallValue * 10n ** BigInt(usdc.decimals) / usdc.price;
|
|
22958
|
+
const shortfallUsdc = (shortfallValue * 10n ** BigInt(usdc.decimals) + usdc.price - 1n) / usdc.price;
|
|
22348
22959
|
if (shortfallUsdc <= 0n) {
|
|
22349
22960
|
const reason = "computed shortfall rounds to zero";
|
|
22350
22961
|
return { result: { ...base, status: "above-floor", reason } };
|
|
@@ -22397,16 +23008,16 @@ var IdleLiquidityService = class {
|
|
|
22397
23008
|
*/
|
|
22398
23009
|
async mintTokenProgram(mint) {
|
|
22399
23010
|
const account = await this.client.provider.connection.getAccountInfo(
|
|
22400
|
-
new
|
|
23011
|
+
new import_web336.PublicKey(mint),
|
|
22401
23012
|
"confirmed"
|
|
22402
23013
|
);
|
|
22403
23014
|
if (!account) throw new Error(`Mint account not found: ${mint}`);
|
|
22404
|
-
if (!account.owner.equals(
|
|
23015
|
+
if (!account.owner.equals(import_spl_token22.TOKEN_PROGRAM_ID) && !account.owner.equals(import_spl_token22.TOKEN_2022_PROGRAM_ID)) {
|
|
22405
23016
|
throw new Error(
|
|
22406
23017
|
`Unsupported token program ${account.owner.toBase58()} for mint ${mint}`
|
|
22407
23018
|
);
|
|
22408
23019
|
}
|
|
22409
|
-
return (0,
|
|
23020
|
+
return (0, import_common59.fromWeb3Pk)(account.owner);
|
|
22410
23021
|
}
|
|
22411
23022
|
/**
|
|
22412
23023
|
* Build, simulate, and (unless `dryRun`) submit the `jupiter_swap`.
|
|
@@ -22426,23 +23037,23 @@ var IdleLiquidityService = class {
|
|
|
22426
23037
|
dryRun,
|
|
22427
23038
|
log
|
|
22428
23039
|
} = params;
|
|
22429
|
-
const signer = (0,
|
|
23040
|
+
const signer = (0, import_common59.fromWeb3Pk)(hwManager.publicKey);
|
|
22430
23041
|
const [sourceTokenProgram, destinationTokenProgram] = await Promise.all([
|
|
22431
|
-
this.mintTokenProgram(
|
|
22432
|
-
this.mintTokenProgram(
|
|
23042
|
+
this.mintTokenProgram(import_common59.PST_MINT),
|
|
23043
|
+
this.mintTokenProgram(import_common59.USDC_MINT)
|
|
22433
23044
|
]);
|
|
22434
23045
|
const jupiterCpi = await jupiter.getSwapCpiData(quote, vault, {
|
|
22435
23046
|
payer: signer
|
|
22436
23047
|
});
|
|
22437
|
-
const { accounts: accounts2, refs, lookupTables } = (0,
|
|
23048
|
+
const { accounts: accounts2, refs, lookupTables } = (0, import_common59.createCpiRefs)([jupiterCpi]);
|
|
22438
23049
|
const vaultTrancheState = coerceBool4(
|
|
22439
23050
|
vaultState.tranchingEnabled
|
|
22440
23051
|
) ? (await this.client.pda.deriveVaultTrancheStatePda(vault))[0] : void 0;
|
|
22441
23052
|
const plan = await this.client.tx.jupiterSwap.getTx({
|
|
22442
23053
|
hwManager: signer,
|
|
22443
23054
|
vault,
|
|
22444
|
-
sourceMint:
|
|
22445
|
-
destinationMint:
|
|
23055
|
+
sourceMint: import_common59.PST_MINT,
|
|
23056
|
+
destinationMint: import_common59.USDC_MINT,
|
|
22446
23057
|
refs,
|
|
22447
23058
|
accounts: accounts2,
|
|
22448
23059
|
sourceTokenProgram,
|
|
@@ -22452,26 +23063,26 @@ var IdleLiquidityService = class {
|
|
|
22452
23063
|
});
|
|
22453
23064
|
const connection = this.client.provider.connection;
|
|
22454
23065
|
const instructions2 = [
|
|
22455
|
-
|
|
23066
|
+
import_web336.ComputeBudgetProgram.setComputeUnitLimit({ units: COMPUTE_UNIT_LIMIT }),
|
|
22456
23067
|
...cuPriceMicroLamports > 0 ? [
|
|
22457
|
-
|
|
23068
|
+
import_web336.ComputeBudgetProgram.setComputeUnitPrice({
|
|
22458
23069
|
microLamports: cuPriceMicroLamports
|
|
22459
23070
|
})
|
|
22460
23071
|
] : [],
|
|
22461
|
-
...(jupiterCpi.preInstructions ?? []).map(
|
|
22462
|
-
...plan.instructions.map(
|
|
23072
|
+
...(jupiterCpi.preInstructions ?? []).map(import_common59.fromKitInstruction),
|
|
23073
|
+
...plan.instructions.map(import_common59.fromKitInstruction)
|
|
22463
23074
|
];
|
|
22464
23075
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
|
|
22465
|
-
const lookupTableAccounts = await (0,
|
|
23076
|
+
const lookupTableAccounts = await (0, import_common59.fetchLookupTables)(
|
|
22466
23077
|
connection,
|
|
22467
23078
|
plan.lookupTables ?? []
|
|
22468
23079
|
);
|
|
22469
|
-
const message2 = new
|
|
23080
|
+
const message2 = new import_web336.TransactionMessage({
|
|
22470
23081
|
payerKey: hwManager.publicKey,
|
|
22471
23082
|
recentBlockhash: blockhash,
|
|
22472
23083
|
instructions: instructions2
|
|
22473
23084
|
}).compileToV0Message(lookupTableAccounts);
|
|
22474
|
-
const transaction = new
|
|
23085
|
+
const transaction = new import_web336.VersionedTransaction(message2);
|
|
22475
23086
|
transaction.sign([hwManager]);
|
|
22476
23087
|
if (!this.client.skipSimulation) {
|
|
22477
23088
|
const simulation = await connection.simulateTransaction(transaction, {
|
|
@@ -22516,10 +23127,10 @@ var IdleLiquidityService = class {
|
|
|
22516
23127
|
};
|
|
22517
23128
|
|
|
22518
23129
|
// src/services/timelockSettlementService.ts
|
|
22519
|
-
var
|
|
22520
|
-
var
|
|
22521
|
-
var
|
|
22522
|
-
var ZERO_PUBKEY =
|
|
23130
|
+
var import_kit19 = require("@solana/kit");
|
|
23131
|
+
var import_web337 = require("@solana/web3.js");
|
|
23132
|
+
var import_common60 = __toESM(require_dist());
|
|
23133
|
+
var ZERO_PUBKEY = import_web337.PublicKey.default.toBase58();
|
|
22523
23134
|
var CONSENSUS_SIGNER_CAPACITY = 4;
|
|
22524
23135
|
var CONSENSUS_ENTRY_OFFSET = 40;
|
|
22525
23136
|
var CONSENSUS_ENTRY_SIZE = 272;
|
|
@@ -22559,11 +23170,11 @@ function decodePendingConsensusSigners(data) {
|
|
|
22559
23170
|
const signers = [];
|
|
22560
23171
|
for (let i = 0; i < count; i += 1) {
|
|
22561
23172
|
const start = CONSENSUS_PENDING_OFFSET + i * 32;
|
|
22562
|
-
const signer = new
|
|
23173
|
+
const signer = new import_web337.PublicKey(bytes.slice(start, start + 32)).toBase58();
|
|
22563
23174
|
if (signer === ZERO_PUBKEY) {
|
|
22564
23175
|
throw new Error(`pending consensus signer ${i} is unset`);
|
|
22565
23176
|
}
|
|
22566
|
-
signers.push((0,
|
|
23177
|
+
signers.push((0, import_kit19.address)(signer));
|
|
22567
23178
|
}
|
|
22568
23179
|
return {
|
|
22569
23180
|
signers,
|
|
@@ -22591,7 +23202,7 @@ function pendingDestinationSettlement(state, now) {
|
|
|
22591
23202
|
const effectiveTs = integer(pending.effectiveTs);
|
|
22592
23203
|
return {
|
|
22593
23204
|
slot: integer(pending.slot),
|
|
22594
|
-
destination: (0,
|
|
23205
|
+
destination: (0, import_kit19.address)(destination),
|
|
22595
23206
|
effectiveTs,
|
|
22596
23207
|
expired: now >= effectiveTs
|
|
22597
23208
|
};
|
|
@@ -22615,7 +23226,7 @@ var TimelockSettlementService = class {
|
|
|
22615
23226
|
});
|
|
22616
23227
|
const dryRun = opts.dryRun ?? false;
|
|
22617
23228
|
const now = opts.now ?? await this.chainTime();
|
|
22618
|
-
const fulfillerAddress = (0,
|
|
23229
|
+
const fulfillerAddress = (0, import_common60.fromWeb3Pk)(fulfiller.publicKey);
|
|
22619
23230
|
const allVaults = opts.vault ? [
|
|
22620
23231
|
{
|
|
22621
23232
|
publicKey: opts.vault,
|
|
@@ -22757,19 +23368,19 @@ var TimelockSettlementService = class {
|
|
|
22757
23368
|
};
|
|
22758
23369
|
|
|
22759
23370
|
// src/services/nestWithdrawalService.ts
|
|
22760
|
-
var
|
|
22761
|
-
var
|
|
22762
|
-
var
|
|
22763
|
-
var
|
|
23371
|
+
var import_kit20 = require("@solana/kit");
|
|
23372
|
+
var import_spl_token23 = require("@solana/spl-token");
|
|
23373
|
+
var import_web338 = require("@solana/web3.js");
|
|
23374
|
+
var import_common61 = __toESM(require_dist());
|
|
22764
23375
|
var import_nest3 = __toESM(require_dist3());
|
|
22765
23376
|
var import_nest4 = __toESM(require_dist3());
|
|
22766
|
-
var NestOftProgram = new
|
|
23377
|
+
var NestOftProgram = new import_web338.PublicKey(
|
|
22767
23378
|
"ChEfPd3RzLeYiRwp1K9evimmaFSd6DV1S4Mv5q5Aj1th"
|
|
22768
23379
|
);
|
|
22769
|
-
var NestOftStore = new
|
|
23380
|
+
var NestOftStore = new import_web338.PublicKey(
|
|
22770
23381
|
"k8mJj8Gyw2gFAqut21AFVUUZhxb4RVDMnb4PrSYiDhV"
|
|
22771
23382
|
);
|
|
22772
|
-
var UsdcMint = new
|
|
23383
|
+
var UsdcMint = new import_web338.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
|
|
22773
23384
|
var NestPerenaComposer = Buffer.from(
|
|
22774
23385
|
"000000000000000000000000908dcb5531691c2124c54e30bb645cf11647090d",
|
|
22775
23386
|
"hex"
|
|
@@ -22786,7 +23397,7 @@ async function buildNestWithdrawalRequest(args) {
|
|
|
22786
23397
|
return decodeNestWithdrawalRequest({ ...args, txBase64 });
|
|
22787
23398
|
}
|
|
22788
23399
|
async function decodeNestWithdrawalRequest(args) {
|
|
22789
|
-
const transaction =
|
|
23400
|
+
const transaction = import_web338.VersionedTransaction.deserialize(
|
|
22790
23401
|
Buffer.from(args.txBase64, "base64")
|
|
22791
23402
|
);
|
|
22792
23403
|
const message2 = transaction.message;
|
|
@@ -22807,19 +23418,19 @@ async function decodeNestWithdrawalRequest(args) {
|
|
|
22807
23418
|
return value;
|
|
22808
23419
|
})
|
|
22809
23420
|
);
|
|
22810
|
-
const decoded =
|
|
23421
|
+
const decoded = import_web338.TransactionMessage.decompile(message2, {
|
|
22811
23422
|
addressLookupTableAccounts: tables
|
|
22812
23423
|
});
|
|
22813
|
-
const nestMint = new
|
|
22814
|
-
const sourceAta = (0,
|
|
22815
|
-
const usdcAta = (0,
|
|
23424
|
+
const nestMint = new import_web338.PublicKey(NEST_RWA_SHARE_MINT);
|
|
23425
|
+
const sourceAta = (0, import_spl_token23.getAssociatedTokenAddressSync)(nestMint, args.owner, true);
|
|
23426
|
+
const usdcAta = (0, import_spl_token23.getAssociatedTokenAddressSync)(UsdcMint, args.owner, true);
|
|
22816
23427
|
const instructions2 = decoded.instructions.filter(
|
|
22817
|
-
(ix) => !ix.programId.equals(
|
|
23428
|
+
(ix) => !ix.programId.equals(import_web338.ComputeBudgetProgram.programId)
|
|
22818
23429
|
);
|
|
22819
23430
|
let sends = 0;
|
|
22820
23431
|
for (const ix of instructions2) {
|
|
22821
|
-
if (ix.programId.equals(
|
|
22822
|
-
if (ix.data.length !== 1 || ix.data[0] !== 1 || !ix.keys[0]?.pubkey.equals(args.owner) || !ix.keys[1]?.pubkey.equals(usdcAta) || !ix.keys[2]?.pubkey.equals(args.owner) || !ix.keys[3]?.pubkey.equals(UsdcMint) || !ix.keys[5]?.pubkey.equals(
|
|
23432
|
+
if (ix.programId.equals(import_spl_token23.ASSOCIATED_TOKEN_PROGRAM_ID)) {
|
|
23433
|
+
if (ix.data.length !== 1 || ix.data[0] !== 1 || !ix.keys[0]?.pubkey.equals(args.owner) || !ix.keys[1]?.pubkey.equals(usdcAta) || !ix.keys[2]?.pubkey.equals(args.owner) || !ix.keys[3]?.pubkey.equals(UsdcMint) || !ix.keys[5]?.pubkey.equals(import_spl_token23.TOKEN_PROGRAM_ID)) {
|
|
22823
23434
|
throw new Error("Unexpected token account creation in Nest withdrawal");
|
|
22824
23435
|
}
|
|
22825
23436
|
continue;
|
|
@@ -22836,13 +23447,137 @@ async function decodeNestWithdrawalRequest(args) {
|
|
|
22836
23447
|
if (sends !== 1)
|
|
22837
23448
|
throw new Error("Nest withdrawal must contain exactly one OFT send");
|
|
22838
23449
|
return {
|
|
22839
|
-
instructions: instructions2.map(
|
|
22840
|
-
lookupTables: tables.map((table) => (0,
|
|
23450
|
+
instructions: instructions2.map(import_common61.toKitInstruction),
|
|
23451
|
+
lookupTables: tables.map((table) => (0, import_kit20.address)(table.key.toBase58()))
|
|
23452
|
+
};
|
|
23453
|
+
}
|
|
23454
|
+
|
|
23455
|
+
// src/services/nestDepositService.ts
|
|
23456
|
+
var import_kit21 = require("@solana/kit");
|
|
23457
|
+
var import_spl_token24 = require("@solana/spl-token");
|
|
23458
|
+
var import_web339 = require("@solana/web3.js");
|
|
23459
|
+
var import_common62 = __toESM(require_dist());
|
|
23460
|
+
var import_nest5 = __toESM(require_dist3());
|
|
23461
|
+
var Usdc = new import_web339.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
|
|
23462
|
+
var Messenger = new import_web339.PublicKey("CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe");
|
|
23463
|
+
var Transmitter = new import_web339.PublicKey(
|
|
23464
|
+
"CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC"
|
|
23465
|
+
);
|
|
23466
|
+
var Router = Buffer.from(
|
|
23467
|
+
"0000000000000000000000007de01896d36bea9cf072ac64e41685418941d8be",
|
|
23468
|
+
"hex"
|
|
23469
|
+
);
|
|
23470
|
+
var Composer = Buffer.from("908dcb5531691c2124c54e30bb645cf11647090d", "hex");
|
|
23471
|
+
var BurnWithHook = Buffer.from([111, 245, 62, 131, 204, 108, 223, 155]);
|
|
23472
|
+
var PerenaAssetId = Buffer.from(
|
|
23473
|
+
"355750bed2d05a1eb92ab578335cc3ea6d572dd5f57a086088c68667f11e50d2",
|
|
23474
|
+
"hex"
|
|
23475
|
+
);
|
|
23476
|
+
var MintAndSend = Buffer.from("fe030ec4", "hex");
|
|
23477
|
+
async function buildNestDepositRequest(args) {
|
|
23478
|
+
if (args.rawAmountUsdc <= 0n || args.rawAmountUsdc > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
23479
|
+
throw new Error(
|
|
23480
|
+
"Nest deposit must be a positive, safely representable USDC base-unit amount"
|
|
23481
|
+
);
|
|
23482
|
+
}
|
|
23483
|
+
const options = args.apiOptions ?? {};
|
|
23484
|
+
const response = await (options.fetchFn ?? fetch)(
|
|
23485
|
+
`${(options.baseUrl ?? import_nest5.NEST_API_BASE_URL).replace(
|
|
23486
|
+
/\/$/,
|
|
23487
|
+
""
|
|
23488
|
+
)}/solana/nest/mint/build-tx`,
|
|
23489
|
+
{
|
|
23490
|
+
method: "POST",
|
|
23491
|
+
headers: { "Content-Type": "application/json" },
|
|
23492
|
+
signal: options.signal,
|
|
23493
|
+
body: JSON.stringify({
|
|
23494
|
+
rawAmountUsdc: Number(args.rawAmountUsdc),
|
|
23495
|
+
receiver: args.owner.toBase58(),
|
|
23496
|
+
nestVaultSlug: NEST_VAULT_SLUG,
|
|
23497
|
+
finality: "standard"
|
|
23498
|
+
})
|
|
23499
|
+
}
|
|
23500
|
+
);
|
|
23501
|
+
const payload = await response.json().catch(() => null);
|
|
23502
|
+
if (!response.ok)
|
|
23503
|
+
throw new Error(
|
|
23504
|
+
`Nest deposit API (${response.status}): ${typeof payload?.error === "string" ? payload.error : response.statusText}`
|
|
23505
|
+
);
|
|
23506
|
+
if (typeof payload?.data?.txBase64 !== "string")
|
|
23507
|
+
throw new Error("Nest API returned no deposit transaction");
|
|
23508
|
+
return decodeNestDepositRequest({ ...args, txBase64: payload.data.txBase64 });
|
|
23509
|
+
}
|
|
23510
|
+
async function decodeNestDepositRequest(args) {
|
|
23511
|
+
if (args.rawAmountUsdc <= 0n || args.rawAmountUsdc > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
23512
|
+
throw new Error(
|
|
23513
|
+
"Nest deposit must be a positive, safely representable USDC base-unit amount"
|
|
23514
|
+
);
|
|
23515
|
+
}
|
|
23516
|
+
const message2 = import_web339.VersionedTransaction.deserialize(
|
|
23517
|
+
Buffer.from(args.txBase64, "base64")
|
|
23518
|
+
).message;
|
|
23519
|
+
if (!message2.staticAccountKeys[0].equals(args.owner))
|
|
23520
|
+
throw new Error("Nest deposit payer must be the manager");
|
|
23521
|
+
const tables = await Promise.all(
|
|
23522
|
+
message2.addressTableLookups.map(async (lookup) => {
|
|
23523
|
+
const { value } = await args.connection.getAddressLookupTable(
|
|
23524
|
+
lookup.accountKey
|
|
23525
|
+
);
|
|
23526
|
+
if (!value)
|
|
23527
|
+
throw new Error(`Nest lookup table not found: ${lookup.accountKey}`);
|
|
23528
|
+
return value;
|
|
23529
|
+
})
|
|
23530
|
+
);
|
|
23531
|
+
const instructions2 = import_web339.TransactionMessage.decompile(message2, {
|
|
23532
|
+
addressLookupTableAccounts: tables
|
|
23533
|
+
}).instructions;
|
|
23534
|
+
const shareMint = new import_web339.PublicKey(NEST_RWA_SHARE_MINT);
|
|
23535
|
+
const shareAta = (0, import_spl_token24.getAssociatedTokenAddressSync)(shareMint, args.owner, true);
|
|
23536
|
+
const usdcAta = (0, import_spl_token24.getAssociatedTokenAddressSync)(Usdc, args.owner, true);
|
|
23537
|
+
let burn;
|
|
23538
|
+
for (const ix of instructions2) {
|
|
23539
|
+
if (ix.programId.equals(import_web339.ComputeBudgetProgram.programId)) continue;
|
|
23540
|
+
if (ix.programId.equals(import_spl_token24.ASSOCIATED_TOKEN_PROGRAM_ID)) {
|
|
23541
|
+
if (ix.data.length !== 1 || ix.data[0] !== 1 || !ix.keys[0]?.pubkey.equals(args.owner) || !ix.keys[1]?.pubkey.equals(shareAta) || !ix.keys[2]?.pubkey.equals(args.owner) || !ix.keys[3]?.pubkey.equals(shareMint) || !ix.keys[4]?.pubkey.equals(import_web339.SystemProgram.programId) || !ix.keys[5]?.pubkey.equals(import_spl_token24.TOKEN_PROGRAM_ID))
|
|
23542
|
+
throw new Error("Unexpected Nest deposit token account creation");
|
|
23543
|
+
continue;
|
|
23544
|
+
}
|
|
23545
|
+
const d = ix.data;
|
|
23546
|
+
const matches = (index, key) => ix.keys[index]?.pubkey.equals(key);
|
|
23547
|
+
if (burn || !ix.programId.equals(Messenger) || ix.keys.length !== 18 || d.length < 316 || !d.subarray(0, 8).equals(BurnWithHook) || d.readBigUInt64LE(8) !== args.rawAmountUsdc || d.readUInt32LE(16) !== 22 || !d.subarray(20, 52).equals(Router) || !d.subarray(52, 84).equals(Router) || d.readBigUInt64LE(84) !== 0n || d.readUInt32LE(92) !== 2e3 || d.readUInt32LE(96) !== d.length - 100 || !d.subarray(100, 120).equals(Composer) || !d.subarray(120, 124).equals(MintAndSend) || !d.subarray(124, 156).equals(PerenaAssetId) || BigInt(`0x${d.subarray(156, 188).toString("hex")}`) !== args.rawAmountUsdc || BigInt(`0x${d.subarray(188, 220).toString("hex")}`) !== 128n || !d.subarray(220, 252).equals(Buffer.concat([Buffer.alloc(12), Composer])) || BigInt(`0x${d.subarray(252, 284).toString("hex")}`) !== 30168n || !d.subarray(284, 316).equals(args.owner.toBuffer()) || !matches(0, args.owner) || !matches(3, usdcAta) || !matches(10, Usdc) || !matches(12, Transmitter) || !matches(13, Messenger) || !matches(14, import_spl_token24.TOKEN_PROGRAM_ID) || !matches(15, import_web339.SystemProgram.programId) || !matches(17, Messenger) || ![0, 1, 11].every((index) => ix.keys[index].isSigner) || ix.keys.some(
|
|
23548
|
+
(meta, index) => meta.isSigner && ![0, 1, 11].includes(index)
|
|
23549
|
+
)) {
|
|
23550
|
+
throw new Error(
|
|
23551
|
+
"Unexpected Nest deposit instruction, amount, or recipient"
|
|
23552
|
+
);
|
|
23553
|
+
}
|
|
23554
|
+
burn = ix;
|
|
23555
|
+
}
|
|
23556
|
+
if (!burn) throw new Error("Nest deposit must contain one CCTP burn");
|
|
23557
|
+
const eventKey = burn.keys[11].pubkey;
|
|
23558
|
+
if (eventKey.equals(args.owner) || burn.keys.some(
|
|
23559
|
+
(meta, index) => index !== 11 && meta.pubkey.equals(eventKey)
|
|
23560
|
+
)) {
|
|
23561
|
+
throw new Error("Nest deposit event signer must be a separate account");
|
|
23562
|
+
}
|
|
23563
|
+
burn.keys[1] = { pubkey: args.owner, isSigner: true, isWritable: true };
|
|
23564
|
+
return {
|
|
23565
|
+
instructions: [
|
|
23566
|
+
(0, import_spl_token24.createAssociatedTokenAccountIdempotentInstruction)(
|
|
23567
|
+
args.owner,
|
|
23568
|
+
shareAta,
|
|
23569
|
+
args.owner,
|
|
23570
|
+
shareMint
|
|
23571
|
+
),
|
|
23572
|
+
burn
|
|
23573
|
+
].map(import_common62.toKitInstruction),
|
|
23574
|
+
lookupTables: tables.map((table) => (0, import_kit21.address)(table.key.toBase58())),
|
|
23575
|
+
ephemeralSignerKeys: [eventKey]
|
|
22841
23576
|
};
|
|
22842
23577
|
}
|
|
22843
23578
|
|
|
22844
23579
|
// src/index.ts
|
|
22845
|
-
var
|
|
23580
|
+
var import_common63 = __toESM(require_dist());
|
|
22846
23581
|
// Annotate the CommonJS export names for ESM import in node:
|
|
22847
23582
|
0 && (module.exports = {
|
|
22848
23583
|
ASSET_DECIMALS,
|
|
@@ -22880,7 +23615,9 @@ var import_common61 = __toESM(require_dist());
|
|
|
22880
23615
|
DEFAULT_REBALANCE_BAND_BPS,
|
|
22881
23616
|
DEFAULT_SLIPPAGE_BPS,
|
|
22882
23617
|
DEFAULT_TARGET_LOCAL_BPS,
|
|
23618
|
+
DEFAULT_TARGET_LOCAL_USDC_TVL_BPS,
|
|
22883
23619
|
DEFAULT_VAULT_ID,
|
|
23620
|
+
DepositCuratorFeesBuilder,
|
|
22884
23621
|
DisableCircuitBreakerBuilder,
|
|
22885
23622
|
DistributeIncentiveBuilder,
|
|
22886
23623
|
DistributeIncentiveV3Builder,
|
|
@@ -22910,6 +23647,7 @@ var import_common61 = __toESM(require_dist());
|
|
|
22910
23647
|
MANAGER_WALLET_NAV_DROP_TRIGGER_BPS,
|
|
22911
23648
|
MANAGER_WALLET_NAV_TOLERANCE_BPS,
|
|
22912
23649
|
MAX_APY_ANCHOR_WINDOW_SECS,
|
|
23650
|
+
MAX_APY_PREVIOUS_ANCHOR_AGE_SECS,
|
|
22913
23651
|
MAX_BALANCE_CHANGE_BPS,
|
|
22914
23652
|
MAX_CONSENSUS_SIGNERS,
|
|
22915
23653
|
MAX_INCENTIVE_RECIPIENTS,
|
|
@@ -22942,6 +23680,7 @@ var import_common61 = __toESM(require_dist());
|
|
|
22942
23680
|
ReportIncentiveV3Builder,
|
|
22943
23681
|
RequestJuniorTrancheWithdrawBuilder,
|
|
22944
23682
|
RpcManagerWalletBalanceSource,
|
|
23683
|
+
RpcMpcWalletBalanceSource,
|
|
22945
23684
|
SHARE_DECIMALS,
|
|
22946
23685
|
SYSTEM_PROGRAM,
|
|
22947
23686
|
SetAssetPriceOracleBuilder,
|
|
@@ -22981,6 +23720,7 @@ var import_common61 = __toESM(require_dist());
|
|
|
22981
23720
|
VaultClient,
|
|
22982
23721
|
VaultQuoteClient,
|
|
22983
23722
|
VaultReallocationBuilder,
|
|
23723
|
+
WITHDRAWABLE_RESERVE_FLOOR_BPS,
|
|
22984
23724
|
WithdrawalQueueService,
|
|
22985
23725
|
accountingUnitPriceToUsd,
|
|
22986
23726
|
addCashflowUpdate,
|
|
@@ -22990,6 +23730,7 @@ var import_common61 = __toESM(require_dist());
|
|
|
22990
23730
|
assertNoUnconfirmedYieldPayments,
|
|
22991
23731
|
buildHoldingUpdate,
|
|
22992
23732
|
buildMarginfiWithdrawInteraction,
|
|
23733
|
+
buildNestDepositRequest,
|
|
22993
23734
|
buildNestWithdrawalRequest,
|
|
22994
23735
|
buildUpdates,
|
|
22995
23736
|
candidateGrossNav,
|
|
@@ -23004,6 +23745,7 @@ var import_common61 = __toESM(require_dist());
|
|
|
23004
23745
|
createVaultClient,
|
|
23005
23746
|
createYieldPayment,
|
|
23006
23747
|
dateToStr,
|
|
23748
|
+
decodeNestDepositRequest,
|
|
23007
23749
|
decodeNestWithdrawalRequest,
|
|
23008
23750
|
decodePendingConsensusSigners,
|
|
23009
23751
|
defaultKeypairPath,
|