@perena/vault-sdk 1.0.50 → 1.0.53
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 +324 -5
- package/dist/index.js +1465 -902
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -149,7 +149,7 @@ var require_compat = __commonJS({
|
|
|
149
149
|
exports2.fromWeb3PublicKey = fromWeb3PublicKey;
|
|
150
150
|
exports2.toWeb3PublicKey = toWeb3PublicKey;
|
|
151
151
|
exports2.asWeb3PublicKey = asWeb3PublicKey2;
|
|
152
|
-
exports2.toKitInstruction =
|
|
152
|
+
exports2.toKitInstruction = toKitInstruction37;
|
|
153
153
|
exports2.fromKitInstruction = fromKitInstruction3;
|
|
154
154
|
var kit_1 = require("@solana/kit");
|
|
155
155
|
var web3_js_1 = require("@solana/web3.js");
|
|
@@ -165,7 +165,7 @@ var require_compat = __commonJS({
|
|
|
165
165
|
exports2.toAddress = fromWeb3PublicKey;
|
|
166
166
|
exports2.fromWeb3Pk = fromWeb3PublicKey;
|
|
167
167
|
exports2.toWeb3Pk = toWeb3PublicKey;
|
|
168
|
-
function
|
|
168
|
+
function toKitInstruction37(ix) {
|
|
169
169
|
return {
|
|
170
170
|
programAddress: ix.programId.toBase58(),
|
|
171
171
|
data: new Uint8Array(ix.data),
|
|
@@ -194,10 +194,10 @@ var require_ata = __commonJS({
|
|
|
194
194
|
"../common/dist/utils/accounts/ata.js"(exports2) {
|
|
195
195
|
"use strict";
|
|
196
196
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
197
|
-
exports2.getAtaAddress =
|
|
197
|
+
exports2.getAtaAddress = getAtaAddress21;
|
|
198
198
|
var spl_token_1 = require("@solana/spl-token");
|
|
199
199
|
var compat_1 = require_compat();
|
|
200
|
-
function
|
|
200
|
+
function getAtaAddress21(mint, owner, tokenProgram, allowOwnerOffCurve = true) {
|
|
201
201
|
const ata = (0, spl_token_1.getAssociatedTokenAddressSync)((0, compat_1.toWeb3PublicKey)(mint), (0, compat_1.toWeb3PublicKey)(owner), allowOwnerOffCurve, (0, compat_1.toWeb3PublicKey)(tokenProgram), spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
|
|
202
202
|
return ata.toBase58();
|
|
203
203
|
}
|
|
@@ -253,9 +253,9 @@ var require_meta = __commonJS({
|
|
|
253
253
|
exports2.toCustomAccountMeta = toCustomAccountMeta;
|
|
254
254
|
exports2.toCustomAccountMetaFromWeb3AccountMeta = toCustomAccountMetaFromWeb3AccountMeta;
|
|
255
255
|
var roles_1 = require_roles();
|
|
256
|
-
function toCustomAccountMeta(
|
|
256
|
+
function toCustomAccountMeta(address16, isWritable, requiredAtaDetails, isSigner) {
|
|
257
257
|
const role = (0, roles_1.getAccountRole)(isWritable ?? false, isSigner ?? false);
|
|
258
|
-
return { address:
|
|
258
|
+
return { address: address16, role, isRequiredAta: requiredAtaDetails };
|
|
259
259
|
}
|
|
260
260
|
function toCustomAccountMetaFromWeb3AccountMeta(web3AccountMeta) {
|
|
261
261
|
return toCustomAccountMeta(web3AccountMeta.pubkey.toBase58(), web3AccountMeta.isWritable, void 0, web3AccountMeta.isSigner);
|
|
@@ -1236,8 +1236,8 @@ var require_cpiClient = __commonJS({
|
|
|
1236
1236
|
var kit_1 = require("@solana/kit");
|
|
1237
1237
|
var common_1 = require_dist();
|
|
1238
1238
|
var constants_1 = require_constants3();
|
|
1239
|
-
function account(
|
|
1240
|
-
return { address:
|
|
1239
|
+
function account(address16, role) {
|
|
1240
|
+
return { address: address16, role };
|
|
1241
1241
|
}
|
|
1242
1242
|
function requiredAddress(value, label) {
|
|
1243
1243
|
if (!value) {
|
|
@@ -1326,7 +1326,7 @@ var require_cpiClient = __commonJS({
|
|
|
1326
1326
|
});
|
|
1327
1327
|
const bankAndOracleRemainingAccounts = [
|
|
1328
1328
|
account(this.accounts.bank, kit_1.AccountRole.READONLY),
|
|
1329
|
-
...this.accounts.oracleAccounts.map((
|
|
1329
|
+
...this.accounts.oracleAccounts.map((address16) => account(address16, kit_1.AccountRole.READONLY))
|
|
1330
1330
|
];
|
|
1331
1331
|
return {
|
|
1332
1332
|
cpiType: params.cpiType ?? common_1.CpiTypes.MARGINFI_WITHDRAW,
|
|
@@ -1391,13 +1391,13 @@ var require_positions = __commonJS({
|
|
|
1391
1391
|
"../../node_modules/.pnpm/marginfi@file+typescript+marginfi_bufferutil@4.1.0_fastestsmallesttextencoderdecoder@1._7432de83e22e4bcea0493cabf074a552/node_modules/marginfi/dist/positions.js"(exports2) {
|
|
1392
1392
|
"use strict";
|
|
1393
1393
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1394
|
-
exports2.parseBankPksFromMarginfiAccount =
|
|
1395
|
-
exports2.createMarginfiReadClient =
|
|
1394
|
+
exports2.parseBankPksFromMarginfiAccount = parseBankPksFromMarginfiAccount4;
|
|
1395
|
+
exports2.createMarginfiReadClient = createMarginfiReadClient4;
|
|
1396
1396
|
exports2.readMarginfiBankBalance = readMarginfiBankBalance2;
|
|
1397
1397
|
exports2.readAllMarginfiBalances = readAllMarginfiBalances2;
|
|
1398
1398
|
var web3_js_1 = require("@solana/web3.js");
|
|
1399
1399
|
var marginfi_client_v2_1 = require("@mrgnlabs/marginfi-client-v2");
|
|
1400
|
-
function
|
|
1400
|
+
function parseBankPksFromMarginfiAccount4(data) {
|
|
1401
1401
|
const DISCRIMINATOR = 8;
|
|
1402
1402
|
const LENDING_ACCOUNT_OFFSET = DISCRIMINATOR + 32 + 32;
|
|
1403
1403
|
const BALANCE_SIZE = 104;
|
|
@@ -1414,7 +1414,7 @@ var require_positions = __commonJS({
|
|
|
1414
1414
|
}
|
|
1415
1415
|
return out;
|
|
1416
1416
|
}
|
|
1417
|
-
async function
|
|
1417
|
+
async function createMarginfiReadClient4(connection, preloadedBankAddresses = []) {
|
|
1418
1418
|
return marginfi_client_v2_1.MarginfiClient.fetch((0, marginfi_client_v2_1.getConfig)("production"), void 0, connection, {
|
|
1419
1419
|
preloadedBankAddresses,
|
|
1420
1420
|
// Balance readers use on-chain shares and bank addresses, not metadata.
|
|
@@ -2978,12 +2978,12 @@ var require_routePreInstructions = __commonJS({
|
|
|
2978
2978
|
if (existingAta.value) {
|
|
2979
2979
|
continue;
|
|
2980
2980
|
}
|
|
2981
|
-
instructions2.push(
|
|
2981
|
+
instructions2.push(toKitInstruction37((0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(new web3_js_1.PublicKey(payer), new web3_js_1.PublicKey(ata), new web3_js_1.PublicKey(user), new web3_js_1.PublicKey(mint), new web3_js_1.PublicKey(tokenProgram), spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID)));
|
|
2982
2982
|
postSuccessCacheInvalidations.push({ address: ata });
|
|
2983
2983
|
}
|
|
2984
2984
|
return { instructions: instructions2, postSuccessCacheInvalidations };
|
|
2985
2985
|
}
|
|
2986
|
-
function
|
|
2986
|
+
function toKitInstruction37(ix) {
|
|
2987
2987
|
return {
|
|
2988
2988
|
programAddress: ix.programId.toBase58(),
|
|
2989
2989
|
accounts: ix.keys.map((account) => ({
|
|
@@ -3302,7 +3302,7 @@ __export(index_exports, {
|
|
|
3302
3302
|
DEFAULT_JUNIOR_WITHDRAWAL_LOCKUP_SECS: () => DEFAULT_JUNIOR_WITHDRAWAL_LOCKUP_SECS,
|
|
3303
3303
|
DEFAULT_MAX_ACCEPTABLE_APY_BPS: () => DEFAULT_MAX_ACCEPTABLE_APY_BPS,
|
|
3304
3304
|
DEFAULT_MAX_ACCOUNTS: () => DEFAULT_MAX_ACCOUNTS,
|
|
3305
|
-
DEFAULT_MINTS: () =>
|
|
3305
|
+
DEFAULT_MINTS: () => import_common63.DEFAULT_MINTS,
|
|
3306
3306
|
DEFAULT_MIN_AMOUNT_UI: () => DEFAULT_MIN_AMOUNT_UI,
|
|
3307
3307
|
DEFAULT_ORACLE_STALENESS_THRESHOLD_SECS: () => DEFAULT_ORACLE_STALENESS_THRESHOLD_SECS,
|
|
3308
3308
|
DEFAULT_PRICE_ORACLE_ACCOUNT: () => DEFAULT_PRICE_ORACLE_ACCOUNT,
|
|
@@ -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,
|
|
@@ -3496,6 +3499,7 @@ __export(index_exports, {
|
|
|
3496
3499
|
prepareVaultTransaction: () => prepareVaultTransaction,
|
|
3497
3500
|
previousPhysicalNav: () => previousPhysicalNav,
|
|
3498
3501
|
priceInAccountingUnit: () => priceInAccountingUnit,
|
|
3502
|
+
publishedConsensusBlockers: () => publishedConsensusBlockers,
|
|
3499
3503
|
readI64LE: () => readI64LE,
|
|
3500
3504
|
readSplMintSupply: () => readSplMintSupply,
|
|
3501
3505
|
reconcileManagerWalletBalances: () => reconcileManagerWalletBalances,
|
|
@@ -3590,16 +3594,16 @@ var USD_STAR_PRINCIPAL_MINT = (0, import_kit.address)(
|
|
|
3590
3594
|
var import_fs = __toESM(require("fs"));
|
|
3591
3595
|
var import_os = __toESM(require("os"));
|
|
3592
3596
|
var import_path = __toESM(require("path"));
|
|
3593
|
-
var
|
|
3594
|
-
var
|
|
3597
|
+
var import_core21 = require("@anchor-lang/core");
|
|
3598
|
+
var import_web324 = require("@solana/web3.js");
|
|
3595
3599
|
var import_kit10 = require("@solana/kit");
|
|
3596
|
-
var
|
|
3600
|
+
var import_common44 = __toESM(require_dist());
|
|
3597
3601
|
|
|
3598
3602
|
// src/client/client.ts
|
|
3599
|
-
var
|
|
3603
|
+
var import_core20 = require("@anchor-lang/core");
|
|
3600
3604
|
var import_kit9 = require("@solana/kit");
|
|
3601
|
-
var
|
|
3602
|
-
var
|
|
3605
|
+
var import_web323 = require("@solana/web3.js");
|
|
3606
|
+
var import_common43 = __toESM(require_dist());
|
|
3603
3607
|
|
|
3604
3608
|
// src/idl/vault.ts
|
|
3605
3609
|
var IDL = {
|
|
@@ -4450,6 +4454,184 @@ var IDL = {
|
|
|
4450
4454
|
}
|
|
4451
4455
|
]
|
|
4452
4456
|
},
|
|
4457
|
+
{
|
|
4458
|
+
name: "deposit_curator_fees",
|
|
4459
|
+
discriminator: [180, 215, 34, 119, 191, 100, 32, 220],
|
|
4460
|
+
accounts: [
|
|
4461
|
+
{
|
|
4462
|
+
name: "curator",
|
|
4463
|
+
docs: [
|
|
4464
|
+
"May also be a curator PDA signing through CPI (for example Squads)."
|
|
4465
|
+
],
|
|
4466
|
+
writable: true,
|
|
4467
|
+
signer: true
|
|
4468
|
+
},
|
|
4469
|
+
{
|
|
4470
|
+
name: "vault",
|
|
4471
|
+
writable: true
|
|
4472
|
+
},
|
|
4473
|
+
{
|
|
4474
|
+
name: "vault_oracle",
|
|
4475
|
+
writable: true
|
|
4476
|
+
},
|
|
4477
|
+
{
|
|
4478
|
+
name: "share_mint"
|
|
4479
|
+
},
|
|
4480
|
+
{
|
|
4481
|
+
name: "vault_tranche_state",
|
|
4482
|
+
writable: true,
|
|
4483
|
+
optional: true
|
|
4484
|
+
},
|
|
4485
|
+
{
|
|
4486
|
+
name: "junior_tranche_share_mint",
|
|
4487
|
+
optional: true
|
|
4488
|
+
},
|
|
4489
|
+
{
|
|
4490
|
+
name: "senior_tranche_share_mint",
|
|
4491
|
+
optional: true
|
|
4492
|
+
},
|
|
4493
|
+
{
|
|
4494
|
+
name: "usdc_mint",
|
|
4495
|
+
address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
|
|
4496
|
+
},
|
|
4497
|
+
{
|
|
4498
|
+
name: "curator_usdc_ata",
|
|
4499
|
+
writable: true,
|
|
4500
|
+
pda: {
|
|
4501
|
+
seeds: [
|
|
4502
|
+
{
|
|
4503
|
+
kind: "account",
|
|
4504
|
+
path: "curator"
|
|
4505
|
+
},
|
|
4506
|
+
{
|
|
4507
|
+
kind: "account",
|
|
4508
|
+
path: "token_program"
|
|
4509
|
+
},
|
|
4510
|
+
{
|
|
4511
|
+
kind: "account",
|
|
4512
|
+
path: "usdc_mint"
|
|
4513
|
+
}
|
|
4514
|
+
],
|
|
4515
|
+
program: {
|
|
4516
|
+
kind: "const",
|
|
4517
|
+
value: [
|
|
4518
|
+
140,
|
|
4519
|
+
151,
|
|
4520
|
+
37,
|
|
4521
|
+
143,
|
|
4522
|
+
78,
|
|
4523
|
+
36,
|
|
4524
|
+
137,
|
|
4525
|
+
241,
|
|
4526
|
+
187,
|
|
4527
|
+
61,
|
|
4528
|
+
16,
|
|
4529
|
+
41,
|
|
4530
|
+
20,
|
|
4531
|
+
142,
|
|
4532
|
+
13,
|
|
4533
|
+
131,
|
|
4534
|
+
11,
|
|
4535
|
+
90,
|
|
4536
|
+
19,
|
|
4537
|
+
153,
|
|
4538
|
+
218,
|
|
4539
|
+
255,
|
|
4540
|
+
16,
|
|
4541
|
+
132,
|
|
4542
|
+
4,
|
|
4543
|
+
142,
|
|
4544
|
+
123,
|
|
4545
|
+
216,
|
|
4546
|
+
219,
|
|
4547
|
+
233,
|
|
4548
|
+
248,
|
|
4549
|
+
89
|
|
4550
|
+
]
|
|
4551
|
+
}
|
|
4552
|
+
}
|
|
4553
|
+
},
|
|
4554
|
+
{
|
|
4555
|
+
name: "vault_usdc_ata",
|
|
4556
|
+
writable: true,
|
|
4557
|
+
pda: {
|
|
4558
|
+
seeds: [
|
|
4559
|
+
{
|
|
4560
|
+
kind: "account",
|
|
4561
|
+
path: "vault"
|
|
4562
|
+
},
|
|
4563
|
+
{
|
|
4564
|
+
kind: "account",
|
|
4565
|
+
path: "token_program"
|
|
4566
|
+
},
|
|
4567
|
+
{
|
|
4568
|
+
kind: "account",
|
|
4569
|
+
path: "usdc_mint"
|
|
4570
|
+
}
|
|
4571
|
+
],
|
|
4572
|
+
program: {
|
|
4573
|
+
kind: "const",
|
|
4574
|
+
value: [
|
|
4575
|
+
140,
|
|
4576
|
+
151,
|
|
4577
|
+
37,
|
|
4578
|
+
143,
|
|
4579
|
+
78,
|
|
4580
|
+
36,
|
|
4581
|
+
137,
|
|
4582
|
+
241,
|
|
4583
|
+
187,
|
|
4584
|
+
61,
|
|
4585
|
+
16,
|
|
4586
|
+
41,
|
|
4587
|
+
20,
|
|
4588
|
+
142,
|
|
4589
|
+
13,
|
|
4590
|
+
131,
|
|
4591
|
+
11,
|
|
4592
|
+
90,
|
|
4593
|
+
19,
|
|
4594
|
+
153,
|
|
4595
|
+
218,
|
|
4596
|
+
255,
|
|
4597
|
+
16,
|
|
4598
|
+
132,
|
|
4599
|
+
4,
|
|
4600
|
+
142,
|
|
4601
|
+
123,
|
|
4602
|
+
216,
|
|
4603
|
+
219,
|
|
4604
|
+
233,
|
|
4605
|
+
248,
|
|
4606
|
+
89
|
|
4607
|
+
]
|
|
4608
|
+
}
|
|
4609
|
+
}
|
|
4610
|
+
},
|
|
4611
|
+
{
|
|
4612
|
+
name: "token_program",
|
|
4613
|
+
address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
|
|
4614
|
+
},
|
|
4615
|
+
{
|
|
4616
|
+
name: "associated_token_program",
|
|
4617
|
+
address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
|
4618
|
+
},
|
|
4619
|
+
{
|
|
4620
|
+
name: "system_program",
|
|
4621
|
+
address: "11111111111111111111111111111111"
|
|
4622
|
+
}
|
|
4623
|
+
],
|
|
4624
|
+
args: [
|
|
4625
|
+
{
|
|
4626
|
+
name: "args",
|
|
4627
|
+
type: {
|
|
4628
|
+
defined: {
|
|
4629
|
+
name: "DepositCuratorFeesArgs"
|
|
4630
|
+
}
|
|
4631
|
+
}
|
|
4632
|
+
}
|
|
4633
|
+
]
|
|
4634
|
+
},
|
|
4453
4635
|
{
|
|
4454
4636
|
name: "disable_circuit_breaker",
|
|
4455
4637
|
discriminator: [200, 37, 34, 37, 19, 156, 178, 253],
|
|
@@ -10008,6 +10190,10 @@ var IDL = {
|
|
|
10008
10190
|
}
|
|
10009
10191
|
],
|
|
10010
10192
|
events: [
|
|
10193
|
+
{
|
|
10194
|
+
name: "CuratorFeesDeposited",
|
|
10195
|
+
discriminator: [61, 40, 69, 224, 253, 73, 224, 46]
|
|
10196
|
+
},
|
|
10011
10197
|
{
|
|
10012
10198
|
name: "IncentiveClaimed",
|
|
10013
10199
|
discriminator: [93, 82, 106, 244, 88, 183, 241, 75]
|
|
@@ -10046,6 +10232,11 @@ var IDL = {
|
|
|
10046
10232
|
}
|
|
10047
10233
|
],
|
|
10048
10234
|
errors: [
|
|
10235
|
+
{
|
|
10236
|
+
code: 13048,
|
|
10237
|
+
name: "MinimumCuratorFeeSharesNotMet",
|
|
10238
|
+
msg: "Deposited USDC credits fewer curator shares than the requested minimum"
|
|
10239
|
+
},
|
|
10049
10240
|
{
|
|
10050
10241
|
code: 14001,
|
|
10051
10242
|
name: "Unauthorized",
|
|
@@ -10620,6 +10811,56 @@ var IDL = {
|
|
|
10620
10811
|
]
|
|
10621
10812
|
}
|
|
10622
10813
|
},
|
|
10814
|
+
{
|
|
10815
|
+
name: "CuratorFeesDeposited",
|
|
10816
|
+
type: {
|
|
10817
|
+
kind: "struct",
|
|
10818
|
+
fields: [
|
|
10819
|
+
{
|
|
10820
|
+
name: "vault",
|
|
10821
|
+
type: "pubkey"
|
|
10822
|
+
},
|
|
10823
|
+
{
|
|
10824
|
+
name: "curator",
|
|
10825
|
+
type: "pubkey"
|
|
10826
|
+
},
|
|
10827
|
+
{
|
|
10828
|
+
name: "usdc_amount",
|
|
10829
|
+
type: "u64"
|
|
10830
|
+
},
|
|
10831
|
+
{
|
|
10832
|
+
name: "accounting_amount",
|
|
10833
|
+
type: "u64"
|
|
10834
|
+
},
|
|
10835
|
+
{
|
|
10836
|
+
name: "curator_shares",
|
|
10837
|
+
type: "u64"
|
|
10838
|
+
}
|
|
10839
|
+
]
|
|
10840
|
+
}
|
|
10841
|
+
},
|
|
10842
|
+
{
|
|
10843
|
+
name: "DepositCuratorFeesArgs",
|
|
10844
|
+
type: {
|
|
10845
|
+
kind: "struct",
|
|
10846
|
+
fields: [
|
|
10847
|
+
{
|
|
10848
|
+
name: "amount",
|
|
10849
|
+
docs: [
|
|
10850
|
+
"USDC atomic units transferred from the curator (six decimals)."
|
|
10851
|
+
],
|
|
10852
|
+
type: "u64"
|
|
10853
|
+
},
|
|
10854
|
+
{
|
|
10855
|
+
name: "min_shares_out",
|
|
10856
|
+
docs: [
|
|
10857
|
+
"Minimum newly credited curator shares; checked at execution-time NAV."
|
|
10858
|
+
],
|
|
10859
|
+
type: "u64"
|
|
10860
|
+
}
|
|
10861
|
+
]
|
|
10862
|
+
}
|
|
10863
|
+
},
|
|
10623
10864
|
{
|
|
10624
10865
|
name: "ExternalLiquiditySlot",
|
|
10625
10866
|
serialization: "bytemuck",
|
|
@@ -14921,38 +15162,115 @@ var DistributeIncentiveV3Builder = class extends DistributeIncentiveBuilder {
|
|
|
14921
15162
|
}
|
|
14922
15163
|
};
|
|
14923
15164
|
|
|
14924
|
-
// src/client/builders/
|
|
15165
|
+
// src/client/builders/depositCuratorFees.ts
|
|
15166
|
+
var import_core3 = require("@anchor-lang/core");
|
|
14925
15167
|
var import_spl_token4 = require("@solana/spl-token");
|
|
14926
15168
|
var import_web37 = require("@solana/web3.js");
|
|
14927
15169
|
var import_common9 = __toESM(require_dist());
|
|
14928
|
-
|
|
15170
|
+
function validateAmounts(args) {
|
|
15171
|
+
if (args.amount <= 0n || args.amount > 0xffffffffffffffffn)
|
|
15172
|
+
throw new RangeError("amount must be a positive u64 in USDC atomic units");
|
|
15173
|
+
const min = args.minSharesOut ?? 0n;
|
|
15174
|
+
if (min < 0n || min > 0xffffffffffffffffn)
|
|
15175
|
+
throw new RangeError("minSharesOut must fit u64");
|
|
15176
|
+
}
|
|
15177
|
+
var DepositCuratorFeesBuilder = class extends VaultBuilderBase {
|
|
14929
15178
|
async getIx(args) {
|
|
14930
|
-
|
|
14931
|
-
|
|
14932
|
-
|
|
15179
|
+
validateAmounts(args);
|
|
15180
|
+
return this.program.methods.depositCuratorFees({
|
|
15181
|
+
amount: new import_core3.BN(args.amount.toString()),
|
|
15182
|
+
minSharesOut: new import_core3.BN((args.minSharesOut ?? 0n).toString())
|
|
15183
|
+
}).accountsStrict({
|
|
15184
|
+
curator: (0, import_common9.toWeb3Pk)(args.curator),
|
|
14933
15185
|
vault: (0, import_common9.toWeb3Pk)(args.vault),
|
|
14934
|
-
|
|
14935
|
-
|
|
14936
|
-
|
|
14937
|
-
|
|
14938
|
-
|
|
15186
|
+
vaultOracle: (0, import_common9.toWeb3Pk)(args.vaultOracle),
|
|
15187
|
+
shareMint: (0, import_common9.toWeb3Pk)(args.shareMint),
|
|
15188
|
+
vaultTrancheState: args.vaultTrancheState ? (0, import_common9.toWeb3Pk)(args.vaultTrancheState) : null,
|
|
15189
|
+
juniorTrancheShareMint: args.juniorTrancheShareMint ? (0, import_common9.toWeb3Pk)(args.juniorTrancheShareMint) : null,
|
|
15190
|
+
seniorTrancheShareMint: args.seniorTrancheShareMint ? (0, import_common9.toWeb3Pk)(args.seniorTrancheShareMint) : null,
|
|
15191
|
+
usdcMint: (0, import_common9.toWeb3Pk)(USDC_MINT),
|
|
15192
|
+
curatorUsdcAta: (0, import_common9.toWeb3Pk)(args.curatorUsdcAta),
|
|
15193
|
+
vaultUsdcAta: (0, import_common9.toWeb3Pk)(args.vaultUsdcAta),
|
|
15194
|
+
tokenProgram: import_spl_token4.TOKEN_PROGRAM_ID,
|
|
14939
15195
|
associatedTokenProgram: import_spl_token4.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
14940
15196
|
systemProgram: import_web37.SystemProgram.programId
|
|
14941
15197
|
}).instruction().then(import_common9.toKitInstruction);
|
|
14942
15198
|
}
|
|
14943
|
-
async deriveIxArgs(
|
|
14944
|
-
|
|
14945
|
-
const [
|
|
14946
|
-
|
|
14947
|
-
|
|
14948
|
-
|
|
14949
|
-
|
|
15199
|
+
async deriveIxArgs(args) {
|
|
15200
|
+
validateAmounts(args);
|
|
15201
|
+
const [vaultOracle] = await this.pda.deriveVaultOraclePda(args.vault);
|
|
15202
|
+
const vault = await this.account.fetchVault(args.vault, { fresh: true });
|
|
15203
|
+
const vaultTrancheState = await resolveVaultTrancheState(
|
|
15204
|
+
this.account,
|
|
15205
|
+
this.pda,
|
|
15206
|
+
args.vault,
|
|
15207
|
+
void 0
|
|
15208
|
+
);
|
|
15209
|
+
const tranche = vaultTrancheState ? await this.account.fetchVaultTrancheState(vaultTrancheState, {
|
|
15210
|
+
fresh: true
|
|
15211
|
+
}) : null;
|
|
15212
|
+
const tokenProgram = (0, import_common9.fromWeb3Pk)(import_spl_token4.TOKEN_PROGRAM_ID);
|
|
15213
|
+
return {
|
|
15214
|
+
...args,
|
|
15215
|
+
vaultOracle,
|
|
15216
|
+
shareMint: (0, import_common9.fromWeb3Pk)(vault.mint),
|
|
15217
|
+
vaultTrancheState,
|
|
15218
|
+
juniorTrancheShareMint: tranche ? (0, import_common9.fromWeb3Pk)(tranche.config.juniorMint) : null,
|
|
15219
|
+
seniorTrancheShareMint: tranche ? (0, import_common9.fromWeb3Pk)(tranche.config.seniorMint) : null,
|
|
15220
|
+
curatorUsdcAta: (0, import_common9.getAtaAddress)(
|
|
15221
|
+
USDC_MINT,
|
|
15222
|
+
args.curator,
|
|
15223
|
+
tokenProgram,
|
|
15224
|
+
true
|
|
14950
15225
|
),
|
|
14951
|
-
|
|
14952
|
-
|
|
14953
|
-
|
|
14954
|
-
|
|
14955
|
-
|
|
15226
|
+
vaultUsdcAta: (0, import_common9.getAtaAddress)(USDC_MINT, args.vault, tokenProgram, true)
|
|
15227
|
+
};
|
|
15228
|
+
}
|
|
15229
|
+
async buildPlanExtras(args) {
|
|
15230
|
+
return {
|
|
15231
|
+
postSuccessCacheInvalidations: [
|
|
15232
|
+
{
|
|
15233
|
+
vaultPda: args.vault,
|
|
15234
|
+
vaultOraclePda: args.vaultOracle,
|
|
15235
|
+
vaultTrancheStatePda: args.vaultTrancheState ?? void 0
|
|
15236
|
+
}
|
|
15237
|
+
]
|
|
15238
|
+
};
|
|
15239
|
+
}
|
|
15240
|
+
};
|
|
15241
|
+
|
|
15242
|
+
// src/client/builders/cancelJuniorTrancheWithdraw.ts
|
|
15243
|
+
var import_spl_token5 = require("@solana/spl-token");
|
|
15244
|
+
var import_web38 = require("@solana/web3.js");
|
|
15245
|
+
var import_common10 = __toESM(require_dist());
|
|
15246
|
+
var CancelJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
15247
|
+
async getIx(args) {
|
|
15248
|
+
return this.program.methods.cancelJuniorTrancheWithdraw().accountsPartial({
|
|
15249
|
+
user: (0, import_common10.toWeb3Pk)(args.user),
|
|
15250
|
+
payer: (0, import_common10.toWeb3Pk)(args.payer),
|
|
15251
|
+
vault: (0, import_common10.toWeb3Pk)(args.vault),
|
|
15252
|
+
withdrawalQueue: (0, import_common10.toWeb3Pk)(args.withdrawalQueue),
|
|
15253
|
+
inputMint: (0, import_common10.toWeb3Pk)(args.inputMint),
|
|
15254
|
+
userInputAta: (0, import_common10.toWeb3Pk)(args.userInputAta),
|
|
15255
|
+
queueInputAta: (0, import_common10.toWeb3Pk)(args.queueInputAta),
|
|
15256
|
+
shareTokenProgram: (0, import_common10.toWeb3Pk)(args.shareTokenProgram),
|
|
15257
|
+
associatedTokenProgram: import_spl_token5.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
15258
|
+
systemProgram: import_web38.SystemProgram.programId
|
|
15259
|
+
}).instruction().then(import_common10.toKitInstruction);
|
|
15260
|
+
}
|
|
15261
|
+
async deriveIxArgs(txArgs) {
|
|
15262
|
+
const payer = txArgs.payer ?? txArgs.user;
|
|
15263
|
+
const [[withdrawalQueue], juniorShare] = await Promise.all([
|
|
15264
|
+
this.pda.deriveVaultTrancheWithdrawalQueuePda(
|
|
15265
|
+
txArgs.vault,
|
|
15266
|
+
txArgs.user,
|
|
15267
|
+
txArgs.queueId
|
|
15268
|
+
),
|
|
15269
|
+
resolveTrancheShare(
|
|
15270
|
+
this.account,
|
|
15271
|
+
txArgs.vault,
|
|
15272
|
+
{ junior: {} },
|
|
15273
|
+
{
|
|
14956
15274
|
mint: txArgs.juniorShareMint,
|
|
14957
15275
|
tokenProgram: txArgs.shareTokenProgram
|
|
14958
15276
|
}
|
|
@@ -14967,8 +15285,8 @@ var CancelJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
14967
15285
|
withdrawalQueue: queuePda,
|
|
14968
15286
|
inputMint: juniorShareMint,
|
|
14969
15287
|
shareTokenProgram,
|
|
14970
|
-
userInputAta: txArgs.userInputAta ?? (0,
|
|
14971
|
-
queueInputAta: (0,
|
|
15288
|
+
userInputAta: txArgs.userInputAta ?? (0, import_common10.getAtaAddress)(juniorShareMint, txArgs.user, shareTokenProgram),
|
|
15289
|
+
queueInputAta: (0, import_common10.getAtaAddress)(
|
|
14972
15290
|
juniorShareMint,
|
|
14973
15291
|
queuePda,
|
|
14974
15292
|
shareTokenProgram,
|
|
@@ -14986,19 +15304,19 @@ var CancelJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
14986
15304
|
};
|
|
14987
15305
|
|
|
14988
15306
|
// src/client/builders/createAssetHolding.ts
|
|
14989
|
-
var
|
|
15307
|
+
var import_common11 = __toESM(require_dist());
|
|
14990
15308
|
var CreateAssetHoldingBuilder = class extends VaultBuilderBase {
|
|
14991
15309
|
async getIx(args) {
|
|
14992
15310
|
return this.program.methods.createAssetHolding({
|
|
14993
15311
|
priceOracleType: args.args.priceOracleType,
|
|
14994
|
-
priceOracleAccount: (0,
|
|
15312
|
+
priceOracleAccount: (0, import_common11.toWeb3Pk)(args.args.priceOracleAccount)
|
|
14995
15313
|
}).accountsPartial({
|
|
14996
|
-
hwManager: (0,
|
|
14997
|
-
vault: (0,
|
|
14998
|
-
vaultOracle: (0,
|
|
14999
|
-
mint: (0,
|
|
15000
|
-
tokenProgram: (0,
|
|
15001
|
-
}).instruction().then(
|
|
15314
|
+
hwManager: (0, import_common11.toWeb3Pk)(args.hwManager),
|
|
15315
|
+
vault: (0, import_common11.toWeb3Pk)(args.vault),
|
|
15316
|
+
vaultOracle: (0, import_common11.toWeb3Pk)(args.vaultOracle),
|
|
15317
|
+
mint: (0, import_common11.toWeb3Pk)(args.mint),
|
|
15318
|
+
tokenProgram: (0, import_common11.toWeb3Pk)(args.tokenProgram)
|
|
15319
|
+
}).instruction().then(import_common11.toKitInstruction);
|
|
15002
15320
|
}
|
|
15003
15321
|
async deriveIxArgs(txArgs) {
|
|
15004
15322
|
const [vaultOracle] = await this.pda.deriveVaultOraclePda(txArgs.vault);
|
|
@@ -15024,15 +15342,15 @@ var CreateAssetHoldingBuilder = class extends VaultBuilderBase {
|
|
|
15024
15342
|
};
|
|
15025
15343
|
|
|
15026
15344
|
// src/client/builders/removeAssetHolding.ts
|
|
15027
|
-
var
|
|
15345
|
+
var import_common12 = __toESM(require_dist());
|
|
15028
15346
|
var RemoveAssetHoldingBuilder = class extends VaultBuilderBase {
|
|
15029
15347
|
async getIx(args) {
|
|
15030
15348
|
return this.program.methods.removeAssetHolding().accountsPartial({
|
|
15031
|
-
hwManager: (0,
|
|
15032
|
-
vault: (0,
|
|
15033
|
-
vaultOracle: (0,
|
|
15034
|
-
mint: (0,
|
|
15035
|
-
}).instruction().then(
|
|
15349
|
+
hwManager: (0, import_common12.toWeb3Pk)(args.hwManager),
|
|
15350
|
+
vault: (0, import_common12.toWeb3Pk)(args.vault),
|
|
15351
|
+
vaultOracle: (0, import_common12.toWeb3Pk)(args.vaultOracle),
|
|
15352
|
+
mint: (0, import_common12.toWeb3Pk)(args.mint)
|
|
15353
|
+
}).instruction().then(import_common12.toKitInstruction);
|
|
15036
15354
|
}
|
|
15037
15355
|
async deriveIxArgs(txArgs) {
|
|
15038
15356
|
const [vaultOracle] = await this.pda.deriveVaultOraclePda(txArgs.vault);
|
|
@@ -15053,16 +15371,16 @@ var RemoveAssetHoldingBuilder = class extends VaultBuilderBase {
|
|
|
15053
15371
|
};
|
|
15054
15372
|
|
|
15055
15373
|
// src/client/builders/updateConsensusSigners.ts
|
|
15056
|
-
var
|
|
15374
|
+
var import_common13 = __toESM(require_dist());
|
|
15057
15375
|
var UpdateConsensusSignersBuilder = class extends VaultBuilderBase {
|
|
15058
15376
|
async getIx(args) {
|
|
15059
15377
|
return this.program.methods.updateConsensusSigners({
|
|
15060
|
-
signers: args.args.signers.map(
|
|
15378
|
+
signers: args.args.signers.map(import_common13.toWeb3Pk)
|
|
15061
15379
|
}).accountsPartial({
|
|
15062
|
-
curator: (0,
|
|
15063
|
-
vault: (0,
|
|
15064
|
-
vaultOracle: (0,
|
|
15065
|
-
}).instruction().then(
|
|
15380
|
+
curator: (0, import_common13.toWeb3Pk)(args.curator),
|
|
15381
|
+
vault: (0, import_common13.toWeb3Pk)(args.vault),
|
|
15382
|
+
vaultOracle: (0, import_common13.toWeb3Pk)(args.vaultOracle)
|
|
15383
|
+
}).instruction().then(import_common13.toKitInstruction);
|
|
15066
15384
|
}
|
|
15067
15385
|
async deriveIxArgs(txArgs) {
|
|
15068
15386
|
const [vaultOracle] = await this.pda.deriveVaultOraclePda(txArgs.vault);
|
|
@@ -15083,9 +15401,9 @@ var UpdateConsensusSignersBuilder = class extends VaultBuilderBase {
|
|
|
15083
15401
|
};
|
|
15084
15402
|
|
|
15085
15403
|
// src/client/builders/createTrancheState.ts
|
|
15086
|
-
var
|
|
15087
|
-
var
|
|
15088
|
-
var
|
|
15404
|
+
var import_core4 = require("@anchor-lang/core");
|
|
15405
|
+
var import_web39 = require("@solana/web3.js");
|
|
15406
|
+
var import_common14 = __toESM(require_dist());
|
|
15089
15407
|
var CreateTrancheStateBuilder = class extends VaultBuilderBase {
|
|
15090
15408
|
async getIx(args) {
|
|
15091
15409
|
return this.program.methods.vaultCreateTrancheState({
|
|
@@ -15097,18 +15415,18 @@ var CreateTrancheStateBuilder = class extends VaultBuilderBase {
|
|
|
15097
15415
|
juniorDepositCap: args.juniorDepositCap,
|
|
15098
15416
|
forMigration: args.forMigration
|
|
15099
15417
|
}).accountsPartial({
|
|
15100
|
-
curator: (0,
|
|
15101
|
-
vault: (0,
|
|
15102
|
-
vaultTrancheState: (0,
|
|
15103
|
-
juniorShareMint: (0,
|
|
15104
|
-
seniorShareMint: (0,
|
|
15418
|
+
curator: (0, import_common14.toWeb3Pk)(args.curator),
|
|
15419
|
+
vault: (0, import_common14.toWeb3Pk)(args.vault),
|
|
15420
|
+
vaultTrancheState: (0, import_common14.toWeb3Pk)(args.vaultTrancheState),
|
|
15421
|
+
juniorShareMint: (0, import_common14.toWeb3Pk)(args.juniorShareMint),
|
|
15422
|
+
seniorShareMint: (0, import_common14.toWeb3Pk)(args.seniorShareMint),
|
|
15105
15423
|
// Optional on-chain: required only on the organic path, where the
|
|
15106
15424
|
// program enforces a fresh NAV before enabling tranching. Left null on
|
|
15107
15425
|
// the migration path so Anchor resolves it to the program ID.
|
|
15108
|
-
vaultOracle: args.vaultOracle ? (0,
|
|
15109
|
-
tokenProgram: (0,
|
|
15110
|
-
systemProgram:
|
|
15111
|
-
}).instruction().then(
|
|
15426
|
+
vaultOracle: args.vaultOracle ? (0, import_common14.toWeb3Pk)(args.vaultOracle) : null,
|
|
15427
|
+
tokenProgram: (0, import_common14.toWeb3Pk)(args.tokenProgram),
|
|
15428
|
+
systemProgram: import_web39.SystemProgram.programId
|
|
15429
|
+
}).instruction().then(import_common14.toKitInstruction);
|
|
15112
15430
|
}
|
|
15113
15431
|
async deriveIxArgs(txArgs) {
|
|
15114
15432
|
const [vaultTrancheState] = await this.pda.deriveVaultTrancheStatePda(
|
|
@@ -15137,10 +15455,10 @@ var CreateTrancheStateBuilder = class extends VaultBuilderBase {
|
|
|
15137
15455
|
juniorFloorApyBps: txArgs.juniorFloorApyBps ?? 0,
|
|
15138
15456
|
earlyUnstakeFeeBps: txArgs.earlyUnstakeFeeBps ?? DEFAULT_JUNIOR_EARLY_UNSTAKE_FEE_BPS,
|
|
15139
15457
|
standardUnstakeFeeBps: txArgs.standardUnstakeFeeBps ?? DEFAULT_JUNIOR_STANDARD_UNSTAKE_FEE_BPS,
|
|
15140
|
-
targetLockupDurationSecs: new
|
|
15458
|
+
targetLockupDurationSecs: new import_core4.BN(
|
|
15141
15459
|
(txArgs.targetLockupDurationSecs ?? DEFAULT_JUNIOR_WITHDRAWAL_LOCKUP_SECS).toString()
|
|
15142
15460
|
),
|
|
15143
|
-
juniorDepositCap: new
|
|
15461
|
+
juniorDepositCap: new import_core4.BN((txArgs.juniorDepositCap ?? 0n).toString()),
|
|
15144
15462
|
forMigration,
|
|
15145
15463
|
tokenProgram: txArgs.tokenProgram ?? TOKEN_PROGRAM_ID
|
|
15146
15464
|
};
|
|
@@ -15155,13 +15473,13 @@ var CreateTrancheStateBuilder = class extends VaultBuilderBase {
|
|
|
15155
15473
|
};
|
|
15156
15474
|
|
|
15157
15475
|
// src/client/builders/activateCircuitBreaker.ts
|
|
15158
|
-
var
|
|
15476
|
+
var import_common15 = __toESM(require_dist());
|
|
15159
15477
|
var ActivateCircuitBreakerBuilder = class extends VaultBuilderBase {
|
|
15160
15478
|
async getIx(args) {
|
|
15161
15479
|
return this.program.methods.activateCircuitBreaker().accountsPartial({
|
|
15162
|
-
cbTrigger: (0,
|
|
15163
|
-
vault: (0,
|
|
15164
|
-
}).instruction().then(
|
|
15480
|
+
cbTrigger: (0, import_common15.toWeb3Pk)(args.cbTrigger),
|
|
15481
|
+
vault: (0, import_common15.toWeb3Pk)(args.vault)
|
|
15482
|
+
}).instruction().then(import_common15.toKitInstruction);
|
|
15165
15483
|
}
|
|
15166
15484
|
async deriveIxArgs(txArgs) {
|
|
15167
15485
|
return txArgs;
|
|
@@ -15174,34 +15492,34 @@ var ActivateCircuitBreakerBuilder = class extends VaultBuilderBase {
|
|
|
15174
15492
|
};
|
|
15175
15493
|
|
|
15176
15494
|
// src/client/builders/createVault.ts
|
|
15177
|
-
var
|
|
15495
|
+
var import_core6 = require("@anchor-lang/core");
|
|
15178
15496
|
var import_token = require("@solana-program/token");
|
|
15179
|
-
var
|
|
15180
|
-
var
|
|
15181
|
-
var
|
|
15497
|
+
var import_spl_token6 = require("@solana/spl-token");
|
|
15498
|
+
var import_web310 = require("@solana/web3.js");
|
|
15499
|
+
var import_common17 = __toESM(require_dist());
|
|
15182
15500
|
|
|
15183
15501
|
// src/client/builders/anchorArgs.ts
|
|
15184
|
-
var
|
|
15185
|
-
var
|
|
15502
|
+
var import_core5 = require("@anchor-lang/core");
|
|
15503
|
+
var import_common16 = __toESM(require_dist());
|
|
15186
15504
|
function toAnchorCreateVaultParams(params) {
|
|
15187
15505
|
return {
|
|
15188
15506
|
...params,
|
|
15189
|
-
hwManager: (0,
|
|
15190
|
-
cbTrigger: (0,
|
|
15191
|
-
feeCollector: (0,
|
|
15192
|
-
baseAssetMint: (0,
|
|
15193
|
-
basePriceOracleAccount: (0,
|
|
15194
|
-
consensusSigners: params.consensusSigners.map(
|
|
15507
|
+
hwManager: (0, import_common16.toWeb3Pk)(params.hwManager),
|
|
15508
|
+
cbTrigger: (0, import_common16.toWeb3Pk)(params.cbTrigger),
|
|
15509
|
+
feeCollector: (0, import_common16.toWeb3Pk)(params.feeCollector),
|
|
15510
|
+
baseAssetMint: (0, import_common16.toWeb3Pk)(params.baseAssetMint),
|
|
15511
|
+
basePriceOracleAccount: (0, import_common16.toWeb3Pk)(params.basePriceOracleAccount),
|
|
15512
|
+
consensusSigners: params.consensusSigners.map(import_common16.toWeb3Pk)
|
|
15195
15513
|
};
|
|
15196
15514
|
}
|
|
15197
15515
|
function toAnchorSetVaultConfigArgs(args) {
|
|
15198
15516
|
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,
|
|
15517
|
+
manager: args.manager ? (0, import_common16.toWeb3Pk)(args.manager) : null,
|
|
15518
|
+
hwManager: args.hwManager ? (0, import_common16.toWeb3Pk)(args.hwManager) : null,
|
|
15519
|
+
cbTrigger: args.cbTrigger ? (0, import_common16.toWeb3Pk)(args.cbTrigger) : null,
|
|
15520
|
+
fulfiller: args.fulfiller ? (0, import_common16.toWeb3Pk)(args.fulfiller) : null,
|
|
15521
|
+
feeCollector: args.feeCollector ? (0, import_common16.toWeb3Pk)(args.feeCollector) : null,
|
|
15522
|
+
newCurator: args.newCurator ? (0, import_common16.toWeb3Pk)(args.newCurator) : null,
|
|
15205
15523
|
mintFeeBps: args.mintFeeBps,
|
|
15206
15524
|
burnFeeBps: args.burnFeeBps,
|
|
15207
15525
|
performanceFeeBps: args.performanceFeeBps,
|
|
@@ -15218,9 +15536,9 @@ function toAnchorSetVaultConfigArgs(args) {
|
|
|
15218
15536
|
function toAnchorConsensusUpdates(updates) {
|
|
15219
15537
|
return updates.map((update) => ({
|
|
15220
15538
|
holdingIndex: update.holdingIndex,
|
|
15221
|
-
mint: update.mint ? (0,
|
|
15222
|
-
price: new
|
|
15223
|
-
externalAmount: new
|
|
15539
|
+
mint: update.mint ? (0, import_common16.toWeb3Pk)(update.mint) : null,
|
|
15540
|
+
price: new import_core5.BN(update.price.toString()),
|
|
15541
|
+
externalAmount: new import_core5.BN(update.externalAmount.toString())
|
|
15224
15542
|
}));
|
|
15225
15543
|
}
|
|
15226
15544
|
|
|
@@ -15228,16 +15546,16 @@ function toAnchorConsensusUpdates(updates) {
|
|
|
15228
15546
|
var CreateVaultBuilder = class extends VaultBuilderBase {
|
|
15229
15547
|
async getIx(args) {
|
|
15230
15548
|
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(
|
|
15549
|
+
curator: (0, import_common17.toWeb3Pk)(args.curator),
|
|
15550
|
+
vault: (0, import_common17.toWeb3Pk)(args.vault),
|
|
15551
|
+
vaultOracle: (0, import_common17.toWeb3Pk)(args.vaultOracle),
|
|
15552
|
+
feeVault: (0, import_common17.toWeb3Pk)(args.feeVault),
|
|
15553
|
+
shareMint: (0, import_common17.toWeb3Pk)(args.shareMint),
|
|
15554
|
+
assetMint: (0, import_common17.toWeb3Pk)(args.assetMint),
|
|
15555
|
+
assetTokenProgram: (0, import_common17.toWeb3Pk)(args.assetTokenProgram),
|
|
15556
|
+
tokenProgram: (0, import_common17.toWeb3Pk)(args.shareTokenProgram ?? TOKEN_PROGRAM_ID),
|
|
15557
|
+
systemProgram: import_web310.SystemProgram.programId
|
|
15558
|
+
}).instruction().then(import_common17.toKitInstruction);
|
|
15241
15559
|
}
|
|
15242
15560
|
async deriveIxArgs(txArgs) {
|
|
15243
15561
|
const vaultId = txArgs.vaultId ?? DEFAULT_VAULT_ID;
|
|
@@ -15266,11 +15584,11 @@ var CreateVaultBuilder = class extends VaultBuilderBase {
|
|
|
15266
15584
|
performanceFeeBps: txArgs.performanceFeeBps ?? 0,
|
|
15267
15585
|
fixedApyBps: txArgs.fixedApyBps ?? 0,
|
|
15268
15586
|
maxApyBps: txArgs.maxApyBps ?? DEFAULT_MAX_ACCEPTABLE_APY_BPS,
|
|
15269
|
-
tvlLimit: new
|
|
15587
|
+
tvlLimit: new import_core6.BN((txArgs.tvlLimit ?? 0n).toString()),
|
|
15270
15588
|
lossesEnabled: txArgs.lossesEnabled ?? false,
|
|
15271
15589
|
initialMintSharePrice: null,
|
|
15272
15590
|
basePriceOracleType: txArgs.basePriceOracleType ?? 1,
|
|
15273
|
-
basePrice: new
|
|
15591
|
+
basePrice: new import_core6.BN(
|
|
15274
15592
|
(txArgs.basePrice ?? 10n ** BigInt(accountingDecimals)).toString()
|
|
15275
15593
|
),
|
|
15276
15594
|
basePriceOracleAccount: txArgs.basePriceOracleAccount ?? DEFAULT_PRICE_ORACLE_ACCOUNT,
|
|
@@ -15282,42 +15600,42 @@ var CreateVaultBuilder = class extends VaultBuilderBase {
|
|
|
15282
15600
|
async getTx(txArgs) {
|
|
15283
15601
|
const args = await this.deriveIxArgs(txArgs);
|
|
15284
15602
|
const createIx = await this.getIx(args);
|
|
15285
|
-
const payer = (0,
|
|
15286
|
-
const assetMint = (0,
|
|
15287
|
-
const assetTokenProgram = (0,
|
|
15288
|
-
const vaultAssetAta = (0,
|
|
15603
|
+
const payer = (0, import_common17.toWeb3Pk)(args.curator);
|
|
15604
|
+
const assetMint = (0, import_common17.toWeb3Pk)(args.assetMint);
|
|
15605
|
+
const assetTokenProgram = (0, import_common17.toWeb3Pk)(args.assetTokenProgram);
|
|
15606
|
+
const vaultAssetAta = (0, import_common17.getAtaAddress)(
|
|
15289
15607
|
args.assetMint,
|
|
15290
15608
|
args.vault,
|
|
15291
15609
|
args.assetTokenProgram,
|
|
15292
15610
|
true
|
|
15293
15611
|
);
|
|
15294
|
-
const feeVaultAta = (0,
|
|
15612
|
+
const feeVaultAta = (0, import_common17.getAtaAddress)(
|
|
15295
15613
|
args.assetMint,
|
|
15296
15614
|
args.feeVault,
|
|
15297
15615
|
args.assetTokenProgram,
|
|
15298
15616
|
true
|
|
15299
15617
|
);
|
|
15300
|
-
const createVaultAssetAta = (0,
|
|
15618
|
+
const createVaultAssetAta = (0, import_spl_token6.createAssociatedTokenAccountIdempotentInstruction)(
|
|
15301
15619
|
payer,
|
|
15302
|
-
(0,
|
|
15303
|
-
(0,
|
|
15620
|
+
(0, import_common17.toWeb3Pk)(vaultAssetAta),
|
|
15621
|
+
(0, import_common17.toWeb3Pk)(args.vault),
|
|
15304
15622
|
assetMint,
|
|
15305
15623
|
assetTokenProgram,
|
|
15306
|
-
|
|
15624
|
+
import_spl_token6.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
15307
15625
|
);
|
|
15308
|
-
const createFeeVaultAta = (0,
|
|
15626
|
+
const createFeeVaultAta = (0, import_spl_token6.createAssociatedTokenAccountIdempotentInstruction)(
|
|
15309
15627
|
payer,
|
|
15310
|
-
(0,
|
|
15311
|
-
(0,
|
|
15628
|
+
(0, import_common17.toWeb3Pk)(feeVaultAta),
|
|
15629
|
+
(0, import_common17.toWeb3Pk)(args.feeVault),
|
|
15312
15630
|
assetMint,
|
|
15313
15631
|
assetTokenProgram,
|
|
15314
|
-
|
|
15632
|
+
import_spl_token6.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
15315
15633
|
);
|
|
15316
15634
|
return {
|
|
15317
15635
|
instructions: [
|
|
15318
15636
|
createIx,
|
|
15319
|
-
(0,
|
|
15320
|
-
(0,
|
|
15637
|
+
(0, import_common17.toKitInstruction)(createVaultAssetAta),
|
|
15638
|
+
(0, import_common17.toKitInstruction)(createFeeVaultAta)
|
|
15321
15639
|
],
|
|
15322
15640
|
postSuccessCacheInvalidations: [
|
|
15323
15641
|
{ vaultPda: args.vault, vaultOraclePda: args.vaultOracle }
|
|
@@ -15327,16 +15645,16 @@ var CreateVaultBuilder = class extends VaultBuilderBase {
|
|
|
15327
15645
|
};
|
|
15328
15646
|
|
|
15329
15647
|
// src/client/builders/initializeVaultRoles.ts
|
|
15330
|
-
var
|
|
15648
|
+
var import_common18 = __toESM(require_dist());
|
|
15331
15649
|
var InitializeVaultRolesBuilder = class extends VaultBuilderBase {
|
|
15332
15650
|
async getIx(args) {
|
|
15333
15651
|
return this.program.methods.initializeVaultRoles({
|
|
15334
|
-
manager: (0,
|
|
15335
|
-
fulfiller: (0,
|
|
15652
|
+
manager: (0, import_common18.toWeb3Pk)(args.args.manager),
|
|
15653
|
+
fulfiller: (0, import_common18.toWeb3Pk)(args.args.fulfiller)
|
|
15336
15654
|
}).accountsPartial({
|
|
15337
|
-
curator: (0,
|
|
15338
|
-
vault: (0,
|
|
15339
|
-
}).instruction().then(
|
|
15655
|
+
curator: (0, import_common18.toWeb3Pk)(args.curator),
|
|
15656
|
+
vault: (0, import_common18.toWeb3Pk)(args.vault)
|
|
15657
|
+
}).instruction().then(import_common18.toKitInstruction);
|
|
15340
15658
|
}
|
|
15341
15659
|
async deriveIxArgs(txArgs) {
|
|
15342
15660
|
return {
|
|
@@ -15356,13 +15674,13 @@ var InitializeVaultRolesBuilder = class extends VaultBuilderBase {
|
|
|
15356
15674
|
};
|
|
15357
15675
|
|
|
15358
15676
|
// src/client/builders/disableCircuitBreaker.ts
|
|
15359
|
-
var
|
|
15677
|
+
var import_common19 = __toESM(require_dist());
|
|
15360
15678
|
var DisableCircuitBreakerBuilder = class extends VaultBuilderBase {
|
|
15361
15679
|
async getIx(args) {
|
|
15362
15680
|
return this.program.methods.disableCircuitBreaker().accountsPartial({
|
|
15363
|
-
curator: (0,
|
|
15364
|
-
vault: (0,
|
|
15365
|
-
}).instruction().then(
|
|
15681
|
+
curator: (0, import_common19.toWeb3Pk)(args.curator),
|
|
15682
|
+
vault: (0, import_common19.toWeb3Pk)(args.vault)
|
|
15683
|
+
}).instruction().then(import_common19.toKitInstruction);
|
|
15366
15684
|
}
|
|
15367
15685
|
async deriveIxArgs(txArgs) {
|
|
15368
15686
|
return txArgs;
|
|
@@ -15375,15 +15693,15 @@ var DisableCircuitBreakerBuilder = class extends VaultBuilderBase {
|
|
|
15375
15693
|
};
|
|
15376
15694
|
|
|
15377
15695
|
// src/client/builders/setVaultConfig.ts
|
|
15378
|
-
var
|
|
15379
|
-
var
|
|
15696
|
+
var import_core7 = require("@anchor-lang/core");
|
|
15697
|
+
var import_common20 = __toESM(require_dist());
|
|
15380
15698
|
var SetVaultConfigBuilder = class extends VaultBuilderBase {
|
|
15381
15699
|
async getIx(args) {
|
|
15382
15700
|
return this.program.methods.setVaultConfig(toAnchorSetVaultConfigArgs(args.args)).accountsPartial({
|
|
15383
|
-
curator: (0,
|
|
15384
|
-
vault: (0,
|
|
15385
|
-
vaultOracle: args.vaultOracle ? (0,
|
|
15386
|
-
}).instruction().then(
|
|
15701
|
+
curator: (0, import_common20.toWeb3Pk)(args.curator),
|
|
15702
|
+
vault: (0, import_common20.toWeb3Pk)(args.vault),
|
|
15703
|
+
vaultOracle: args.vaultOracle ? (0, import_common20.toWeb3Pk)(args.vaultOracle) : null
|
|
15704
|
+
}).instruction().then(import_common20.toKitInstruction);
|
|
15387
15705
|
}
|
|
15388
15706
|
async deriveIxArgs(txArgs) {
|
|
15389
15707
|
const [derivedVaultOracle] = await this.pda.deriveVaultOraclePda(
|
|
@@ -15405,28 +15723,28 @@ var SetVaultConfigBuilder = class extends VaultBuilderBase {
|
|
|
15405
15723
|
performanceFeeBps: txArgs.performanceFeeBps ?? null,
|
|
15406
15724
|
fixedApyBps: txArgs.fixedApyBps ?? null,
|
|
15407
15725
|
maxApyBps: txArgs.maxApyBps ?? null,
|
|
15408
|
-
tvlLimit: txArgs.tvlLimit !== void 0 ? new
|
|
15726
|
+
tvlLimit: txArgs.tvlLimit !== void 0 ? new import_core7.BN(txArgs.tvlLimit.toString()) : null,
|
|
15409
15727
|
lossesEnabled: txArgs.lossesEnabled ?? null,
|
|
15410
|
-
priceStalenessThresholdSecs: txArgs.priceStalenessThresholdSecs !== void 0 ? new
|
|
15728
|
+
priceStalenessThresholdSecs: txArgs.priceStalenessThresholdSecs !== void 0 ? new import_core7.BN(txArgs.priceStalenessThresholdSecs.toString()) : null,
|
|
15411
15729
|
userBurnLimit: txArgs.userBurnLimit !== void 0 ? {
|
|
15412
|
-
windowLimit: new
|
|
15730
|
+
windowLimit: new import_core7.BN(
|
|
15413
15731
|
txArgs.userBurnLimit.windowLimit.toString()
|
|
15414
15732
|
),
|
|
15415
|
-
windowDurationSeconds: new
|
|
15733
|
+
windowDurationSeconds: new import_core7.BN(
|
|
15416
15734
|
txArgs.userBurnLimit.windowDurationSeconds.toString()
|
|
15417
15735
|
)
|
|
15418
15736
|
} : null,
|
|
15419
15737
|
managerPullLimit: txArgs.managerPullLimit !== void 0 ? {
|
|
15420
|
-
windowLimit: new
|
|
15738
|
+
windowLimit: new import_core7.BN(
|
|
15421
15739
|
txArgs.managerPullLimit.windowLimit.toString()
|
|
15422
15740
|
),
|
|
15423
|
-
windowDurationSeconds: new
|
|
15741
|
+
windowDurationSeconds: new import_core7.BN(
|
|
15424
15742
|
txArgs.managerPullLimit.windowDurationSeconds.toString()
|
|
15425
15743
|
)
|
|
15426
15744
|
} : null,
|
|
15427
15745
|
rebalanceLimit: txArgs.rebalanceLimit !== void 0 ? {
|
|
15428
15746
|
windowLimitBps: txArgs.rebalanceLimit.windowLimitBps,
|
|
15429
|
-
windowDurationSeconds: new
|
|
15747
|
+
windowDurationSeconds: new import_core7.BN(
|
|
15430
15748
|
txArgs.rebalanceLimit.windowDurationSeconds.toString()
|
|
15431
15749
|
)
|
|
15432
15750
|
} : null
|
|
@@ -15441,14 +15759,14 @@ var SetVaultConfigBuilder = class extends VaultBuilderBase {
|
|
|
15441
15759
|
};
|
|
15442
15760
|
|
|
15443
15761
|
// src/client/builders/setProtocolFee.ts
|
|
15444
|
-
var
|
|
15762
|
+
var import_common21 = __toESM(require_dist());
|
|
15445
15763
|
var SetProtocolFeeBuilder = class extends VaultBuilderBase {
|
|
15446
15764
|
async getIx(args) {
|
|
15447
15765
|
return this.program.methods.setProtocolFee({ protocolFeeBps: args.args.protocolFeeBps }).accountsPartial({
|
|
15448
|
-
protocolAuthority: (0,
|
|
15449
|
-
vault: (0,
|
|
15450
|
-
vaultOracle: args.vaultOracle ? (0,
|
|
15451
|
-
}).instruction().then(
|
|
15766
|
+
protocolAuthority: (0, import_common21.toWeb3Pk)(args.protocolAuthority),
|
|
15767
|
+
vault: (0, import_common21.toWeb3Pk)(args.vault),
|
|
15768
|
+
vaultOracle: args.vaultOracle ? (0, import_common21.toWeb3Pk)(args.vaultOracle) : null
|
|
15769
|
+
}).instruction().then(import_common21.toKitInstruction);
|
|
15452
15770
|
}
|
|
15453
15771
|
async deriveIxArgs(txArgs) {
|
|
15454
15772
|
const [derivedVaultOracle] = await this.pda.deriveVaultOraclePda(
|
|
@@ -15472,13 +15790,13 @@ var SetProtocolFeeBuilder = class extends VaultBuilderBase {
|
|
|
15472
15790
|
};
|
|
15473
15791
|
|
|
15474
15792
|
// src/client/builders/crankNav.ts
|
|
15475
|
-
var
|
|
15793
|
+
var import_spl_token7 = require("@solana/spl-token");
|
|
15476
15794
|
var import_kit6 = require("@solana/kit");
|
|
15477
|
-
var
|
|
15478
|
-
var
|
|
15795
|
+
var import_web311 = require("@solana/web3.js");
|
|
15796
|
+
var import_common23 = __toESM(require_dist());
|
|
15479
15797
|
|
|
15480
15798
|
// src/client/builders/feeCollector.ts
|
|
15481
|
-
var
|
|
15799
|
+
var import_common22 = __toESM(require_dist());
|
|
15482
15800
|
function resolveProtocolFeeRecipient(override) {
|
|
15483
15801
|
return override ?? PROTOCOL_FEE_RECIPIENT;
|
|
15484
15802
|
}
|
|
@@ -15487,14 +15805,14 @@ async function resolveVaultFeeCollector(account, vault, override) {
|
|
|
15487
15805
|
return override;
|
|
15488
15806
|
}
|
|
15489
15807
|
const vaultState = await account.fetchVault(vault);
|
|
15490
|
-
return (0,
|
|
15808
|
+
return (0, import_common22.fromWeb3Pk)(vaultState.roles.feeCollector);
|
|
15491
15809
|
}
|
|
15492
15810
|
function baseAssetMintFromVault(vaultState) {
|
|
15493
15811
|
const baseHolding = vaultState.holdings.find((holding) => holding.isBase);
|
|
15494
15812
|
if (!baseHolding) {
|
|
15495
15813
|
throw new Error("Vault has no base asset holding");
|
|
15496
15814
|
}
|
|
15497
|
-
return (0,
|
|
15815
|
+
return (0, import_common22.fromWeb3Pk)(baseHolding.mint);
|
|
15498
15816
|
}
|
|
15499
15817
|
async function resolveVaultBaseAssetMint(account, vault, override) {
|
|
15500
15818
|
if (override) {
|
|
@@ -15509,7 +15827,7 @@ async function resolveFeeAssetTokenProgram(account, vault, feeAssetMint, overrid
|
|
|
15509
15827
|
}
|
|
15510
15828
|
const vaultState = await account.fetchVault(vault);
|
|
15511
15829
|
const holding = vaultState.holdings.find(
|
|
15512
|
-
(entry) => (0,
|
|
15830
|
+
(entry) => (0, import_common22.fromWeb3Pk)(entry.mint) === feeAssetMint
|
|
15513
15831
|
);
|
|
15514
15832
|
if (!holding) {
|
|
15515
15833
|
return TOKEN_PROGRAM_ID;
|
|
@@ -15521,21 +15839,21 @@ async function resolveFeeAssetTokenProgram(account, vault, feeAssetMint, overrid
|
|
|
15521
15839
|
var CrankNavBuilder = class extends VaultBuilderBase {
|
|
15522
15840
|
async getIx(args) {
|
|
15523
15841
|
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(
|
|
15842
|
+
cranker: (0, import_common23.toWeb3Pk)(args.cranker),
|
|
15843
|
+
vault: (0, import_common23.toWeb3Pk)(args.vault),
|
|
15844
|
+
vaultOracle: (0, import_common23.toWeb3Pk)(args.vaultOracle),
|
|
15845
|
+
vaultTrancheState: args.vaultTrancheState ? (0, import_common23.toWeb3Pk)(args.vaultTrancheState) : null,
|
|
15846
|
+
shareMint: (0, import_common23.toWeb3Pk)(args.shareMint),
|
|
15847
|
+
juniorTrancheShareMint: args.juniorTrancheShareMint ? (0, import_common23.toWeb3Pk)(args.juniorTrancheShareMint) : null,
|
|
15848
|
+
seniorTrancheShareMint: args.seniorTrancheShareMint ? (0, import_common23.toWeb3Pk)(args.seniorTrancheShareMint) : null,
|
|
15849
|
+
feeAssetMint: (0, import_common23.toWeb3Pk)(args.feeAssetMint),
|
|
15850
|
+
vaultFeeAssetAta: (0, import_common23.toWeb3Pk)(args.vaultFeeAssetAta),
|
|
15851
|
+
feeVault: (0, import_common23.toWeb3Pk)(args.feeVault),
|
|
15852
|
+
feeVaultAta: (0, import_common23.toWeb3Pk)(args.feeVaultAta),
|
|
15853
|
+
feeAssetTokenProgram: (0, import_common23.toWeb3Pk)(args.feeAssetTokenProgram),
|
|
15854
|
+
associatedTokenProgram: import_spl_token7.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
15855
|
+
systemProgram: import_web311.SystemProgram.programId
|
|
15856
|
+
}).instruction().then(import_common23.toKitInstruction);
|
|
15539
15857
|
}
|
|
15540
15858
|
async deriveIxArgs(txArgs) {
|
|
15541
15859
|
const [vaultOracle] = await this.pda.deriveVaultOraclePda(txArgs.vault);
|
|
@@ -15585,13 +15903,13 @@ var CrankNavBuilder = class extends VaultBuilderBase {
|
|
|
15585
15903
|
seniorTrancheShareMint,
|
|
15586
15904
|
feeAssetMint,
|
|
15587
15905
|
feeVault,
|
|
15588
|
-
vaultFeeAssetAta: (0,
|
|
15906
|
+
vaultFeeAssetAta: (0, import_common23.getAtaAddress)(
|
|
15589
15907
|
feeAssetMint,
|
|
15590
15908
|
txArgs.vault,
|
|
15591
15909
|
feeAssetTokenProgram,
|
|
15592
15910
|
true
|
|
15593
15911
|
),
|
|
15594
|
-
feeVaultAta: (0,
|
|
15912
|
+
feeVaultAta: (0, import_common23.getAtaAddress)(
|
|
15595
15913
|
feeAssetMint,
|
|
15596
15914
|
feeVault,
|
|
15597
15915
|
feeAssetTokenProgram,
|
|
@@ -15601,25 +15919,25 @@ var CrankNavBuilder = class extends VaultBuilderBase {
|
|
|
15601
15919
|
};
|
|
15602
15920
|
}
|
|
15603
15921
|
async buildPreambleInstructions(args) {
|
|
15604
|
-
const payer = (0,
|
|
15922
|
+
const payer = (0, import_common23.toWeb3Pk)(args.cranker);
|
|
15605
15923
|
return [
|
|
15606
|
-
(0,
|
|
15924
|
+
(0, import_spl_token7.createAssociatedTokenAccountIdempotentInstruction)(
|
|
15607
15925
|
payer,
|
|
15608
|
-
(0,
|
|
15609
|
-
(0,
|
|
15610
|
-
(0,
|
|
15611
|
-
(0,
|
|
15612
|
-
|
|
15926
|
+
(0, import_common23.toWeb3Pk)(args.vaultFeeAssetAta),
|
|
15927
|
+
(0, import_common23.toWeb3Pk)(args.vault),
|
|
15928
|
+
(0, import_common23.toWeb3Pk)(args.feeAssetMint),
|
|
15929
|
+
(0, import_common23.toWeb3Pk)(args.feeAssetTokenProgram),
|
|
15930
|
+
import_spl_token7.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
15613
15931
|
),
|
|
15614
|
-
(0,
|
|
15932
|
+
(0, import_spl_token7.createAssociatedTokenAccountIdempotentInstruction)(
|
|
15615
15933
|
payer,
|
|
15616
|
-
(0,
|
|
15617
|
-
(0,
|
|
15618
|
-
(0,
|
|
15619
|
-
(0,
|
|
15620
|
-
|
|
15934
|
+
(0, import_common23.toWeb3Pk)(args.feeVaultAta),
|
|
15935
|
+
(0, import_common23.toWeb3Pk)(args.feeVault),
|
|
15936
|
+
(0, import_common23.toWeb3Pk)(args.feeAssetMint),
|
|
15937
|
+
(0, import_common23.toWeb3Pk)(args.feeAssetTokenProgram),
|
|
15938
|
+
import_spl_token7.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
15621
15939
|
)
|
|
15622
|
-
].map(
|
|
15940
|
+
].map(import_common23.toKitInstruction);
|
|
15623
15941
|
}
|
|
15624
15942
|
async buildPlanExtras(args) {
|
|
15625
15943
|
return {
|
|
@@ -15645,29 +15963,29 @@ var CrankNavBuilder = class extends VaultBuilderBase {
|
|
|
15645
15963
|
};
|
|
15646
15964
|
|
|
15647
15965
|
// src/client/builders/crankPerformanceFees.ts
|
|
15648
|
-
var
|
|
15649
|
-
var
|
|
15650
|
-
var
|
|
15966
|
+
var import_spl_token8 = require("@solana/spl-token");
|
|
15967
|
+
var import_web312 = require("@solana/web3.js");
|
|
15968
|
+
var import_common24 = __toESM(require_dist());
|
|
15651
15969
|
var CrankPerformanceFeesBuilder = class extends VaultBuilderBase {
|
|
15652
15970
|
async getIx(args) {
|
|
15653
15971
|
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,
|
|
15972
|
+
cranker: (0, import_common24.toWeb3Pk)(args.cranker),
|
|
15973
|
+
vault: (0, import_common24.toWeb3Pk)(args.vault),
|
|
15974
|
+
shareMint: (0, import_common24.toWeb3Pk)(args.shareMint),
|
|
15975
|
+
feeCollector: (0, import_common24.toWeb3Pk)(args.feeCollector),
|
|
15976
|
+
feeCollectorShareAta: (0, import_common24.toWeb3Pk)(args.feeCollectorShareAta),
|
|
15977
|
+
protocolFeeCollector: (0, import_common24.toWeb3Pk)(args.protocolFeeCollector),
|
|
15978
|
+
protocolFeeCollectorShareAta: (0, import_common24.toWeb3Pk)(
|
|
15661
15979
|
args.protocolFeeCollectorShareAta
|
|
15662
15980
|
),
|
|
15663
|
-
shareTokenProgram: (0,
|
|
15664
|
-
associatedTokenProgram:
|
|
15665
|
-
systemProgram:
|
|
15666
|
-
}).instruction().then(
|
|
15981
|
+
shareTokenProgram: (0, import_common24.toWeb3Pk)(args.shareTokenProgram),
|
|
15982
|
+
associatedTokenProgram: import_spl_token8.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
15983
|
+
systemProgram: import_web312.SystemProgram.programId
|
|
15984
|
+
}).instruction().then(import_common24.toKitInstruction);
|
|
15667
15985
|
}
|
|
15668
15986
|
async deriveIxArgs(txArgs) {
|
|
15669
15987
|
const vaultState = await this.account.fetchVault(txArgs.vault);
|
|
15670
|
-
const shareMint = (0,
|
|
15988
|
+
const shareMint = (0, import_common24.fromWeb3Pk)(vaultState.mint);
|
|
15671
15989
|
const shareTokenProgram = txArgs.shareTokenProgram ?? tokenProgramAddressFromIdlEnum(vaultState.mintTokenProgram);
|
|
15672
15990
|
const feeCollector = await resolveVaultFeeCollector(
|
|
15673
15991
|
this.account,
|
|
@@ -15684,7 +16002,7 @@ var CrankPerformanceFeesBuilder = class extends VaultBuilderBase {
|
|
|
15684
16002
|
feeCollector,
|
|
15685
16003
|
// The vault fee collector is a role that is routinely a Squads vault
|
|
15686
16004
|
// (off-curve PDA), so allow an off-curve owner here too.
|
|
15687
|
-
feeCollectorShareAta: (0,
|
|
16005
|
+
feeCollectorShareAta: (0, import_common24.getAtaAddress)(
|
|
15688
16006
|
shareMint,
|
|
15689
16007
|
feeCollector,
|
|
15690
16008
|
shareTokenProgram,
|
|
@@ -15694,7 +16012,7 @@ var CrankPerformanceFeesBuilder = class extends VaultBuilderBase {
|
|
|
15694
16012
|
// The protocol fee recipient is a hardcoded protocol-controlled address
|
|
15695
16013
|
// that may be off-curve (e.g. a PDA / multisig vault), so allow an
|
|
15696
16014
|
// off-curve owner when deriving its ATA.
|
|
15697
|
-
protocolFeeCollectorShareAta: (0,
|
|
16015
|
+
protocolFeeCollectorShareAta: (0, import_common24.getAtaAddress)(
|
|
15698
16016
|
shareMint,
|
|
15699
16017
|
protocolFeeCollector,
|
|
15700
16018
|
shareTokenProgram,
|
|
@@ -15720,7 +16038,7 @@ var CrankPerformanceFeesBuilder = class extends VaultBuilderBase {
|
|
|
15720
16038
|
};
|
|
15721
16039
|
|
|
15722
16040
|
// src/client/builders/setExternalLiquidity.ts
|
|
15723
|
-
var
|
|
16041
|
+
var import_common25 = __toESM(require_dist());
|
|
15724
16042
|
function toExternalLiquiditySource(source) {
|
|
15725
16043
|
switch (source) {
|
|
15726
16044
|
case 0:
|
|
@@ -15736,11 +16054,11 @@ var SetExternalLiquidityBuilder = class extends VaultBuilderBase {
|
|
|
15736
16054
|
return this.program.methods.setExternalLiquidity({
|
|
15737
16055
|
index: args.args.index,
|
|
15738
16056
|
source: args.args.source,
|
|
15739
|
-
userAccount: (0,
|
|
16057
|
+
userAccount: (0, import_common25.toWeb3Pk)(args.args.userAccount)
|
|
15740
16058
|
}).accountsPartial({
|
|
15741
|
-
curator: (0,
|
|
15742
|
-
vault: (0,
|
|
15743
|
-
}).instruction().then(
|
|
16059
|
+
curator: (0, import_common25.toWeb3Pk)(args.curator),
|
|
16060
|
+
vault: (0, import_common25.toWeb3Pk)(args.vault)
|
|
16061
|
+
}).instruction().then(import_common25.toKitInstruction);
|
|
15744
16062
|
}
|
|
15745
16063
|
async deriveIxArgs(txArgs) {
|
|
15746
16064
|
return {
|
|
@@ -15761,16 +16079,16 @@ var SetExternalLiquidityBuilder = class extends VaultBuilderBase {
|
|
|
15761
16079
|
};
|
|
15762
16080
|
|
|
15763
16081
|
// src/client/builders/setManagerWithdrawDestination.ts
|
|
15764
|
-
var
|
|
16082
|
+
var import_common26 = __toESM(require_dist());
|
|
15765
16083
|
var SetManagerWithdrawDestinationBuilder = class extends VaultBuilderBase {
|
|
15766
16084
|
async getIx(args) {
|
|
15767
16085
|
return this.program.methods.setManagerWithdrawDestination({
|
|
15768
16086
|
slot: args.args.slot,
|
|
15769
|
-
address: (0,
|
|
16087
|
+
address: (0, import_common26.toWeb3Pk)(args.args.address)
|
|
15770
16088
|
}).accountsPartial({
|
|
15771
|
-
curator: (0,
|
|
15772
|
-
vault: (0,
|
|
15773
|
-
}).instruction().then(
|
|
16089
|
+
curator: (0, import_common26.toWeb3Pk)(args.curator),
|
|
16090
|
+
vault: (0, import_common26.toWeb3Pk)(args.vault)
|
|
16091
|
+
}).instruction().then(import_common26.toKitInstruction);
|
|
15774
16092
|
}
|
|
15775
16093
|
async deriveIxArgs(txArgs) {
|
|
15776
16094
|
return {
|
|
@@ -15790,17 +16108,17 @@ var SetManagerWithdrawDestinationBuilder = class extends VaultBuilderBase {
|
|
|
15790
16108
|
};
|
|
15791
16109
|
|
|
15792
16110
|
// src/client/builders/setAssetPriceOracle.ts
|
|
15793
|
-
var
|
|
16111
|
+
var import_common27 = __toESM(require_dist());
|
|
15794
16112
|
var SetAssetPriceOracleBuilder = class extends VaultBuilderBase {
|
|
15795
16113
|
async getIx(args) {
|
|
15796
16114
|
return this.program.methods.setAssetPriceOracle({
|
|
15797
|
-
mint: (0,
|
|
16115
|
+
mint: (0, import_common27.toWeb3Pk)(args.args.mint),
|
|
15798
16116
|
priceOracleType: args.args.priceOracleType,
|
|
15799
|
-
priceOracleAccount: (0,
|
|
16117
|
+
priceOracleAccount: (0, import_common27.toWeb3Pk)(args.args.priceOracleAccount)
|
|
15800
16118
|
}).accountsPartial({
|
|
15801
|
-
curator: (0,
|
|
15802
|
-
vault: (0,
|
|
15803
|
-
}).instruction().then(
|
|
16119
|
+
curator: (0, import_common27.toWeb3Pk)(args.curator),
|
|
16120
|
+
vault: (0, import_common27.toWeb3Pk)(args.vault)
|
|
16121
|
+
}).instruction().then(import_common27.toKitInstruction);
|
|
15804
16122
|
}
|
|
15805
16123
|
async deriveIxArgs(txArgs) {
|
|
15806
16124
|
return {
|
|
@@ -15821,19 +16139,19 @@ var SetAssetPriceOracleBuilder = class extends VaultBuilderBase {
|
|
|
15821
16139
|
};
|
|
15822
16140
|
|
|
15823
16141
|
// src/client/builders/updateAssetPrice.ts
|
|
15824
|
-
var
|
|
15825
|
-
var
|
|
16142
|
+
var import_core8 = require("@anchor-lang/core");
|
|
16143
|
+
var import_common28 = __toESM(require_dist());
|
|
15826
16144
|
var DEFAULT_PRICE_MAX_AGE_SECS = 90n;
|
|
15827
16145
|
var UpdateAssetPriceBuilder = class extends VaultBuilderBase {
|
|
15828
16146
|
async getIx(args) {
|
|
15829
16147
|
return this.program.methods.updateAssetPrice({
|
|
15830
|
-
mint: (0,
|
|
16148
|
+
mint: (0, import_common28.toWeb3Pk)(args.args.mint),
|
|
15831
16149
|
maxAgeSecs: args.args.maxAgeSecs
|
|
15832
16150
|
}).accountsPartial({
|
|
15833
|
-
updater: (0,
|
|
15834
|
-
vault: (0,
|
|
15835
|
-
oracleAccount: (0,
|
|
15836
|
-
}).instruction().then(
|
|
16151
|
+
updater: (0, import_common28.toWeb3Pk)(args.updater),
|
|
16152
|
+
vault: (0, import_common28.toWeb3Pk)(args.vault),
|
|
16153
|
+
oracleAccount: (0, import_common28.toWeb3Pk)(args.oracleAccount)
|
|
16154
|
+
}).instruction().then(import_common28.toKitInstruction);
|
|
15837
16155
|
}
|
|
15838
16156
|
async deriveIxArgs(txArgs) {
|
|
15839
16157
|
return {
|
|
@@ -15842,7 +16160,7 @@ var UpdateAssetPriceBuilder = class extends VaultBuilderBase {
|
|
|
15842
16160
|
oracleAccount: txArgs.oracleAccount,
|
|
15843
16161
|
args: {
|
|
15844
16162
|
mint: txArgs.mint,
|
|
15845
|
-
maxAgeSecs: new
|
|
16163
|
+
maxAgeSecs: new import_core8.BN(
|
|
15846
16164
|
(txArgs.maxAgeSecs ?? DEFAULT_PRICE_MAX_AGE_SECS).toString()
|
|
15847
16165
|
)
|
|
15848
16166
|
}
|
|
@@ -15865,18 +16183,18 @@ var UpdateAssetPriceBuilder = class extends VaultBuilderBase {
|
|
|
15865
16183
|
};
|
|
15866
16184
|
|
|
15867
16185
|
// src/client/builders/updateConsensusOracle.ts
|
|
15868
|
-
var
|
|
16186
|
+
var import_common29 = __toESM(require_dist());
|
|
15869
16187
|
var UpdateConsensusOracleBuilder = class extends VaultBuilderBase {
|
|
15870
16188
|
async getIx(args) {
|
|
15871
16189
|
return this.program.methods.updateConsensusOracle({
|
|
15872
16190
|
updates: toAnchorConsensusUpdates(args.updates)
|
|
15873
16191
|
}).accountsPartial({
|
|
15874
|
-
signer: (0,
|
|
15875
|
-
vault: (0,
|
|
15876
|
-
vaultOracle: (0,
|
|
15877
|
-
assetMint: args.assetMint ? (0,
|
|
15878
|
-
assetTokenProgram: args.assetTokenProgram ? (0,
|
|
15879
|
-
}).instruction().then(
|
|
16192
|
+
signer: (0, import_common29.toWeb3Pk)(args.signer),
|
|
16193
|
+
vault: (0, import_common29.toWeb3Pk)(args.vault),
|
|
16194
|
+
vaultOracle: (0, import_common29.toWeb3Pk)(args.vaultOracle),
|
|
16195
|
+
assetMint: args.assetMint ? (0, import_common29.toWeb3Pk)(args.assetMint) : null,
|
|
16196
|
+
assetTokenProgram: args.assetTokenProgram ? (0, import_common29.toWeb3Pk)(args.assetTokenProgram) : null
|
|
16197
|
+
}).instruction().then(import_common29.toKitInstruction);
|
|
15880
16198
|
}
|
|
15881
16199
|
async deriveIxArgs(txArgs) {
|
|
15882
16200
|
const [derivedVaultOracle] = await this.pda.deriveVaultOraclePda(
|
|
@@ -15920,25 +16238,25 @@ var UpdateConsensusOracleBuilder = class extends VaultBuilderBase {
|
|
|
15920
16238
|
};
|
|
15921
16239
|
|
|
15922
16240
|
// src/client/builders/executeShareSwap.ts
|
|
15923
|
-
var
|
|
15924
|
-
var
|
|
15925
|
-
var
|
|
15926
|
-
var
|
|
16241
|
+
var import_core9 = require("@anchor-lang/core");
|
|
16242
|
+
var import_spl_token9 = require("@solana/spl-token");
|
|
16243
|
+
var import_web313 = require("@solana/web3.js");
|
|
16244
|
+
var import_common30 = __toESM(require_dist());
|
|
15927
16245
|
var ExecuteShareSwapBuilder = class extends VaultBuilderBase {
|
|
15928
16246
|
getIxAccounts(args) {
|
|
15929
16247
|
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:
|
|
16248
|
+
user: (0, import_common30.toWeb3Pk)(args.user),
|
|
16249
|
+
vault: (0, import_common30.toWeb3Pk)(args.vault),
|
|
16250
|
+
vaultOracle: (0, import_common30.toWeb3Pk)(args.vaultOracle),
|
|
16251
|
+
vaultTrancheState: (0, import_common30.toWeb3Pk)(args.vaultTrancheState),
|
|
16252
|
+
shareMint: (0, import_common30.toWeb3Pk)(args.shareMint),
|
|
16253
|
+
trancheShareMint: (0, import_common30.toWeb3Pk)(args.trancheShareMint),
|
|
16254
|
+
userShareAta: (0, import_common30.toWeb3Pk)(args.userShareAta),
|
|
16255
|
+
userTrancheShareAta: (0, import_common30.toWeb3Pk)(args.userTrancheShareAta),
|
|
16256
|
+
shareTokenProgram: (0, import_common30.toWeb3Pk)(args.shareTokenProgram),
|
|
16257
|
+
trancheShareTokenProgram: (0, import_common30.toWeb3Pk)(args.trancheShareTokenProgram),
|
|
16258
|
+
associatedTokenProgram: import_spl_token9.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
16259
|
+
systemProgram: import_web313.SystemProgram.programId
|
|
15942
16260
|
};
|
|
15943
16261
|
}
|
|
15944
16262
|
getIxData(args) {
|
|
@@ -15949,7 +16267,7 @@ var ExecuteShareSwapBuilder = class extends VaultBuilderBase {
|
|
|
15949
16267
|
}
|
|
15950
16268
|
async getIx(args) {
|
|
15951
16269
|
const data = this.getIxData(args);
|
|
15952
|
-
return this.program.methods.executeShareSwap(data.kind, data.shareAmount).accountsPartial(this.getIxAccounts(args)).instruction().then(
|
|
16270
|
+
return this.program.methods.executeShareSwap(data.kind, data.shareAmount).accountsPartial(this.getIxAccounts(args)).instruction().then(import_common30.toKitInstruction);
|
|
15953
16271
|
}
|
|
15954
16272
|
async deriveIxArgs(txArgs) {
|
|
15955
16273
|
const [
|
|
@@ -15980,11 +16298,11 @@ var ExecuteShareSwapBuilder = class extends VaultBuilderBase {
|
|
|
15980
16298
|
shareMint,
|
|
15981
16299
|
trancheShareMint,
|
|
15982
16300
|
kind: txArgs.kind,
|
|
15983
|
-
shareAmount: new
|
|
16301
|
+
shareAmount: new import_core9.BN(txArgs.shareAmount.toString()),
|
|
15984
16302
|
shareTokenProgram,
|
|
15985
16303
|
trancheShareTokenProgram,
|
|
15986
|
-
userShareAta: (0,
|
|
15987
|
-
userTrancheShareAta: (0,
|
|
16304
|
+
userShareAta: (0, import_common30.getAtaAddress)(shareMint, txArgs.user, shareTokenProgram),
|
|
16305
|
+
userTrancheShareAta: (0, import_common30.getAtaAddress)(
|
|
15988
16306
|
trancheShareMint,
|
|
15989
16307
|
txArgs.user,
|
|
15990
16308
|
trancheShareTokenProgram
|
|
@@ -15992,16 +16310,16 @@ var ExecuteShareSwapBuilder = class extends VaultBuilderBase {
|
|
|
15992
16310
|
};
|
|
15993
16311
|
}
|
|
15994
16312
|
async buildPreambleInstructions(args) {
|
|
15995
|
-
const payer = (0,
|
|
15996
|
-
const createUserTrancheShareAta = (0,
|
|
16313
|
+
const payer = (0, import_common30.toWeb3Pk)(args.user);
|
|
16314
|
+
const createUserTrancheShareAta = (0, import_spl_token9.createAssociatedTokenAccountIdempotentInstruction)(
|
|
15997
16315
|
payer,
|
|
15998
|
-
(0,
|
|
16316
|
+
(0, import_common30.toWeb3Pk)(args.userTrancheShareAta),
|
|
15999
16317
|
payer,
|
|
16000
|
-
(0,
|
|
16001
|
-
(0,
|
|
16002
|
-
|
|
16318
|
+
(0, import_common30.toWeb3Pk)(args.trancheShareMint),
|
|
16319
|
+
(0, import_common30.toWeb3Pk)(args.trancheShareTokenProgram),
|
|
16320
|
+
import_spl_token9.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16003
16321
|
);
|
|
16004
|
-
return [createUserTrancheShareAta].map(
|
|
16322
|
+
return [createUserTrancheShareAta].map(import_common30.toKitInstruction);
|
|
16005
16323
|
}
|
|
16006
16324
|
async buildPlanExtras(args) {
|
|
16007
16325
|
return {
|
|
@@ -16023,25 +16341,25 @@ var ExecuteShareSwapBuilder = class extends VaultBuilderBase {
|
|
|
16023
16341
|
};
|
|
16024
16342
|
|
|
16025
16343
|
// src/client/builders/executeDeposit.ts
|
|
16026
|
-
var
|
|
16027
|
-
var
|
|
16028
|
-
var
|
|
16344
|
+
var import_core10 = require("@anchor-lang/core");
|
|
16345
|
+
var import_spl_token10 = require("@solana/spl-token");
|
|
16346
|
+
var import_common31 = __toESM(require_dist());
|
|
16029
16347
|
var ExecuteDepositBuilder = class extends VaultBuilderBase {
|
|
16030
16348
|
getIxAccounts(args) {
|
|
16031
16349
|
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,
|
|
16350
|
+
user: (0, import_common31.toWeb3Pk)(args.user),
|
|
16351
|
+
vault: (0, import_common31.toWeb3Pk)(args.vault),
|
|
16352
|
+
vaultOracle: (0, import_common31.toWeb3Pk)(args.vaultOracle),
|
|
16353
|
+
vaultTrancheState: args.vaultTrancheState ? (0, import_common31.toWeb3Pk)(args.vaultTrancheState) : null,
|
|
16354
|
+
assetMint: (0, import_common31.toWeb3Pk)(args.assetMint),
|
|
16355
|
+
shareMint: (0, import_common31.toWeb3Pk)(args.shareMint),
|
|
16356
|
+
userAssetAta: (0, import_common31.toWeb3Pk)(args.userAssetAta),
|
|
16357
|
+
vaultAssetAta: (0, import_common31.toWeb3Pk)(args.vaultAssetAta),
|
|
16358
|
+
feeVault: (0, import_common31.toWeb3Pk)(args.feeVault),
|
|
16359
|
+
feeVaultAta: (0, import_common31.toWeb3Pk)(args.feeVaultAta),
|
|
16360
|
+
userShareAta: (0, import_common31.toWeb3Pk)(args.userShareAta),
|
|
16361
|
+
assetTokenProgram: (0, import_common31.toWeb3Pk)(args.assetTokenProgram),
|
|
16362
|
+
shareTokenProgram: (0, import_common31.toWeb3Pk)(args.shareTokenProgram)
|
|
16045
16363
|
};
|
|
16046
16364
|
}
|
|
16047
16365
|
getIxData(args) {
|
|
@@ -16058,7 +16376,7 @@ var ExecuteDepositBuilder = class extends VaultBuilderBase {
|
|
|
16058
16376
|
) : this.program.methods.executeDeposit(data.amount);
|
|
16059
16377
|
return methods.accountsPartial(
|
|
16060
16378
|
this.getIxAccounts(args)
|
|
16061
|
-
).instruction().then(
|
|
16379
|
+
).instruction().then(import_common31.toKitInstruction);
|
|
16062
16380
|
}
|
|
16063
16381
|
async deriveIxArgs(txArgs) {
|
|
16064
16382
|
const connection = this.program.provider.connection;
|
|
@@ -16097,61 +16415,61 @@ var ExecuteDepositBuilder = class extends VaultBuilderBase {
|
|
|
16097
16415
|
vaultTrancheState,
|
|
16098
16416
|
assetMint: txArgs.assetMint,
|
|
16099
16417
|
shareMint: txArgs.shareMint,
|
|
16100
|
-
amount: new
|
|
16418
|
+
amount: new import_core10.BN(txArgs.amount.toString()),
|
|
16101
16419
|
addressSeeds: txArgs.addressSeeds,
|
|
16102
16420
|
assetTokenProgram,
|
|
16103
16421
|
shareTokenProgram,
|
|
16104
|
-
userAssetAta: txArgs.userAssetAta ?? (0,
|
|
16105
|
-
vaultAssetAta: (0,
|
|
16422
|
+
userAssetAta: txArgs.userAssetAta ?? (0, import_common31.getAtaAddress)(txArgs.assetMint, txArgs.user, assetTokenProgram),
|
|
16423
|
+
vaultAssetAta: (0, import_common31.getAtaAddress)(
|
|
16106
16424
|
txArgs.assetMint,
|
|
16107
16425
|
txArgs.vault,
|
|
16108
16426
|
assetTokenProgram,
|
|
16109
16427
|
true
|
|
16110
16428
|
),
|
|
16111
16429
|
feeVault,
|
|
16112
|
-
feeVaultAta: (0,
|
|
16430
|
+
feeVaultAta: (0, import_common31.getAtaAddress)(
|
|
16113
16431
|
txArgs.assetMint,
|
|
16114
16432
|
feeVault,
|
|
16115
16433
|
assetTokenProgram,
|
|
16116
16434
|
true
|
|
16117
16435
|
),
|
|
16118
|
-
userShareAta: txArgs.userShareAta ?? (0,
|
|
16436
|
+
userShareAta: txArgs.userShareAta ?? (0, import_common31.getAtaAddress)(txArgs.shareMint, txArgs.user, shareTokenProgram)
|
|
16119
16437
|
};
|
|
16120
16438
|
}
|
|
16121
16439
|
async buildPreambleInstructions(args) {
|
|
16122
|
-
const payer = (0,
|
|
16123
|
-
const createVaultAssetAta = (0,
|
|
16440
|
+
const payer = (0, import_common31.toWeb3Pk)(args.user);
|
|
16441
|
+
const createVaultAssetAta = (0, import_spl_token10.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16124
16442
|
payer,
|
|
16125
|
-
(0,
|
|
16126
|
-
(0,
|
|
16127
|
-
(0,
|
|
16128
|
-
(0,
|
|
16129
|
-
|
|
16443
|
+
(0, import_common31.toWeb3Pk)(args.vaultAssetAta),
|
|
16444
|
+
(0, import_common31.toWeb3Pk)(args.vault),
|
|
16445
|
+
(0, import_common31.toWeb3Pk)(args.assetMint),
|
|
16446
|
+
(0, import_common31.toWeb3Pk)(args.assetTokenProgram),
|
|
16447
|
+
import_spl_token10.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16130
16448
|
);
|
|
16131
|
-
const createFeeVaultAta = (0,
|
|
16449
|
+
const createFeeVaultAta = (0, import_spl_token10.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16132
16450
|
payer,
|
|
16133
|
-
(0,
|
|
16134
|
-
(0,
|
|
16135
|
-
(0,
|
|
16136
|
-
(0,
|
|
16137
|
-
|
|
16451
|
+
(0, import_common31.toWeb3Pk)(args.feeVaultAta),
|
|
16452
|
+
(0, import_common31.toWeb3Pk)(args.feeVault),
|
|
16453
|
+
(0, import_common31.toWeb3Pk)(args.assetMint),
|
|
16454
|
+
(0, import_common31.toWeb3Pk)(args.assetTokenProgram),
|
|
16455
|
+
import_spl_token10.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16138
16456
|
);
|
|
16139
|
-
const defaultUserShareAta = (0,
|
|
16457
|
+
const defaultUserShareAta = (0, import_common31.getAtaAddress)(
|
|
16140
16458
|
args.shareMint,
|
|
16141
16459
|
args.user,
|
|
16142
16460
|
args.shareTokenProgram
|
|
16143
16461
|
);
|
|
16144
|
-
const createUserShareAta = (0,
|
|
16145
|
-
(0,
|
|
16146
|
-
) ? (0,
|
|
16462
|
+
const createUserShareAta = (0, import_common31.toWeb3Pk)(args.userShareAta).equals(
|
|
16463
|
+
(0, import_common31.toWeb3Pk)(defaultUserShareAta)
|
|
16464
|
+
) ? (0, import_spl_token10.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16147
16465
|
payer,
|
|
16148
|
-
(0,
|
|
16466
|
+
(0, import_common31.toWeb3Pk)(args.userShareAta),
|
|
16149
16467
|
payer,
|
|
16150
|
-
(0,
|
|
16151
|
-
(0,
|
|
16152
|
-
|
|
16468
|
+
(0, import_common31.toWeb3Pk)(args.shareMint),
|
|
16469
|
+
(0, import_common31.toWeb3Pk)(args.shareTokenProgram),
|
|
16470
|
+
import_spl_token10.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16153
16471
|
) : null;
|
|
16154
|
-
return [createVaultAssetAta, createFeeVaultAta, createUserShareAta].filter((ix) => ix != null).map(
|
|
16472
|
+
return [createVaultAssetAta, createFeeVaultAta, createUserShareAta].filter((ix) => ix != null).map(import_common31.toKitInstruction);
|
|
16155
16473
|
}
|
|
16156
16474
|
async buildPlanExtras(args) {
|
|
16157
16475
|
return {
|
|
@@ -16171,28 +16489,28 @@ var ExecuteDepositBuilder = class extends VaultBuilderBase {
|
|
|
16171
16489
|
};
|
|
16172
16490
|
|
|
16173
16491
|
// src/client/builders/executeTrancheDeposit.ts
|
|
16174
|
-
var
|
|
16175
|
-
var
|
|
16176
|
-
var
|
|
16177
|
-
var
|
|
16492
|
+
var import_core11 = require("@anchor-lang/core");
|
|
16493
|
+
var import_spl_token11 = require("@solana/spl-token");
|
|
16494
|
+
var import_web314 = require("@solana/web3.js");
|
|
16495
|
+
var import_common32 = __toESM(require_dist());
|
|
16178
16496
|
var ExecuteTrancheDepositBuilder = class extends VaultBuilderBase {
|
|
16179
16497
|
getIxAccounts(args) {
|
|
16180
16498
|
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:
|
|
16499
|
+
user: (0, import_common32.toWeb3Pk)(args.user),
|
|
16500
|
+
vault: (0, import_common32.toWeb3Pk)(args.vault),
|
|
16501
|
+
vaultOracle: (0, import_common32.toWeb3Pk)(args.vaultOracle),
|
|
16502
|
+
vaultTrancheState: (0, import_common32.toWeb3Pk)(args.vaultTrancheState),
|
|
16503
|
+
assetMint: (0, import_common32.toWeb3Pk)(args.assetMint),
|
|
16504
|
+
trancheShareMint: (0, import_common32.toWeb3Pk)(args.trancheShareMint),
|
|
16505
|
+
userAssetAta: (0, import_common32.toWeb3Pk)(args.userAssetAta),
|
|
16506
|
+
vaultAssetAta: (0, import_common32.toWeb3Pk)(args.vaultAssetAta),
|
|
16507
|
+
feeVault: (0, import_common32.toWeb3Pk)(args.feeVault),
|
|
16508
|
+
feeVaultAta: (0, import_common32.toWeb3Pk)(args.feeVaultAta),
|
|
16509
|
+
userTrancheShareAta: (0, import_common32.toWeb3Pk)(args.userTrancheShareAta),
|
|
16510
|
+
assetTokenProgram: (0, import_common32.toWeb3Pk)(args.assetTokenProgram),
|
|
16511
|
+
shareTokenProgram: (0, import_common32.toWeb3Pk)(args.shareTokenProgram),
|
|
16512
|
+
associatedTokenProgram: import_spl_token11.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
16513
|
+
systemProgram: import_web314.SystemProgram.programId
|
|
16196
16514
|
};
|
|
16197
16515
|
}
|
|
16198
16516
|
getIxData(args) {
|
|
@@ -16211,7 +16529,7 @@ var ExecuteTrancheDepositBuilder = class extends VaultBuilderBase {
|
|
|
16211
16529
|
) : this.program.methods.executeTrancheDeposit(data.kind, data.amount);
|
|
16212
16530
|
return methods.accountsPartial(
|
|
16213
16531
|
this.getIxAccounts(args)
|
|
16214
|
-
).instruction().then(
|
|
16532
|
+
).instruction().then(import_common32.toKitInstruction);
|
|
16215
16533
|
}
|
|
16216
16534
|
async deriveIxArgs(txArgs) {
|
|
16217
16535
|
const connection = this.program.provider.connection;
|
|
@@ -16240,29 +16558,29 @@ var ExecuteTrancheDepositBuilder = class extends VaultBuilderBase {
|
|
|
16240
16558
|
assetMint: txArgs.assetMint,
|
|
16241
16559
|
trancheShareMint,
|
|
16242
16560
|
kind: txArgs.kind,
|
|
16243
|
-
amount: new
|
|
16561
|
+
amount: new import_core11.BN(txArgs.amount.toString()),
|
|
16244
16562
|
addressSeeds: txArgs.addressSeeds,
|
|
16245
16563
|
assetTokenProgram,
|
|
16246
16564
|
shareTokenProgram,
|
|
16247
|
-
userAssetAta: (0,
|
|
16565
|
+
userAssetAta: (0, import_common32.getAtaAddress)(
|
|
16248
16566
|
txArgs.assetMint,
|
|
16249
16567
|
txArgs.user,
|
|
16250
16568
|
assetTokenProgram
|
|
16251
16569
|
),
|
|
16252
|
-
vaultAssetAta: (0,
|
|
16570
|
+
vaultAssetAta: (0, import_common32.getAtaAddress)(
|
|
16253
16571
|
txArgs.assetMint,
|
|
16254
16572
|
txArgs.vault,
|
|
16255
16573
|
assetTokenProgram,
|
|
16256
16574
|
true
|
|
16257
16575
|
),
|
|
16258
16576
|
feeVault,
|
|
16259
|
-
feeVaultAta: (0,
|
|
16577
|
+
feeVaultAta: (0, import_common32.getAtaAddress)(
|
|
16260
16578
|
txArgs.assetMint,
|
|
16261
16579
|
feeVault,
|
|
16262
16580
|
assetTokenProgram,
|
|
16263
16581
|
true
|
|
16264
16582
|
),
|
|
16265
|
-
userTrancheShareAta: (0,
|
|
16583
|
+
userTrancheShareAta: (0, import_common32.getAtaAddress)(
|
|
16266
16584
|
trancheShareMint,
|
|
16267
16585
|
txArgs.user,
|
|
16268
16586
|
shareTokenProgram
|
|
@@ -16270,33 +16588,33 @@ var ExecuteTrancheDepositBuilder = class extends VaultBuilderBase {
|
|
|
16270
16588
|
};
|
|
16271
16589
|
}
|
|
16272
16590
|
async buildPreambleInstructions(args) {
|
|
16273
|
-
const payer = (0,
|
|
16274
|
-
const createVaultAssetAta = (0,
|
|
16591
|
+
const payer = (0, import_common32.toWeb3Pk)(args.user);
|
|
16592
|
+
const createVaultAssetAta = (0, import_spl_token11.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16275
16593
|
payer,
|
|
16276
|
-
(0,
|
|
16277
|
-
(0,
|
|
16278
|
-
(0,
|
|
16279
|
-
(0,
|
|
16280
|
-
|
|
16594
|
+
(0, import_common32.toWeb3Pk)(args.vaultAssetAta),
|
|
16595
|
+
(0, import_common32.toWeb3Pk)(args.vault),
|
|
16596
|
+
(0, import_common32.toWeb3Pk)(args.assetMint),
|
|
16597
|
+
(0, import_common32.toWeb3Pk)(args.assetTokenProgram),
|
|
16598
|
+
import_spl_token11.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16281
16599
|
);
|
|
16282
|
-
const createUserShareAta = (0,
|
|
16600
|
+
const createUserShareAta = (0, import_spl_token11.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16283
16601
|
payer,
|
|
16284
|
-
(0,
|
|
16602
|
+
(0, import_common32.toWeb3Pk)(args.userTrancheShareAta),
|
|
16285
16603
|
payer,
|
|
16286
|
-
(0,
|
|
16287
|
-
(0,
|
|
16288
|
-
|
|
16604
|
+
(0, import_common32.toWeb3Pk)(args.trancheShareMint),
|
|
16605
|
+
(0, import_common32.toWeb3Pk)(args.shareTokenProgram),
|
|
16606
|
+
import_spl_token11.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16289
16607
|
);
|
|
16290
|
-
const createFeeVaultAta = (0,
|
|
16608
|
+
const createFeeVaultAta = (0, import_spl_token11.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16291
16609
|
payer,
|
|
16292
|
-
(0,
|
|
16293
|
-
(0,
|
|
16294
|
-
(0,
|
|
16295
|
-
(0,
|
|
16296
|
-
|
|
16610
|
+
(0, import_common32.toWeb3Pk)(args.feeVaultAta),
|
|
16611
|
+
(0, import_common32.toWeb3Pk)(args.feeVault),
|
|
16612
|
+
(0, import_common32.toWeb3Pk)(args.assetMint),
|
|
16613
|
+
(0, import_common32.toWeb3Pk)(args.assetTokenProgram),
|
|
16614
|
+
import_spl_token11.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16297
16615
|
);
|
|
16298
16616
|
return [createVaultAssetAta, createFeeVaultAta, createUserShareAta].map(
|
|
16299
|
-
|
|
16617
|
+
import_common32.toKitInstruction
|
|
16300
16618
|
);
|
|
16301
16619
|
}
|
|
16302
16620
|
async buildPlanExtras(args) {
|
|
@@ -16319,27 +16637,27 @@ var ExecuteTrancheDepositBuilder = class extends VaultBuilderBase {
|
|
|
16319
16637
|
};
|
|
16320
16638
|
|
|
16321
16639
|
// src/client/builders/executeTrancheWithdraw.ts
|
|
16322
|
-
var
|
|
16323
|
-
var
|
|
16324
|
-
var
|
|
16325
|
-
var
|
|
16640
|
+
var import_core12 = require("@anchor-lang/core");
|
|
16641
|
+
var import_spl_token12 = require("@solana/spl-token");
|
|
16642
|
+
var import_web316 = require("@solana/web3.js");
|
|
16643
|
+
var import_common34 = __toESM(require_dist());
|
|
16326
16644
|
|
|
16327
16645
|
// src/client/builders/externalLiquidity.ts
|
|
16328
16646
|
var import_kit7 = require("@solana/kit");
|
|
16329
|
-
var
|
|
16330
|
-
var
|
|
16647
|
+
var import_web315 = require("@solana/web3.js");
|
|
16648
|
+
var import_common33 = __toESM(require_dist());
|
|
16331
16649
|
var import_marginfi = __toESM(require_dist2());
|
|
16332
16650
|
function parseMarginfiSlot(slot) {
|
|
16333
16651
|
const data = slot?.data;
|
|
16334
16652
|
if (!data || data.length < 40) return null;
|
|
16335
16653
|
if (data[0] !== 1) return null;
|
|
16336
16654
|
const pubkeyBytes = new Uint8Array(data.slice(8, 40));
|
|
16337
|
-
const userAccount = new
|
|
16655
|
+
const userAccount = new import_web315.PublicKey(pubkeyBytes).toBase58();
|
|
16338
16656
|
return { userAccount };
|
|
16339
16657
|
}
|
|
16340
16658
|
function toWeb3AccountMeta(account) {
|
|
16341
16659
|
return {
|
|
16342
|
-
pubkey: new
|
|
16660
|
+
pubkey: new import_web315.PublicKey(account.address),
|
|
16343
16661
|
isWritable: account.role === import_kit7.AccountRole.WRITABLE || account.role === import_kit7.AccountRole.WRITABLE_SIGNER,
|
|
16344
16662
|
isSigner: account.role === import_kit7.AccountRole.READONLY_SIGNER || account.role === import_kit7.AccountRole.WRITABLE_SIGNER
|
|
16345
16663
|
};
|
|
@@ -16378,7 +16696,7 @@ function resolveExternalWithdraw({
|
|
|
16378
16696
|
};
|
|
16379
16697
|
}
|
|
16380
16698
|
const marginfiClient = new import_marginfi.CpiClient({ accounts: marginfiAccounts });
|
|
16381
|
-
const withdrawRefs = (0,
|
|
16699
|
+
const withdrawRefs = (0, import_common33.createCpiRefs)([
|
|
16382
16700
|
marginfiClient.withdraw_cpi({
|
|
16383
16701
|
marginfiAccount: slot0.userAccount,
|
|
16384
16702
|
authority: vault,
|
|
@@ -16398,14 +16716,14 @@ function buildMarginfiWithdrawInteraction(args) {
|
|
|
16398
16716
|
`No Marginfi market is configured for asset mint ${args.assetMint}`
|
|
16399
16717
|
);
|
|
16400
16718
|
}
|
|
16401
|
-
const vaultAssetAta = (0,
|
|
16719
|
+
const vaultAssetAta = (0, import_common33.getAtaAddress)(
|
|
16402
16720
|
args.assetMint,
|
|
16403
16721
|
args.vault,
|
|
16404
16722
|
marginfiAccounts.tokenProgram,
|
|
16405
16723
|
true
|
|
16406
16724
|
);
|
|
16407
16725
|
const marginfiClient = new import_marginfi.CpiClient({ accounts: marginfiAccounts });
|
|
16408
|
-
const withdraw = (0,
|
|
16726
|
+
const withdraw = (0, import_common33.createCpiRefs)([
|
|
16409
16727
|
marginfiClient.withdraw_cpi({
|
|
16410
16728
|
marginfiAccount: args.marginfiAccount,
|
|
16411
16729
|
authority: args.vault,
|
|
@@ -16429,19 +16747,19 @@ function buildMarginfiWithdrawInteraction(args) {
|
|
|
16429
16747
|
var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
16430
16748
|
getIxAccounts(args) {
|
|
16431
16749
|
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:
|
|
16750
|
+
user: (0, import_common34.toWeb3Pk)(args.user),
|
|
16751
|
+
vault: (0, import_common34.toWeb3Pk)(args.vault),
|
|
16752
|
+
vaultOracle: (0, import_common34.toWeb3Pk)(args.vaultOracle),
|
|
16753
|
+
vaultTrancheState: (0, import_common34.toWeb3Pk)(args.vaultTrancheState),
|
|
16754
|
+
assetMint: (0, import_common34.toWeb3Pk)(args.assetMint),
|
|
16755
|
+
trancheShareMint: (0, import_common34.toWeb3Pk)(args.trancheShareMint),
|
|
16756
|
+
userAssetAta: (0, import_common34.toWeb3Pk)(args.userAssetAta),
|
|
16757
|
+
vaultAssetAta: (0, import_common34.toWeb3Pk)(args.vaultAssetAta),
|
|
16758
|
+
userTrancheShareAta: (0, import_common34.toWeb3Pk)(args.userTrancheShareAta),
|
|
16759
|
+
assetTokenProgram: (0, import_common34.toWeb3Pk)(args.assetTokenProgram),
|
|
16760
|
+
shareTokenProgram: (0, import_common34.toWeb3Pk)(args.shareTokenProgram),
|
|
16761
|
+
associatedTokenProgram: import_spl_token12.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
16762
|
+
systemProgram: import_web316.SystemProgram.programId
|
|
16445
16763
|
};
|
|
16446
16764
|
}
|
|
16447
16765
|
getIxData(args) {
|
|
@@ -16478,7 +16796,7 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16478
16796
|
);
|
|
16479
16797
|
return methods.accountsPartial(
|
|
16480
16798
|
this.getIxAccounts(args)
|
|
16481
|
-
).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(
|
|
16799
|
+
).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(import_common34.toKitInstruction);
|
|
16482
16800
|
}
|
|
16483
16801
|
async deriveIxArgs(txArgs) {
|
|
16484
16802
|
const connection = this.program.provider.connection;
|
|
@@ -16499,7 +16817,7 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16499
16817
|
txArgs.assetTokenProgram
|
|
16500
16818
|
);
|
|
16501
16819
|
const { mint: trancheShareMint, tokenProgram: shareTokenProgram } = trancheShare;
|
|
16502
|
-
const vaultAssetAta = (0,
|
|
16820
|
+
const vaultAssetAta = (0, import_common34.getAtaAddress)(
|
|
16503
16821
|
txArgs.assetMint,
|
|
16504
16822
|
txArgs.vault,
|
|
16505
16823
|
assetTokenProgram,
|
|
@@ -16524,17 +16842,17 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16524
16842
|
assetMint: txArgs.assetMint,
|
|
16525
16843
|
trancheShareMint,
|
|
16526
16844
|
kind: txArgs.kind,
|
|
16527
|
-
shareAmount: new
|
|
16845
|
+
shareAmount: new import_core12.BN(txArgs.shareAmount.toString()),
|
|
16528
16846
|
addressSeeds: txArgs.addressSeeds,
|
|
16529
16847
|
assetTokenProgram,
|
|
16530
16848
|
shareTokenProgram,
|
|
16531
|
-
userAssetAta: (0,
|
|
16849
|
+
userAssetAta: (0, import_common34.getAtaAddress)(
|
|
16532
16850
|
txArgs.assetMint,
|
|
16533
16851
|
txArgs.user,
|
|
16534
16852
|
assetTokenProgram
|
|
16535
16853
|
),
|
|
16536
16854
|
vaultAssetAta,
|
|
16537
|
-
userTrancheShareAta: (0,
|
|
16855
|
+
userTrancheShareAta: (0, import_common34.getAtaAddress)(
|
|
16538
16856
|
trancheShareMint,
|
|
16539
16857
|
txArgs.user,
|
|
16540
16858
|
shareTokenProgram
|
|
@@ -16548,16 +16866,16 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16548
16866
|
return txArgs.lookupTables;
|
|
16549
16867
|
}
|
|
16550
16868
|
async buildPreambleInstructions(args) {
|
|
16551
|
-
const payer = (0,
|
|
16552
|
-
const createUserAssetAta = (0,
|
|
16869
|
+
const payer = (0, import_common34.toWeb3Pk)(args.user);
|
|
16870
|
+
const createUserAssetAta = (0, import_spl_token12.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16553
16871
|
payer,
|
|
16554
|
-
(0,
|
|
16872
|
+
(0, import_common34.toWeb3Pk)(args.userAssetAta),
|
|
16555
16873
|
payer,
|
|
16556
|
-
(0,
|
|
16557
|
-
(0,
|
|
16558
|
-
|
|
16874
|
+
(0, import_common34.toWeb3Pk)(args.assetMint),
|
|
16875
|
+
(0, import_common34.toWeb3Pk)(args.assetTokenProgram),
|
|
16876
|
+
import_spl_token12.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16559
16877
|
);
|
|
16560
|
-
return [createUserAssetAta].map(
|
|
16878
|
+
return [createUserAssetAta].map(import_common34.toKitInstruction);
|
|
16561
16879
|
}
|
|
16562
16880
|
async buildPlanExtras(args) {
|
|
16563
16881
|
return {
|
|
@@ -16569,25 +16887,25 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16569
16887
|
};
|
|
16570
16888
|
|
|
16571
16889
|
// src/client/builders/executeWithdraw.ts
|
|
16572
|
-
var
|
|
16573
|
-
var
|
|
16574
|
-
var
|
|
16890
|
+
var import_core13 = require("@anchor-lang/core");
|
|
16891
|
+
var import_spl_token13 = require("@solana/spl-token");
|
|
16892
|
+
var import_common35 = __toESM(require_dist());
|
|
16575
16893
|
var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
16576
16894
|
getIxAccounts(args) {
|
|
16577
16895
|
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,
|
|
16896
|
+
user: (0, import_common35.toWeb3Pk)(args.user),
|
|
16897
|
+
vault: (0, import_common35.toWeb3Pk)(args.vault),
|
|
16898
|
+
vaultOracle: (0, import_common35.toWeb3Pk)(args.vaultOracle),
|
|
16899
|
+
vaultTrancheState: args.vaultTrancheState ? (0, import_common35.toWeb3Pk)(args.vaultTrancheState) : null,
|
|
16900
|
+
assetMint: (0, import_common35.toWeb3Pk)(args.assetMint),
|
|
16901
|
+
shareMint: (0, import_common35.toWeb3Pk)(args.shareMint),
|
|
16902
|
+
userAssetAta: (0, import_common35.toWeb3Pk)(args.userAssetAta),
|
|
16903
|
+
vaultAssetAta: (0, import_common35.toWeb3Pk)(args.vaultAssetAta),
|
|
16904
|
+
feeVault: (0, import_common35.toWeb3Pk)(args.feeVault),
|
|
16905
|
+
feeVaultAta: (0, import_common35.toWeb3Pk)(args.feeVaultAta),
|
|
16906
|
+
userShareAta: (0, import_common35.toWeb3Pk)(args.userShareAta),
|
|
16907
|
+
assetTokenProgram: (0, import_common35.toWeb3Pk)(args.assetTokenProgram),
|
|
16908
|
+
shareTokenProgram: (0, import_common35.toWeb3Pk)(args.shareTokenProgram)
|
|
16591
16909
|
};
|
|
16592
16910
|
}
|
|
16593
16911
|
getIxData(args) {
|
|
@@ -16617,7 +16935,7 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16617
16935
|
) : this.program.methods.executeWithdraw(data.shareAmount);
|
|
16618
16936
|
return methods.accountsPartial(
|
|
16619
16937
|
this.getIxAccounts(args)
|
|
16620
|
-
).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(
|
|
16938
|
+
).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(import_common35.toKitInstruction);
|
|
16621
16939
|
}
|
|
16622
16940
|
async deriveIxArgs(txArgs) {
|
|
16623
16941
|
const connection = this.program.provider.connection;
|
|
@@ -16651,7 +16969,7 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16651
16969
|
),
|
|
16652
16970
|
this.account.fetchVault(txArgs.vault)
|
|
16653
16971
|
]);
|
|
16654
|
-
const vaultAssetAta = (0,
|
|
16972
|
+
const vaultAssetAta = (0, import_common35.getAtaAddress)(
|
|
16655
16973
|
txArgs.assetMint,
|
|
16656
16974
|
txArgs.vault,
|
|
16657
16975
|
assetTokenProgram,
|
|
@@ -16675,19 +16993,19 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16675
16993
|
vaultTrancheState: vaultTrancheState ?? null,
|
|
16676
16994
|
assetMint: txArgs.assetMint,
|
|
16677
16995
|
shareMint: txArgs.shareMint,
|
|
16678
|
-
shareAmount: new
|
|
16996
|
+
shareAmount: new import_core13.BN(txArgs.shareAmount.toString()),
|
|
16679
16997
|
assetTokenProgram,
|
|
16680
16998
|
shareTokenProgram,
|
|
16681
|
-
userAssetAta: txArgs.userAssetAta ?? (0,
|
|
16999
|
+
userAssetAta: txArgs.userAssetAta ?? (0, import_common35.getAtaAddress)(txArgs.assetMint, txArgs.user, assetTokenProgram),
|
|
16682
17000
|
vaultAssetAta,
|
|
16683
17001
|
feeVault,
|
|
16684
|
-
feeVaultAta: (0,
|
|
17002
|
+
feeVaultAta: (0, import_common35.getAtaAddress)(
|
|
16685
17003
|
txArgs.assetMint,
|
|
16686
17004
|
feeVault,
|
|
16687
17005
|
assetTokenProgram,
|
|
16688
17006
|
true
|
|
16689
17007
|
),
|
|
16690
|
-
userShareAta: txArgs.userShareAta ?? (0,
|
|
17008
|
+
userShareAta: txArgs.userShareAta ?? (0, import_common35.getAtaAddress)(txArgs.shareMint, txArgs.user, shareTokenProgram),
|
|
16691
17009
|
externalWithdrawIxRefs,
|
|
16692
17010
|
externalLiquiditySource,
|
|
16693
17011
|
externalWithdrawAccounts,
|
|
@@ -16698,31 +17016,31 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16698
17016
|
return txArgs.lookupTables;
|
|
16699
17017
|
}
|
|
16700
17018
|
async buildPreambleInstructions(args) {
|
|
16701
|
-
const defaultUserAssetAta = (0,
|
|
17019
|
+
const defaultUserAssetAta = (0, import_common35.getAtaAddress)(
|
|
16702
17020
|
args.assetMint,
|
|
16703
17021
|
args.user,
|
|
16704
17022
|
args.assetTokenProgram
|
|
16705
17023
|
);
|
|
16706
|
-
const payer = (0,
|
|
16707
|
-
const createUserAssetAta = (0,
|
|
16708
|
-
(0,
|
|
16709
|
-
) ? (0,
|
|
17024
|
+
const payer = (0, import_common35.toWeb3Pk)(args.user);
|
|
17025
|
+
const createUserAssetAta = (0, import_common35.toWeb3Pk)(args.userAssetAta).equals(
|
|
17026
|
+
(0, import_common35.toWeb3Pk)(defaultUserAssetAta)
|
|
17027
|
+
) ? (0, import_spl_token13.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16710
17028
|
payer,
|
|
16711
|
-
(0,
|
|
17029
|
+
(0, import_common35.toWeb3Pk)(args.userAssetAta),
|
|
16712
17030
|
payer,
|
|
16713
|
-
(0,
|
|
16714
|
-
(0,
|
|
16715
|
-
|
|
17031
|
+
(0, import_common35.toWeb3Pk)(args.assetMint),
|
|
17032
|
+
(0, import_common35.toWeb3Pk)(args.assetTokenProgram),
|
|
17033
|
+
import_spl_token13.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16716
17034
|
) : null;
|
|
16717
|
-
const createFeeVaultAta = (0,
|
|
17035
|
+
const createFeeVaultAta = (0, import_spl_token13.createAssociatedTokenAccountIdempotentInstruction)(
|
|
16718
17036
|
payer,
|
|
16719
|
-
(0,
|
|
16720
|
-
(0,
|
|
16721
|
-
(0,
|
|
16722
|
-
(0,
|
|
16723
|
-
|
|
17037
|
+
(0, import_common35.toWeb3Pk)(args.feeVaultAta),
|
|
17038
|
+
(0, import_common35.toWeb3Pk)(args.feeVault),
|
|
17039
|
+
(0, import_common35.toWeb3Pk)(args.assetMint),
|
|
17040
|
+
(0, import_common35.toWeb3Pk)(args.assetTokenProgram),
|
|
17041
|
+
import_spl_token13.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16724
17042
|
);
|
|
16725
|
-
return [createUserAssetAta, createFeeVaultAta].filter((ix) => ix != null).map(
|
|
17043
|
+
return [createUserAssetAta, createFeeVaultAta].filter((ix) => ix != null).map(import_common35.toKitInstruction);
|
|
16726
17044
|
}
|
|
16727
17045
|
async buildPlanExtras(args) {
|
|
16728
17046
|
return {
|
|
@@ -16732,9 +17050,9 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16732
17050
|
};
|
|
16733
17051
|
|
|
16734
17052
|
// src/client/builders/fulfillJuniorTrancheWithdraw.ts
|
|
16735
|
-
var
|
|
16736
|
-
var
|
|
16737
|
-
var
|
|
17053
|
+
var import_spl_token14 = require("@solana/spl-token");
|
|
17054
|
+
var import_web317 = require("@solana/web3.js");
|
|
17055
|
+
var import_common36 = __toESM(require_dist());
|
|
16738
17056
|
var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
16739
17057
|
async getIx(args) {
|
|
16740
17058
|
const externalWithdrawIxRefs = args.externalWithdrawIxRefs ?? null;
|
|
@@ -16748,24 +17066,24 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16748
17066
|
externalLiquiditySource
|
|
16749
17067
|
);
|
|
16750
17068
|
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(
|
|
17069
|
+
signer: (0, import_common36.toWeb3Pk)(args.signer),
|
|
17070
|
+
owner: (0, import_common36.toWeb3Pk)(args.owner),
|
|
17071
|
+
queuePayer: (0, import_common36.toWeb3Pk)(args.queuePayer),
|
|
17072
|
+
vault: (0, import_common36.toWeb3Pk)(args.vault),
|
|
17073
|
+
vaultOracle: (0, import_common36.toWeb3Pk)(args.vaultOracle),
|
|
17074
|
+
vaultTrancheState: (0, import_common36.toWeb3Pk)(args.vaultTrancheState),
|
|
17075
|
+
withdrawalQueue: (0, import_common36.toWeb3Pk)(args.withdrawalQueue),
|
|
17076
|
+
outputMint: (0, import_common36.toWeb3Pk)(args.outputMint),
|
|
17077
|
+
inputMint: (0, import_common36.toWeb3Pk)(args.inputMint),
|
|
17078
|
+
ownerInputAta: (0, import_common36.toWeb3Pk)(args.ownerInputAta),
|
|
17079
|
+
ownerOutputAta: (0, import_common36.toWeb3Pk)(args.ownerOutputAta),
|
|
17080
|
+
vaultOutputAta: (0, import_common36.toWeb3Pk)(args.vaultOutputAta),
|
|
17081
|
+
queueInputAta: (0, import_common36.toWeb3Pk)(args.queueInputAta),
|
|
17082
|
+
assetTokenProgram: (0, import_common36.toWeb3Pk)(args.assetTokenProgram),
|
|
17083
|
+
shareTokenProgram: (0, import_common36.toWeb3Pk)(args.shareTokenProgram),
|
|
17084
|
+
associatedTokenProgram: import_spl_token14.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
17085
|
+
systemProgram: import_web317.SystemProgram.programId
|
|
17086
|
+
}).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(import_common36.toKitInstruction);
|
|
16769
17087
|
}
|
|
16770
17088
|
async deriveIxArgs(txArgs) {
|
|
16771
17089
|
const connection = this.program.provider.connection;
|
|
@@ -16806,7 +17124,7 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16806
17124
|
]);
|
|
16807
17125
|
const { mint: juniorShareMint, tokenProgram: shareTokenProgram } = juniorShare;
|
|
16808
17126
|
const queuePda = txArgs.withdrawalQueue ?? withdrawalQueue;
|
|
16809
|
-
const vaultOutputAta = (0,
|
|
17127
|
+
const vaultOutputAta = (0, import_common36.getAtaAddress)(
|
|
16810
17128
|
txArgs.assetMint,
|
|
16811
17129
|
txArgs.vault,
|
|
16812
17130
|
assetTokenProgram,
|
|
@@ -16835,14 +17153,14 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16835
17153
|
inputMint: juniorShareMint,
|
|
16836
17154
|
assetTokenProgram,
|
|
16837
17155
|
shareTokenProgram,
|
|
16838
|
-
ownerInputAta: txArgs.ownerInputAta ?? (0,
|
|
16839
|
-
ownerOutputAta: (0,
|
|
17156
|
+
ownerInputAta: txArgs.ownerInputAta ?? (0, import_common36.getAtaAddress)(juniorShareMint, txArgs.owner, shareTokenProgram),
|
|
17157
|
+
ownerOutputAta: (0, import_common36.getAtaAddress)(
|
|
16840
17158
|
txArgs.assetMint,
|
|
16841
17159
|
txArgs.owner,
|
|
16842
17160
|
assetTokenProgram
|
|
16843
17161
|
),
|
|
16844
17162
|
vaultOutputAta,
|
|
16845
|
-
queueInputAta: (0,
|
|
17163
|
+
queueInputAta: (0, import_common36.getAtaAddress)(
|
|
16846
17164
|
juniorShareMint,
|
|
16847
17165
|
queuePda,
|
|
16848
17166
|
shareTokenProgram,
|
|
@@ -16858,23 +17176,23 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16858
17176
|
return txArgs.lookupTables;
|
|
16859
17177
|
}
|
|
16860
17178
|
async buildPreambleInstructions(args) {
|
|
16861
|
-
const defaultOwnerInputAta = (0,
|
|
17179
|
+
const defaultOwnerInputAta = (0, import_common36.getAtaAddress)(
|
|
16862
17180
|
args.inputMint,
|
|
16863
17181
|
args.owner,
|
|
16864
17182
|
args.shareTokenProgram
|
|
16865
17183
|
);
|
|
16866
|
-
if (!(0,
|
|
17184
|
+
if (!(0, import_common36.toWeb3Pk)(args.ownerInputAta).equals((0, import_common36.toWeb3Pk)(defaultOwnerInputAta))) {
|
|
16867
17185
|
return [];
|
|
16868
17186
|
}
|
|
16869
17187
|
return [
|
|
16870
|
-
(0,
|
|
16871
|
-
(0,
|
|
16872
|
-
(0,
|
|
16873
|
-
(0,
|
|
16874
|
-
(0,
|
|
16875
|
-
(0,
|
|
16876
|
-
(0,
|
|
16877
|
-
|
|
17188
|
+
(0, import_common36.toKitInstruction)(
|
|
17189
|
+
(0, import_spl_token14.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17190
|
+
(0, import_common36.toWeb3Pk)(args.signer),
|
|
17191
|
+
(0, import_common36.toWeb3Pk)(args.ownerInputAta),
|
|
17192
|
+
(0, import_common36.toWeb3Pk)(args.owner),
|
|
17193
|
+
(0, import_common36.toWeb3Pk)(args.inputMint),
|
|
17194
|
+
(0, import_common36.toWeb3Pk)(args.shareTokenProgram),
|
|
17195
|
+
import_spl_token14.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
16878
17196
|
)
|
|
16879
17197
|
)
|
|
16880
17198
|
];
|
|
@@ -16892,9 +17210,9 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
16892
17210
|
}
|
|
16893
17211
|
};
|
|
16894
17212
|
|
|
16895
|
-
// src/client/builders/updateTrancheConfig.ts
|
|
16896
|
-
var
|
|
16897
|
-
var
|
|
17213
|
+
// src/client/builders/updateTrancheConfig.ts
|
|
17214
|
+
var import_core14 = require("@anchor-lang/core");
|
|
17215
|
+
var import_common37 = __toESM(require_dist());
|
|
16898
17216
|
var UpdateTrancheConfigBuilder = class extends VaultBuilderBase {
|
|
16899
17217
|
async getIx(args) {
|
|
16900
17218
|
return this.program.methods.vaultUpdateTrancheConfig({
|
|
@@ -16905,11 +17223,11 @@ var UpdateTrancheConfigBuilder = class extends VaultBuilderBase {
|
|
|
16905
17223
|
targetLockupDurationSecs: args.targetLockupDurationSecs,
|
|
16906
17224
|
juniorDepositCap: args.juniorDepositCap
|
|
16907
17225
|
}).accountsPartial({
|
|
16908
|
-
curator: (0,
|
|
16909
|
-
vault: (0,
|
|
16910
|
-
vaultTrancheState: (0,
|
|
16911
|
-
vaultOracle: (0,
|
|
16912
|
-
}).instruction().then(
|
|
17226
|
+
curator: (0, import_common37.toWeb3Pk)(args.curator),
|
|
17227
|
+
vault: (0, import_common37.toWeb3Pk)(args.vault),
|
|
17228
|
+
vaultTrancheState: (0, import_common37.toWeb3Pk)(args.vaultTrancheState),
|
|
17229
|
+
vaultOracle: (0, import_common37.toWeb3Pk)(args.vaultOracle)
|
|
17230
|
+
}).instruction().then(import_common37.toKitInstruction);
|
|
16913
17231
|
}
|
|
16914
17232
|
async deriveIxArgs(txArgs) {
|
|
16915
17233
|
const [vaultTrancheState] = await this.pda.deriveVaultTrancheStatePda(
|
|
@@ -16925,8 +17243,8 @@ var UpdateTrancheConfigBuilder = class extends VaultBuilderBase {
|
|
|
16925
17243
|
juniorFloorApyBps: txArgs.juniorFloorApyBps ?? null,
|
|
16926
17244
|
earlyUnstakeFeeBps: txArgs.earlyUnstakeFeeBps ?? null,
|
|
16927
17245
|
standardUnstakeFeeBps: txArgs.standardUnstakeFeeBps ?? null,
|
|
16928
|
-
targetLockupDurationSecs: txArgs.targetLockupDurationSecs === void 0 ? null : new
|
|
16929
|
-
juniorDepositCap: txArgs.juniorDepositCap === void 0 ? null : new
|
|
17246
|
+
targetLockupDurationSecs: txArgs.targetLockupDurationSecs === void 0 ? null : new import_core14.BN(txArgs.targetLockupDurationSecs.toString()),
|
|
17247
|
+
juniorDepositCap: txArgs.juniorDepositCap === void 0 ? null : new import_core14.BN(txArgs.juniorDepositCap.toString())
|
|
16930
17248
|
};
|
|
16931
17249
|
}
|
|
16932
17250
|
async buildPlanExtras(args) {
|
|
@@ -16939,25 +17257,25 @@ var UpdateTrancheConfigBuilder = class extends VaultBuilderBase {
|
|
|
16939
17257
|
};
|
|
16940
17258
|
|
|
16941
17259
|
// src/client/builders/managerRedepositAsset.ts
|
|
16942
|
-
var
|
|
16943
|
-
var
|
|
16944
|
-
var
|
|
16945
|
-
var
|
|
17260
|
+
var import_core15 = require("@anchor-lang/core");
|
|
17261
|
+
var import_spl_token15 = require("@solana/spl-token");
|
|
17262
|
+
var import_web318 = require("@solana/web3.js");
|
|
17263
|
+
var import_common38 = __toESM(require_dist());
|
|
16946
17264
|
var ManagerRedepositAssetBuilder = class extends VaultBuilderBase {
|
|
16947
17265
|
async getIx(args) {
|
|
16948
17266
|
return this.program.methods.managerRedepositAsset({
|
|
16949
17267
|
depositAmount: args.depositAmount,
|
|
16950
17268
|
externalAmount: args.externalAmount
|
|
16951
17269
|
}).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(
|
|
17270
|
+
manager: (0, import_common38.toWeb3Pk)(args.manager),
|
|
17271
|
+
vault: (0, import_common38.toWeb3Pk)(args.vault),
|
|
17272
|
+
assetMint: (0, import_common38.toWeb3Pk)(args.assetMint),
|
|
17273
|
+
vaultAssetAta: (0, import_common38.toWeb3Pk)(args.vaultAssetAta),
|
|
17274
|
+
managerAssetAta: (0, import_common38.toWeb3Pk)(args.managerAssetAta),
|
|
17275
|
+
assetTokenProgram: (0, import_common38.toWeb3Pk)(args.assetTokenProgram),
|
|
17276
|
+
associatedTokenProgram: import_spl_token15.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
17277
|
+
systemProgram: import_web318.SystemProgram.programId
|
|
17278
|
+
}).instruction().then(import_common38.toKitInstruction);
|
|
16961
17279
|
}
|
|
16962
17280
|
async deriveIxArgs(txArgs) {
|
|
16963
17281
|
const connection = this.program.provider.connection;
|
|
@@ -16971,10 +17289,10 @@ var ManagerRedepositAssetBuilder = class extends VaultBuilderBase {
|
|
|
16971
17289
|
manager: txArgs.manager,
|
|
16972
17290
|
vault: txArgs.vault,
|
|
16973
17291
|
assetMint: txArgs.assetMint,
|
|
16974
|
-
depositAmount: new
|
|
16975
|
-
externalAmount: new
|
|
17292
|
+
depositAmount: new import_core15.BN(txArgs.depositAmount.toString()),
|
|
17293
|
+
externalAmount: new import_core15.BN(externalAmount.toString()),
|
|
16976
17294
|
assetTokenProgram,
|
|
16977
|
-
vaultAssetAta: (0,
|
|
17295
|
+
vaultAssetAta: (0, import_common38.getAtaAddress)(
|
|
16978
17296
|
txArgs.assetMint,
|
|
16979
17297
|
txArgs.vault,
|
|
16980
17298
|
assetTokenProgram,
|
|
@@ -16982,7 +17300,7 @@ var ManagerRedepositAssetBuilder = class extends VaultBuilderBase {
|
|
|
16982
17300
|
),
|
|
16983
17301
|
// The manager may be a PDA (e.g. a Squads vault), so allow off-curve
|
|
16984
17302
|
// owners when deriving its ATA.
|
|
16985
|
-
managerAssetAta: (0,
|
|
17303
|
+
managerAssetAta: (0, import_common38.getAtaAddress)(
|
|
16986
17304
|
txArgs.assetMint,
|
|
16987
17305
|
txArgs.manager,
|
|
16988
17306
|
assetTokenProgram,
|
|
@@ -16998,23 +17316,23 @@ var ManagerRedepositAssetBuilder = class extends VaultBuilderBase {
|
|
|
16998
17316
|
};
|
|
16999
17317
|
|
|
17000
17318
|
// src/client/builders/managerWithdrawAsset.ts
|
|
17001
|
-
var
|
|
17002
|
-
var
|
|
17003
|
-
var
|
|
17004
|
-
var
|
|
17319
|
+
var import_core16 = require("@anchor-lang/core");
|
|
17320
|
+
var import_spl_token16 = require("@solana/spl-token");
|
|
17321
|
+
var import_web319 = require("@solana/web3.js");
|
|
17322
|
+
var import_common39 = __toESM(require_dist());
|
|
17005
17323
|
var ManagerWithdrawAssetBuilder = class extends VaultBuilderBase {
|
|
17006
17324
|
async getIx(args) {
|
|
17007
17325
|
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(
|
|
17326
|
+
manager: (0, import_common39.toWeb3Pk)(args.manager),
|
|
17327
|
+
vault: (0, import_common39.toWeb3Pk)(args.vault),
|
|
17328
|
+
assetMint: (0, import_common39.toWeb3Pk)(args.assetMint),
|
|
17329
|
+
vaultAssetAta: (0, import_common39.toWeb3Pk)(args.vaultAssetAta),
|
|
17330
|
+
destination: (0, import_common39.toWeb3Pk)(args.destination),
|
|
17331
|
+
destinationAssetAta: (0, import_common39.toWeb3Pk)(args.destinationAssetAta),
|
|
17332
|
+
assetTokenProgram: (0, import_common39.toWeb3Pk)(args.assetTokenProgram),
|
|
17333
|
+
associatedTokenProgram: import_spl_token16.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
17334
|
+
systemProgram: import_web319.SystemProgram.programId
|
|
17335
|
+
}).instruction().then(import_common39.toKitInstruction);
|
|
17018
17336
|
}
|
|
17019
17337
|
async deriveIxArgs(txArgs) {
|
|
17020
17338
|
const connection = this.program.provider.connection;
|
|
@@ -17029,15 +17347,15 @@ var ManagerWithdrawAssetBuilder = class extends VaultBuilderBase {
|
|
|
17029
17347
|
vault: txArgs.vault,
|
|
17030
17348
|
assetMint: txArgs.assetMint,
|
|
17031
17349
|
destination,
|
|
17032
|
-
amount: new
|
|
17350
|
+
amount: new import_core16.BN(txArgs.amount.toString()),
|
|
17033
17351
|
assetTokenProgram,
|
|
17034
|
-
vaultAssetAta: (0,
|
|
17352
|
+
vaultAssetAta: (0, import_common39.getAtaAddress)(
|
|
17035
17353
|
txArgs.assetMint,
|
|
17036
17354
|
txArgs.vault,
|
|
17037
17355
|
assetTokenProgram,
|
|
17038
17356
|
true
|
|
17039
17357
|
),
|
|
17040
|
-
destinationAssetAta: (0,
|
|
17358
|
+
destinationAssetAta: (0, import_common39.getAtaAddress)(
|
|
17041
17359
|
txArgs.assetMint,
|
|
17042
17360
|
destination,
|
|
17043
17361
|
assetTokenProgram,
|
|
@@ -17054,18 +17372,18 @@ var ManagerWithdrawAssetBuilder = class extends VaultBuilderBase {
|
|
|
17054
17372
|
};
|
|
17055
17373
|
|
|
17056
17374
|
// src/client/builders/protocolInteraction.ts
|
|
17057
|
-
var
|
|
17375
|
+
var import_core17 = require("@anchor-lang/core");
|
|
17058
17376
|
var import_kit8 = require("@solana/kit");
|
|
17059
|
-
var
|
|
17060
|
-
var
|
|
17061
|
-
var
|
|
17377
|
+
var import_spl_token17 = require("@solana/spl-token");
|
|
17378
|
+
var import_web320 = require("@solana/web3.js");
|
|
17379
|
+
var import_common40 = __toESM(require_dist());
|
|
17062
17380
|
var DEFAULT_PYTH_PRICE_MAX_AGE_SECS = 90n;
|
|
17063
17381
|
function toAssetPriceOracleConfig(args) {
|
|
17064
17382
|
return {
|
|
17065
17383
|
priceOracleType: args?.priceOracleType ?? { none: {} },
|
|
17066
|
-
initialPrice: new
|
|
17384
|
+
initialPrice: new import_core17.BN((args?.initialPrice ?? 0n).toString()),
|
|
17067
17385
|
priceOracleAccount: args?.priceOracleAccount ?? DEFAULT_PRICE_ORACLE_ACCOUNT,
|
|
17068
|
-
pythMaxAgeSecs: new
|
|
17386
|
+
pythMaxAgeSecs: new import_core17.BN(
|
|
17069
17387
|
(args?.pythMaxAgeSecs ?? DEFAULT_PYTH_PRICE_MAX_AGE_SECS).toString()
|
|
17070
17388
|
)
|
|
17071
17389
|
};
|
|
@@ -17073,12 +17391,12 @@ function toAssetPriceOracleConfig(args) {
|
|
|
17073
17391
|
function toAnchorAssetPriceOracleConfig(config) {
|
|
17074
17392
|
return {
|
|
17075
17393
|
...config,
|
|
17076
|
-
priceOracleAccount: (0,
|
|
17394
|
+
priceOracleAccount: (0, import_common40.toWeb3Pk)(config.priceOracleAccount)
|
|
17077
17395
|
};
|
|
17078
17396
|
}
|
|
17079
17397
|
function toWeb3AccountMeta2(account) {
|
|
17080
17398
|
return {
|
|
17081
|
-
pubkey: new
|
|
17399
|
+
pubkey: new import_web320.PublicKey(account.address),
|
|
17082
17400
|
isWritable: account.role === import_kit8.AccountRole.WRITABLE || account.role === import_kit8.AccountRole.WRITABLE_SIGNER,
|
|
17083
17401
|
isSigner: account.role === import_kit8.AccountRole.READONLY_SIGNER || account.role === import_kit8.AccountRole.WRITABLE_SIGNER
|
|
17084
17402
|
};
|
|
@@ -17087,14 +17405,14 @@ var ProtocolInteractionBuilder = class extends VaultBuilderBase {
|
|
|
17087
17405
|
async getIx(args) {
|
|
17088
17406
|
return this.program.methods.protocolInteraction(args.refs, {
|
|
17089
17407
|
externalLiquidityIndex: args.externalLiquidityIndex,
|
|
17090
|
-
affectedAssetMint: args.affectedAssetMint ? (0,
|
|
17408
|
+
affectedAssetMint: args.affectedAssetMint ? (0, import_common40.toWeb3Pk)(args.affectedAssetMint) : null
|
|
17091
17409
|
}).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(
|
|
17410
|
+
hwManager: (0, import_common40.toWeb3Pk)(args.hwManager),
|
|
17411
|
+
vault: (0, import_common40.toWeb3Pk)(args.vault),
|
|
17412
|
+
affectedAssetMint: args.affectedAssetMint ? (0, import_common40.toWeb3Pk)(args.affectedAssetMint) : null,
|
|
17413
|
+
affectedVaultAta: args.affectedVaultAta ? (0, import_common40.toWeb3Pk)(args.affectedVaultAta) : null,
|
|
17414
|
+
affectedTokenProgram: args.affectedTokenProgram ? (0, import_common40.toWeb3Pk)(args.affectedTokenProgram) : null
|
|
17415
|
+
}).remainingAccounts(args.accounts.map(toWeb3AccountMeta2)).instruction().then(import_common40.toKitInstruction);
|
|
17098
17416
|
}
|
|
17099
17417
|
async deriveIxArgs(txArgs) {
|
|
17100
17418
|
const affectedTokenProgram = txArgs.affectedAssetMint ? txArgs.affectedTokenProgram ?? TOKEN_PROGRAM_ID : null;
|
|
@@ -17106,7 +17424,7 @@ var ProtocolInteractionBuilder = class extends VaultBuilderBase {
|
|
|
17106
17424
|
accounts: txArgs.accounts,
|
|
17107
17425
|
affectedAssetMint: txArgs.affectedAssetMint ?? null,
|
|
17108
17426
|
affectedTokenProgram,
|
|
17109
|
-
affectedVaultAta: txArgs.affectedAssetMint && affectedTokenProgram ? (0,
|
|
17427
|
+
affectedVaultAta: txArgs.affectedAssetMint && affectedTokenProgram ? (0, import_common40.getAtaAddress)(
|
|
17110
17428
|
txArgs.affectedAssetMint,
|
|
17111
17429
|
txArgs.vault,
|
|
17112
17430
|
affectedTokenProgram,
|
|
@@ -17125,18 +17443,18 @@ var JupiterSwapBuilder = class extends VaultBuilderBase {
|
|
|
17125
17443
|
args.destinationPriceOracle
|
|
17126
17444
|
)
|
|
17127
17445
|
}).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(
|
|
17446
|
+
hwManager: (0, import_common40.toWeb3Pk)(args.hwManager),
|
|
17447
|
+
vault: (0, import_common40.toWeb3Pk)(args.vault),
|
|
17448
|
+
sourceMint: (0, import_common40.toWeb3Pk)(args.sourceMint),
|
|
17449
|
+
destinationMint: (0, import_common40.toWeb3Pk)(args.destinationMint),
|
|
17450
|
+
vaultSourceAta: (0, import_common40.toWeb3Pk)(args.vaultSourceAta),
|
|
17451
|
+
vaultDestinationAta: (0, import_common40.toWeb3Pk)(args.vaultDestinationAta),
|
|
17452
|
+
sourceTokenProgram: (0, import_common40.toWeb3Pk)(args.sourceTokenProgram),
|
|
17453
|
+
destinationTokenProgram: (0, import_common40.toWeb3Pk)(args.destinationTokenProgram),
|
|
17454
|
+
destinationOracleAccount: args.destinationOracleAccount ? (0, import_common40.toWeb3Pk)(args.destinationOracleAccount) : null,
|
|
17455
|
+
vaultOracle: (0, import_common40.toWeb3Pk)(args.vaultOracle),
|
|
17456
|
+
vaultTrancheState: args.vaultTrancheState ? (0, import_common40.toWeb3Pk)(args.vaultTrancheState) : null
|
|
17457
|
+
}).remainingAccounts(args.accounts.map(toWeb3AccountMeta2)).instruction().then(import_common40.toKitInstruction);
|
|
17140
17458
|
}
|
|
17141
17459
|
async deriveIxArgs(txArgs) {
|
|
17142
17460
|
const sourceTokenProgram = txArgs.sourceTokenProgram ?? TOKEN_PROGRAM_ID;
|
|
@@ -17157,13 +17475,13 @@ var JupiterSwapBuilder = class extends VaultBuilderBase {
|
|
|
17157
17475
|
accounts: txArgs.accounts,
|
|
17158
17476
|
sourceTokenProgram,
|
|
17159
17477
|
destinationTokenProgram,
|
|
17160
|
-
vaultSourceAta: (0,
|
|
17478
|
+
vaultSourceAta: (0, import_common40.getAtaAddress)(
|
|
17161
17479
|
txArgs.sourceMint,
|
|
17162
17480
|
txArgs.vault,
|
|
17163
17481
|
sourceTokenProgram,
|
|
17164
17482
|
true
|
|
17165
17483
|
),
|
|
17166
|
-
vaultDestinationAta: (0,
|
|
17484
|
+
vaultDestinationAta: (0, import_common40.getAtaAddress)(
|
|
17167
17485
|
txArgs.destinationMint,
|
|
17168
17486
|
txArgs.vault,
|
|
17169
17487
|
destinationTokenProgram,
|
|
@@ -17172,24 +17490,24 @@ var JupiterSwapBuilder = class extends VaultBuilderBase {
|
|
|
17172
17490
|
};
|
|
17173
17491
|
}
|
|
17174
17492
|
async buildPreambleInstructions(args) {
|
|
17175
|
-
const payer = (0,
|
|
17176
|
-
const createSourceAta = (0,
|
|
17493
|
+
const payer = (0, import_common40.toWeb3Pk)(args.hwManager);
|
|
17494
|
+
const createSourceAta = (0, import_spl_token17.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17177
17495
|
payer,
|
|
17178
|
-
(0,
|
|
17179
|
-
(0,
|
|
17180
|
-
(0,
|
|
17181
|
-
(0,
|
|
17182
|
-
|
|
17496
|
+
(0, import_common40.toWeb3Pk)(args.vaultSourceAta),
|
|
17497
|
+
(0, import_common40.toWeb3Pk)(args.vault),
|
|
17498
|
+
(0, import_common40.toWeb3Pk)(args.sourceMint),
|
|
17499
|
+
(0, import_common40.toWeb3Pk)(args.sourceTokenProgram),
|
|
17500
|
+
import_spl_token17.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
17183
17501
|
);
|
|
17184
|
-
const createDestinationAta = (0,
|
|
17502
|
+
const createDestinationAta = (0, import_spl_token17.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17185
17503
|
payer,
|
|
17186
|
-
(0,
|
|
17187
|
-
(0,
|
|
17188
|
-
(0,
|
|
17189
|
-
(0,
|
|
17190
|
-
|
|
17504
|
+
(0, import_common40.toWeb3Pk)(args.vaultDestinationAta),
|
|
17505
|
+
(0, import_common40.toWeb3Pk)(args.vault),
|
|
17506
|
+
(0, import_common40.toWeb3Pk)(args.destinationMint),
|
|
17507
|
+
(0, import_common40.toWeb3Pk)(args.destinationTokenProgram),
|
|
17508
|
+
import_spl_token17.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
17191
17509
|
);
|
|
17192
|
-
return [createSourceAta, createDestinationAta].map(
|
|
17510
|
+
return [createSourceAta, createDestinationAta].map(import_common40.toKitInstruction);
|
|
17193
17511
|
}
|
|
17194
17512
|
async buildLookupTables(_args, txArgs) {
|
|
17195
17513
|
return txArgs.lookupTables;
|
|
@@ -17222,27 +17540,27 @@ var JupiterSwapBuilder = class extends VaultBuilderBase {
|
|
|
17222
17540
|
};
|
|
17223
17541
|
|
|
17224
17542
|
// src/client/builders/requestJuniorTrancheWithdraw.ts
|
|
17225
|
-
var
|
|
17226
|
-
var
|
|
17227
|
-
var
|
|
17228
|
-
var
|
|
17543
|
+
var import_core18 = require("@anchor-lang/core");
|
|
17544
|
+
var import_spl_token18 = require("@solana/spl-token");
|
|
17545
|
+
var import_web321 = require("@solana/web3.js");
|
|
17546
|
+
var import_common41 = __toESM(require_dist());
|
|
17229
17547
|
var RequestJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
17230
17548
|
async getIx(args) {
|
|
17231
17549
|
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(
|
|
17550
|
+
user: (0, import_common41.toWeb3Pk)(args.user),
|
|
17551
|
+
payer: (0, import_common41.toWeb3Pk)(args.payer),
|
|
17552
|
+
vault: (0, import_common41.toWeb3Pk)(args.vault),
|
|
17553
|
+
vaultOracle: (0, import_common41.toWeb3Pk)(args.vaultOracle),
|
|
17554
|
+
vaultTrancheState: (0, import_common41.toWeb3Pk)(args.vaultTrancheState),
|
|
17555
|
+
withdrawalQueue: (0, import_common41.toWeb3Pk)(args.withdrawalQueue),
|
|
17556
|
+
outputMint: (0, import_common41.toWeb3Pk)(args.outputMint),
|
|
17557
|
+
inputMint: (0, import_common41.toWeb3Pk)(args.inputMint),
|
|
17558
|
+
userInputAta: (0, import_common41.toWeb3Pk)(args.userInputAta),
|
|
17559
|
+
queueInputAta: (0, import_common41.toWeb3Pk)(args.queueInputAta),
|
|
17560
|
+
shareTokenProgram: (0, import_common41.toWeb3Pk)(args.shareTokenProgram),
|
|
17561
|
+
associatedTokenProgram: import_spl_token18.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
17562
|
+
systemProgram: import_web321.SystemProgram.programId
|
|
17563
|
+
}).instruction().then(import_common41.toKitInstruction);
|
|
17246
17564
|
}
|
|
17247
17565
|
async deriveIxArgs(txArgs) {
|
|
17248
17566
|
const payer = txArgs.payer ?? txArgs.user;
|
|
@@ -17276,10 +17594,10 @@ var RequestJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
17276
17594
|
outputMint: txArgs.assetMint,
|
|
17277
17595
|
inputMint: juniorShareMint,
|
|
17278
17596
|
queueId: txArgs.queueId,
|
|
17279
|
-
shareAmount: new
|
|
17597
|
+
shareAmount: new import_core18.BN(txArgs.shareAmount.toString()),
|
|
17280
17598
|
shareTokenProgram,
|
|
17281
|
-
userInputAta: txArgs.userInputAta ?? (0,
|
|
17282
|
-
queueInputAta: (0,
|
|
17599
|
+
userInputAta: txArgs.userInputAta ?? (0, import_common41.getAtaAddress)(juniorShareMint, txArgs.user, shareTokenProgram),
|
|
17600
|
+
queueInputAta: (0, import_common41.getAtaAddress)(
|
|
17283
17601
|
juniorShareMint,
|
|
17284
17602
|
queuePda,
|
|
17285
17603
|
shareTokenProgram,
|
|
@@ -17301,17 +17619,17 @@ var RequestJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
17301
17619
|
};
|
|
17302
17620
|
|
|
17303
17621
|
// src/client/builders/vaultReallocation.ts
|
|
17304
|
-
var
|
|
17305
|
-
var
|
|
17306
|
-
var
|
|
17307
|
-
var
|
|
17622
|
+
var import_core19 = require("@anchor-lang/core");
|
|
17623
|
+
var import_spl_token19 = require("@solana/spl-token");
|
|
17624
|
+
var import_web322 = require("@solana/web3.js");
|
|
17625
|
+
var import_common42 = __toESM(require_dist());
|
|
17308
17626
|
var DEFAULT_PYTH_PRICE_MAX_AGE_SECS2 = 90n;
|
|
17309
17627
|
function toAssetPriceOracleConfig2(args) {
|
|
17310
17628
|
return {
|
|
17311
17629
|
priceOracleType: args?.priceOracleType ?? { none: {} },
|
|
17312
|
-
initialPrice: new
|
|
17630
|
+
initialPrice: new import_core19.BN((args?.initialPrice ?? 0n).toString()),
|
|
17313
17631
|
priceOracleAccount: args?.priceOracleAccount ?? DEFAULT_PRICE_ORACLE_ACCOUNT,
|
|
17314
|
-
pythMaxAgeSecs: new
|
|
17632
|
+
pythMaxAgeSecs: new import_core19.BN(
|
|
17315
17633
|
(args?.pythMaxAgeSecs ?? DEFAULT_PYTH_PRICE_MAX_AGE_SECS2).toString()
|
|
17316
17634
|
)
|
|
17317
17635
|
};
|
|
@@ -17319,7 +17637,7 @@ function toAssetPriceOracleConfig2(args) {
|
|
|
17319
17637
|
function toAnchorAssetPriceOracleConfig2(config) {
|
|
17320
17638
|
return {
|
|
17321
17639
|
...config,
|
|
17322
|
-
priceOracleAccount: (0,
|
|
17640
|
+
priceOracleAccount: (0, import_common42.toWeb3Pk)(config.priceOracleAccount)
|
|
17323
17641
|
};
|
|
17324
17642
|
}
|
|
17325
17643
|
var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
@@ -17328,35 +17646,35 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
17328
17646
|
amount: args.amount,
|
|
17329
17647
|
assetPriceOracle: toAnchorAssetPriceOracleConfig2(args.assetPriceOracle)
|
|
17330
17648
|
}).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,
|
|
17649
|
+
manager: (0, import_common42.toWeb3Pk)(args.manager),
|
|
17650
|
+
allocationVault: (0, import_common42.toWeb3Pk)(args.allocationVault),
|
|
17651
|
+
sourceVault: args.sourceVault ? (0, import_common42.toWeb3Pk)(args.sourceVault) : null,
|
|
17652
|
+
sourceVaultOracle: args.sourceVaultOracle ? (0, import_common42.toWeb3Pk)(args.sourceVaultOracle) : null,
|
|
17653
|
+
destinationVault: (0, import_common42.toWeb3Pk)(args.destinationVault),
|
|
17654
|
+
destinationVaultOracle: (0, import_common42.toWeb3Pk)(args.destinationVaultOracle),
|
|
17655
|
+
mint: (0, import_common42.toWeb3Pk)(args.mint),
|
|
17656
|
+
sourceShareMint: args.sourceShareMint ? (0, import_common42.toWeb3Pk)(args.sourceShareMint) : null,
|
|
17657
|
+
destinationShareMint: (0, import_common42.toWeb3Pk)(args.destinationShareMint),
|
|
17658
|
+
allocationMintAta: (0, import_common42.toWeb3Pk)(args.allocationMintAta),
|
|
17659
|
+
sourceVaultMintAta: args.sourceVaultMintAta ? (0, import_common42.toWeb3Pk)(args.sourceVaultMintAta) : null,
|
|
17660
|
+
destinationVaultMintAta: (0, import_common42.toWeb3Pk)(args.destinationVaultMintAta),
|
|
17661
|
+
destinationFeeVault: (0, import_common42.toWeb3Pk)(args.destinationFeeVault),
|
|
17662
|
+
destinationFeeVaultMintAta: (0, import_common42.toWeb3Pk)(args.destinationFeeVaultMintAta),
|
|
17663
|
+
allocationSourceShareAta: args.allocationSourceShareAta ? (0, import_common42.toWeb3Pk)(args.allocationSourceShareAta) : null,
|
|
17664
|
+
allocationDestinationShareAta: (0, import_common42.toWeb3Pk)(
|
|
17347
17665
|
args.allocationDestinationShareAta
|
|
17348
17666
|
),
|
|
17349
|
-
sourceVaultTrancheState: args.sourceVaultTrancheState ? (0,
|
|
17350
|
-
destinationVaultTrancheState: args.destinationVaultTrancheState ? (0,
|
|
17351
|
-
assetOracleAccount: args.assetOracleAccount ? (0,
|
|
17352
|
-
assetTokenProgram: (0,
|
|
17353
|
-
sourceShareTokenProgram: (0,
|
|
17354
|
-
destinationShareTokenProgram: (0,
|
|
17667
|
+
sourceVaultTrancheState: args.sourceVaultTrancheState ? (0, import_common42.toWeb3Pk)(args.sourceVaultTrancheState) : null,
|
|
17668
|
+
destinationVaultTrancheState: args.destinationVaultTrancheState ? (0, import_common42.toWeb3Pk)(args.destinationVaultTrancheState) : null,
|
|
17669
|
+
assetOracleAccount: args.assetOracleAccount ? (0, import_common42.toWeb3Pk)(args.assetOracleAccount) : null,
|
|
17670
|
+
assetTokenProgram: (0, import_common42.toWeb3Pk)(args.assetTokenProgram),
|
|
17671
|
+
sourceShareTokenProgram: (0, import_common42.toWeb3Pk)(args.sourceShareTokenProgram),
|
|
17672
|
+
destinationShareTokenProgram: (0, import_common42.toWeb3Pk)(
|
|
17355
17673
|
args.destinationShareTokenProgram
|
|
17356
17674
|
),
|
|
17357
|
-
associatedTokenProgram:
|
|
17358
|
-
systemProgram:
|
|
17359
|
-
}).instruction().then(
|
|
17675
|
+
associatedTokenProgram: import_spl_token19.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
17676
|
+
systemProgram: import_web322.SystemProgram.programId
|
|
17677
|
+
}).instruction().then(import_common42.toKitInstruction);
|
|
17360
17678
|
}
|
|
17361
17679
|
async deriveIxArgs(txArgs) {
|
|
17362
17680
|
const assetTokenProgram = txArgs.assetTokenProgram ?? TOKEN_PROGRAM_ID;
|
|
@@ -17381,7 +17699,7 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
17381
17699
|
mint: txArgs.mint,
|
|
17382
17700
|
sourceShareMint,
|
|
17383
17701
|
destinationShareMint: txArgs.destinationShareMint,
|
|
17384
|
-
amount: new
|
|
17702
|
+
amount: new import_core19.BN(txArgs.amount.toString()),
|
|
17385
17703
|
assetPriceOracle: toAssetPriceOracleConfig2(txArgs.assetPriceOracle),
|
|
17386
17704
|
sourceVaultTrancheState: txArgs.sourceVaultTrancheState ?? null,
|
|
17387
17705
|
destinationVaultTrancheState: txArgs.destinationVaultTrancheState ?? null,
|
|
@@ -17389,33 +17707,33 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
17389
17707
|
assetTokenProgram,
|
|
17390
17708
|
sourceShareTokenProgram,
|
|
17391
17709
|
destinationShareTokenProgram,
|
|
17392
|
-
allocationMintAta: (0,
|
|
17710
|
+
allocationMintAta: (0, import_common42.getAtaAddress)(
|
|
17393
17711
|
txArgs.mint,
|
|
17394
17712
|
txArgs.allocationVault,
|
|
17395
17713
|
assetTokenProgram,
|
|
17396
17714
|
true
|
|
17397
17715
|
),
|
|
17398
|
-
sourceVaultMintAta: sourceVault ? (0,
|
|
17399
|
-
destinationVaultMintAta: (0,
|
|
17716
|
+
sourceVaultMintAta: sourceVault ? (0, import_common42.getAtaAddress)(txArgs.mint, sourceVault, assetTokenProgram, true) : null,
|
|
17717
|
+
destinationVaultMintAta: (0, import_common42.getAtaAddress)(
|
|
17400
17718
|
txArgs.mint,
|
|
17401
17719
|
txArgs.destinationVault,
|
|
17402
17720
|
assetTokenProgram,
|
|
17403
17721
|
true
|
|
17404
17722
|
),
|
|
17405
17723
|
destinationFeeVault,
|
|
17406
|
-
destinationFeeVaultMintAta: (0,
|
|
17724
|
+
destinationFeeVaultMintAta: (0, import_common42.getAtaAddress)(
|
|
17407
17725
|
txArgs.mint,
|
|
17408
17726
|
destinationFeeVault,
|
|
17409
17727
|
assetTokenProgram,
|
|
17410
17728
|
true
|
|
17411
17729
|
),
|
|
17412
|
-
allocationSourceShareAta: sourceShareMint && sourceVault ? (0,
|
|
17730
|
+
allocationSourceShareAta: sourceShareMint && sourceVault ? (0, import_common42.getAtaAddress)(
|
|
17413
17731
|
sourceShareMint,
|
|
17414
17732
|
txArgs.allocationVault,
|
|
17415
17733
|
sourceShareTokenProgram,
|
|
17416
17734
|
true
|
|
17417
17735
|
) : null,
|
|
17418
|
-
allocationDestinationShareAta: (0,
|
|
17736
|
+
allocationDestinationShareAta: (0, import_common42.getAtaAddress)(
|
|
17419
17737
|
txArgs.destinationShareMint,
|
|
17420
17738
|
txArgs.allocationVault,
|
|
17421
17739
|
destinationShareTokenProgram,
|
|
@@ -17424,62 +17742,62 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
17424
17742
|
};
|
|
17425
17743
|
}
|
|
17426
17744
|
async buildPreambleInstructions(args) {
|
|
17427
|
-
const payer = (0,
|
|
17745
|
+
const payer = (0, import_common42.toWeb3Pk)(args.manager);
|
|
17428
17746
|
const instructions2 = [
|
|
17429
|
-
(0,
|
|
17747
|
+
(0, import_spl_token19.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17430
17748
|
payer,
|
|
17431
|
-
(0,
|
|
17432
|
-
(0,
|
|
17433
|
-
(0,
|
|
17434
|
-
(0,
|
|
17435
|
-
|
|
17749
|
+
(0, import_common42.toWeb3Pk)(args.allocationMintAta),
|
|
17750
|
+
(0, import_common42.toWeb3Pk)(args.allocationVault),
|
|
17751
|
+
(0, import_common42.toWeb3Pk)(args.mint),
|
|
17752
|
+
(0, import_common42.toWeb3Pk)(args.assetTokenProgram),
|
|
17753
|
+
import_spl_token19.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
17436
17754
|
),
|
|
17437
|
-
(0,
|
|
17755
|
+
(0, import_spl_token19.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17438
17756
|
payer,
|
|
17439
|
-
(0,
|
|
17440
|
-
(0,
|
|
17441
|
-
(0,
|
|
17442
|
-
(0,
|
|
17443
|
-
|
|
17757
|
+
(0, import_common42.toWeb3Pk)(args.destinationVaultMintAta),
|
|
17758
|
+
(0, import_common42.toWeb3Pk)(args.destinationVault),
|
|
17759
|
+
(0, import_common42.toWeb3Pk)(args.mint),
|
|
17760
|
+
(0, import_common42.toWeb3Pk)(args.assetTokenProgram),
|
|
17761
|
+
import_spl_token19.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
17444
17762
|
),
|
|
17445
|
-
(0,
|
|
17763
|
+
(0, import_spl_token19.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17446
17764
|
payer,
|
|
17447
|
-
(0,
|
|
17448
|
-
(0,
|
|
17449
|
-
(0,
|
|
17450
|
-
(0,
|
|
17451
|
-
|
|
17765
|
+
(0, import_common42.toWeb3Pk)(args.destinationFeeVaultMintAta),
|
|
17766
|
+
(0, import_common42.toWeb3Pk)(args.destinationFeeVault),
|
|
17767
|
+
(0, import_common42.toWeb3Pk)(args.mint),
|
|
17768
|
+
(0, import_common42.toWeb3Pk)(args.assetTokenProgram),
|
|
17769
|
+
import_spl_token19.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
17452
17770
|
),
|
|
17453
|
-
(0,
|
|
17771
|
+
(0, import_spl_token19.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17454
17772
|
payer,
|
|
17455
|
-
(0,
|
|
17456
|
-
(0,
|
|
17457
|
-
(0,
|
|
17458
|
-
(0,
|
|
17459
|
-
|
|
17773
|
+
(0, import_common42.toWeb3Pk)(args.allocationDestinationShareAta),
|
|
17774
|
+
(0, import_common42.toWeb3Pk)(args.allocationVault),
|
|
17775
|
+
(0, import_common42.toWeb3Pk)(args.destinationShareMint),
|
|
17776
|
+
(0, import_common42.toWeb3Pk)(args.destinationShareTokenProgram),
|
|
17777
|
+
import_spl_token19.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
17460
17778
|
)
|
|
17461
17779
|
];
|
|
17462
17780
|
if (args.sourceVault && args.sourceShareMint && args.sourceVaultMintAta && args.allocationSourceShareAta) {
|
|
17463
17781
|
instructions2.push(
|
|
17464
|
-
(0,
|
|
17782
|
+
(0, import_spl_token19.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17465
17783
|
payer,
|
|
17466
|
-
(0,
|
|
17467
|
-
(0,
|
|
17468
|
-
(0,
|
|
17469
|
-
(0,
|
|
17470
|
-
|
|
17784
|
+
(0, import_common42.toWeb3Pk)(args.sourceVaultMintAta),
|
|
17785
|
+
(0, import_common42.toWeb3Pk)(args.sourceVault),
|
|
17786
|
+
(0, import_common42.toWeb3Pk)(args.mint),
|
|
17787
|
+
(0, import_common42.toWeb3Pk)(args.assetTokenProgram),
|
|
17788
|
+
import_spl_token19.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
17471
17789
|
),
|
|
17472
|
-
(0,
|
|
17790
|
+
(0, import_spl_token19.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17473
17791
|
payer,
|
|
17474
|
-
(0,
|
|
17475
|
-
(0,
|
|
17476
|
-
(0,
|
|
17477
|
-
(0,
|
|
17478
|
-
|
|
17792
|
+
(0, import_common42.toWeb3Pk)(args.allocationSourceShareAta),
|
|
17793
|
+
(0, import_common42.toWeb3Pk)(args.allocationVault),
|
|
17794
|
+
(0, import_common42.toWeb3Pk)(args.sourceShareMint),
|
|
17795
|
+
(0, import_common42.toWeb3Pk)(args.sourceShareTokenProgram),
|
|
17796
|
+
import_spl_token19.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
17479
17797
|
)
|
|
17480
17798
|
);
|
|
17481
17799
|
}
|
|
17482
|
-
return instructions2.map(
|
|
17800
|
+
return instructions2.map(import_common42.toKitInstruction);
|
|
17483
17801
|
}
|
|
17484
17802
|
async buildPlanExtras(args) {
|
|
17485
17803
|
return {
|
|
@@ -17517,6 +17835,7 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
17517
17835
|
// src/client/transaction.ts
|
|
17518
17836
|
var TransactionClient = class {
|
|
17519
17837
|
constructor(context) {
|
|
17838
|
+
this.depositCuratorFees = new DepositCuratorFeesBuilder(context);
|
|
17520
17839
|
this.createIncentiveV3 = new CreateIncentiveV3Builder(context);
|
|
17521
17840
|
this.addIncentiveRecipientV3 = new AddIncentiveRecipientV3Builder(context);
|
|
17522
17841
|
this.setIncentiveLimitsV3 = new SetIncentiveLimitsV3Builder(context);
|
|
@@ -17577,7 +17896,7 @@ var VaultClient = class {
|
|
|
17577
17896
|
this.provider = provider;
|
|
17578
17897
|
this.skipSimulation = options.skipSimulation ?? false;
|
|
17579
17898
|
const idl = { ...IDL, address: programId };
|
|
17580
|
-
this.program = new
|
|
17899
|
+
this.program = new import_core20.Program(idl, provider);
|
|
17581
17900
|
this.pda = new PdaClient((0, import_kit9.address)(this.program.programId.toBase58()));
|
|
17582
17901
|
const rpc = createRpcFromConnection(provider.connection);
|
|
17583
17902
|
this.account = new AccountClient(this.program, this.pda, rpc);
|
|
@@ -17599,8 +17918,8 @@ var VaultClient = class {
|
|
|
17599
17918
|
*/
|
|
17600
17919
|
async sendTransaction(payer, plan, extraSigners = []) {
|
|
17601
17920
|
const { blockhash, lastValidBlockHeight } = await this.provider.connection.getLatestBlockhash("confirmed");
|
|
17602
|
-
const tx = new
|
|
17603
|
-
...plan.instructions.map(
|
|
17921
|
+
const tx = new import_web323.Transaction().add(
|
|
17922
|
+
...plan.instructions.map(import_common43.fromKitInstruction)
|
|
17604
17923
|
);
|
|
17605
17924
|
tx.feePayer = payer.publicKey;
|
|
17606
17925
|
tx.recentBlockhash = blockhash;
|
|
@@ -17634,13 +17953,13 @@ var VaultClient = class {
|
|
|
17634
17953
|
const { blockhash } = await this.provider.connection.getLatestBlockhash(
|
|
17635
17954
|
"confirmed"
|
|
17636
17955
|
);
|
|
17637
|
-
const lookupTableAccounts = plan.lookupTables?.length ? await (0,
|
|
17638
|
-
const message2 = new
|
|
17956
|
+
const lookupTableAccounts = plan.lookupTables?.length ? await (0, import_common43.fetchLookupTables)(this.provider.connection, plan.lookupTables) : [];
|
|
17957
|
+
const message2 = new import_web323.TransactionMessage({
|
|
17639
17958
|
payerKey: payer.publicKey,
|
|
17640
17959
|
recentBlockhash: blockhash,
|
|
17641
|
-
instructions: plan.instructions.map(
|
|
17960
|
+
instructions: plan.instructions.map(import_common43.fromKitInstruction)
|
|
17642
17961
|
}).compileToV0Message(lookupTableAccounts);
|
|
17643
|
-
const tx = new
|
|
17962
|
+
const tx = new import_web323.VersionedTransaction(message2);
|
|
17644
17963
|
const result = await this.provider.connection.simulateTransaction(tx, {
|
|
17645
17964
|
sigVerify: false,
|
|
17646
17965
|
commitment: "processed"
|
|
@@ -17714,7 +18033,7 @@ function resolveKeypairPath(keypairPath) {
|
|
|
17714
18033
|
}
|
|
17715
18034
|
function loadKeypair(keypairPath) {
|
|
17716
18035
|
const raw = import_fs.default.readFileSync(resolveKeypairPath(keypairPath), "utf-8");
|
|
17717
|
-
return
|
|
18036
|
+
return import_web324.Keypair.fromSecretKey(new Uint8Array(JSON.parse(raw)));
|
|
17718
18037
|
}
|
|
17719
18038
|
var ENV_AGNOSTIC_ROLES = /* @__PURE__ */ new Set(["fulfiller", "rebalancer"]);
|
|
17720
18039
|
function defaultKeypairPath(env, role = "vault") {
|
|
@@ -17725,8 +18044,8 @@ function defaultKeypairPath(env, role = "vault") {
|
|
|
17725
18044
|
}
|
|
17726
18045
|
function createVaultClient(env, opts = {}) {
|
|
17727
18046
|
const payer = opts.keypair ?? loadKeypair(opts.keypairPath ?? defaultKeypairPath(env, opts.role));
|
|
17728
|
-
const connection = new
|
|
17729
|
-
const provider = new
|
|
18047
|
+
const connection = new import_web324.Connection(opts.rpcUrl ?? getRpcUrl(env), "confirmed");
|
|
18048
|
+
const provider = new import_core21.AnchorProvider(connection, new import_core21.Wallet(payer), {
|
|
17730
18049
|
commitment: "confirmed"
|
|
17731
18050
|
});
|
|
17732
18051
|
const client = new VaultClient(
|
|
@@ -17739,11 +18058,11 @@ function createVaultClient(env, opts = {}) {
|
|
|
17739
18058
|
client,
|
|
17740
18059
|
provider,
|
|
17741
18060
|
payer,
|
|
17742
|
-
signer: (0,
|
|
18061
|
+
signer: (0, import_common44.fromWeb3Pk)(payer.publicKey)
|
|
17743
18062
|
};
|
|
17744
18063
|
}
|
|
17745
18064
|
function keypairAddress(keypairPath) {
|
|
17746
|
-
return (0,
|
|
18065
|
+
return (0, import_common44.fromWeb3Pk)(loadKeypair(keypairPath).publicKey);
|
|
17747
18066
|
}
|
|
17748
18067
|
|
|
17749
18068
|
// src/utils/math.ts
|
|
@@ -17757,16 +18076,16 @@ function fromUiAmount(amount, decimals) {
|
|
|
17757
18076
|
}
|
|
17758
18077
|
|
|
17759
18078
|
// src/utils/provider.ts
|
|
17760
|
-
var
|
|
18079
|
+
var import_core22 = require("@anchor-lang/core");
|
|
17761
18080
|
function makeProvider(connection, payer) {
|
|
17762
|
-
return new
|
|
18081
|
+
return new import_core22.AnchorProvider(connection, new import_core22.Wallet(payer), {
|
|
17763
18082
|
commitment: "confirmed"
|
|
17764
18083
|
});
|
|
17765
18084
|
}
|
|
17766
18085
|
|
|
17767
18086
|
// src/utils/squads.ts
|
|
17768
18087
|
var squads = __toESM(require("@sqds/multisig"));
|
|
17769
|
-
var
|
|
18088
|
+
var import_web325 = require("@solana/web3.js");
|
|
17770
18089
|
var SQUADS_SIMULATION_COMMITMENT = "processed";
|
|
17771
18090
|
var SquadsProposalExecutionSimulationError = class extends Error {
|
|
17772
18091
|
constructor(transactionError, logs, unitsConsumed) {
|
|
@@ -17790,8 +18109,8 @@ function validateVaultIndex(vaultIndex) {
|
|
|
17790
18109
|
}
|
|
17791
18110
|
function resolveSquadsWalletRoute(route) {
|
|
17792
18111
|
validateVaultIndex(route.vaultIndex);
|
|
17793
|
-
const wallet = new
|
|
17794
|
-
const multisigPda = new
|
|
18112
|
+
const wallet = new import_web325.PublicKey(route.wallet);
|
|
18113
|
+
const multisigPda = new import_web325.PublicKey(route.multisigPda);
|
|
17795
18114
|
const [vaultPda] = squads.getVaultPda({
|
|
17796
18115
|
multisigPda,
|
|
17797
18116
|
index: route.vaultIndex
|
|
@@ -17799,7 +18118,7 @@ function resolveSquadsWalletRoute(route) {
|
|
|
17799
18118
|
return { ...route, wallet, multisigPda, vaultPda };
|
|
17800
18119
|
}
|
|
17801
18120
|
function findSquadsWalletRoute(wallet, routes) {
|
|
17802
|
-
const walletKey = typeof wallet === "string" ? new
|
|
18121
|
+
const walletKey = typeof wallet === "string" ? new import_web325.PublicKey(wallet) : wallet;
|
|
17803
18122
|
const route = routes.find(
|
|
17804
18123
|
(candidate) => candidate.wallet === walletKey.toBase58()
|
|
17805
18124
|
);
|
|
@@ -17817,18 +18136,18 @@ function validateSquadsWalletRoutes(routes) {
|
|
|
17817
18136
|
}
|
|
17818
18137
|
}
|
|
17819
18138
|
function vaultAuthorityForWallet(wallet, routes) {
|
|
17820
|
-
const walletKey = typeof wallet === "string" ? new
|
|
18139
|
+
const walletKey = typeof wallet === "string" ? new import_web325.PublicKey(wallet) : wallet;
|
|
17821
18140
|
return findSquadsWalletRoute(walletKey, routes)?.vaultPda ?? walletKey;
|
|
17822
18141
|
}
|
|
17823
18142
|
async function simulateSquadsProposalExecution(args) {
|
|
17824
18143
|
const { connection, feePayer, instructions: instructions2 } = args;
|
|
17825
18144
|
const recentBlockhash = args.recentBlockhash ?? (await connection.getLatestBlockhash(SQUADS_SIMULATION_COMMITMENT)).blockhash;
|
|
17826
|
-
const message2 = new
|
|
18145
|
+
const message2 = new import_web325.TransactionMessage({
|
|
17827
18146
|
payerKey: feePayer,
|
|
17828
18147
|
recentBlockhash,
|
|
17829
18148
|
instructions: [...instructions2]
|
|
17830
18149
|
}).compileToV0Message(args.addressLookupTableAccounts);
|
|
17831
|
-
const transaction = new
|
|
18150
|
+
const transaction = new import_web325.VersionedTransaction(message2);
|
|
17832
18151
|
const { value } = await connection.simulateTransaction(transaction, {
|
|
17833
18152
|
sigVerify: false,
|
|
17834
18153
|
commitment: SQUADS_SIMULATION_COMMITMENT,
|
|
@@ -17853,7 +18172,7 @@ async function prepareVaultTransaction(args) {
|
|
|
17853
18172
|
throw new Error("Ephemeral signers require a Squads route");
|
|
17854
18173
|
return {
|
|
17855
18174
|
kind: "direct",
|
|
17856
|
-
transaction: new
|
|
18175
|
+
transaction: new import_web325.Transaction().add(...instructions2),
|
|
17857
18176
|
authority: proposer
|
|
17858
18177
|
};
|
|
17859
18178
|
}
|
|
@@ -17906,7 +18225,7 @@ async function prepareVaultTransaction(args) {
|
|
|
17906
18225
|
});
|
|
17907
18226
|
if (replacements.size) {
|
|
17908
18227
|
instructions2 = instructions2.map(
|
|
17909
|
-
(ix) => new
|
|
18228
|
+
(ix) => new import_web325.TransactionInstruction({
|
|
17910
18229
|
programId: ix.programId,
|
|
17911
18230
|
data: ix.data,
|
|
17912
18231
|
keys: ix.keys.map((meta) => ({
|
|
@@ -17926,7 +18245,7 @@ async function prepareVaultTransaction(args) {
|
|
|
17926
18245
|
addressLookupTableAccounts: args.addressLookupTableAccounts
|
|
17927
18246
|
});
|
|
17928
18247
|
}
|
|
17929
|
-
const transactionMessage = new
|
|
18248
|
+
const transactionMessage = new import_web325.TransactionMessage({
|
|
17930
18249
|
payerKey: route.vaultPda,
|
|
17931
18250
|
recentBlockhash: blockhash,
|
|
17932
18251
|
instructions: [...instructions2]
|
|
@@ -17956,7 +18275,7 @@ async function prepareVaultTransaction(args) {
|
|
|
17956
18275
|
});
|
|
17957
18276
|
return {
|
|
17958
18277
|
kind: "squads",
|
|
17959
|
-
transaction: new
|
|
18278
|
+
transaction: new import_web325.Transaction().add(
|
|
17960
18279
|
createVaultTransactionIx,
|
|
17961
18280
|
createProposalIx
|
|
17962
18281
|
),
|
|
@@ -17971,16 +18290,16 @@ async function prepareVaultTransaction(args) {
|
|
|
17971
18290
|
|
|
17972
18291
|
// src/utils/squadsBuffer.ts
|
|
17973
18292
|
var squads2 = __toESM(require("@sqds/multisig"));
|
|
17974
|
-
var
|
|
18293
|
+
var import_web326 = require("@solana/web3.js");
|
|
17975
18294
|
var PacketSize = 1232;
|
|
17976
18295
|
var BufferChunkSize = 700;
|
|
17977
18296
|
var MaxBufferSize = 4e3;
|
|
17978
18297
|
async function prepareSquadsProposalUpload(args) {
|
|
17979
18298
|
const { connection, proposer, prepared } = args;
|
|
17980
18299
|
const transaction = prepared.transaction;
|
|
17981
|
-
const sizeProbe = new
|
|
18300
|
+
const sizeProbe = new import_web326.Transaction({
|
|
17982
18301
|
feePayer: proposer,
|
|
17983
|
-
recentBlockhash:
|
|
18302
|
+
recentBlockhash: import_web326.PublicKey.default.toBase58()
|
|
17984
18303
|
}).add(...transaction.instructions);
|
|
17985
18304
|
let fits = false;
|
|
17986
18305
|
try {
|
|
@@ -18000,7 +18319,7 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
18000
18319
|
let bufferPda;
|
|
18001
18320
|
let bufferIndex = 0;
|
|
18002
18321
|
for (; bufferIndex <= 255; bufferIndex++) {
|
|
18003
|
-
const [candidate] =
|
|
18322
|
+
const [candidate] = import_web326.PublicKey.findProgramAddressSync(
|
|
18004
18323
|
[
|
|
18005
18324
|
Buffer.from("multisig"),
|
|
18006
18325
|
prepared.multisigPda.toBuffer(),
|
|
@@ -18028,7 +18347,7 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
18028
18347
|
creator: proposer
|
|
18029
18348
|
};
|
|
18030
18349
|
const setupTransactions = [
|
|
18031
|
-
new
|
|
18350
|
+
new import_web326.Transaction().add(
|
|
18032
18351
|
squads2.generated.createTransactionBufferCreateInstruction(
|
|
18033
18352
|
{
|
|
18034
18353
|
...accounts2,
|
|
@@ -18048,7 +18367,7 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
18048
18367
|
];
|
|
18049
18368
|
for (let offset = BufferChunkSize; offset < bytes.length; offset += BufferChunkSize) {
|
|
18050
18369
|
setupTransactions.push(
|
|
18051
|
-
new
|
|
18370
|
+
new import_web326.Transaction().add(
|
|
18052
18371
|
squads2.generated.createTransactionBufferExtendInstruction(accounts2, {
|
|
18053
18372
|
args: { buffer: bytes.slice(offset, offset + BufferChunkSize) }
|
|
18054
18373
|
})
|
|
@@ -18061,7 +18380,7 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
18061
18380
|
vaultTransactionCreateItemTransaction: prepared.vaultTransactionPda,
|
|
18062
18381
|
vaultTransactionCreateItemCreator: proposer,
|
|
18063
18382
|
vaultTransactionCreateItemRentPayer: proposer,
|
|
18064
|
-
vaultTransactionCreateItemSystemProgram:
|
|
18383
|
+
vaultTransactionCreateItemSystemProgram: import_web326.SystemProgram.programId,
|
|
18065
18384
|
transactionBuffer: bufferPda,
|
|
18066
18385
|
creator: proposer
|
|
18067
18386
|
},
|
|
@@ -18073,7 +18392,7 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
18073
18392
|
).isWritable = true;
|
|
18074
18393
|
return {
|
|
18075
18394
|
setupTransactions,
|
|
18076
|
-
proposalTransaction: new
|
|
18395
|
+
proposalTransaction: new import_web326.Transaction().add(
|
|
18077
18396
|
finalize,
|
|
18078
18397
|
...transaction.instructions.slice(1)
|
|
18079
18398
|
),
|
|
@@ -18083,21 +18402,21 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
18083
18402
|
}
|
|
18084
18403
|
|
|
18085
18404
|
// 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,
|
|
18405
|
+
var import_spl_token20 = require("@solana/spl-token");
|
|
18406
|
+
var import_web327 = require("@solana/web3.js");
|
|
18407
|
+
var import_common45 = __toESM(require_dist());
|
|
18408
|
+
async function createTokenMintIxs(connection, payer, authority, decimals, tokenProgram = import_spl_token20.TOKEN_2022_PROGRAM_ID) {
|
|
18409
|
+
const mint = import_web327.Keypair.generate();
|
|
18410
|
+
const lamports = await (0, import_spl_token20.getMinimumBalanceForRentExemptMint)(connection);
|
|
18092
18411
|
const ixs = [
|
|
18093
|
-
|
|
18412
|
+
import_web327.SystemProgram.createAccount({
|
|
18094
18413
|
fromPubkey: payer,
|
|
18095
18414
|
newAccountPubkey: mint.publicKey,
|
|
18096
|
-
space:
|
|
18415
|
+
space: import_spl_token20.MINT_SIZE,
|
|
18097
18416
|
lamports,
|
|
18098
18417
|
programId: tokenProgram
|
|
18099
18418
|
}),
|
|
18100
|
-
(0,
|
|
18419
|
+
(0, import_spl_token20.createInitializeMint2Instruction)(
|
|
18101
18420
|
mint.publicKey,
|
|
18102
18421
|
decimals,
|
|
18103
18422
|
authority,
|
|
@@ -18107,7 +18426,7 @@ async function createTokenMintIxs(connection, payer, authority, decimals, tokenP
|
|
|
18107
18426
|
];
|
|
18108
18427
|
return { mint, ixs };
|
|
18109
18428
|
}
|
|
18110
|
-
async function createTokenMint(connection, payer, decimals, tokenProgram =
|
|
18429
|
+
async function createTokenMint(connection, payer, decimals, tokenProgram = import_spl_token20.TOKEN_2022_PROGRAM_ID) {
|
|
18111
18430
|
const { mint, ixs } = await createTokenMintIxs(
|
|
18112
18431
|
connection,
|
|
18113
18432
|
payer.publicKey,
|
|
@@ -18116,7 +18435,7 @@ async function createTokenMint(connection, payer, decimals, tokenProgram = impor
|
|
|
18116
18435
|
tokenProgram
|
|
18117
18436
|
);
|
|
18118
18437
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
|
|
18119
|
-
const tx = new
|
|
18438
|
+
const tx = new import_web327.Transaction().add(...ixs);
|
|
18120
18439
|
tx.feePayer = payer.publicKey;
|
|
18121
18440
|
tx.recentBlockhash = blockhash;
|
|
18122
18441
|
tx.sign(payer, mint);
|
|
@@ -18129,24 +18448,24 @@ async function createTokenMint(connection, payer, decimals, tokenProgram = impor
|
|
|
18129
18448
|
);
|
|
18130
18449
|
return mint.publicKey;
|
|
18131
18450
|
}
|
|
18132
|
-
async function mintTokensTo(connection, payer, mint, destination, amount, tokenProgram =
|
|
18133
|
-
const tokenProgramPk = (0,
|
|
18134
|
-
const ata = (0,
|
|
18451
|
+
async function mintTokensTo(connection, payer, mint, destination, amount, tokenProgram = import_spl_token20.TOKEN_2022_PROGRAM_ID, allowOwnerOffCurve = true) {
|
|
18452
|
+
const tokenProgramPk = (0, import_common45.asWeb3PublicKey)(tokenProgram);
|
|
18453
|
+
const ata = (0, import_spl_token20.getAssociatedTokenAddressSync)(
|
|
18135
18454
|
mint,
|
|
18136
18455
|
destination,
|
|
18137
18456
|
allowOwnerOffCurve,
|
|
18138
18457
|
tokenProgramPk
|
|
18139
18458
|
);
|
|
18140
18459
|
const ixs = [
|
|
18141
|
-
(0,
|
|
18460
|
+
(0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
|
|
18142
18461
|
payer.publicKey,
|
|
18143
18462
|
ata,
|
|
18144
18463
|
destination,
|
|
18145
18464
|
mint,
|
|
18146
18465
|
tokenProgramPk,
|
|
18147
|
-
|
|
18466
|
+
import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
18148
18467
|
),
|
|
18149
|
-
(0,
|
|
18468
|
+
(0, import_spl_token20.createMintToInstruction)(
|
|
18150
18469
|
mint,
|
|
18151
18470
|
ata,
|
|
18152
18471
|
payer.publicKey,
|
|
@@ -18155,12 +18474,12 @@ async function mintTokensTo(connection, payer, mint, destination, amount, tokenP
|
|
|
18155
18474
|
tokenProgramPk
|
|
18156
18475
|
)
|
|
18157
18476
|
];
|
|
18158
|
-
const tx = new
|
|
18477
|
+
const tx = new import_web327.Transaction().add(...ixs);
|
|
18159
18478
|
await connection.sendTransaction(tx, [payer]);
|
|
18160
18479
|
}
|
|
18161
18480
|
|
|
18162
18481
|
// src/utils/yieldApi.ts
|
|
18163
|
-
var
|
|
18482
|
+
var import_core23 = require("@anchor-lang/core");
|
|
18164
18483
|
var YIELD_API_BASE = process.env.YIELD_API_BASE ?? "https://yield-tracker.perena.org";
|
|
18165
18484
|
async function yieldApiReq(endpoint, reqType, bodyData, options) {
|
|
18166
18485
|
const headers = {
|
|
@@ -18486,7 +18805,7 @@ async function getTrackedValue(accountName) {
|
|
|
18486
18805
|
return trackedValueFromResponse(await getYield(accountName));
|
|
18487
18806
|
}
|
|
18488
18807
|
async function getTotalYield(accountNames, start, end) {
|
|
18489
|
-
let totalYield = new
|
|
18808
|
+
let totalYield = new import_core23.BN(0);
|
|
18490
18809
|
for (const accountName of accountNames) {
|
|
18491
18810
|
const res = await getYield(accountName, start, end);
|
|
18492
18811
|
if (isNavAccountValue(res)) {
|
|
@@ -18495,7 +18814,7 @@ async function getTotalYield(accountNames, start, end) {
|
|
|
18495
18814
|
);
|
|
18496
18815
|
}
|
|
18497
18816
|
console.log(res);
|
|
18498
|
-
totalYield = totalYield.add(new
|
|
18817
|
+
totalYield = totalYield.add(new import_core23.BN(res.total_yield));
|
|
18499
18818
|
}
|
|
18500
18819
|
return totalYield;
|
|
18501
18820
|
}
|
|
@@ -18512,7 +18831,7 @@ async function getTotalOutstandingYield(accountNames, start, end) {
|
|
|
18512
18831
|
}
|
|
18513
18832
|
return total;
|
|
18514
18833
|
}
|
|
18515
|
-
async function getTotalTrackedValue(accountNames, start, end) {
|
|
18834
|
+
async function getTotalTrackedValue(accountNames, start, end, onAccountValue) {
|
|
18516
18835
|
let totalValue = 0;
|
|
18517
18836
|
let principal = 0;
|
|
18518
18837
|
let outstandingYield = 0;
|
|
@@ -18522,12 +18841,13 @@ async function getTotalTrackedValue(accountNames, start, end) {
|
|
|
18522
18841
|
totalValue += tracked.totalValue;
|
|
18523
18842
|
principal += tracked.principal;
|
|
18524
18843
|
outstandingYield += tracked.outstandingYield;
|
|
18844
|
+
onAccountValue?.(accountName, tracked);
|
|
18525
18845
|
}
|
|
18526
18846
|
return { totalValue, principal, outstandingYield };
|
|
18527
18847
|
}
|
|
18528
18848
|
|
|
18529
18849
|
// src/services/withdrawalQueueService.ts
|
|
18530
|
-
var
|
|
18850
|
+
var import_common46 = __toESM(require_dist());
|
|
18531
18851
|
function bnToBigInt(value) {
|
|
18532
18852
|
return BigInt(value.toString());
|
|
18533
18853
|
}
|
|
@@ -18548,7 +18868,7 @@ var WithdrawalQueueService = class {
|
|
|
18548
18868
|
const program = this.client.program.account;
|
|
18549
18869
|
const accounts2 = await program.vaultWithdrawalQueue.all();
|
|
18550
18870
|
return accounts2.map(
|
|
18551
|
-
(entry) => this.toSnapshot((0,
|
|
18871
|
+
(entry) => this.toSnapshot((0, import_common46.fromWeb3Pk)(entry.publicKey), entry.account)
|
|
18552
18872
|
);
|
|
18553
18873
|
}
|
|
18554
18874
|
/** Withdrawal queues for a single vault. */
|
|
@@ -18589,7 +18909,7 @@ var WithdrawalQueueService = class {
|
|
|
18589
18909
|
async fulfill(signer, queue) {
|
|
18590
18910
|
const plan = await this.client.tx.fulfillJuniorTrancheWithdraw.getTx({
|
|
18591
18911
|
owner: queue.owner,
|
|
18592
|
-
signer: (0,
|
|
18912
|
+
signer: (0, import_common46.fromWeb3Pk)(signer.publicKey),
|
|
18593
18913
|
queuePayer: queue.payer,
|
|
18594
18914
|
vault: queue.vault,
|
|
18595
18915
|
withdrawalQueue: queue.pda,
|
|
@@ -18643,12 +18963,12 @@ var WithdrawalQueueService = class {
|
|
|
18643
18963
|
const a = account;
|
|
18644
18964
|
return {
|
|
18645
18965
|
pda,
|
|
18646
|
-
vault: (0,
|
|
18647
|
-
owner: (0,
|
|
18648
|
-
payer: (0,
|
|
18966
|
+
vault: (0, import_common46.fromWeb3Pk)(a.parties.vault),
|
|
18967
|
+
owner: (0, import_common46.fromWeb3Pk)(a.parties.owner),
|
|
18968
|
+
payer: (0, import_common46.fromWeb3Pk)(a.parties.payer),
|
|
18649
18969
|
queueId: a.header.queueId,
|
|
18650
|
-
inputMint: (0,
|
|
18651
|
-
outputMint: (0,
|
|
18970
|
+
inputMint: (0, import_common46.fromWeb3Pk)(a.mints.inputMint),
|
|
18971
|
+
outputMint: (0, import_common46.fromWeb3Pk)(a.mints.outputMint),
|
|
18652
18972
|
inputAmount: bnToBigInt(a.request.inputAmount),
|
|
18653
18973
|
requestTs: bnToNumber(a.request.requestTs),
|
|
18654
18974
|
expiryTs: bnToNumber(a.request.expiryTs)
|
|
@@ -18658,7 +18978,7 @@ var WithdrawalQueueService = class {
|
|
|
18658
18978
|
|
|
18659
18979
|
// src/services/oracleService.ts
|
|
18660
18980
|
var import_kit11 = require("@solana/kit");
|
|
18661
|
-
var
|
|
18981
|
+
var import_common47 = __toESM(require_dist());
|
|
18662
18982
|
var SYSTEM_PROGRAM2 = "11111111111111111111111111111111";
|
|
18663
18983
|
var DEFAULT_PRICE_STALENESS_THRESHOLD_SECS2 = 86400n;
|
|
18664
18984
|
var PRICE_ORACLE_TYPES_BY_INDEX2 = [
|
|
@@ -18722,7 +19042,7 @@ var OracleService = class {
|
|
|
18722
19042
|
*/
|
|
18723
19043
|
async updateAssetConsensusPrice(signer, args, log) {
|
|
18724
19044
|
const plan = await this.client.tx.updateConsensusOracle.getTx({
|
|
18725
|
-
signer: (0,
|
|
19045
|
+
signer: (0, import_common47.fromWeb3Pk)(signer.publicKey),
|
|
18726
19046
|
vault: args.vault,
|
|
18727
19047
|
updates: args.updates,
|
|
18728
19048
|
assetMint: args.assetMint,
|
|
@@ -18738,7 +19058,7 @@ var OracleService = class {
|
|
|
18738
19058
|
/** Settle the vault NAV from its current holdings (permissionless). */
|
|
18739
19059
|
async crankNav(cranker, args, log) {
|
|
18740
19060
|
const plan = await this.client.tx.crankNav.getTx({
|
|
18741
|
-
cranker: (0,
|
|
19061
|
+
cranker: (0, import_common47.fromWeb3Pk)(cranker.publicKey),
|
|
18742
19062
|
vault: args.vault,
|
|
18743
19063
|
vaultTrancheState: args.vaultTrancheState
|
|
18744
19064
|
});
|
|
@@ -18811,7 +19131,7 @@ var OracleService = class {
|
|
|
18811
19131
|
/** Re-price one live-oracle holding from its bound Pyth/nested-vault account. */
|
|
18812
19132
|
async refreshAssetPrice(updater, args, log) {
|
|
18813
19133
|
const plan = await this.client.tx.updateAssetPrice.getTx({
|
|
18814
|
-
updater: (0,
|
|
19134
|
+
updater: (0, import_common47.fromWeb3Pk)(updater.publicKey),
|
|
18815
19135
|
vault: args.vault,
|
|
18816
19136
|
mint: args.mint,
|
|
18817
19137
|
oracleAccount: args.oracleAccount,
|
|
@@ -18907,11 +19227,11 @@ function toBigInt2(value) {
|
|
|
18907
19227
|
}
|
|
18908
19228
|
|
|
18909
19229
|
// src/services/consensusOracle/utils/holdings.ts
|
|
18910
|
-
var
|
|
18911
|
-
var
|
|
19230
|
+
var import_web328 = require("@solana/web3.js");
|
|
19231
|
+
var import_common48 = __toESM(require_dist());
|
|
18912
19232
|
function selectReportableHoldings(holdings, excludedMints = /* @__PURE__ */ new Set()) {
|
|
18913
19233
|
return holdings.map((holding, holdingIndex) => ({ holding, holdingIndex })).filter(({ holding }) => {
|
|
18914
|
-
const mint = (0,
|
|
19234
|
+
const mint = (0, import_common48.fromWeb3Pk)(holding.mint);
|
|
18915
19235
|
return mint !== SYSTEM_PROGRAM && !excludedMints.has(mint.toString()) && REPORTABLE_ORACLE_VARIANTS.has(
|
|
18916
19236
|
variantName2(holding.priceOracleType).toLowerCase()
|
|
18917
19237
|
);
|
|
@@ -18946,7 +19266,7 @@ function parseExternalLiquidityRefs(vaultState) {
|
|
|
18946
19266
|
if (!data || data.length < 40) continue;
|
|
18947
19267
|
if (data[0] !== 1) continue;
|
|
18948
19268
|
const pubkeyBytes = new Uint8Array(data.slice(8, 40));
|
|
18949
|
-
const userAccount = new
|
|
19269
|
+
const userAccount = new import_web328.PublicKey(pubkeyBytes).toBase58();
|
|
18950
19270
|
refs.push({
|
|
18951
19271
|
kind: "marginfi",
|
|
18952
19272
|
mint: "",
|
|
@@ -19172,17 +19492,18 @@ function formatBpsAsPercent(bps) {
|
|
|
19172
19492
|
}
|
|
19173
19493
|
|
|
19174
19494
|
// src/services/consensusOracle/pipeline/dryRunSettlement.ts
|
|
19175
|
-
var
|
|
19176
|
-
var
|
|
19495
|
+
var import_web330 = require("@solana/web3.js");
|
|
19496
|
+
var import_common49 = __toESM(require_dist());
|
|
19177
19497
|
|
|
19178
19498
|
// src/services/consensusOracle/settlement/settlementSimulator.ts
|
|
19179
19499
|
var import_kit12 = require("@solana/kit");
|
|
19180
|
-
var
|
|
19500
|
+
var import_web329 = require("@solana/web3.js");
|
|
19181
19501
|
var DEFAULT_SHARE_PRICE = 1000000n;
|
|
19182
19502
|
var BPS_DENOMINATOR3 = 10000n;
|
|
19183
19503
|
var NAV_LOSS_TOLERANCE_BPS = 25n;
|
|
19184
19504
|
var SECONDS_PER_YEAR = 31536000n;
|
|
19185
19505
|
var MAX_APY_ANCHOR_WINDOW_SECS = 604800n;
|
|
19506
|
+
var MAX_APY_PREVIOUS_ANCHOR_AGE_SECS = 2n * MAX_APY_ANCHOR_WINDOW_SECS;
|
|
19186
19507
|
var DEFAULT_STALENESS_SECS = 86400n;
|
|
19187
19508
|
var CONSENSUS_MAX_DIFF_BPS = 8n;
|
|
19188
19509
|
var MIN_CONSENSUS_SIGNERS = 2;
|
|
@@ -19195,6 +19516,47 @@ var EXTERNAL_OFFSET = PRICE_OFFSET + MAX_HOLDINGS * 8;
|
|
|
19195
19516
|
var APY_SCALE = 1000000000000000000n;
|
|
19196
19517
|
var APY_LN_2 = 693147180559945309n;
|
|
19197
19518
|
var APY_SERIES_TERMS = 32;
|
|
19519
|
+
function publishedConsensusBlockers(args) {
|
|
19520
|
+
const oracle = decodeOracleData(args.oracleData, args.nowTs);
|
|
19521
|
+
const holdings = args.vault.holdings.map(decodeHolding);
|
|
19522
|
+
const consensus = applyConsensus(
|
|
19523
|
+
holdings.map((holding) => ({ ...holding })),
|
|
19524
|
+
oracle.entries,
|
|
19525
|
+
args.nowTs,
|
|
19526
|
+
oracle.stalenessThresholdSecs
|
|
19527
|
+
);
|
|
19528
|
+
const own = oracle.entries.find((entry) => entry.signer === args.signer);
|
|
19529
|
+
const blockers = [];
|
|
19530
|
+
for (const update of args.updates) {
|
|
19531
|
+
const holding = holdings[update.holdingIndex];
|
|
19532
|
+
if (holding?.cleared && update.externalAmount === 0n) continue;
|
|
19533
|
+
if (!holding || holding.mint !== update.mint) {
|
|
19534
|
+
blockers.push(
|
|
19535
|
+
`holding #${update.holdingIndex} changed after publication`
|
|
19536
|
+
);
|
|
19537
|
+
continue;
|
|
19538
|
+
}
|
|
19539
|
+
if (!own || !isFresh(own.lastUpdateTs, args.nowTs, oracle.stalenessThresholdSecs) || own.prices[update.holdingIndex] !== update.price || own.externalAmounts[update.holdingIndex] !== update.externalAmount) {
|
|
19540
|
+
blockers.push(
|
|
19541
|
+
`holding #${update.holdingIndex} submitted report is not current`
|
|
19542
|
+
);
|
|
19543
|
+
continue;
|
|
19544
|
+
}
|
|
19545
|
+
const result = consensus.find(
|
|
19546
|
+
(item) => item.holdingIndex === update.holdingIndex
|
|
19547
|
+
);
|
|
19548
|
+
if (result?.settledExternalAmount === void 0) {
|
|
19549
|
+
blockers.push(
|
|
19550
|
+
`holding #${update.holdingIndex}: ${result?.reason ?? "no consensus"}`
|
|
19551
|
+
);
|
|
19552
|
+
} else if (holding.externalAmount !== result.settledExternalAmount || result.settledPrice !== void 0 && holding.price !== result.settledPrice) {
|
|
19553
|
+
blockers.push(
|
|
19554
|
+
`holding #${update.holdingIndex} consensus has not been applied to holdings`
|
|
19555
|
+
);
|
|
19556
|
+
}
|
|
19557
|
+
}
|
|
19558
|
+
return blockers;
|
|
19559
|
+
}
|
|
19198
19560
|
function simulateConsensusOracleSettlement(args) {
|
|
19199
19561
|
const warnings = [];
|
|
19200
19562
|
const blockers = [];
|
|
@@ -19380,7 +19742,7 @@ function applyConsensus(holdings, entries, nowTs, stalenessThresholdSecs) {
|
|
|
19380
19742
|
continue;
|
|
19381
19743
|
}
|
|
19382
19744
|
const reports = entries.filter(
|
|
19383
|
-
(entry) => entry.signer !==
|
|
19745
|
+
(entry) => entry.signer !== import_web329.PublicKey.default.toBase58() && isFresh(entry.lastUpdateTs, nowTs, stalenessThresholdSecs) && (entry.prices[index] ?? 0n) > 0n
|
|
19384
19746
|
);
|
|
19385
19747
|
const usesConsensusPrice = holding.priceOracleType === "consensusoracle";
|
|
19386
19748
|
const prices = reports.map((entry) => entry.prices[index] ?? 0n);
|
|
@@ -19455,7 +19817,9 @@ function settleVault(args) {
|
|
|
19455
19817
|
};
|
|
19456
19818
|
timestampSource = hasFixedAnchor ? "legacy fixed-APY anchor (initialization)" : "current share-price observation (initialization)";
|
|
19457
19819
|
}
|
|
19458
|
-
const
|
|
19820
|
+
const hasPreviousForShortWindow = args.nowTs - maxApyAnchor.timestamp < MAX_APY_ANCHOR_WINDOW_SECS && maxApyAnchor.previousSharePrice > 0n && maxApyAnchor.previousTimestamp > 0n;
|
|
19821
|
+
const previousTooOld = args.nowTs - maxApyAnchor.previousTimestamp > MAX_APY_PREVIOUS_ANCHOR_AGE_SECS;
|
|
19822
|
+
const usePrevious = hasPreviousForShortWindow && !previousTooOld;
|
|
19459
19823
|
const priorApyValue = usePrevious ? maxApyAnchor.previousSharePrice : maxApyAnchor.sharePrice;
|
|
19460
19824
|
const priorTs = usePrevious ? maxApyAnchor.previousTimestamp : maxApyAnchor.timestamp;
|
|
19461
19825
|
if (usePrevious) timestampSource = "apy.max_apy_anchor.previous_timestamp";
|
|
@@ -19543,6 +19907,7 @@ function settleVault(args) {
|
|
|
19543
19907
|
priorTs,
|
|
19544
19908
|
timestampSource,
|
|
19545
19909
|
checkpointTs: maxApyAnchor.timestamp,
|
|
19910
|
+
ignoredPreviousCheckpointTs: hasPreviousForShortWindow && previousTooOld ? maxApyAnchor.previousTimestamp : void 0,
|
|
19546
19911
|
nowTs: args.nowTs,
|
|
19547
19912
|
elapsedSecs,
|
|
19548
19913
|
impliedApyMicroBps: rateAvailable ? numerator * 1000000n / denominator : void 0,
|
|
@@ -19878,7 +20243,7 @@ function decodeOracleData(data, nowTs) {
|
|
|
19878
20243
|
(_, holdingIndex) => readU64(data, offset + EXTERNAL_OFFSET + holdingIndex * 8)
|
|
19879
20244
|
);
|
|
19880
20245
|
entries.push({
|
|
19881
|
-
signer: new
|
|
20246
|
+
signer: new import_web329.PublicKey(signerBytes).toBase58(),
|
|
19882
20247
|
lastUpdateTs: readI64(data, offset + 32),
|
|
19883
20248
|
prices,
|
|
19884
20249
|
externalAmounts
|
|
@@ -19893,7 +20258,7 @@ function decodeOracleData(data, nowTs) {
|
|
|
19893
20258
|
data.slice(pendingOffset + index * 32, pendingOffset + (index + 1) * 32)
|
|
19894
20259
|
);
|
|
19895
20260
|
entries[index] = {
|
|
19896
|
-
signer: index < pendingCount ? new
|
|
20261
|
+
signer: index < pendingCount ? new import_web329.PublicKey(signerBytes).toBase58() : import_web329.PublicKey.default.toBase58(),
|
|
19897
20262
|
lastUpdateTs: 0n,
|
|
19898
20263
|
prices: Array(MAX_HOLDINGS).fill(0n),
|
|
19899
20264
|
externalAmounts: Array(MAX_HOLDINGS).fill(0n)
|
|
@@ -19921,7 +20286,7 @@ function decodeHolding(value) {
|
|
|
19921
20286
|
externalAmount: bigint(holding.externalAmount),
|
|
19922
20287
|
price: bigint(holding.price),
|
|
19923
20288
|
lastUpdateTs: bigint(holding.lastUpdateTs),
|
|
19924
|
-
cleared: mintString ===
|
|
20289
|
+
cleared: mintString === import_web329.PublicKey.default.toBase58()
|
|
19925
20290
|
};
|
|
19926
20291
|
}
|
|
19927
20292
|
function decodeTrancheState(decoded, args, warnings, blockers) {
|
|
@@ -20296,17 +20661,22 @@ function formatRealizedApy(apy) {
|
|
|
20296
20661
|
apy.priorValue,
|
|
20297
20662
|
6
|
|
20298
20663
|
)} [${apy.priorValue}] -> ${apy.nextValue === void 0 ? "unavailable (zero supply)" : `${formatUnits(apy.nextValue, 6)} [${apy.nextValue}]`}`,
|
|
20299
|
-
` weekly checkpoints: every 604800s (7 days); previous checkpoint
|
|
20664
|
+
` weekly checkpoints: every 604800s (7 days); previous checkpoint used only when at most 14 days old; latest=${apy.checkpointTs}`,
|
|
20300
20665
|
` observation window: ${formatUnits(
|
|
20301
20666
|
apy.elapsedSecs * 1000000n / 86400n,
|
|
20302
20667
|
6
|
|
20303
|
-
)} days${apy.elapsedSecs < MAX_APY_ANCHOR_WINDOW_SECS ? " (
|
|
20668
|
+
)} days${apy.elapsedSecs < MAX_APY_ANCHOR_WINDOW_SECS ? " (short observation window: less than 7 days)" : ""}`,
|
|
20304
20669
|
` timestamp: ${apy.priorTs} from ${apy.timestampSource}; settlement time estimate=${apy.nowTs}; elapsed=${apy.elapsedSecs}s`,
|
|
20305
20670
|
` configured max: ${apy.maxApyBps}bps (${formatUnits(
|
|
20306
20671
|
BigInt(apy.maxApyBps),
|
|
20307
20672
|
2
|
|
20308
20673
|
)}%); regular HWM: ${apy.hwmBefore} -> ${apy.hwmAfter}`
|
|
20309
20674
|
];
|
|
20675
|
+
if (apy.ignoredPreviousCheckpointTs !== void 0) {
|
|
20676
|
+
lines.push(
|
|
20677
|
+
` previous checkpoint ${apy.ignoredPreviousCheckpointTs} ignored (older than 14 days); using the latest checkpoint`
|
|
20678
|
+
);
|
|
20679
|
+
}
|
|
20310
20680
|
if (apy.impliedApyMicroBps !== void 0) {
|
|
20311
20681
|
lines.push(
|
|
20312
20682
|
` implied APY (linear annualization): ${formatUnits(
|
|
@@ -20386,11 +20756,11 @@ async function simulateDryRunSettlement({
|
|
|
20386
20756
|
client.account.fetchVaultOracleForVault(vault, { fresh: true }),
|
|
20387
20757
|
tranchingEnabled ? client.account.fetchVaultTrancheStateForVault(vault, { fresh: true }) : Promise.resolve(void 0)
|
|
20388
20758
|
]);
|
|
20389
|
-
const mintKeys = [new
|
|
20759
|
+
const mintKeys = [new import_web330.PublicKey(vaultState.mint)];
|
|
20390
20760
|
if (trancheState) {
|
|
20391
20761
|
mintKeys.push(
|
|
20392
|
-
new
|
|
20393
|
-
new
|
|
20762
|
+
new import_web330.PublicKey(trancheState.config.juniorMint),
|
|
20763
|
+
new import_web330.PublicKey(trancheState.config.seniorMint)
|
|
20394
20764
|
);
|
|
20395
20765
|
}
|
|
20396
20766
|
const mintAccounts = await client.provider.connection.getMultipleAccountsInfo(
|
|
@@ -20406,7 +20776,7 @@ async function simulateDryRunSettlement({
|
|
|
20406
20776
|
oracleData: oracleState.data,
|
|
20407
20777
|
trancheState,
|
|
20408
20778
|
updates,
|
|
20409
|
-
signer: (0,
|
|
20779
|
+
signer: (0, import_common49.fromWeb3Pk)(signer.publicKey),
|
|
20410
20780
|
nowTs: nowSecs,
|
|
20411
20781
|
physicalShareSupply: supplies[0],
|
|
20412
20782
|
physicalJuniorSupply: tranchingEnabled ? supplies[1] : void 0,
|
|
@@ -20415,7 +20785,7 @@ async function simulateDryRunSettlement({
|
|
|
20415
20785
|
}
|
|
20416
20786
|
|
|
20417
20787
|
// src/services/consensusOracle/pipeline/holdingUpdates.ts
|
|
20418
|
-
var
|
|
20788
|
+
var import_common50 = __toESM(require_dist());
|
|
20419
20789
|
async function buildUpdates(yieldTracker, reportableHoldings, inputs) {
|
|
20420
20790
|
const updates = [];
|
|
20421
20791
|
for (const entry of reportableHoldings) {
|
|
@@ -20425,7 +20795,7 @@ async function buildUpdates(yieldTracker, reportableHoldings, inputs) {
|
|
|
20425
20795
|
}
|
|
20426
20796
|
async function buildHoldingUpdate(yieldTracker, entry, inputs) {
|
|
20427
20797
|
const { holding, holdingIndex } = entry;
|
|
20428
|
-
const mint = (0,
|
|
20798
|
+
const mint = (0, import_common50.fromWeb3Pk)(holding.mint);
|
|
20429
20799
|
const mintKey = mint.toString();
|
|
20430
20800
|
const oracleType = variantName2(holding.priceOracleType).toLowerCase();
|
|
20431
20801
|
let usd;
|
|
@@ -20487,14 +20857,14 @@ async function resolveTrackedAmounts(yieldTracker, cfg, decimals) {
|
|
|
20487
20857
|
);
|
|
20488
20858
|
}
|
|
20489
20859
|
return {
|
|
20490
|
-
trackedValueAmount: tracked.totalValue > 0 ? (0,
|
|
20491
|
-
principalAmount: tracked.principal > 0 ? (0,
|
|
20492
|
-
yieldAmount: tracked.outstandingYield > 0 ? (0,
|
|
20860
|
+
trackedValueAmount: tracked.totalValue > 0 ? (0, import_common50.fromUiAmount)(tracked.totalValue, decimals) : 0n,
|
|
20861
|
+
principalAmount: tracked.principal > 0 ? (0, import_common50.fromUiAmount)(tracked.principal, decimals) : 0n,
|
|
20862
|
+
yieldAmount: tracked.outstandingYield > 0 ? (0, import_common50.fromUiAmount)(tracked.outstandingYield, decimals) : 0n
|
|
20493
20863
|
};
|
|
20494
20864
|
}
|
|
20495
20865
|
|
|
20496
20866
|
// src/services/consensusOracle/pipeline/livePriceRefresh.ts
|
|
20497
|
-
var
|
|
20867
|
+
var import_common51 = __toESM(require_dist());
|
|
20498
20868
|
async function refreshLiveOraclePrices({
|
|
20499
20869
|
oracle,
|
|
20500
20870
|
signer,
|
|
@@ -20513,7 +20883,7 @@ async function refreshLiveOraclePrices({
|
|
|
20513
20883
|
for (const holding of vaultState.holdings) {
|
|
20514
20884
|
const oracleType = variantName2(holding.priceOracleType).toLowerCase();
|
|
20515
20885
|
if (!LIVE_ORACLE_VARIANTS.has(oracleType)) continue;
|
|
20516
|
-
const mint = (0,
|
|
20886
|
+
const mint = (0, import_common51.fromWeb3Pk)(holding.mint);
|
|
20517
20887
|
if (mint.toString() === SYSTEM_PROGRAM) continue;
|
|
20518
20888
|
const activeAmount = toBigInt2(holding.localAmount) + toBigInt2(holding.externalAmount);
|
|
20519
20889
|
if (activeAmount === 0n) continue;
|
|
@@ -20528,7 +20898,7 @@ async function refreshLiveOraclePrices({
|
|
|
20528
20898
|
);
|
|
20529
20899
|
continue;
|
|
20530
20900
|
}
|
|
20531
|
-
const oracleAccount = (0,
|
|
20901
|
+
const oracleAccount = (0, import_common51.fromWeb3Pk)(holding.priceOracleAccount);
|
|
20532
20902
|
if (oracleAccount.toString() === SYSTEM_PROGRAM) {
|
|
20533
20903
|
log(
|
|
20534
20904
|
`vault ${vault}: cannot refresh ${mint}; ${oracleType} holding has no oracle account`
|
|
@@ -20552,7 +20922,7 @@ async function refreshLiveOraclePrices({
|
|
|
20552
20922
|
}
|
|
20553
20923
|
|
|
20554
20924
|
// src/services/consensusOracle/pipeline/managerWalletReconciliation.ts
|
|
20555
|
-
var
|
|
20925
|
+
var import_common52 = __toESM(require_dist());
|
|
20556
20926
|
|
|
20557
20927
|
// src/services/consensusOracle/sources/nestPriceSource.ts
|
|
20558
20928
|
var import_kit13 = require("@solana/kit");
|
|
@@ -20597,13 +20967,13 @@ function candidateGrossNav(state, updates) {
|
|
|
20597
20967
|
const byIndex = /* @__PURE__ */ new Map();
|
|
20598
20968
|
for (const update of updates) {
|
|
20599
20969
|
const holding = state.holdings[update.holdingIndex];
|
|
20600
|
-
if (!holding || (0,
|
|
20970
|
+
if (!holding || (0, import_common52.fromWeb3Pk)(holding.mint) !== update.mint || holding.decimals !== update.decimals || byIndex.has(update.holdingIndex)) {
|
|
20601
20971
|
throw new Error(`Invalid NAV update for holding #${update.holdingIndex}`);
|
|
20602
20972
|
}
|
|
20603
20973
|
byIndex.set(update.holdingIndex, update);
|
|
20604
20974
|
}
|
|
20605
20975
|
return state.holdings.reduce((nav, holding, index) => {
|
|
20606
|
-
if ((0,
|
|
20976
|
+
if ((0, import_common52.fromWeb3Pk)(holding.mint) === SYSTEM_PROGRAM) return nav;
|
|
20607
20977
|
const update = byIndex.get(index);
|
|
20608
20978
|
const local = toBigInt2(holding.localAmount);
|
|
20609
20979
|
const external = update?.externalAmount ?? toBigInt2(holding.externalAmount);
|
|
@@ -20641,12 +21011,13 @@ async function reconcileManagerWalletBalances({
|
|
|
20641
21011
|
vaultState,
|
|
20642
21012
|
updates,
|
|
20643
21013
|
source,
|
|
21014
|
+
mpcSource,
|
|
20644
21015
|
log = () => {
|
|
20645
21016
|
}
|
|
20646
21017
|
}) {
|
|
20647
21018
|
const previousNav = previousPhysicalNav(vaultState);
|
|
20648
21019
|
if (updates.some(
|
|
20649
|
-
(update) => (update.managerWalletAmount ?? 0n) !== 0n || (update.pendingNestAmount ?? 0n) !== 0n
|
|
21020
|
+
(update) => (update.managerWalletAmount ?? 0n) !== 0n || (update.mpcWalletAmount ?? 0n) !== 0n || (update.mpcMarginfiAmount ?? 0n) !== 0n || (update.pendingNestAmount ?? 0n) !== 0n
|
|
20650
21021
|
)) {
|
|
20651
21022
|
throw new Error("Manager reconciliation requires fresh source amounts");
|
|
20652
21023
|
}
|
|
@@ -20678,30 +21049,49 @@ async function reconcileManagerWalletBalances({
|
|
|
20678
21049
|
throw new Error("Duplicate base mint in manager reconciliation");
|
|
20679
21050
|
}
|
|
20680
21051
|
if (vaultState.holdings.some(
|
|
20681
|
-
(holding) => coerceBool3(holding.isBase) && !mints2.includes((0,
|
|
21052
|
+
(holding) => coerceBool3(holding.isBase) && !mints2.includes((0, import_common52.fromWeb3Pk)(holding.mint))
|
|
20682
21053
|
)) {
|
|
20683
21054
|
throw new Error(
|
|
20684
21055
|
"Cannot reconcile all vault base assets with oracle reports"
|
|
20685
21056
|
);
|
|
20686
21057
|
}
|
|
20687
|
-
const manager = (0,
|
|
21058
|
+
const manager = (0, import_common52.fromWeb3Pk)(vaultState.roles.manager);
|
|
20688
21059
|
if (manager === SYSTEM_PROGRAM || manager === vault) {
|
|
20689
21060
|
throw new Error("Invalid manager wallet for NAV reconciliation");
|
|
20690
21061
|
}
|
|
20691
21062
|
log(
|
|
20692
21063
|
`vault ${vault}: NAV ${candidateNav} is at least 0.1% below ${previousNav}; checking manager ${manager}`
|
|
20693
21064
|
);
|
|
20694
|
-
const amounts = await
|
|
21065
|
+
const [amounts, mpc] = await Promise.all([
|
|
21066
|
+
source.fetchBalances(manager, mints2),
|
|
21067
|
+
mpcSource?.fetchBalances(vault, manager, mints2)
|
|
21068
|
+
]);
|
|
21069
|
+
if (mpc && [manager, vault, SYSTEM_PROGRAM].includes(mpc.wallet)) {
|
|
21070
|
+
throw new Error("Invalid MPC wallet for NAV reconciliation");
|
|
21071
|
+
}
|
|
21072
|
+
const balance = (value, label) => {
|
|
21073
|
+
if (typeof value !== "bigint" || value < 0n || value > U64_MAX) {
|
|
21074
|
+
throw new Error(`Invalid ${label} base-asset balance for reconciliation`);
|
|
21075
|
+
}
|
|
21076
|
+
return value;
|
|
21077
|
+
};
|
|
20695
21078
|
const adjusted = updates.map((update) => {
|
|
20696
21079
|
if (!mints2.includes(update.mint)) return update;
|
|
20697
|
-
const amount = amounts.get(update.mint) ?? 0n;
|
|
20698
|
-
|
|
20699
|
-
|
|
20700
|
-
|
|
21080
|
+
const amount = balance(amounts.get(update.mint) ?? 0n, "manager");
|
|
21081
|
+
const mpcTokens = balance(mpc?.tokens.get(update.mint) ?? 0n, "MPC token");
|
|
21082
|
+
const mpcMarginfi = balance(
|
|
21083
|
+
mpc?.marginfi.get(update.mint) ?? 0n,
|
|
21084
|
+
"MPC Marginfi"
|
|
21085
|
+
);
|
|
21086
|
+
if (mpc)
|
|
21087
|
+
log(
|
|
21088
|
+
`vault ${vault}: MPC ${mpc.wallet} mint ${update.mint}: tokens=${mpcTokens} marginfi=${mpcMarginfi}`
|
|
21089
|
+
);
|
|
20701
21090
|
return {
|
|
20702
21091
|
...update,
|
|
20703
21092
|
managerWalletAmount: amount,
|
|
20704
|
-
|
|
21093
|
+
...mpc ? { mpcWalletAmount: mpcTokens, mpcMarginfiAmount: mpcMarginfi } : {},
|
|
21094
|
+
externalAmount: update.externalAmount + amount + mpcTokens + mpcMarginfi
|
|
20705
21095
|
};
|
|
20706
21096
|
});
|
|
20707
21097
|
const adjustedNav = candidateGrossNav(vaultState, adjusted);
|
|
@@ -20709,22 +21099,23 @@ async function reconcileManagerWalletBalances({
|
|
|
20709
21099
|
const absoluteDelta = delta < 0n ? -delta : delta;
|
|
20710
21100
|
const accepted = adjustedNav > candidateNav && absoluteDelta * BPS <= previousNav * MANAGER_WALLET_NAV_TOLERANCE_BPS;
|
|
20711
21101
|
log(
|
|
20712
|
-
`vault ${vault}: manager wallet ${accepted ? "accepted" : "rejected"}; adjusted NAV ${adjustedNav}, previous NAV ${previousNav}, allowed difference \xB10.05%`
|
|
21102
|
+
`vault ${vault}: manager${mpc ? " + MPC wallets" : " wallet"} ${accepted ? "accepted" : "rejected"}; adjusted NAV ${adjustedNav}, previous NAV ${previousNav}, allowed difference \xB10.05%`
|
|
20713
21103
|
);
|
|
20714
21104
|
return {
|
|
20715
21105
|
accepted,
|
|
20716
21106
|
updates: accepted ? adjusted : pendingUpdates,
|
|
20717
21107
|
previousNav,
|
|
20718
21108
|
candidateNav,
|
|
20719
|
-
adjustedNav
|
|
21109
|
+
adjustedNav,
|
|
21110
|
+
walletUpdates: adjusted
|
|
20720
21111
|
};
|
|
20721
21112
|
}
|
|
20722
21113
|
function managerReconciliationStateKey(state) {
|
|
20723
21114
|
return JSON.stringify({
|
|
20724
|
-
manager: (0,
|
|
21115
|
+
manager: (0, import_common52.fromWeb3Pk)(state.roles.manager),
|
|
20725
21116
|
previousNav: previousPhysicalNav(state).toString(),
|
|
20726
21117
|
holdings: state.holdings.map((holding) => [
|
|
20727
|
-
(0,
|
|
21118
|
+
(0, import_common52.fromWeb3Pk)(holding.mint),
|
|
20728
21119
|
holding.decimals,
|
|
20729
21120
|
variantName2(holding.priceOracleType),
|
|
20730
21121
|
coerceBool3(holding.isBase),
|
|
@@ -20736,14 +21127,14 @@ function managerReconciliationStateKey(state) {
|
|
|
20736
21127
|
}
|
|
20737
21128
|
|
|
20738
21129
|
// src/services/consensusOracle/pipeline/pricingInputs.ts
|
|
20739
|
-
var
|
|
21130
|
+
var import_common53 = __toESM(require_dist());
|
|
20740
21131
|
async function gatherPricingInputs(deps, target, vaultState, reportableHoldings, log = () => {
|
|
20741
21132
|
}) {
|
|
20742
21133
|
const consensusMints = reportableHoldings.filter(
|
|
20743
21134
|
({ holding }) => variantName2(holding.priceOracleType).toLowerCase() === CONSENSUS_ORACLE_VARIANT
|
|
20744
|
-
).map(({ holding }) => (0,
|
|
21135
|
+
).map(({ holding }) => (0, import_common53.fromWeb3Pk)(holding.mint));
|
|
20745
21136
|
const baseHolding = vaultState.holdings.find((h) => coerceBool3(h.isBase));
|
|
20746
|
-
const baseMint = baseHolding ? (0,
|
|
21137
|
+
const baseMint = baseHolding ? (0, import_common53.fromWeb3Pk)(baseHolding.mint) : consensusMints[0];
|
|
20747
21138
|
if (!baseMint) {
|
|
20748
21139
|
throw new Error(`vault has no holdings \u2014 cannot determine base asset`);
|
|
20749
21140
|
}
|
|
@@ -20827,11 +21218,11 @@ function reconcilePositionSnapshots(snapshots, vault, log) {
|
|
|
20827
21218
|
}
|
|
20828
21219
|
|
|
20829
21220
|
// src/services/consensusOracle/pipeline/receiptMints.ts
|
|
20830
|
-
var
|
|
21221
|
+
var import_common54 = __toESM(require_dist());
|
|
20831
21222
|
async function fetchReceiptMints(client, vault, vaultState) {
|
|
20832
21223
|
const receiptMints = /* @__PURE__ */ new Set();
|
|
20833
21224
|
if (vaultState.mint) {
|
|
20834
|
-
receiptMints.add((0,
|
|
21225
|
+
receiptMints.add((0, import_common54.fromWeb3Pk)(vaultState.mint).toString());
|
|
20835
21226
|
}
|
|
20836
21227
|
if (!coerceBool3(vaultState.tranchingEnabled)) return receiptMints;
|
|
20837
21228
|
const trancheState = await client.account.fetchVaultTrancheStateForVault(
|
|
@@ -20839,19 +21230,19 @@ async function fetchReceiptMints(client, vault, vaultState) {
|
|
|
20839
21230
|
{ fresh: true }
|
|
20840
21231
|
);
|
|
20841
21232
|
receiptMints.add(
|
|
20842
|
-
(0,
|
|
21233
|
+
(0, import_common54.fromWeb3Pk)(trancheState.config.juniorMint).toString()
|
|
20843
21234
|
);
|
|
20844
21235
|
receiptMints.add(
|
|
20845
|
-
(0,
|
|
21236
|
+
(0, import_common54.fromWeb3Pk)(trancheState.config.seniorMint).toString()
|
|
20846
21237
|
);
|
|
20847
21238
|
return receiptMints;
|
|
20848
21239
|
}
|
|
20849
21240
|
|
|
20850
21241
|
// src/services/consensusOracle/pipeline/settlement.ts
|
|
20851
|
-
var
|
|
21242
|
+
var import_common56 = __toESM(require_dist());
|
|
20852
21243
|
|
|
20853
21244
|
// src/services/consensusOracle/pipeline/yieldAccounts.ts
|
|
20854
|
-
var
|
|
21245
|
+
var import_common55 = __toESM(require_dist());
|
|
20855
21246
|
async function assertNoUnconfirmedYieldPayments(yieldTracker, target) {
|
|
20856
21247
|
const accountNames = [
|
|
20857
21248
|
...new Set(
|
|
@@ -20893,7 +21284,7 @@ async function withDiscoveredYieldAccounts(yieldTracker, target, vaultState, exc
|
|
|
20893
21284
|
);
|
|
20894
21285
|
if (namesToAttach.length === 0) return target;
|
|
20895
21286
|
const baseHolding = vaultState.holdings.find((holding) => {
|
|
20896
|
-
const mint = (0,
|
|
21287
|
+
const mint = (0, import_common55.fromWeb3Pk)(holding.mint).toString();
|
|
20897
21288
|
return coerceBool3(holding.isBase) && !excludedMints.has(mint);
|
|
20898
21289
|
});
|
|
20899
21290
|
if (!baseHolding) {
|
|
@@ -20901,7 +21292,7 @@ async function withDiscoveredYieldAccounts(yieldTracker, target, vaultState, exc
|
|
|
20901
21292
|
`vault ${target.vault}: tagged yield accounts found but no base holding is available`
|
|
20902
21293
|
);
|
|
20903
21294
|
}
|
|
20904
|
-
const baseMint = (0,
|
|
21295
|
+
const baseMint = (0, import_common55.fromWeb3Pk)(baseHolding.mint);
|
|
20905
21296
|
const holdings = [...target.holdings ?? []];
|
|
20906
21297
|
const existingIndex = holdings.findIndex(
|
|
20907
21298
|
(holding) => holding.mint.toString() === baseMint.toString()
|
|
@@ -20941,7 +21332,7 @@ async function settleVault2({
|
|
|
20941
21332
|
log(`vault ${vault}: submitting ${updates.length} consensus asset update(s)`);
|
|
20942
21333
|
for (const update of updates) {
|
|
20943
21334
|
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}]`
|
|
21335
|
+
` 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
21336
|
);
|
|
20946
21337
|
}
|
|
20947
21338
|
try {
|
|
@@ -20976,6 +21367,31 @@ async function settleVault2({
|
|
|
20976
21367
|
},
|
|
20977
21368
|
log
|
|
20978
21369
|
);
|
|
21370
|
+
let crankSkippedReason;
|
|
21371
|
+
try {
|
|
21372
|
+
const [publishedVault, publishedOracle, publishedAt] = await Promise.all([
|
|
21373
|
+
client.account.fetchVault(vault, { fresh: true }),
|
|
21374
|
+
client.account.fetchVaultOracleForVault(vault, { fresh: true }),
|
|
21375
|
+
client.account.fetchClockUnixTimestamp()
|
|
21376
|
+
]);
|
|
21377
|
+
const blockers = publishedConsensusBlockers({
|
|
21378
|
+
vault: publishedVault,
|
|
21379
|
+
oracleData: publishedOracle.data,
|
|
21380
|
+
updates,
|
|
21381
|
+
signer: (0, import_common56.fromWeb3Pk)(signer.publicKey),
|
|
21382
|
+
nowTs: publishedAt
|
|
21383
|
+
});
|
|
21384
|
+
if (blockers.length)
|
|
21385
|
+
crankSkippedReason = `waiting for published consensus: ${blockers.join(
|
|
21386
|
+
"; "
|
|
21387
|
+
)}`;
|
|
21388
|
+
} catch (error) {
|
|
21389
|
+
crankSkippedReason = `could not verify published consensus: ${error instanceof Error ? error.message : String(error)}`;
|
|
21390
|
+
}
|
|
21391
|
+
if (crankSkippedReason) {
|
|
21392
|
+
log(`skip crank nav ${vault}: ${crankSkippedReason}`);
|
|
21393
|
+
return { updateSignature, crankSkippedReason };
|
|
21394
|
+
}
|
|
20979
21395
|
const crankResult = await oracle.crankNavIfReady(signer, { vault }, log);
|
|
20980
21396
|
return {
|
|
20981
21397
|
updateSignature,
|
|
@@ -21004,7 +21420,7 @@ async function logProspectiveApy({
|
|
|
21004
21420
|
);
|
|
21005
21421
|
const prospectiveNav = vaultState.holdings.reduce(
|
|
21006
21422
|
(sum, holding, holdingIndex) => {
|
|
21007
|
-
const mint = (0,
|
|
21423
|
+
const mint = (0, import_common56.fromWeb3Pk)(holding.mint).toString();
|
|
21008
21424
|
if (mint === SYSTEM_PROGRAM) return sum;
|
|
21009
21425
|
const update = updatesByIndex.get(holdingIndex);
|
|
21010
21426
|
const localAmount = toBigInt2(holding.localAmount);
|
|
@@ -21092,8 +21508,8 @@ var LivePriceSource = class {
|
|
|
21092
21508
|
};
|
|
21093
21509
|
|
|
21094
21510
|
// src/services/consensusOracle/sources/managerWalletBalanceSource.ts
|
|
21095
|
-
var
|
|
21096
|
-
var
|
|
21511
|
+
var import_web331 = require("@solana/web3.js");
|
|
21512
|
+
var import_spl_token21 = require("@solana/spl-token");
|
|
21097
21513
|
var RpcManagerWalletBalanceSource = class {
|
|
21098
21514
|
constructor(connection) {
|
|
21099
21515
|
this.connection = connection;
|
|
@@ -21101,8 +21517,8 @@ var RpcManagerWalletBalanceSource = class {
|
|
|
21101
21517
|
async fetchBalances(manager, mints2) {
|
|
21102
21518
|
const wanted = new Set(mints2);
|
|
21103
21519
|
if (wanted.size === 0) return /* @__PURE__ */ new Map();
|
|
21104
|
-
const owner = new
|
|
21105
|
-
const programs = [
|
|
21520
|
+
const owner = new import_web331.PublicKey(manager);
|
|
21521
|
+
const programs = [import_spl_token21.TOKEN_PROGRAM_ID, import_spl_token21.TOKEN_2022_PROGRAM_ID];
|
|
21106
21522
|
const responses = await Promise.all(
|
|
21107
21523
|
programs.map(
|
|
21108
21524
|
(programId) => this.connection.getParsedTokenAccountsByOwner(
|
|
@@ -21144,6 +21560,124 @@ var RpcManagerWalletBalanceSource = class {
|
|
|
21144
21560
|
}
|
|
21145
21561
|
};
|
|
21146
21562
|
|
|
21563
|
+
// src/services/consensusOracle/sources/mpcWalletBalanceSource.ts
|
|
21564
|
+
var import_web332 = require("@solana/web3.js");
|
|
21565
|
+
|
|
21566
|
+
// src/services/consensusOracle/sources/mpcMarginfiDeposits.ts
|
|
21567
|
+
var import_kit14 = require("@solana/kit");
|
|
21568
|
+
var import_marginfi_client_v2 = require("@mrgnlabs/marginfi-client-v2");
|
|
21569
|
+
var import_marginfi2 = __toESM(require_dist2());
|
|
21570
|
+
async function readMarginfiDepositsForAuthority(connection, authority, mints2) {
|
|
21571
|
+
const wanted = new Set(mints2.map((mint) => mint.toBase58()));
|
|
21572
|
+
if (wanted.size === 0) return /* @__PURE__ */ new Map();
|
|
21573
|
+
const config = (0, import_marginfi_client_v2.getConfig)("production");
|
|
21574
|
+
const discriminator = import_marginfi_client_v2.MARGINFI_IDL.accounts.find(
|
|
21575
|
+
(account) => account.name.toLowerCase() === "marginfiaccount"
|
|
21576
|
+
).discriminator;
|
|
21577
|
+
const records = await connection.getProgramAccounts(config.programId, {
|
|
21578
|
+
commitment: "confirmed",
|
|
21579
|
+
filters: [
|
|
21580
|
+
{
|
|
21581
|
+
memcmp: {
|
|
21582
|
+
offset: 0,
|
|
21583
|
+
bytes: (0, import_kit14.getBase58Decoder)().decode(new Uint8Array(discriminator))
|
|
21584
|
+
}
|
|
21585
|
+
},
|
|
21586
|
+
{ memcmp: { offset: 8, bytes: config.groupPk.toBase58() } },
|
|
21587
|
+
{ memcmp: { offset: 40, bytes: authority.toBase58() } }
|
|
21588
|
+
]
|
|
21589
|
+
});
|
|
21590
|
+
if (records.length === 0) return /* @__PURE__ */ new Map();
|
|
21591
|
+
const seen = /* @__PURE__ */ new Set();
|
|
21592
|
+
const bankKeys = /* @__PURE__ */ new Map();
|
|
21593
|
+
for (const { pubkey: pubkey2, account } of records) {
|
|
21594
|
+
const key = pubkey2.toBase58();
|
|
21595
|
+
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())) {
|
|
21596
|
+
throw new Error(`Invalid or duplicate MPC Marginfi account ${key}`);
|
|
21597
|
+
}
|
|
21598
|
+
seen.add(key);
|
|
21599
|
+
for (const bank of (0, import_marginfi2.parseBankPksFromMarginfiAccount)(account.data))
|
|
21600
|
+
bankKeys.set(bank.toBase58(), bank);
|
|
21601
|
+
}
|
|
21602
|
+
const client = await (0, import_marginfi2.createMarginfiReadClient)(connection, [
|
|
21603
|
+
...bankKeys.values()
|
|
21604
|
+
]);
|
|
21605
|
+
const accounts2 = records.map(({ pubkey: pubkey2, account }) => {
|
|
21606
|
+
const key = pubkey2.toBase58();
|
|
21607
|
+
const decoded = import_marginfi_client_v2.MarginfiAccount.fromAccountDataRaw(
|
|
21608
|
+
pubkey2,
|
|
21609
|
+
account.data,
|
|
21610
|
+
client.program.idl
|
|
21611
|
+
);
|
|
21612
|
+
if (!decoded.authority.equals(authority) || !decoded.group.equals(config.groupPk)) {
|
|
21613
|
+
throw new Error(`Invalid MPC Marginfi authority or group for ${key}`);
|
|
21614
|
+
}
|
|
21615
|
+
for (const balance of decoded.activeBalances) {
|
|
21616
|
+
if (!balance.liabilityShares.isZero()) {
|
|
21617
|
+
throw new Error(`MPC Marginfi account has borrowing: ${key}`);
|
|
21618
|
+
}
|
|
21619
|
+
}
|
|
21620
|
+
return decoded;
|
|
21621
|
+
});
|
|
21622
|
+
const amounts = /* @__PURE__ */ new Map();
|
|
21623
|
+
for (const account of accounts2) {
|
|
21624
|
+
for (const balance of account.activeBalances) {
|
|
21625
|
+
const bank = client.getBankByPk(balance.bankPk);
|
|
21626
|
+
if (!bank)
|
|
21627
|
+
throw new Error(`MPC Marginfi bank not found: ${balance.bankPk}`);
|
|
21628
|
+
const mint = bank.mint.toBase58();
|
|
21629
|
+
if (!wanted.has(mint)) continue;
|
|
21630
|
+
const quantity = balance.computeQuantity(bank).assets;
|
|
21631
|
+
if (!quantity.isFinite() || quantity.isNegative()) {
|
|
21632
|
+
throw new Error(`Invalid MPC Marginfi deposit for ${mint}`);
|
|
21633
|
+
}
|
|
21634
|
+
const amount = BigInt(quantity.toFixed(0, 3));
|
|
21635
|
+
const total = (amounts.get(mint) ?? 0n) + amount;
|
|
21636
|
+
if (total > 0xffffffffffffffffn)
|
|
21637
|
+
throw new Error(`MPC Marginfi deposit exceeds u64: ${mint}`);
|
|
21638
|
+
amounts.set(mint, total);
|
|
21639
|
+
}
|
|
21640
|
+
}
|
|
21641
|
+
return amounts;
|
|
21642
|
+
}
|
|
21643
|
+
|
|
21644
|
+
// src/services/consensusOracle/sources/mpcWalletBalanceSource.ts
|
|
21645
|
+
var RpcMpcWalletBalanceSource = class {
|
|
21646
|
+
constructor(connection, bindings) {
|
|
21647
|
+
this.connection = connection;
|
|
21648
|
+
const entries = /* @__PURE__ */ new Map();
|
|
21649
|
+
const wallets = /* @__PURE__ */ new Set();
|
|
21650
|
+
for (const binding of bindings) {
|
|
21651
|
+
const { vault, manager, wallet } = binding;
|
|
21652
|
+
for (const key of [vault, manager, wallet]) new import_web332.PublicKey(key);
|
|
21653
|
+
if (entries.has(vault) || wallets.has(wallet) || wallet === manager || wallet === vault || wallet === import_web332.PublicKey.default.toBase58())
|
|
21654
|
+
throw new Error("Invalid or duplicate MPC wallet binding");
|
|
21655
|
+
entries.set(vault, { ...binding });
|
|
21656
|
+
wallets.add(wallet);
|
|
21657
|
+
}
|
|
21658
|
+
this.bindings = entries;
|
|
21659
|
+
this.tokens = new RpcManagerWalletBalanceSource(connection);
|
|
21660
|
+
}
|
|
21661
|
+
async fetchBalances(vault, manager, mints2) {
|
|
21662
|
+
const binding = this.bindings.get(vault);
|
|
21663
|
+
if (!binding) return void 0;
|
|
21664
|
+
if (binding.manager !== manager) {
|
|
21665
|
+
throw new Error(
|
|
21666
|
+
`MPC wallet binding no longer matches manager for ${vault}`
|
|
21667
|
+
);
|
|
21668
|
+
}
|
|
21669
|
+
const [tokens, deposits] = await Promise.all([
|
|
21670
|
+
this.tokens.fetchBalances(binding.wallet, mints2),
|
|
21671
|
+
readMarginfiDepositsForAuthority(
|
|
21672
|
+
this.connection,
|
|
21673
|
+
new import_web332.PublicKey(binding.wallet),
|
|
21674
|
+
mints2.map((mint) => new import_web332.PublicKey(mint))
|
|
21675
|
+
)
|
|
21676
|
+
]);
|
|
21677
|
+
return { wallet: binding.wallet, tokens, marginfi: deposits };
|
|
21678
|
+
}
|
|
21679
|
+
};
|
|
21680
|
+
|
|
21147
21681
|
// src/services/consensusOracle/positions/externalPositions.ts
|
|
21148
21682
|
var ExternalPositionRegistry = class {
|
|
21149
21683
|
constructor(providers = [], log = () => {
|
|
@@ -21179,12 +21713,12 @@ var StaticPositionProvider = class {
|
|
|
21179
21713
|
};
|
|
21180
21714
|
|
|
21181
21715
|
// src/services/consensusOracle/positions/kaminoPositionProvider.ts
|
|
21182
|
-
var
|
|
21183
|
-
var
|
|
21716
|
+
var import_kit15 = require("@solana/kit");
|
|
21717
|
+
var import_web333 = require("@solana/web3.js");
|
|
21184
21718
|
var import_klend_sdk = require("@kamino-finance/klend-sdk");
|
|
21185
21719
|
async function readKaminoBalance(manager, vault, sharesHolder) {
|
|
21186
21720
|
const userShares = await manager.getUserSharesBalanceSingleVault(
|
|
21187
|
-
(0,
|
|
21721
|
+
(0, import_kit15.address)(sharesHolder.toBase58()),
|
|
21188
21722
|
vault
|
|
21189
21723
|
);
|
|
21190
21724
|
const tokensPerShare = await manager.getTokensPerShareSingleVault(vault);
|
|
@@ -21200,7 +21734,7 @@ var KaminoPositionProvider = class {
|
|
|
21200
21734
|
async positionsFor(ctx) {
|
|
21201
21735
|
const refs = ctx.refs.filter((r) => r.kind === "kamino");
|
|
21202
21736
|
if (refs.length === 0) return [];
|
|
21203
|
-
const rpc = (0,
|
|
21737
|
+
const rpc = (0, import_kit15.createSolanaRpc)(this.rpcUrl);
|
|
21204
21738
|
const slotDuration = await (0, import_klend_sdk.getMedianSlotDurationInMsFromLastEpochs)();
|
|
21205
21739
|
const manager = new import_klend_sdk.KaminoManager(rpc, slotDuration);
|
|
21206
21740
|
const out = [];
|
|
@@ -21213,11 +21747,11 @@ var KaminoPositionProvider = class {
|
|
|
21213
21747
|
);
|
|
21214
21748
|
continue;
|
|
21215
21749
|
}
|
|
21216
|
-
const kVault = new import_klend_sdk.KaminoVault(rpc, (0,
|
|
21750
|
+
const kVault = new import_klend_sdk.KaminoVault(rpc, (0, import_kit15.address)(vaultState));
|
|
21217
21751
|
const amount = await readKaminoBalance(
|
|
21218
21752
|
manager,
|
|
21219
21753
|
kVault,
|
|
21220
|
-
new
|
|
21754
|
+
new import_web333.PublicKey(sharesHolder)
|
|
21221
21755
|
);
|
|
21222
21756
|
out.push({ mint: ref.mint, amount });
|
|
21223
21757
|
}
|
|
@@ -21226,8 +21760,8 @@ var KaminoPositionProvider = class {
|
|
|
21226
21760
|
};
|
|
21227
21761
|
|
|
21228
21762
|
// src/services/consensusOracle/positions/marginfiPositionProvider.ts
|
|
21229
|
-
var
|
|
21230
|
-
var
|
|
21763
|
+
var import_web334 = require("@solana/web3.js");
|
|
21764
|
+
var import_marginfi3 = __toESM(require_dist2());
|
|
21231
21765
|
var MarginfiPositionProvider = class {
|
|
21232
21766
|
constructor(connection, log = () => {
|
|
21233
21767
|
}) {
|
|
@@ -21237,14 +21771,14 @@ var MarginfiPositionProvider = class {
|
|
|
21237
21771
|
async positionsFor(ctx) {
|
|
21238
21772
|
const refs = ctx.refs.filter((r) => r.kind === "marginfi");
|
|
21239
21773
|
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
|
|
21774
|
+
const explicitBanks = refs.map((r) => r.marginfiBank).filter(Boolean).map((bank) => new import_web334.PublicKey(bank));
|
|
21775
|
+
const autoAccountPks = refs.filter((r) => !r.marginfiBank).map((r) => r.marginfiAccount).filter(Boolean).map((account) => new import_web334.PublicKey(account));
|
|
21242
21776
|
const autoBanks = [];
|
|
21243
21777
|
for (const accountPk of autoAccountPks) {
|
|
21244
21778
|
try {
|
|
21245
21779
|
const info = await this.connection.getAccountInfo(accountPk);
|
|
21246
21780
|
if (info) {
|
|
21247
|
-
autoBanks.push(...(0,
|
|
21781
|
+
autoBanks.push(...(0, import_marginfi3.parseBankPksFromMarginfiAccount)(info.data));
|
|
21248
21782
|
}
|
|
21249
21783
|
} catch (err) {
|
|
21250
21784
|
this.log(
|
|
@@ -21252,7 +21786,7 @@ var MarginfiPositionProvider = class {
|
|
|
21252
21786
|
);
|
|
21253
21787
|
}
|
|
21254
21788
|
}
|
|
21255
|
-
const client = await (0,
|
|
21789
|
+
const client = await (0, import_marginfi3.createMarginfiReadClient)(this.connection, [
|
|
21256
21790
|
...explicitBanks,
|
|
21257
21791
|
...autoBanks
|
|
21258
21792
|
]);
|
|
@@ -21265,16 +21799,16 @@ var MarginfiPositionProvider = class {
|
|
|
21265
21799
|
}
|
|
21266
21800
|
const bank = ref.marginfiBank;
|
|
21267
21801
|
if (bank) {
|
|
21268
|
-
const amount = await (0,
|
|
21802
|
+
const amount = await (0, import_marginfi3.readMarginfiBankBalance)(
|
|
21269
21803
|
client,
|
|
21270
|
-
new
|
|
21271
|
-
new
|
|
21804
|
+
new import_web334.PublicKey(account),
|
|
21805
|
+
new import_web334.PublicKey(bank)
|
|
21272
21806
|
);
|
|
21273
21807
|
out.push({ mint: ref.mint, amount });
|
|
21274
21808
|
} else {
|
|
21275
|
-
const balances = await (0,
|
|
21809
|
+
const balances = await (0, import_marginfi3.readAllMarginfiBalances)(
|
|
21276
21810
|
client,
|
|
21277
|
-
new
|
|
21811
|
+
new import_web334.PublicKey(account)
|
|
21278
21812
|
);
|
|
21279
21813
|
for (const { mint, amount } of balances) {
|
|
21280
21814
|
out.push({ mint: mint.toBase58(), amount });
|
|
@@ -21474,6 +22008,16 @@ var MockYieldTracker = class {
|
|
|
21474
22008
|
}
|
|
21475
22009
|
};
|
|
21476
22010
|
|
|
22011
|
+
// src/services/consensusOracle/runtime/mpcWallets.ts
|
|
22012
|
+
var import_kit16 = require("@solana/kit");
|
|
22013
|
+
var MPC_WALLETS = [
|
|
22014
|
+
{
|
|
22015
|
+
vault: (0, import_kit16.address)("ECJGrTZ6QYMEwiEAnL4oReWF126uc22e9Lojy9qyCjHT"),
|
|
22016
|
+
manager: (0, import_kit16.address)("4jMRBkpWrfhhwFYTwG3o7hmsXQwbJUwdyUX8htB6KwLJ"),
|
|
22017
|
+
wallet: (0, import_kit16.address)("4EXphBhAWcm8NHEENzURiJBPtMPsg2PoXWf95E6sRyfB")
|
|
22018
|
+
}
|
|
22019
|
+
];
|
|
22020
|
+
|
|
21477
22021
|
// src/services/consensusOracle/runtime/liveConsensusOracleDeps.ts
|
|
21478
22022
|
var YIELD_TRACKER_DECIMALS = 6;
|
|
21479
22023
|
function createLiveConsensusOracleDeps(connection, opts = {}) {
|
|
@@ -21482,6 +22026,7 @@ function createLiveConsensusOracleDeps(connection, opts = {}) {
|
|
|
21482
22026
|
const deps = {
|
|
21483
22027
|
priceSource: new LivePriceSource(),
|
|
21484
22028
|
managerWalletBalances: new RpcManagerWalletBalanceSource(connection),
|
|
22029
|
+
mpcWalletBalances: new RpcMpcWalletBalanceSource(connection, MPC_WALLETS),
|
|
21485
22030
|
yieldTracker: {
|
|
21486
22031
|
async getAccountNamesForVault(vault) {
|
|
21487
22032
|
const accounts2 = await getAccounts();
|
|
@@ -21492,7 +22037,19 @@ function createLiveConsensusOracleDeps(connection, opts = {}) {
|
|
|
21492
22037
|
return raw / 10 ** YIELD_TRACKER_DECIMALS;
|
|
21493
22038
|
},
|
|
21494
22039
|
async getTotalTrackedValue(accountNames, start, end) {
|
|
21495
|
-
const tracked = await getTotalTrackedValue(
|
|
22040
|
+
const tracked = await getTotalTrackedValue(
|
|
22041
|
+
accountNames,
|
|
22042
|
+
start,
|
|
22043
|
+
end,
|
|
22044
|
+
(accountName, value) => {
|
|
22045
|
+
const amount = (raw) => `${(raw / 10 ** YIELD_TRACKER_DECIMALS).toFixed(
|
|
22046
|
+
YIELD_TRACKER_DECIMALS
|
|
22047
|
+
)} USDC [raw=${raw}]`;
|
|
22048
|
+
log(
|
|
22049
|
+
` yield tracker account ${JSON.stringify(accountName)} (${value.valuationModel}): value=${amount(value.totalValue)}` + (value.valuationModel === "apr" ? ` principal=${amount(value.principal)} outstandingYield=${amount(value.outstandingYield)}` : "")
|
|
22050
|
+
);
|
|
22051
|
+
}
|
|
22052
|
+
);
|
|
21496
22053
|
return {
|
|
21497
22054
|
totalValue: tracked.totalValue / 10 ** YIELD_TRACKER_DECIMALS,
|
|
21498
22055
|
principal: tracked.principal / 10 ** YIELD_TRACKER_DECIMALS,
|
|
@@ -21515,7 +22072,7 @@ function createLiveConsensusOracleDeps(connection, opts = {}) {
|
|
|
21515
22072
|
}
|
|
21516
22073
|
|
|
21517
22074
|
// src/services/consensusOracle/consensusOracleService.ts
|
|
21518
|
-
var
|
|
22075
|
+
var import_common57 = __toESM(require_dist());
|
|
21519
22076
|
var ConsensusOracleService = class {
|
|
21520
22077
|
constructor(client, deps) {
|
|
21521
22078
|
this.client = client;
|
|
@@ -21551,7 +22108,7 @@ var ConsensusOracleService = class {
|
|
|
21551
22108
|
receiptMints
|
|
21552
22109
|
);
|
|
21553
22110
|
const filteredCount = vaultState.holdings.filter(
|
|
21554
|
-
(holding) => receiptMints.has((0,
|
|
22111
|
+
(holding) => receiptMints.has((0, import_common57.fromWeb3Pk)(holding.mint).toString())
|
|
21555
22112
|
).length;
|
|
21556
22113
|
if (filteredCount > 0) {
|
|
21557
22114
|
log(
|
|
@@ -21591,6 +22148,7 @@ var ConsensusOracleService = class {
|
|
|
21591
22148
|
vaultState,
|
|
21592
22149
|
updates: sourcedUpdates,
|
|
21593
22150
|
source: this.deps.managerWalletBalances,
|
|
22151
|
+
mpcSource: this.deps.mpcWalletBalances,
|
|
21594
22152
|
log
|
|
21595
22153
|
});
|
|
21596
22154
|
const updates = reconciliation.updates;
|
|
@@ -21662,13 +22220,14 @@ var ConsensusOracleService = class {
|
|
|
21662
22220
|
vault: target.vault,
|
|
21663
22221
|
vaultState: freshState,
|
|
21664
22222
|
updates: sourcedUpdates,
|
|
21665
|
-
source: this.deps.managerWalletBalances
|
|
22223
|
+
source: this.deps.managerWalletBalances,
|
|
22224
|
+
mpcSource: this.deps.mpcWalletBalances
|
|
21666
22225
|
});
|
|
21667
22226
|
if (!fresh.accepted || fresh.updates.some(
|
|
21668
|
-
(update, index) => update.externalAmount !== updates[index].externalAmount
|
|
22227
|
+
(update, index) => update.externalAmount !== updates[index].externalAmount || update.managerWalletAmount !== updates[index].managerWalletAmount || update.mpcWalletAmount !== updates[index].mpcWalletAmount || update.mpcMarginfiAmount !== updates[index].mpcMarginfiAmount
|
|
21669
22228
|
)) {
|
|
21670
22229
|
throw new Error(
|
|
21671
|
-
"Manager wallet changed during reconciliation; retry with fresh inputs"
|
|
22230
|
+
"Manager wallet changed or MPC balances changed during reconciliation; retry with fresh inputs"
|
|
21672
22231
|
);
|
|
21673
22232
|
}
|
|
21674
22233
|
} : void 0
|
|
@@ -21770,10 +22329,10 @@ async function runLiveConsensusOracle(env, oracleSigner, opts = {}) {
|
|
|
21770
22329
|
}
|
|
21771
22330
|
|
|
21772
22331
|
// src/services/externalLiquidityIntegrityService.ts
|
|
21773
|
-
var
|
|
21774
|
-
var
|
|
21775
|
-
var
|
|
21776
|
-
var
|
|
22332
|
+
var import_kit17 = require("@solana/kit");
|
|
22333
|
+
var import_web335 = require("@solana/web3.js");
|
|
22334
|
+
var import_common58 = __toESM(require_dist());
|
|
22335
|
+
var import_marginfi4 = __toESM(require_dist2());
|
|
21777
22336
|
var DEFAULT_MIN_AMOUNT_UI = 1;
|
|
21778
22337
|
var DEFAULT_TARGET_LOCAL_BPS = 50;
|
|
21779
22338
|
var DEFAULT_TARGET_LOCAL_USDC_TVL_BPS = 150;
|
|
@@ -21795,7 +22354,7 @@ function parseActiveSlots(externalLiquidity) {
|
|
|
21795
22354
|
if (discriminant === 0) continue;
|
|
21796
22355
|
if (discriminant !== 1) continue;
|
|
21797
22356
|
const pubkeyBytes = new Uint8Array(data.slice(8, 40));
|
|
21798
|
-
const userAccount = (0,
|
|
22357
|
+
const userAccount = (0, import_common58.toAddress)(new import_web335.PublicKey(pubkeyBytes));
|
|
21799
22358
|
results.push({ index: i, source: "marginfi", userAccount });
|
|
21800
22359
|
}
|
|
21801
22360
|
return results;
|
|
@@ -21925,8 +22484,8 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
21925
22484
|
result.skipped++;
|
|
21926
22485
|
return result;
|
|
21927
22486
|
}
|
|
21928
|
-
const hwManagerAddress = (0,
|
|
21929
|
-
const vaultPk = new
|
|
22487
|
+
const hwManagerAddress = (0, import_common58.fromWeb3Pk)(hwManager.publicKey);
|
|
22488
|
+
const vaultPk = new import_web335.PublicKey(vault.toString());
|
|
21930
22489
|
const registeredHwManager = pubkeyStr(
|
|
21931
22490
|
vaultState.roles.hwManager
|
|
21932
22491
|
);
|
|
@@ -21954,13 +22513,13 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
21954
22513
|
continue;
|
|
21955
22514
|
}
|
|
21956
22515
|
for (const holding of holdings) {
|
|
21957
|
-
const mintAddress = (0,
|
|
22516
|
+
const mintAddress = (0, import_kit17.address)(pubkeyStr(holding.mint));
|
|
21958
22517
|
const localAmount = toBigInt3(holding.localAmount);
|
|
21959
22518
|
const externalAmount = toBigInt3(holding.externalAmount);
|
|
21960
22519
|
const decimals = Number(holding.decimals ?? 0);
|
|
21961
22520
|
const minRaw = toRawAmount(minAmountUi, decimals);
|
|
21962
22521
|
let targetLocalAmount;
|
|
21963
|
-
if (mintAddress ===
|
|
22522
|
+
if (mintAddress === import_common58.USDC_MINT) {
|
|
21964
22523
|
const tvl = toBigInt3(vaultState.accounting.tvl);
|
|
21965
22524
|
const price = toBigInt3(holding.price);
|
|
21966
22525
|
const stalenessThreshold = Number(toBigInt3(vaultState.config.priceStalenessThresholdSecs)) || DEFAULT_PRICE_STALENESS_THRESHOLD_SECS;
|
|
@@ -21993,7 +22552,7 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
21993
22552
|
result.skipped++;
|
|
21994
22553
|
continue;
|
|
21995
22554
|
}
|
|
21996
|
-
const marginfiAccounts = (0,
|
|
22555
|
+
const marginfiAccounts = (0, import_marginfi4.marginfiAccountsForMint)(mintAddress);
|
|
21997
22556
|
if (!marginfiAccounts) {
|
|
21998
22557
|
log(
|
|
21999
22558
|
`Vault ${vault} slot ${slot.index}: mint ${mintAddress} has no Marginfi bank configured \u2014 skipping`
|
|
@@ -22060,17 +22619,17 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
22060
22619
|
log = () => {
|
|
22061
22620
|
}
|
|
22062
22621
|
} = params;
|
|
22063
|
-
const marginfiClient = new
|
|
22622
|
+
const marginfiClient = new import_marginfi4.CpiClient({
|
|
22064
22623
|
accounts: marginfiAccounts
|
|
22065
22624
|
});
|
|
22066
|
-
const { getAtaAddress:
|
|
22067
|
-
const vaultAta =
|
|
22625
|
+
const { getAtaAddress: getAtaAddress21 } = await Promise.resolve().then(() => __toESM(require_dist()));
|
|
22626
|
+
const vaultAta = getAtaAddress21(
|
|
22068
22627
|
mintAddress,
|
|
22069
22628
|
vault,
|
|
22070
22629
|
marginfiAccounts.tokenProgram,
|
|
22071
22630
|
true
|
|
22072
22631
|
);
|
|
22073
|
-
const cpiRefs = (0,
|
|
22632
|
+
const cpiRefs = (0, import_common58.createCpiRefs)([
|
|
22074
22633
|
direction === "deposit" ? marginfiClient.deposit_cpi({
|
|
22075
22634
|
marginfiAccount: slot.userAccount,
|
|
22076
22635
|
authority: vault,
|
|
@@ -22121,13 +22680,13 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
22121
22680
|
};
|
|
22122
22681
|
|
|
22123
22682
|
// src/services/idleLiquidityService.ts
|
|
22124
|
-
var
|
|
22125
|
-
var
|
|
22126
|
-
var
|
|
22127
|
-
var
|
|
22128
|
-
var
|
|
22683
|
+
var import_kit18 = require("@solana/kit");
|
|
22684
|
+
var import_spl_token22 = require("@solana/spl-token");
|
|
22685
|
+
var import_marginfi_client_v22 = require("@mrgnlabs/marginfi-client-v2");
|
|
22686
|
+
var import_web336 = require("@solana/web3.js");
|
|
22687
|
+
var import_common59 = __toESM(require_dist());
|
|
22129
22688
|
var import_jupiter2 = __toESM(require_dist4());
|
|
22130
|
-
var
|
|
22689
|
+
var import_marginfi5 = __toESM(require_dist2());
|
|
22131
22690
|
var IDLE_RESERVE_FLOOR_BPS = 400;
|
|
22132
22691
|
var IDLE_RESERVE_TARGET_BPS = 500;
|
|
22133
22692
|
var WITHDRAWABLE_RESERVE_FLOOR_BPS = 150;
|
|
@@ -22220,13 +22779,13 @@ var IdleLiquidityService = class {
|
|
|
22220
22779
|
return { ...base, status: "insufficient-pst", reason };
|
|
22221
22780
|
}
|
|
22222
22781
|
const jupiter = new import_jupiter2.JupiterSwapClient(
|
|
22223
|
-
(0,
|
|
22782
|
+
(0, import_kit18.createSolanaRpc)(this.client.provider.connection.rpcEndpoint)
|
|
22224
22783
|
);
|
|
22225
22784
|
let quote;
|
|
22226
22785
|
try {
|
|
22227
22786
|
quote = await jupiter.getQuote({
|
|
22228
|
-
inputMint:
|
|
22229
|
-
outputMint:
|
|
22787
|
+
inputMint: import_common59.PST_MINT,
|
|
22788
|
+
outputMint: import_common59.USDC_MINT,
|
|
22230
22789
|
amount: pstInput,
|
|
22231
22790
|
slippageBps: opts.slippageBps ?? DEFAULT_SLIPPAGE_BPS,
|
|
22232
22791
|
maxAccounts: DEFAULT_MAX_ACCOUNTS
|
|
@@ -22272,13 +22831,13 @@ var IdleLiquidityService = class {
|
|
|
22272
22831
|
/** Read only the two locations that constitute the idle USDC reserve. */
|
|
22273
22832
|
async fetchIdleUsdc(vault, vaultState) {
|
|
22274
22833
|
const connection = this.client.provider.connection;
|
|
22275
|
-
const vaultPk = new
|
|
22276
|
-
const usdcMint = new
|
|
22277
|
-
const ata = (0,
|
|
22834
|
+
const vaultPk = new import_web336.PublicKey(vault);
|
|
22835
|
+
const usdcMint = new import_web336.PublicKey(import_common59.USDC_MINT);
|
|
22836
|
+
const ata = (0, import_spl_token22.getAssociatedTokenAddressSync)(usdcMint, vaultPk, true);
|
|
22278
22837
|
const tokenInfo = await connection.getAccountInfo(ata, "confirmed");
|
|
22279
22838
|
let localAmount = 0n;
|
|
22280
22839
|
if (tokenInfo) {
|
|
22281
|
-
const tokenAccount = (0,
|
|
22840
|
+
const tokenAccount = (0, import_spl_token22.unpackAccount)(ata, tokenInfo, import_spl_token22.TOKEN_PROGRAM_ID);
|
|
22282
22841
|
if (!tokenAccount.mint.equals(usdcMint) || !tokenAccount.owner.equals(vaultPk) || !tokenAccount.isInitialized) {
|
|
22283
22842
|
throw new Error(`Invalid vault USDC token account: ${ata.toBase58()}`);
|
|
22284
22843
|
}
|
|
@@ -22299,21 +22858,21 @@ var IdleLiquidityService = class {
|
|
|
22299
22858
|
if (data.length < 40) {
|
|
22300
22859
|
throw new Error(`Invalid Project0 external-liquidity slot ${slotIndex}`);
|
|
22301
22860
|
}
|
|
22302
|
-
const positionPk = new
|
|
22861
|
+
const positionPk = new import_web336.PublicKey(new Uint8Array(data.slice(8, 40)));
|
|
22303
22862
|
const positionInfo = await connection.getAccountInfo(
|
|
22304
22863
|
positionPk,
|
|
22305
22864
|
"confirmed"
|
|
22306
22865
|
);
|
|
22307
|
-
if (!positionInfo || !positionInfo.owner.equals(new
|
|
22866
|
+
if (!positionInfo || !positionInfo.owner.equals(new import_web336.PublicKey(import_marginfi5.MARGINFI_PROGRAM_ID))) {
|
|
22308
22867
|
throw new Error(
|
|
22309
22868
|
`Invalid Project0 slot-${slotIndex} account: ${positionPk.toBase58()}`
|
|
22310
22869
|
);
|
|
22311
22870
|
}
|
|
22312
|
-
const marginfi = await (0,
|
|
22871
|
+
const marginfi = await (0, import_marginfi5.createMarginfiReadClient)(
|
|
22313
22872
|
connection,
|
|
22314
|
-
(0,
|
|
22873
|
+
(0, import_marginfi5.parseBankPksFromMarginfiAccount)(positionInfo.data)
|
|
22315
22874
|
);
|
|
22316
|
-
const position = await
|
|
22875
|
+
const position = await import_marginfi_client_v22.MarginfiAccountWrapper.fetch(positionPk, marginfi);
|
|
22317
22876
|
if (!position.authority.equals(vaultPk)) {
|
|
22318
22877
|
throw new Error(`Project0 slot-${slotIndex} authority is not the vault`);
|
|
22319
22878
|
}
|
|
@@ -22368,8 +22927,8 @@ var IdleLiquidityService = class {
|
|
|
22368
22927
|
log(`Vault ${vault}: ${reason} \u2014 skipping`);
|
|
22369
22928
|
return { result: { ...empty, status: "no-tvl", reason } };
|
|
22370
22929
|
}
|
|
22371
|
-
const usdc = findHolding2(vaultState,
|
|
22372
|
-
const pst = findHolding2(vaultState,
|
|
22930
|
+
const usdc = findHolding2(vaultState, import_common59.USDC_MINT);
|
|
22931
|
+
const pst = findHolding2(vaultState, import_common59.PST_MINT);
|
|
22373
22932
|
if (!usdc || !pst) {
|
|
22374
22933
|
const reason = `vault has no ${usdc ? "PST" : "USDC"} holding`;
|
|
22375
22934
|
log(`Vault ${vault}: ${reason} \u2014 skipping`);
|
|
@@ -22517,16 +23076,16 @@ var IdleLiquidityService = class {
|
|
|
22517
23076
|
*/
|
|
22518
23077
|
async mintTokenProgram(mint) {
|
|
22519
23078
|
const account = await this.client.provider.connection.getAccountInfo(
|
|
22520
|
-
new
|
|
23079
|
+
new import_web336.PublicKey(mint),
|
|
22521
23080
|
"confirmed"
|
|
22522
23081
|
);
|
|
22523
23082
|
if (!account) throw new Error(`Mint account not found: ${mint}`);
|
|
22524
|
-
if (!account.owner.equals(
|
|
23083
|
+
if (!account.owner.equals(import_spl_token22.TOKEN_PROGRAM_ID) && !account.owner.equals(import_spl_token22.TOKEN_2022_PROGRAM_ID)) {
|
|
22525
23084
|
throw new Error(
|
|
22526
23085
|
`Unsupported token program ${account.owner.toBase58()} for mint ${mint}`
|
|
22527
23086
|
);
|
|
22528
23087
|
}
|
|
22529
|
-
return (0,
|
|
23088
|
+
return (0, import_common59.fromWeb3Pk)(account.owner);
|
|
22530
23089
|
}
|
|
22531
23090
|
/**
|
|
22532
23091
|
* Build, simulate, and (unless `dryRun`) submit the `jupiter_swap`.
|
|
@@ -22546,23 +23105,23 @@ var IdleLiquidityService = class {
|
|
|
22546
23105
|
dryRun,
|
|
22547
23106
|
log
|
|
22548
23107
|
} = params;
|
|
22549
|
-
const signer = (0,
|
|
23108
|
+
const signer = (0, import_common59.fromWeb3Pk)(hwManager.publicKey);
|
|
22550
23109
|
const [sourceTokenProgram, destinationTokenProgram] = await Promise.all([
|
|
22551
|
-
this.mintTokenProgram(
|
|
22552
|
-
this.mintTokenProgram(
|
|
23110
|
+
this.mintTokenProgram(import_common59.PST_MINT),
|
|
23111
|
+
this.mintTokenProgram(import_common59.USDC_MINT)
|
|
22553
23112
|
]);
|
|
22554
23113
|
const jupiterCpi = await jupiter.getSwapCpiData(quote, vault, {
|
|
22555
23114
|
payer: signer
|
|
22556
23115
|
});
|
|
22557
|
-
const { accounts: accounts2, refs, lookupTables } = (0,
|
|
23116
|
+
const { accounts: accounts2, refs, lookupTables } = (0, import_common59.createCpiRefs)([jupiterCpi]);
|
|
22558
23117
|
const vaultTrancheState = coerceBool4(
|
|
22559
23118
|
vaultState.tranchingEnabled
|
|
22560
23119
|
) ? (await this.client.pda.deriveVaultTrancheStatePda(vault))[0] : void 0;
|
|
22561
23120
|
const plan = await this.client.tx.jupiterSwap.getTx({
|
|
22562
23121
|
hwManager: signer,
|
|
22563
23122
|
vault,
|
|
22564
|
-
sourceMint:
|
|
22565
|
-
destinationMint:
|
|
23123
|
+
sourceMint: import_common59.PST_MINT,
|
|
23124
|
+
destinationMint: import_common59.USDC_MINT,
|
|
22566
23125
|
refs,
|
|
22567
23126
|
accounts: accounts2,
|
|
22568
23127
|
sourceTokenProgram,
|
|
@@ -22572,26 +23131,26 @@ var IdleLiquidityService = class {
|
|
|
22572
23131
|
});
|
|
22573
23132
|
const connection = this.client.provider.connection;
|
|
22574
23133
|
const instructions2 = [
|
|
22575
|
-
|
|
23134
|
+
import_web336.ComputeBudgetProgram.setComputeUnitLimit({ units: COMPUTE_UNIT_LIMIT }),
|
|
22576
23135
|
...cuPriceMicroLamports > 0 ? [
|
|
22577
|
-
|
|
23136
|
+
import_web336.ComputeBudgetProgram.setComputeUnitPrice({
|
|
22578
23137
|
microLamports: cuPriceMicroLamports
|
|
22579
23138
|
})
|
|
22580
23139
|
] : [],
|
|
22581
|
-
...(jupiterCpi.preInstructions ?? []).map(
|
|
22582
|
-
...plan.instructions.map(
|
|
23140
|
+
...(jupiterCpi.preInstructions ?? []).map(import_common59.fromKitInstruction),
|
|
23141
|
+
...plan.instructions.map(import_common59.fromKitInstruction)
|
|
22583
23142
|
];
|
|
22584
23143
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
|
|
22585
|
-
const lookupTableAccounts = await (0,
|
|
23144
|
+
const lookupTableAccounts = await (0, import_common59.fetchLookupTables)(
|
|
22586
23145
|
connection,
|
|
22587
23146
|
plan.lookupTables ?? []
|
|
22588
23147
|
);
|
|
22589
|
-
const message2 = new
|
|
23148
|
+
const message2 = new import_web336.TransactionMessage({
|
|
22590
23149
|
payerKey: hwManager.publicKey,
|
|
22591
23150
|
recentBlockhash: blockhash,
|
|
22592
23151
|
instructions: instructions2
|
|
22593
23152
|
}).compileToV0Message(lookupTableAccounts);
|
|
22594
|
-
const transaction = new
|
|
23153
|
+
const transaction = new import_web336.VersionedTransaction(message2);
|
|
22595
23154
|
transaction.sign([hwManager]);
|
|
22596
23155
|
if (!this.client.skipSimulation) {
|
|
22597
23156
|
const simulation = await connection.simulateTransaction(transaction, {
|
|
@@ -22636,10 +23195,10 @@ var IdleLiquidityService = class {
|
|
|
22636
23195
|
};
|
|
22637
23196
|
|
|
22638
23197
|
// src/services/timelockSettlementService.ts
|
|
22639
|
-
var
|
|
22640
|
-
var
|
|
22641
|
-
var
|
|
22642
|
-
var ZERO_PUBKEY =
|
|
23198
|
+
var import_kit19 = require("@solana/kit");
|
|
23199
|
+
var import_web337 = require("@solana/web3.js");
|
|
23200
|
+
var import_common60 = __toESM(require_dist());
|
|
23201
|
+
var ZERO_PUBKEY = import_web337.PublicKey.default.toBase58();
|
|
22643
23202
|
var CONSENSUS_SIGNER_CAPACITY = 4;
|
|
22644
23203
|
var CONSENSUS_ENTRY_OFFSET = 40;
|
|
22645
23204
|
var CONSENSUS_ENTRY_SIZE = 272;
|
|
@@ -22679,11 +23238,11 @@ function decodePendingConsensusSigners(data) {
|
|
|
22679
23238
|
const signers = [];
|
|
22680
23239
|
for (let i = 0; i < count; i += 1) {
|
|
22681
23240
|
const start = CONSENSUS_PENDING_OFFSET + i * 32;
|
|
22682
|
-
const signer = new
|
|
23241
|
+
const signer = new import_web337.PublicKey(bytes.slice(start, start + 32)).toBase58();
|
|
22683
23242
|
if (signer === ZERO_PUBKEY) {
|
|
22684
23243
|
throw new Error(`pending consensus signer ${i} is unset`);
|
|
22685
23244
|
}
|
|
22686
|
-
signers.push((0,
|
|
23245
|
+
signers.push((0, import_kit19.address)(signer));
|
|
22687
23246
|
}
|
|
22688
23247
|
return {
|
|
22689
23248
|
signers,
|
|
@@ -22711,7 +23270,7 @@ function pendingDestinationSettlement(state, now) {
|
|
|
22711
23270
|
const effectiveTs = integer(pending.effectiveTs);
|
|
22712
23271
|
return {
|
|
22713
23272
|
slot: integer(pending.slot),
|
|
22714
|
-
destination: (0,
|
|
23273
|
+
destination: (0, import_kit19.address)(destination),
|
|
22715
23274
|
effectiveTs,
|
|
22716
23275
|
expired: now >= effectiveTs
|
|
22717
23276
|
};
|
|
@@ -22735,7 +23294,7 @@ var TimelockSettlementService = class {
|
|
|
22735
23294
|
});
|
|
22736
23295
|
const dryRun = opts.dryRun ?? false;
|
|
22737
23296
|
const now = opts.now ?? await this.chainTime();
|
|
22738
|
-
const fulfillerAddress = (0,
|
|
23297
|
+
const fulfillerAddress = (0, import_common60.fromWeb3Pk)(fulfiller.publicKey);
|
|
22739
23298
|
const allVaults = opts.vault ? [
|
|
22740
23299
|
{
|
|
22741
23300
|
publicKey: opts.vault,
|
|
@@ -22877,19 +23436,19 @@ var TimelockSettlementService = class {
|
|
|
22877
23436
|
};
|
|
22878
23437
|
|
|
22879
23438
|
// src/services/nestWithdrawalService.ts
|
|
22880
|
-
var
|
|
22881
|
-
var
|
|
22882
|
-
var
|
|
22883
|
-
var
|
|
23439
|
+
var import_kit20 = require("@solana/kit");
|
|
23440
|
+
var import_spl_token23 = require("@solana/spl-token");
|
|
23441
|
+
var import_web338 = require("@solana/web3.js");
|
|
23442
|
+
var import_common61 = __toESM(require_dist());
|
|
22884
23443
|
var import_nest3 = __toESM(require_dist3());
|
|
22885
23444
|
var import_nest4 = __toESM(require_dist3());
|
|
22886
|
-
var NestOftProgram = new
|
|
23445
|
+
var NestOftProgram = new import_web338.PublicKey(
|
|
22887
23446
|
"ChEfPd3RzLeYiRwp1K9evimmaFSd6DV1S4Mv5q5Aj1th"
|
|
22888
23447
|
);
|
|
22889
|
-
var NestOftStore = new
|
|
23448
|
+
var NestOftStore = new import_web338.PublicKey(
|
|
22890
23449
|
"k8mJj8Gyw2gFAqut21AFVUUZhxb4RVDMnb4PrSYiDhV"
|
|
22891
23450
|
);
|
|
22892
|
-
var UsdcMint = new
|
|
23451
|
+
var UsdcMint = new import_web338.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
|
|
22893
23452
|
var NestPerenaComposer = Buffer.from(
|
|
22894
23453
|
"000000000000000000000000908dcb5531691c2124c54e30bb645cf11647090d",
|
|
22895
23454
|
"hex"
|
|
@@ -22906,7 +23465,7 @@ async function buildNestWithdrawalRequest(args) {
|
|
|
22906
23465
|
return decodeNestWithdrawalRequest({ ...args, txBase64 });
|
|
22907
23466
|
}
|
|
22908
23467
|
async function decodeNestWithdrawalRequest(args) {
|
|
22909
|
-
const transaction =
|
|
23468
|
+
const transaction = import_web338.VersionedTransaction.deserialize(
|
|
22910
23469
|
Buffer.from(args.txBase64, "base64")
|
|
22911
23470
|
);
|
|
22912
23471
|
const message2 = transaction.message;
|
|
@@ -22927,19 +23486,19 @@ async function decodeNestWithdrawalRequest(args) {
|
|
|
22927
23486
|
return value;
|
|
22928
23487
|
})
|
|
22929
23488
|
);
|
|
22930
|
-
const decoded =
|
|
23489
|
+
const decoded = import_web338.TransactionMessage.decompile(message2, {
|
|
22931
23490
|
addressLookupTableAccounts: tables
|
|
22932
23491
|
});
|
|
22933
|
-
const nestMint = new
|
|
22934
|
-
const sourceAta = (0,
|
|
22935
|
-
const usdcAta = (0,
|
|
23492
|
+
const nestMint = new import_web338.PublicKey(NEST_RWA_SHARE_MINT);
|
|
23493
|
+
const sourceAta = (0, import_spl_token23.getAssociatedTokenAddressSync)(nestMint, args.owner, true);
|
|
23494
|
+
const usdcAta = (0, import_spl_token23.getAssociatedTokenAddressSync)(UsdcMint, args.owner, true);
|
|
22936
23495
|
const instructions2 = decoded.instructions.filter(
|
|
22937
|
-
(ix) => !ix.programId.equals(
|
|
23496
|
+
(ix) => !ix.programId.equals(import_web338.ComputeBudgetProgram.programId)
|
|
22938
23497
|
);
|
|
22939
23498
|
let sends = 0;
|
|
22940
23499
|
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(
|
|
23500
|
+
if (ix.programId.equals(import_spl_token23.ASSOCIATED_TOKEN_PROGRAM_ID)) {
|
|
23501
|
+
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
23502
|
throw new Error("Unexpected token account creation in Nest withdrawal");
|
|
22944
23503
|
}
|
|
22945
23504
|
continue;
|
|
@@ -22956,20 +23515,20 @@ async function decodeNestWithdrawalRequest(args) {
|
|
|
22956
23515
|
if (sends !== 1)
|
|
22957
23516
|
throw new Error("Nest withdrawal must contain exactly one OFT send");
|
|
22958
23517
|
return {
|
|
22959
|
-
instructions: instructions2.map(
|
|
22960
|
-
lookupTables: tables.map((table) => (0,
|
|
23518
|
+
instructions: instructions2.map(import_common61.toKitInstruction),
|
|
23519
|
+
lookupTables: tables.map((table) => (0, import_kit20.address)(table.key.toBase58()))
|
|
22961
23520
|
};
|
|
22962
23521
|
}
|
|
22963
23522
|
|
|
22964
23523
|
// src/services/nestDepositService.ts
|
|
22965
|
-
var
|
|
22966
|
-
var
|
|
22967
|
-
var
|
|
22968
|
-
var
|
|
23524
|
+
var import_kit21 = require("@solana/kit");
|
|
23525
|
+
var import_spl_token24 = require("@solana/spl-token");
|
|
23526
|
+
var import_web339 = require("@solana/web3.js");
|
|
23527
|
+
var import_common62 = __toESM(require_dist());
|
|
22969
23528
|
var import_nest5 = __toESM(require_dist3());
|
|
22970
|
-
var Usdc = new
|
|
22971
|
-
var Messenger = new
|
|
22972
|
-
var Transmitter = new
|
|
23529
|
+
var Usdc = new import_web339.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
|
|
23530
|
+
var Messenger = new import_web339.PublicKey("CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe");
|
|
23531
|
+
var Transmitter = new import_web339.PublicKey(
|
|
22973
23532
|
"CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC"
|
|
22974
23533
|
);
|
|
22975
23534
|
var Router = Buffer.from(
|
|
@@ -23022,7 +23581,7 @@ async function decodeNestDepositRequest(args) {
|
|
|
23022
23581
|
"Nest deposit must be a positive, safely representable USDC base-unit amount"
|
|
23023
23582
|
);
|
|
23024
23583
|
}
|
|
23025
|
-
const message2 =
|
|
23584
|
+
const message2 = import_web339.VersionedTransaction.deserialize(
|
|
23026
23585
|
Buffer.from(args.txBase64, "base64")
|
|
23027
23586
|
).message;
|
|
23028
23587
|
if (!message2.staticAccountKeys[0].equals(args.owner))
|
|
@@ -23037,23 +23596,23 @@ async function decodeNestDepositRequest(args) {
|
|
|
23037
23596
|
return value;
|
|
23038
23597
|
})
|
|
23039
23598
|
);
|
|
23040
|
-
const instructions2 =
|
|
23599
|
+
const instructions2 = import_web339.TransactionMessage.decompile(message2, {
|
|
23041
23600
|
addressLookupTableAccounts: tables
|
|
23042
23601
|
}).instructions;
|
|
23043
|
-
const shareMint = new
|
|
23044
|
-
const shareAta = (0,
|
|
23045
|
-
const usdcAta = (0,
|
|
23602
|
+
const shareMint = new import_web339.PublicKey(NEST_RWA_SHARE_MINT);
|
|
23603
|
+
const shareAta = (0, import_spl_token24.getAssociatedTokenAddressSync)(shareMint, args.owner, true);
|
|
23604
|
+
const usdcAta = (0, import_spl_token24.getAssociatedTokenAddressSync)(Usdc, args.owner, true);
|
|
23046
23605
|
let burn;
|
|
23047
23606
|
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(
|
|
23607
|
+
if (ix.programId.equals(import_web339.ComputeBudgetProgram.programId)) continue;
|
|
23608
|
+
if (ix.programId.equals(import_spl_token24.ASSOCIATED_TOKEN_PROGRAM_ID)) {
|
|
23609
|
+
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
23610
|
throw new Error("Unexpected Nest deposit token account creation");
|
|
23052
23611
|
continue;
|
|
23053
23612
|
}
|
|
23054
23613
|
const d = ix.data;
|
|
23055
23614
|
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,
|
|
23615
|
+
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
23616
|
(meta, index) => meta.isSigner && ![0, 1, 11].includes(index)
|
|
23058
23617
|
)) {
|
|
23059
23618
|
throw new Error(
|
|
@@ -23072,21 +23631,21 @@ async function decodeNestDepositRequest(args) {
|
|
|
23072
23631
|
burn.keys[1] = { pubkey: args.owner, isSigner: true, isWritable: true };
|
|
23073
23632
|
return {
|
|
23074
23633
|
instructions: [
|
|
23075
|
-
(0,
|
|
23634
|
+
(0, import_spl_token24.createAssociatedTokenAccountIdempotentInstruction)(
|
|
23076
23635
|
args.owner,
|
|
23077
23636
|
shareAta,
|
|
23078
23637
|
args.owner,
|
|
23079
23638
|
shareMint
|
|
23080
23639
|
),
|
|
23081
23640
|
burn
|
|
23082
|
-
].map(
|
|
23083
|
-
lookupTables: tables.map((table) => (0,
|
|
23641
|
+
].map(import_common62.toKitInstruction),
|
|
23642
|
+
lookupTables: tables.map((table) => (0, import_kit21.address)(table.key.toBase58())),
|
|
23084
23643
|
ephemeralSignerKeys: [eventKey]
|
|
23085
23644
|
};
|
|
23086
23645
|
}
|
|
23087
23646
|
|
|
23088
23647
|
// src/index.ts
|
|
23089
|
-
var
|
|
23648
|
+
var import_common63 = __toESM(require_dist());
|
|
23090
23649
|
// Annotate the CommonJS export names for ESM import in node:
|
|
23091
23650
|
0 && (module.exports = {
|
|
23092
23651
|
ASSET_DECIMALS,
|
|
@@ -23126,6 +23685,7 @@ var import_common62 = __toESM(require_dist());
|
|
|
23126
23685
|
DEFAULT_TARGET_LOCAL_BPS,
|
|
23127
23686
|
DEFAULT_TARGET_LOCAL_USDC_TVL_BPS,
|
|
23128
23687
|
DEFAULT_VAULT_ID,
|
|
23688
|
+
DepositCuratorFeesBuilder,
|
|
23129
23689
|
DisableCircuitBreakerBuilder,
|
|
23130
23690
|
DistributeIncentiveBuilder,
|
|
23131
23691
|
DistributeIncentiveV3Builder,
|
|
@@ -23155,6 +23715,7 @@ var import_common62 = __toESM(require_dist());
|
|
|
23155
23715
|
MANAGER_WALLET_NAV_DROP_TRIGGER_BPS,
|
|
23156
23716
|
MANAGER_WALLET_NAV_TOLERANCE_BPS,
|
|
23157
23717
|
MAX_APY_ANCHOR_WINDOW_SECS,
|
|
23718
|
+
MAX_APY_PREVIOUS_ANCHOR_AGE_SECS,
|
|
23158
23719
|
MAX_BALANCE_CHANGE_BPS,
|
|
23159
23720
|
MAX_CONSENSUS_SIGNERS,
|
|
23160
23721
|
MAX_INCENTIVE_RECIPIENTS,
|
|
@@ -23187,6 +23748,7 @@ var import_common62 = __toESM(require_dist());
|
|
|
23187
23748
|
ReportIncentiveV3Builder,
|
|
23188
23749
|
RequestJuniorTrancheWithdrawBuilder,
|
|
23189
23750
|
RpcManagerWalletBalanceSource,
|
|
23751
|
+
RpcMpcWalletBalanceSource,
|
|
23190
23752
|
SHARE_DECIMALS,
|
|
23191
23753
|
SYSTEM_PROGRAM,
|
|
23192
23754
|
SetAssetPriceOracleBuilder,
|
|
@@ -23309,6 +23871,7 @@ var import_common62 = __toESM(require_dist());
|
|
|
23309
23871
|
prepareVaultTransaction,
|
|
23310
23872
|
previousPhysicalNav,
|
|
23311
23873
|
priceInAccountingUnit,
|
|
23874
|
+
publishedConsensusBlockers,
|
|
23312
23875
|
readI64LE,
|
|
23313
23876
|
readSplMintSupply,
|
|
23314
23877
|
reconcileManagerWalletBalances,
|