@perena/vault-sdk 1.0.50 → 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/dist/index.d.ts +309 -5
- package/dist/index.js +1394 -900
- 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,
|
|
@@ -3313,6 +3313,7 @@ __export(index_exports, {
|
|
|
3313
3313
|
DEFAULT_TARGET_LOCAL_BPS: () => DEFAULT_TARGET_LOCAL_BPS,
|
|
3314
3314
|
DEFAULT_TARGET_LOCAL_USDC_TVL_BPS: () => DEFAULT_TARGET_LOCAL_USDC_TVL_BPS,
|
|
3315
3315
|
DEFAULT_VAULT_ID: () => DEFAULT_VAULT_ID,
|
|
3316
|
+
DepositCuratorFeesBuilder: () => DepositCuratorFeesBuilder,
|
|
3316
3317
|
DisableCircuitBreakerBuilder: () => DisableCircuitBreakerBuilder,
|
|
3317
3318
|
DistributeIncentiveBuilder: () => DistributeIncentiveBuilder,
|
|
3318
3319
|
DistributeIncentiveV3Builder: () => DistributeIncentiveV3Builder,
|
|
@@ -3342,6 +3343,7 @@ __export(index_exports, {
|
|
|
3342
3343
|
MANAGER_WALLET_NAV_DROP_TRIGGER_BPS: () => MANAGER_WALLET_NAV_DROP_TRIGGER_BPS,
|
|
3343
3344
|
MANAGER_WALLET_NAV_TOLERANCE_BPS: () => MANAGER_WALLET_NAV_TOLERANCE_BPS,
|
|
3344
3345
|
MAX_APY_ANCHOR_WINDOW_SECS: () => MAX_APY_ANCHOR_WINDOW_SECS,
|
|
3346
|
+
MAX_APY_PREVIOUS_ANCHOR_AGE_SECS: () => MAX_APY_PREVIOUS_ANCHOR_AGE_SECS,
|
|
3345
3347
|
MAX_BALANCE_CHANGE_BPS: () => MAX_BALANCE_CHANGE_BPS,
|
|
3346
3348
|
MAX_CONSENSUS_SIGNERS: () => MAX_CONSENSUS_SIGNERS,
|
|
3347
3349
|
MAX_INCENTIVE_RECIPIENTS: () => MAX_INCENTIVE_RECIPIENTS,
|
|
@@ -3352,7 +3354,7 @@ __export(index_exports, {
|
|
|
3352
3354
|
ManagerRedepositAssetBuilder: () => ManagerRedepositAssetBuilder,
|
|
3353
3355
|
ManagerWithdrawAssetBuilder: () => ManagerWithdrawAssetBuilder,
|
|
3354
3356
|
MarginfiPositionProvider: () => MarginfiPositionProvider,
|
|
3355
|
-
MintRegistry: () =>
|
|
3357
|
+
MintRegistry: () => import_common63.MintRegistry,
|
|
3356
3358
|
MockYieldTracker: () => MockYieldTracker,
|
|
3357
3359
|
NEST_API_BASE_URL: () => import_nest2.NEST_API_BASE_URL,
|
|
3358
3360
|
NEST_RWA_SHARE_MINT: () => NEST_RWA_SHARE_MINT,
|
|
@@ -3374,6 +3376,7 @@ __export(index_exports, {
|
|
|
3374
3376
|
ReportIncentiveV3Builder: () => ReportIncentiveV3Builder,
|
|
3375
3377
|
RequestJuniorTrancheWithdrawBuilder: () => RequestJuniorTrancheWithdrawBuilder,
|
|
3376
3378
|
RpcManagerWalletBalanceSource: () => RpcManagerWalletBalanceSource,
|
|
3379
|
+
RpcMpcWalletBalanceSource: () => RpcMpcWalletBalanceSource,
|
|
3377
3380
|
SHARE_DECIMALS: () => SHARE_DECIMALS,
|
|
3378
3381
|
SYSTEM_PROGRAM: () => SYSTEM_PROGRAM,
|
|
3379
3382
|
SetAssetPriceOracleBuilder: () => SetAssetPriceOracleBuilder,
|
|
@@ -3488,7 +3491,7 @@ __export(index_exports, {
|
|
|
3488
3491
|
makeProvider: () => makeProvider,
|
|
3489
3492
|
managerReconciliationStateKey: () => managerReconciliationStateKey,
|
|
3490
3493
|
mintTokensTo: () => mintTokensTo,
|
|
3491
|
-
mints: () =>
|
|
3494
|
+
mints: () => import_common63.mints,
|
|
3492
3495
|
mostFrequent: () => mostFrequent,
|
|
3493
3496
|
parseExternalLiquidityRefs: () => parseExternalLiquidityRefs,
|
|
3494
3497
|
planRebalance: () => planRebalance,
|
|
@@ -3590,16 +3593,16 @@ var USD_STAR_PRINCIPAL_MINT = (0, import_kit.address)(
|
|
|
3590
3593
|
var import_fs = __toESM(require("fs"));
|
|
3591
3594
|
var import_os = __toESM(require("os"));
|
|
3592
3595
|
var import_path = __toESM(require("path"));
|
|
3593
|
-
var
|
|
3594
|
-
var
|
|
3596
|
+
var import_core21 = require("@anchor-lang/core");
|
|
3597
|
+
var import_web324 = require("@solana/web3.js");
|
|
3595
3598
|
var import_kit10 = require("@solana/kit");
|
|
3596
|
-
var
|
|
3599
|
+
var import_common44 = __toESM(require_dist());
|
|
3597
3600
|
|
|
3598
3601
|
// src/client/client.ts
|
|
3599
|
-
var
|
|
3602
|
+
var import_core20 = require("@anchor-lang/core");
|
|
3600
3603
|
var import_kit9 = require("@solana/kit");
|
|
3601
|
-
var
|
|
3602
|
-
var
|
|
3604
|
+
var import_web323 = require("@solana/web3.js");
|
|
3605
|
+
var import_common43 = __toESM(require_dist());
|
|
3603
3606
|
|
|
3604
3607
|
// src/idl/vault.ts
|
|
3605
3608
|
var IDL = {
|
|
@@ -4450,6 +4453,184 @@ var IDL = {
|
|
|
4450
4453
|
}
|
|
4451
4454
|
]
|
|
4452
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
|
+
},
|
|
4453
4634
|
{
|
|
4454
4635
|
name: "disable_circuit_breaker",
|
|
4455
4636
|
discriminator: [200, 37, 34, 37, 19, 156, 178, 253],
|
|
@@ -10008,6 +10189,10 @@ var IDL = {
|
|
|
10008
10189
|
}
|
|
10009
10190
|
],
|
|
10010
10191
|
events: [
|
|
10192
|
+
{
|
|
10193
|
+
name: "CuratorFeesDeposited",
|
|
10194
|
+
discriminator: [61, 40, 69, 224, 253, 73, 224, 46]
|
|
10195
|
+
},
|
|
10011
10196
|
{
|
|
10012
10197
|
name: "IncentiveClaimed",
|
|
10013
10198
|
discriminator: [93, 82, 106, 244, 88, 183, 241, 75]
|
|
@@ -10046,6 +10231,11 @@ var IDL = {
|
|
|
10046
10231
|
}
|
|
10047
10232
|
],
|
|
10048
10233
|
errors: [
|
|
10234
|
+
{
|
|
10235
|
+
code: 13048,
|
|
10236
|
+
name: "MinimumCuratorFeeSharesNotMet",
|
|
10237
|
+
msg: "Deposited USDC credits fewer curator shares than the requested minimum"
|
|
10238
|
+
},
|
|
10049
10239
|
{
|
|
10050
10240
|
code: 14001,
|
|
10051
10241
|
name: "Unauthorized",
|
|
@@ -10620,6 +10810,56 @@ var IDL = {
|
|
|
10620
10810
|
]
|
|
10621
10811
|
}
|
|
10622
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
|
+
},
|
|
10623
10863
|
{
|
|
10624
10864
|
name: "ExternalLiquiditySlot",
|
|
10625
10865
|
serialization: "bytemuck",
|
|
@@ -14921,38 +15161,115 @@ var DistributeIncentiveV3Builder = class extends DistributeIncentiveBuilder {
|
|
|
14921
15161
|
}
|
|
14922
15162
|
};
|
|
14923
15163
|
|
|
14924
|
-
// src/client/builders/
|
|
15164
|
+
// src/client/builders/depositCuratorFees.ts
|
|
15165
|
+
var import_core3 = require("@anchor-lang/core");
|
|
14925
15166
|
var import_spl_token4 = require("@solana/spl-token");
|
|
14926
15167
|
var import_web37 = require("@solana/web3.js");
|
|
14927
15168
|
var import_common9 = __toESM(require_dist());
|
|
14928
|
-
|
|
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 {
|
|
14929
15177
|
async getIx(args) {
|
|
14930
|
-
|
|
14931
|
-
|
|
14932
|
-
|
|
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),
|
|
14933
15184
|
vault: (0, import_common9.toWeb3Pk)(args.vault),
|
|
14934
|
-
|
|
14935
|
-
|
|
14936
|
-
|
|
14937
|
-
|
|
14938
|
-
|
|
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,
|
|
14939
15194
|
associatedTokenProgram: import_spl_token4.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
14940
15195
|
systemProgram: import_web37.SystemProgram.programId
|
|
14941
15196
|
}).instruction().then(import_common9.toKitInstruction);
|
|
14942
15197
|
}
|
|
14943
|
-
async deriveIxArgs(
|
|
14944
|
-
|
|
14945
|
-
const [
|
|
14946
|
-
|
|
14947
|
-
|
|
14948
|
-
|
|
14949
|
-
|
|
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
|
|
14950
15224
|
),
|
|
14951
|
-
|
|
14952
|
-
|
|
14953
|
-
|
|
14954
|
-
|
|
14955
|
-
|
|
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
|
+
{
|
|
14956
15273
|
mint: txArgs.juniorShareMint,
|
|
14957
15274
|
tokenProgram: txArgs.shareTokenProgram
|
|
14958
15275
|
}
|
|
@@ -14967,8 +15284,8 @@ var CancelJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
14967
15284
|
withdrawalQueue: queuePda,
|
|
14968
15285
|
inputMint: juniorShareMint,
|
|
14969
15286
|
shareTokenProgram,
|
|
14970
|
-
userInputAta: txArgs.userInputAta ?? (0,
|
|
14971
|
-
queueInputAta: (0,
|
|
15287
|
+
userInputAta: txArgs.userInputAta ?? (0, import_common10.getAtaAddress)(juniorShareMint, txArgs.user, shareTokenProgram),
|
|
15288
|
+
queueInputAta: (0, import_common10.getAtaAddress)(
|
|
14972
15289
|
juniorShareMint,
|
|
14973
15290
|
queuePda,
|
|
14974
15291
|
shareTokenProgram,
|
|
@@ -14986,19 +15303,19 @@ var CancelJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
14986
15303
|
};
|
|
14987
15304
|
|
|
14988
15305
|
// src/client/builders/createAssetHolding.ts
|
|
14989
|
-
var
|
|
15306
|
+
var import_common11 = __toESM(require_dist());
|
|
14990
15307
|
var CreateAssetHoldingBuilder = class extends VaultBuilderBase {
|
|
14991
15308
|
async getIx(args) {
|
|
14992
15309
|
return this.program.methods.createAssetHolding({
|
|
14993
15310
|
priceOracleType: args.args.priceOracleType,
|
|
14994
|
-
priceOracleAccount: (0,
|
|
15311
|
+
priceOracleAccount: (0, import_common11.toWeb3Pk)(args.args.priceOracleAccount)
|
|
14995
15312
|
}).accountsPartial({
|
|
14996
|
-
hwManager: (0,
|
|
14997
|
-
vault: (0,
|
|
14998
|
-
vaultOracle: (0,
|
|
14999
|
-
mint: (0,
|
|
15000
|
-
tokenProgram: (0,
|
|
15001
|
-
}).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);
|
|
15002
15319
|
}
|
|
15003
15320
|
async deriveIxArgs(txArgs) {
|
|
15004
15321
|
const [vaultOracle] = await this.pda.deriveVaultOraclePda(txArgs.vault);
|
|
@@ -15024,15 +15341,15 @@ var CreateAssetHoldingBuilder = class extends VaultBuilderBase {
|
|
|
15024
15341
|
};
|
|
15025
15342
|
|
|
15026
15343
|
// src/client/builders/removeAssetHolding.ts
|
|
15027
|
-
var
|
|
15344
|
+
var import_common12 = __toESM(require_dist());
|
|
15028
15345
|
var RemoveAssetHoldingBuilder = class extends VaultBuilderBase {
|
|
15029
15346
|
async getIx(args) {
|
|
15030
15347
|
return this.program.methods.removeAssetHolding().accountsPartial({
|
|
15031
|
-
hwManager: (0,
|
|
15032
|
-
vault: (0,
|
|
15033
|
-
vaultOracle: (0,
|
|
15034
|
-
mint: (0,
|
|
15035
|
-
}).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);
|
|
15036
15353
|
}
|
|
15037
15354
|
async deriveIxArgs(txArgs) {
|
|
15038
15355
|
const [vaultOracle] = await this.pda.deriveVaultOraclePda(txArgs.vault);
|
|
@@ -15053,16 +15370,16 @@ var RemoveAssetHoldingBuilder = class extends VaultBuilderBase {
|
|
|
15053
15370
|
};
|
|
15054
15371
|
|
|
15055
15372
|
// src/client/builders/updateConsensusSigners.ts
|
|
15056
|
-
var
|
|
15373
|
+
var import_common13 = __toESM(require_dist());
|
|
15057
15374
|
var UpdateConsensusSignersBuilder = class extends VaultBuilderBase {
|
|
15058
15375
|
async getIx(args) {
|
|
15059
15376
|
return this.program.methods.updateConsensusSigners({
|
|
15060
|
-
signers: args.args.signers.map(
|
|
15377
|
+
signers: args.args.signers.map(import_common13.toWeb3Pk)
|
|
15061
15378
|
}).accountsPartial({
|
|
15062
|
-
curator: (0,
|
|
15063
|
-
vault: (0,
|
|
15064
|
-
vaultOracle: (0,
|
|
15065
|
-
}).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);
|
|
15066
15383
|
}
|
|
15067
15384
|
async deriveIxArgs(txArgs) {
|
|
15068
15385
|
const [vaultOracle] = await this.pda.deriveVaultOraclePda(txArgs.vault);
|
|
@@ -15083,9 +15400,9 @@ var UpdateConsensusSignersBuilder = class extends VaultBuilderBase {
|
|
|
15083
15400
|
};
|
|
15084
15401
|
|
|
15085
15402
|
// src/client/builders/createTrancheState.ts
|
|
15086
|
-
var
|
|
15087
|
-
var
|
|
15088
|
-
var
|
|
15403
|
+
var import_core4 = require("@anchor-lang/core");
|
|
15404
|
+
var import_web39 = require("@solana/web3.js");
|
|
15405
|
+
var import_common14 = __toESM(require_dist());
|
|
15089
15406
|
var CreateTrancheStateBuilder = class extends VaultBuilderBase {
|
|
15090
15407
|
async getIx(args) {
|
|
15091
15408
|
return this.program.methods.vaultCreateTrancheState({
|
|
@@ -15097,18 +15414,18 @@ var CreateTrancheStateBuilder = class extends VaultBuilderBase {
|
|
|
15097
15414
|
juniorDepositCap: args.juniorDepositCap,
|
|
15098
15415
|
forMigration: args.forMigration
|
|
15099
15416
|
}).accountsPartial({
|
|
15100
|
-
curator: (0,
|
|
15101
|
-
vault: (0,
|
|
15102
|
-
vaultTrancheState: (0,
|
|
15103
|
-
juniorShareMint: (0,
|
|
15104
|
-
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),
|
|
15105
15422
|
// Optional on-chain: required only on the organic path, where the
|
|
15106
15423
|
// program enforces a fresh NAV before enabling tranching. Left null on
|
|
15107
15424
|
// the migration path so Anchor resolves it to the program ID.
|
|
15108
|
-
vaultOracle: args.vaultOracle ? (0,
|
|
15109
|
-
tokenProgram: (0,
|
|
15110
|
-
systemProgram:
|
|
15111
|
-
}).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);
|
|
15112
15429
|
}
|
|
15113
15430
|
async deriveIxArgs(txArgs) {
|
|
15114
15431
|
const [vaultTrancheState] = await this.pda.deriveVaultTrancheStatePda(
|
|
@@ -15137,10 +15454,10 @@ var CreateTrancheStateBuilder = class extends VaultBuilderBase {
|
|
|
15137
15454
|
juniorFloorApyBps: txArgs.juniorFloorApyBps ?? 0,
|
|
15138
15455
|
earlyUnstakeFeeBps: txArgs.earlyUnstakeFeeBps ?? DEFAULT_JUNIOR_EARLY_UNSTAKE_FEE_BPS,
|
|
15139
15456
|
standardUnstakeFeeBps: txArgs.standardUnstakeFeeBps ?? DEFAULT_JUNIOR_STANDARD_UNSTAKE_FEE_BPS,
|
|
15140
|
-
targetLockupDurationSecs: new
|
|
15457
|
+
targetLockupDurationSecs: new import_core4.BN(
|
|
15141
15458
|
(txArgs.targetLockupDurationSecs ?? DEFAULT_JUNIOR_WITHDRAWAL_LOCKUP_SECS).toString()
|
|
15142
15459
|
),
|
|
15143
|
-
juniorDepositCap: new
|
|
15460
|
+
juniorDepositCap: new import_core4.BN((txArgs.juniorDepositCap ?? 0n).toString()),
|
|
15144
15461
|
forMigration,
|
|
15145
15462
|
tokenProgram: txArgs.tokenProgram ?? TOKEN_PROGRAM_ID
|
|
15146
15463
|
};
|
|
@@ -15155,13 +15472,13 @@ var CreateTrancheStateBuilder = class extends VaultBuilderBase {
|
|
|
15155
15472
|
};
|
|
15156
15473
|
|
|
15157
15474
|
// src/client/builders/activateCircuitBreaker.ts
|
|
15158
|
-
var
|
|
15475
|
+
var import_common15 = __toESM(require_dist());
|
|
15159
15476
|
var ActivateCircuitBreakerBuilder = class extends VaultBuilderBase {
|
|
15160
15477
|
async getIx(args) {
|
|
15161
15478
|
return this.program.methods.activateCircuitBreaker().accountsPartial({
|
|
15162
|
-
cbTrigger: (0,
|
|
15163
|
-
vault: (0,
|
|
15164
|
-
}).instruction().then(
|
|
15479
|
+
cbTrigger: (0, import_common15.toWeb3Pk)(args.cbTrigger),
|
|
15480
|
+
vault: (0, import_common15.toWeb3Pk)(args.vault)
|
|
15481
|
+
}).instruction().then(import_common15.toKitInstruction);
|
|
15165
15482
|
}
|
|
15166
15483
|
async deriveIxArgs(txArgs) {
|
|
15167
15484
|
return txArgs;
|
|
@@ -15174,34 +15491,34 @@ var ActivateCircuitBreakerBuilder = class extends VaultBuilderBase {
|
|
|
15174
15491
|
};
|
|
15175
15492
|
|
|
15176
15493
|
// src/client/builders/createVault.ts
|
|
15177
|
-
var
|
|
15494
|
+
var import_core6 = require("@anchor-lang/core");
|
|
15178
15495
|
var import_token = require("@solana-program/token");
|
|
15179
|
-
var
|
|
15180
|
-
var
|
|
15181
|
-
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());
|
|
15182
15499
|
|
|
15183
15500
|
// src/client/builders/anchorArgs.ts
|
|
15184
|
-
var
|
|
15185
|
-
var
|
|
15501
|
+
var import_core5 = require("@anchor-lang/core");
|
|
15502
|
+
var import_common16 = __toESM(require_dist());
|
|
15186
15503
|
function toAnchorCreateVaultParams(params) {
|
|
15187
15504
|
return {
|
|
15188
15505
|
...params,
|
|
15189
|
-
hwManager: (0,
|
|
15190
|
-
cbTrigger: (0,
|
|
15191
|
-
feeCollector: (0,
|
|
15192
|
-
baseAssetMint: (0,
|
|
15193
|
-
basePriceOracleAccount: (0,
|
|
15194
|
-
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)
|
|
15195
15512
|
};
|
|
15196
15513
|
}
|
|
15197
15514
|
function toAnchorSetVaultConfigArgs(args) {
|
|
15198
15515
|
return {
|
|
15199
|
-
manager: args.manager ? (0,
|
|
15200
|
-
hwManager: args.hwManager ? (0,
|
|
15201
|
-
cbTrigger: args.cbTrigger ? (0,
|
|
15202
|
-
fulfiller: args.fulfiller ? (0,
|
|
15203
|
-
feeCollector: args.feeCollector ? (0,
|
|
15204
|
-
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,
|
|
15205
15522
|
mintFeeBps: args.mintFeeBps,
|
|
15206
15523
|
burnFeeBps: args.burnFeeBps,
|
|
15207
15524
|
performanceFeeBps: args.performanceFeeBps,
|
|
@@ -15218,9 +15535,9 @@ function toAnchorSetVaultConfigArgs(args) {
|
|
|
15218
15535
|
function toAnchorConsensusUpdates(updates) {
|
|
15219
15536
|
return updates.map((update) => ({
|
|
15220
15537
|
holdingIndex: update.holdingIndex,
|
|
15221
|
-
mint: update.mint ? (0,
|
|
15222
|
-
price: new
|
|
15223
|
-
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())
|
|
15224
15541
|
}));
|
|
15225
15542
|
}
|
|
15226
15543
|
|
|
@@ -15228,16 +15545,16 @@ function toAnchorConsensusUpdates(updates) {
|
|
|
15228
15545
|
var CreateVaultBuilder = class extends VaultBuilderBase {
|
|
15229
15546
|
async getIx(args) {
|
|
15230
15547
|
return this.program.methods.createVault(toAnchorCreateVaultParams(args.params)).accountsPartial({
|
|
15231
|
-
curator: (0,
|
|
15232
|
-
vault: (0,
|
|
15233
|
-
vaultOracle: (0,
|
|
15234
|
-
feeVault: (0,
|
|
15235
|
-
shareMint: (0,
|
|
15236
|
-
assetMint: (0,
|
|
15237
|
-
assetTokenProgram: (0,
|
|
15238
|
-
tokenProgram: (0,
|
|
15239
|
-
systemProgram:
|
|
15240
|
-
}).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);
|
|
15241
15558
|
}
|
|
15242
15559
|
async deriveIxArgs(txArgs) {
|
|
15243
15560
|
const vaultId = txArgs.vaultId ?? DEFAULT_VAULT_ID;
|
|
@@ -15266,11 +15583,11 @@ var CreateVaultBuilder = class extends VaultBuilderBase {
|
|
|
15266
15583
|
performanceFeeBps: txArgs.performanceFeeBps ?? 0,
|
|
15267
15584
|
fixedApyBps: txArgs.fixedApyBps ?? 0,
|
|
15268
15585
|
maxApyBps: txArgs.maxApyBps ?? DEFAULT_MAX_ACCEPTABLE_APY_BPS,
|
|
15269
|
-
tvlLimit: new
|
|
15586
|
+
tvlLimit: new import_core6.BN((txArgs.tvlLimit ?? 0n).toString()),
|
|
15270
15587
|
lossesEnabled: txArgs.lossesEnabled ?? false,
|
|
15271
15588
|
initialMintSharePrice: null,
|
|
15272
15589
|
basePriceOracleType: txArgs.basePriceOracleType ?? 1,
|
|
15273
|
-
basePrice: new
|
|
15590
|
+
basePrice: new import_core6.BN(
|
|
15274
15591
|
(txArgs.basePrice ?? 10n ** BigInt(accountingDecimals)).toString()
|
|
15275
15592
|
),
|
|
15276
15593
|
basePriceOracleAccount: txArgs.basePriceOracleAccount ?? DEFAULT_PRICE_ORACLE_ACCOUNT,
|
|
@@ -15282,42 +15599,42 @@ var CreateVaultBuilder = class extends VaultBuilderBase {
|
|
|
15282
15599
|
async getTx(txArgs) {
|
|
15283
15600
|
const args = await this.deriveIxArgs(txArgs);
|
|
15284
15601
|
const createIx = await this.getIx(args);
|
|
15285
|
-
const payer = (0,
|
|
15286
|
-
const assetMint = (0,
|
|
15287
|
-
const assetTokenProgram = (0,
|
|
15288
|
-
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)(
|
|
15289
15606
|
args.assetMint,
|
|
15290
15607
|
args.vault,
|
|
15291
15608
|
args.assetTokenProgram,
|
|
15292
15609
|
true
|
|
15293
15610
|
);
|
|
15294
|
-
const feeVaultAta = (0,
|
|
15611
|
+
const feeVaultAta = (0, import_common17.getAtaAddress)(
|
|
15295
15612
|
args.assetMint,
|
|
15296
15613
|
args.feeVault,
|
|
15297
15614
|
args.assetTokenProgram,
|
|
15298
15615
|
true
|
|
15299
15616
|
);
|
|
15300
|
-
const createVaultAssetAta = (0,
|
|
15617
|
+
const createVaultAssetAta = (0, import_spl_token6.createAssociatedTokenAccountIdempotentInstruction)(
|
|
15301
15618
|
payer,
|
|
15302
|
-
(0,
|
|
15303
|
-
(0,
|
|
15619
|
+
(0, import_common17.toWeb3Pk)(vaultAssetAta),
|
|
15620
|
+
(0, import_common17.toWeb3Pk)(args.vault),
|
|
15304
15621
|
assetMint,
|
|
15305
15622
|
assetTokenProgram,
|
|
15306
|
-
|
|
15623
|
+
import_spl_token6.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
15307
15624
|
);
|
|
15308
|
-
const createFeeVaultAta = (0,
|
|
15625
|
+
const createFeeVaultAta = (0, import_spl_token6.createAssociatedTokenAccountIdempotentInstruction)(
|
|
15309
15626
|
payer,
|
|
15310
|
-
(0,
|
|
15311
|
-
(0,
|
|
15627
|
+
(0, import_common17.toWeb3Pk)(feeVaultAta),
|
|
15628
|
+
(0, import_common17.toWeb3Pk)(args.feeVault),
|
|
15312
15629
|
assetMint,
|
|
15313
15630
|
assetTokenProgram,
|
|
15314
|
-
|
|
15631
|
+
import_spl_token6.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
15315
15632
|
);
|
|
15316
15633
|
return {
|
|
15317
15634
|
instructions: [
|
|
15318
15635
|
createIx,
|
|
15319
|
-
(0,
|
|
15320
|
-
(0,
|
|
15636
|
+
(0, import_common17.toKitInstruction)(createVaultAssetAta),
|
|
15637
|
+
(0, import_common17.toKitInstruction)(createFeeVaultAta)
|
|
15321
15638
|
],
|
|
15322
15639
|
postSuccessCacheInvalidations: [
|
|
15323
15640
|
{ vaultPda: args.vault, vaultOraclePda: args.vaultOracle }
|
|
@@ -15327,16 +15644,16 @@ var CreateVaultBuilder = class extends VaultBuilderBase {
|
|
|
15327
15644
|
};
|
|
15328
15645
|
|
|
15329
15646
|
// src/client/builders/initializeVaultRoles.ts
|
|
15330
|
-
var
|
|
15647
|
+
var import_common18 = __toESM(require_dist());
|
|
15331
15648
|
var InitializeVaultRolesBuilder = class extends VaultBuilderBase {
|
|
15332
15649
|
async getIx(args) {
|
|
15333
15650
|
return this.program.methods.initializeVaultRoles({
|
|
15334
|
-
manager: (0,
|
|
15335
|
-
fulfiller: (0,
|
|
15651
|
+
manager: (0, import_common18.toWeb3Pk)(args.args.manager),
|
|
15652
|
+
fulfiller: (0, import_common18.toWeb3Pk)(args.args.fulfiller)
|
|
15336
15653
|
}).accountsPartial({
|
|
15337
|
-
curator: (0,
|
|
15338
|
-
vault: (0,
|
|
15339
|
-
}).instruction().then(
|
|
15654
|
+
curator: (0, import_common18.toWeb3Pk)(args.curator),
|
|
15655
|
+
vault: (0, import_common18.toWeb3Pk)(args.vault)
|
|
15656
|
+
}).instruction().then(import_common18.toKitInstruction);
|
|
15340
15657
|
}
|
|
15341
15658
|
async deriveIxArgs(txArgs) {
|
|
15342
15659
|
return {
|
|
@@ -15356,13 +15673,13 @@ var InitializeVaultRolesBuilder = class extends VaultBuilderBase {
|
|
|
15356
15673
|
};
|
|
15357
15674
|
|
|
15358
15675
|
// src/client/builders/disableCircuitBreaker.ts
|
|
15359
|
-
var
|
|
15676
|
+
var import_common19 = __toESM(require_dist());
|
|
15360
15677
|
var DisableCircuitBreakerBuilder = class extends VaultBuilderBase {
|
|
15361
15678
|
async getIx(args) {
|
|
15362
15679
|
return this.program.methods.disableCircuitBreaker().accountsPartial({
|
|
15363
|
-
curator: (0,
|
|
15364
|
-
vault: (0,
|
|
15365
|
-
}).instruction().then(
|
|
15680
|
+
curator: (0, import_common19.toWeb3Pk)(args.curator),
|
|
15681
|
+
vault: (0, import_common19.toWeb3Pk)(args.vault)
|
|
15682
|
+
}).instruction().then(import_common19.toKitInstruction);
|
|
15366
15683
|
}
|
|
15367
15684
|
async deriveIxArgs(txArgs) {
|
|
15368
15685
|
return txArgs;
|
|
@@ -15375,15 +15692,15 @@ var DisableCircuitBreakerBuilder = class extends VaultBuilderBase {
|
|
|
15375
15692
|
};
|
|
15376
15693
|
|
|
15377
15694
|
// src/client/builders/setVaultConfig.ts
|
|
15378
|
-
var
|
|
15379
|
-
var
|
|
15695
|
+
var import_core7 = require("@anchor-lang/core");
|
|
15696
|
+
var import_common20 = __toESM(require_dist());
|
|
15380
15697
|
var SetVaultConfigBuilder = class extends VaultBuilderBase {
|
|
15381
15698
|
async getIx(args) {
|
|
15382
15699
|
return this.program.methods.setVaultConfig(toAnchorSetVaultConfigArgs(args.args)).accountsPartial({
|
|
15383
|
-
curator: (0,
|
|
15384
|
-
vault: (0,
|
|
15385
|
-
vaultOracle: args.vaultOracle ? (0,
|
|
15386
|
-
}).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);
|
|
15387
15704
|
}
|
|
15388
15705
|
async deriveIxArgs(txArgs) {
|
|
15389
15706
|
const [derivedVaultOracle] = await this.pda.deriveVaultOraclePda(
|
|
@@ -15405,28 +15722,28 @@ var SetVaultConfigBuilder = class extends VaultBuilderBase {
|
|
|
15405
15722
|
performanceFeeBps: txArgs.performanceFeeBps ?? null,
|
|
15406
15723
|
fixedApyBps: txArgs.fixedApyBps ?? null,
|
|
15407
15724
|
maxApyBps: txArgs.maxApyBps ?? null,
|
|
15408
|
-
tvlLimit: txArgs.tvlLimit !== void 0 ? new
|
|
15725
|
+
tvlLimit: txArgs.tvlLimit !== void 0 ? new import_core7.BN(txArgs.tvlLimit.toString()) : null,
|
|
15409
15726
|
lossesEnabled: txArgs.lossesEnabled ?? null,
|
|
15410
|
-
priceStalenessThresholdSecs: txArgs.priceStalenessThresholdSecs !== void 0 ? new
|
|
15727
|
+
priceStalenessThresholdSecs: txArgs.priceStalenessThresholdSecs !== void 0 ? new import_core7.BN(txArgs.priceStalenessThresholdSecs.toString()) : null,
|
|
15411
15728
|
userBurnLimit: txArgs.userBurnLimit !== void 0 ? {
|
|
15412
|
-
windowLimit: new
|
|
15729
|
+
windowLimit: new import_core7.BN(
|
|
15413
15730
|
txArgs.userBurnLimit.windowLimit.toString()
|
|
15414
15731
|
),
|
|
15415
|
-
windowDurationSeconds: new
|
|
15732
|
+
windowDurationSeconds: new import_core7.BN(
|
|
15416
15733
|
txArgs.userBurnLimit.windowDurationSeconds.toString()
|
|
15417
15734
|
)
|
|
15418
15735
|
} : null,
|
|
15419
15736
|
managerPullLimit: txArgs.managerPullLimit !== void 0 ? {
|
|
15420
|
-
windowLimit: new
|
|
15737
|
+
windowLimit: new import_core7.BN(
|
|
15421
15738
|
txArgs.managerPullLimit.windowLimit.toString()
|
|
15422
15739
|
),
|
|
15423
|
-
windowDurationSeconds: new
|
|
15740
|
+
windowDurationSeconds: new import_core7.BN(
|
|
15424
15741
|
txArgs.managerPullLimit.windowDurationSeconds.toString()
|
|
15425
15742
|
)
|
|
15426
15743
|
} : null,
|
|
15427
15744
|
rebalanceLimit: txArgs.rebalanceLimit !== void 0 ? {
|
|
15428
15745
|
windowLimitBps: txArgs.rebalanceLimit.windowLimitBps,
|
|
15429
|
-
windowDurationSeconds: new
|
|
15746
|
+
windowDurationSeconds: new import_core7.BN(
|
|
15430
15747
|
txArgs.rebalanceLimit.windowDurationSeconds.toString()
|
|
15431
15748
|
)
|
|
15432
15749
|
} : null
|
|
@@ -15441,14 +15758,14 @@ var SetVaultConfigBuilder = class extends VaultBuilderBase {
|
|
|
15441
15758
|
};
|
|
15442
15759
|
|
|
15443
15760
|
// src/client/builders/setProtocolFee.ts
|
|
15444
|
-
var
|
|
15761
|
+
var import_common21 = __toESM(require_dist());
|
|
15445
15762
|
var SetProtocolFeeBuilder = class extends VaultBuilderBase {
|
|
15446
15763
|
async getIx(args) {
|
|
15447
15764
|
return this.program.methods.setProtocolFee({ protocolFeeBps: args.args.protocolFeeBps }).accountsPartial({
|
|
15448
|
-
protocolAuthority: (0,
|
|
15449
|
-
vault: (0,
|
|
15450
|
-
vaultOracle: args.vaultOracle ? (0,
|
|
15451
|
-
}).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);
|
|
15452
15769
|
}
|
|
15453
15770
|
async deriveIxArgs(txArgs) {
|
|
15454
15771
|
const [derivedVaultOracle] = await this.pda.deriveVaultOraclePda(
|
|
@@ -15472,13 +15789,13 @@ var SetProtocolFeeBuilder = class extends VaultBuilderBase {
|
|
|
15472
15789
|
};
|
|
15473
15790
|
|
|
15474
15791
|
// src/client/builders/crankNav.ts
|
|
15475
|
-
var
|
|
15792
|
+
var import_spl_token7 = require("@solana/spl-token");
|
|
15476
15793
|
var import_kit6 = require("@solana/kit");
|
|
15477
|
-
var
|
|
15478
|
-
var
|
|
15794
|
+
var import_web311 = require("@solana/web3.js");
|
|
15795
|
+
var import_common23 = __toESM(require_dist());
|
|
15479
15796
|
|
|
15480
15797
|
// src/client/builders/feeCollector.ts
|
|
15481
|
-
var
|
|
15798
|
+
var import_common22 = __toESM(require_dist());
|
|
15482
15799
|
function resolveProtocolFeeRecipient(override) {
|
|
15483
15800
|
return override ?? PROTOCOL_FEE_RECIPIENT;
|
|
15484
15801
|
}
|
|
@@ -15487,14 +15804,14 @@ async function resolveVaultFeeCollector(account, vault, override) {
|
|
|
15487
15804
|
return override;
|
|
15488
15805
|
}
|
|
15489
15806
|
const vaultState = await account.fetchVault(vault);
|
|
15490
|
-
return (0,
|
|
15807
|
+
return (0, import_common22.fromWeb3Pk)(vaultState.roles.feeCollector);
|
|
15491
15808
|
}
|
|
15492
15809
|
function baseAssetMintFromVault(vaultState) {
|
|
15493
15810
|
const baseHolding = vaultState.holdings.find((holding) => holding.isBase);
|
|
15494
15811
|
if (!baseHolding) {
|
|
15495
15812
|
throw new Error("Vault has no base asset holding");
|
|
15496
15813
|
}
|
|
15497
|
-
return (0,
|
|
15814
|
+
return (0, import_common22.fromWeb3Pk)(baseHolding.mint);
|
|
15498
15815
|
}
|
|
15499
15816
|
async function resolveVaultBaseAssetMint(account, vault, override) {
|
|
15500
15817
|
if (override) {
|
|
@@ -15509,7 +15826,7 @@ async function resolveFeeAssetTokenProgram(account, vault, feeAssetMint, overrid
|
|
|
15509
15826
|
}
|
|
15510
15827
|
const vaultState = await account.fetchVault(vault);
|
|
15511
15828
|
const holding = vaultState.holdings.find(
|
|
15512
|
-
(entry) => (0,
|
|
15829
|
+
(entry) => (0, import_common22.fromWeb3Pk)(entry.mint) === feeAssetMint
|
|
15513
15830
|
);
|
|
15514
15831
|
if (!holding) {
|
|
15515
15832
|
return TOKEN_PROGRAM_ID;
|
|
@@ -15521,21 +15838,21 @@ async function resolveFeeAssetTokenProgram(account, vault, feeAssetMint, overrid
|
|
|
15521
15838
|
var CrankNavBuilder = class extends VaultBuilderBase {
|
|
15522
15839
|
async getIx(args) {
|
|
15523
15840
|
return this.program.methods.crankNav().accountsPartial({
|
|
15524
|
-
cranker: (0,
|
|
15525
|
-
vault: (0,
|
|
15526
|
-
vaultOracle: (0,
|
|
15527
|
-
vaultTrancheState: args.vaultTrancheState ? (0,
|
|
15528
|
-
shareMint: (0,
|
|
15529
|
-
juniorTrancheShareMint: args.juniorTrancheShareMint ? (0,
|
|
15530
|
-
seniorTrancheShareMint: args.seniorTrancheShareMint ? (0,
|
|
15531
|
-
feeAssetMint: (0,
|
|
15532
|
-
vaultFeeAssetAta: (0,
|
|
15533
|
-
feeVault: (0,
|
|
15534
|
-
feeVaultAta: (0,
|
|
15535
|
-
feeAssetTokenProgram: (0,
|
|
15536
|
-
associatedTokenProgram:
|
|
15537
|
-
systemProgram:
|
|
15538
|
-
}).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);
|
|
15539
15856
|
}
|
|
15540
15857
|
async deriveIxArgs(txArgs) {
|
|
15541
15858
|
const [vaultOracle] = await this.pda.deriveVaultOraclePda(txArgs.vault);
|
|
@@ -15585,13 +15902,13 @@ var CrankNavBuilder = class extends VaultBuilderBase {
|
|
|
15585
15902
|
seniorTrancheShareMint,
|
|
15586
15903
|
feeAssetMint,
|
|
15587
15904
|
feeVault,
|
|
15588
|
-
vaultFeeAssetAta: (0,
|
|
15905
|
+
vaultFeeAssetAta: (0, import_common23.getAtaAddress)(
|
|
15589
15906
|
feeAssetMint,
|
|
15590
15907
|
txArgs.vault,
|
|
15591
15908
|
feeAssetTokenProgram,
|
|
15592
15909
|
true
|
|
15593
15910
|
),
|
|
15594
|
-
feeVaultAta: (0,
|
|
15911
|
+
feeVaultAta: (0, import_common23.getAtaAddress)(
|
|
15595
15912
|
feeAssetMint,
|
|
15596
15913
|
feeVault,
|
|
15597
15914
|
feeAssetTokenProgram,
|
|
@@ -15601,25 +15918,25 @@ var CrankNavBuilder = class extends VaultBuilderBase {
|
|
|
15601
15918
|
};
|
|
15602
15919
|
}
|
|
15603
15920
|
async buildPreambleInstructions(args) {
|
|
15604
|
-
const payer = (0,
|
|
15921
|
+
const payer = (0, import_common23.toWeb3Pk)(args.cranker);
|
|
15605
15922
|
return [
|
|
15606
|
-
(0,
|
|
15923
|
+
(0, import_spl_token7.createAssociatedTokenAccountIdempotentInstruction)(
|
|
15607
15924
|
payer,
|
|
15608
|
-
(0,
|
|
15609
|
-
(0,
|
|
15610
|
-
(0,
|
|
15611
|
-
(0,
|
|
15612
|
-
|
|
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
|
|
15613
15930
|
),
|
|
15614
|
-
(0,
|
|
15931
|
+
(0, import_spl_token7.createAssociatedTokenAccountIdempotentInstruction)(
|
|
15615
15932
|
payer,
|
|
15616
|
-
(0,
|
|
15617
|
-
(0,
|
|
15618
|
-
(0,
|
|
15619
|
-
(0,
|
|
15620
|
-
|
|
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
|
|
15621
15938
|
)
|
|
15622
|
-
].map(
|
|
15939
|
+
].map(import_common23.toKitInstruction);
|
|
15623
15940
|
}
|
|
15624
15941
|
async buildPlanExtras(args) {
|
|
15625
15942
|
return {
|
|
@@ -15645,29 +15962,29 @@ var CrankNavBuilder = class extends VaultBuilderBase {
|
|
|
15645
15962
|
};
|
|
15646
15963
|
|
|
15647
15964
|
// src/client/builders/crankPerformanceFees.ts
|
|
15648
|
-
var
|
|
15649
|
-
var
|
|
15650
|
-
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());
|
|
15651
15968
|
var CrankPerformanceFeesBuilder = class extends VaultBuilderBase {
|
|
15652
15969
|
async getIx(args) {
|
|
15653
15970
|
return this.program.methods.crankPerformanceFees().accountsPartial({
|
|
15654
|
-
cranker: (0,
|
|
15655
|
-
vault: (0,
|
|
15656
|
-
shareMint: (0,
|
|
15657
|
-
feeCollector: (0,
|
|
15658
|
-
feeCollectorShareAta: (0,
|
|
15659
|
-
protocolFeeCollector: (0,
|
|
15660
|
-
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)(
|
|
15661
15978
|
args.protocolFeeCollectorShareAta
|
|
15662
15979
|
),
|
|
15663
|
-
shareTokenProgram: (0,
|
|
15664
|
-
associatedTokenProgram:
|
|
15665
|
-
systemProgram:
|
|
15666
|
-
}).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);
|
|
15667
15984
|
}
|
|
15668
15985
|
async deriveIxArgs(txArgs) {
|
|
15669
15986
|
const vaultState = await this.account.fetchVault(txArgs.vault);
|
|
15670
|
-
const shareMint = (0,
|
|
15987
|
+
const shareMint = (0, import_common24.fromWeb3Pk)(vaultState.mint);
|
|
15671
15988
|
const shareTokenProgram = txArgs.shareTokenProgram ?? tokenProgramAddressFromIdlEnum(vaultState.mintTokenProgram);
|
|
15672
15989
|
const feeCollector = await resolveVaultFeeCollector(
|
|
15673
15990
|
this.account,
|
|
@@ -15684,7 +16001,7 @@ var CrankPerformanceFeesBuilder = class extends VaultBuilderBase {
|
|
|
15684
16001
|
feeCollector,
|
|
15685
16002
|
// The vault fee collector is a role that is routinely a Squads vault
|
|
15686
16003
|
// (off-curve PDA), so allow an off-curve owner here too.
|
|
15687
|
-
feeCollectorShareAta: (0,
|
|
16004
|
+
feeCollectorShareAta: (0, import_common24.getAtaAddress)(
|
|
15688
16005
|
shareMint,
|
|
15689
16006
|
feeCollector,
|
|
15690
16007
|
shareTokenProgram,
|
|
@@ -15694,7 +16011,7 @@ var CrankPerformanceFeesBuilder = class extends VaultBuilderBase {
|
|
|
15694
16011
|
// The protocol fee recipient is a hardcoded protocol-controlled address
|
|
15695
16012
|
// that may be off-curve (e.g. a PDA / multisig vault), so allow an
|
|
15696
16013
|
// off-curve owner when deriving its ATA.
|
|
15697
|
-
protocolFeeCollectorShareAta: (0,
|
|
16014
|
+
protocolFeeCollectorShareAta: (0, import_common24.getAtaAddress)(
|
|
15698
16015
|
shareMint,
|
|
15699
16016
|
protocolFeeCollector,
|
|
15700
16017
|
shareTokenProgram,
|
|
@@ -15720,7 +16037,7 @@ var CrankPerformanceFeesBuilder = class extends VaultBuilderBase {
|
|
|
15720
16037
|
};
|
|
15721
16038
|
|
|
15722
16039
|
// src/client/builders/setExternalLiquidity.ts
|
|
15723
|
-
var
|
|
16040
|
+
var import_common25 = __toESM(require_dist());
|
|
15724
16041
|
function toExternalLiquiditySource(source) {
|
|
15725
16042
|
switch (source) {
|
|
15726
16043
|
case 0:
|
|
@@ -15736,11 +16053,11 @@ var SetExternalLiquidityBuilder = class extends VaultBuilderBase {
|
|
|
15736
16053
|
return this.program.methods.setExternalLiquidity({
|
|
15737
16054
|
index: args.args.index,
|
|
15738
16055
|
source: args.args.source,
|
|
15739
|
-
userAccount: (0,
|
|
16056
|
+
userAccount: (0, import_common25.toWeb3Pk)(args.args.userAccount)
|
|
15740
16057
|
}).accountsPartial({
|
|
15741
|
-
curator: (0,
|
|
15742
|
-
vault: (0,
|
|
15743
|
-
}).instruction().then(
|
|
16058
|
+
curator: (0, import_common25.toWeb3Pk)(args.curator),
|
|
16059
|
+
vault: (0, import_common25.toWeb3Pk)(args.vault)
|
|
16060
|
+
}).instruction().then(import_common25.toKitInstruction);
|
|
15744
16061
|
}
|
|
15745
16062
|
async deriveIxArgs(txArgs) {
|
|
15746
16063
|
return {
|
|
@@ -15761,16 +16078,16 @@ var SetExternalLiquidityBuilder = class extends VaultBuilderBase {
|
|
|
15761
16078
|
};
|
|
15762
16079
|
|
|
15763
16080
|
// src/client/builders/setManagerWithdrawDestination.ts
|
|
15764
|
-
var
|
|
16081
|
+
var import_common26 = __toESM(require_dist());
|
|
15765
16082
|
var SetManagerWithdrawDestinationBuilder = class extends VaultBuilderBase {
|
|
15766
16083
|
async getIx(args) {
|
|
15767
16084
|
return this.program.methods.setManagerWithdrawDestination({
|
|
15768
16085
|
slot: args.args.slot,
|
|
15769
|
-
address: (0,
|
|
16086
|
+
address: (0, import_common26.toWeb3Pk)(args.args.address)
|
|
15770
16087
|
}).accountsPartial({
|
|
15771
|
-
curator: (0,
|
|
15772
|
-
vault: (0,
|
|
15773
|
-
}).instruction().then(
|
|
16088
|
+
curator: (0, import_common26.toWeb3Pk)(args.curator),
|
|
16089
|
+
vault: (0, import_common26.toWeb3Pk)(args.vault)
|
|
16090
|
+
}).instruction().then(import_common26.toKitInstruction);
|
|
15774
16091
|
}
|
|
15775
16092
|
async deriveIxArgs(txArgs) {
|
|
15776
16093
|
return {
|
|
@@ -15790,17 +16107,17 @@ var SetManagerWithdrawDestinationBuilder = class extends VaultBuilderBase {
|
|
|
15790
16107
|
};
|
|
15791
16108
|
|
|
15792
16109
|
// src/client/builders/setAssetPriceOracle.ts
|
|
15793
|
-
var
|
|
16110
|
+
var import_common27 = __toESM(require_dist());
|
|
15794
16111
|
var SetAssetPriceOracleBuilder = class extends VaultBuilderBase {
|
|
15795
16112
|
async getIx(args) {
|
|
15796
16113
|
return this.program.methods.setAssetPriceOracle({
|
|
15797
|
-
mint: (0,
|
|
16114
|
+
mint: (0, import_common27.toWeb3Pk)(args.args.mint),
|
|
15798
16115
|
priceOracleType: args.args.priceOracleType,
|
|
15799
|
-
priceOracleAccount: (0,
|
|
16116
|
+
priceOracleAccount: (0, import_common27.toWeb3Pk)(args.args.priceOracleAccount)
|
|
15800
16117
|
}).accountsPartial({
|
|
15801
|
-
curator: (0,
|
|
15802
|
-
vault: (0,
|
|
15803
|
-
}).instruction().then(
|
|
16118
|
+
curator: (0, import_common27.toWeb3Pk)(args.curator),
|
|
16119
|
+
vault: (0, import_common27.toWeb3Pk)(args.vault)
|
|
16120
|
+
}).instruction().then(import_common27.toKitInstruction);
|
|
15804
16121
|
}
|
|
15805
16122
|
async deriveIxArgs(txArgs) {
|
|
15806
16123
|
return {
|
|
@@ -15821,19 +16138,19 @@ var SetAssetPriceOracleBuilder = class extends VaultBuilderBase {
|
|
|
15821
16138
|
};
|
|
15822
16139
|
|
|
15823
16140
|
// src/client/builders/updateAssetPrice.ts
|
|
15824
|
-
var
|
|
15825
|
-
var
|
|
16141
|
+
var import_core8 = require("@anchor-lang/core");
|
|
16142
|
+
var import_common28 = __toESM(require_dist());
|
|
15826
16143
|
var DEFAULT_PRICE_MAX_AGE_SECS = 90n;
|
|
15827
16144
|
var UpdateAssetPriceBuilder = class extends VaultBuilderBase {
|
|
15828
16145
|
async getIx(args) {
|
|
15829
16146
|
return this.program.methods.updateAssetPrice({
|
|
15830
|
-
mint: (0,
|
|
16147
|
+
mint: (0, import_common28.toWeb3Pk)(args.args.mint),
|
|
15831
16148
|
maxAgeSecs: args.args.maxAgeSecs
|
|
15832
16149
|
}).accountsPartial({
|
|
15833
|
-
updater: (0,
|
|
15834
|
-
vault: (0,
|
|
15835
|
-
oracleAccount: (0,
|
|
15836
|
-
}).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);
|
|
15837
16154
|
}
|
|
15838
16155
|
async deriveIxArgs(txArgs) {
|
|
15839
16156
|
return {
|
|
@@ -15842,7 +16159,7 @@ var UpdateAssetPriceBuilder = class extends VaultBuilderBase {
|
|
|
15842
16159
|
oracleAccount: txArgs.oracleAccount,
|
|
15843
16160
|
args: {
|
|
15844
16161
|
mint: txArgs.mint,
|
|
15845
|
-
maxAgeSecs: new
|
|
16162
|
+
maxAgeSecs: new import_core8.BN(
|
|
15846
16163
|
(txArgs.maxAgeSecs ?? DEFAULT_PRICE_MAX_AGE_SECS).toString()
|
|
15847
16164
|
)
|
|
15848
16165
|
}
|
|
@@ -15865,18 +16182,18 @@ var UpdateAssetPriceBuilder = class extends VaultBuilderBase {
|
|
|
15865
16182
|
};
|
|
15866
16183
|
|
|
15867
16184
|
// src/client/builders/updateConsensusOracle.ts
|
|
15868
|
-
var
|
|
16185
|
+
var import_common29 = __toESM(require_dist());
|
|
15869
16186
|
var UpdateConsensusOracleBuilder = class extends VaultBuilderBase {
|
|
15870
16187
|
async getIx(args) {
|
|
15871
16188
|
return this.program.methods.updateConsensusOracle({
|
|
15872
16189
|
updates: toAnchorConsensusUpdates(args.updates)
|
|
15873
16190
|
}).accountsPartial({
|
|
15874
|
-
signer: (0,
|
|
15875
|
-
vault: (0,
|
|
15876
|
-
vaultOracle: (0,
|
|
15877
|
-
assetMint: args.assetMint ? (0,
|
|
15878
|
-
assetTokenProgram: args.assetTokenProgram ? (0,
|
|
15879
|
-
}).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);
|
|
15880
16197
|
}
|
|
15881
16198
|
async deriveIxArgs(txArgs) {
|
|
15882
16199
|
const [derivedVaultOracle] = await this.pda.deriveVaultOraclePda(
|
|
@@ -15920,25 +16237,25 @@ var UpdateConsensusOracleBuilder = class extends VaultBuilderBase {
|
|
|
15920
16237
|
};
|
|
15921
16238
|
|
|
15922
16239
|
// src/client/builders/executeShareSwap.ts
|
|
15923
|
-
var
|
|
15924
|
-
var
|
|
15925
|
-
var
|
|
15926
|
-
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());
|
|
15927
16244
|
var ExecuteShareSwapBuilder = class extends VaultBuilderBase {
|
|
15928
16245
|
getIxAccounts(args) {
|
|
15929
16246
|
return {
|
|
15930
|
-
user: (0,
|
|
15931
|
-
vault: (0,
|
|
15932
|
-
vaultOracle: (0,
|
|
15933
|
-
vaultTrancheState: (0,
|
|
15934
|
-
shareMint: (0,
|
|
15935
|
-
trancheShareMint: (0,
|
|
15936
|
-
userShareAta: (0,
|
|
15937
|
-
userTrancheShareAta: (0,
|
|
15938
|
-
shareTokenProgram: (0,
|
|
15939
|
-
trancheShareTokenProgram: (0,
|
|
15940
|
-
associatedTokenProgram:
|
|
15941
|
-
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
|
|
15942
16259
|
};
|
|
15943
16260
|
}
|
|
15944
16261
|
getIxData(args) {
|
|
@@ -15949,7 +16266,7 @@ var ExecuteShareSwapBuilder = class extends VaultBuilderBase {
|
|
|
15949
16266
|
}
|
|
15950
16267
|
async getIx(args) {
|
|
15951
16268
|
const data = this.getIxData(args);
|
|
15952
|
-
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);
|
|
15953
16270
|
}
|
|
15954
16271
|
async deriveIxArgs(txArgs) {
|
|
15955
16272
|
const [
|
|
@@ -15980,11 +16297,11 @@ var ExecuteShareSwapBuilder = class extends VaultBuilderBase {
|
|
|
15980
16297
|
shareMint,
|
|
15981
16298
|
trancheShareMint,
|
|
15982
16299
|
kind: txArgs.kind,
|
|
15983
|
-
shareAmount: new
|
|
16300
|
+
shareAmount: new import_core9.BN(txArgs.shareAmount.toString()),
|
|
15984
16301
|
shareTokenProgram,
|
|
15985
16302
|
trancheShareTokenProgram,
|
|
15986
|
-
userShareAta: (0,
|
|
15987
|
-
userTrancheShareAta: (0,
|
|
16303
|
+
userShareAta: (0, import_common30.getAtaAddress)(shareMint, txArgs.user, shareTokenProgram),
|
|
16304
|
+
userTrancheShareAta: (0, import_common30.getAtaAddress)(
|
|
15988
16305
|
trancheShareMint,
|
|
15989
16306
|
txArgs.user,
|
|
15990
16307
|
trancheShareTokenProgram
|
|
@@ -15992,16 +16309,16 @@ var ExecuteShareSwapBuilder = class extends VaultBuilderBase {
|
|
|
15992
16309
|
};
|
|
15993
16310
|
}
|
|
15994
16311
|
async buildPreambleInstructions(args) {
|
|
15995
|
-
const payer = (0,
|
|
15996
|
-
const createUserTrancheShareAta = (0,
|
|
16312
|
+
const payer = (0, import_common30.toWeb3Pk)(args.user);
|
|
16313
|
+
const createUserTrancheShareAta = (0, import_spl_token9.createAssociatedTokenAccountIdempotentInstruction)(
|
|
15997
16314
|
payer,
|
|
15998
|
-
(0,
|
|
16315
|
+
(0, import_common30.toWeb3Pk)(args.userTrancheShareAta),
|
|
15999
16316
|
payer,
|
|
16000
|
-
(0,
|
|
16001
|
-
(0,
|
|
16002
|
-
|
|
16317
|
+
(0, import_common30.toWeb3Pk)(args.trancheShareMint),
|
|
16318
|
+
(0, import_common30.toWeb3Pk)(args.trancheShareTokenProgram),
|
|
16319
|
+
import_spl_token9.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16003
16320
|
);
|
|
16004
|
-
return [createUserTrancheShareAta].map(
|
|
16321
|
+
return [createUserTrancheShareAta].map(import_common30.toKitInstruction);
|
|
16005
16322
|
}
|
|
16006
16323
|
async buildPlanExtras(args) {
|
|
16007
16324
|
return {
|
|
@@ -16023,25 +16340,25 @@ var ExecuteShareSwapBuilder = class extends VaultBuilderBase {
|
|
|
16023
16340
|
};
|
|
16024
16341
|
|
|
16025
16342
|
// src/client/builders/executeDeposit.ts
|
|
16026
|
-
var
|
|
16027
|
-
var
|
|
16028
|
-
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());
|
|
16029
16346
|
var ExecuteDepositBuilder = class extends VaultBuilderBase {
|
|
16030
16347
|
getIxAccounts(args) {
|
|
16031
16348
|
return {
|
|
16032
|
-
user: (0,
|
|
16033
|
-
vault: (0,
|
|
16034
|
-
vaultOracle: (0,
|
|
16035
|
-
vaultTrancheState: args.vaultTrancheState ? (0,
|
|
16036
|
-
assetMint: (0,
|
|
16037
|
-
shareMint: (0,
|
|
16038
|
-
userAssetAta: (0,
|
|
16039
|
-
vaultAssetAta: (0,
|
|
16040
|
-
feeVault: (0,
|
|
16041
|
-
feeVaultAta: (0,
|
|
16042
|
-
userShareAta: (0,
|
|
16043
|
-
assetTokenProgram: (0,
|
|
16044
|
-
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)
|
|
16045
16362
|
};
|
|
16046
16363
|
}
|
|
16047
16364
|
getIxData(args) {
|
|
@@ -16058,7 +16375,7 @@ var ExecuteDepositBuilder = class extends VaultBuilderBase {
|
|
|
16058
16375
|
) : this.program.methods.executeDeposit(data.amount);
|
|
16059
16376
|
return methods.accountsPartial(
|
|
16060
16377
|
this.getIxAccounts(args)
|
|
16061
|
-
).instruction().then(
|
|
16378
|
+
).instruction().then(import_common31.toKitInstruction);
|
|
16062
16379
|
}
|
|
16063
16380
|
async deriveIxArgs(txArgs) {
|
|
16064
16381
|
const connection = this.program.provider.connection;
|
|
@@ -16097,61 +16414,61 @@ var ExecuteDepositBuilder = class extends VaultBuilderBase {
|
|
|
16097
16414
|
vaultTrancheState,
|
|
16098
16415
|
assetMint: txArgs.assetMint,
|
|
16099
16416
|
shareMint: txArgs.shareMint,
|
|
16100
|
-
amount: new
|
|
16417
|
+
amount: new import_core10.BN(txArgs.amount.toString()),
|
|
16101
16418
|
addressSeeds: txArgs.addressSeeds,
|
|
16102
16419
|
assetTokenProgram,
|
|
16103
16420
|
shareTokenProgram,
|
|
16104
|
-
userAssetAta: txArgs.userAssetAta ?? (0,
|
|
16105
|
-
vaultAssetAta: (0,
|
|
16421
|
+
userAssetAta: txArgs.userAssetAta ?? (0, import_common31.getAtaAddress)(txArgs.assetMint, txArgs.user, assetTokenProgram),
|
|
16422
|
+
vaultAssetAta: (0, import_common31.getAtaAddress)(
|
|
16106
16423
|
txArgs.assetMint,
|
|
16107
16424
|
txArgs.vault,
|
|
16108
16425
|
assetTokenProgram,
|
|
16109
16426
|
true
|
|
16110
16427
|
),
|
|
16111
16428
|
feeVault,
|
|
16112
|
-
feeVaultAta: (0,
|
|
16429
|
+
feeVaultAta: (0, import_common31.getAtaAddress)(
|
|
16113
16430
|
txArgs.assetMint,
|
|
16114
16431
|
feeVault,
|
|
16115
16432
|
assetTokenProgram,
|
|
16116
16433
|
true
|
|
16117
16434
|
),
|
|
16118
|
-
userShareAta: txArgs.userShareAta ?? (0,
|
|
16435
|
+
userShareAta: txArgs.userShareAta ?? (0, import_common31.getAtaAddress)(txArgs.shareMint, txArgs.user, shareTokenProgram)
|
|
16119
16436
|
};
|
|
16120
16437
|
}
|
|
16121
16438
|
async buildPreambleInstructions(args) {
|
|
16122
|
-
const payer = (0,
|
|
16123
|
-
const createVaultAssetAta = (0,
|
|
16439
|
+
const payer = (0, import_common31.toWeb3Pk)(args.user);
|
|
16440
|
+
const createVaultAssetAta = (0, import_spl_token10.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16124
16441
|
payer,
|
|
16125
|
-
(0,
|
|
16126
|
-
(0,
|
|
16127
|
-
(0,
|
|
16128
|
-
(0,
|
|
16129
|
-
|
|
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
|
|
16130
16447
|
);
|
|
16131
|
-
const createFeeVaultAta = (0,
|
|
16448
|
+
const createFeeVaultAta = (0, import_spl_token10.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16132
16449
|
payer,
|
|
16133
|
-
(0,
|
|
16134
|
-
(0,
|
|
16135
|
-
(0,
|
|
16136
|
-
(0,
|
|
16137
|
-
|
|
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
|
|
16138
16455
|
);
|
|
16139
|
-
const defaultUserShareAta = (0,
|
|
16456
|
+
const defaultUserShareAta = (0, import_common31.getAtaAddress)(
|
|
16140
16457
|
args.shareMint,
|
|
16141
16458
|
args.user,
|
|
16142
16459
|
args.shareTokenProgram
|
|
16143
16460
|
);
|
|
16144
|
-
const createUserShareAta = (0,
|
|
16145
|
-
(0,
|
|
16146
|
-
) ? (0,
|
|
16461
|
+
const createUserShareAta = (0, import_common31.toWeb3Pk)(args.userShareAta).equals(
|
|
16462
|
+
(0, import_common31.toWeb3Pk)(defaultUserShareAta)
|
|
16463
|
+
) ? (0, import_spl_token10.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16147
16464
|
payer,
|
|
16148
|
-
(0,
|
|
16465
|
+
(0, import_common31.toWeb3Pk)(args.userShareAta),
|
|
16149
16466
|
payer,
|
|
16150
|
-
(0,
|
|
16151
|
-
(0,
|
|
16152
|
-
|
|
16467
|
+
(0, import_common31.toWeb3Pk)(args.shareMint),
|
|
16468
|
+
(0, import_common31.toWeb3Pk)(args.shareTokenProgram),
|
|
16469
|
+
import_spl_token10.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16153
16470
|
) : null;
|
|
16154
|
-
return [createVaultAssetAta, createFeeVaultAta, createUserShareAta].filter((ix) => ix != null).map(
|
|
16471
|
+
return [createVaultAssetAta, createFeeVaultAta, createUserShareAta].filter((ix) => ix != null).map(import_common31.toKitInstruction);
|
|
16155
16472
|
}
|
|
16156
16473
|
async buildPlanExtras(args) {
|
|
16157
16474
|
return {
|
|
@@ -16171,28 +16488,28 @@ var ExecuteDepositBuilder = class extends VaultBuilderBase {
|
|
|
16171
16488
|
};
|
|
16172
16489
|
|
|
16173
16490
|
// src/client/builders/executeTrancheDeposit.ts
|
|
16174
|
-
var
|
|
16175
|
-
var
|
|
16176
|
-
var
|
|
16177
|
-
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());
|
|
16178
16495
|
var ExecuteTrancheDepositBuilder = class extends VaultBuilderBase {
|
|
16179
16496
|
getIxAccounts(args) {
|
|
16180
16497
|
return {
|
|
16181
|
-
user: (0,
|
|
16182
|
-
vault: (0,
|
|
16183
|
-
vaultOracle: (0,
|
|
16184
|
-
vaultTrancheState: (0,
|
|
16185
|
-
assetMint: (0,
|
|
16186
|
-
trancheShareMint: (0,
|
|
16187
|
-
userAssetAta: (0,
|
|
16188
|
-
vaultAssetAta: (0,
|
|
16189
|
-
feeVault: (0,
|
|
16190
|
-
feeVaultAta: (0,
|
|
16191
|
-
userTrancheShareAta: (0,
|
|
16192
|
-
assetTokenProgram: (0,
|
|
16193
|
-
shareTokenProgram: (0,
|
|
16194
|
-
associatedTokenProgram:
|
|
16195
|
-
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
|
|
16196
16513
|
};
|
|
16197
16514
|
}
|
|
16198
16515
|
getIxData(args) {
|
|
@@ -16211,7 +16528,7 @@ var ExecuteTrancheDepositBuilder = class extends VaultBuilderBase {
|
|
|
16211
16528
|
) : this.program.methods.executeTrancheDeposit(data.kind, data.amount);
|
|
16212
16529
|
return methods.accountsPartial(
|
|
16213
16530
|
this.getIxAccounts(args)
|
|
16214
|
-
).instruction().then(
|
|
16531
|
+
).instruction().then(import_common32.toKitInstruction);
|
|
16215
16532
|
}
|
|
16216
16533
|
async deriveIxArgs(txArgs) {
|
|
16217
16534
|
const connection = this.program.provider.connection;
|
|
@@ -16240,29 +16557,29 @@ var ExecuteTrancheDepositBuilder = class extends VaultBuilderBase {
|
|
|
16240
16557
|
assetMint: txArgs.assetMint,
|
|
16241
16558
|
trancheShareMint,
|
|
16242
16559
|
kind: txArgs.kind,
|
|
16243
|
-
amount: new
|
|
16560
|
+
amount: new import_core11.BN(txArgs.amount.toString()),
|
|
16244
16561
|
addressSeeds: txArgs.addressSeeds,
|
|
16245
16562
|
assetTokenProgram,
|
|
16246
16563
|
shareTokenProgram,
|
|
16247
|
-
userAssetAta: (0,
|
|
16564
|
+
userAssetAta: (0, import_common32.getAtaAddress)(
|
|
16248
16565
|
txArgs.assetMint,
|
|
16249
16566
|
txArgs.user,
|
|
16250
16567
|
assetTokenProgram
|
|
16251
16568
|
),
|
|
16252
|
-
vaultAssetAta: (0,
|
|
16569
|
+
vaultAssetAta: (0, import_common32.getAtaAddress)(
|
|
16253
16570
|
txArgs.assetMint,
|
|
16254
16571
|
txArgs.vault,
|
|
16255
16572
|
assetTokenProgram,
|
|
16256
16573
|
true
|
|
16257
16574
|
),
|
|
16258
16575
|
feeVault,
|
|
16259
|
-
feeVaultAta: (0,
|
|
16576
|
+
feeVaultAta: (0, import_common32.getAtaAddress)(
|
|
16260
16577
|
txArgs.assetMint,
|
|
16261
16578
|
feeVault,
|
|
16262
16579
|
assetTokenProgram,
|
|
16263
16580
|
true
|
|
16264
16581
|
),
|
|
16265
|
-
userTrancheShareAta: (0,
|
|
16582
|
+
userTrancheShareAta: (0, import_common32.getAtaAddress)(
|
|
16266
16583
|
trancheShareMint,
|
|
16267
16584
|
txArgs.user,
|
|
16268
16585
|
shareTokenProgram
|
|
@@ -16270,33 +16587,33 @@ var ExecuteTrancheDepositBuilder = class extends VaultBuilderBase {
|
|
|
16270
16587
|
};
|
|
16271
16588
|
}
|
|
16272
16589
|
async buildPreambleInstructions(args) {
|
|
16273
|
-
const payer = (0,
|
|
16274
|
-
const createVaultAssetAta = (0,
|
|
16590
|
+
const payer = (0, import_common32.toWeb3Pk)(args.user);
|
|
16591
|
+
const createVaultAssetAta = (0, import_spl_token11.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16275
16592
|
payer,
|
|
16276
|
-
(0,
|
|
16277
|
-
(0,
|
|
16278
|
-
(0,
|
|
16279
|
-
(0,
|
|
16280
|
-
|
|
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
|
|
16281
16598
|
);
|
|
16282
|
-
const createUserShareAta = (0,
|
|
16599
|
+
const createUserShareAta = (0, import_spl_token11.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16283
16600
|
payer,
|
|
16284
|
-
(0,
|
|
16601
|
+
(0, import_common32.toWeb3Pk)(args.userTrancheShareAta),
|
|
16285
16602
|
payer,
|
|
16286
|
-
(0,
|
|
16287
|
-
(0,
|
|
16288
|
-
|
|
16603
|
+
(0, import_common32.toWeb3Pk)(args.trancheShareMint),
|
|
16604
|
+
(0, import_common32.toWeb3Pk)(args.shareTokenProgram),
|
|
16605
|
+
import_spl_token11.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16289
16606
|
);
|
|
16290
|
-
const createFeeVaultAta = (0,
|
|
16607
|
+
const createFeeVaultAta = (0, import_spl_token11.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16291
16608
|
payer,
|
|
16292
|
-
(0,
|
|
16293
|
-
(0,
|
|
16294
|
-
(0,
|
|
16295
|
-
(0,
|
|
16296
|
-
|
|
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
|
|
16297
16614
|
);
|
|
16298
16615
|
return [createVaultAssetAta, createFeeVaultAta, createUserShareAta].map(
|
|
16299
|
-
|
|
16616
|
+
import_common32.toKitInstruction
|
|
16300
16617
|
);
|
|
16301
16618
|
}
|
|
16302
16619
|
async buildPlanExtras(args) {
|
|
@@ -16319,27 +16636,27 @@ var ExecuteTrancheDepositBuilder = class extends VaultBuilderBase {
|
|
|
16319
16636
|
};
|
|
16320
16637
|
|
|
16321
16638
|
// src/client/builders/executeTrancheWithdraw.ts
|
|
16322
|
-
var
|
|
16323
|
-
var
|
|
16324
|
-
var
|
|
16325
|
-
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());
|
|
16326
16643
|
|
|
16327
16644
|
// src/client/builders/externalLiquidity.ts
|
|
16328
16645
|
var import_kit7 = require("@solana/kit");
|
|
16329
|
-
var
|
|
16330
|
-
var
|
|
16646
|
+
var import_web315 = require("@solana/web3.js");
|
|
16647
|
+
var import_common33 = __toESM(require_dist());
|
|
16331
16648
|
var import_marginfi = __toESM(require_dist2());
|
|
16332
16649
|
function parseMarginfiSlot(slot) {
|
|
16333
16650
|
const data = slot?.data;
|
|
16334
16651
|
if (!data || data.length < 40) return null;
|
|
16335
16652
|
if (data[0] !== 1) return null;
|
|
16336
16653
|
const pubkeyBytes = new Uint8Array(data.slice(8, 40));
|
|
16337
|
-
const userAccount = new
|
|
16654
|
+
const userAccount = new import_web315.PublicKey(pubkeyBytes).toBase58();
|
|
16338
16655
|
return { userAccount };
|
|
16339
16656
|
}
|
|
16340
16657
|
function toWeb3AccountMeta(account) {
|
|
16341
16658
|
return {
|
|
16342
|
-
pubkey: new
|
|
16659
|
+
pubkey: new import_web315.PublicKey(account.address),
|
|
16343
16660
|
isWritable: account.role === import_kit7.AccountRole.WRITABLE || account.role === import_kit7.AccountRole.WRITABLE_SIGNER,
|
|
16344
16661
|
isSigner: account.role === import_kit7.AccountRole.READONLY_SIGNER || account.role === import_kit7.AccountRole.WRITABLE_SIGNER
|
|
16345
16662
|
};
|
|
@@ -16378,7 +16695,7 @@ function resolveExternalWithdraw({
|
|
|
16378
16695
|
};
|
|
16379
16696
|
}
|
|
16380
16697
|
const marginfiClient = new import_marginfi.CpiClient({ accounts: marginfiAccounts });
|
|
16381
|
-
const withdrawRefs = (0,
|
|
16698
|
+
const withdrawRefs = (0, import_common33.createCpiRefs)([
|
|
16382
16699
|
marginfiClient.withdraw_cpi({
|
|
16383
16700
|
marginfiAccount: slot0.userAccount,
|
|
16384
16701
|
authority: vault,
|
|
@@ -16398,14 +16715,14 @@ function buildMarginfiWithdrawInteraction(args) {
|
|
|
16398
16715
|
`No Marginfi market is configured for asset mint ${args.assetMint}`
|
|
16399
16716
|
);
|
|
16400
16717
|
}
|
|
16401
|
-
const vaultAssetAta = (0,
|
|
16718
|
+
const vaultAssetAta = (0, import_common33.getAtaAddress)(
|
|
16402
16719
|
args.assetMint,
|
|
16403
16720
|
args.vault,
|
|
16404
16721
|
marginfiAccounts.tokenProgram,
|
|
16405
16722
|
true
|
|
16406
16723
|
);
|
|
16407
16724
|
const marginfiClient = new import_marginfi.CpiClient({ accounts: marginfiAccounts });
|
|
16408
|
-
const withdraw = (0,
|
|
16725
|
+
const withdraw = (0, import_common33.createCpiRefs)([
|
|
16409
16726
|
marginfiClient.withdraw_cpi({
|
|
16410
16727
|
marginfiAccount: args.marginfiAccount,
|
|
16411
16728
|
authority: args.vault,
|
|
@@ -16429,19 +16746,19 @@ function buildMarginfiWithdrawInteraction(args) {
|
|
|
16429
16746
|
var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
16430
16747
|
getIxAccounts(args) {
|
|
16431
16748
|
return {
|
|
16432
|
-
user: (0,
|
|
16433
|
-
vault: (0,
|
|
16434
|
-
vaultOracle: (0,
|
|
16435
|
-
vaultTrancheState: (0,
|
|
16436
|
-
assetMint: (0,
|
|
16437
|
-
trancheShareMint: (0,
|
|
16438
|
-
userAssetAta: (0,
|
|
16439
|
-
vaultAssetAta: (0,
|
|
16440
|
-
userTrancheShareAta: (0,
|
|
16441
|
-
assetTokenProgram: (0,
|
|
16442
|
-
shareTokenProgram: (0,
|
|
16443
|
-
associatedTokenProgram:
|
|
16444
|
-
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
|
|
16445
16762
|
};
|
|
16446
16763
|
}
|
|
16447
16764
|
getIxData(args) {
|
|
@@ -16478,7 +16795,7 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16478
16795
|
);
|
|
16479
16796
|
return methods.accountsPartial(
|
|
16480
16797
|
this.getIxAccounts(args)
|
|
16481
|
-
).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(
|
|
16798
|
+
).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(import_common34.toKitInstruction);
|
|
16482
16799
|
}
|
|
16483
16800
|
async deriveIxArgs(txArgs) {
|
|
16484
16801
|
const connection = this.program.provider.connection;
|
|
@@ -16499,7 +16816,7 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16499
16816
|
txArgs.assetTokenProgram
|
|
16500
16817
|
);
|
|
16501
16818
|
const { mint: trancheShareMint, tokenProgram: shareTokenProgram } = trancheShare;
|
|
16502
|
-
const vaultAssetAta = (0,
|
|
16819
|
+
const vaultAssetAta = (0, import_common34.getAtaAddress)(
|
|
16503
16820
|
txArgs.assetMint,
|
|
16504
16821
|
txArgs.vault,
|
|
16505
16822
|
assetTokenProgram,
|
|
@@ -16524,17 +16841,17 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16524
16841
|
assetMint: txArgs.assetMint,
|
|
16525
16842
|
trancheShareMint,
|
|
16526
16843
|
kind: txArgs.kind,
|
|
16527
|
-
shareAmount: new
|
|
16844
|
+
shareAmount: new import_core12.BN(txArgs.shareAmount.toString()),
|
|
16528
16845
|
addressSeeds: txArgs.addressSeeds,
|
|
16529
16846
|
assetTokenProgram,
|
|
16530
16847
|
shareTokenProgram,
|
|
16531
|
-
userAssetAta: (0,
|
|
16848
|
+
userAssetAta: (0, import_common34.getAtaAddress)(
|
|
16532
16849
|
txArgs.assetMint,
|
|
16533
16850
|
txArgs.user,
|
|
16534
16851
|
assetTokenProgram
|
|
16535
16852
|
),
|
|
16536
16853
|
vaultAssetAta,
|
|
16537
|
-
userTrancheShareAta: (0,
|
|
16854
|
+
userTrancheShareAta: (0, import_common34.getAtaAddress)(
|
|
16538
16855
|
trancheShareMint,
|
|
16539
16856
|
txArgs.user,
|
|
16540
16857
|
shareTokenProgram
|
|
@@ -16548,16 +16865,16 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16548
16865
|
return txArgs.lookupTables;
|
|
16549
16866
|
}
|
|
16550
16867
|
async buildPreambleInstructions(args) {
|
|
16551
|
-
const payer = (0,
|
|
16552
|
-
const createUserAssetAta = (0,
|
|
16868
|
+
const payer = (0, import_common34.toWeb3Pk)(args.user);
|
|
16869
|
+
const createUserAssetAta = (0, import_spl_token12.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16553
16870
|
payer,
|
|
16554
|
-
(0,
|
|
16871
|
+
(0, import_common34.toWeb3Pk)(args.userAssetAta),
|
|
16555
16872
|
payer,
|
|
16556
|
-
(0,
|
|
16557
|
-
(0,
|
|
16558
|
-
|
|
16873
|
+
(0, import_common34.toWeb3Pk)(args.assetMint),
|
|
16874
|
+
(0, import_common34.toWeb3Pk)(args.assetTokenProgram),
|
|
16875
|
+
import_spl_token12.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16559
16876
|
);
|
|
16560
|
-
return [createUserAssetAta].map(
|
|
16877
|
+
return [createUserAssetAta].map(import_common34.toKitInstruction);
|
|
16561
16878
|
}
|
|
16562
16879
|
async buildPlanExtras(args) {
|
|
16563
16880
|
return {
|
|
@@ -16569,25 +16886,25 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16569
16886
|
};
|
|
16570
16887
|
|
|
16571
16888
|
// src/client/builders/executeWithdraw.ts
|
|
16572
|
-
var
|
|
16573
|
-
var
|
|
16574
|
-
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());
|
|
16575
16892
|
var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
16576
16893
|
getIxAccounts(args) {
|
|
16577
16894
|
return {
|
|
16578
|
-
user: (0,
|
|
16579
|
-
vault: (0,
|
|
16580
|
-
vaultOracle: (0,
|
|
16581
|
-
vaultTrancheState: args.vaultTrancheState ? (0,
|
|
16582
|
-
assetMint: (0,
|
|
16583
|
-
shareMint: (0,
|
|
16584
|
-
userAssetAta: (0,
|
|
16585
|
-
vaultAssetAta: (0,
|
|
16586
|
-
feeVault: (0,
|
|
16587
|
-
feeVaultAta: (0,
|
|
16588
|
-
userShareAta: (0,
|
|
16589
|
-
assetTokenProgram: (0,
|
|
16590
|
-
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)
|
|
16591
16908
|
};
|
|
16592
16909
|
}
|
|
16593
16910
|
getIxData(args) {
|
|
@@ -16617,7 +16934,7 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16617
16934
|
) : this.program.methods.executeWithdraw(data.shareAmount);
|
|
16618
16935
|
return methods.accountsPartial(
|
|
16619
16936
|
this.getIxAccounts(args)
|
|
16620
|
-
).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(
|
|
16937
|
+
).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(import_common35.toKitInstruction);
|
|
16621
16938
|
}
|
|
16622
16939
|
async deriveIxArgs(txArgs) {
|
|
16623
16940
|
const connection = this.program.provider.connection;
|
|
@@ -16651,7 +16968,7 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16651
16968
|
),
|
|
16652
16969
|
this.account.fetchVault(txArgs.vault)
|
|
16653
16970
|
]);
|
|
16654
|
-
const vaultAssetAta = (0,
|
|
16971
|
+
const vaultAssetAta = (0, import_common35.getAtaAddress)(
|
|
16655
16972
|
txArgs.assetMint,
|
|
16656
16973
|
txArgs.vault,
|
|
16657
16974
|
assetTokenProgram,
|
|
@@ -16675,19 +16992,19 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16675
16992
|
vaultTrancheState: vaultTrancheState ?? null,
|
|
16676
16993
|
assetMint: txArgs.assetMint,
|
|
16677
16994
|
shareMint: txArgs.shareMint,
|
|
16678
|
-
shareAmount: new
|
|
16995
|
+
shareAmount: new import_core13.BN(txArgs.shareAmount.toString()),
|
|
16679
16996
|
assetTokenProgram,
|
|
16680
16997
|
shareTokenProgram,
|
|
16681
|
-
userAssetAta: txArgs.userAssetAta ?? (0,
|
|
16998
|
+
userAssetAta: txArgs.userAssetAta ?? (0, import_common35.getAtaAddress)(txArgs.assetMint, txArgs.user, assetTokenProgram),
|
|
16682
16999
|
vaultAssetAta,
|
|
16683
17000
|
feeVault,
|
|
16684
|
-
feeVaultAta: (0,
|
|
17001
|
+
feeVaultAta: (0, import_common35.getAtaAddress)(
|
|
16685
17002
|
txArgs.assetMint,
|
|
16686
17003
|
feeVault,
|
|
16687
17004
|
assetTokenProgram,
|
|
16688
17005
|
true
|
|
16689
17006
|
),
|
|
16690
|
-
userShareAta: txArgs.userShareAta ?? (0,
|
|
17007
|
+
userShareAta: txArgs.userShareAta ?? (0, import_common35.getAtaAddress)(txArgs.shareMint, txArgs.user, shareTokenProgram),
|
|
16691
17008
|
externalWithdrawIxRefs,
|
|
16692
17009
|
externalLiquiditySource,
|
|
16693
17010
|
externalWithdrawAccounts,
|
|
@@ -16698,31 +17015,31 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16698
17015
|
return txArgs.lookupTables;
|
|
16699
17016
|
}
|
|
16700
17017
|
async buildPreambleInstructions(args) {
|
|
16701
|
-
const defaultUserAssetAta = (0,
|
|
17018
|
+
const defaultUserAssetAta = (0, import_common35.getAtaAddress)(
|
|
16702
17019
|
args.assetMint,
|
|
16703
17020
|
args.user,
|
|
16704
17021
|
args.assetTokenProgram
|
|
16705
17022
|
);
|
|
16706
|
-
const payer = (0,
|
|
16707
|
-
const createUserAssetAta = (0,
|
|
16708
|
-
(0,
|
|
16709
|
-
) ? (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)(
|
|
16710
17027
|
payer,
|
|
16711
|
-
(0,
|
|
17028
|
+
(0, import_common35.toWeb3Pk)(args.userAssetAta),
|
|
16712
17029
|
payer,
|
|
16713
|
-
(0,
|
|
16714
|
-
(0,
|
|
16715
|
-
|
|
17030
|
+
(0, import_common35.toWeb3Pk)(args.assetMint),
|
|
17031
|
+
(0, import_common35.toWeb3Pk)(args.assetTokenProgram),
|
|
17032
|
+
import_spl_token13.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16716
17033
|
) : null;
|
|
16717
|
-
const createFeeVaultAta = (0,
|
|
17034
|
+
const createFeeVaultAta = (0, import_spl_token13.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16718
17035
|
payer,
|
|
16719
|
-
(0,
|
|
16720
|
-
(0,
|
|
16721
|
-
(0,
|
|
16722
|
-
(0,
|
|
16723
|
-
|
|
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
|
|
16724
17041
|
);
|
|
16725
|
-
return [createUserAssetAta, createFeeVaultAta].filter((ix) => ix != null).map(
|
|
17042
|
+
return [createUserAssetAta, createFeeVaultAta].filter((ix) => ix != null).map(import_common35.toKitInstruction);
|
|
16726
17043
|
}
|
|
16727
17044
|
async buildPlanExtras(args) {
|
|
16728
17045
|
return {
|
|
@@ -16732,9 +17049,9 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16732
17049
|
};
|
|
16733
17050
|
|
|
16734
17051
|
// src/client/builders/fulfillJuniorTrancheWithdraw.ts
|
|
16735
|
-
var
|
|
16736
|
-
var
|
|
16737
|
-
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());
|
|
16738
17055
|
var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
16739
17056
|
async getIx(args) {
|
|
16740
17057
|
const externalWithdrawIxRefs = args.externalWithdrawIxRefs ?? null;
|
|
@@ -16748,24 +17065,24 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16748
17065
|
externalLiquiditySource
|
|
16749
17066
|
);
|
|
16750
17067
|
return methods.accountsPartial({
|
|
16751
|
-
signer: (0,
|
|
16752
|
-
owner: (0,
|
|
16753
|
-
queuePayer: (0,
|
|
16754
|
-
vault: (0,
|
|
16755
|
-
vaultOracle: (0,
|
|
16756
|
-
vaultTrancheState: (0,
|
|
16757
|
-
withdrawalQueue: (0,
|
|
16758
|
-
outputMint: (0,
|
|
16759
|
-
inputMint: (0,
|
|
16760
|
-
ownerInputAta: (0,
|
|
16761
|
-
ownerOutputAta: (0,
|
|
16762
|
-
vaultOutputAta: (0,
|
|
16763
|
-
queueInputAta: (0,
|
|
16764
|
-
assetTokenProgram: (0,
|
|
16765
|
-
shareTokenProgram: (0,
|
|
16766
|
-
associatedTokenProgram:
|
|
16767
|
-
systemProgram:
|
|
16768
|
-
}).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);
|
|
16769
17086
|
}
|
|
16770
17087
|
async deriveIxArgs(txArgs) {
|
|
16771
17088
|
const connection = this.program.provider.connection;
|
|
@@ -16806,7 +17123,7 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16806
17123
|
]);
|
|
16807
17124
|
const { mint: juniorShareMint, tokenProgram: shareTokenProgram } = juniorShare;
|
|
16808
17125
|
const queuePda = txArgs.withdrawalQueue ?? withdrawalQueue;
|
|
16809
|
-
const vaultOutputAta = (0,
|
|
17126
|
+
const vaultOutputAta = (0, import_common36.getAtaAddress)(
|
|
16810
17127
|
txArgs.assetMint,
|
|
16811
17128
|
txArgs.vault,
|
|
16812
17129
|
assetTokenProgram,
|
|
@@ -16835,14 +17152,14 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16835
17152
|
inputMint: juniorShareMint,
|
|
16836
17153
|
assetTokenProgram,
|
|
16837
17154
|
shareTokenProgram,
|
|
16838
|
-
ownerInputAta: txArgs.ownerInputAta ?? (0,
|
|
16839
|
-
ownerOutputAta: (0,
|
|
17155
|
+
ownerInputAta: txArgs.ownerInputAta ?? (0, import_common36.getAtaAddress)(juniorShareMint, txArgs.owner, shareTokenProgram),
|
|
17156
|
+
ownerOutputAta: (0, import_common36.getAtaAddress)(
|
|
16840
17157
|
txArgs.assetMint,
|
|
16841
17158
|
txArgs.owner,
|
|
16842
17159
|
assetTokenProgram
|
|
16843
17160
|
),
|
|
16844
17161
|
vaultOutputAta,
|
|
16845
|
-
queueInputAta: (0,
|
|
17162
|
+
queueInputAta: (0, import_common36.getAtaAddress)(
|
|
16846
17163
|
juniorShareMint,
|
|
16847
17164
|
queuePda,
|
|
16848
17165
|
shareTokenProgram,
|
|
@@ -16858,23 +17175,23 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16858
17175
|
return txArgs.lookupTables;
|
|
16859
17176
|
}
|
|
16860
17177
|
async buildPreambleInstructions(args) {
|
|
16861
|
-
const defaultOwnerInputAta = (0,
|
|
17178
|
+
const defaultOwnerInputAta = (0, import_common36.getAtaAddress)(
|
|
16862
17179
|
args.inputMint,
|
|
16863
17180
|
args.owner,
|
|
16864
17181
|
args.shareTokenProgram
|
|
16865
17182
|
);
|
|
16866
|
-
if (!(0,
|
|
17183
|
+
if (!(0, import_common36.toWeb3Pk)(args.ownerInputAta).equals((0, import_common36.toWeb3Pk)(defaultOwnerInputAta))) {
|
|
16867
17184
|
return [];
|
|
16868
17185
|
}
|
|
16869
17186
|
return [
|
|
16870
|
-
(0,
|
|
16871
|
-
(0,
|
|
16872
|
-
(0,
|
|
16873
|
-
(0,
|
|
16874
|
-
(0,
|
|
16875
|
-
(0,
|
|
16876
|
-
(0,
|
|
16877
|
-
|
|
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
|
|
16878
17195
|
)
|
|
16879
17196
|
)
|
|
16880
17197
|
];
|
|
@@ -16893,8 +17210,8 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16893
17210
|
};
|
|
16894
17211
|
|
|
16895
17212
|
// src/client/builders/updateTrancheConfig.ts
|
|
16896
|
-
var
|
|
16897
|
-
var
|
|
17213
|
+
var import_core14 = require("@anchor-lang/core");
|
|
17214
|
+
var import_common37 = __toESM(require_dist());
|
|
16898
17215
|
var UpdateTrancheConfigBuilder = class extends VaultBuilderBase {
|
|
16899
17216
|
async getIx(args) {
|
|
16900
17217
|
return this.program.methods.vaultUpdateTrancheConfig({
|
|
@@ -16905,11 +17222,11 @@ var UpdateTrancheConfigBuilder = class extends VaultBuilderBase {
|
|
|
16905
17222
|
targetLockupDurationSecs: args.targetLockupDurationSecs,
|
|
16906
17223
|
juniorDepositCap: args.juniorDepositCap
|
|
16907
17224
|
}).accountsPartial({
|
|
16908
|
-
curator: (0,
|
|
16909
|
-
vault: (0,
|
|
16910
|
-
vaultTrancheState: (0,
|
|
16911
|
-
vaultOracle: (0,
|
|
16912
|
-
}).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);
|
|
16913
17230
|
}
|
|
16914
17231
|
async deriveIxArgs(txArgs) {
|
|
16915
17232
|
const [vaultTrancheState] = await this.pda.deriveVaultTrancheStatePda(
|
|
@@ -16925,8 +17242,8 @@ var UpdateTrancheConfigBuilder = class extends VaultBuilderBase {
|
|
|
16925
17242
|
juniorFloorApyBps: txArgs.juniorFloorApyBps ?? null,
|
|
16926
17243
|
earlyUnstakeFeeBps: txArgs.earlyUnstakeFeeBps ?? null,
|
|
16927
17244
|
standardUnstakeFeeBps: txArgs.standardUnstakeFeeBps ?? null,
|
|
16928
|
-
targetLockupDurationSecs: txArgs.targetLockupDurationSecs === void 0 ? null : new
|
|
16929
|
-
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())
|
|
16930
17247
|
};
|
|
16931
17248
|
}
|
|
16932
17249
|
async buildPlanExtras(args) {
|
|
@@ -16939,25 +17256,25 @@ var UpdateTrancheConfigBuilder = class extends VaultBuilderBase {
|
|
|
16939
17256
|
};
|
|
16940
17257
|
|
|
16941
17258
|
// src/client/builders/managerRedepositAsset.ts
|
|
16942
|
-
var
|
|
16943
|
-
var
|
|
16944
|
-
var
|
|
16945
|
-
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());
|
|
16946
17263
|
var ManagerRedepositAssetBuilder = class extends VaultBuilderBase {
|
|
16947
17264
|
async getIx(args) {
|
|
16948
17265
|
return this.program.methods.managerRedepositAsset({
|
|
16949
17266
|
depositAmount: args.depositAmount,
|
|
16950
17267
|
externalAmount: args.externalAmount
|
|
16951
17268
|
}).accountsPartial({
|
|
16952
|
-
manager: (0,
|
|
16953
|
-
vault: (0,
|
|
16954
|
-
assetMint: (0,
|
|
16955
|
-
vaultAssetAta: (0,
|
|
16956
|
-
managerAssetAta: (0,
|
|
16957
|
-
assetTokenProgram: (0,
|
|
16958
|
-
associatedTokenProgram:
|
|
16959
|
-
systemProgram:
|
|
16960
|
-
}).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);
|
|
16961
17278
|
}
|
|
16962
17279
|
async deriveIxArgs(txArgs) {
|
|
16963
17280
|
const connection = this.program.provider.connection;
|
|
@@ -16971,10 +17288,10 @@ var ManagerRedepositAssetBuilder = class extends VaultBuilderBase {
|
|
|
16971
17288
|
manager: txArgs.manager,
|
|
16972
17289
|
vault: txArgs.vault,
|
|
16973
17290
|
assetMint: txArgs.assetMint,
|
|
16974
|
-
depositAmount: new
|
|
16975
|
-
externalAmount: new
|
|
17291
|
+
depositAmount: new import_core15.BN(txArgs.depositAmount.toString()),
|
|
17292
|
+
externalAmount: new import_core15.BN(externalAmount.toString()),
|
|
16976
17293
|
assetTokenProgram,
|
|
16977
|
-
vaultAssetAta: (0,
|
|
17294
|
+
vaultAssetAta: (0, import_common38.getAtaAddress)(
|
|
16978
17295
|
txArgs.assetMint,
|
|
16979
17296
|
txArgs.vault,
|
|
16980
17297
|
assetTokenProgram,
|
|
@@ -16982,7 +17299,7 @@ var ManagerRedepositAssetBuilder = class extends VaultBuilderBase {
|
|
|
16982
17299
|
),
|
|
16983
17300
|
// The manager may be a PDA (e.g. a Squads vault), so allow off-curve
|
|
16984
17301
|
// owners when deriving its ATA.
|
|
16985
|
-
managerAssetAta: (0,
|
|
17302
|
+
managerAssetAta: (0, import_common38.getAtaAddress)(
|
|
16986
17303
|
txArgs.assetMint,
|
|
16987
17304
|
txArgs.manager,
|
|
16988
17305
|
assetTokenProgram,
|
|
@@ -16998,23 +17315,23 @@ var ManagerRedepositAssetBuilder = class extends VaultBuilderBase {
|
|
|
16998
17315
|
};
|
|
16999
17316
|
|
|
17000
17317
|
// src/client/builders/managerWithdrawAsset.ts
|
|
17001
|
-
var
|
|
17002
|
-
var
|
|
17003
|
-
var
|
|
17004
|
-
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());
|
|
17005
17322
|
var ManagerWithdrawAssetBuilder = class extends VaultBuilderBase {
|
|
17006
17323
|
async getIx(args) {
|
|
17007
17324
|
return this.program.methods.managerWithdrawAsset(args.amount).accountsPartial({
|
|
17008
|
-
manager: (0,
|
|
17009
|
-
vault: (0,
|
|
17010
|
-
assetMint: (0,
|
|
17011
|
-
vaultAssetAta: (0,
|
|
17012
|
-
destination: (0,
|
|
17013
|
-
destinationAssetAta: (0,
|
|
17014
|
-
assetTokenProgram: (0,
|
|
17015
|
-
associatedTokenProgram:
|
|
17016
|
-
systemProgram:
|
|
17017
|
-
}).instruction().then(
|
|
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);
|
|
17018
17335
|
}
|
|
17019
17336
|
async deriveIxArgs(txArgs) {
|
|
17020
17337
|
const connection = this.program.provider.connection;
|
|
@@ -17029,15 +17346,15 @@ var ManagerWithdrawAssetBuilder = class extends VaultBuilderBase {
|
|
|
17029
17346
|
vault: txArgs.vault,
|
|
17030
17347
|
assetMint: txArgs.assetMint,
|
|
17031
17348
|
destination,
|
|
17032
|
-
amount: new
|
|
17349
|
+
amount: new import_core16.BN(txArgs.amount.toString()),
|
|
17033
17350
|
assetTokenProgram,
|
|
17034
|
-
vaultAssetAta: (0,
|
|
17351
|
+
vaultAssetAta: (0, import_common39.getAtaAddress)(
|
|
17035
17352
|
txArgs.assetMint,
|
|
17036
17353
|
txArgs.vault,
|
|
17037
17354
|
assetTokenProgram,
|
|
17038
17355
|
true
|
|
17039
17356
|
),
|
|
17040
|
-
destinationAssetAta: (0,
|
|
17357
|
+
destinationAssetAta: (0, import_common39.getAtaAddress)(
|
|
17041
17358
|
txArgs.assetMint,
|
|
17042
17359
|
destination,
|
|
17043
17360
|
assetTokenProgram,
|
|
@@ -17054,18 +17371,18 @@ var ManagerWithdrawAssetBuilder = class extends VaultBuilderBase {
|
|
|
17054
17371
|
};
|
|
17055
17372
|
|
|
17056
17373
|
// src/client/builders/protocolInteraction.ts
|
|
17057
|
-
var
|
|
17374
|
+
var import_core17 = require("@anchor-lang/core");
|
|
17058
17375
|
var import_kit8 = require("@solana/kit");
|
|
17059
|
-
var
|
|
17060
|
-
var
|
|
17061
|
-
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());
|
|
17062
17379
|
var DEFAULT_PYTH_PRICE_MAX_AGE_SECS = 90n;
|
|
17063
17380
|
function toAssetPriceOracleConfig(args) {
|
|
17064
17381
|
return {
|
|
17065
17382
|
priceOracleType: args?.priceOracleType ?? { none: {} },
|
|
17066
|
-
initialPrice: new
|
|
17383
|
+
initialPrice: new import_core17.BN((args?.initialPrice ?? 0n).toString()),
|
|
17067
17384
|
priceOracleAccount: args?.priceOracleAccount ?? DEFAULT_PRICE_ORACLE_ACCOUNT,
|
|
17068
|
-
pythMaxAgeSecs: new
|
|
17385
|
+
pythMaxAgeSecs: new import_core17.BN(
|
|
17069
17386
|
(args?.pythMaxAgeSecs ?? DEFAULT_PYTH_PRICE_MAX_AGE_SECS).toString()
|
|
17070
17387
|
)
|
|
17071
17388
|
};
|
|
@@ -17073,12 +17390,12 @@ function toAssetPriceOracleConfig(args) {
|
|
|
17073
17390
|
function toAnchorAssetPriceOracleConfig(config) {
|
|
17074
17391
|
return {
|
|
17075
17392
|
...config,
|
|
17076
|
-
priceOracleAccount: (0,
|
|
17393
|
+
priceOracleAccount: (0, import_common40.toWeb3Pk)(config.priceOracleAccount)
|
|
17077
17394
|
};
|
|
17078
17395
|
}
|
|
17079
17396
|
function toWeb3AccountMeta2(account) {
|
|
17080
17397
|
return {
|
|
17081
|
-
pubkey: new
|
|
17398
|
+
pubkey: new import_web320.PublicKey(account.address),
|
|
17082
17399
|
isWritable: account.role === import_kit8.AccountRole.WRITABLE || account.role === import_kit8.AccountRole.WRITABLE_SIGNER,
|
|
17083
17400
|
isSigner: account.role === import_kit8.AccountRole.READONLY_SIGNER || account.role === import_kit8.AccountRole.WRITABLE_SIGNER
|
|
17084
17401
|
};
|
|
@@ -17087,14 +17404,14 @@ var ProtocolInteractionBuilder = class extends VaultBuilderBase {
|
|
|
17087
17404
|
async getIx(args) {
|
|
17088
17405
|
return this.program.methods.protocolInteraction(args.refs, {
|
|
17089
17406
|
externalLiquidityIndex: args.externalLiquidityIndex,
|
|
17090
|
-
affectedAssetMint: args.affectedAssetMint ? (0,
|
|
17407
|
+
affectedAssetMint: args.affectedAssetMint ? (0, import_common40.toWeb3Pk)(args.affectedAssetMint) : null
|
|
17091
17408
|
}).accountsPartial({
|
|
17092
|
-
hwManager: (0,
|
|
17093
|
-
vault: (0,
|
|
17094
|
-
affectedAssetMint: args.affectedAssetMint ? (0,
|
|
17095
|
-
affectedVaultAta: args.affectedVaultAta ? (0,
|
|
17096
|
-
affectedTokenProgram: args.affectedTokenProgram ? (0,
|
|
17097
|
-
}).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);
|
|
17098
17415
|
}
|
|
17099
17416
|
async deriveIxArgs(txArgs) {
|
|
17100
17417
|
const affectedTokenProgram = txArgs.affectedAssetMint ? txArgs.affectedTokenProgram ?? TOKEN_PROGRAM_ID : null;
|
|
@@ -17106,7 +17423,7 @@ var ProtocolInteractionBuilder = class extends VaultBuilderBase {
|
|
|
17106
17423
|
accounts: txArgs.accounts,
|
|
17107
17424
|
affectedAssetMint: txArgs.affectedAssetMint ?? null,
|
|
17108
17425
|
affectedTokenProgram,
|
|
17109
|
-
affectedVaultAta: txArgs.affectedAssetMint && affectedTokenProgram ? (0,
|
|
17426
|
+
affectedVaultAta: txArgs.affectedAssetMint && affectedTokenProgram ? (0, import_common40.getAtaAddress)(
|
|
17110
17427
|
txArgs.affectedAssetMint,
|
|
17111
17428
|
txArgs.vault,
|
|
17112
17429
|
affectedTokenProgram,
|
|
@@ -17125,18 +17442,18 @@ var JupiterSwapBuilder = class extends VaultBuilderBase {
|
|
|
17125
17442
|
args.destinationPriceOracle
|
|
17126
17443
|
)
|
|
17127
17444
|
}).accountsPartial({
|
|
17128
|
-
hwManager: (0,
|
|
17129
|
-
vault: (0,
|
|
17130
|
-
sourceMint: (0,
|
|
17131
|
-
destinationMint: (0,
|
|
17132
|
-
vaultSourceAta: (0,
|
|
17133
|
-
vaultDestinationAta: (0,
|
|
17134
|
-
sourceTokenProgram: (0,
|
|
17135
|
-
destinationTokenProgram: (0,
|
|
17136
|
-
destinationOracleAccount: args.destinationOracleAccount ? (0,
|
|
17137
|
-
vaultOracle: (0,
|
|
17138
|
-
vaultTrancheState: args.vaultTrancheState ? (0,
|
|
17139
|
-
}).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);
|
|
17140
17457
|
}
|
|
17141
17458
|
async deriveIxArgs(txArgs) {
|
|
17142
17459
|
const sourceTokenProgram = txArgs.sourceTokenProgram ?? TOKEN_PROGRAM_ID;
|
|
@@ -17157,13 +17474,13 @@ var JupiterSwapBuilder = class extends VaultBuilderBase {
|
|
|
17157
17474
|
accounts: txArgs.accounts,
|
|
17158
17475
|
sourceTokenProgram,
|
|
17159
17476
|
destinationTokenProgram,
|
|
17160
|
-
vaultSourceAta: (0,
|
|
17477
|
+
vaultSourceAta: (0, import_common40.getAtaAddress)(
|
|
17161
17478
|
txArgs.sourceMint,
|
|
17162
17479
|
txArgs.vault,
|
|
17163
17480
|
sourceTokenProgram,
|
|
17164
17481
|
true
|
|
17165
17482
|
),
|
|
17166
|
-
vaultDestinationAta: (0,
|
|
17483
|
+
vaultDestinationAta: (0, import_common40.getAtaAddress)(
|
|
17167
17484
|
txArgs.destinationMint,
|
|
17168
17485
|
txArgs.vault,
|
|
17169
17486
|
destinationTokenProgram,
|
|
@@ -17172,24 +17489,24 @@ var JupiterSwapBuilder = class extends VaultBuilderBase {
|
|
|
17172
17489
|
};
|
|
17173
17490
|
}
|
|
17174
17491
|
async buildPreambleInstructions(args) {
|
|
17175
|
-
const payer = (0,
|
|
17176
|
-
const createSourceAta = (0,
|
|
17492
|
+
const payer = (0, import_common40.toWeb3Pk)(args.hwManager);
|
|
17493
|
+
const createSourceAta = (0, import_spl_token17.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17177
17494
|
payer,
|
|
17178
|
-
(0,
|
|
17179
|
-
(0,
|
|
17180
|
-
(0,
|
|
17181
|
-
(0,
|
|
17182
|
-
|
|
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
|
|
17183
17500
|
);
|
|
17184
|
-
const createDestinationAta = (0,
|
|
17501
|
+
const createDestinationAta = (0, import_spl_token17.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17185
17502
|
payer,
|
|
17186
|
-
(0,
|
|
17187
|
-
(0,
|
|
17188
|
-
(0,
|
|
17189
|
-
(0,
|
|
17190
|
-
|
|
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
|
|
17191
17508
|
);
|
|
17192
|
-
return [createSourceAta, createDestinationAta].map(
|
|
17509
|
+
return [createSourceAta, createDestinationAta].map(import_common40.toKitInstruction);
|
|
17193
17510
|
}
|
|
17194
17511
|
async buildLookupTables(_args, txArgs) {
|
|
17195
17512
|
return txArgs.lookupTables;
|
|
@@ -17222,27 +17539,27 @@ var JupiterSwapBuilder = class extends VaultBuilderBase {
|
|
|
17222
17539
|
};
|
|
17223
17540
|
|
|
17224
17541
|
// src/client/builders/requestJuniorTrancheWithdraw.ts
|
|
17225
|
-
var
|
|
17226
|
-
var
|
|
17227
|
-
var
|
|
17228
|
-
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());
|
|
17229
17546
|
var RequestJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
17230
17547
|
async getIx(args) {
|
|
17231
17548
|
return this.program.methods.requestJuniorTrancheWithdraw(args.queueId, args.shareAmount).accountsPartial({
|
|
17232
|
-
user: (0,
|
|
17233
|
-
payer: (0,
|
|
17234
|
-
vault: (0,
|
|
17235
|
-
vaultOracle: (0,
|
|
17236
|
-
vaultTrancheState: (0,
|
|
17237
|
-
withdrawalQueue: (0,
|
|
17238
|
-
outputMint: (0,
|
|
17239
|
-
inputMint: (0,
|
|
17240
|
-
userInputAta: (0,
|
|
17241
|
-
queueInputAta: (0,
|
|
17242
|
-
shareTokenProgram: (0,
|
|
17243
|
-
associatedTokenProgram:
|
|
17244
|
-
systemProgram:
|
|
17245
|
-
}).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);
|
|
17246
17563
|
}
|
|
17247
17564
|
async deriveIxArgs(txArgs) {
|
|
17248
17565
|
const payer = txArgs.payer ?? txArgs.user;
|
|
@@ -17276,10 +17593,10 @@ var RequestJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
17276
17593
|
outputMint: txArgs.assetMint,
|
|
17277
17594
|
inputMint: juniorShareMint,
|
|
17278
17595
|
queueId: txArgs.queueId,
|
|
17279
|
-
shareAmount: new
|
|
17596
|
+
shareAmount: new import_core18.BN(txArgs.shareAmount.toString()),
|
|
17280
17597
|
shareTokenProgram,
|
|
17281
|
-
userInputAta: txArgs.userInputAta ?? (0,
|
|
17282
|
-
queueInputAta: (0,
|
|
17598
|
+
userInputAta: txArgs.userInputAta ?? (0, import_common41.getAtaAddress)(juniorShareMint, txArgs.user, shareTokenProgram),
|
|
17599
|
+
queueInputAta: (0, import_common41.getAtaAddress)(
|
|
17283
17600
|
juniorShareMint,
|
|
17284
17601
|
queuePda,
|
|
17285
17602
|
shareTokenProgram,
|
|
@@ -17301,17 +17618,17 @@ var RequestJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
17301
17618
|
};
|
|
17302
17619
|
|
|
17303
17620
|
// src/client/builders/vaultReallocation.ts
|
|
17304
|
-
var
|
|
17305
|
-
var
|
|
17306
|
-
var
|
|
17307
|
-
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());
|
|
17308
17625
|
var DEFAULT_PYTH_PRICE_MAX_AGE_SECS2 = 90n;
|
|
17309
17626
|
function toAssetPriceOracleConfig2(args) {
|
|
17310
17627
|
return {
|
|
17311
17628
|
priceOracleType: args?.priceOracleType ?? { none: {} },
|
|
17312
|
-
initialPrice: new
|
|
17629
|
+
initialPrice: new import_core19.BN((args?.initialPrice ?? 0n).toString()),
|
|
17313
17630
|
priceOracleAccount: args?.priceOracleAccount ?? DEFAULT_PRICE_ORACLE_ACCOUNT,
|
|
17314
|
-
pythMaxAgeSecs: new
|
|
17631
|
+
pythMaxAgeSecs: new import_core19.BN(
|
|
17315
17632
|
(args?.pythMaxAgeSecs ?? DEFAULT_PYTH_PRICE_MAX_AGE_SECS2).toString()
|
|
17316
17633
|
)
|
|
17317
17634
|
};
|
|
@@ -17319,7 +17636,7 @@ function toAssetPriceOracleConfig2(args) {
|
|
|
17319
17636
|
function toAnchorAssetPriceOracleConfig2(config) {
|
|
17320
17637
|
return {
|
|
17321
17638
|
...config,
|
|
17322
|
-
priceOracleAccount: (0,
|
|
17639
|
+
priceOracleAccount: (0, import_common42.toWeb3Pk)(config.priceOracleAccount)
|
|
17323
17640
|
};
|
|
17324
17641
|
}
|
|
17325
17642
|
var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
@@ -17328,35 +17645,35 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
17328
17645
|
amount: args.amount,
|
|
17329
17646
|
assetPriceOracle: toAnchorAssetPriceOracleConfig2(args.assetPriceOracle)
|
|
17330
17647
|
}).accountsPartial({
|
|
17331
|
-
manager: (0,
|
|
17332
|
-
allocationVault: (0,
|
|
17333
|
-
sourceVault: args.sourceVault ? (0,
|
|
17334
|
-
sourceVaultOracle: args.sourceVaultOracle ? (0,
|
|
17335
|
-
destinationVault: (0,
|
|
17336
|
-
destinationVaultOracle: (0,
|
|
17337
|
-
mint: (0,
|
|
17338
|
-
sourceShareMint: args.sourceShareMint ? (0,
|
|
17339
|
-
destinationShareMint: (0,
|
|
17340
|
-
allocationMintAta: (0,
|
|
17341
|
-
sourceVaultMintAta: args.sourceVaultMintAta ? (0,
|
|
17342
|
-
destinationVaultMintAta: (0,
|
|
17343
|
-
destinationFeeVault: (0,
|
|
17344
|
-
destinationFeeVaultMintAta: (0,
|
|
17345
|
-
allocationSourceShareAta: args.allocationSourceShareAta ? (0,
|
|
17346
|
-
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)(
|
|
17347
17664
|
args.allocationDestinationShareAta
|
|
17348
17665
|
),
|
|
17349
|
-
sourceVaultTrancheState: args.sourceVaultTrancheState ? (0,
|
|
17350
|
-
destinationVaultTrancheState: args.destinationVaultTrancheState ? (0,
|
|
17351
|
-
assetOracleAccount: args.assetOracleAccount ? (0,
|
|
17352
|
-
assetTokenProgram: (0,
|
|
17353
|
-
sourceShareTokenProgram: (0,
|
|
17354
|
-
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)(
|
|
17355
17672
|
args.destinationShareTokenProgram
|
|
17356
17673
|
),
|
|
17357
|
-
associatedTokenProgram:
|
|
17358
|
-
systemProgram:
|
|
17359
|
-
}).instruction().then(
|
|
17674
|
+
associatedTokenProgram: import_spl_token19.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
17675
|
+
systemProgram: import_web322.SystemProgram.programId
|
|
17676
|
+
}).instruction().then(import_common42.toKitInstruction);
|
|
17360
17677
|
}
|
|
17361
17678
|
async deriveIxArgs(txArgs) {
|
|
17362
17679
|
const assetTokenProgram = txArgs.assetTokenProgram ?? TOKEN_PROGRAM_ID;
|
|
@@ -17381,7 +17698,7 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
17381
17698
|
mint: txArgs.mint,
|
|
17382
17699
|
sourceShareMint,
|
|
17383
17700
|
destinationShareMint: txArgs.destinationShareMint,
|
|
17384
|
-
amount: new
|
|
17701
|
+
amount: new import_core19.BN(txArgs.amount.toString()),
|
|
17385
17702
|
assetPriceOracle: toAssetPriceOracleConfig2(txArgs.assetPriceOracle),
|
|
17386
17703
|
sourceVaultTrancheState: txArgs.sourceVaultTrancheState ?? null,
|
|
17387
17704
|
destinationVaultTrancheState: txArgs.destinationVaultTrancheState ?? null,
|
|
@@ -17389,33 +17706,33 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
17389
17706
|
assetTokenProgram,
|
|
17390
17707
|
sourceShareTokenProgram,
|
|
17391
17708
|
destinationShareTokenProgram,
|
|
17392
|
-
allocationMintAta: (0,
|
|
17709
|
+
allocationMintAta: (0, import_common42.getAtaAddress)(
|
|
17393
17710
|
txArgs.mint,
|
|
17394
17711
|
txArgs.allocationVault,
|
|
17395
17712
|
assetTokenProgram,
|
|
17396
17713
|
true
|
|
17397
17714
|
),
|
|
17398
|
-
sourceVaultMintAta: sourceVault ? (0,
|
|
17399
|
-
destinationVaultMintAta: (0,
|
|
17715
|
+
sourceVaultMintAta: sourceVault ? (0, import_common42.getAtaAddress)(txArgs.mint, sourceVault, assetTokenProgram, true) : null,
|
|
17716
|
+
destinationVaultMintAta: (0, import_common42.getAtaAddress)(
|
|
17400
17717
|
txArgs.mint,
|
|
17401
17718
|
txArgs.destinationVault,
|
|
17402
17719
|
assetTokenProgram,
|
|
17403
17720
|
true
|
|
17404
17721
|
),
|
|
17405
17722
|
destinationFeeVault,
|
|
17406
|
-
destinationFeeVaultMintAta: (0,
|
|
17723
|
+
destinationFeeVaultMintAta: (0, import_common42.getAtaAddress)(
|
|
17407
17724
|
txArgs.mint,
|
|
17408
17725
|
destinationFeeVault,
|
|
17409
17726
|
assetTokenProgram,
|
|
17410
17727
|
true
|
|
17411
17728
|
),
|
|
17412
|
-
allocationSourceShareAta: sourceShareMint && sourceVault ? (0,
|
|
17729
|
+
allocationSourceShareAta: sourceShareMint && sourceVault ? (0, import_common42.getAtaAddress)(
|
|
17413
17730
|
sourceShareMint,
|
|
17414
17731
|
txArgs.allocationVault,
|
|
17415
17732
|
sourceShareTokenProgram,
|
|
17416
17733
|
true
|
|
17417
17734
|
) : null,
|
|
17418
|
-
allocationDestinationShareAta: (0,
|
|
17735
|
+
allocationDestinationShareAta: (0, import_common42.getAtaAddress)(
|
|
17419
17736
|
txArgs.destinationShareMint,
|
|
17420
17737
|
txArgs.allocationVault,
|
|
17421
17738
|
destinationShareTokenProgram,
|
|
@@ -17424,62 +17741,62 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
17424
17741
|
};
|
|
17425
17742
|
}
|
|
17426
17743
|
async buildPreambleInstructions(args) {
|
|
17427
|
-
const payer = (0,
|
|
17744
|
+
const payer = (0, import_common42.toWeb3Pk)(args.manager);
|
|
17428
17745
|
const instructions2 = [
|
|
17429
|
-
(0,
|
|
17746
|
+
(0, import_spl_token19.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17430
17747
|
payer,
|
|
17431
|
-
(0,
|
|
17432
|
-
(0,
|
|
17433
|
-
(0,
|
|
17434
|
-
(0,
|
|
17435
|
-
|
|
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
|
|
17436
17753
|
),
|
|
17437
|
-
(0,
|
|
17754
|
+
(0, import_spl_token19.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17438
17755
|
payer,
|
|
17439
|
-
(0,
|
|
17440
|
-
(0,
|
|
17441
|
-
(0,
|
|
17442
|
-
(0,
|
|
17443
|
-
|
|
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
|
|
17444
17761
|
),
|
|
17445
|
-
(0,
|
|
17762
|
+
(0, import_spl_token19.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17446
17763
|
payer,
|
|
17447
|
-
(0,
|
|
17448
|
-
(0,
|
|
17449
|
-
(0,
|
|
17450
|
-
(0,
|
|
17451
|
-
|
|
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
|
|
17452
17769
|
),
|
|
17453
|
-
(0,
|
|
17770
|
+
(0, import_spl_token19.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17454
17771
|
payer,
|
|
17455
|
-
(0,
|
|
17456
|
-
(0,
|
|
17457
|
-
(0,
|
|
17458
|
-
(0,
|
|
17459
|
-
|
|
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
|
|
17460
17777
|
)
|
|
17461
17778
|
];
|
|
17462
17779
|
if (args.sourceVault && args.sourceShareMint && args.sourceVaultMintAta && args.allocationSourceShareAta) {
|
|
17463
17780
|
instructions2.push(
|
|
17464
|
-
(0,
|
|
17781
|
+
(0, import_spl_token19.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17465
17782
|
payer,
|
|
17466
|
-
(0,
|
|
17467
|
-
(0,
|
|
17468
|
-
(0,
|
|
17469
|
-
(0,
|
|
17470
|
-
|
|
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
|
|
17471
17788
|
),
|
|
17472
|
-
(0,
|
|
17789
|
+
(0, import_spl_token19.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17473
17790
|
payer,
|
|
17474
|
-
(0,
|
|
17475
|
-
(0,
|
|
17476
|
-
(0,
|
|
17477
|
-
(0,
|
|
17478
|
-
|
|
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
|
|
17479
17796
|
)
|
|
17480
17797
|
);
|
|
17481
17798
|
}
|
|
17482
|
-
return instructions2.map(
|
|
17799
|
+
return instructions2.map(import_common42.toKitInstruction);
|
|
17483
17800
|
}
|
|
17484
17801
|
async buildPlanExtras(args) {
|
|
17485
17802
|
return {
|
|
@@ -17517,6 +17834,7 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
17517
17834
|
// src/client/transaction.ts
|
|
17518
17835
|
var TransactionClient = class {
|
|
17519
17836
|
constructor(context) {
|
|
17837
|
+
this.depositCuratorFees = new DepositCuratorFeesBuilder(context);
|
|
17520
17838
|
this.createIncentiveV3 = new CreateIncentiveV3Builder(context);
|
|
17521
17839
|
this.addIncentiveRecipientV3 = new AddIncentiveRecipientV3Builder(context);
|
|
17522
17840
|
this.setIncentiveLimitsV3 = new SetIncentiveLimitsV3Builder(context);
|
|
@@ -17577,7 +17895,7 @@ var VaultClient = class {
|
|
|
17577
17895
|
this.provider = provider;
|
|
17578
17896
|
this.skipSimulation = options.skipSimulation ?? false;
|
|
17579
17897
|
const idl = { ...IDL, address: programId };
|
|
17580
|
-
this.program = new
|
|
17898
|
+
this.program = new import_core20.Program(idl, provider);
|
|
17581
17899
|
this.pda = new PdaClient((0, import_kit9.address)(this.program.programId.toBase58()));
|
|
17582
17900
|
const rpc = createRpcFromConnection(provider.connection);
|
|
17583
17901
|
this.account = new AccountClient(this.program, this.pda, rpc);
|
|
@@ -17599,8 +17917,8 @@ var VaultClient = class {
|
|
|
17599
17917
|
*/
|
|
17600
17918
|
async sendTransaction(payer, plan, extraSigners = []) {
|
|
17601
17919
|
const { blockhash, lastValidBlockHeight } = await this.provider.connection.getLatestBlockhash("confirmed");
|
|
17602
|
-
const tx = new
|
|
17603
|
-
...plan.instructions.map(
|
|
17920
|
+
const tx = new import_web323.Transaction().add(
|
|
17921
|
+
...plan.instructions.map(import_common43.fromKitInstruction)
|
|
17604
17922
|
);
|
|
17605
17923
|
tx.feePayer = payer.publicKey;
|
|
17606
17924
|
tx.recentBlockhash = blockhash;
|
|
@@ -17634,13 +17952,13 @@ var VaultClient = class {
|
|
|
17634
17952
|
const { blockhash } = await this.provider.connection.getLatestBlockhash(
|
|
17635
17953
|
"confirmed"
|
|
17636
17954
|
);
|
|
17637
|
-
const lookupTableAccounts = plan.lookupTables?.length ? await (0,
|
|
17638
|
-
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({
|
|
17639
17957
|
payerKey: payer.publicKey,
|
|
17640
17958
|
recentBlockhash: blockhash,
|
|
17641
|
-
instructions: plan.instructions.map(
|
|
17959
|
+
instructions: plan.instructions.map(import_common43.fromKitInstruction)
|
|
17642
17960
|
}).compileToV0Message(lookupTableAccounts);
|
|
17643
|
-
const tx = new
|
|
17961
|
+
const tx = new import_web323.VersionedTransaction(message2);
|
|
17644
17962
|
const result = await this.provider.connection.simulateTransaction(tx, {
|
|
17645
17963
|
sigVerify: false,
|
|
17646
17964
|
commitment: "processed"
|
|
@@ -17714,7 +18032,7 @@ function resolveKeypairPath(keypairPath) {
|
|
|
17714
18032
|
}
|
|
17715
18033
|
function loadKeypair(keypairPath) {
|
|
17716
18034
|
const raw = import_fs.default.readFileSync(resolveKeypairPath(keypairPath), "utf-8");
|
|
17717
|
-
return
|
|
18035
|
+
return import_web324.Keypair.fromSecretKey(new Uint8Array(JSON.parse(raw)));
|
|
17718
18036
|
}
|
|
17719
18037
|
var ENV_AGNOSTIC_ROLES = /* @__PURE__ */ new Set(["fulfiller", "rebalancer"]);
|
|
17720
18038
|
function defaultKeypairPath(env, role = "vault") {
|
|
@@ -17725,8 +18043,8 @@ function defaultKeypairPath(env, role = "vault") {
|
|
|
17725
18043
|
}
|
|
17726
18044
|
function createVaultClient(env, opts = {}) {
|
|
17727
18045
|
const payer = opts.keypair ?? loadKeypair(opts.keypairPath ?? defaultKeypairPath(env, opts.role));
|
|
17728
|
-
const connection = new
|
|
17729
|
-
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), {
|
|
17730
18048
|
commitment: "confirmed"
|
|
17731
18049
|
});
|
|
17732
18050
|
const client = new VaultClient(
|
|
@@ -17739,11 +18057,11 @@ function createVaultClient(env, opts = {}) {
|
|
|
17739
18057
|
client,
|
|
17740
18058
|
provider,
|
|
17741
18059
|
payer,
|
|
17742
|
-
signer: (0,
|
|
18060
|
+
signer: (0, import_common44.fromWeb3Pk)(payer.publicKey)
|
|
17743
18061
|
};
|
|
17744
18062
|
}
|
|
17745
18063
|
function keypairAddress(keypairPath) {
|
|
17746
|
-
return (0,
|
|
18064
|
+
return (0, import_common44.fromWeb3Pk)(loadKeypair(keypairPath).publicKey);
|
|
17747
18065
|
}
|
|
17748
18066
|
|
|
17749
18067
|
// src/utils/math.ts
|
|
@@ -17757,16 +18075,16 @@ function fromUiAmount(amount, decimals) {
|
|
|
17757
18075
|
}
|
|
17758
18076
|
|
|
17759
18077
|
// src/utils/provider.ts
|
|
17760
|
-
var
|
|
18078
|
+
var import_core22 = require("@anchor-lang/core");
|
|
17761
18079
|
function makeProvider(connection, payer) {
|
|
17762
|
-
return new
|
|
18080
|
+
return new import_core22.AnchorProvider(connection, new import_core22.Wallet(payer), {
|
|
17763
18081
|
commitment: "confirmed"
|
|
17764
18082
|
});
|
|
17765
18083
|
}
|
|
17766
18084
|
|
|
17767
18085
|
// src/utils/squads.ts
|
|
17768
18086
|
var squads = __toESM(require("@sqds/multisig"));
|
|
17769
|
-
var
|
|
18087
|
+
var import_web325 = require("@solana/web3.js");
|
|
17770
18088
|
var SQUADS_SIMULATION_COMMITMENT = "processed";
|
|
17771
18089
|
var SquadsProposalExecutionSimulationError = class extends Error {
|
|
17772
18090
|
constructor(transactionError, logs, unitsConsumed) {
|
|
@@ -17790,8 +18108,8 @@ function validateVaultIndex(vaultIndex) {
|
|
|
17790
18108
|
}
|
|
17791
18109
|
function resolveSquadsWalletRoute(route) {
|
|
17792
18110
|
validateVaultIndex(route.vaultIndex);
|
|
17793
|
-
const wallet = new
|
|
17794
|
-
const multisigPda = new
|
|
18111
|
+
const wallet = new import_web325.PublicKey(route.wallet);
|
|
18112
|
+
const multisigPda = new import_web325.PublicKey(route.multisigPda);
|
|
17795
18113
|
const [vaultPda] = squads.getVaultPda({
|
|
17796
18114
|
multisigPda,
|
|
17797
18115
|
index: route.vaultIndex
|
|
@@ -17799,7 +18117,7 @@ function resolveSquadsWalletRoute(route) {
|
|
|
17799
18117
|
return { ...route, wallet, multisigPda, vaultPda };
|
|
17800
18118
|
}
|
|
17801
18119
|
function findSquadsWalletRoute(wallet, routes) {
|
|
17802
|
-
const walletKey = typeof wallet === "string" ? new
|
|
18120
|
+
const walletKey = typeof wallet === "string" ? new import_web325.PublicKey(wallet) : wallet;
|
|
17803
18121
|
const route = routes.find(
|
|
17804
18122
|
(candidate) => candidate.wallet === walletKey.toBase58()
|
|
17805
18123
|
);
|
|
@@ -17817,18 +18135,18 @@ function validateSquadsWalletRoutes(routes) {
|
|
|
17817
18135
|
}
|
|
17818
18136
|
}
|
|
17819
18137
|
function vaultAuthorityForWallet(wallet, routes) {
|
|
17820
|
-
const walletKey = typeof wallet === "string" ? new
|
|
18138
|
+
const walletKey = typeof wallet === "string" ? new import_web325.PublicKey(wallet) : wallet;
|
|
17821
18139
|
return findSquadsWalletRoute(walletKey, routes)?.vaultPda ?? walletKey;
|
|
17822
18140
|
}
|
|
17823
18141
|
async function simulateSquadsProposalExecution(args) {
|
|
17824
18142
|
const { connection, feePayer, instructions: instructions2 } = args;
|
|
17825
18143
|
const recentBlockhash = args.recentBlockhash ?? (await connection.getLatestBlockhash(SQUADS_SIMULATION_COMMITMENT)).blockhash;
|
|
17826
|
-
const message2 = new
|
|
18144
|
+
const message2 = new import_web325.TransactionMessage({
|
|
17827
18145
|
payerKey: feePayer,
|
|
17828
18146
|
recentBlockhash,
|
|
17829
18147
|
instructions: [...instructions2]
|
|
17830
18148
|
}).compileToV0Message(args.addressLookupTableAccounts);
|
|
17831
|
-
const transaction = new
|
|
18149
|
+
const transaction = new import_web325.VersionedTransaction(message2);
|
|
17832
18150
|
const { value } = await connection.simulateTransaction(transaction, {
|
|
17833
18151
|
sigVerify: false,
|
|
17834
18152
|
commitment: SQUADS_SIMULATION_COMMITMENT,
|
|
@@ -17853,7 +18171,7 @@ async function prepareVaultTransaction(args) {
|
|
|
17853
18171
|
throw new Error("Ephemeral signers require a Squads route");
|
|
17854
18172
|
return {
|
|
17855
18173
|
kind: "direct",
|
|
17856
|
-
transaction: new
|
|
18174
|
+
transaction: new import_web325.Transaction().add(...instructions2),
|
|
17857
18175
|
authority: proposer
|
|
17858
18176
|
};
|
|
17859
18177
|
}
|
|
@@ -17906,7 +18224,7 @@ async function prepareVaultTransaction(args) {
|
|
|
17906
18224
|
});
|
|
17907
18225
|
if (replacements.size) {
|
|
17908
18226
|
instructions2 = instructions2.map(
|
|
17909
|
-
(ix) => new
|
|
18227
|
+
(ix) => new import_web325.TransactionInstruction({
|
|
17910
18228
|
programId: ix.programId,
|
|
17911
18229
|
data: ix.data,
|
|
17912
18230
|
keys: ix.keys.map((meta) => ({
|
|
@@ -17926,7 +18244,7 @@ async function prepareVaultTransaction(args) {
|
|
|
17926
18244
|
addressLookupTableAccounts: args.addressLookupTableAccounts
|
|
17927
18245
|
});
|
|
17928
18246
|
}
|
|
17929
|
-
const transactionMessage = new
|
|
18247
|
+
const transactionMessage = new import_web325.TransactionMessage({
|
|
17930
18248
|
payerKey: route.vaultPda,
|
|
17931
18249
|
recentBlockhash: blockhash,
|
|
17932
18250
|
instructions: [...instructions2]
|
|
@@ -17956,7 +18274,7 @@ async function prepareVaultTransaction(args) {
|
|
|
17956
18274
|
});
|
|
17957
18275
|
return {
|
|
17958
18276
|
kind: "squads",
|
|
17959
|
-
transaction: new
|
|
18277
|
+
transaction: new import_web325.Transaction().add(
|
|
17960
18278
|
createVaultTransactionIx,
|
|
17961
18279
|
createProposalIx
|
|
17962
18280
|
),
|
|
@@ -17971,16 +18289,16 @@ async function prepareVaultTransaction(args) {
|
|
|
17971
18289
|
|
|
17972
18290
|
// src/utils/squadsBuffer.ts
|
|
17973
18291
|
var squads2 = __toESM(require("@sqds/multisig"));
|
|
17974
|
-
var
|
|
18292
|
+
var import_web326 = require("@solana/web3.js");
|
|
17975
18293
|
var PacketSize = 1232;
|
|
17976
18294
|
var BufferChunkSize = 700;
|
|
17977
18295
|
var MaxBufferSize = 4e3;
|
|
17978
18296
|
async function prepareSquadsProposalUpload(args) {
|
|
17979
18297
|
const { connection, proposer, prepared } = args;
|
|
17980
18298
|
const transaction = prepared.transaction;
|
|
17981
|
-
const sizeProbe = new
|
|
18299
|
+
const sizeProbe = new import_web326.Transaction({
|
|
17982
18300
|
feePayer: proposer,
|
|
17983
|
-
recentBlockhash:
|
|
18301
|
+
recentBlockhash: import_web326.PublicKey.default.toBase58()
|
|
17984
18302
|
}).add(...transaction.instructions);
|
|
17985
18303
|
let fits = false;
|
|
17986
18304
|
try {
|
|
@@ -18000,7 +18318,7 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
18000
18318
|
let bufferPda;
|
|
18001
18319
|
let bufferIndex = 0;
|
|
18002
18320
|
for (; bufferIndex <= 255; bufferIndex++) {
|
|
18003
|
-
const [candidate] =
|
|
18321
|
+
const [candidate] = import_web326.PublicKey.findProgramAddressSync(
|
|
18004
18322
|
[
|
|
18005
18323
|
Buffer.from("multisig"),
|
|
18006
18324
|
prepared.multisigPda.toBuffer(),
|
|
@@ -18028,7 +18346,7 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
18028
18346
|
creator: proposer
|
|
18029
18347
|
};
|
|
18030
18348
|
const setupTransactions = [
|
|
18031
|
-
new
|
|
18349
|
+
new import_web326.Transaction().add(
|
|
18032
18350
|
squads2.generated.createTransactionBufferCreateInstruction(
|
|
18033
18351
|
{
|
|
18034
18352
|
...accounts2,
|
|
@@ -18048,7 +18366,7 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
18048
18366
|
];
|
|
18049
18367
|
for (let offset = BufferChunkSize; offset < bytes.length; offset += BufferChunkSize) {
|
|
18050
18368
|
setupTransactions.push(
|
|
18051
|
-
new
|
|
18369
|
+
new import_web326.Transaction().add(
|
|
18052
18370
|
squads2.generated.createTransactionBufferExtendInstruction(accounts2, {
|
|
18053
18371
|
args: { buffer: bytes.slice(offset, offset + BufferChunkSize) }
|
|
18054
18372
|
})
|
|
@@ -18061,7 +18379,7 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
18061
18379
|
vaultTransactionCreateItemTransaction: prepared.vaultTransactionPda,
|
|
18062
18380
|
vaultTransactionCreateItemCreator: proposer,
|
|
18063
18381
|
vaultTransactionCreateItemRentPayer: proposer,
|
|
18064
|
-
vaultTransactionCreateItemSystemProgram:
|
|
18382
|
+
vaultTransactionCreateItemSystemProgram: import_web326.SystemProgram.programId,
|
|
18065
18383
|
transactionBuffer: bufferPda,
|
|
18066
18384
|
creator: proposer
|
|
18067
18385
|
},
|
|
@@ -18073,7 +18391,7 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
18073
18391
|
).isWritable = true;
|
|
18074
18392
|
return {
|
|
18075
18393
|
setupTransactions,
|
|
18076
|
-
proposalTransaction: new
|
|
18394
|
+
proposalTransaction: new import_web326.Transaction().add(
|
|
18077
18395
|
finalize,
|
|
18078
18396
|
...transaction.instructions.slice(1)
|
|
18079
18397
|
),
|
|
@@ -18083,21 +18401,21 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
18083
18401
|
}
|
|
18084
18402
|
|
|
18085
18403
|
// src/utils/token.ts
|
|
18086
|
-
var
|
|
18087
|
-
var
|
|
18088
|
-
var
|
|
18089
|
-
async function createTokenMintIxs(connection, payer, authority, decimals, tokenProgram =
|
|
18090
|
-
const mint =
|
|
18091
|
-
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);
|
|
18092
18410
|
const ixs = [
|
|
18093
|
-
|
|
18411
|
+
import_web327.SystemProgram.createAccount({
|
|
18094
18412
|
fromPubkey: payer,
|
|
18095
18413
|
newAccountPubkey: mint.publicKey,
|
|
18096
|
-
space:
|
|
18414
|
+
space: import_spl_token20.MINT_SIZE,
|
|
18097
18415
|
lamports,
|
|
18098
18416
|
programId: tokenProgram
|
|
18099
18417
|
}),
|
|
18100
|
-
(0,
|
|
18418
|
+
(0, import_spl_token20.createInitializeMint2Instruction)(
|
|
18101
18419
|
mint.publicKey,
|
|
18102
18420
|
decimals,
|
|
18103
18421
|
authority,
|
|
@@ -18107,7 +18425,7 @@ async function createTokenMintIxs(connection, payer, authority, decimals, tokenP
|
|
|
18107
18425
|
];
|
|
18108
18426
|
return { mint, ixs };
|
|
18109
18427
|
}
|
|
18110
|
-
async function createTokenMint(connection, payer, decimals, tokenProgram =
|
|
18428
|
+
async function createTokenMint(connection, payer, decimals, tokenProgram = import_spl_token20.TOKEN_2022_PROGRAM_ID) {
|
|
18111
18429
|
const { mint, ixs } = await createTokenMintIxs(
|
|
18112
18430
|
connection,
|
|
18113
18431
|
payer.publicKey,
|
|
@@ -18116,7 +18434,7 @@ async function createTokenMint(connection, payer, decimals, tokenProgram = impor
|
|
|
18116
18434
|
tokenProgram
|
|
18117
18435
|
);
|
|
18118
18436
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
|
|
18119
|
-
const tx = new
|
|
18437
|
+
const tx = new import_web327.Transaction().add(...ixs);
|
|
18120
18438
|
tx.feePayer = payer.publicKey;
|
|
18121
18439
|
tx.recentBlockhash = blockhash;
|
|
18122
18440
|
tx.sign(payer, mint);
|
|
@@ -18129,24 +18447,24 @@ async function createTokenMint(connection, payer, decimals, tokenProgram = impor
|
|
|
18129
18447
|
);
|
|
18130
18448
|
return mint.publicKey;
|
|
18131
18449
|
}
|
|
18132
|
-
async function mintTokensTo(connection, payer, mint, destination, amount, tokenProgram =
|
|
18133
|
-
const tokenProgramPk = (0,
|
|
18134
|
-
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)(
|
|
18135
18453
|
mint,
|
|
18136
18454
|
destination,
|
|
18137
18455
|
allowOwnerOffCurve,
|
|
18138
18456
|
tokenProgramPk
|
|
18139
18457
|
);
|
|
18140
18458
|
const ixs = [
|
|
18141
|
-
(0,
|
|
18459
|
+
(0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
|
|
18142
18460
|
payer.publicKey,
|
|
18143
18461
|
ata,
|
|
18144
18462
|
destination,
|
|
18145
18463
|
mint,
|
|
18146
18464
|
tokenProgramPk,
|
|
18147
|
-
|
|
18465
|
+
import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
18148
18466
|
),
|
|
18149
|
-
(0,
|
|
18467
|
+
(0, import_spl_token20.createMintToInstruction)(
|
|
18150
18468
|
mint,
|
|
18151
18469
|
ata,
|
|
18152
18470
|
payer.publicKey,
|
|
@@ -18155,12 +18473,12 @@ async function mintTokensTo(connection, payer, mint, destination, amount, tokenP
|
|
|
18155
18473
|
tokenProgramPk
|
|
18156
18474
|
)
|
|
18157
18475
|
];
|
|
18158
|
-
const tx = new
|
|
18476
|
+
const tx = new import_web327.Transaction().add(...ixs);
|
|
18159
18477
|
await connection.sendTransaction(tx, [payer]);
|
|
18160
18478
|
}
|
|
18161
18479
|
|
|
18162
18480
|
// src/utils/yieldApi.ts
|
|
18163
|
-
var
|
|
18481
|
+
var import_core23 = require("@anchor-lang/core");
|
|
18164
18482
|
var YIELD_API_BASE = process.env.YIELD_API_BASE ?? "https://yield-tracker.perena.org";
|
|
18165
18483
|
async function yieldApiReq(endpoint, reqType, bodyData, options) {
|
|
18166
18484
|
const headers = {
|
|
@@ -18486,7 +18804,7 @@ async function getTrackedValue(accountName) {
|
|
|
18486
18804
|
return trackedValueFromResponse(await getYield(accountName));
|
|
18487
18805
|
}
|
|
18488
18806
|
async function getTotalYield(accountNames, start, end) {
|
|
18489
|
-
let totalYield = new
|
|
18807
|
+
let totalYield = new import_core23.BN(0);
|
|
18490
18808
|
for (const accountName of accountNames) {
|
|
18491
18809
|
const res = await getYield(accountName, start, end);
|
|
18492
18810
|
if (isNavAccountValue(res)) {
|
|
@@ -18495,7 +18813,7 @@ async function getTotalYield(accountNames, start, end) {
|
|
|
18495
18813
|
);
|
|
18496
18814
|
}
|
|
18497
18815
|
console.log(res);
|
|
18498
|
-
totalYield = totalYield.add(new
|
|
18816
|
+
totalYield = totalYield.add(new import_core23.BN(res.total_yield));
|
|
18499
18817
|
}
|
|
18500
18818
|
return totalYield;
|
|
18501
18819
|
}
|
|
@@ -18512,7 +18830,7 @@ async function getTotalOutstandingYield(accountNames, start, end) {
|
|
|
18512
18830
|
}
|
|
18513
18831
|
return total;
|
|
18514
18832
|
}
|
|
18515
|
-
async function getTotalTrackedValue(accountNames, start, end) {
|
|
18833
|
+
async function getTotalTrackedValue(accountNames, start, end, onAccountValue) {
|
|
18516
18834
|
let totalValue = 0;
|
|
18517
18835
|
let principal = 0;
|
|
18518
18836
|
let outstandingYield = 0;
|
|
@@ -18522,12 +18840,13 @@ async function getTotalTrackedValue(accountNames, start, end) {
|
|
|
18522
18840
|
totalValue += tracked.totalValue;
|
|
18523
18841
|
principal += tracked.principal;
|
|
18524
18842
|
outstandingYield += tracked.outstandingYield;
|
|
18843
|
+
onAccountValue?.(accountName, tracked);
|
|
18525
18844
|
}
|
|
18526
18845
|
return { totalValue, principal, outstandingYield };
|
|
18527
18846
|
}
|
|
18528
18847
|
|
|
18529
18848
|
// src/services/withdrawalQueueService.ts
|
|
18530
|
-
var
|
|
18849
|
+
var import_common46 = __toESM(require_dist());
|
|
18531
18850
|
function bnToBigInt(value) {
|
|
18532
18851
|
return BigInt(value.toString());
|
|
18533
18852
|
}
|
|
@@ -18548,7 +18867,7 @@ var WithdrawalQueueService = class {
|
|
|
18548
18867
|
const program = this.client.program.account;
|
|
18549
18868
|
const accounts2 = await program.vaultWithdrawalQueue.all();
|
|
18550
18869
|
return accounts2.map(
|
|
18551
|
-
(entry) => this.toSnapshot((0,
|
|
18870
|
+
(entry) => this.toSnapshot((0, import_common46.fromWeb3Pk)(entry.publicKey), entry.account)
|
|
18552
18871
|
);
|
|
18553
18872
|
}
|
|
18554
18873
|
/** Withdrawal queues for a single vault. */
|
|
@@ -18589,7 +18908,7 @@ var WithdrawalQueueService = class {
|
|
|
18589
18908
|
async fulfill(signer, queue) {
|
|
18590
18909
|
const plan = await this.client.tx.fulfillJuniorTrancheWithdraw.getTx({
|
|
18591
18910
|
owner: queue.owner,
|
|
18592
|
-
signer: (0,
|
|
18911
|
+
signer: (0, import_common46.fromWeb3Pk)(signer.publicKey),
|
|
18593
18912
|
queuePayer: queue.payer,
|
|
18594
18913
|
vault: queue.vault,
|
|
18595
18914
|
withdrawalQueue: queue.pda,
|
|
@@ -18643,12 +18962,12 @@ var WithdrawalQueueService = class {
|
|
|
18643
18962
|
const a = account;
|
|
18644
18963
|
return {
|
|
18645
18964
|
pda,
|
|
18646
|
-
vault: (0,
|
|
18647
|
-
owner: (0,
|
|
18648
|
-
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),
|
|
18649
18968
|
queueId: a.header.queueId,
|
|
18650
|
-
inputMint: (0,
|
|
18651
|
-
outputMint: (0,
|
|
18969
|
+
inputMint: (0, import_common46.fromWeb3Pk)(a.mints.inputMint),
|
|
18970
|
+
outputMint: (0, import_common46.fromWeb3Pk)(a.mints.outputMint),
|
|
18652
18971
|
inputAmount: bnToBigInt(a.request.inputAmount),
|
|
18653
18972
|
requestTs: bnToNumber(a.request.requestTs),
|
|
18654
18973
|
expiryTs: bnToNumber(a.request.expiryTs)
|
|
@@ -18658,7 +18977,7 @@ var WithdrawalQueueService = class {
|
|
|
18658
18977
|
|
|
18659
18978
|
// src/services/oracleService.ts
|
|
18660
18979
|
var import_kit11 = require("@solana/kit");
|
|
18661
|
-
var
|
|
18980
|
+
var import_common47 = __toESM(require_dist());
|
|
18662
18981
|
var SYSTEM_PROGRAM2 = "11111111111111111111111111111111";
|
|
18663
18982
|
var DEFAULT_PRICE_STALENESS_THRESHOLD_SECS2 = 86400n;
|
|
18664
18983
|
var PRICE_ORACLE_TYPES_BY_INDEX2 = [
|
|
@@ -18722,7 +19041,7 @@ var OracleService = class {
|
|
|
18722
19041
|
*/
|
|
18723
19042
|
async updateAssetConsensusPrice(signer, args, log) {
|
|
18724
19043
|
const plan = await this.client.tx.updateConsensusOracle.getTx({
|
|
18725
|
-
signer: (0,
|
|
19044
|
+
signer: (0, import_common47.fromWeb3Pk)(signer.publicKey),
|
|
18726
19045
|
vault: args.vault,
|
|
18727
19046
|
updates: args.updates,
|
|
18728
19047
|
assetMint: args.assetMint,
|
|
@@ -18738,7 +19057,7 @@ var OracleService = class {
|
|
|
18738
19057
|
/** Settle the vault NAV from its current holdings (permissionless). */
|
|
18739
19058
|
async crankNav(cranker, args, log) {
|
|
18740
19059
|
const plan = await this.client.tx.crankNav.getTx({
|
|
18741
|
-
cranker: (0,
|
|
19060
|
+
cranker: (0, import_common47.fromWeb3Pk)(cranker.publicKey),
|
|
18742
19061
|
vault: args.vault,
|
|
18743
19062
|
vaultTrancheState: args.vaultTrancheState
|
|
18744
19063
|
});
|
|
@@ -18811,7 +19130,7 @@ var OracleService = class {
|
|
|
18811
19130
|
/** Re-price one live-oracle holding from its bound Pyth/nested-vault account. */
|
|
18812
19131
|
async refreshAssetPrice(updater, args, log) {
|
|
18813
19132
|
const plan = await this.client.tx.updateAssetPrice.getTx({
|
|
18814
|
-
updater: (0,
|
|
19133
|
+
updater: (0, import_common47.fromWeb3Pk)(updater.publicKey),
|
|
18815
19134
|
vault: args.vault,
|
|
18816
19135
|
mint: args.mint,
|
|
18817
19136
|
oracleAccount: args.oracleAccount,
|
|
@@ -18907,11 +19226,11 @@ function toBigInt2(value) {
|
|
|
18907
19226
|
}
|
|
18908
19227
|
|
|
18909
19228
|
// src/services/consensusOracle/utils/holdings.ts
|
|
18910
|
-
var
|
|
18911
|
-
var
|
|
19229
|
+
var import_web328 = require("@solana/web3.js");
|
|
19230
|
+
var import_common48 = __toESM(require_dist());
|
|
18912
19231
|
function selectReportableHoldings(holdings, excludedMints = /* @__PURE__ */ new Set()) {
|
|
18913
19232
|
return holdings.map((holding, holdingIndex) => ({ holding, holdingIndex })).filter(({ holding }) => {
|
|
18914
|
-
const mint = (0,
|
|
19233
|
+
const mint = (0, import_common48.fromWeb3Pk)(holding.mint);
|
|
18915
19234
|
return mint !== SYSTEM_PROGRAM && !excludedMints.has(mint.toString()) && REPORTABLE_ORACLE_VARIANTS.has(
|
|
18916
19235
|
variantName2(holding.priceOracleType).toLowerCase()
|
|
18917
19236
|
);
|
|
@@ -18946,7 +19265,7 @@ function parseExternalLiquidityRefs(vaultState) {
|
|
|
18946
19265
|
if (!data || data.length < 40) continue;
|
|
18947
19266
|
if (data[0] !== 1) continue;
|
|
18948
19267
|
const pubkeyBytes = new Uint8Array(data.slice(8, 40));
|
|
18949
|
-
const userAccount = new
|
|
19268
|
+
const userAccount = new import_web328.PublicKey(pubkeyBytes).toBase58();
|
|
18950
19269
|
refs.push({
|
|
18951
19270
|
kind: "marginfi",
|
|
18952
19271
|
mint: "",
|
|
@@ -19172,17 +19491,18 @@ function formatBpsAsPercent(bps) {
|
|
|
19172
19491
|
}
|
|
19173
19492
|
|
|
19174
19493
|
// src/services/consensusOracle/pipeline/dryRunSettlement.ts
|
|
19175
|
-
var
|
|
19176
|
-
var
|
|
19494
|
+
var import_web330 = require("@solana/web3.js");
|
|
19495
|
+
var import_common49 = __toESM(require_dist());
|
|
19177
19496
|
|
|
19178
19497
|
// src/services/consensusOracle/settlement/settlementSimulator.ts
|
|
19179
19498
|
var import_kit12 = require("@solana/kit");
|
|
19180
|
-
var
|
|
19499
|
+
var import_web329 = require("@solana/web3.js");
|
|
19181
19500
|
var DEFAULT_SHARE_PRICE = 1000000n;
|
|
19182
19501
|
var BPS_DENOMINATOR3 = 10000n;
|
|
19183
19502
|
var NAV_LOSS_TOLERANCE_BPS = 25n;
|
|
19184
19503
|
var SECONDS_PER_YEAR = 31536000n;
|
|
19185
19504
|
var MAX_APY_ANCHOR_WINDOW_SECS = 604800n;
|
|
19505
|
+
var MAX_APY_PREVIOUS_ANCHOR_AGE_SECS = 2n * MAX_APY_ANCHOR_WINDOW_SECS;
|
|
19186
19506
|
var DEFAULT_STALENESS_SECS = 86400n;
|
|
19187
19507
|
var CONSENSUS_MAX_DIFF_BPS = 8n;
|
|
19188
19508
|
var MIN_CONSENSUS_SIGNERS = 2;
|
|
@@ -19380,7 +19700,7 @@ function applyConsensus(holdings, entries, nowTs, stalenessThresholdSecs) {
|
|
|
19380
19700
|
continue;
|
|
19381
19701
|
}
|
|
19382
19702
|
const reports = entries.filter(
|
|
19383
|
-
(entry) => entry.signer !==
|
|
19703
|
+
(entry) => entry.signer !== import_web329.PublicKey.default.toBase58() && isFresh(entry.lastUpdateTs, nowTs, stalenessThresholdSecs) && (entry.prices[index] ?? 0n) > 0n
|
|
19384
19704
|
);
|
|
19385
19705
|
const usesConsensusPrice = holding.priceOracleType === "consensusoracle";
|
|
19386
19706
|
const prices = reports.map((entry) => entry.prices[index] ?? 0n);
|
|
@@ -19455,7 +19775,9 @@ function settleVault(args) {
|
|
|
19455
19775
|
};
|
|
19456
19776
|
timestampSource = hasFixedAnchor ? "legacy fixed-APY anchor (initialization)" : "current share-price observation (initialization)";
|
|
19457
19777
|
}
|
|
19458
|
-
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;
|
|
19459
19781
|
const priorApyValue = usePrevious ? maxApyAnchor.previousSharePrice : maxApyAnchor.sharePrice;
|
|
19460
19782
|
const priorTs = usePrevious ? maxApyAnchor.previousTimestamp : maxApyAnchor.timestamp;
|
|
19461
19783
|
if (usePrevious) timestampSource = "apy.max_apy_anchor.previous_timestamp";
|
|
@@ -19543,6 +19865,7 @@ function settleVault(args) {
|
|
|
19543
19865
|
priorTs,
|
|
19544
19866
|
timestampSource,
|
|
19545
19867
|
checkpointTs: maxApyAnchor.timestamp,
|
|
19868
|
+
ignoredPreviousCheckpointTs: hasPreviousForShortWindow && previousTooOld ? maxApyAnchor.previousTimestamp : void 0,
|
|
19546
19869
|
nowTs: args.nowTs,
|
|
19547
19870
|
elapsedSecs,
|
|
19548
19871
|
impliedApyMicroBps: rateAvailable ? numerator * 1000000n / denominator : void 0,
|
|
@@ -19878,7 +20201,7 @@ function decodeOracleData(data, nowTs) {
|
|
|
19878
20201
|
(_, holdingIndex) => readU64(data, offset + EXTERNAL_OFFSET + holdingIndex * 8)
|
|
19879
20202
|
);
|
|
19880
20203
|
entries.push({
|
|
19881
|
-
signer: new
|
|
20204
|
+
signer: new import_web329.PublicKey(signerBytes).toBase58(),
|
|
19882
20205
|
lastUpdateTs: readI64(data, offset + 32),
|
|
19883
20206
|
prices,
|
|
19884
20207
|
externalAmounts
|
|
@@ -19893,7 +20216,7 @@ function decodeOracleData(data, nowTs) {
|
|
|
19893
20216
|
data.slice(pendingOffset + index * 32, pendingOffset + (index + 1) * 32)
|
|
19894
20217
|
);
|
|
19895
20218
|
entries[index] = {
|
|
19896
|
-
signer: index < pendingCount ? new
|
|
20219
|
+
signer: index < pendingCount ? new import_web329.PublicKey(signerBytes).toBase58() : import_web329.PublicKey.default.toBase58(),
|
|
19897
20220
|
lastUpdateTs: 0n,
|
|
19898
20221
|
prices: Array(MAX_HOLDINGS).fill(0n),
|
|
19899
20222
|
externalAmounts: Array(MAX_HOLDINGS).fill(0n)
|
|
@@ -19921,7 +20244,7 @@ function decodeHolding(value) {
|
|
|
19921
20244
|
externalAmount: bigint(holding.externalAmount),
|
|
19922
20245
|
price: bigint(holding.price),
|
|
19923
20246
|
lastUpdateTs: bigint(holding.lastUpdateTs),
|
|
19924
|
-
cleared: mintString ===
|
|
20247
|
+
cleared: mintString === import_web329.PublicKey.default.toBase58()
|
|
19925
20248
|
};
|
|
19926
20249
|
}
|
|
19927
20250
|
function decodeTrancheState(decoded, args, warnings, blockers) {
|
|
@@ -20296,17 +20619,22 @@ function formatRealizedApy(apy) {
|
|
|
20296
20619
|
apy.priorValue,
|
|
20297
20620
|
6
|
|
20298
20621
|
)} [${apy.priorValue}] -> ${apy.nextValue === void 0 ? "unavailable (zero supply)" : `${formatUnits(apy.nextValue, 6)} [${apy.nextValue}]`}`,
|
|
20299
|
-
` 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}`,
|
|
20300
20623
|
` observation window: ${formatUnits(
|
|
20301
20624
|
apy.elapsedSecs * 1000000n / 86400n,
|
|
20302
20625
|
6
|
|
20303
|
-
)} days${apy.elapsedSecs < MAX_APY_ANCHOR_WINDOW_SECS ? " (
|
|
20626
|
+
)} days${apy.elapsedSecs < MAX_APY_ANCHOR_WINDOW_SECS ? " (short observation window: less than 7 days)" : ""}`,
|
|
20304
20627
|
` timestamp: ${apy.priorTs} from ${apy.timestampSource}; settlement time estimate=${apy.nowTs}; elapsed=${apy.elapsedSecs}s`,
|
|
20305
20628
|
` configured max: ${apy.maxApyBps}bps (${formatUnits(
|
|
20306
20629
|
BigInt(apy.maxApyBps),
|
|
20307
20630
|
2
|
|
20308
20631
|
)}%); regular HWM: ${apy.hwmBefore} -> ${apy.hwmAfter}`
|
|
20309
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
|
+
}
|
|
20310
20638
|
if (apy.impliedApyMicroBps !== void 0) {
|
|
20311
20639
|
lines.push(
|
|
20312
20640
|
` implied APY (linear annualization): ${formatUnits(
|
|
@@ -20386,11 +20714,11 @@ async function simulateDryRunSettlement({
|
|
|
20386
20714
|
client.account.fetchVaultOracleForVault(vault, { fresh: true }),
|
|
20387
20715
|
tranchingEnabled ? client.account.fetchVaultTrancheStateForVault(vault, { fresh: true }) : Promise.resolve(void 0)
|
|
20388
20716
|
]);
|
|
20389
|
-
const mintKeys = [new
|
|
20717
|
+
const mintKeys = [new import_web330.PublicKey(vaultState.mint)];
|
|
20390
20718
|
if (trancheState) {
|
|
20391
20719
|
mintKeys.push(
|
|
20392
|
-
new
|
|
20393
|
-
new
|
|
20720
|
+
new import_web330.PublicKey(trancheState.config.juniorMint),
|
|
20721
|
+
new import_web330.PublicKey(trancheState.config.seniorMint)
|
|
20394
20722
|
);
|
|
20395
20723
|
}
|
|
20396
20724
|
const mintAccounts = await client.provider.connection.getMultipleAccountsInfo(
|
|
@@ -20406,7 +20734,7 @@ async function simulateDryRunSettlement({
|
|
|
20406
20734
|
oracleData: oracleState.data,
|
|
20407
20735
|
trancheState,
|
|
20408
20736
|
updates,
|
|
20409
|
-
signer: (0,
|
|
20737
|
+
signer: (0, import_common49.fromWeb3Pk)(signer.publicKey),
|
|
20410
20738
|
nowTs: nowSecs,
|
|
20411
20739
|
physicalShareSupply: supplies[0],
|
|
20412
20740
|
physicalJuniorSupply: tranchingEnabled ? supplies[1] : void 0,
|
|
@@ -20415,7 +20743,7 @@ async function simulateDryRunSettlement({
|
|
|
20415
20743
|
}
|
|
20416
20744
|
|
|
20417
20745
|
// src/services/consensusOracle/pipeline/holdingUpdates.ts
|
|
20418
|
-
var
|
|
20746
|
+
var import_common50 = __toESM(require_dist());
|
|
20419
20747
|
async function buildUpdates(yieldTracker, reportableHoldings, inputs) {
|
|
20420
20748
|
const updates = [];
|
|
20421
20749
|
for (const entry of reportableHoldings) {
|
|
@@ -20425,7 +20753,7 @@ async function buildUpdates(yieldTracker, reportableHoldings, inputs) {
|
|
|
20425
20753
|
}
|
|
20426
20754
|
async function buildHoldingUpdate(yieldTracker, entry, inputs) {
|
|
20427
20755
|
const { holding, holdingIndex } = entry;
|
|
20428
|
-
const mint = (0,
|
|
20756
|
+
const mint = (0, import_common50.fromWeb3Pk)(holding.mint);
|
|
20429
20757
|
const mintKey = mint.toString();
|
|
20430
20758
|
const oracleType = variantName2(holding.priceOracleType).toLowerCase();
|
|
20431
20759
|
let usd;
|
|
@@ -20487,14 +20815,14 @@ async function resolveTrackedAmounts(yieldTracker, cfg, decimals) {
|
|
|
20487
20815
|
);
|
|
20488
20816
|
}
|
|
20489
20817
|
return {
|
|
20490
|
-
trackedValueAmount: tracked.totalValue > 0 ? (0,
|
|
20491
|
-
principalAmount: tracked.principal > 0 ? (0,
|
|
20492
|
-
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
|
|
20493
20821
|
};
|
|
20494
20822
|
}
|
|
20495
20823
|
|
|
20496
20824
|
// src/services/consensusOracle/pipeline/livePriceRefresh.ts
|
|
20497
|
-
var
|
|
20825
|
+
var import_common51 = __toESM(require_dist());
|
|
20498
20826
|
async function refreshLiveOraclePrices({
|
|
20499
20827
|
oracle,
|
|
20500
20828
|
signer,
|
|
@@ -20513,7 +20841,7 @@ async function refreshLiveOraclePrices({
|
|
|
20513
20841
|
for (const holding of vaultState.holdings) {
|
|
20514
20842
|
const oracleType = variantName2(holding.priceOracleType).toLowerCase();
|
|
20515
20843
|
if (!LIVE_ORACLE_VARIANTS.has(oracleType)) continue;
|
|
20516
|
-
const mint = (0,
|
|
20844
|
+
const mint = (0, import_common51.fromWeb3Pk)(holding.mint);
|
|
20517
20845
|
if (mint.toString() === SYSTEM_PROGRAM) continue;
|
|
20518
20846
|
const activeAmount = toBigInt2(holding.localAmount) + toBigInt2(holding.externalAmount);
|
|
20519
20847
|
if (activeAmount === 0n) continue;
|
|
@@ -20528,7 +20856,7 @@ async function refreshLiveOraclePrices({
|
|
|
20528
20856
|
);
|
|
20529
20857
|
continue;
|
|
20530
20858
|
}
|
|
20531
|
-
const oracleAccount = (0,
|
|
20859
|
+
const oracleAccount = (0, import_common51.fromWeb3Pk)(holding.priceOracleAccount);
|
|
20532
20860
|
if (oracleAccount.toString() === SYSTEM_PROGRAM) {
|
|
20533
20861
|
log(
|
|
20534
20862
|
`vault ${vault}: cannot refresh ${mint}; ${oracleType} holding has no oracle account`
|
|
@@ -20552,7 +20880,7 @@ async function refreshLiveOraclePrices({
|
|
|
20552
20880
|
}
|
|
20553
20881
|
|
|
20554
20882
|
// src/services/consensusOracle/pipeline/managerWalletReconciliation.ts
|
|
20555
|
-
var
|
|
20883
|
+
var import_common52 = __toESM(require_dist());
|
|
20556
20884
|
|
|
20557
20885
|
// src/services/consensusOracle/sources/nestPriceSource.ts
|
|
20558
20886
|
var import_kit13 = require("@solana/kit");
|
|
@@ -20597,13 +20925,13 @@ function candidateGrossNav(state, updates) {
|
|
|
20597
20925
|
const byIndex = /* @__PURE__ */ new Map();
|
|
20598
20926
|
for (const update of updates) {
|
|
20599
20927
|
const holding = state.holdings[update.holdingIndex];
|
|
20600
|
-
if (!holding || (0,
|
|
20928
|
+
if (!holding || (0, import_common52.fromWeb3Pk)(holding.mint) !== update.mint || holding.decimals !== update.decimals || byIndex.has(update.holdingIndex)) {
|
|
20601
20929
|
throw new Error(`Invalid NAV update for holding #${update.holdingIndex}`);
|
|
20602
20930
|
}
|
|
20603
20931
|
byIndex.set(update.holdingIndex, update);
|
|
20604
20932
|
}
|
|
20605
20933
|
return state.holdings.reduce((nav, holding, index) => {
|
|
20606
|
-
if ((0,
|
|
20934
|
+
if ((0, import_common52.fromWeb3Pk)(holding.mint) === SYSTEM_PROGRAM) return nav;
|
|
20607
20935
|
const update = byIndex.get(index);
|
|
20608
20936
|
const local = toBigInt2(holding.localAmount);
|
|
20609
20937
|
const external = update?.externalAmount ?? toBigInt2(holding.externalAmount);
|
|
@@ -20641,12 +20969,13 @@ async function reconcileManagerWalletBalances({
|
|
|
20641
20969
|
vaultState,
|
|
20642
20970
|
updates,
|
|
20643
20971
|
source,
|
|
20972
|
+
mpcSource,
|
|
20644
20973
|
log = () => {
|
|
20645
20974
|
}
|
|
20646
20975
|
}) {
|
|
20647
20976
|
const previousNav = previousPhysicalNav(vaultState);
|
|
20648
20977
|
if (updates.some(
|
|
20649
|
-
(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
|
|
20650
20979
|
)) {
|
|
20651
20980
|
throw new Error("Manager reconciliation requires fresh source amounts");
|
|
20652
20981
|
}
|
|
@@ -20678,30 +21007,49 @@ async function reconcileManagerWalletBalances({
|
|
|
20678
21007
|
throw new Error("Duplicate base mint in manager reconciliation");
|
|
20679
21008
|
}
|
|
20680
21009
|
if (vaultState.holdings.some(
|
|
20681
|
-
(holding) => coerceBool3(holding.isBase) && !mints2.includes((0,
|
|
21010
|
+
(holding) => coerceBool3(holding.isBase) && !mints2.includes((0, import_common52.fromWeb3Pk)(holding.mint))
|
|
20682
21011
|
)) {
|
|
20683
21012
|
throw new Error(
|
|
20684
21013
|
"Cannot reconcile all vault base assets with oracle reports"
|
|
20685
21014
|
);
|
|
20686
21015
|
}
|
|
20687
|
-
const manager = (0,
|
|
21016
|
+
const manager = (0, import_common52.fromWeb3Pk)(vaultState.roles.manager);
|
|
20688
21017
|
if (manager === SYSTEM_PROGRAM || manager === vault) {
|
|
20689
21018
|
throw new Error("Invalid manager wallet for NAV reconciliation");
|
|
20690
21019
|
}
|
|
20691
21020
|
log(
|
|
20692
21021
|
`vault ${vault}: NAV ${candidateNav} is at least 0.1% below ${previousNav}; checking manager ${manager}`
|
|
20693
21022
|
);
|
|
20694
|
-
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
|
+
};
|
|
20695
21036
|
const adjusted = updates.map((update) => {
|
|
20696
21037
|
if (!mints2.includes(update.mint)) return update;
|
|
20697
|
-
const amount = amounts.get(update.mint) ?? 0n;
|
|
20698
|
-
|
|
20699
|
-
|
|
20700
|
-
|
|
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
|
+
);
|
|
20701
21048
|
return {
|
|
20702
21049
|
...update,
|
|
20703
21050
|
managerWalletAmount: amount,
|
|
20704
|
-
|
|
21051
|
+
...mpc ? { mpcWalletAmount: mpcTokens, mpcMarginfiAmount: mpcMarginfi } : {},
|
|
21052
|
+
externalAmount: update.externalAmount + amount + mpcTokens + mpcMarginfi
|
|
20705
21053
|
};
|
|
20706
21054
|
});
|
|
20707
21055
|
const adjustedNav = candidateGrossNav(vaultState, adjusted);
|
|
@@ -20709,7 +21057,7 @@ async function reconcileManagerWalletBalances({
|
|
|
20709
21057
|
const absoluteDelta = delta < 0n ? -delta : delta;
|
|
20710
21058
|
const accepted = adjustedNav > candidateNav && absoluteDelta * BPS <= previousNav * MANAGER_WALLET_NAV_TOLERANCE_BPS;
|
|
20711
21059
|
log(
|
|
20712
|
-
`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%`
|
|
20713
21061
|
);
|
|
20714
21062
|
return {
|
|
20715
21063
|
accepted,
|
|
@@ -20721,10 +21069,10 @@ async function reconcileManagerWalletBalances({
|
|
|
20721
21069
|
}
|
|
20722
21070
|
function managerReconciliationStateKey(state) {
|
|
20723
21071
|
return JSON.stringify({
|
|
20724
|
-
manager: (0,
|
|
21072
|
+
manager: (0, import_common52.fromWeb3Pk)(state.roles.manager),
|
|
20725
21073
|
previousNav: previousPhysicalNav(state).toString(),
|
|
20726
21074
|
holdings: state.holdings.map((holding) => [
|
|
20727
|
-
(0,
|
|
21075
|
+
(0, import_common52.fromWeb3Pk)(holding.mint),
|
|
20728
21076
|
holding.decimals,
|
|
20729
21077
|
variantName2(holding.priceOracleType),
|
|
20730
21078
|
coerceBool3(holding.isBase),
|
|
@@ -20736,14 +21084,14 @@ function managerReconciliationStateKey(state) {
|
|
|
20736
21084
|
}
|
|
20737
21085
|
|
|
20738
21086
|
// src/services/consensusOracle/pipeline/pricingInputs.ts
|
|
20739
|
-
var
|
|
21087
|
+
var import_common53 = __toESM(require_dist());
|
|
20740
21088
|
async function gatherPricingInputs(deps, target, vaultState, reportableHoldings, log = () => {
|
|
20741
21089
|
}) {
|
|
20742
21090
|
const consensusMints = reportableHoldings.filter(
|
|
20743
21091
|
({ holding }) => variantName2(holding.priceOracleType).toLowerCase() === CONSENSUS_ORACLE_VARIANT
|
|
20744
|
-
).map(({ holding }) => (0,
|
|
21092
|
+
).map(({ holding }) => (0, import_common53.fromWeb3Pk)(holding.mint));
|
|
20745
21093
|
const baseHolding = vaultState.holdings.find((h) => coerceBool3(h.isBase));
|
|
20746
|
-
const baseMint = baseHolding ? (0,
|
|
21094
|
+
const baseMint = baseHolding ? (0, import_common53.fromWeb3Pk)(baseHolding.mint) : consensusMints[0];
|
|
20747
21095
|
if (!baseMint) {
|
|
20748
21096
|
throw new Error(`vault has no holdings \u2014 cannot determine base asset`);
|
|
20749
21097
|
}
|
|
@@ -20827,11 +21175,11 @@ function reconcilePositionSnapshots(snapshots, vault, log) {
|
|
|
20827
21175
|
}
|
|
20828
21176
|
|
|
20829
21177
|
// src/services/consensusOracle/pipeline/receiptMints.ts
|
|
20830
|
-
var
|
|
21178
|
+
var import_common54 = __toESM(require_dist());
|
|
20831
21179
|
async function fetchReceiptMints(client, vault, vaultState) {
|
|
20832
21180
|
const receiptMints = /* @__PURE__ */ new Set();
|
|
20833
21181
|
if (vaultState.mint) {
|
|
20834
|
-
receiptMints.add((0,
|
|
21182
|
+
receiptMints.add((0, import_common54.fromWeb3Pk)(vaultState.mint).toString());
|
|
20835
21183
|
}
|
|
20836
21184
|
if (!coerceBool3(vaultState.tranchingEnabled)) return receiptMints;
|
|
20837
21185
|
const trancheState = await client.account.fetchVaultTrancheStateForVault(
|
|
@@ -20839,19 +21187,19 @@ async function fetchReceiptMints(client, vault, vaultState) {
|
|
|
20839
21187
|
{ fresh: true }
|
|
20840
21188
|
);
|
|
20841
21189
|
receiptMints.add(
|
|
20842
|
-
(0,
|
|
21190
|
+
(0, import_common54.fromWeb3Pk)(trancheState.config.juniorMint).toString()
|
|
20843
21191
|
);
|
|
20844
21192
|
receiptMints.add(
|
|
20845
|
-
(0,
|
|
21193
|
+
(0, import_common54.fromWeb3Pk)(trancheState.config.seniorMint).toString()
|
|
20846
21194
|
);
|
|
20847
21195
|
return receiptMints;
|
|
20848
21196
|
}
|
|
20849
21197
|
|
|
20850
21198
|
// src/services/consensusOracle/pipeline/settlement.ts
|
|
20851
|
-
var
|
|
21199
|
+
var import_common56 = __toESM(require_dist());
|
|
20852
21200
|
|
|
20853
21201
|
// src/services/consensusOracle/pipeline/yieldAccounts.ts
|
|
20854
|
-
var
|
|
21202
|
+
var import_common55 = __toESM(require_dist());
|
|
20855
21203
|
async function assertNoUnconfirmedYieldPayments(yieldTracker, target) {
|
|
20856
21204
|
const accountNames = [
|
|
20857
21205
|
...new Set(
|
|
@@ -20893,7 +21241,7 @@ async function withDiscoveredYieldAccounts(yieldTracker, target, vaultState, exc
|
|
|
20893
21241
|
);
|
|
20894
21242
|
if (namesToAttach.length === 0) return target;
|
|
20895
21243
|
const baseHolding = vaultState.holdings.find((holding) => {
|
|
20896
|
-
const mint = (0,
|
|
21244
|
+
const mint = (0, import_common55.fromWeb3Pk)(holding.mint).toString();
|
|
20897
21245
|
return coerceBool3(holding.isBase) && !excludedMints.has(mint);
|
|
20898
21246
|
});
|
|
20899
21247
|
if (!baseHolding) {
|
|
@@ -20901,7 +21249,7 @@ async function withDiscoveredYieldAccounts(yieldTracker, target, vaultState, exc
|
|
|
20901
21249
|
`vault ${target.vault}: tagged yield accounts found but no base holding is available`
|
|
20902
21250
|
);
|
|
20903
21251
|
}
|
|
20904
|
-
const baseMint = (0,
|
|
21252
|
+
const baseMint = (0, import_common55.fromWeb3Pk)(baseHolding.mint);
|
|
20905
21253
|
const holdings = [...target.holdings ?? []];
|
|
20906
21254
|
const existingIndex = holdings.findIndex(
|
|
20907
21255
|
(holding) => holding.mint.toString() === baseMint.toString()
|
|
@@ -20941,7 +21289,7 @@ async function settleVault2({
|
|
|
20941
21289
|
log(`vault ${vault}: submitting ${updates.length} consensus asset update(s)`);
|
|
20942
21290
|
for (const update of updates) {
|
|
20943
21291
|
log(
|
|
20944
|
-
` 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}]`
|
|
20945
21293
|
);
|
|
20946
21294
|
}
|
|
20947
21295
|
try {
|
|
@@ -21004,7 +21352,7 @@ async function logProspectiveApy({
|
|
|
21004
21352
|
);
|
|
21005
21353
|
const prospectiveNav = vaultState.holdings.reduce(
|
|
21006
21354
|
(sum, holding, holdingIndex) => {
|
|
21007
|
-
const mint = (0,
|
|
21355
|
+
const mint = (0, import_common56.fromWeb3Pk)(holding.mint).toString();
|
|
21008
21356
|
if (mint === SYSTEM_PROGRAM) return sum;
|
|
21009
21357
|
const update = updatesByIndex.get(holdingIndex);
|
|
21010
21358
|
const localAmount = toBigInt2(holding.localAmount);
|
|
@@ -21092,8 +21440,8 @@ var LivePriceSource = class {
|
|
|
21092
21440
|
};
|
|
21093
21441
|
|
|
21094
21442
|
// src/services/consensusOracle/sources/managerWalletBalanceSource.ts
|
|
21095
|
-
var
|
|
21096
|
-
var
|
|
21443
|
+
var import_web331 = require("@solana/web3.js");
|
|
21444
|
+
var import_spl_token21 = require("@solana/spl-token");
|
|
21097
21445
|
var RpcManagerWalletBalanceSource = class {
|
|
21098
21446
|
constructor(connection) {
|
|
21099
21447
|
this.connection = connection;
|
|
@@ -21101,8 +21449,8 @@ var RpcManagerWalletBalanceSource = class {
|
|
|
21101
21449
|
async fetchBalances(manager, mints2) {
|
|
21102
21450
|
const wanted = new Set(mints2);
|
|
21103
21451
|
if (wanted.size === 0) return /* @__PURE__ */ new Map();
|
|
21104
|
-
const owner = new
|
|
21105
|
-
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];
|
|
21106
21454
|
const responses = await Promise.all(
|
|
21107
21455
|
programs.map(
|
|
21108
21456
|
(programId) => this.connection.getParsedTokenAccountsByOwner(
|
|
@@ -21144,6 +21492,124 @@ var RpcManagerWalletBalanceSource = class {
|
|
|
21144
21492
|
}
|
|
21145
21493
|
};
|
|
21146
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
|
+
|
|
21147
21613
|
// src/services/consensusOracle/positions/externalPositions.ts
|
|
21148
21614
|
var ExternalPositionRegistry = class {
|
|
21149
21615
|
constructor(providers = [], log = () => {
|
|
@@ -21179,12 +21645,12 @@ var StaticPositionProvider = class {
|
|
|
21179
21645
|
};
|
|
21180
21646
|
|
|
21181
21647
|
// src/services/consensusOracle/positions/kaminoPositionProvider.ts
|
|
21182
|
-
var
|
|
21183
|
-
var
|
|
21648
|
+
var import_kit15 = require("@solana/kit");
|
|
21649
|
+
var import_web333 = require("@solana/web3.js");
|
|
21184
21650
|
var import_klend_sdk = require("@kamino-finance/klend-sdk");
|
|
21185
21651
|
async function readKaminoBalance(manager, vault, sharesHolder) {
|
|
21186
21652
|
const userShares = await manager.getUserSharesBalanceSingleVault(
|
|
21187
|
-
(0,
|
|
21653
|
+
(0, import_kit15.address)(sharesHolder.toBase58()),
|
|
21188
21654
|
vault
|
|
21189
21655
|
);
|
|
21190
21656
|
const tokensPerShare = await manager.getTokensPerShareSingleVault(vault);
|
|
@@ -21200,7 +21666,7 @@ var KaminoPositionProvider = class {
|
|
|
21200
21666
|
async positionsFor(ctx) {
|
|
21201
21667
|
const refs = ctx.refs.filter((r) => r.kind === "kamino");
|
|
21202
21668
|
if (refs.length === 0) return [];
|
|
21203
|
-
const rpc = (0,
|
|
21669
|
+
const rpc = (0, import_kit15.createSolanaRpc)(this.rpcUrl);
|
|
21204
21670
|
const slotDuration = await (0, import_klend_sdk.getMedianSlotDurationInMsFromLastEpochs)();
|
|
21205
21671
|
const manager = new import_klend_sdk.KaminoManager(rpc, slotDuration);
|
|
21206
21672
|
const out = [];
|
|
@@ -21213,11 +21679,11 @@ var KaminoPositionProvider = class {
|
|
|
21213
21679
|
);
|
|
21214
21680
|
continue;
|
|
21215
21681
|
}
|
|
21216
|
-
const kVault = new import_klend_sdk.KaminoVault(rpc, (0,
|
|
21682
|
+
const kVault = new import_klend_sdk.KaminoVault(rpc, (0, import_kit15.address)(vaultState));
|
|
21217
21683
|
const amount = await readKaminoBalance(
|
|
21218
21684
|
manager,
|
|
21219
21685
|
kVault,
|
|
21220
|
-
new
|
|
21686
|
+
new import_web333.PublicKey(sharesHolder)
|
|
21221
21687
|
);
|
|
21222
21688
|
out.push({ mint: ref.mint, amount });
|
|
21223
21689
|
}
|
|
@@ -21226,8 +21692,8 @@ var KaminoPositionProvider = class {
|
|
|
21226
21692
|
};
|
|
21227
21693
|
|
|
21228
21694
|
// src/services/consensusOracle/positions/marginfiPositionProvider.ts
|
|
21229
|
-
var
|
|
21230
|
-
var
|
|
21695
|
+
var import_web334 = require("@solana/web3.js");
|
|
21696
|
+
var import_marginfi3 = __toESM(require_dist2());
|
|
21231
21697
|
var MarginfiPositionProvider = class {
|
|
21232
21698
|
constructor(connection, log = () => {
|
|
21233
21699
|
}) {
|
|
@@ -21237,14 +21703,14 @@ var MarginfiPositionProvider = class {
|
|
|
21237
21703
|
async positionsFor(ctx) {
|
|
21238
21704
|
const refs = ctx.refs.filter((r) => r.kind === "marginfi");
|
|
21239
21705
|
if (refs.length === 0) return [];
|
|
21240
|
-
const explicitBanks = refs.map((r) => r.marginfiBank).filter(Boolean).map((bank) => new
|
|
21241
|
-
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));
|
|
21242
21708
|
const autoBanks = [];
|
|
21243
21709
|
for (const accountPk of autoAccountPks) {
|
|
21244
21710
|
try {
|
|
21245
21711
|
const info = await this.connection.getAccountInfo(accountPk);
|
|
21246
21712
|
if (info) {
|
|
21247
|
-
autoBanks.push(...(0,
|
|
21713
|
+
autoBanks.push(...(0, import_marginfi3.parseBankPksFromMarginfiAccount)(info.data));
|
|
21248
21714
|
}
|
|
21249
21715
|
} catch (err) {
|
|
21250
21716
|
this.log(
|
|
@@ -21252,7 +21718,7 @@ var MarginfiPositionProvider = class {
|
|
|
21252
21718
|
);
|
|
21253
21719
|
}
|
|
21254
21720
|
}
|
|
21255
|
-
const client = await (0,
|
|
21721
|
+
const client = await (0, import_marginfi3.createMarginfiReadClient)(this.connection, [
|
|
21256
21722
|
...explicitBanks,
|
|
21257
21723
|
...autoBanks
|
|
21258
21724
|
]);
|
|
@@ -21265,16 +21731,16 @@ var MarginfiPositionProvider = class {
|
|
|
21265
21731
|
}
|
|
21266
21732
|
const bank = ref.marginfiBank;
|
|
21267
21733
|
if (bank) {
|
|
21268
|
-
const amount = await (0,
|
|
21734
|
+
const amount = await (0, import_marginfi3.readMarginfiBankBalance)(
|
|
21269
21735
|
client,
|
|
21270
|
-
new
|
|
21271
|
-
new
|
|
21736
|
+
new import_web334.PublicKey(account),
|
|
21737
|
+
new import_web334.PublicKey(bank)
|
|
21272
21738
|
);
|
|
21273
21739
|
out.push({ mint: ref.mint, amount });
|
|
21274
21740
|
} else {
|
|
21275
|
-
const balances = await (0,
|
|
21741
|
+
const balances = await (0, import_marginfi3.readAllMarginfiBalances)(
|
|
21276
21742
|
client,
|
|
21277
|
-
new
|
|
21743
|
+
new import_web334.PublicKey(account)
|
|
21278
21744
|
);
|
|
21279
21745
|
for (const { mint, amount } of balances) {
|
|
21280
21746
|
out.push({ mint: mint.toBase58(), amount });
|
|
@@ -21474,6 +21940,16 @@ var MockYieldTracker = class {
|
|
|
21474
21940
|
}
|
|
21475
21941
|
};
|
|
21476
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
|
+
|
|
21477
21953
|
// src/services/consensusOracle/runtime/liveConsensusOracleDeps.ts
|
|
21478
21954
|
var YIELD_TRACKER_DECIMALS = 6;
|
|
21479
21955
|
function createLiveConsensusOracleDeps(connection, opts = {}) {
|
|
@@ -21482,6 +21958,7 @@ function createLiveConsensusOracleDeps(connection, opts = {}) {
|
|
|
21482
21958
|
const deps = {
|
|
21483
21959
|
priceSource: new LivePriceSource(),
|
|
21484
21960
|
managerWalletBalances: new RpcManagerWalletBalanceSource(connection),
|
|
21961
|
+
mpcWalletBalances: new RpcMpcWalletBalanceSource(connection, MPC_WALLETS),
|
|
21485
21962
|
yieldTracker: {
|
|
21486
21963
|
async getAccountNamesForVault(vault) {
|
|
21487
21964
|
const accounts2 = await getAccounts();
|
|
@@ -21492,7 +21969,19 @@ function createLiveConsensusOracleDeps(connection, opts = {}) {
|
|
|
21492
21969
|
return raw / 10 ** YIELD_TRACKER_DECIMALS;
|
|
21493
21970
|
},
|
|
21494
21971
|
async getTotalTrackedValue(accountNames, start, end) {
|
|
21495
|
-
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
|
+
);
|
|
21496
21985
|
return {
|
|
21497
21986
|
totalValue: tracked.totalValue / 10 ** YIELD_TRACKER_DECIMALS,
|
|
21498
21987
|
principal: tracked.principal / 10 ** YIELD_TRACKER_DECIMALS,
|
|
@@ -21515,7 +22004,7 @@ function createLiveConsensusOracleDeps(connection, opts = {}) {
|
|
|
21515
22004
|
}
|
|
21516
22005
|
|
|
21517
22006
|
// src/services/consensusOracle/consensusOracleService.ts
|
|
21518
|
-
var
|
|
22007
|
+
var import_common57 = __toESM(require_dist());
|
|
21519
22008
|
var ConsensusOracleService = class {
|
|
21520
22009
|
constructor(client, deps) {
|
|
21521
22010
|
this.client = client;
|
|
@@ -21551,7 +22040,7 @@ var ConsensusOracleService = class {
|
|
|
21551
22040
|
receiptMints
|
|
21552
22041
|
);
|
|
21553
22042
|
const filteredCount = vaultState.holdings.filter(
|
|
21554
|
-
(holding) => receiptMints.has((0,
|
|
22043
|
+
(holding) => receiptMints.has((0, import_common57.fromWeb3Pk)(holding.mint).toString())
|
|
21555
22044
|
).length;
|
|
21556
22045
|
if (filteredCount > 0) {
|
|
21557
22046
|
log(
|
|
@@ -21591,6 +22080,7 @@ var ConsensusOracleService = class {
|
|
|
21591
22080
|
vaultState,
|
|
21592
22081
|
updates: sourcedUpdates,
|
|
21593
22082
|
source: this.deps.managerWalletBalances,
|
|
22083
|
+
mpcSource: this.deps.mpcWalletBalances,
|
|
21594
22084
|
log
|
|
21595
22085
|
});
|
|
21596
22086
|
const updates = reconciliation.updates;
|
|
@@ -21662,13 +22152,14 @@ var ConsensusOracleService = class {
|
|
|
21662
22152
|
vault: target.vault,
|
|
21663
22153
|
vaultState: freshState,
|
|
21664
22154
|
updates: sourcedUpdates,
|
|
21665
|
-
source: this.deps.managerWalletBalances
|
|
22155
|
+
source: this.deps.managerWalletBalances,
|
|
22156
|
+
mpcSource: this.deps.mpcWalletBalances
|
|
21666
22157
|
});
|
|
21667
22158
|
if (!fresh.accepted || fresh.updates.some(
|
|
21668
|
-
(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
|
|
21669
22160
|
)) {
|
|
21670
22161
|
throw new Error(
|
|
21671
|
-
"Manager wallet changed during reconciliation; retry with fresh inputs"
|
|
22162
|
+
"Manager wallet changed or MPC balances changed during reconciliation; retry with fresh inputs"
|
|
21672
22163
|
);
|
|
21673
22164
|
}
|
|
21674
22165
|
} : void 0
|
|
@@ -21770,10 +22261,10 @@ async function runLiveConsensusOracle(env, oracleSigner, opts = {}) {
|
|
|
21770
22261
|
}
|
|
21771
22262
|
|
|
21772
22263
|
// src/services/externalLiquidityIntegrityService.ts
|
|
21773
|
-
var
|
|
21774
|
-
var
|
|
21775
|
-
var
|
|
21776
|
-
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());
|
|
21777
22268
|
var DEFAULT_MIN_AMOUNT_UI = 1;
|
|
21778
22269
|
var DEFAULT_TARGET_LOCAL_BPS = 50;
|
|
21779
22270
|
var DEFAULT_TARGET_LOCAL_USDC_TVL_BPS = 150;
|
|
@@ -21795,7 +22286,7 @@ function parseActiveSlots(externalLiquidity) {
|
|
|
21795
22286
|
if (discriminant === 0) continue;
|
|
21796
22287
|
if (discriminant !== 1) continue;
|
|
21797
22288
|
const pubkeyBytes = new Uint8Array(data.slice(8, 40));
|
|
21798
|
-
const userAccount = (0,
|
|
22289
|
+
const userAccount = (0, import_common58.toAddress)(new import_web335.PublicKey(pubkeyBytes));
|
|
21799
22290
|
results.push({ index: i, source: "marginfi", userAccount });
|
|
21800
22291
|
}
|
|
21801
22292
|
return results;
|
|
@@ -21925,8 +22416,8 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
21925
22416
|
result.skipped++;
|
|
21926
22417
|
return result;
|
|
21927
22418
|
}
|
|
21928
|
-
const hwManagerAddress = (0,
|
|
21929
|
-
const vaultPk = new
|
|
22419
|
+
const hwManagerAddress = (0, import_common58.fromWeb3Pk)(hwManager.publicKey);
|
|
22420
|
+
const vaultPk = new import_web335.PublicKey(vault.toString());
|
|
21930
22421
|
const registeredHwManager = pubkeyStr(
|
|
21931
22422
|
vaultState.roles.hwManager
|
|
21932
22423
|
);
|
|
@@ -21954,13 +22445,13 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
21954
22445
|
continue;
|
|
21955
22446
|
}
|
|
21956
22447
|
for (const holding of holdings) {
|
|
21957
|
-
const mintAddress = (0,
|
|
22448
|
+
const mintAddress = (0, import_kit17.address)(pubkeyStr(holding.mint));
|
|
21958
22449
|
const localAmount = toBigInt3(holding.localAmount);
|
|
21959
22450
|
const externalAmount = toBigInt3(holding.externalAmount);
|
|
21960
22451
|
const decimals = Number(holding.decimals ?? 0);
|
|
21961
22452
|
const minRaw = toRawAmount(minAmountUi, decimals);
|
|
21962
22453
|
let targetLocalAmount;
|
|
21963
|
-
if (mintAddress ===
|
|
22454
|
+
if (mintAddress === import_common58.USDC_MINT) {
|
|
21964
22455
|
const tvl = toBigInt3(vaultState.accounting.tvl);
|
|
21965
22456
|
const price = toBigInt3(holding.price);
|
|
21966
22457
|
const stalenessThreshold = Number(toBigInt3(vaultState.config.priceStalenessThresholdSecs)) || DEFAULT_PRICE_STALENESS_THRESHOLD_SECS;
|
|
@@ -21993,7 +22484,7 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
21993
22484
|
result.skipped++;
|
|
21994
22485
|
continue;
|
|
21995
22486
|
}
|
|
21996
|
-
const marginfiAccounts = (0,
|
|
22487
|
+
const marginfiAccounts = (0, import_marginfi4.marginfiAccountsForMint)(mintAddress);
|
|
21997
22488
|
if (!marginfiAccounts) {
|
|
21998
22489
|
log(
|
|
21999
22490
|
`Vault ${vault} slot ${slot.index}: mint ${mintAddress} has no Marginfi bank configured \u2014 skipping`
|
|
@@ -22060,17 +22551,17 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
22060
22551
|
log = () => {
|
|
22061
22552
|
}
|
|
22062
22553
|
} = params;
|
|
22063
|
-
const marginfiClient = new
|
|
22554
|
+
const marginfiClient = new import_marginfi4.CpiClient({
|
|
22064
22555
|
accounts: marginfiAccounts
|
|
22065
22556
|
});
|
|
22066
|
-
const { getAtaAddress:
|
|
22067
|
-
const vaultAta =
|
|
22557
|
+
const { getAtaAddress: getAtaAddress21 } = await Promise.resolve().then(() => __toESM(require_dist()));
|
|
22558
|
+
const vaultAta = getAtaAddress21(
|
|
22068
22559
|
mintAddress,
|
|
22069
22560
|
vault,
|
|
22070
22561
|
marginfiAccounts.tokenProgram,
|
|
22071
22562
|
true
|
|
22072
22563
|
);
|
|
22073
|
-
const cpiRefs = (0,
|
|
22564
|
+
const cpiRefs = (0, import_common58.createCpiRefs)([
|
|
22074
22565
|
direction === "deposit" ? marginfiClient.deposit_cpi({
|
|
22075
22566
|
marginfiAccount: slot.userAccount,
|
|
22076
22567
|
authority: vault,
|
|
@@ -22121,13 +22612,13 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
22121
22612
|
};
|
|
22122
22613
|
|
|
22123
22614
|
// src/services/idleLiquidityService.ts
|
|
22124
|
-
var
|
|
22125
|
-
var
|
|
22126
|
-
var
|
|
22127
|
-
var
|
|
22128
|
-
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());
|
|
22129
22620
|
var import_jupiter2 = __toESM(require_dist4());
|
|
22130
|
-
var
|
|
22621
|
+
var import_marginfi5 = __toESM(require_dist2());
|
|
22131
22622
|
var IDLE_RESERVE_FLOOR_BPS = 400;
|
|
22132
22623
|
var IDLE_RESERVE_TARGET_BPS = 500;
|
|
22133
22624
|
var WITHDRAWABLE_RESERVE_FLOOR_BPS = 150;
|
|
@@ -22220,13 +22711,13 @@ var IdleLiquidityService = class {
|
|
|
22220
22711
|
return { ...base, status: "insufficient-pst", reason };
|
|
22221
22712
|
}
|
|
22222
22713
|
const jupiter = new import_jupiter2.JupiterSwapClient(
|
|
22223
|
-
(0,
|
|
22714
|
+
(0, import_kit18.createSolanaRpc)(this.client.provider.connection.rpcEndpoint)
|
|
22224
22715
|
);
|
|
22225
22716
|
let quote;
|
|
22226
22717
|
try {
|
|
22227
22718
|
quote = await jupiter.getQuote({
|
|
22228
|
-
inputMint:
|
|
22229
|
-
outputMint:
|
|
22719
|
+
inputMint: import_common59.PST_MINT,
|
|
22720
|
+
outputMint: import_common59.USDC_MINT,
|
|
22230
22721
|
amount: pstInput,
|
|
22231
22722
|
slippageBps: opts.slippageBps ?? DEFAULT_SLIPPAGE_BPS,
|
|
22232
22723
|
maxAccounts: DEFAULT_MAX_ACCOUNTS
|
|
@@ -22272,13 +22763,13 @@ var IdleLiquidityService = class {
|
|
|
22272
22763
|
/** Read only the two locations that constitute the idle USDC reserve. */
|
|
22273
22764
|
async fetchIdleUsdc(vault, vaultState) {
|
|
22274
22765
|
const connection = this.client.provider.connection;
|
|
22275
|
-
const vaultPk = new
|
|
22276
|
-
const usdcMint = new
|
|
22277
|
-
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);
|
|
22278
22769
|
const tokenInfo = await connection.getAccountInfo(ata, "confirmed");
|
|
22279
22770
|
let localAmount = 0n;
|
|
22280
22771
|
if (tokenInfo) {
|
|
22281
|
-
const tokenAccount = (0,
|
|
22772
|
+
const tokenAccount = (0, import_spl_token22.unpackAccount)(ata, tokenInfo, import_spl_token22.TOKEN_PROGRAM_ID);
|
|
22282
22773
|
if (!tokenAccount.mint.equals(usdcMint) || !tokenAccount.owner.equals(vaultPk) || !tokenAccount.isInitialized) {
|
|
22283
22774
|
throw new Error(`Invalid vault USDC token account: ${ata.toBase58()}`);
|
|
22284
22775
|
}
|
|
@@ -22299,21 +22790,21 @@ var IdleLiquidityService = class {
|
|
|
22299
22790
|
if (data.length < 40) {
|
|
22300
22791
|
throw new Error(`Invalid Project0 external-liquidity slot ${slotIndex}`);
|
|
22301
22792
|
}
|
|
22302
|
-
const positionPk = new
|
|
22793
|
+
const positionPk = new import_web336.PublicKey(new Uint8Array(data.slice(8, 40)));
|
|
22303
22794
|
const positionInfo = await connection.getAccountInfo(
|
|
22304
22795
|
positionPk,
|
|
22305
22796
|
"confirmed"
|
|
22306
22797
|
);
|
|
22307
|
-
if (!positionInfo || !positionInfo.owner.equals(new
|
|
22798
|
+
if (!positionInfo || !positionInfo.owner.equals(new import_web336.PublicKey(import_marginfi5.MARGINFI_PROGRAM_ID))) {
|
|
22308
22799
|
throw new Error(
|
|
22309
22800
|
`Invalid Project0 slot-${slotIndex} account: ${positionPk.toBase58()}`
|
|
22310
22801
|
);
|
|
22311
22802
|
}
|
|
22312
|
-
const marginfi = await (0,
|
|
22803
|
+
const marginfi = await (0, import_marginfi5.createMarginfiReadClient)(
|
|
22313
22804
|
connection,
|
|
22314
|
-
(0,
|
|
22805
|
+
(0, import_marginfi5.parseBankPksFromMarginfiAccount)(positionInfo.data)
|
|
22315
22806
|
);
|
|
22316
|
-
const position = await
|
|
22807
|
+
const position = await import_marginfi_client_v22.MarginfiAccountWrapper.fetch(positionPk, marginfi);
|
|
22317
22808
|
if (!position.authority.equals(vaultPk)) {
|
|
22318
22809
|
throw new Error(`Project0 slot-${slotIndex} authority is not the vault`);
|
|
22319
22810
|
}
|
|
@@ -22368,8 +22859,8 @@ var IdleLiquidityService = class {
|
|
|
22368
22859
|
log(`Vault ${vault}: ${reason} \u2014 skipping`);
|
|
22369
22860
|
return { result: { ...empty, status: "no-tvl", reason } };
|
|
22370
22861
|
}
|
|
22371
|
-
const usdc = findHolding2(vaultState,
|
|
22372
|
-
const pst = findHolding2(vaultState,
|
|
22862
|
+
const usdc = findHolding2(vaultState, import_common59.USDC_MINT);
|
|
22863
|
+
const pst = findHolding2(vaultState, import_common59.PST_MINT);
|
|
22373
22864
|
if (!usdc || !pst) {
|
|
22374
22865
|
const reason = `vault has no ${usdc ? "PST" : "USDC"} holding`;
|
|
22375
22866
|
log(`Vault ${vault}: ${reason} \u2014 skipping`);
|
|
@@ -22517,16 +23008,16 @@ var IdleLiquidityService = class {
|
|
|
22517
23008
|
*/
|
|
22518
23009
|
async mintTokenProgram(mint) {
|
|
22519
23010
|
const account = await this.client.provider.connection.getAccountInfo(
|
|
22520
|
-
new
|
|
23011
|
+
new import_web336.PublicKey(mint),
|
|
22521
23012
|
"confirmed"
|
|
22522
23013
|
);
|
|
22523
23014
|
if (!account) throw new Error(`Mint account not found: ${mint}`);
|
|
22524
|
-
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)) {
|
|
22525
23016
|
throw new Error(
|
|
22526
23017
|
`Unsupported token program ${account.owner.toBase58()} for mint ${mint}`
|
|
22527
23018
|
);
|
|
22528
23019
|
}
|
|
22529
|
-
return (0,
|
|
23020
|
+
return (0, import_common59.fromWeb3Pk)(account.owner);
|
|
22530
23021
|
}
|
|
22531
23022
|
/**
|
|
22532
23023
|
* Build, simulate, and (unless `dryRun`) submit the `jupiter_swap`.
|
|
@@ -22546,23 +23037,23 @@ var IdleLiquidityService = class {
|
|
|
22546
23037
|
dryRun,
|
|
22547
23038
|
log
|
|
22548
23039
|
} = params;
|
|
22549
|
-
const signer = (0,
|
|
23040
|
+
const signer = (0, import_common59.fromWeb3Pk)(hwManager.publicKey);
|
|
22550
23041
|
const [sourceTokenProgram, destinationTokenProgram] = await Promise.all([
|
|
22551
|
-
this.mintTokenProgram(
|
|
22552
|
-
this.mintTokenProgram(
|
|
23042
|
+
this.mintTokenProgram(import_common59.PST_MINT),
|
|
23043
|
+
this.mintTokenProgram(import_common59.USDC_MINT)
|
|
22553
23044
|
]);
|
|
22554
23045
|
const jupiterCpi = await jupiter.getSwapCpiData(quote, vault, {
|
|
22555
23046
|
payer: signer
|
|
22556
23047
|
});
|
|
22557
|
-
const { accounts: accounts2, refs, lookupTables } = (0,
|
|
23048
|
+
const { accounts: accounts2, refs, lookupTables } = (0, import_common59.createCpiRefs)([jupiterCpi]);
|
|
22558
23049
|
const vaultTrancheState = coerceBool4(
|
|
22559
23050
|
vaultState.tranchingEnabled
|
|
22560
23051
|
) ? (await this.client.pda.deriveVaultTrancheStatePda(vault))[0] : void 0;
|
|
22561
23052
|
const plan = await this.client.tx.jupiterSwap.getTx({
|
|
22562
23053
|
hwManager: signer,
|
|
22563
23054
|
vault,
|
|
22564
|
-
sourceMint:
|
|
22565
|
-
destinationMint:
|
|
23055
|
+
sourceMint: import_common59.PST_MINT,
|
|
23056
|
+
destinationMint: import_common59.USDC_MINT,
|
|
22566
23057
|
refs,
|
|
22567
23058
|
accounts: accounts2,
|
|
22568
23059
|
sourceTokenProgram,
|
|
@@ -22572,26 +23063,26 @@ var IdleLiquidityService = class {
|
|
|
22572
23063
|
});
|
|
22573
23064
|
const connection = this.client.provider.connection;
|
|
22574
23065
|
const instructions2 = [
|
|
22575
|
-
|
|
23066
|
+
import_web336.ComputeBudgetProgram.setComputeUnitLimit({ units: COMPUTE_UNIT_LIMIT }),
|
|
22576
23067
|
...cuPriceMicroLamports > 0 ? [
|
|
22577
|
-
|
|
23068
|
+
import_web336.ComputeBudgetProgram.setComputeUnitPrice({
|
|
22578
23069
|
microLamports: cuPriceMicroLamports
|
|
22579
23070
|
})
|
|
22580
23071
|
] : [],
|
|
22581
|
-
...(jupiterCpi.preInstructions ?? []).map(
|
|
22582
|
-
...plan.instructions.map(
|
|
23072
|
+
...(jupiterCpi.preInstructions ?? []).map(import_common59.fromKitInstruction),
|
|
23073
|
+
...plan.instructions.map(import_common59.fromKitInstruction)
|
|
22583
23074
|
];
|
|
22584
23075
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
|
|
22585
|
-
const lookupTableAccounts = await (0,
|
|
23076
|
+
const lookupTableAccounts = await (0, import_common59.fetchLookupTables)(
|
|
22586
23077
|
connection,
|
|
22587
23078
|
plan.lookupTables ?? []
|
|
22588
23079
|
);
|
|
22589
|
-
const message2 = new
|
|
23080
|
+
const message2 = new import_web336.TransactionMessage({
|
|
22590
23081
|
payerKey: hwManager.publicKey,
|
|
22591
23082
|
recentBlockhash: blockhash,
|
|
22592
23083
|
instructions: instructions2
|
|
22593
23084
|
}).compileToV0Message(lookupTableAccounts);
|
|
22594
|
-
const transaction = new
|
|
23085
|
+
const transaction = new import_web336.VersionedTransaction(message2);
|
|
22595
23086
|
transaction.sign([hwManager]);
|
|
22596
23087
|
if (!this.client.skipSimulation) {
|
|
22597
23088
|
const simulation = await connection.simulateTransaction(transaction, {
|
|
@@ -22636,10 +23127,10 @@ var IdleLiquidityService = class {
|
|
|
22636
23127
|
};
|
|
22637
23128
|
|
|
22638
23129
|
// src/services/timelockSettlementService.ts
|
|
22639
|
-
var
|
|
22640
|
-
var
|
|
22641
|
-
var
|
|
22642
|
-
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();
|
|
22643
23134
|
var CONSENSUS_SIGNER_CAPACITY = 4;
|
|
22644
23135
|
var CONSENSUS_ENTRY_OFFSET = 40;
|
|
22645
23136
|
var CONSENSUS_ENTRY_SIZE = 272;
|
|
@@ -22679,11 +23170,11 @@ function decodePendingConsensusSigners(data) {
|
|
|
22679
23170
|
const signers = [];
|
|
22680
23171
|
for (let i = 0; i < count; i += 1) {
|
|
22681
23172
|
const start = CONSENSUS_PENDING_OFFSET + i * 32;
|
|
22682
|
-
const signer = new
|
|
23173
|
+
const signer = new import_web337.PublicKey(bytes.slice(start, start + 32)).toBase58();
|
|
22683
23174
|
if (signer === ZERO_PUBKEY) {
|
|
22684
23175
|
throw new Error(`pending consensus signer ${i} is unset`);
|
|
22685
23176
|
}
|
|
22686
|
-
signers.push((0,
|
|
23177
|
+
signers.push((0, import_kit19.address)(signer));
|
|
22687
23178
|
}
|
|
22688
23179
|
return {
|
|
22689
23180
|
signers,
|
|
@@ -22711,7 +23202,7 @@ function pendingDestinationSettlement(state, now) {
|
|
|
22711
23202
|
const effectiveTs = integer(pending.effectiveTs);
|
|
22712
23203
|
return {
|
|
22713
23204
|
slot: integer(pending.slot),
|
|
22714
|
-
destination: (0,
|
|
23205
|
+
destination: (0, import_kit19.address)(destination),
|
|
22715
23206
|
effectiveTs,
|
|
22716
23207
|
expired: now >= effectiveTs
|
|
22717
23208
|
};
|
|
@@ -22735,7 +23226,7 @@ var TimelockSettlementService = class {
|
|
|
22735
23226
|
});
|
|
22736
23227
|
const dryRun = opts.dryRun ?? false;
|
|
22737
23228
|
const now = opts.now ?? await this.chainTime();
|
|
22738
|
-
const fulfillerAddress = (0,
|
|
23229
|
+
const fulfillerAddress = (0, import_common60.fromWeb3Pk)(fulfiller.publicKey);
|
|
22739
23230
|
const allVaults = opts.vault ? [
|
|
22740
23231
|
{
|
|
22741
23232
|
publicKey: opts.vault,
|
|
@@ -22877,19 +23368,19 @@ var TimelockSettlementService = class {
|
|
|
22877
23368
|
};
|
|
22878
23369
|
|
|
22879
23370
|
// src/services/nestWithdrawalService.ts
|
|
22880
|
-
var
|
|
22881
|
-
var
|
|
22882
|
-
var
|
|
22883
|
-
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());
|
|
22884
23375
|
var import_nest3 = __toESM(require_dist3());
|
|
22885
23376
|
var import_nest4 = __toESM(require_dist3());
|
|
22886
|
-
var NestOftProgram = new
|
|
23377
|
+
var NestOftProgram = new import_web338.PublicKey(
|
|
22887
23378
|
"ChEfPd3RzLeYiRwp1K9evimmaFSd6DV1S4Mv5q5Aj1th"
|
|
22888
23379
|
);
|
|
22889
|
-
var NestOftStore = new
|
|
23380
|
+
var NestOftStore = new import_web338.PublicKey(
|
|
22890
23381
|
"k8mJj8Gyw2gFAqut21AFVUUZhxb4RVDMnb4PrSYiDhV"
|
|
22891
23382
|
);
|
|
22892
|
-
var UsdcMint = new
|
|
23383
|
+
var UsdcMint = new import_web338.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
|
|
22893
23384
|
var NestPerenaComposer = Buffer.from(
|
|
22894
23385
|
"000000000000000000000000908dcb5531691c2124c54e30bb645cf11647090d",
|
|
22895
23386
|
"hex"
|
|
@@ -22906,7 +23397,7 @@ async function buildNestWithdrawalRequest(args) {
|
|
|
22906
23397
|
return decodeNestWithdrawalRequest({ ...args, txBase64 });
|
|
22907
23398
|
}
|
|
22908
23399
|
async function decodeNestWithdrawalRequest(args) {
|
|
22909
|
-
const transaction =
|
|
23400
|
+
const transaction = import_web338.VersionedTransaction.deserialize(
|
|
22910
23401
|
Buffer.from(args.txBase64, "base64")
|
|
22911
23402
|
);
|
|
22912
23403
|
const message2 = transaction.message;
|
|
@@ -22927,19 +23418,19 @@ async function decodeNestWithdrawalRequest(args) {
|
|
|
22927
23418
|
return value;
|
|
22928
23419
|
})
|
|
22929
23420
|
);
|
|
22930
|
-
const decoded =
|
|
23421
|
+
const decoded = import_web338.TransactionMessage.decompile(message2, {
|
|
22931
23422
|
addressLookupTableAccounts: tables
|
|
22932
23423
|
});
|
|
22933
|
-
const nestMint = new
|
|
22934
|
-
const sourceAta = (0,
|
|
22935
|
-
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);
|
|
22936
23427
|
const instructions2 = decoded.instructions.filter(
|
|
22937
|
-
(ix) => !ix.programId.equals(
|
|
23428
|
+
(ix) => !ix.programId.equals(import_web338.ComputeBudgetProgram.programId)
|
|
22938
23429
|
);
|
|
22939
23430
|
let sends = 0;
|
|
22940
23431
|
for (const ix of instructions2) {
|
|
22941
|
-
if (ix.programId.equals(
|
|
22942
|
-
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)) {
|
|
22943
23434
|
throw new Error("Unexpected token account creation in Nest withdrawal");
|
|
22944
23435
|
}
|
|
22945
23436
|
continue;
|
|
@@ -22956,20 +23447,20 @@ async function decodeNestWithdrawalRequest(args) {
|
|
|
22956
23447
|
if (sends !== 1)
|
|
22957
23448
|
throw new Error("Nest withdrawal must contain exactly one OFT send");
|
|
22958
23449
|
return {
|
|
22959
|
-
instructions: instructions2.map(
|
|
22960
|
-
lookupTables: tables.map((table) => (0,
|
|
23450
|
+
instructions: instructions2.map(import_common61.toKitInstruction),
|
|
23451
|
+
lookupTables: tables.map((table) => (0, import_kit20.address)(table.key.toBase58()))
|
|
22961
23452
|
};
|
|
22962
23453
|
}
|
|
22963
23454
|
|
|
22964
23455
|
// src/services/nestDepositService.ts
|
|
22965
|
-
var
|
|
22966
|
-
var
|
|
22967
|
-
var
|
|
22968
|
-
var
|
|
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());
|
|
22969
23460
|
var import_nest5 = __toESM(require_dist3());
|
|
22970
|
-
var Usdc = new
|
|
22971
|
-
var Messenger = new
|
|
22972
|
-
var Transmitter = new
|
|
23461
|
+
var Usdc = new import_web339.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
|
|
23462
|
+
var Messenger = new import_web339.PublicKey("CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe");
|
|
23463
|
+
var Transmitter = new import_web339.PublicKey(
|
|
22973
23464
|
"CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC"
|
|
22974
23465
|
);
|
|
22975
23466
|
var Router = Buffer.from(
|
|
@@ -23022,7 +23513,7 @@ async function decodeNestDepositRequest(args) {
|
|
|
23022
23513
|
"Nest deposit must be a positive, safely representable USDC base-unit amount"
|
|
23023
23514
|
);
|
|
23024
23515
|
}
|
|
23025
|
-
const message2 =
|
|
23516
|
+
const message2 = import_web339.VersionedTransaction.deserialize(
|
|
23026
23517
|
Buffer.from(args.txBase64, "base64")
|
|
23027
23518
|
).message;
|
|
23028
23519
|
if (!message2.staticAccountKeys[0].equals(args.owner))
|
|
@@ -23037,23 +23528,23 @@ async function decodeNestDepositRequest(args) {
|
|
|
23037
23528
|
return value;
|
|
23038
23529
|
})
|
|
23039
23530
|
);
|
|
23040
|
-
const instructions2 =
|
|
23531
|
+
const instructions2 = import_web339.TransactionMessage.decompile(message2, {
|
|
23041
23532
|
addressLookupTableAccounts: tables
|
|
23042
23533
|
}).instructions;
|
|
23043
|
-
const shareMint = new
|
|
23044
|
-
const shareAta = (0,
|
|
23045
|
-
const usdcAta = (0,
|
|
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);
|
|
23046
23537
|
let burn;
|
|
23047
23538
|
for (const ix of instructions2) {
|
|
23048
|
-
if (ix.programId.equals(
|
|
23049
|
-
if (ix.programId.equals(
|
|
23050
|
-
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(
|
|
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))
|
|
23051
23542
|
throw new Error("Unexpected Nest deposit token account creation");
|
|
23052
23543
|
continue;
|
|
23053
23544
|
}
|
|
23054
23545
|
const d = ix.data;
|
|
23055
23546
|
const matches = (index, key) => ix.keys[index]?.pubkey.equals(key);
|
|
23056
|
-
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,
|
|
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(
|
|
23057
23548
|
(meta, index) => meta.isSigner && ![0, 1, 11].includes(index)
|
|
23058
23549
|
)) {
|
|
23059
23550
|
throw new Error(
|
|
@@ -23072,21 +23563,21 @@ async function decodeNestDepositRequest(args) {
|
|
|
23072
23563
|
burn.keys[1] = { pubkey: args.owner, isSigner: true, isWritable: true };
|
|
23073
23564
|
return {
|
|
23074
23565
|
instructions: [
|
|
23075
|
-
(0,
|
|
23566
|
+
(0, import_spl_token24.createAssociatedTokenAccountIdempotentInstruction)(
|
|
23076
23567
|
args.owner,
|
|
23077
23568
|
shareAta,
|
|
23078
23569
|
args.owner,
|
|
23079
23570
|
shareMint
|
|
23080
23571
|
),
|
|
23081
23572
|
burn
|
|
23082
|
-
].map(
|
|
23083
|
-
lookupTables: tables.map((table) => (0,
|
|
23573
|
+
].map(import_common62.toKitInstruction),
|
|
23574
|
+
lookupTables: tables.map((table) => (0, import_kit21.address)(table.key.toBase58())),
|
|
23084
23575
|
ephemeralSignerKeys: [eventKey]
|
|
23085
23576
|
};
|
|
23086
23577
|
}
|
|
23087
23578
|
|
|
23088
23579
|
// src/index.ts
|
|
23089
|
-
var
|
|
23580
|
+
var import_common63 = __toESM(require_dist());
|
|
23090
23581
|
// Annotate the CommonJS export names for ESM import in node:
|
|
23091
23582
|
0 && (module.exports = {
|
|
23092
23583
|
ASSET_DECIMALS,
|
|
@@ -23126,6 +23617,7 @@ var import_common62 = __toESM(require_dist());
|
|
|
23126
23617
|
DEFAULT_TARGET_LOCAL_BPS,
|
|
23127
23618
|
DEFAULT_TARGET_LOCAL_USDC_TVL_BPS,
|
|
23128
23619
|
DEFAULT_VAULT_ID,
|
|
23620
|
+
DepositCuratorFeesBuilder,
|
|
23129
23621
|
DisableCircuitBreakerBuilder,
|
|
23130
23622
|
DistributeIncentiveBuilder,
|
|
23131
23623
|
DistributeIncentiveV3Builder,
|
|
@@ -23155,6 +23647,7 @@ var import_common62 = __toESM(require_dist());
|
|
|
23155
23647
|
MANAGER_WALLET_NAV_DROP_TRIGGER_BPS,
|
|
23156
23648
|
MANAGER_WALLET_NAV_TOLERANCE_BPS,
|
|
23157
23649
|
MAX_APY_ANCHOR_WINDOW_SECS,
|
|
23650
|
+
MAX_APY_PREVIOUS_ANCHOR_AGE_SECS,
|
|
23158
23651
|
MAX_BALANCE_CHANGE_BPS,
|
|
23159
23652
|
MAX_CONSENSUS_SIGNERS,
|
|
23160
23653
|
MAX_INCENTIVE_RECIPIENTS,
|
|
@@ -23187,6 +23680,7 @@ var import_common62 = __toESM(require_dist());
|
|
|
23187
23680
|
ReportIncentiveV3Builder,
|
|
23188
23681
|
RequestJuniorTrancheWithdrawBuilder,
|
|
23189
23682
|
RpcManagerWalletBalanceSource,
|
|
23683
|
+
RpcMpcWalletBalanceSource,
|
|
23190
23684
|
SHARE_DECIMALS,
|
|
23191
23685
|
SYSTEM_PROGRAM,
|
|
23192
23686
|
SetAssetPriceOracleBuilder,
|