@perena/vault-sdk 1.0.69 → 1.0.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -30
- package/dist/index.d.ts +37 -18
- package/dist/index.js +658 -643
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -156,7 +156,7 @@ var require_compat = __commonJS({
|
|
|
156
156
|
exports2.fromWeb3PublicKey = fromWeb3PublicKey;
|
|
157
157
|
exports2.toWeb3PublicKey = toWeb3PublicKey;
|
|
158
158
|
exports2.asWeb3PublicKey = asWeb3PublicKey2;
|
|
159
|
-
exports2.toKitInstruction =
|
|
159
|
+
exports2.toKitInstruction = toKitInstruction43;
|
|
160
160
|
exports2.fromKitInstruction = fromKitInstruction3;
|
|
161
161
|
var kit_1 = require("@solana/kit");
|
|
162
162
|
var web3_js_1 = require("@solana/web3.js");
|
|
@@ -172,7 +172,7 @@ var require_compat = __commonJS({
|
|
|
172
172
|
exports2.toAddress = fromWeb3PublicKey;
|
|
173
173
|
exports2.fromWeb3Pk = fromWeb3PublicKey;
|
|
174
174
|
exports2.toWeb3Pk = toWeb3PublicKey;
|
|
175
|
-
function
|
|
175
|
+
function toKitInstruction43(ix) {
|
|
176
176
|
return {
|
|
177
177
|
programAddress: ix.programId.toBase58(),
|
|
178
178
|
data: new Uint8Array(ix.data),
|
|
@@ -2048,7 +2048,6 @@ var index_exports = {};
|
|
|
2048
2048
|
__export(index_exports, {
|
|
2049
2049
|
ASSET_DECIMALS: () => ASSET_DECIMALS,
|
|
2050
2050
|
ASSET_REBALANCE_COOLDOWN_SECS: () => ASSET_REBALANCE_COOLDOWN_SECS,
|
|
2051
|
-
ASYNC_REDEMPTION_CANCEL_DELAY_SECS: () => ASYNC_REDEMPTION_CANCEL_DELAY_SECS,
|
|
2052
2051
|
AccountClient: () => AccountClient,
|
|
2053
2052
|
ActivateCircuitBreakerBuilder: () => ActivateCircuitBreakerBuilder,
|
|
2054
2053
|
AddIncentiveRecipientBuilder: () => AddIncentiveRecipientBuilder,
|
|
@@ -2075,7 +2074,7 @@ __export(index_exports, {
|
|
|
2075
2074
|
DEFAULT_JUNIOR_WITHDRAWAL_LOCKUP_SECS: () => DEFAULT_JUNIOR_WITHDRAWAL_LOCKUP_SECS,
|
|
2076
2075
|
DEFAULT_MARGINFI_WEIGHT_BPS: () => DEFAULT_MARGINFI_WEIGHT_BPS,
|
|
2077
2076
|
DEFAULT_MAX_ACCEPTABLE_APY_BPS: () => DEFAULT_MAX_ACCEPTABLE_APY_BPS,
|
|
2078
|
-
DEFAULT_MINTS: () =>
|
|
2077
|
+
DEFAULT_MINTS: () => import_common71.DEFAULT_MINTS,
|
|
2079
2078
|
DEFAULT_MIN_AMOUNT_UI: () => DEFAULT_MIN_AMOUNT_UI,
|
|
2080
2079
|
DEFAULT_ORACLE_STALENESS_THRESHOLD_SECS: () => DEFAULT_ORACLE_STALENESS_THRESHOLD_SECS,
|
|
2081
2080
|
DEFAULT_PRICE_ORACLE_ACCOUNT: () => DEFAULT_PRICE_ORACLE_ACCOUNT,
|
|
@@ -2131,7 +2130,7 @@ __export(index_exports, {
|
|
|
2131
2130
|
ManagerRedepositAssetBuilder: () => ManagerRedepositAssetBuilder,
|
|
2132
2131
|
ManagerWithdrawAssetBuilder: () => ManagerWithdrawAssetBuilder,
|
|
2133
2132
|
MarginfiPositionProvider: () => MarginfiPositionProvider,
|
|
2134
|
-
MintRegistry: () =>
|
|
2133
|
+
MintRegistry: () => import_common71.MintRegistry,
|
|
2135
2134
|
MockYieldTracker: () => MockYieldTracker,
|
|
2136
2135
|
NEST_API_BASE_URL: () => import_nest2.NEST_API_BASE_URL,
|
|
2137
2136
|
NEST_RWA_SHARE_MINT: () => NEST_RWA_SHARE_MINT,
|
|
@@ -2237,7 +2236,6 @@ __export(index_exports, {
|
|
|
2237
2236
|
defaultKeypairPath: () => defaultKeypairPath,
|
|
2238
2237
|
deleteAccount: () => deleteAccount,
|
|
2239
2238
|
discoverVaultsForSigner: () => discoverVaultsForSigner,
|
|
2240
|
-
externalWithdrawComputeBudget: () => externalWithdrawComputeBudget,
|
|
2241
2239
|
externalWithdrawLookupTables: () => externalWithdrawLookupTables,
|
|
2242
2240
|
fetchExternalPositions: () => fetchExternalPositions,
|
|
2243
2241
|
fetchNestRedemptionQuote: () => import_nest4.fetchNestRedemptionQuote,
|
|
@@ -2287,7 +2285,7 @@ __export(index_exports, {
|
|
|
2287
2285
|
makeProvider: () => makeProvider,
|
|
2288
2286
|
managerReconciliationStateKey: () => managerReconciliationStateKey,
|
|
2289
2287
|
mintTokensTo: () => mintTokensTo,
|
|
2290
|
-
mints: () =>
|
|
2288
|
+
mints: () => import_common71.mints,
|
|
2291
2289
|
mostFrequent: () => mostFrequent,
|
|
2292
2290
|
parseExternalLiquidityRefs: () => parseExternalLiquidityRefs,
|
|
2293
2291
|
planExternalAllocation: () => planExternalAllocation,
|
|
@@ -2333,8 +2331,7 @@ __export(index_exports, {
|
|
|
2333
2331
|
vaultAuthorityForWallet: () => vaultAuthorityForWallet,
|
|
2334
2332
|
walletReconciliationGuardUpdates: () => walletReconciliationGuardUpdates,
|
|
2335
2333
|
withDiscoveredYieldAccounts: () => withDiscoveredYieldAccounts,
|
|
2336
|
-
withVaultLookupTables: () => withVaultLookupTables
|
|
2337
|
-
withdrawalComputeBudget: () => withdrawalComputeBudget
|
|
2334
|
+
withVaultLookupTables: () => withVaultLookupTables
|
|
2338
2335
|
});
|
|
2339
2336
|
module.exports = __toCommonJS(index_exports);
|
|
2340
2337
|
|
|
@@ -2387,7 +2384,6 @@ var MAX_PRICE_STALENESS_THRESHOLD_SECS = 7 * 24 * 60 * 60;
|
|
|
2387
2384
|
var DEFAULT_VAULT_ID = 0;
|
|
2388
2385
|
var DEFAULT_MAX_ACCEPTABLE_APY_BPS = 1e4;
|
|
2389
2386
|
var DEFAULT_JUNIOR_WITHDRAWAL_LOCKUP_SECS = 7 * 24 * 60 * 60;
|
|
2390
|
-
var ASYNC_REDEMPTION_CANCEL_DELAY_SECS = 30 * 24 * 60 * 60;
|
|
2391
2387
|
var DEFAULT_JUNIOR_EARLY_UNSTAKE_FEE_BPS = 100;
|
|
2392
2388
|
var DEFAULT_JUNIOR_STANDARD_UNSTAKE_FEE_BPS = 50;
|
|
2393
2389
|
var USDC_MINT = (0, import_kit.address)(
|
|
@@ -2440,15 +2436,15 @@ var import_fs = __toESM(require("fs"));
|
|
|
2440
2436
|
var import_os = __toESM(require("os"));
|
|
2441
2437
|
var import_path = __toESM(require("path"));
|
|
2442
2438
|
var import_core23 = require("@anchor-lang/core");
|
|
2443
|
-
var
|
|
2439
|
+
var import_web330 = require("@solana/web3.js");
|
|
2444
2440
|
var import_kit11 = require("@solana/kit");
|
|
2445
|
-
var
|
|
2441
|
+
var import_common50 = __toESM(require_dist());
|
|
2446
2442
|
|
|
2447
2443
|
// src/client/client.ts
|
|
2448
2444
|
var import_core22 = require("@anchor-lang/core");
|
|
2449
2445
|
var import_kit10 = require("@solana/kit");
|
|
2450
|
-
var
|
|
2451
|
-
var
|
|
2446
|
+
var import_web329 = require("@solana/web3.js");
|
|
2447
|
+
var import_common49 = __toESM(require_dist());
|
|
2452
2448
|
|
|
2453
2449
|
// src/idl/vault.ts
|
|
2454
2450
|
var IDL = {
|
|
@@ -11657,7 +11653,8 @@ var IDL = {
|
|
|
11657
11653
|
{
|
|
11658
11654
|
"name": "RedemptionMode",
|
|
11659
11655
|
"docs": [
|
|
11660
|
-
"Redemption policy for regular vault shares. Zero preserves existing vault behavior."
|
|
11656
|
+
"Redemption policy for regular vault shares. Zero preserves existing vault behavior.",
|
|
11657
|
+
"Numeric layout is part of the account and instruction formats; only append variants."
|
|
11661
11658
|
],
|
|
11662
11659
|
"repr": {
|
|
11663
11660
|
"kind": "rust"
|
|
@@ -11670,6 +11667,9 @@ var IDL = {
|
|
|
11670
11667
|
},
|
|
11671
11668
|
{
|
|
11672
11669
|
"name": "AsyncOnly"
|
|
11670
|
+
},
|
|
11671
|
+
{
|
|
11672
|
+
"name": "Hybrid"
|
|
11673
11673
|
}
|
|
11674
11674
|
]
|
|
11675
11675
|
}
|
|
@@ -12146,6 +12146,15 @@ var IDL = {
|
|
|
12146
12146
|
}
|
|
12147
12147
|
}
|
|
12148
12148
|
}
|
|
12149
|
+
},
|
|
12150
|
+
{
|
|
12151
|
+
"name": "redemption_period_secs",
|
|
12152
|
+
"docs": [
|
|
12153
|
+
"Minimum delay in seconds for new regular-share async requests. Zero disables the delay."
|
|
12154
|
+
],
|
|
12155
|
+
"type": {
|
|
12156
|
+
"option": "i64"
|
|
12157
|
+
}
|
|
12149
12158
|
}
|
|
12150
12159
|
]
|
|
12151
12160
|
}
|
|
@@ -12804,12 +12813,19 @@ var IDL = {
|
|
|
12804
12813
|
],
|
|
12805
12814
|
"type": "u64"
|
|
12806
12815
|
},
|
|
12816
|
+
{
|
|
12817
|
+
"name": "redemption_period_secs",
|
|
12818
|
+
"docs": [
|
|
12819
|
+
"Minimum delay for new regular-share async withdrawals; zero allows immediate settlement."
|
|
12820
|
+
],
|
|
12821
|
+
"type": "i64"
|
|
12822
|
+
},
|
|
12807
12823
|
{
|
|
12808
12824
|
"name": "_padding3",
|
|
12809
12825
|
"type": {
|
|
12810
12826
|
"array": [
|
|
12811
12827
|
"u64",
|
|
12812
|
-
|
|
12828
|
+
20
|
|
12813
12829
|
]
|
|
12814
12830
|
}
|
|
12815
12831
|
}
|
|
@@ -15756,6 +15772,7 @@ function toAnchorSetVaultConfigArgs(args) {
|
|
|
15756
15772
|
tvlLimit: args.tvlLimit,
|
|
15757
15773
|
lossesEnabled: args.lossesEnabled,
|
|
15758
15774
|
redemptionMode: args.redemptionMode ?? null,
|
|
15775
|
+
redemptionPeriodSecs: args.redemptionPeriodSecs ?? null,
|
|
15759
15776
|
priceStalenessThresholdSecs: args.priceStalenessThresholdSecs,
|
|
15760
15777
|
userBurnLimit: args.userBurnLimit,
|
|
15761
15778
|
managerPullLimit: args.managerPullLimit,
|
|
@@ -15955,6 +15972,7 @@ var SetVaultConfigBuilder = class extends VaultBuilderBase {
|
|
|
15955
15972
|
tvlLimit: txArgs.tvlLimit !== void 0 ? new import_core7.BN(txArgs.tvlLimit.toString()) : null,
|
|
15956
15973
|
lossesEnabled: txArgs.lossesEnabled ?? null,
|
|
15957
15974
|
redemptionMode: txArgs.redemptionMode ?? null,
|
|
15975
|
+
redemptionPeriodSecs: txArgs.redemptionPeriodSecs !== void 0 ? new import_core7.BN(txArgs.redemptionPeriodSecs.toString()) : null,
|
|
15958
15976
|
priceStalenessThresholdSecs: txArgs.priceStalenessThresholdSecs !== void 0 ? new import_core7.BN(txArgs.priceStalenessThresholdSecs.toString()) : null,
|
|
15959
15977
|
userBurnLimit: txArgs.userBurnLimit !== void 0 ? {
|
|
15960
15978
|
windowLimit: new import_core7.BN(
|
|
@@ -16872,11 +16890,10 @@ var ExecuteTrancheDepositBuilder = class extends VaultBuilderBase {
|
|
|
16872
16890
|
var import_core13 = require("@anchor-lang/core");
|
|
16873
16891
|
var import_spl_token13 = require("@solana/spl-token");
|
|
16874
16892
|
var import_web319 = require("@solana/web3.js");
|
|
16875
|
-
var
|
|
16893
|
+
var import_common36 = __toESM(require_dist());
|
|
16876
16894
|
|
|
16877
16895
|
// src/client/builders/withdrawalPlan.ts
|
|
16878
16896
|
var import_web317 = require("@solana/web3.js");
|
|
16879
|
-
var import_common35 = __toESM(require_dist());
|
|
16880
16897
|
|
|
16881
16898
|
// src/client/builders/withdrawalLiquidity.ts
|
|
16882
16899
|
var import_core12 = require("@anchor-lang/core");
|
|
@@ -17457,28 +17474,12 @@ async function resolveWithdrawalPlan(args) {
|
|
|
17457
17474
|
positions: positions()
|
|
17458
17475
|
});
|
|
17459
17476
|
}
|
|
17460
|
-
function withdrawalComputeBudget(legs) {
|
|
17461
|
-
const external = legs.filter((l) => l.externalWithdrawIxRefs !== null);
|
|
17462
|
-
if (!external.length) return [];
|
|
17463
|
-
const units = Math.min(
|
|
17464
|
-
14e5,
|
|
17465
|
-
external.reduce(
|
|
17466
|
-
(sum, l) => sum + (l.externalWithdrawIxRefs.cpi.types.includes(
|
|
17467
|
-
import_common35.CpiTypes.KLEND_WITHDRAW_AND_REDEEM_V2
|
|
17468
|
-
) ? 1e6 : 4e5),
|
|
17469
|
-
0
|
|
17470
|
-
)
|
|
17471
|
-
);
|
|
17472
|
-
return [
|
|
17473
|
-
(0, import_common35.toKitInstruction)(import_web317.ComputeBudgetProgram.setComputeUnitLimit({ units }))
|
|
17474
|
-
];
|
|
17475
|
-
}
|
|
17476
17477
|
|
|
17477
17478
|
// src/client/builders/externalLiquidity.ts
|
|
17478
17479
|
var import_kit8 = require("@solana/kit");
|
|
17479
17480
|
var import_web318 = require("@solana/web3.js");
|
|
17480
17481
|
var import_kamino3 = __toESM(require_dist3());
|
|
17481
|
-
var
|
|
17482
|
+
var import_common35 = __toESM(require_dist());
|
|
17482
17483
|
var import_marginfi2 = __toESM(require_dist2());
|
|
17483
17484
|
function parseMarginfiSlot(slot) {
|
|
17484
17485
|
const data = slot?.data;
|
|
@@ -17495,21 +17496,12 @@ function toWeb3AccountMeta(account) {
|
|
|
17495
17496
|
isSigner: account.role === import_kit8.AccountRole.READONLY_SIGNER || account.role === import_kit8.AccountRole.WRITABLE_SIGNER
|
|
17496
17497
|
};
|
|
17497
17498
|
}
|
|
17498
|
-
function externalWithdrawComputeBudget(refs) {
|
|
17499
|
-
return refs?.cpi.types.some(
|
|
17500
|
-
(t) => t === import_common36.CpiTypes.KLEND_WITHDRAW_AND_REDEEM_V2 || t === import_common36.CpiTypes.KLEND_DEPOSIT_AND_COLLATERALIZE_V2
|
|
17501
|
-
) ? [
|
|
17502
|
-
(0, import_common36.toKitInstruction)(
|
|
17503
|
-
import_web318.ComputeBudgetProgram.setComputeUnitLimit({ units: 1e6 })
|
|
17504
|
-
)
|
|
17505
|
-
] : [];
|
|
17506
|
-
}
|
|
17507
17499
|
function externalWithdrawLookupTables(refs, tables = []) {
|
|
17508
17500
|
return [
|
|
17509
17501
|
.../* @__PURE__ */ new Set([
|
|
17510
17502
|
...tables,
|
|
17511
17503
|
...refs?.cpi.types.some(
|
|
17512
|
-
(t) => t ===
|
|
17504
|
+
(t) => t === import_common35.CpiTypes.KLEND_WITHDRAW_AND_REDEEM_V2 || t === import_common35.CpiTypes.KLEND_DEPOSIT_AND_COLLATERALIZE_V2
|
|
17513
17505
|
) ? [import_kamino3.KAMINO_LENDING_LOOKUP_TABLE] : []
|
|
17514
17506
|
])
|
|
17515
17507
|
];
|
|
@@ -17541,7 +17533,7 @@ async function resolveExternalWithdraw({
|
|
|
17541
17533
|
const marginfiAccounts = marginfi && (0, import_marginfi2.marginfiAccountsForMint)(assetMint);
|
|
17542
17534
|
if (marginfi && marginfiAccounts) {
|
|
17543
17535
|
const client = new import_marginfi2.CpiClient({ accounts: marginfiAccounts });
|
|
17544
|
-
const refs = (0,
|
|
17536
|
+
const refs = (0, import_common35.createCpiRefs)([
|
|
17545
17537
|
client.withdraw_cpi({
|
|
17546
17538
|
marginfiAccount: marginfi.userAccount,
|
|
17547
17539
|
authority: vault,
|
|
@@ -17565,7 +17557,7 @@ async function resolveExternalWithdraw({
|
|
|
17565
17557
|
assetMint
|
|
17566
17558
|
});
|
|
17567
17559
|
if (context) {
|
|
17568
|
-
const refs = (0,
|
|
17560
|
+
const refs = (0, import_common35.createCpiRefs)(
|
|
17569
17561
|
(0, import_kamino3.kaminoWithdrawCpis)({
|
|
17570
17562
|
...context,
|
|
17571
17563
|
vault,
|
|
@@ -17598,14 +17590,14 @@ function buildMarginfiWithdrawInteraction(args) {
|
|
|
17598
17590
|
`No Marginfi market is configured for asset mint ${args.assetMint}`
|
|
17599
17591
|
);
|
|
17600
17592
|
}
|
|
17601
|
-
const vaultAssetAta = (0,
|
|
17593
|
+
const vaultAssetAta = (0, import_common35.getAtaAddress)(
|
|
17602
17594
|
args.assetMint,
|
|
17603
17595
|
args.vault,
|
|
17604
17596
|
marginfiAccounts.tokenProgram,
|
|
17605
17597
|
true
|
|
17606
17598
|
);
|
|
17607
17599
|
const marginfiClient = new import_marginfi2.CpiClient({ accounts: marginfiAccounts });
|
|
17608
|
-
const withdraw = (0,
|
|
17600
|
+
const withdraw = (0, import_common35.createCpiRefs)([
|
|
17609
17601
|
marginfiClient.withdraw_cpi({
|
|
17610
17602
|
marginfiAccount: args.marginfiAccount,
|
|
17611
17603
|
authority: args.vault,
|
|
@@ -17687,12 +17679,9 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
17687
17679
|
}
|
|
17688
17680
|
async getTx(txArgs) {
|
|
17689
17681
|
const legs = await this.getIxArgs(txArgs);
|
|
17690
|
-
const preamble =
|
|
17691
|
-
(ix) => ix.programAddress !== import_web319.ComputeBudgetProgram.programId.toBase58()
|
|
17692
|
-
);
|
|
17682
|
+
const preamble = await this.buildPreambleInstructions(legs[0]);
|
|
17693
17683
|
return this.withVaultLookupTables({
|
|
17694
17684
|
instructions: [
|
|
17695
|
-
...withdrawalComputeBudget(legs),
|
|
17696
17685
|
...preamble,
|
|
17697
17686
|
...await Promise.all(legs.map((args) => this.getIx(args)))
|
|
17698
17687
|
],
|
|
@@ -17702,17 +17691,17 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
17702
17691
|
}
|
|
17703
17692
|
getIxAccounts(args) {
|
|
17704
17693
|
return {
|
|
17705
|
-
user: (0,
|
|
17706
|
-
vault: (0,
|
|
17707
|
-
vaultOracle: (0,
|
|
17708
|
-
vaultTrancheState: (0,
|
|
17709
|
-
assetMint: (0,
|
|
17710
|
-
trancheShareMint: (0,
|
|
17711
|
-
userAssetAta: (0,
|
|
17712
|
-
vaultAssetAta: (0,
|
|
17713
|
-
userTrancheShareAta: (0,
|
|
17714
|
-
assetTokenProgram: (0,
|
|
17715
|
-
shareTokenProgram: (0,
|
|
17694
|
+
user: (0, import_common36.toWeb3Pk)(args.user),
|
|
17695
|
+
vault: (0, import_common36.toWeb3Pk)(args.vault),
|
|
17696
|
+
vaultOracle: (0, import_common36.toWeb3Pk)(args.vaultOracle),
|
|
17697
|
+
vaultTrancheState: (0, import_common36.toWeb3Pk)(args.vaultTrancheState),
|
|
17698
|
+
assetMint: (0, import_common36.toWeb3Pk)(args.assetMint),
|
|
17699
|
+
trancheShareMint: (0, import_common36.toWeb3Pk)(args.trancheShareMint),
|
|
17700
|
+
userAssetAta: (0, import_common36.toWeb3Pk)(args.userAssetAta),
|
|
17701
|
+
vaultAssetAta: (0, import_common36.toWeb3Pk)(args.vaultAssetAta),
|
|
17702
|
+
userTrancheShareAta: (0, import_common36.toWeb3Pk)(args.userTrancheShareAta),
|
|
17703
|
+
assetTokenProgram: (0, import_common36.toWeb3Pk)(args.assetTokenProgram),
|
|
17704
|
+
shareTokenProgram: (0, import_common36.toWeb3Pk)(args.shareTokenProgram),
|
|
17716
17705
|
associatedTokenProgram: import_spl_token13.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
17717
17706
|
systemProgram: import_web319.SystemProgram.programId
|
|
17718
17707
|
};
|
|
@@ -17751,7 +17740,7 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
17751
17740
|
);
|
|
17752
17741
|
return methods.accountsPartial(
|
|
17753
17742
|
this.getIxAccounts(args)
|
|
17754
|
-
).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(
|
|
17743
|
+
).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(import_common36.toKitInstruction);
|
|
17755
17744
|
}
|
|
17756
17745
|
async deriveIxArgs(txArgs) {
|
|
17757
17746
|
const connection = this.program.provider.connection;
|
|
@@ -17772,7 +17761,7 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
17772
17761
|
txArgs.assetTokenProgram
|
|
17773
17762
|
);
|
|
17774
17763
|
const { mint: trancheShareMint, tokenProgram: shareTokenProgram } = trancheShare;
|
|
17775
|
-
const vaultAssetAta = (0,
|
|
17764
|
+
const vaultAssetAta = (0, import_common36.getAtaAddress)(
|
|
17776
17765
|
txArgs.assetMint,
|
|
17777
17766
|
txArgs.vault,
|
|
17778
17767
|
assetTokenProgram,
|
|
@@ -17802,13 +17791,13 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
17802
17791
|
addressSeeds: txArgs.addressSeeds,
|
|
17803
17792
|
assetTokenProgram,
|
|
17804
17793
|
shareTokenProgram,
|
|
17805
|
-
userAssetAta: (0,
|
|
17794
|
+
userAssetAta: (0, import_common36.getAtaAddress)(
|
|
17806
17795
|
txArgs.assetMint,
|
|
17807
17796
|
txArgs.user,
|
|
17808
17797
|
assetTokenProgram
|
|
17809
17798
|
),
|
|
17810
17799
|
vaultAssetAta,
|
|
17811
|
-
userTrancheShareAta: (0,
|
|
17800
|
+
userTrancheShareAta: (0, import_common36.getAtaAddress)(
|
|
17812
17801
|
trancheShareMint,
|
|
17813
17802
|
txArgs.user,
|
|
17814
17803
|
shareTokenProgram
|
|
@@ -17825,19 +17814,16 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
17825
17814
|
);
|
|
17826
17815
|
}
|
|
17827
17816
|
async buildPreambleInstructions(args) {
|
|
17828
|
-
const payer = (0,
|
|
17817
|
+
const payer = (0, import_common36.toWeb3Pk)(args.user);
|
|
17829
17818
|
const createUserAssetAta = (0, import_spl_token13.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17830
17819
|
payer,
|
|
17831
|
-
(0,
|
|
17820
|
+
(0, import_common36.toWeb3Pk)(args.userAssetAta),
|
|
17832
17821
|
payer,
|
|
17833
|
-
(0,
|
|
17834
|
-
(0,
|
|
17822
|
+
(0, import_common36.toWeb3Pk)(args.assetMint),
|
|
17823
|
+
(0, import_common36.toWeb3Pk)(args.assetTokenProgram),
|
|
17835
17824
|
import_spl_token13.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
17836
17825
|
);
|
|
17837
|
-
return [
|
|
17838
|
-
...externalWithdrawComputeBudget(args.externalWithdrawIxRefs),
|
|
17839
|
-
(0, import_common37.toKitInstruction)(createUserAssetAta)
|
|
17840
|
-
];
|
|
17826
|
+
return [(0, import_common36.toKitInstruction)(createUserAssetAta)];
|
|
17841
17827
|
}
|
|
17842
17828
|
async buildPlanExtras(args) {
|
|
17843
17829
|
return {
|
|
@@ -17850,9 +17836,8 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
17850
17836
|
|
|
17851
17837
|
// src/client/builders/executeWithdraw.ts
|
|
17852
17838
|
var import_core14 = require("@anchor-lang/core");
|
|
17853
|
-
var import_web320 = require("@solana/web3.js");
|
|
17854
17839
|
var import_spl_token14 = require("@solana/spl-token");
|
|
17855
|
-
var
|
|
17840
|
+
var import_common37 = __toESM(require_dist());
|
|
17856
17841
|
var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
17857
17842
|
/** Ordered arguments, including CPI data/account refs, for every partial burn. */
|
|
17858
17843
|
async getIxArgs(txArgs) {
|
|
@@ -17915,12 +17900,9 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
17915
17900
|
}
|
|
17916
17901
|
async getTx(txArgs) {
|
|
17917
17902
|
const legs = await this.getIxArgs(txArgs);
|
|
17918
|
-
const preamble =
|
|
17919
|
-
(ix) => ix.programAddress !== import_web320.ComputeBudgetProgram.programId.toBase58()
|
|
17920
|
-
);
|
|
17903
|
+
const preamble = await this.buildPreambleInstructions(legs[0]);
|
|
17921
17904
|
return this.withVaultLookupTables({
|
|
17922
17905
|
instructions: [
|
|
17923
|
-
...withdrawalComputeBudget(legs),
|
|
17924
17906
|
...preamble,
|
|
17925
17907
|
...await Promise.all(legs.map((args) => this.getIx(args)))
|
|
17926
17908
|
],
|
|
@@ -17930,19 +17912,19 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
17930
17912
|
}
|
|
17931
17913
|
getIxAccounts(args) {
|
|
17932
17914
|
return {
|
|
17933
|
-
user: (0,
|
|
17934
|
-
vault: (0,
|
|
17935
|
-
vaultOracle: (0,
|
|
17936
|
-
vaultTrancheState: args.vaultTrancheState ? (0,
|
|
17937
|
-
assetMint: (0,
|
|
17938
|
-
shareMint: (0,
|
|
17939
|
-
userAssetAta: (0,
|
|
17940
|
-
vaultAssetAta: (0,
|
|
17941
|
-
feeVault: (0,
|
|
17942
|
-
feeVaultAta: (0,
|
|
17943
|
-
userShareAta: (0,
|
|
17944
|
-
assetTokenProgram: (0,
|
|
17945
|
-
shareTokenProgram: (0,
|
|
17915
|
+
user: (0, import_common37.toWeb3Pk)(args.user),
|
|
17916
|
+
vault: (0, import_common37.toWeb3Pk)(args.vault),
|
|
17917
|
+
vaultOracle: (0, import_common37.toWeb3Pk)(args.vaultOracle),
|
|
17918
|
+
vaultTrancheState: args.vaultTrancheState ? (0, import_common37.toWeb3Pk)(args.vaultTrancheState) : null,
|
|
17919
|
+
assetMint: (0, import_common37.toWeb3Pk)(args.assetMint),
|
|
17920
|
+
shareMint: (0, import_common37.toWeb3Pk)(args.shareMint),
|
|
17921
|
+
userAssetAta: (0, import_common37.toWeb3Pk)(args.userAssetAta),
|
|
17922
|
+
vaultAssetAta: (0, import_common37.toWeb3Pk)(args.vaultAssetAta),
|
|
17923
|
+
feeVault: (0, import_common37.toWeb3Pk)(args.feeVault),
|
|
17924
|
+
feeVaultAta: (0, import_common37.toWeb3Pk)(args.feeVaultAta),
|
|
17925
|
+
userShareAta: (0, import_common37.toWeb3Pk)(args.userShareAta),
|
|
17926
|
+
assetTokenProgram: (0, import_common37.toWeb3Pk)(args.assetTokenProgram),
|
|
17927
|
+
shareTokenProgram: (0, import_common37.toWeb3Pk)(args.shareTokenProgram)
|
|
17946
17928
|
};
|
|
17947
17929
|
}
|
|
17948
17930
|
getIxData(args) {
|
|
@@ -17972,7 +17954,7 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
17972
17954
|
) : this.program.methods.executeWithdraw(data.shareAmount);
|
|
17973
17955
|
return methods.accountsPartial(
|
|
17974
17956
|
this.getIxAccounts(args)
|
|
17975
|
-
).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(
|
|
17957
|
+
).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(import_common37.toKitInstruction);
|
|
17976
17958
|
}
|
|
17977
17959
|
async deriveIxArgs(txArgs) {
|
|
17978
17960
|
const connection = this.program.provider.connection;
|
|
@@ -18006,7 +17988,7 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
18006
17988
|
),
|
|
18007
17989
|
this.account.fetchVault(txArgs.vault)
|
|
18008
17990
|
]);
|
|
18009
|
-
const vaultAssetAta = (0,
|
|
17991
|
+
const vaultAssetAta = (0, import_common37.getAtaAddress)(
|
|
18010
17992
|
txArgs.assetMint,
|
|
18011
17993
|
txArgs.vault,
|
|
18012
17994
|
assetTokenProgram,
|
|
@@ -18034,16 +18016,16 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
18034
18016
|
shareAmount: new import_core14.BN(txArgs.shareAmount.toString()),
|
|
18035
18017
|
assetTokenProgram,
|
|
18036
18018
|
shareTokenProgram,
|
|
18037
|
-
userAssetAta: txArgs.userAssetAta ?? (0,
|
|
18019
|
+
userAssetAta: txArgs.userAssetAta ?? (0, import_common37.getAtaAddress)(txArgs.assetMint, txArgs.user, assetTokenProgram),
|
|
18038
18020
|
vaultAssetAta,
|
|
18039
18021
|
feeVault,
|
|
18040
|
-
feeVaultAta: (0,
|
|
18022
|
+
feeVaultAta: (0, import_common37.getAtaAddress)(
|
|
18041
18023
|
txArgs.assetMint,
|
|
18042
18024
|
feeVault,
|
|
18043
18025
|
assetTokenProgram,
|
|
18044
18026
|
true
|
|
18045
18027
|
),
|
|
18046
|
-
userShareAta: txArgs.userShareAta ?? (0,
|
|
18028
|
+
userShareAta: txArgs.userShareAta ?? (0, import_common37.getAtaAddress)(txArgs.shareMint, txArgs.user, shareTokenProgram),
|
|
18047
18029
|
externalWithdrawIxRefs,
|
|
18048
18030
|
externalLiquiditySource,
|
|
18049
18031
|
externalWithdrawAccounts,
|
|
@@ -18057,34 +18039,31 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
18057
18039
|
);
|
|
18058
18040
|
}
|
|
18059
18041
|
async buildPreambleInstructions(args) {
|
|
18060
|
-
const defaultUserAssetAta = (0,
|
|
18042
|
+
const defaultUserAssetAta = (0, import_common37.getAtaAddress)(
|
|
18061
18043
|
args.assetMint,
|
|
18062
18044
|
args.user,
|
|
18063
18045
|
args.assetTokenProgram
|
|
18064
18046
|
);
|
|
18065
|
-
const payer = (0,
|
|
18066
|
-
const createUserAssetAta = (0,
|
|
18067
|
-
(0,
|
|
18047
|
+
const payer = (0, import_common37.toWeb3Pk)(args.user);
|
|
18048
|
+
const createUserAssetAta = (0, import_common37.toWeb3Pk)(args.userAssetAta).equals(
|
|
18049
|
+
(0, import_common37.toWeb3Pk)(defaultUserAssetAta)
|
|
18068
18050
|
) ? (0, import_spl_token14.createAssociatedTokenAccountIdempotentInstruction)(
|
|
18069
18051
|
payer,
|
|
18070
|
-
(0,
|
|
18052
|
+
(0, import_common37.toWeb3Pk)(args.userAssetAta),
|
|
18071
18053
|
payer,
|
|
18072
|
-
(0,
|
|
18073
|
-
(0,
|
|
18054
|
+
(0, import_common37.toWeb3Pk)(args.assetMint),
|
|
18055
|
+
(0, import_common37.toWeb3Pk)(args.assetTokenProgram),
|
|
18074
18056
|
import_spl_token14.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
18075
18057
|
) : null;
|
|
18076
18058
|
const createFeeVaultAta = (0, import_spl_token14.createAssociatedTokenAccountIdempotentInstruction)(
|
|
18077
18059
|
payer,
|
|
18078
|
-
(0,
|
|
18079
|
-
(0,
|
|
18080
|
-
(0,
|
|
18081
|
-
(0,
|
|
18060
|
+
(0, import_common37.toWeb3Pk)(args.feeVaultAta),
|
|
18061
|
+
(0, import_common37.toWeb3Pk)(args.feeVault),
|
|
18062
|
+
(0, import_common37.toWeb3Pk)(args.assetMint),
|
|
18063
|
+
(0, import_common37.toWeb3Pk)(args.assetTokenProgram),
|
|
18082
18064
|
import_spl_token14.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
18083
18065
|
);
|
|
18084
|
-
return [
|
|
18085
|
-
...externalWithdrawComputeBudget(args.externalWithdrawIxRefs),
|
|
18086
|
-
...[createUserAssetAta, createFeeVaultAta].filter((ix) => ix != null).map(import_common38.toKitInstruction)
|
|
18087
|
-
];
|
|
18066
|
+
return [createUserAssetAta, createFeeVaultAta].filter((ix) => ix != null).map(import_common37.toKitInstruction);
|
|
18088
18067
|
}
|
|
18089
18068
|
async buildPlanExtras(args) {
|
|
18090
18069
|
return {
|
|
@@ -18095,8 +18074,8 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
18095
18074
|
|
|
18096
18075
|
// src/client/builders/fulfillJuniorTrancheWithdraw.ts
|
|
18097
18076
|
var import_spl_token15 = require("@solana/spl-token");
|
|
18098
|
-
var
|
|
18099
|
-
var
|
|
18077
|
+
var import_web320 = require("@solana/web3.js");
|
|
18078
|
+
var import_common38 = __toESM(require_dist());
|
|
18100
18079
|
var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
18101
18080
|
async getIx(args) {
|
|
18102
18081
|
const externalWithdrawIxRefs = args.externalWithdrawIxRefs ?? null;
|
|
@@ -18110,24 +18089,24 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
18110
18089
|
externalLiquiditySource
|
|
18111
18090
|
);
|
|
18112
18091
|
return methods.accountsPartial({
|
|
18113
|
-
signer: (0,
|
|
18114
|
-
owner: (0,
|
|
18115
|
-
queuePayer: (0,
|
|
18116
|
-
vault: (0,
|
|
18117
|
-
vaultOracle: (0,
|
|
18118
|
-
vaultTrancheState: (0,
|
|
18119
|
-
withdrawalQueue: (0,
|
|
18120
|
-
outputMint: (0,
|
|
18121
|
-
inputMint: (0,
|
|
18122
|
-
ownerInputAta: (0,
|
|
18123
|
-
ownerOutputAta: (0,
|
|
18124
|
-
vaultOutputAta: (0,
|
|
18125
|
-
queueInputAta: (0,
|
|
18126
|
-
assetTokenProgram: (0,
|
|
18127
|
-
shareTokenProgram: (0,
|
|
18092
|
+
signer: (0, import_common38.toWeb3Pk)(args.signer),
|
|
18093
|
+
owner: (0, import_common38.toWeb3Pk)(args.owner),
|
|
18094
|
+
queuePayer: (0, import_common38.toWeb3Pk)(args.queuePayer),
|
|
18095
|
+
vault: (0, import_common38.toWeb3Pk)(args.vault),
|
|
18096
|
+
vaultOracle: (0, import_common38.toWeb3Pk)(args.vaultOracle),
|
|
18097
|
+
vaultTrancheState: (0, import_common38.toWeb3Pk)(args.vaultTrancheState),
|
|
18098
|
+
withdrawalQueue: (0, import_common38.toWeb3Pk)(args.withdrawalQueue),
|
|
18099
|
+
outputMint: (0, import_common38.toWeb3Pk)(args.outputMint),
|
|
18100
|
+
inputMint: (0, import_common38.toWeb3Pk)(args.inputMint),
|
|
18101
|
+
ownerInputAta: (0, import_common38.toWeb3Pk)(args.ownerInputAta),
|
|
18102
|
+
ownerOutputAta: (0, import_common38.toWeb3Pk)(args.ownerOutputAta),
|
|
18103
|
+
vaultOutputAta: (0, import_common38.toWeb3Pk)(args.vaultOutputAta),
|
|
18104
|
+
queueInputAta: (0, import_common38.toWeb3Pk)(args.queueInputAta),
|
|
18105
|
+
assetTokenProgram: (0, import_common38.toWeb3Pk)(args.assetTokenProgram),
|
|
18106
|
+
shareTokenProgram: (0, import_common38.toWeb3Pk)(args.shareTokenProgram),
|
|
18128
18107
|
associatedTokenProgram: import_spl_token15.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
18129
|
-
systemProgram:
|
|
18130
|
-
}).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(
|
|
18108
|
+
systemProgram: import_web320.SystemProgram.programId
|
|
18109
|
+
}).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(import_common38.toKitInstruction);
|
|
18131
18110
|
}
|
|
18132
18111
|
async deriveIxArgs(txArgs) {
|
|
18133
18112
|
const connection = this.program.provider.connection;
|
|
@@ -18168,7 +18147,7 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
18168
18147
|
]);
|
|
18169
18148
|
const { mint: juniorShareMint, tokenProgram: shareTokenProgram } = juniorShare;
|
|
18170
18149
|
const queuePda = txArgs.withdrawalQueue ?? withdrawalQueue;
|
|
18171
|
-
const vaultOutputAta = (0,
|
|
18150
|
+
const vaultOutputAta = (0, import_common38.getAtaAddress)(
|
|
18172
18151
|
txArgs.assetMint,
|
|
18173
18152
|
txArgs.vault,
|
|
18174
18153
|
assetTokenProgram,
|
|
@@ -18198,14 +18177,14 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
18198
18177
|
inputMint: juniorShareMint,
|
|
18199
18178
|
assetTokenProgram,
|
|
18200
18179
|
shareTokenProgram,
|
|
18201
|
-
ownerInputAta: txArgs.ownerInputAta ?? (0,
|
|
18202
|
-
ownerOutputAta: (0,
|
|
18180
|
+
ownerInputAta: txArgs.ownerInputAta ?? (0, import_common38.getAtaAddress)(juniorShareMint, txArgs.owner, shareTokenProgram),
|
|
18181
|
+
ownerOutputAta: (0, import_common38.getAtaAddress)(
|
|
18203
18182
|
txArgs.assetMint,
|
|
18204
18183
|
txArgs.owner,
|
|
18205
18184
|
assetTokenProgram
|
|
18206
18185
|
),
|
|
18207
18186
|
vaultOutputAta,
|
|
18208
|
-
queueInputAta: (0,
|
|
18187
|
+
queueInputAta: (0, import_common38.getAtaAddress)(
|
|
18209
18188
|
juniorShareMint,
|
|
18210
18189
|
queuePda,
|
|
18211
18190
|
shareTokenProgram,
|
|
@@ -18224,23 +18203,22 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
18224
18203
|
);
|
|
18225
18204
|
}
|
|
18226
18205
|
async buildPreambleInstructions(args) {
|
|
18227
|
-
const defaultOwnerInputAta = (0,
|
|
18206
|
+
const defaultOwnerInputAta = (0, import_common38.getAtaAddress)(
|
|
18228
18207
|
args.inputMint,
|
|
18229
18208
|
args.owner,
|
|
18230
18209
|
args.shareTokenProgram
|
|
18231
18210
|
);
|
|
18232
|
-
if (!(0,
|
|
18233
|
-
return
|
|
18211
|
+
if (!(0, import_common38.toWeb3Pk)(args.ownerInputAta).equals((0, import_common38.toWeb3Pk)(defaultOwnerInputAta))) {
|
|
18212
|
+
return [];
|
|
18234
18213
|
}
|
|
18235
18214
|
return [
|
|
18236
|
-
|
|
18237
|
-
(0, import_common39.toKitInstruction)(
|
|
18215
|
+
(0, import_common38.toKitInstruction)(
|
|
18238
18216
|
(0, import_spl_token15.createAssociatedTokenAccountIdempotentInstruction)(
|
|
18239
|
-
(0,
|
|
18240
|
-
(0,
|
|
18241
|
-
(0,
|
|
18242
|
-
(0,
|
|
18243
|
-
(0,
|
|
18217
|
+
(0, import_common38.toWeb3Pk)(args.signer),
|
|
18218
|
+
(0, import_common38.toWeb3Pk)(args.ownerInputAta),
|
|
18219
|
+
(0, import_common38.toWeb3Pk)(args.owner),
|
|
18220
|
+
(0, import_common38.toWeb3Pk)(args.inputMint),
|
|
18221
|
+
(0, import_common38.toWeb3Pk)(args.shareTokenProgram),
|
|
18244
18222
|
import_spl_token15.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
18245
18223
|
)
|
|
18246
18224
|
)
|
|
@@ -18261,7 +18239,7 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
18261
18239
|
|
|
18262
18240
|
// src/client/builders/updateTrancheConfig.ts
|
|
18263
18241
|
var import_core15 = require("@anchor-lang/core");
|
|
18264
|
-
var
|
|
18242
|
+
var import_common39 = __toESM(require_dist());
|
|
18265
18243
|
var UpdateTrancheConfigBuilder = class extends VaultBuilderBase {
|
|
18266
18244
|
async getIx(args) {
|
|
18267
18245
|
return this.program.methods.vaultUpdateTrancheConfig({
|
|
@@ -18272,11 +18250,11 @@ var UpdateTrancheConfigBuilder = class extends VaultBuilderBase {
|
|
|
18272
18250
|
targetLockupDurationSecs: args.targetLockupDurationSecs,
|
|
18273
18251
|
juniorDepositCap: args.juniorDepositCap
|
|
18274
18252
|
}).accountsPartial({
|
|
18275
|
-
curator: (0,
|
|
18276
|
-
vault: (0,
|
|
18277
|
-
vaultTrancheState: (0,
|
|
18278
|
-
vaultOracle: (0,
|
|
18279
|
-
}).instruction().then(
|
|
18253
|
+
curator: (0, import_common39.toWeb3Pk)(args.curator),
|
|
18254
|
+
vault: (0, import_common39.toWeb3Pk)(args.vault),
|
|
18255
|
+
vaultTrancheState: (0, import_common39.toWeb3Pk)(args.vaultTrancheState),
|
|
18256
|
+
vaultOracle: (0, import_common39.toWeb3Pk)(args.vaultOracle)
|
|
18257
|
+
}).instruction().then(import_common39.toKitInstruction);
|
|
18280
18258
|
}
|
|
18281
18259
|
async deriveIxArgs(txArgs) {
|
|
18282
18260
|
const [vaultTrancheState] = await this.pda.deriveVaultTrancheStatePda(
|
|
@@ -18308,23 +18286,23 @@ var UpdateTrancheConfigBuilder = class extends VaultBuilderBase {
|
|
|
18308
18286
|
// src/client/builders/managerRedepositAsset.ts
|
|
18309
18287
|
var import_core16 = require("@anchor-lang/core");
|
|
18310
18288
|
var import_spl_token16 = require("@solana/spl-token");
|
|
18311
|
-
var
|
|
18312
|
-
var
|
|
18289
|
+
var import_web321 = require("@solana/web3.js");
|
|
18290
|
+
var import_common40 = __toESM(require_dist());
|
|
18313
18291
|
var ManagerRedepositAssetBuilder = class extends VaultBuilderBase {
|
|
18314
18292
|
async getIx(args) {
|
|
18315
18293
|
return this.program.methods.managerRedepositAsset({
|
|
18316
18294
|
depositAmount: args.depositAmount,
|
|
18317
18295
|
externalAmount: args.externalAmount
|
|
18318
18296
|
}).accountsPartial({
|
|
18319
|
-
manager: (0,
|
|
18320
|
-
vault: (0,
|
|
18321
|
-
assetMint: (0,
|
|
18322
|
-
vaultAssetAta: (0,
|
|
18323
|
-
managerAssetAta: (0,
|
|
18324
|
-
assetTokenProgram: (0,
|
|
18297
|
+
manager: (0, import_common40.toWeb3Pk)(args.manager),
|
|
18298
|
+
vault: (0, import_common40.toWeb3Pk)(args.vault),
|
|
18299
|
+
assetMint: (0, import_common40.toWeb3Pk)(args.assetMint),
|
|
18300
|
+
vaultAssetAta: (0, import_common40.toWeb3Pk)(args.vaultAssetAta),
|
|
18301
|
+
managerAssetAta: (0, import_common40.toWeb3Pk)(args.managerAssetAta),
|
|
18302
|
+
assetTokenProgram: (0, import_common40.toWeb3Pk)(args.assetTokenProgram),
|
|
18325
18303
|
associatedTokenProgram: import_spl_token16.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
18326
|
-
systemProgram:
|
|
18327
|
-
}).instruction().then(
|
|
18304
|
+
systemProgram: import_web321.SystemProgram.programId
|
|
18305
|
+
}).instruction().then(import_common40.toKitInstruction);
|
|
18328
18306
|
}
|
|
18329
18307
|
async deriveIxArgs(txArgs) {
|
|
18330
18308
|
const connection = this.program.provider.connection;
|
|
@@ -18341,7 +18319,7 @@ var ManagerRedepositAssetBuilder = class extends VaultBuilderBase {
|
|
|
18341
18319
|
depositAmount: new import_core16.BN(txArgs.depositAmount.toString()),
|
|
18342
18320
|
externalAmount: new import_core16.BN(externalAmount.toString()),
|
|
18343
18321
|
assetTokenProgram,
|
|
18344
|
-
vaultAssetAta: (0,
|
|
18322
|
+
vaultAssetAta: (0, import_common40.getAtaAddress)(
|
|
18345
18323
|
txArgs.assetMint,
|
|
18346
18324
|
txArgs.vault,
|
|
18347
18325
|
assetTokenProgram,
|
|
@@ -18349,7 +18327,7 @@ var ManagerRedepositAssetBuilder = class extends VaultBuilderBase {
|
|
|
18349
18327
|
),
|
|
18350
18328
|
// The manager may be a PDA (e.g. a Squads vault), so allow off-curve
|
|
18351
18329
|
// owners when deriving its ATA.
|
|
18352
|
-
managerAssetAta: (0,
|
|
18330
|
+
managerAssetAta: (0, import_common40.getAtaAddress)(
|
|
18353
18331
|
txArgs.assetMint,
|
|
18354
18332
|
txArgs.manager,
|
|
18355
18333
|
assetTokenProgram,
|
|
@@ -18367,21 +18345,21 @@ var ManagerRedepositAssetBuilder = class extends VaultBuilderBase {
|
|
|
18367
18345
|
// src/client/builders/managerWithdrawAsset.ts
|
|
18368
18346
|
var import_core17 = require("@anchor-lang/core");
|
|
18369
18347
|
var import_spl_token17 = require("@solana/spl-token");
|
|
18370
|
-
var
|
|
18371
|
-
var
|
|
18348
|
+
var import_web322 = require("@solana/web3.js");
|
|
18349
|
+
var import_common41 = __toESM(require_dist());
|
|
18372
18350
|
var ManagerWithdrawAssetBuilder = class extends VaultBuilderBase {
|
|
18373
18351
|
async getIx(args) {
|
|
18374
18352
|
return this.program.methods.managerWithdrawAsset(args.amount).accountsPartial({
|
|
18375
|
-
manager: (0,
|
|
18376
|
-
vault: (0,
|
|
18377
|
-
assetMint: (0,
|
|
18378
|
-
vaultAssetAta: (0,
|
|
18379
|
-
destination: (0,
|
|
18380
|
-
destinationAssetAta: (0,
|
|
18381
|
-
assetTokenProgram: (0,
|
|
18353
|
+
manager: (0, import_common41.toWeb3Pk)(args.manager),
|
|
18354
|
+
vault: (0, import_common41.toWeb3Pk)(args.vault),
|
|
18355
|
+
assetMint: (0, import_common41.toWeb3Pk)(args.assetMint),
|
|
18356
|
+
vaultAssetAta: (0, import_common41.toWeb3Pk)(args.vaultAssetAta),
|
|
18357
|
+
destination: (0, import_common41.toWeb3Pk)(args.destination),
|
|
18358
|
+
destinationAssetAta: (0, import_common41.toWeb3Pk)(args.destinationAssetAta),
|
|
18359
|
+
assetTokenProgram: (0, import_common41.toWeb3Pk)(args.assetTokenProgram),
|
|
18382
18360
|
associatedTokenProgram: import_spl_token17.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
18383
|
-
systemProgram:
|
|
18384
|
-
}).instruction().then(
|
|
18361
|
+
systemProgram: import_web322.SystemProgram.programId
|
|
18362
|
+
}).instruction().then(import_common41.toKitInstruction);
|
|
18385
18363
|
}
|
|
18386
18364
|
async deriveIxArgs(txArgs) {
|
|
18387
18365
|
const connection = this.program.provider.connection;
|
|
@@ -18398,13 +18376,13 @@ var ManagerWithdrawAssetBuilder = class extends VaultBuilderBase {
|
|
|
18398
18376
|
destination,
|
|
18399
18377
|
amount: new import_core17.BN(txArgs.amount.toString()),
|
|
18400
18378
|
assetTokenProgram,
|
|
18401
|
-
vaultAssetAta: (0,
|
|
18379
|
+
vaultAssetAta: (0, import_common41.getAtaAddress)(
|
|
18402
18380
|
txArgs.assetMint,
|
|
18403
18381
|
txArgs.vault,
|
|
18404
18382
|
assetTokenProgram,
|
|
18405
18383
|
true
|
|
18406
18384
|
),
|
|
18407
|
-
destinationAssetAta: (0,
|
|
18385
|
+
destinationAssetAta: (0, import_common41.getAtaAddress)(
|
|
18408
18386
|
txArgs.assetMint,
|
|
18409
18387
|
destination,
|
|
18410
18388
|
assetTokenProgram,
|
|
@@ -18424,8 +18402,8 @@ var ManagerWithdrawAssetBuilder = class extends VaultBuilderBase {
|
|
|
18424
18402
|
var import_core18 = require("@anchor-lang/core");
|
|
18425
18403
|
var import_kit9 = require("@solana/kit");
|
|
18426
18404
|
var import_spl_token18 = require("@solana/spl-token");
|
|
18427
|
-
var
|
|
18428
|
-
var
|
|
18405
|
+
var import_web323 = require("@solana/web3.js");
|
|
18406
|
+
var import_common42 = __toESM(require_dist());
|
|
18429
18407
|
var DEFAULT_PYTH_PRICE_MAX_AGE_SECS = 90n;
|
|
18430
18408
|
function toAssetPriceOracleConfig(args) {
|
|
18431
18409
|
return {
|
|
@@ -18440,12 +18418,12 @@ function toAssetPriceOracleConfig(args) {
|
|
|
18440
18418
|
function toAnchorAssetPriceOracleConfig(config) {
|
|
18441
18419
|
return {
|
|
18442
18420
|
...config,
|
|
18443
|
-
priceOracleAccount: (0,
|
|
18421
|
+
priceOracleAccount: (0, import_common42.toWeb3Pk)(config.priceOracleAccount)
|
|
18444
18422
|
};
|
|
18445
18423
|
}
|
|
18446
18424
|
function toWeb3AccountMeta2(account) {
|
|
18447
18425
|
return {
|
|
18448
|
-
pubkey: new
|
|
18426
|
+
pubkey: new import_web323.PublicKey(account.address),
|
|
18449
18427
|
isWritable: account.role === import_kit9.AccountRole.WRITABLE || account.role === import_kit9.AccountRole.WRITABLE_SIGNER,
|
|
18450
18428
|
isSigner: account.role === import_kit9.AccountRole.READONLY_SIGNER || account.role === import_kit9.AccountRole.WRITABLE_SIGNER
|
|
18451
18429
|
};
|
|
@@ -18454,14 +18432,14 @@ var ProtocolInteractionBuilder = class extends VaultBuilderBase {
|
|
|
18454
18432
|
async getIx(args) {
|
|
18455
18433
|
return this.program.methods.protocolInteraction(args.refs, {
|
|
18456
18434
|
externalLiquidityIndex: args.externalLiquidityIndex,
|
|
18457
|
-
affectedAssetMint: args.affectedAssetMint ? (0,
|
|
18435
|
+
affectedAssetMint: args.affectedAssetMint ? (0, import_common42.toWeb3Pk)(args.affectedAssetMint) : null
|
|
18458
18436
|
}).accountsPartial({
|
|
18459
|
-
hwManager: (0,
|
|
18460
|
-
vault: (0,
|
|
18461
|
-
affectedAssetMint: args.affectedAssetMint ? (0,
|
|
18462
|
-
affectedVaultAta: args.affectedVaultAta ? (0,
|
|
18463
|
-
affectedTokenProgram: args.affectedTokenProgram ? (0,
|
|
18464
|
-
}).remainingAccounts(args.accounts.map(toWeb3AccountMeta2)).instruction().then(
|
|
18437
|
+
hwManager: (0, import_common42.toWeb3Pk)(args.hwManager),
|
|
18438
|
+
vault: (0, import_common42.toWeb3Pk)(args.vault),
|
|
18439
|
+
affectedAssetMint: args.affectedAssetMint ? (0, import_common42.toWeb3Pk)(args.affectedAssetMint) : null,
|
|
18440
|
+
affectedVaultAta: args.affectedVaultAta ? (0, import_common42.toWeb3Pk)(args.affectedVaultAta) : null,
|
|
18441
|
+
affectedTokenProgram: args.affectedTokenProgram ? (0, import_common42.toWeb3Pk)(args.affectedTokenProgram) : null
|
|
18442
|
+
}).remainingAccounts(args.accounts.map(toWeb3AccountMeta2)).instruction().then(import_common42.toKitInstruction);
|
|
18465
18443
|
}
|
|
18466
18444
|
async deriveIxArgs(txArgs) {
|
|
18467
18445
|
const affectedTokenProgram = txArgs.affectedAssetMint ? txArgs.affectedTokenProgram ?? TOKEN_PROGRAM_ID : null;
|
|
@@ -18473,7 +18451,7 @@ var ProtocolInteractionBuilder = class extends VaultBuilderBase {
|
|
|
18473
18451
|
accounts: txArgs.accounts,
|
|
18474
18452
|
affectedAssetMint: txArgs.affectedAssetMint ?? null,
|
|
18475
18453
|
affectedTokenProgram,
|
|
18476
|
-
affectedVaultAta: txArgs.affectedAssetMint && affectedTokenProgram ? (0,
|
|
18454
|
+
affectedVaultAta: txArgs.affectedAssetMint && affectedTokenProgram ? (0, import_common42.getAtaAddress)(
|
|
18477
18455
|
txArgs.affectedAssetMint,
|
|
18478
18456
|
txArgs.vault,
|
|
18479
18457
|
affectedTokenProgram,
|
|
@@ -18484,9 +18462,6 @@ var ProtocolInteractionBuilder = class extends VaultBuilderBase {
|
|
|
18484
18462
|
async buildLookupTables(args, txArgs) {
|
|
18485
18463
|
return externalWithdrawLookupTables(args.refs, txArgs.lookupTables);
|
|
18486
18464
|
}
|
|
18487
|
-
async buildPreambleInstructions(args) {
|
|
18488
|
-
return externalWithdrawComputeBudget(args.refs);
|
|
18489
|
-
}
|
|
18490
18465
|
};
|
|
18491
18466
|
var JupiterSwapBuilder = class extends VaultBuilderBase {
|
|
18492
18467
|
async getIx(args) {
|
|
@@ -18495,18 +18470,18 @@ var JupiterSwapBuilder = class extends VaultBuilderBase {
|
|
|
18495
18470
|
args.destinationPriceOracle
|
|
18496
18471
|
)
|
|
18497
18472
|
}).accountsPartial({
|
|
18498
|
-
hwManager: (0,
|
|
18499
|
-
vault: (0,
|
|
18500
|
-
sourceMint: (0,
|
|
18501
|
-
destinationMint: (0,
|
|
18502
|
-
vaultSourceAta: (0,
|
|
18503
|
-
vaultDestinationAta: (0,
|
|
18504
|
-
sourceTokenProgram: (0,
|
|
18505
|
-
destinationTokenProgram: (0,
|
|
18506
|
-
destinationOracleAccount: args.destinationOracleAccount ? (0,
|
|
18507
|
-
vaultOracle: (0,
|
|
18508
|
-
vaultTrancheState: args.vaultTrancheState ? (0,
|
|
18509
|
-
}).remainingAccounts(args.accounts.map(toWeb3AccountMeta2)).instruction().then(
|
|
18473
|
+
hwManager: (0, import_common42.toWeb3Pk)(args.hwManager),
|
|
18474
|
+
vault: (0, import_common42.toWeb3Pk)(args.vault),
|
|
18475
|
+
sourceMint: (0, import_common42.toWeb3Pk)(args.sourceMint),
|
|
18476
|
+
destinationMint: (0, import_common42.toWeb3Pk)(args.destinationMint),
|
|
18477
|
+
vaultSourceAta: (0, import_common42.toWeb3Pk)(args.vaultSourceAta),
|
|
18478
|
+
vaultDestinationAta: (0, import_common42.toWeb3Pk)(args.vaultDestinationAta),
|
|
18479
|
+
sourceTokenProgram: (0, import_common42.toWeb3Pk)(args.sourceTokenProgram),
|
|
18480
|
+
destinationTokenProgram: (0, import_common42.toWeb3Pk)(args.destinationTokenProgram),
|
|
18481
|
+
destinationOracleAccount: args.destinationOracleAccount ? (0, import_common42.toWeb3Pk)(args.destinationOracleAccount) : null,
|
|
18482
|
+
vaultOracle: (0, import_common42.toWeb3Pk)(args.vaultOracle),
|
|
18483
|
+
vaultTrancheState: args.vaultTrancheState ? (0, import_common42.toWeb3Pk)(args.vaultTrancheState) : null
|
|
18484
|
+
}).remainingAccounts(args.accounts.map(toWeb3AccountMeta2)).instruction().then(import_common42.toKitInstruction);
|
|
18510
18485
|
}
|
|
18511
18486
|
async deriveIxArgs(txArgs) {
|
|
18512
18487
|
const sourceTokenProgram = txArgs.sourceTokenProgram ?? TOKEN_PROGRAM_ID;
|
|
@@ -18527,13 +18502,13 @@ var JupiterSwapBuilder = class extends VaultBuilderBase {
|
|
|
18527
18502
|
accounts: txArgs.accounts,
|
|
18528
18503
|
sourceTokenProgram,
|
|
18529
18504
|
destinationTokenProgram,
|
|
18530
|
-
vaultSourceAta: (0,
|
|
18505
|
+
vaultSourceAta: (0, import_common42.getAtaAddress)(
|
|
18531
18506
|
txArgs.sourceMint,
|
|
18532
18507
|
txArgs.vault,
|
|
18533
18508
|
sourceTokenProgram,
|
|
18534
18509
|
true
|
|
18535
18510
|
),
|
|
18536
|
-
vaultDestinationAta: (0,
|
|
18511
|
+
vaultDestinationAta: (0, import_common42.getAtaAddress)(
|
|
18537
18512
|
txArgs.destinationMint,
|
|
18538
18513
|
txArgs.vault,
|
|
18539
18514
|
destinationTokenProgram,
|
|
@@ -18542,24 +18517,24 @@ var JupiterSwapBuilder = class extends VaultBuilderBase {
|
|
|
18542
18517
|
};
|
|
18543
18518
|
}
|
|
18544
18519
|
async buildPreambleInstructions(args) {
|
|
18545
|
-
const payer = (0,
|
|
18520
|
+
const payer = (0, import_common42.toWeb3Pk)(args.hwManager);
|
|
18546
18521
|
const createSourceAta = (0, import_spl_token18.createAssociatedTokenAccountIdempotentInstruction)(
|
|
18547
18522
|
payer,
|
|
18548
|
-
(0,
|
|
18549
|
-
(0,
|
|
18550
|
-
(0,
|
|
18551
|
-
(0,
|
|
18523
|
+
(0, import_common42.toWeb3Pk)(args.vaultSourceAta),
|
|
18524
|
+
(0, import_common42.toWeb3Pk)(args.vault),
|
|
18525
|
+
(0, import_common42.toWeb3Pk)(args.sourceMint),
|
|
18526
|
+
(0, import_common42.toWeb3Pk)(args.sourceTokenProgram),
|
|
18552
18527
|
import_spl_token18.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
18553
18528
|
);
|
|
18554
18529
|
const createDestinationAta = (0, import_spl_token18.createAssociatedTokenAccountIdempotentInstruction)(
|
|
18555
18530
|
payer,
|
|
18556
|
-
(0,
|
|
18557
|
-
(0,
|
|
18558
|
-
(0,
|
|
18559
|
-
(0,
|
|
18531
|
+
(0, import_common42.toWeb3Pk)(args.vaultDestinationAta),
|
|
18532
|
+
(0, import_common42.toWeb3Pk)(args.vault),
|
|
18533
|
+
(0, import_common42.toWeb3Pk)(args.destinationMint),
|
|
18534
|
+
(0, import_common42.toWeb3Pk)(args.destinationTokenProgram),
|
|
18560
18535
|
import_spl_token18.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
18561
18536
|
);
|
|
18562
|
-
return [createSourceAta, createDestinationAta].map(
|
|
18537
|
+
return [createSourceAta, createDestinationAta].map(import_common42.toKitInstruction);
|
|
18563
18538
|
}
|
|
18564
18539
|
async buildLookupTables(_args, txArgs) {
|
|
18565
18540
|
return txArgs.lookupTables;
|
|
@@ -18594,25 +18569,25 @@ var JupiterSwapBuilder = class extends VaultBuilderBase {
|
|
|
18594
18569
|
// src/client/builders/requestJuniorTrancheWithdraw.ts
|
|
18595
18570
|
var import_core19 = require("@anchor-lang/core");
|
|
18596
18571
|
var import_spl_token19 = require("@solana/spl-token");
|
|
18597
|
-
var
|
|
18598
|
-
var
|
|
18572
|
+
var import_web324 = require("@solana/web3.js");
|
|
18573
|
+
var import_common43 = __toESM(require_dist());
|
|
18599
18574
|
var RequestJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
18600
18575
|
async getIx(args) {
|
|
18601
18576
|
return this.program.methods.requestJuniorTrancheWithdraw(args.queueId, args.shareAmount).accountsPartial({
|
|
18602
|
-
user: (0,
|
|
18603
|
-
payer: (0,
|
|
18604
|
-
vault: (0,
|
|
18605
|
-
vaultOracle: (0,
|
|
18606
|
-
vaultTrancheState: (0,
|
|
18607
|
-
withdrawalQueue: (0,
|
|
18608
|
-
outputMint: (0,
|
|
18609
|
-
inputMint: (0,
|
|
18610
|
-
userInputAta: (0,
|
|
18611
|
-
queueInputAta: (0,
|
|
18612
|
-
shareTokenProgram: (0,
|
|
18577
|
+
user: (0, import_common43.toWeb3Pk)(args.user),
|
|
18578
|
+
payer: (0, import_common43.toWeb3Pk)(args.payer),
|
|
18579
|
+
vault: (0, import_common43.toWeb3Pk)(args.vault),
|
|
18580
|
+
vaultOracle: (0, import_common43.toWeb3Pk)(args.vaultOracle),
|
|
18581
|
+
vaultTrancheState: (0, import_common43.toWeb3Pk)(args.vaultTrancheState),
|
|
18582
|
+
withdrawalQueue: (0, import_common43.toWeb3Pk)(args.withdrawalQueue),
|
|
18583
|
+
outputMint: (0, import_common43.toWeb3Pk)(args.outputMint),
|
|
18584
|
+
inputMint: (0, import_common43.toWeb3Pk)(args.inputMint),
|
|
18585
|
+
userInputAta: (0, import_common43.toWeb3Pk)(args.userInputAta),
|
|
18586
|
+
queueInputAta: (0, import_common43.toWeb3Pk)(args.queueInputAta),
|
|
18587
|
+
shareTokenProgram: (0, import_common43.toWeb3Pk)(args.shareTokenProgram),
|
|
18613
18588
|
associatedTokenProgram: import_spl_token19.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
18614
|
-
systemProgram:
|
|
18615
|
-
}).instruction().then(
|
|
18589
|
+
systemProgram: import_web324.SystemProgram.programId
|
|
18590
|
+
}).instruction().then(import_common43.toKitInstruction);
|
|
18616
18591
|
}
|
|
18617
18592
|
async deriveIxArgs(txArgs) {
|
|
18618
18593
|
const payer = txArgs.payer ?? txArgs.user;
|
|
@@ -18648,8 +18623,8 @@ var RequestJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
18648
18623
|
queueId: txArgs.queueId,
|
|
18649
18624
|
shareAmount: new import_core19.BN(txArgs.shareAmount.toString()),
|
|
18650
18625
|
shareTokenProgram,
|
|
18651
|
-
userInputAta: txArgs.userInputAta ?? (0,
|
|
18652
|
-
queueInputAta: (0,
|
|
18626
|
+
userInputAta: txArgs.userInputAta ?? (0, import_common43.getAtaAddress)(juniorShareMint, txArgs.user, shareTokenProgram),
|
|
18627
|
+
queueInputAta: (0, import_common43.getAtaAddress)(
|
|
18653
18628
|
juniorShareMint,
|
|
18654
18629
|
queuePda,
|
|
18655
18630
|
shareTokenProgram,
|
|
@@ -18673,8 +18648,8 @@ var RequestJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
18673
18648
|
// src/client/builders/vaultReallocation.ts
|
|
18674
18649
|
var import_core20 = require("@anchor-lang/core");
|
|
18675
18650
|
var import_spl_token20 = require("@solana/spl-token");
|
|
18676
|
-
var
|
|
18677
|
-
var
|
|
18651
|
+
var import_web325 = require("@solana/web3.js");
|
|
18652
|
+
var import_common44 = __toESM(require_dist());
|
|
18678
18653
|
var DEFAULT_PYTH_PRICE_MAX_AGE_SECS2 = 90n;
|
|
18679
18654
|
function toAssetPriceOracleConfig2(args) {
|
|
18680
18655
|
return {
|
|
@@ -18689,7 +18664,7 @@ function toAssetPriceOracleConfig2(args) {
|
|
|
18689
18664
|
function toAnchorAssetPriceOracleConfig2(config) {
|
|
18690
18665
|
return {
|
|
18691
18666
|
...config,
|
|
18692
|
-
priceOracleAccount: (0,
|
|
18667
|
+
priceOracleAccount: (0, import_common44.toWeb3Pk)(config.priceOracleAccount)
|
|
18693
18668
|
};
|
|
18694
18669
|
}
|
|
18695
18670
|
var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
@@ -18698,35 +18673,35 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
18698
18673
|
amount: args.amount,
|
|
18699
18674
|
assetPriceOracle: toAnchorAssetPriceOracleConfig2(args.assetPriceOracle)
|
|
18700
18675
|
}).accountsPartial({
|
|
18701
|
-
manager: (0,
|
|
18702
|
-
allocationVault: (0,
|
|
18703
|
-
sourceVault: args.sourceVault ? (0,
|
|
18704
|
-
sourceVaultOracle: args.sourceVaultOracle ? (0,
|
|
18705
|
-
destinationVault: (0,
|
|
18706
|
-
destinationVaultOracle: (0,
|
|
18707
|
-
mint: (0,
|
|
18708
|
-
sourceShareMint: args.sourceShareMint ? (0,
|
|
18709
|
-
destinationShareMint: (0,
|
|
18710
|
-
allocationMintAta: (0,
|
|
18711
|
-
sourceVaultMintAta: args.sourceVaultMintAta ? (0,
|
|
18712
|
-
destinationVaultMintAta: (0,
|
|
18713
|
-
destinationFeeVault: (0,
|
|
18714
|
-
destinationFeeVaultMintAta: (0,
|
|
18715
|
-
allocationSourceShareAta: args.allocationSourceShareAta ? (0,
|
|
18716
|
-
allocationDestinationShareAta: (0,
|
|
18676
|
+
manager: (0, import_common44.toWeb3Pk)(args.manager),
|
|
18677
|
+
allocationVault: (0, import_common44.toWeb3Pk)(args.allocationVault),
|
|
18678
|
+
sourceVault: args.sourceVault ? (0, import_common44.toWeb3Pk)(args.sourceVault) : null,
|
|
18679
|
+
sourceVaultOracle: args.sourceVaultOracle ? (0, import_common44.toWeb3Pk)(args.sourceVaultOracle) : null,
|
|
18680
|
+
destinationVault: (0, import_common44.toWeb3Pk)(args.destinationVault),
|
|
18681
|
+
destinationVaultOracle: (0, import_common44.toWeb3Pk)(args.destinationVaultOracle),
|
|
18682
|
+
mint: (0, import_common44.toWeb3Pk)(args.mint),
|
|
18683
|
+
sourceShareMint: args.sourceShareMint ? (0, import_common44.toWeb3Pk)(args.sourceShareMint) : null,
|
|
18684
|
+
destinationShareMint: (0, import_common44.toWeb3Pk)(args.destinationShareMint),
|
|
18685
|
+
allocationMintAta: (0, import_common44.toWeb3Pk)(args.allocationMintAta),
|
|
18686
|
+
sourceVaultMintAta: args.sourceVaultMintAta ? (0, import_common44.toWeb3Pk)(args.sourceVaultMintAta) : null,
|
|
18687
|
+
destinationVaultMintAta: (0, import_common44.toWeb3Pk)(args.destinationVaultMintAta),
|
|
18688
|
+
destinationFeeVault: (0, import_common44.toWeb3Pk)(args.destinationFeeVault),
|
|
18689
|
+
destinationFeeVaultMintAta: (0, import_common44.toWeb3Pk)(args.destinationFeeVaultMintAta),
|
|
18690
|
+
allocationSourceShareAta: args.allocationSourceShareAta ? (0, import_common44.toWeb3Pk)(args.allocationSourceShareAta) : null,
|
|
18691
|
+
allocationDestinationShareAta: (0, import_common44.toWeb3Pk)(
|
|
18717
18692
|
args.allocationDestinationShareAta
|
|
18718
18693
|
),
|
|
18719
|
-
sourceVaultTrancheState: args.sourceVaultTrancheState ? (0,
|
|
18720
|
-
destinationVaultTrancheState: args.destinationVaultTrancheState ? (0,
|
|
18721
|
-
assetOracleAccount: args.assetOracleAccount ? (0,
|
|
18722
|
-
assetTokenProgram: (0,
|
|
18723
|
-
sourceShareTokenProgram: (0,
|
|
18724
|
-
destinationShareTokenProgram: (0,
|
|
18694
|
+
sourceVaultTrancheState: args.sourceVaultTrancheState ? (0, import_common44.toWeb3Pk)(args.sourceVaultTrancheState) : null,
|
|
18695
|
+
destinationVaultTrancheState: args.destinationVaultTrancheState ? (0, import_common44.toWeb3Pk)(args.destinationVaultTrancheState) : null,
|
|
18696
|
+
assetOracleAccount: args.assetOracleAccount ? (0, import_common44.toWeb3Pk)(args.assetOracleAccount) : null,
|
|
18697
|
+
assetTokenProgram: (0, import_common44.toWeb3Pk)(args.assetTokenProgram),
|
|
18698
|
+
sourceShareTokenProgram: (0, import_common44.toWeb3Pk)(args.sourceShareTokenProgram),
|
|
18699
|
+
destinationShareTokenProgram: (0, import_common44.toWeb3Pk)(
|
|
18725
18700
|
args.destinationShareTokenProgram
|
|
18726
18701
|
),
|
|
18727
18702
|
associatedTokenProgram: import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
18728
|
-
systemProgram:
|
|
18729
|
-
}).instruction().then(
|
|
18703
|
+
systemProgram: import_web325.SystemProgram.programId
|
|
18704
|
+
}).instruction().then(import_common44.toKitInstruction);
|
|
18730
18705
|
}
|
|
18731
18706
|
async deriveIxArgs(txArgs) {
|
|
18732
18707
|
const assetTokenProgram = txArgs.assetTokenProgram ?? TOKEN_PROGRAM_ID;
|
|
@@ -18759,33 +18734,33 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
18759
18734
|
assetTokenProgram,
|
|
18760
18735
|
sourceShareTokenProgram,
|
|
18761
18736
|
destinationShareTokenProgram,
|
|
18762
|
-
allocationMintAta: (0,
|
|
18737
|
+
allocationMintAta: (0, import_common44.getAtaAddress)(
|
|
18763
18738
|
txArgs.mint,
|
|
18764
18739
|
txArgs.allocationVault,
|
|
18765
18740
|
assetTokenProgram,
|
|
18766
18741
|
true
|
|
18767
18742
|
),
|
|
18768
|
-
sourceVaultMintAta: sourceVault ? (0,
|
|
18769
|
-
destinationVaultMintAta: (0,
|
|
18743
|
+
sourceVaultMintAta: sourceVault ? (0, import_common44.getAtaAddress)(txArgs.mint, sourceVault, assetTokenProgram, true) : null,
|
|
18744
|
+
destinationVaultMintAta: (0, import_common44.getAtaAddress)(
|
|
18770
18745
|
txArgs.mint,
|
|
18771
18746
|
txArgs.destinationVault,
|
|
18772
18747
|
assetTokenProgram,
|
|
18773
18748
|
true
|
|
18774
18749
|
),
|
|
18775
18750
|
destinationFeeVault,
|
|
18776
|
-
destinationFeeVaultMintAta: (0,
|
|
18751
|
+
destinationFeeVaultMintAta: (0, import_common44.getAtaAddress)(
|
|
18777
18752
|
txArgs.mint,
|
|
18778
18753
|
destinationFeeVault,
|
|
18779
18754
|
assetTokenProgram,
|
|
18780
18755
|
true
|
|
18781
18756
|
),
|
|
18782
|
-
allocationSourceShareAta: sourceShareMint && sourceVault ? (0,
|
|
18757
|
+
allocationSourceShareAta: sourceShareMint && sourceVault ? (0, import_common44.getAtaAddress)(
|
|
18783
18758
|
sourceShareMint,
|
|
18784
18759
|
txArgs.allocationVault,
|
|
18785
18760
|
sourceShareTokenProgram,
|
|
18786
18761
|
true
|
|
18787
18762
|
) : null,
|
|
18788
|
-
allocationDestinationShareAta: (0,
|
|
18763
|
+
allocationDestinationShareAta: (0, import_common44.getAtaAddress)(
|
|
18789
18764
|
txArgs.destinationShareMint,
|
|
18790
18765
|
txArgs.allocationVault,
|
|
18791
18766
|
destinationShareTokenProgram,
|
|
@@ -18794,38 +18769,38 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
18794
18769
|
};
|
|
18795
18770
|
}
|
|
18796
18771
|
async buildPreambleInstructions(args) {
|
|
18797
|
-
const payer = (0,
|
|
18772
|
+
const payer = (0, import_common44.toWeb3Pk)(args.manager);
|
|
18798
18773
|
const instructions2 = [
|
|
18799
18774
|
(0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
|
|
18800
18775
|
payer,
|
|
18801
|
-
(0,
|
|
18802
|
-
(0,
|
|
18803
|
-
(0,
|
|
18804
|
-
(0,
|
|
18776
|
+
(0, import_common44.toWeb3Pk)(args.allocationMintAta),
|
|
18777
|
+
(0, import_common44.toWeb3Pk)(args.allocationVault),
|
|
18778
|
+
(0, import_common44.toWeb3Pk)(args.mint),
|
|
18779
|
+
(0, import_common44.toWeb3Pk)(args.assetTokenProgram),
|
|
18805
18780
|
import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
18806
18781
|
),
|
|
18807
18782
|
(0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
|
|
18808
18783
|
payer,
|
|
18809
|
-
(0,
|
|
18810
|
-
(0,
|
|
18811
|
-
(0,
|
|
18812
|
-
(0,
|
|
18784
|
+
(0, import_common44.toWeb3Pk)(args.destinationVaultMintAta),
|
|
18785
|
+
(0, import_common44.toWeb3Pk)(args.destinationVault),
|
|
18786
|
+
(0, import_common44.toWeb3Pk)(args.mint),
|
|
18787
|
+
(0, import_common44.toWeb3Pk)(args.assetTokenProgram),
|
|
18813
18788
|
import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
18814
18789
|
),
|
|
18815
18790
|
(0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
|
|
18816
18791
|
payer,
|
|
18817
|
-
(0,
|
|
18818
|
-
(0,
|
|
18819
|
-
(0,
|
|
18820
|
-
(0,
|
|
18792
|
+
(0, import_common44.toWeb3Pk)(args.destinationFeeVaultMintAta),
|
|
18793
|
+
(0, import_common44.toWeb3Pk)(args.destinationFeeVault),
|
|
18794
|
+
(0, import_common44.toWeb3Pk)(args.mint),
|
|
18795
|
+
(0, import_common44.toWeb3Pk)(args.assetTokenProgram),
|
|
18821
18796
|
import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
18822
18797
|
),
|
|
18823
18798
|
(0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
|
|
18824
18799
|
payer,
|
|
18825
|
-
(0,
|
|
18826
|
-
(0,
|
|
18827
|
-
(0,
|
|
18828
|
-
(0,
|
|
18800
|
+
(0, import_common44.toWeb3Pk)(args.allocationDestinationShareAta),
|
|
18801
|
+
(0, import_common44.toWeb3Pk)(args.allocationVault),
|
|
18802
|
+
(0, import_common44.toWeb3Pk)(args.destinationShareMint),
|
|
18803
|
+
(0, import_common44.toWeb3Pk)(args.destinationShareTokenProgram),
|
|
18829
18804
|
import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
18830
18805
|
)
|
|
18831
18806
|
];
|
|
@@ -18833,23 +18808,23 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
18833
18808
|
instructions2.push(
|
|
18834
18809
|
(0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
|
|
18835
18810
|
payer,
|
|
18836
|
-
(0,
|
|
18837
|
-
(0,
|
|
18838
|
-
(0,
|
|
18839
|
-
(0,
|
|
18811
|
+
(0, import_common44.toWeb3Pk)(args.sourceVaultMintAta),
|
|
18812
|
+
(0, import_common44.toWeb3Pk)(args.sourceVault),
|
|
18813
|
+
(0, import_common44.toWeb3Pk)(args.mint),
|
|
18814
|
+
(0, import_common44.toWeb3Pk)(args.assetTokenProgram),
|
|
18840
18815
|
import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
18841
18816
|
),
|
|
18842
18817
|
(0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
|
|
18843
18818
|
payer,
|
|
18844
|
-
(0,
|
|
18845
|
-
(0,
|
|
18846
|
-
(0,
|
|
18847
|
-
(0,
|
|
18819
|
+
(0, import_common44.toWeb3Pk)(args.allocationSourceShareAta),
|
|
18820
|
+
(0, import_common44.toWeb3Pk)(args.allocationVault),
|
|
18821
|
+
(0, import_common44.toWeb3Pk)(args.sourceShareMint),
|
|
18822
|
+
(0, import_common44.toWeb3Pk)(args.sourceShareTokenProgram),
|
|
18848
18823
|
import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
18849
18824
|
)
|
|
18850
18825
|
);
|
|
18851
18826
|
}
|
|
18852
|
-
return instructions2.map(
|
|
18827
|
+
return instructions2.map(import_common44.toKitInstruction);
|
|
18853
18828
|
}
|
|
18854
18829
|
async buildPlanExtras(args) {
|
|
18855
18830
|
return {
|
|
@@ -18887,24 +18862,24 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
18887
18862
|
// src/client/builders/requestAsyncWithdraw.ts
|
|
18888
18863
|
var import_core21 = require("@anchor-lang/core");
|
|
18889
18864
|
var import_spl_token21 = require("@solana/spl-token");
|
|
18890
|
-
var
|
|
18891
|
-
var
|
|
18865
|
+
var import_web326 = require("@solana/web3.js");
|
|
18866
|
+
var import_common45 = __toESM(require_dist());
|
|
18892
18867
|
var RequestAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
18893
18868
|
async getIx(args) {
|
|
18894
18869
|
return this.program.methods.requestAsyncWithdraw(args.queueId, args.shareAmount).accountsPartial({
|
|
18895
|
-
user: (0,
|
|
18896
|
-
payer: (0,
|
|
18897
|
-
vault: (0,
|
|
18898
|
-
vaultOracle: (0,
|
|
18899
|
-
withdrawalQueue: (0,
|
|
18900
|
-
outputMint: (0,
|
|
18901
|
-
inputMint: (0,
|
|
18902
|
-
userInputAta: (0,
|
|
18903
|
-
queueInputAta: (0,
|
|
18904
|
-
shareTokenProgram: (0,
|
|
18870
|
+
user: (0, import_common45.toWeb3Pk)(args.user),
|
|
18871
|
+
payer: (0, import_common45.toWeb3Pk)(args.payer),
|
|
18872
|
+
vault: (0, import_common45.toWeb3Pk)(args.vault),
|
|
18873
|
+
vaultOracle: (0, import_common45.toWeb3Pk)(args.vaultOracle),
|
|
18874
|
+
withdrawalQueue: (0, import_common45.toWeb3Pk)(args.withdrawalQueue),
|
|
18875
|
+
outputMint: (0, import_common45.toWeb3Pk)(args.outputMint),
|
|
18876
|
+
inputMint: (0, import_common45.toWeb3Pk)(args.inputMint),
|
|
18877
|
+
userInputAta: (0, import_common45.toWeb3Pk)(args.userInputAta),
|
|
18878
|
+
queueInputAta: (0, import_common45.toWeb3Pk)(args.queueInputAta),
|
|
18879
|
+
shareTokenProgram: (0, import_common45.toWeb3Pk)(args.shareTokenProgram),
|
|
18905
18880
|
associatedTokenProgram: import_spl_token21.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
18906
|
-
systemProgram:
|
|
18907
|
-
}).instruction().then(
|
|
18881
|
+
systemProgram: import_web326.SystemProgram.programId
|
|
18882
|
+
}).instruction().then(import_common45.toKitInstruction);
|
|
18908
18883
|
}
|
|
18909
18884
|
async deriveIxArgs(txArgs) {
|
|
18910
18885
|
const payer = txArgs.payer ?? txArgs.user;
|
|
@@ -18922,7 +18897,7 @@ var RequestAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
18922
18897
|
),
|
|
18923
18898
|
this.account.fetchVault(txArgs.vault)
|
|
18924
18899
|
]);
|
|
18925
|
-
const shareMint = txArgs.shareMint ?? (0,
|
|
18900
|
+
const shareMint = txArgs.shareMint ?? (0, import_common45.fromWeb3Pk)(vaultData.mint);
|
|
18926
18901
|
const queuePda = txArgs.withdrawalQueue ?? withdrawalQueue;
|
|
18927
18902
|
return {
|
|
18928
18903
|
user: txArgs.user,
|
|
@@ -18935,8 +18910,8 @@ var RequestAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
18935
18910
|
queueId: txArgs.queueId,
|
|
18936
18911
|
shareAmount: new import_core21.BN(txArgs.shareAmount.toString()),
|
|
18937
18912
|
shareTokenProgram,
|
|
18938
|
-
userInputAta: txArgs.userInputAta ?? (0,
|
|
18939
|
-
queueInputAta: (0,
|
|
18913
|
+
userInputAta: txArgs.userInputAta ?? (0, import_common45.getAtaAddress)(shareMint, txArgs.user, shareTokenProgram, true),
|
|
18914
|
+
queueInputAta: (0, import_common45.getAtaAddress)(
|
|
18940
18915
|
shareMint,
|
|
18941
18916
|
queuePda,
|
|
18942
18917
|
shareTokenProgram,
|
|
@@ -18958,8 +18933,8 @@ var RequestAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
18958
18933
|
|
|
18959
18934
|
// src/client/builders/fulfillAsyncWithdraw.ts
|
|
18960
18935
|
var import_spl_token22 = require("@solana/spl-token");
|
|
18961
|
-
var
|
|
18962
|
-
var
|
|
18936
|
+
var import_web327 = require("@solana/web3.js");
|
|
18937
|
+
var import_common46 = __toESM(require_dist());
|
|
18963
18938
|
var FulfillAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
18964
18939
|
async getIx(args) {
|
|
18965
18940
|
const externalWithdrawIxRefs = args.externalWithdrawIxRefs ?? null;
|
|
@@ -18969,24 +18944,24 @@ var FulfillAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
18969
18944
|
externalLiquiditySource
|
|
18970
18945
|
);
|
|
18971
18946
|
return methods.accountsPartial({
|
|
18972
|
-
signer: (0,
|
|
18973
|
-
owner: (0,
|
|
18974
|
-
queuePayer: (0,
|
|
18975
|
-
vault: (0,
|
|
18976
|
-
vaultOracle: (0,
|
|
18977
|
-
vaultTrancheState: args.vaultTrancheState ? (0,
|
|
18978
|
-
withdrawalQueue: (0,
|
|
18979
|
-
outputMint: (0,
|
|
18980
|
-
inputMint: (0,
|
|
18981
|
-
ownerInputAta: (0,
|
|
18982
|
-
ownerOutputAta: (0,
|
|
18983
|
-
vaultOutputAta: (0,
|
|
18984
|
-
queueInputAta: (0,
|
|
18985
|
-
assetTokenProgram: (0,
|
|
18986
|
-
shareTokenProgram: (0,
|
|
18947
|
+
signer: (0, import_common46.toWeb3Pk)(args.signer),
|
|
18948
|
+
owner: (0, import_common46.toWeb3Pk)(args.owner),
|
|
18949
|
+
queuePayer: (0, import_common46.toWeb3Pk)(args.queuePayer),
|
|
18950
|
+
vault: (0, import_common46.toWeb3Pk)(args.vault),
|
|
18951
|
+
vaultOracle: (0, import_common46.toWeb3Pk)(args.vaultOracle),
|
|
18952
|
+
vaultTrancheState: args.vaultTrancheState ? (0, import_common46.toWeb3Pk)(args.vaultTrancheState) : null,
|
|
18953
|
+
withdrawalQueue: (0, import_common46.toWeb3Pk)(args.withdrawalQueue),
|
|
18954
|
+
outputMint: (0, import_common46.toWeb3Pk)(args.outputMint),
|
|
18955
|
+
inputMint: (0, import_common46.toWeb3Pk)(args.inputMint),
|
|
18956
|
+
ownerInputAta: (0, import_common46.toWeb3Pk)(args.ownerInputAta),
|
|
18957
|
+
ownerOutputAta: (0, import_common46.toWeb3Pk)(args.ownerOutputAta),
|
|
18958
|
+
vaultOutputAta: (0, import_common46.toWeb3Pk)(args.vaultOutputAta),
|
|
18959
|
+
queueInputAta: (0, import_common46.toWeb3Pk)(args.queueInputAta),
|
|
18960
|
+
assetTokenProgram: (0, import_common46.toWeb3Pk)(args.assetTokenProgram),
|
|
18961
|
+
shareTokenProgram: (0, import_common46.toWeb3Pk)(args.shareTokenProgram),
|
|
18987
18962
|
associatedTokenProgram: import_spl_token22.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
18988
|
-
systemProgram:
|
|
18989
|
-
}).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(
|
|
18963
|
+
systemProgram: import_web327.SystemProgram.programId
|
|
18964
|
+
}).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(import_common46.toKitInstruction);
|
|
18990
18965
|
}
|
|
18991
18966
|
async deriveIxArgs(txArgs) {
|
|
18992
18967
|
const connection = this.program.provider.connection;
|
|
@@ -19025,13 +19000,13 @@ var FulfillAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
19025
19000
|
),
|
|
19026
19001
|
this.account.fetchVault(txArgs.vault, { fresh: true })
|
|
19027
19002
|
]);
|
|
19028
|
-
const shareMint = txArgs.shareMint ?? (0,
|
|
19003
|
+
const shareMint = txArgs.shareMint ?? (0, import_common46.fromWeb3Pk)(vaultData.mint);
|
|
19029
19004
|
const queuePda = txArgs.withdrawalQueue ?? withdrawalQueue;
|
|
19030
19005
|
const queue = await this.account.fetchVaultWithdrawalQueue(queuePda, {
|
|
19031
19006
|
fresh: true
|
|
19032
19007
|
});
|
|
19033
|
-
const queuePayer = txArgs.queuePayer ?? (0,
|
|
19034
|
-
const vaultOutputAta = (0,
|
|
19008
|
+
const queuePayer = txArgs.queuePayer ?? (0, import_common46.fromWeb3Pk)(queue.parties.payer);
|
|
19009
|
+
const vaultOutputAta = (0, import_common46.getAtaAddress)(
|
|
19035
19010
|
txArgs.assetMint,
|
|
19036
19011
|
txArgs.vault,
|
|
19037
19012
|
assetTokenProgram,
|
|
@@ -19050,7 +19025,7 @@ var FulfillAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
19050
19025
|
skipExternalLiquidity = localAmount >= BigInt(queue.request.outputAmount.toString());
|
|
19051
19026
|
} else {
|
|
19052
19027
|
const holding = vaultData.holdings.find(
|
|
19053
|
-
(h) => (0,
|
|
19028
|
+
(h) => (0, import_common46.fromWeb3Pk)(h.mint) === txArgs.assetMint
|
|
19054
19029
|
);
|
|
19055
19030
|
if (!holding)
|
|
19056
19031
|
throw new Error("Withdrawal asset is not a vault holding");
|
|
@@ -19068,7 +19043,7 @@ var FulfillAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
19068
19043
|
decimals: holding.decimals,
|
|
19069
19044
|
// The queue owner receives the exemption, not the fulfiller.
|
|
19070
19045
|
feeBps: WALLET_FEE_EXEMPT_WHITELIST.includes(
|
|
19071
|
-
(0,
|
|
19046
|
+
(0, import_common46.fromWeb3Pk)(queue.parties.owner)
|
|
19072
19047
|
) ? 0 : vaultData.config.fees.burnFeeBps
|
|
19073
19048
|
},
|
|
19074
19049
|
BigInt(queue.request.inputAmount.toString())
|
|
@@ -19104,15 +19079,15 @@ var FulfillAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
19104
19079
|
inputMint: shareMint,
|
|
19105
19080
|
assetTokenProgram,
|
|
19106
19081
|
shareTokenProgram,
|
|
19107
|
-
ownerInputAta: txArgs.ownerInputAta ?? (0,
|
|
19108
|
-
ownerOutputAta: (0,
|
|
19082
|
+
ownerInputAta: txArgs.ownerInputAta ?? (0, import_common46.getAtaAddress)(shareMint, txArgs.owner, shareTokenProgram, true),
|
|
19083
|
+
ownerOutputAta: (0, import_common46.getAtaAddress)(
|
|
19109
19084
|
txArgs.assetMint,
|
|
19110
19085
|
txArgs.owner,
|
|
19111
19086
|
assetTokenProgram,
|
|
19112
19087
|
true
|
|
19113
19088
|
),
|
|
19114
19089
|
vaultOutputAta,
|
|
19115
|
-
queueInputAta: (0,
|
|
19090
|
+
queueInputAta: (0, import_common46.getAtaAddress)(
|
|
19116
19091
|
shareMint,
|
|
19117
19092
|
queuePda,
|
|
19118
19093
|
shareTokenProgram,
|
|
@@ -19130,7 +19105,7 @@ var FulfillAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
19130
19105
|
);
|
|
19131
19106
|
}
|
|
19132
19107
|
async buildPreambleInstructions(args) {
|
|
19133
|
-
const defaultOwnerInputAta = (0,
|
|
19108
|
+
const defaultOwnerInputAta = (0, import_common46.getAtaAddress)(
|
|
19134
19109
|
args.inputMint,
|
|
19135
19110
|
args.owner,
|
|
19136
19111
|
args.shareTokenProgram,
|
|
@@ -19143,27 +19118,24 @@ var FulfillAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
19143
19118
|
program: args.assetTokenProgram
|
|
19144
19119
|
}
|
|
19145
19120
|
];
|
|
19146
|
-
if ((0,
|
|
19121
|
+
if ((0, import_common46.toWeb3Pk)(args.ownerInputAta).equals((0, import_common46.toWeb3Pk)(defaultOwnerInputAta))) {
|
|
19147
19122
|
atas.push({
|
|
19148
19123
|
mint: args.inputMint,
|
|
19149
19124
|
ata: args.ownerInputAta,
|
|
19150
19125
|
program: args.shareTokenProgram
|
|
19151
19126
|
});
|
|
19152
19127
|
}
|
|
19153
|
-
return
|
|
19154
|
-
|
|
19155
|
-
|
|
19156
|
-
|
|
19157
|
-
(0,
|
|
19158
|
-
|
|
19159
|
-
|
|
19160
|
-
|
|
19161
|
-
(0, import_common47.toWeb3Pk)(mint),
|
|
19162
|
-
(0, import_common47.toWeb3Pk)(program)
|
|
19163
|
-
)
|
|
19128
|
+
return atas.map(
|
|
19129
|
+
({ mint, ata, program }) => (0, import_common46.toKitInstruction)(
|
|
19130
|
+
(0, import_spl_token22.createAssociatedTokenAccountIdempotentInstruction)(
|
|
19131
|
+
(0, import_common46.toWeb3Pk)(args.signer),
|
|
19132
|
+
(0, import_common46.toWeb3Pk)(ata),
|
|
19133
|
+
(0, import_common46.toWeb3Pk)(args.owner),
|
|
19134
|
+
(0, import_common46.toWeb3Pk)(mint),
|
|
19135
|
+
(0, import_common46.toWeb3Pk)(program)
|
|
19164
19136
|
)
|
|
19165
19137
|
)
|
|
19166
|
-
|
|
19138
|
+
);
|
|
19167
19139
|
}
|
|
19168
19140
|
async buildPlanExtras(args) {
|
|
19169
19141
|
return {
|
|
@@ -19179,16 +19151,16 @@ var FulfillAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
19179
19151
|
};
|
|
19180
19152
|
|
|
19181
19153
|
// src/client/builders/priceAsyncWithdraw.ts
|
|
19182
|
-
var
|
|
19154
|
+
var import_common47 = __toESM(require_dist());
|
|
19183
19155
|
var PriceAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
19184
19156
|
async getIx(args) {
|
|
19185
19157
|
return this.program.methods.priceAsyncWithdraw().accountsPartial({
|
|
19186
|
-
hwManager: (0,
|
|
19187
|
-
vault: (0,
|
|
19188
|
-
vaultOracle: (0,
|
|
19189
|
-
vaultTrancheState: args.vaultTrancheState ? (0,
|
|
19190
|
-
withdrawalQueue: (0,
|
|
19191
|
-
}).instruction().then(
|
|
19158
|
+
hwManager: (0, import_common47.toWeb3Pk)(args.hwManager),
|
|
19159
|
+
vault: (0, import_common47.toWeb3Pk)(args.vault),
|
|
19160
|
+
vaultOracle: (0, import_common47.toWeb3Pk)(args.vaultOracle),
|
|
19161
|
+
vaultTrancheState: args.vaultTrancheState ? (0, import_common47.toWeb3Pk)(args.vaultTrancheState) : null,
|
|
19162
|
+
withdrawalQueue: (0, import_common47.toWeb3Pk)(args.withdrawalQueue)
|
|
19163
|
+
}).instruction().then(import_common47.toKitInstruction);
|
|
19192
19164
|
}
|
|
19193
19165
|
async deriveIxArgs(args) {
|
|
19194
19166
|
const [[oracle], tranche] = await Promise.all([
|
|
@@ -19217,22 +19189,22 @@ var PriceAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
19217
19189
|
|
|
19218
19190
|
// src/client/builders/cancelAsyncWithdraw.ts
|
|
19219
19191
|
var import_spl_token23 = require("@solana/spl-token");
|
|
19220
|
-
var
|
|
19221
|
-
var
|
|
19192
|
+
var import_web328 = require("@solana/web3.js");
|
|
19193
|
+
var import_common48 = __toESM(require_dist());
|
|
19222
19194
|
var CancelAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
19223
19195
|
async getIx(args) {
|
|
19224
19196
|
return this.program.methods.cancelAsyncWithdraw().accountsPartial({
|
|
19225
|
-
user: (0,
|
|
19226
|
-
payer: (0,
|
|
19227
|
-
vault: (0,
|
|
19228
|
-
withdrawalQueue: (0,
|
|
19229
|
-
inputMint: (0,
|
|
19230
|
-
userInputAta: (0,
|
|
19231
|
-
queueInputAta: (0,
|
|
19232
|
-
shareTokenProgram: (0,
|
|
19197
|
+
user: (0, import_common48.toWeb3Pk)(args.user),
|
|
19198
|
+
payer: (0, import_common48.toWeb3Pk)(args.payer),
|
|
19199
|
+
vault: (0, import_common48.toWeb3Pk)(args.vault),
|
|
19200
|
+
withdrawalQueue: (0, import_common48.toWeb3Pk)(args.withdrawalQueue),
|
|
19201
|
+
inputMint: (0, import_common48.toWeb3Pk)(args.inputMint),
|
|
19202
|
+
userInputAta: (0, import_common48.toWeb3Pk)(args.userInputAta),
|
|
19203
|
+
queueInputAta: (0, import_common48.toWeb3Pk)(args.queueInputAta),
|
|
19204
|
+
shareTokenProgram: (0, import_common48.toWeb3Pk)(args.shareTokenProgram),
|
|
19233
19205
|
associatedTokenProgram: import_spl_token23.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
19234
|
-
systemProgram:
|
|
19235
|
-
}).instruction().then(
|
|
19206
|
+
systemProgram: import_web328.SystemProgram.programId
|
|
19207
|
+
}).instruction().then(import_common48.toKitInstruction);
|
|
19236
19208
|
}
|
|
19237
19209
|
async deriveIxArgs(args) {
|
|
19238
19210
|
const [[derived], vault] = await Promise.all([
|
|
@@ -19248,7 +19220,7 @@ var CancelAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
19248
19220
|
withdrawalQueue,
|
|
19249
19221
|
{ fresh: true }
|
|
19250
19222
|
);
|
|
19251
|
-
const inputMint = (0,
|
|
19223
|
+
const inputMint = (0, import_common48.fromWeb3Pk)(vault.mint);
|
|
19252
19224
|
const shareTokenProgram = tokenProgramAddressFromIdlEnum(
|
|
19253
19225
|
vault.mintTokenProgram
|
|
19254
19226
|
);
|
|
@@ -19258,9 +19230,9 @@ var CancelAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
19258
19230
|
withdrawalQueue,
|
|
19259
19231
|
inputMint,
|
|
19260
19232
|
shareTokenProgram,
|
|
19261
|
-
payer: (0,
|
|
19262
|
-
userInputAta: args.userInputAta ?? (0,
|
|
19263
|
-
queueInputAta: (0,
|
|
19233
|
+
payer: (0, import_common48.fromWeb3Pk)(queue.parties.payer),
|
|
19234
|
+
userInputAta: args.userInputAta ?? (0, import_common48.getAtaAddress)(inputMint, args.user, shareTokenProgram, true),
|
|
19235
|
+
queueInputAta: (0, import_common48.getAtaAddress)(
|
|
19264
19236
|
inputMint,
|
|
19265
19237
|
withdrawalQueue,
|
|
19266
19238
|
shareTokenProgram,
|
|
@@ -19269,7 +19241,7 @@ var CancelAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
19269
19241
|
};
|
|
19270
19242
|
}
|
|
19271
19243
|
async buildPreambleInstructions(args) {
|
|
19272
|
-
const ata = (0,
|
|
19244
|
+
const ata = (0, import_common48.getAtaAddress)(
|
|
19273
19245
|
args.inputMint,
|
|
19274
19246
|
args.user,
|
|
19275
19247
|
args.shareTokenProgram,
|
|
@@ -19277,13 +19249,13 @@ var CancelAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
19277
19249
|
);
|
|
19278
19250
|
if (ata !== args.userInputAta) return [];
|
|
19279
19251
|
return [
|
|
19280
|
-
(0,
|
|
19252
|
+
(0, import_common48.toKitInstruction)(
|
|
19281
19253
|
(0, import_spl_token23.createAssociatedTokenAccountIdempotentInstruction)(
|
|
19282
|
-
(0,
|
|
19283
|
-
(0,
|
|
19284
|
-
(0,
|
|
19285
|
-
(0,
|
|
19286
|
-
(0,
|
|
19254
|
+
(0, import_common48.toWeb3Pk)(args.user),
|
|
19255
|
+
(0, import_common48.toWeb3Pk)(ata),
|
|
19256
|
+
(0, import_common48.toWeb3Pk)(args.user),
|
|
19257
|
+
(0, import_common48.toWeb3Pk)(args.inputMint),
|
|
19258
|
+
(0, import_common48.toWeb3Pk)(args.shareTokenProgram)
|
|
19287
19259
|
)
|
|
19288
19260
|
)
|
|
19289
19261
|
];
|
|
@@ -19394,15 +19366,15 @@ var VaultClient = class {
|
|
|
19394
19366
|
this.vaultLookupTables
|
|
19395
19367
|
);
|
|
19396
19368
|
const { blockhash, lastValidBlockHeight } = await this.provider.connection.getLatestBlockhash("confirmed");
|
|
19397
|
-
const instructions2 = plan.instructions.map(
|
|
19369
|
+
const instructions2 = plan.instructions.map(import_common49.fromKitInstruction);
|
|
19398
19370
|
let tx;
|
|
19399
19371
|
if (plan.lookupTables?.length) {
|
|
19400
|
-
const tables = await (0,
|
|
19372
|
+
const tables = await (0, import_common49.fetchLookupTables)(
|
|
19401
19373
|
this.provider.connection,
|
|
19402
19374
|
plan.lookupTables
|
|
19403
19375
|
);
|
|
19404
|
-
tx = new
|
|
19405
|
-
new
|
|
19376
|
+
tx = new import_web329.VersionedTransaction(
|
|
19377
|
+
new import_web329.TransactionMessage({
|
|
19406
19378
|
payerKey: payer.publicKey,
|
|
19407
19379
|
recentBlockhash: blockhash,
|
|
19408
19380
|
instructions: instructions2
|
|
@@ -19410,7 +19382,7 @@ var VaultClient = class {
|
|
|
19410
19382
|
);
|
|
19411
19383
|
tx.sign([payer, ...extraSigners]);
|
|
19412
19384
|
} else {
|
|
19413
|
-
tx = new
|
|
19385
|
+
tx = new import_web329.Transaction().add(...instructions2);
|
|
19414
19386
|
tx.feePayer = payer.publicKey;
|
|
19415
19387
|
tx.recentBlockhash = blockhash;
|
|
19416
19388
|
tx.sign(payer, ...extraSigners);
|
|
@@ -19449,13 +19421,13 @@ var VaultClient = class {
|
|
|
19449
19421
|
const { blockhash } = await this.provider.connection.getLatestBlockhash(
|
|
19450
19422
|
"confirmed"
|
|
19451
19423
|
);
|
|
19452
|
-
const lookupTableAccounts = plan.lookupTables?.length ? await (0,
|
|
19453
|
-
const message2 = new
|
|
19424
|
+
const lookupTableAccounts = plan.lookupTables?.length ? await (0, import_common49.fetchLookupTables)(this.provider.connection, plan.lookupTables) : [];
|
|
19425
|
+
const message2 = new import_web329.TransactionMessage({
|
|
19454
19426
|
payerKey: payer.publicKey,
|
|
19455
19427
|
recentBlockhash: blockhash,
|
|
19456
|
-
instructions: plan.instructions.map(
|
|
19428
|
+
instructions: plan.instructions.map(import_common49.fromKitInstruction)
|
|
19457
19429
|
}).compileToV0Message(lookupTableAccounts);
|
|
19458
|
-
const tx = new
|
|
19430
|
+
const tx = new import_web329.VersionedTransaction(message2);
|
|
19459
19431
|
const result = await this.provider.connection.simulateTransaction(tx, {
|
|
19460
19432
|
sigVerify: false,
|
|
19461
19433
|
commitment: "processed"
|
|
@@ -19529,7 +19501,7 @@ function resolveKeypairPath(keypairPath) {
|
|
|
19529
19501
|
}
|
|
19530
19502
|
function loadKeypair(keypairPath) {
|
|
19531
19503
|
const raw = import_fs.default.readFileSync(resolveKeypairPath(keypairPath), "utf-8");
|
|
19532
|
-
return
|
|
19504
|
+
return import_web330.Keypair.fromSecretKey(new Uint8Array(JSON.parse(raw)));
|
|
19533
19505
|
}
|
|
19534
19506
|
var ENV_AGNOSTIC_ROLES = /* @__PURE__ */ new Set(["fulfiller", "rebalancer"]);
|
|
19535
19507
|
function defaultKeypairPath(env, role = "vault") {
|
|
@@ -19540,7 +19512,7 @@ function defaultKeypairPath(env, role = "vault") {
|
|
|
19540
19512
|
}
|
|
19541
19513
|
function createVaultClient(env, opts = {}) {
|
|
19542
19514
|
const payer = opts.keypair ?? loadKeypair(opts.keypairPath ?? defaultKeypairPath(env, opts.role));
|
|
19543
|
-
const connection = new
|
|
19515
|
+
const connection = new import_web330.Connection(opts.rpcUrl ?? getRpcUrl(env), "confirmed");
|
|
19544
19516
|
const provider = new import_core23.AnchorProvider(connection, new import_core23.Wallet(payer), {
|
|
19545
19517
|
commitment: "confirmed"
|
|
19546
19518
|
});
|
|
@@ -19557,11 +19529,11 @@ function createVaultClient(env, opts = {}) {
|
|
|
19557
19529
|
client,
|
|
19558
19530
|
provider,
|
|
19559
19531
|
payer,
|
|
19560
|
-
signer: (0,
|
|
19532
|
+
signer: (0, import_common50.fromWeb3Pk)(payer.publicKey)
|
|
19561
19533
|
};
|
|
19562
19534
|
}
|
|
19563
19535
|
function keypairAddress(keypairPath) {
|
|
19564
|
-
return (0,
|
|
19536
|
+
return (0, import_common50.fromWeb3Pk)(loadKeypair(keypairPath).publicKey);
|
|
19565
19537
|
}
|
|
19566
19538
|
|
|
19567
19539
|
// src/utils/math.ts
|
|
@@ -19584,7 +19556,7 @@ function makeProvider(connection, payer) {
|
|
|
19584
19556
|
|
|
19585
19557
|
// src/utils/squads.ts
|
|
19586
19558
|
var squads = __toESM(require("@sqds/multisig"));
|
|
19587
|
-
var
|
|
19559
|
+
var import_web331 = require("@solana/web3.js");
|
|
19588
19560
|
var SQUADS_SIMULATION_COMMITMENT = "processed";
|
|
19589
19561
|
var SquadsProposalExecutionSimulationError = class extends Error {
|
|
19590
19562
|
constructor(transactionError, logs, unitsConsumed) {
|
|
@@ -19608,8 +19580,8 @@ function validateVaultIndex(vaultIndex) {
|
|
|
19608
19580
|
}
|
|
19609
19581
|
function resolveSquadsWalletRoute(route) {
|
|
19610
19582
|
validateVaultIndex(route.vaultIndex);
|
|
19611
|
-
const wallet = new
|
|
19612
|
-
const multisigPda = new
|
|
19583
|
+
const wallet = new import_web331.PublicKey(route.wallet);
|
|
19584
|
+
const multisigPda = new import_web331.PublicKey(route.multisigPda);
|
|
19613
19585
|
const [vaultPda] = squads.getVaultPda({
|
|
19614
19586
|
multisigPda,
|
|
19615
19587
|
index: route.vaultIndex
|
|
@@ -19617,7 +19589,7 @@ function resolveSquadsWalletRoute(route) {
|
|
|
19617
19589
|
return { ...route, wallet, multisigPda, vaultPda };
|
|
19618
19590
|
}
|
|
19619
19591
|
function findSquadsWalletRoute(wallet, routes) {
|
|
19620
|
-
const walletKey = typeof wallet === "string" ? new
|
|
19592
|
+
const walletKey = typeof wallet === "string" ? new import_web331.PublicKey(wallet) : wallet;
|
|
19621
19593
|
const route = routes.find(
|
|
19622
19594
|
(candidate) => candidate.wallet === walletKey.toBase58()
|
|
19623
19595
|
);
|
|
@@ -19635,18 +19607,18 @@ function validateSquadsWalletRoutes(routes) {
|
|
|
19635
19607
|
}
|
|
19636
19608
|
}
|
|
19637
19609
|
function vaultAuthorityForWallet(wallet, routes) {
|
|
19638
|
-
const walletKey = typeof wallet === "string" ? new
|
|
19610
|
+
const walletKey = typeof wallet === "string" ? new import_web331.PublicKey(wallet) : wallet;
|
|
19639
19611
|
return findSquadsWalletRoute(walletKey, routes)?.vaultPda ?? walletKey;
|
|
19640
19612
|
}
|
|
19641
19613
|
async function simulateSquadsProposalExecution(args) {
|
|
19642
19614
|
const { connection, feePayer, instructions: instructions2 } = args;
|
|
19643
19615
|
const recentBlockhash = args.recentBlockhash ?? (await connection.getLatestBlockhash(SQUADS_SIMULATION_COMMITMENT)).blockhash;
|
|
19644
|
-
const message2 = new
|
|
19616
|
+
const message2 = new import_web331.TransactionMessage({
|
|
19645
19617
|
payerKey: feePayer,
|
|
19646
19618
|
recentBlockhash,
|
|
19647
19619
|
instructions: [...instructions2]
|
|
19648
19620
|
}).compileToV0Message(args.addressLookupTableAccounts);
|
|
19649
|
-
const transaction = new
|
|
19621
|
+
const transaction = new import_web331.VersionedTransaction(message2);
|
|
19650
19622
|
const { value } = await connection.simulateTransaction(transaction, {
|
|
19651
19623
|
sigVerify: false,
|
|
19652
19624
|
commitment: SQUADS_SIMULATION_COMMITMENT,
|
|
@@ -19671,7 +19643,7 @@ async function prepareVaultTransaction(args) {
|
|
|
19671
19643
|
throw new Error("Ephemeral signers require a Squads route");
|
|
19672
19644
|
return {
|
|
19673
19645
|
kind: "direct",
|
|
19674
|
-
transaction: new
|
|
19646
|
+
transaction: new import_web331.Transaction().add(...instructions2),
|
|
19675
19647
|
authority: proposer
|
|
19676
19648
|
};
|
|
19677
19649
|
}
|
|
@@ -19724,7 +19696,7 @@ async function prepareVaultTransaction(args) {
|
|
|
19724
19696
|
});
|
|
19725
19697
|
if (replacements.size) {
|
|
19726
19698
|
instructions2 = instructions2.map(
|
|
19727
|
-
(ix) => new
|
|
19699
|
+
(ix) => new import_web331.TransactionInstruction({
|
|
19728
19700
|
programId: ix.programId,
|
|
19729
19701
|
data: ix.data,
|
|
19730
19702
|
keys: ix.keys.map((meta) => ({
|
|
@@ -19752,7 +19724,7 @@ async function prepareVaultTransaction(args) {
|
|
|
19752
19724
|
executionSimulationError = error;
|
|
19753
19725
|
}
|
|
19754
19726
|
}
|
|
19755
|
-
const transactionMessage = new
|
|
19727
|
+
const transactionMessage = new import_web331.TransactionMessage({
|
|
19756
19728
|
payerKey: route.vaultPda,
|
|
19757
19729
|
recentBlockhash: blockhash,
|
|
19758
19730
|
instructions: [...instructions2]
|
|
@@ -19782,7 +19754,7 @@ async function prepareVaultTransaction(args) {
|
|
|
19782
19754
|
});
|
|
19783
19755
|
return {
|
|
19784
19756
|
kind: "squads",
|
|
19785
|
-
transaction: new
|
|
19757
|
+
transaction: new import_web331.Transaction().add(
|
|
19786
19758
|
createVaultTransactionIx,
|
|
19787
19759
|
createProposalIx
|
|
19788
19760
|
),
|
|
@@ -19798,16 +19770,16 @@ async function prepareVaultTransaction(args) {
|
|
|
19798
19770
|
|
|
19799
19771
|
// src/utils/squadsBuffer.ts
|
|
19800
19772
|
var squads2 = __toESM(require("@sqds/multisig"));
|
|
19801
|
-
var
|
|
19773
|
+
var import_web332 = require("@solana/web3.js");
|
|
19802
19774
|
var PacketSize = 1232;
|
|
19803
19775
|
var BufferChunkSize = 700;
|
|
19804
19776
|
var MaxBufferSize = 4e3;
|
|
19805
19777
|
async function prepareSquadsProposalUpload(args) {
|
|
19806
19778
|
const { connection, proposer, prepared } = args;
|
|
19807
19779
|
const transaction = prepared.transaction;
|
|
19808
|
-
const sizeProbe = new
|
|
19780
|
+
const sizeProbe = new import_web332.Transaction({
|
|
19809
19781
|
feePayer: proposer,
|
|
19810
|
-
recentBlockhash:
|
|
19782
|
+
recentBlockhash: import_web332.PublicKey.default.toBase58()
|
|
19811
19783
|
}).add(...transaction.instructions);
|
|
19812
19784
|
let fits = false;
|
|
19813
19785
|
try {
|
|
@@ -19827,7 +19799,7 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
19827
19799
|
let bufferPda;
|
|
19828
19800
|
let bufferIndex = 0;
|
|
19829
19801
|
for (; bufferIndex <= 255; bufferIndex++) {
|
|
19830
|
-
const [candidate] =
|
|
19802
|
+
const [candidate] = import_web332.PublicKey.findProgramAddressSync(
|
|
19831
19803
|
[
|
|
19832
19804
|
Buffer.from("multisig"),
|
|
19833
19805
|
prepared.multisigPda.toBuffer(),
|
|
@@ -19855,7 +19827,7 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
19855
19827
|
creator: proposer
|
|
19856
19828
|
};
|
|
19857
19829
|
const setupTransactions = [
|
|
19858
|
-
new
|
|
19830
|
+
new import_web332.Transaction().add(
|
|
19859
19831
|
squads2.generated.createTransactionBufferCreateInstruction(
|
|
19860
19832
|
{
|
|
19861
19833
|
...accounts2,
|
|
@@ -19875,7 +19847,7 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
19875
19847
|
];
|
|
19876
19848
|
for (let offset = BufferChunkSize; offset < bytes.length; offset += BufferChunkSize) {
|
|
19877
19849
|
setupTransactions.push(
|
|
19878
|
-
new
|
|
19850
|
+
new import_web332.Transaction().add(
|
|
19879
19851
|
squads2.generated.createTransactionBufferExtendInstruction(accounts2, {
|
|
19880
19852
|
args: { buffer: bytes.slice(offset, offset + BufferChunkSize) }
|
|
19881
19853
|
})
|
|
@@ -19888,7 +19860,7 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
19888
19860
|
vaultTransactionCreateItemTransaction: prepared.vaultTransactionPda,
|
|
19889
19861
|
vaultTransactionCreateItemCreator: proposer,
|
|
19890
19862
|
vaultTransactionCreateItemRentPayer: proposer,
|
|
19891
|
-
vaultTransactionCreateItemSystemProgram:
|
|
19863
|
+
vaultTransactionCreateItemSystemProgram: import_web332.SystemProgram.programId,
|
|
19892
19864
|
transactionBuffer: bufferPda,
|
|
19893
19865
|
creator: proposer
|
|
19894
19866
|
},
|
|
@@ -19900,7 +19872,7 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
19900
19872
|
).isWritable = true;
|
|
19901
19873
|
return {
|
|
19902
19874
|
setupTransactions,
|
|
19903
|
-
proposalTransaction: new
|
|
19875
|
+
proposalTransaction: new import_web332.Transaction().add(
|
|
19904
19876
|
finalize,
|
|
19905
19877
|
...transaction.instructions.slice(1)
|
|
19906
19878
|
),
|
|
@@ -19911,13 +19883,13 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
19911
19883
|
|
|
19912
19884
|
// src/utils/token.ts
|
|
19913
19885
|
var import_spl_token24 = require("@solana/spl-token");
|
|
19914
|
-
var
|
|
19915
|
-
var
|
|
19886
|
+
var import_web333 = require("@solana/web3.js");
|
|
19887
|
+
var import_common51 = __toESM(require_dist());
|
|
19916
19888
|
async function createTokenMintIxs(connection, payer, authority, decimals, tokenProgram = import_spl_token24.TOKEN_2022_PROGRAM_ID) {
|
|
19917
|
-
const mint =
|
|
19889
|
+
const mint = import_web333.Keypair.generate();
|
|
19918
19890
|
const lamports = await (0, import_spl_token24.getMinimumBalanceForRentExemptMint)(connection);
|
|
19919
19891
|
const ixs = [
|
|
19920
|
-
|
|
19892
|
+
import_web333.SystemProgram.createAccount({
|
|
19921
19893
|
fromPubkey: payer,
|
|
19922
19894
|
newAccountPubkey: mint.publicKey,
|
|
19923
19895
|
space: import_spl_token24.MINT_SIZE,
|
|
@@ -19943,7 +19915,7 @@ async function createTokenMint(connection, payer, decimals, tokenProgram = impor
|
|
|
19943
19915
|
tokenProgram
|
|
19944
19916
|
);
|
|
19945
19917
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
|
|
19946
|
-
const tx = new
|
|
19918
|
+
const tx = new import_web333.Transaction().add(...ixs);
|
|
19947
19919
|
tx.feePayer = payer.publicKey;
|
|
19948
19920
|
tx.recentBlockhash = blockhash;
|
|
19949
19921
|
tx.sign(payer, mint);
|
|
@@ -19957,7 +19929,7 @@ async function createTokenMint(connection, payer, decimals, tokenProgram = impor
|
|
|
19957
19929
|
return mint.publicKey;
|
|
19958
19930
|
}
|
|
19959
19931
|
async function mintTokensTo(connection, payer, mint, destination, amount, tokenProgram = import_spl_token24.TOKEN_2022_PROGRAM_ID, allowOwnerOffCurve = true) {
|
|
19960
|
-
const tokenProgramPk = (0,
|
|
19932
|
+
const tokenProgramPk = (0, import_common51.asWeb3PublicKey)(tokenProgram);
|
|
19961
19933
|
const ata = (0, import_spl_token24.getAssociatedTokenAddressSync)(
|
|
19962
19934
|
mint,
|
|
19963
19935
|
destination,
|
|
@@ -19982,7 +19954,7 @@ async function mintTokensTo(connection, payer, mint, destination, amount, tokenP
|
|
|
19982
19954
|
tokenProgramPk
|
|
19983
19955
|
)
|
|
19984
19956
|
];
|
|
19985
|
-
const tx = new
|
|
19957
|
+
const tx = new import_web333.Transaction().add(...ixs);
|
|
19986
19958
|
await connection.sendTransaction(tx, [payer]);
|
|
19987
19959
|
}
|
|
19988
19960
|
|
|
@@ -20372,7 +20344,7 @@ async function getTotalTrackedValue(accountNames, start, end, onAccountValue) {
|
|
|
20372
20344
|
}
|
|
20373
20345
|
|
|
20374
20346
|
// src/services/withdrawalQueueService.ts
|
|
20375
|
-
var
|
|
20347
|
+
var import_common52 = __toESM(require_dist());
|
|
20376
20348
|
function bnToBigInt(value) {
|
|
20377
20349
|
return BigInt(value.toString());
|
|
20378
20350
|
}
|
|
@@ -20438,10 +20410,10 @@ var WithdrawalQueueService = class {
|
|
|
20438
20410
|
const vault = await this.client.account.fetchVault(queue.vault, {
|
|
20439
20411
|
fresh: true
|
|
20440
20412
|
});
|
|
20441
|
-
if (queue.inputMint === (0,
|
|
20413
|
+
if (queue.inputMint === (0, import_common52.fromWeb3Pk)(vault.mint)) {
|
|
20442
20414
|
const plan2 = await this.client.tx.fulfillAsyncWithdraw.getTx({
|
|
20443
20415
|
owner: queue.owner,
|
|
20444
|
-
signer: (0,
|
|
20416
|
+
signer: (0, import_common52.fromWeb3Pk)(signer.publicKey),
|
|
20445
20417
|
queuePayer: queue.payer,
|
|
20446
20418
|
vault: queue.vault,
|
|
20447
20419
|
withdrawalQueue: queue.pda,
|
|
@@ -20455,14 +20427,14 @@ var WithdrawalQueueService = class {
|
|
|
20455
20427
|
queue.vault,
|
|
20456
20428
|
{ fresh: true }
|
|
20457
20429
|
);
|
|
20458
|
-
if (queue.inputMint !== (0,
|
|
20430
|
+
if (queue.inputMint !== (0, import_common52.fromWeb3Pk)(tranche.config.juniorMint)) {
|
|
20459
20431
|
throw new Error(
|
|
20460
20432
|
`Unsupported withdrawal queue input mint: ${queue.inputMint}`
|
|
20461
20433
|
);
|
|
20462
20434
|
}
|
|
20463
20435
|
const plan = await this.client.tx.fulfillJuniorTrancheWithdraw.getTx({
|
|
20464
20436
|
owner: queue.owner,
|
|
20465
|
-
signer: (0,
|
|
20437
|
+
signer: (0, import_common52.fromWeb3Pk)(signer.publicKey),
|
|
20466
20438
|
queuePayer: queue.payer,
|
|
20467
20439
|
vault: queue.vault,
|
|
20468
20440
|
withdrawalQueue: queue.pda,
|
|
@@ -20473,8 +20445,8 @@ var WithdrawalQueueService = class {
|
|
|
20473
20445
|
return this.client.sendTransaction(signer, plan);
|
|
20474
20446
|
}
|
|
20475
20447
|
/**
|
|
20476
|
-
* Fulfill
|
|
20477
|
-
*
|
|
20448
|
+
* Fulfill regular queues oldest-first by request timestamp. An older pending
|
|
20449
|
+
* request blocks later regular requests; junior queues and other vaults continue.
|
|
20478
20450
|
*/
|
|
20479
20451
|
async fulfillAllDue(signer, opts = {}) {
|
|
20480
20452
|
const { vault, log } = opts;
|
|
@@ -20482,31 +20454,77 @@ var WithdrawalQueueService = class {
|
|
|
20482
20454
|
const summary = {
|
|
20483
20455
|
fulfilled: 0,
|
|
20484
20456
|
skippedNotDue: 0,
|
|
20457
|
+
skippedBlocked: 0,
|
|
20458
|
+
skippedNoLiquidity: 0,
|
|
20485
20459
|
failed: 0,
|
|
20486
20460
|
signatures: []
|
|
20487
20461
|
};
|
|
20488
|
-
const now = this.
|
|
20462
|
+
const now = Number(await this.client.account.fetchClockUnixTimestamp());
|
|
20463
|
+
const byVault = /* @__PURE__ */ new Map();
|
|
20489
20464
|
for (const queue of queues) {
|
|
20490
|
-
|
|
20491
|
-
|
|
20492
|
-
|
|
20493
|
-
|
|
20494
|
-
|
|
20495
|
-
|
|
20496
|
-
|
|
20465
|
+
const group = byVault.get(queue.vault) ?? [];
|
|
20466
|
+
group.push(queue);
|
|
20467
|
+
byVault.set(queue.vault, group);
|
|
20468
|
+
}
|
|
20469
|
+
for (const [vault2, group] of byVault) {
|
|
20470
|
+
let regularBlocked = false;
|
|
20471
|
+
let regularMint;
|
|
20497
20472
|
try {
|
|
20498
|
-
|
|
20499
|
-
|
|
20473
|
+
regularMint = (0, import_common52.fromWeb3Pk)(
|
|
20474
|
+
(await this.client.account.fetchVault(vault2, { fresh: true })).mint
|
|
20500
20475
|
);
|
|
20501
|
-
const sig = await this.fulfill(signer, queue);
|
|
20502
|
-
summary.fulfilled += 1;
|
|
20503
|
-
summary.signatures.push(sig);
|
|
20504
|
-
log?.(`fulfilled ${queue.pda} (owner ${queue.owner}): ${sig}`);
|
|
20505
20476
|
} catch (err) {
|
|
20506
|
-
summary.failed +=
|
|
20477
|
+
summary.failed += group.length;
|
|
20507
20478
|
log?.(
|
|
20508
|
-
`FAILED
|
|
20479
|
+
`FAILED vault ${vault2}: ${err instanceof Error ? err.message : String(err)}`
|
|
20509
20480
|
);
|
|
20481
|
+
continue;
|
|
20482
|
+
}
|
|
20483
|
+
const regularQueues = group.filter((q) => q.inputMint === regularMint).sort(
|
|
20484
|
+
(a, b) => a.requestTs - b.requestTs || (a.pda < b.pda ? -1 : a.pda > b.pda ? 1 : 0)
|
|
20485
|
+
);
|
|
20486
|
+
for (const queue of [
|
|
20487
|
+
...regularQueues,
|
|
20488
|
+
...group.filter((q) => q.inputMint !== regularMint)
|
|
20489
|
+
]) {
|
|
20490
|
+
const regular = queue.inputMint === regularMint;
|
|
20491
|
+
if (regular && regularBlocked) {
|
|
20492
|
+
summary.skippedBlocked += 1;
|
|
20493
|
+
log?.(
|
|
20494
|
+
`skipped-blocked ${queue.pda}: an older request is still pending`
|
|
20495
|
+
);
|
|
20496
|
+
continue;
|
|
20497
|
+
}
|
|
20498
|
+
if (!this.isDue(queue, now)) {
|
|
20499
|
+
summary.skippedNotDue += 1;
|
|
20500
|
+
if (regular) regularBlocked = true;
|
|
20501
|
+
log?.(
|
|
20502
|
+
`skip ${queue.pda} (owner ${queue.owner}) \u2014 due in ${this.secondsUntilDue(queue, now)}s`
|
|
20503
|
+
);
|
|
20504
|
+
continue;
|
|
20505
|
+
}
|
|
20506
|
+
try {
|
|
20507
|
+
log?.(
|
|
20508
|
+
`fulfilling ${queue.pda} \u2014 paying ${queue.inputAmount} shares worth of ${queue.outputMint} to owner ${queue.owner}`
|
|
20509
|
+
);
|
|
20510
|
+
const sig = await this.fulfill(signer, queue);
|
|
20511
|
+
summary.fulfilled += 1;
|
|
20512
|
+
summary.signatures.push(sig);
|
|
20513
|
+
log?.(`fulfilled ${queue.pda} (owner ${queue.owner}): ${sig}`);
|
|
20514
|
+
} catch (err) {
|
|
20515
|
+
if (regular) regularBlocked = true;
|
|
20516
|
+
const message2 = err instanceof Error ? err.message : String(err);
|
|
20517
|
+
const logs = err?.logs ?? [];
|
|
20518
|
+
if (/InsufficientVaultLiquidity/.test([message2, ...logs].join("\n"))) {
|
|
20519
|
+
summary.skippedNoLiquidity += 1;
|
|
20520
|
+
log?.(
|
|
20521
|
+
`skipped-no-liquidity ${queue.pda} (owner ${queue.owner}): ${message2}`
|
|
20522
|
+
);
|
|
20523
|
+
} else {
|
|
20524
|
+
summary.failed += 1;
|
|
20525
|
+
log?.(`FAILED ${queue.pda} (owner ${queue.owner}): ${message2}`);
|
|
20526
|
+
}
|
|
20527
|
+
}
|
|
20510
20528
|
}
|
|
20511
20529
|
}
|
|
20512
20530
|
return summary;
|
|
@@ -20516,12 +20534,12 @@ var WithdrawalQueueService = class {
|
|
|
20516
20534
|
const a = account;
|
|
20517
20535
|
return {
|
|
20518
20536
|
pda,
|
|
20519
|
-
vault: (0,
|
|
20520
|
-
owner: (0,
|
|
20521
|
-
payer: (0,
|
|
20537
|
+
vault: (0, import_common52.fromWeb3Pk)(a.parties.vault),
|
|
20538
|
+
owner: (0, import_common52.fromWeb3Pk)(a.parties.owner),
|
|
20539
|
+
payer: (0, import_common52.fromWeb3Pk)(a.parties.payer),
|
|
20522
20540
|
queueId: a.header.queueId,
|
|
20523
|
-
inputMint: (0,
|
|
20524
|
-
outputMint: (0,
|
|
20541
|
+
inputMint: (0, import_common52.fromWeb3Pk)(a.mints.inputMint),
|
|
20542
|
+
outputMint: (0, import_common52.fromWeb3Pk)(a.mints.outputMint),
|
|
20525
20543
|
inputAmount: bnToBigInt(a.request.inputAmount),
|
|
20526
20544
|
requestTs: bnToNumber(a.request.requestTs),
|
|
20527
20545
|
expiryTs: bnToNumber(a.request.expiryTs),
|
|
@@ -20533,7 +20551,7 @@ var WithdrawalQueueService = class {
|
|
|
20533
20551
|
|
|
20534
20552
|
// src/services/oracleService.ts
|
|
20535
20553
|
var import_kit12 = require("@solana/kit");
|
|
20536
|
-
var
|
|
20554
|
+
var import_common53 = __toESM(require_dist());
|
|
20537
20555
|
var SYSTEM_PROGRAM2 = "11111111111111111111111111111111";
|
|
20538
20556
|
var DEFAULT_PRICE_STALENESS_THRESHOLD_SECS2 = 86400n;
|
|
20539
20557
|
var PRICE_ORACLE_TYPES_BY_INDEX2 = [
|
|
@@ -20597,7 +20615,7 @@ var OracleService = class {
|
|
|
20597
20615
|
*/
|
|
20598
20616
|
async updateAssetConsensusPrice(signer, args, log) {
|
|
20599
20617
|
const plan = await this.client.tx.updateConsensusOracle.getTx({
|
|
20600
|
-
signer: (0,
|
|
20618
|
+
signer: (0, import_common53.fromWeb3Pk)(signer.publicKey),
|
|
20601
20619
|
vault: args.vault,
|
|
20602
20620
|
updates: args.updates,
|
|
20603
20621
|
assetMint: args.assetMint,
|
|
@@ -20617,14 +20635,14 @@ var OracleService = class {
|
|
|
20617
20635
|
*/
|
|
20618
20636
|
async updateAssetConsensusPriceAndCrankNavIfReady(signer, args, log, beforeSubmit) {
|
|
20619
20637
|
const updatePlan = await this.client.tx.updateConsensusOracle.getTx({
|
|
20620
|
-
signer: (0,
|
|
20638
|
+
signer: (0, import_common53.fromWeb3Pk)(signer.publicKey),
|
|
20621
20639
|
...args
|
|
20622
20640
|
});
|
|
20623
20641
|
let plan = updatePlan;
|
|
20624
20642
|
let crankSkippedReason;
|
|
20625
20643
|
try {
|
|
20626
20644
|
const crankPlan = await this.client.tx.crankNav.getTx({
|
|
20627
|
-
cranker: (0,
|
|
20645
|
+
cranker: (0, import_common53.fromWeb3Pk)(signer.publicKey),
|
|
20628
20646
|
vault: args.vault
|
|
20629
20647
|
});
|
|
20630
20648
|
const combinedPlan = {
|
|
@@ -20671,7 +20689,7 @@ var OracleService = class {
|
|
|
20671
20689
|
/** Settle the vault NAV from its current holdings (permissionless). */
|
|
20672
20690
|
async crankNav(cranker, args, log) {
|
|
20673
20691
|
const plan = await this.client.tx.crankNav.getTx({
|
|
20674
|
-
cranker: (0,
|
|
20692
|
+
cranker: (0, import_common53.fromWeb3Pk)(cranker.publicKey),
|
|
20675
20693
|
vault: args.vault,
|
|
20676
20694
|
vaultTrancheState: args.vaultTrancheState
|
|
20677
20695
|
});
|
|
@@ -20744,7 +20762,7 @@ var OracleService = class {
|
|
|
20744
20762
|
/** Re-price one live-oracle holding from its bound Pyth/nested-vault account. */
|
|
20745
20763
|
async refreshAssetPrice(updater, args, log) {
|
|
20746
20764
|
const plan = await this.client.tx.updateAssetPrice.getTx({
|
|
20747
|
-
updater: (0,
|
|
20765
|
+
updater: (0, import_common53.fromWeb3Pk)(updater.publicKey),
|
|
20748
20766
|
vault: args.vault,
|
|
20749
20767
|
mint: args.mint,
|
|
20750
20768
|
oracleAccount: args.oracleAccount,
|
|
@@ -20840,11 +20858,11 @@ function toBigInt2(value) {
|
|
|
20840
20858
|
}
|
|
20841
20859
|
|
|
20842
20860
|
// src/services/consensusOracle/utils/holdings.ts
|
|
20843
|
-
var
|
|
20844
|
-
var
|
|
20861
|
+
var import_web334 = require("@solana/web3.js");
|
|
20862
|
+
var import_common54 = __toESM(require_dist());
|
|
20845
20863
|
function selectReportableHoldings(holdings, excludedMints = /* @__PURE__ */ new Set()) {
|
|
20846
20864
|
return holdings.map((holding, holdingIndex) => ({ holding, holdingIndex })).filter(({ holding }) => {
|
|
20847
|
-
const mint = (0,
|
|
20865
|
+
const mint = (0, import_common54.fromWeb3Pk)(holding.mint);
|
|
20848
20866
|
return mint !== SYSTEM_PROGRAM && !excludedMints.has(mint.toString()) && REPORTABLE_ORACLE_VARIANTS.has(
|
|
20849
20867
|
variantName2(holding.priceOracleType).toLowerCase()
|
|
20850
20868
|
);
|
|
@@ -20879,7 +20897,7 @@ function parseExternalLiquidityRefs(vaultState) {
|
|
|
20879
20897
|
if (!data || data.length < 40) continue;
|
|
20880
20898
|
if (data[0] !== 1 && data[0] !== 2) continue;
|
|
20881
20899
|
const pubkeyBytes = new Uint8Array(data.slice(8, 40));
|
|
20882
|
-
const userAccount = new
|
|
20900
|
+
const userAccount = new import_web334.PublicKey(pubkeyBytes).toBase58();
|
|
20883
20901
|
refs.push(
|
|
20884
20902
|
data[0] === 1 ? { kind: "marginfi", mint: "", marginfiAccount: userAccount } : {
|
|
20885
20903
|
kind: "kamino-lend",
|
|
@@ -21107,12 +21125,12 @@ function formatBpsAsPercent(bps) {
|
|
|
21107
21125
|
}
|
|
21108
21126
|
|
|
21109
21127
|
// src/services/consensusOracle/pipeline/dryRunSettlement.ts
|
|
21110
|
-
var
|
|
21111
|
-
var
|
|
21128
|
+
var import_web336 = require("@solana/web3.js");
|
|
21129
|
+
var import_common55 = __toESM(require_dist());
|
|
21112
21130
|
|
|
21113
21131
|
// src/services/consensusOracle/settlement/settlementSimulator.ts
|
|
21114
21132
|
var import_kit13 = require("@solana/kit");
|
|
21115
|
-
var
|
|
21133
|
+
var import_web335 = require("@solana/web3.js");
|
|
21116
21134
|
var DEFAULT_SHARE_PRICE = 1000000n;
|
|
21117
21135
|
var BPS_DENOMINATOR3 = 10000n;
|
|
21118
21136
|
var NAV_LOSS_TOLERANCE_BPS = 1n;
|
|
@@ -21385,7 +21403,7 @@ function applyConsensus(holdings, entries, nowTs, stalenessThresholdSecs) {
|
|
|
21385
21403
|
continue;
|
|
21386
21404
|
}
|
|
21387
21405
|
const reports = entries.filter(
|
|
21388
|
-
(entry) => entry.signer !==
|
|
21406
|
+
(entry) => entry.signer !== import_web335.PublicKey.default.toBase58() && isFresh(entry.lastUpdateTs, nowTs, stalenessThresholdSecs) && (entry.prices[index] ?? 0n) > 0n
|
|
21389
21407
|
);
|
|
21390
21408
|
const usesConsensusPrice = holding.priceOracleType === "consensusoracle";
|
|
21391
21409
|
const prices = reports.map((entry) => entry.prices[index] ?? 0n);
|
|
@@ -21886,7 +21904,7 @@ function decodeOracleData(data, nowTs) {
|
|
|
21886
21904
|
(_, holdingIndex) => readU64(data, offset + EXTERNAL_OFFSET + holdingIndex * 8)
|
|
21887
21905
|
);
|
|
21888
21906
|
entries.push({
|
|
21889
|
-
signer: new
|
|
21907
|
+
signer: new import_web335.PublicKey(signerBytes).toBase58(),
|
|
21890
21908
|
lastUpdateTs: readI64(data, offset + 32),
|
|
21891
21909
|
prices,
|
|
21892
21910
|
externalAmounts
|
|
@@ -21901,7 +21919,7 @@ function decodeOracleData(data, nowTs) {
|
|
|
21901
21919
|
data.slice(pendingOffset + index * 32, pendingOffset + (index + 1) * 32)
|
|
21902
21920
|
);
|
|
21903
21921
|
entries[index] = {
|
|
21904
|
-
signer: index < pendingCount ? new
|
|
21922
|
+
signer: index < pendingCount ? new import_web335.PublicKey(signerBytes).toBase58() : import_web335.PublicKey.default.toBase58(),
|
|
21905
21923
|
lastUpdateTs: 0n,
|
|
21906
21924
|
prices: Array(MAX_HOLDINGS).fill(0n),
|
|
21907
21925
|
externalAmounts: Array(MAX_HOLDINGS).fill(0n)
|
|
@@ -21929,7 +21947,7 @@ function decodeHolding(value) {
|
|
|
21929
21947
|
externalAmount: bigint(holding.externalAmount),
|
|
21930
21948
|
price: bigint(holding.price),
|
|
21931
21949
|
lastUpdateTs: bigint(holding.lastUpdateTs),
|
|
21932
|
-
cleared: mintString ===
|
|
21950
|
+
cleared: mintString === import_web335.PublicKey.default.toBase58()
|
|
21933
21951
|
};
|
|
21934
21952
|
}
|
|
21935
21953
|
function decodeTrancheState(decoded, args, warnings, blockers) {
|
|
@@ -22412,11 +22430,11 @@ async function fetchSimulationArgs({
|
|
|
22412
22430
|
client.account.fetchVaultOracleForVault(vault, { fresh: true }),
|
|
22413
22431
|
tranchingEnabled ? client.account.fetchVaultTrancheStateForVault(vault, { fresh: true }) : Promise.resolve(void 0)
|
|
22414
22432
|
]);
|
|
22415
|
-
const mintKeys = [new
|
|
22433
|
+
const mintKeys = [new import_web336.PublicKey(vaultState.mint)];
|
|
22416
22434
|
if (trancheState) {
|
|
22417
22435
|
mintKeys.push(
|
|
22418
|
-
new
|
|
22419
|
-
new
|
|
22436
|
+
new import_web336.PublicKey(trancheState.config.juniorMint),
|
|
22437
|
+
new import_web336.PublicKey(trancheState.config.seniorMint)
|
|
22420
22438
|
);
|
|
22421
22439
|
}
|
|
22422
22440
|
const mintAccounts = await client.provider.connection.getMultipleAccountsInfo(
|
|
@@ -22432,7 +22450,7 @@ async function fetchSimulationArgs({
|
|
|
22432
22450
|
oracleData: oracleState.data,
|
|
22433
22451
|
trancheState,
|
|
22434
22452
|
updates,
|
|
22435
|
-
signer: (0,
|
|
22453
|
+
signer: (0, import_common55.fromWeb3Pk)(signer.publicKey),
|
|
22436
22454
|
nowTs: nowSecs,
|
|
22437
22455
|
physicalShareSupply: supplies[0],
|
|
22438
22456
|
physicalJuniorSupply: tranchingEnabled ? supplies[1] : void 0,
|
|
@@ -22441,7 +22459,7 @@ async function fetchSimulationArgs({
|
|
|
22441
22459
|
}
|
|
22442
22460
|
|
|
22443
22461
|
// src/services/consensusOracle/pipeline/holdingUpdates.ts
|
|
22444
|
-
var
|
|
22462
|
+
var import_common56 = __toESM(require_dist());
|
|
22445
22463
|
async function buildUpdates(yieldTracker, reportableHoldings, inputs) {
|
|
22446
22464
|
const updates = [];
|
|
22447
22465
|
for (const entry of reportableHoldings) {
|
|
@@ -22451,7 +22469,7 @@ async function buildUpdates(yieldTracker, reportableHoldings, inputs) {
|
|
|
22451
22469
|
}
|
|
22452
22470
|
async function buildHoldingUpdate(yieldTracker, entry, inputs) {
|
|
22453
22471
|
const { holding, holdingIndex } = entry;
|
|
22454
|
-
const mint = (0,
|
|
22472
|
+
const mint = (0, import_common56.fromWeb3Pk)(holding.mint);
|
|
22455
22473
|
const mintKey = mint.toString();
|
|
22456
22474
|
const oracleType = variantName2(holding.priceOracleType).toLowerCase();
|
|
22457
22475
|
let usd;
|
|
@@ -22513,9 +22531,9 @@ async function resolveTrackedAmounts(yieldTracker, cfg, decimals) {
|
|
|
22513
22531
|
);
|
|
22514
22532
|
}
|
|
22515
22533
|
return {
|
|
22516
|
-
trackedValueAmount: tracked.totalValue > 0 ? (0,
|
|
22517
|
-
principalAmount: tracked.principal > 0 ? (0,
|
|
22518
|
-
yieldAmount: tracked.outstandingYield > 0 ? (0,
|
|
22534
|
+
trackedValueAmount: tracked.totalValue > 0 ? (0, import_common56.fromUiAmount)(tracked.totalValue, decimals) : 0n,
|
|
22535
|
+
principalAmount: tracked.principal > 0 ? (0, import_common56.fromUiAmount)(tracked.principal, decimals) : 0n,
|
|
22536
|
+
yieldAmount: tracked.outstandingYield > 0 ? (0, import_common56.fromUiAmount)(tracked.outstandingYield, decimals) : 0n
|
|
22519
22537
|
};
|
|
22520
22538
|
}
|
|
22521
22539
|
|
|
@@ -22549,7 +22567,7 @@ function assertOracleImpliedApy(vault, simulation, label) {
|
|
|
22549
22567
|
}
|
|
22550
22568
|
|
|
22551
22569
|
// src/services/consensusOracle/pipeline/livePriceRefresh.ts
|
|
22552
|
-
var
|
|
22570
|
+
var import_common57 = __toESM(require_dist());
|
|
22553
22571
|
async function refreshLiveOraclePrices({
|
|
22554
22572
|
oracle,
|
|
22555
22573
|
signer,
|
|
@@ -22568,7 +22586,7 @@ async function refreshLiveOraclePrices({
|
|
|
22568
22586
|
for (const holding of vaultState.holdings) {
|
|
22569
22587
|
const oracleType = variantName2(holding.priceOracleType).toLowerCase();
|
|
22570
22588
|
if (!LIVE_ORACLE_VARIANTS.has(oracleType)) continue;
|
|
22571
|
-
const mint = (0,
|
|
22589
|
+
const mint = (0, import_common57.fromWeb3Pk)(holding.mint);
|
|
22572
22590
|
if (mint.toString() === SYSTEM_PROGRAM) continue;
|
|
22573
22591
|
const activeAmount = toBigInt2(holding.localAmount) + toBigInt2(holding.externalAmount);
|
|
22574
22592
|
if (activeAmount === 0n) continue;
|
|
@@ -22583,7 +22601,7 @@ async function refreshLiveOraclePrices({
|
|
|
22583
22601
|
);
|
|
22584
22602
|
continue;
|
|
22585
22603
|
}
|
|
22586
|
-
const oracleAccount = (0,
|
|
22604
|
+
const oracleAccount = (0, import_common57.fromWeb3Pk)(holding.priceOracleAccount);
|
|
22587
22605
|
if (oracleAccount.toString() === SYSTEM_PROGRAM) {
|
|
22588
22606
|
log(
|
|
22589
22607
|
`vault ${vault}: cannot refresh ${mint}; ${oracleType} holding has no oracle account`
|
|
@@ -22607,7 +22625,7 @@ async function refreshLiveOraclePrices({
|
|
|
22607
22625
|
}
|
|
22608
22626
|
|
|
22609
22627
|
// src/services/consensusOracle/pipeline/managerWalletReconciliation.ts
|
|
22610
|
-
var
|
|
22628
|
+
var import_common58 = __toESM(require_dist());
|
|
22611
22629
|
|
|
22612
22630
|
// src/services/consensusOracle/sources/nestPriceSource.ts
|
|
22613
22631
|
var import_kit14 = require("@solana/kit");
|
|
@@ -22654,13 +22672,13 @@ function candidateGrossNav(state, updates) {
|
|
|
22654
22672
|
const byIndex = /* @__PURE__ */ new Map();
|
|
22655
22673
|
for (const update of updates) {
|
|
22656
22674
|
const holding = state.holdings[update.holdingIndex];
|
|
22657
|
-
if (!holding || (0,
|
|
22675
|
+
if (!holding || (0, import_common58.fromWeb3Pk)(holding.mint) !== update.mint || holding.decimals !== update.decimals || byIndex.has(update.holdingIndex)) {
|
|
22658
22676
|
throw new Error(`Invalid NAV update for holding #${update.holdingIndex}`);
|
|
22659
22677
|
}
|
|
22660
22678
|
byIndex.set(update.holdingIndex, update);
|
|
22661
22679
|
}
|
|
22662
22680
|
return state.holdings.reduce((nav, holding, index) => {
|
|
22663
|
-
if ((0,
|
|
22681
|
+
if ((0, import_common58.fromWeb3Pk)(holding.mint) === SYSTEM_PROGRAM) return nav;
|
|
22664
22682
|
const update = byIndex.get(index);
|
|
22665
22683
|
const local = toBigInt2(holding.localAmount);
|
|
22666
22684
|
const external = update?.externalAmount ?? toBigInt2(holding.externalAmount);
|
|
@@ -22727,13 +22745,13 @@ async function reconcileManagerWalletBalances({
|
|
|
22727
22745
|
throw new Error("Duplicate base mint in manager reconciliation");
|
|
22728
22746
|
}
|
|
22729
22747
|
if (vaultState.holdings.some(
|
|
22730
|
-
(holding) => coerceBool3(holding.isBase) && !mints2.includes((0,
|
|
22748
|
+
(holding) => coerceBool3(holding.isBase) && !mints2.includes((0, import_common58.fromWeb3Pk)(holding.mint))
|
|
22731
22749
|
)) {
|
|
22732
22750
|
throw new Error(
|
|
22733
22751
|
"Cannot reconcile all vault base assets with oracle reports"
|
|
22734
22752
|
);
|
|
22735
22753
|
}
|
|
22736
|
-
const manager = (0,
|
|
22754
|
+
const manager = (0, import_common58.fromWeb3Pk)(vaultState.roles.manager);
|
|
22737
22755
|
if (manager === SYSTEM_PROGRAM || manager === vault) {
|
|
22738
22756
|
throw new Error("Invalid manager wallet for NAV reconciliation");
|
|
22739
22757
|
}
|
|
@@ -22819,13 +22837,13 @@ function walletReconciliationGuardUpdates(state, reconciliation) {
|
|
|
22819
22837
|
}
|
|
22820
22838
|
function managerReconciliationStateKey(state) {
|
|
22821
22839
|
return JSON.stringify({
|
|
22822
|
-
manager: (0,
|
|
22840
|
+
manager: (0, import_common58.fromWeb3Pk)(state.roles.manager),
|
|
22823
22841
|
assetDecimals: state.config.assetDecimals,
|
|
22824
22842
|
holdings: state.holdings.map((holding) => [
|
|
22825
|
-
(0,
|
|
22843
|
+
(0, import_common58.fromWeb3Pk)(holding.mint),
|
|
22826
22844
|
holding.decimals,
|
|
22827
22845
|
variantName2(holding.priceOracleType),
|
|
22828
|
-
holding.priceOracleAccount ? (0,
|
|
22846
|
+
holding.priceOracleAccount ? (0, import_common58.fromWeb3Pk)(holding.priceOracleAccount) : void 0,
|
|
22829
22847
|
coerceBool3(holding.isBase),
|
|
22830
22848
|
toBigInt2(holding.localAmount).toString()
|
|
22831
22849
|
])
|
|
@@ -22864,14 +22882,14 @@ function assertReconciliationExternalValues(initial, current, errorPrefix) {
|
|
|
22864
22882
|
}
|
|
22865
22883
|
|
|
22866
22884
|
// src/services/consensusOracle/pipeline/pricingInputs.ts
|
|
22867
|
-
var
|
|
22885
|
+
var import_common59 = __toESM(require_dist());
|
|
22868
22886
|
async function gatherPricingInputs(deps, target, vaultState, reportableHoldings, log = () => {
|
|
22869
22887
|
}) {
|
|
22870
22888
|
const consensusMints = reportableHoldings.filter(
|
|
22871
22889
|
({ holding }) => variantName2(holding.priceOracleType).toLowerCase() === CONSENSUS_ORACLE_VARIANT
|
|
22872
|
-
).map(({ holding }) => (0,
|
|
22890
|
+
).map(({ holding }) => (0, import_common59.fromWeb3Pk)(holding.mint));
|
|
22873
22891
|
const baseHolding = vaultState.holdings.find((h) => coerceBool3(h.isBase));
|
|
22874
|
-
const baseMint = baseHolding ? (0,
|
|
22892
|
+
const baseMint = baseHolding ? (0, import_common59.fromWeb3Pk)(baseHolding.mint) : consensusMints[0];
|
|
22875
22893
|
if (!baseMint) {
|
|
22876
22894
|
throw new Error(`vault has no holdings \u2014 cannot determine base asset`);
|
|
22877
22895
|
}
|
|
@@ -22957,11 +22975,11 @@ function reconcilePositionSnapshots(snapshots, vault, log) {
|
|
|
22957
22975
|
}
|
|
22958
22976
|
|
|
22959
22977
|
// src/services/consensusOracle/pipeline/receiptMints.ts
|
|
22960
|
-
var
|
|
22978
|
+
var import_common60 = __toESM(require_dist());
|
|
22961
22979
|
async function fetchReceiptMints(client, vault, vaultState) {
|
|
22962
22980
|
const receiptMints = /* @__PURE__ */ new Set();
|
|
22963
22981
|
if (vaultState.mint) {
|
|
22964
|
-
receiptMints.add((0,
|
|
22982
|
+
receiptMints.add((0, import_common60.fromWeb3Pk)(vaultState.mint).toString());
|
|
22965
22983
|
}
|
|
22966
22984
|
if (!coerceBool3(vaultState.tranchingEnabled)) return receiptMints;
|
|
22967
22985
|
const trancheState = await client.account.fetchVaultTrancheStateForVault(
|
|
@@ -22969,19 +22987,19 @@ async function fetchReceiptMints(client, vault, vaultState) {
|
|
|
22969
22987
|
{ fresh: true }
|
|
22970
22988
|
);
|
|
22971
22989
|
receiptMints.add(
|
|
22972
|
-
(0,
|
|
22990
|
+
(0, import_common60.fromWeb3Pk)(trancheState.config.juniorMint).toString()
|
|
22973
22991
|
);
|
|
22974
22992
|
receiptMints.add(
|
|
22975
|
-
(0,
|
|
22993
|
+
(0, import_common60.fromWeb3Pk)(trancheState.config.seniorMint).toString()
|
|
22976
22994
|
);
|
|
22977
22995
|
return receiptMints;
|
|
22978
22996
|
}
|
|
22979
22997
|
|
|
22980
22998
|
// src/services/consensusOracle/pipeline/settlement.ts
|
|
22981
|
-
var
|
|
22999
|
+
var import_common62 = __toESM(require_dist());
|
|
22982
23000
|
|
|
22983
23001
|
// src/services/consensusOracle/pipeline/yieldAccounts.ts
|
|
22984
|
-
var
|
|
23002
|
+
var import_common61 = __toESM(require_dist());
|
|
22985
23003
|
async function assertNoUnconfirmedYieldPayments(yieldTracker, target) {
|
|
22986
23004
|
const accountNames = [
|
|
22987
23005
|
...new Set(
|
|
@@ -23023,7 +23041,7 @@ async function withDiscoveredYieldAccounts(yieldTracker, target, vaultState, exc
|
|
|
23023
23041
|
);
|
|
23024
23042
|
if (namesToAttach.length === 0) return target;
|
|
23025
23043
|
const baseHolding = vaultState.holdings.find((holding) => {
|
|
23026
|
-
const mint = (0,
|
|
23044
|
+
const mint = (0, import_common61.fromWeb3Pk)(holding.mint).toString();
|
|
23027
23045
|
return coerceBool3(holding.isBase) && !excludedMints.has(mint);
|
|
23028
23046
|
});
|
|
23029
23047
|
if (!baseHolding) {
|
|
@@ -23031,7 +23049,7 @@ async function withDiscoveredYieldAccounts(yieldTracker, target, vaultState, exc
|
|
|
23031
23049
|
`vault ${target.vault}: tagged yield accounts found but no base holding is available`
|
|
23032
23050
|
);
|
|
23033
23051
|
}
|
|
23034
|
-
const baseMint = (0,
|
|
23052
|
+
const baseMint = (0, import_common61.fromWeb3Pk)(baseHolding.mint);
|
|
23035
23053
|
const holdings = [...target.holdings ?? []];
|
|
23036
23054
|
const existingIndex = holdings.findIndex(
|
|
23037
23055
|
(holding) => holding.mint.toString() === baseMint.toString()
|
|
@@ -23154,7 +23172,7 @@ async function logProspectiveApy({
|
|
|
23154
23172
|
);
|
|
23155
23173
|
const prospectiveNav = vaultState.holdings.reduce(
|
|
23156
23174
|
(sum, holding, holdingIndex) => {
|
|
23157
|
-
const mint = (0,
|
|
23175
|
+
const mint = (0, import_common62.fromWeb3Pk)(holding.mint).toString();
|
|
23158
23176
|
if (mint === SYSTEM_PROGRAM) return sum;
|
|
23159
23177
|
const update = updatesByIndex.get(holdingIndex);
|
|
23160
23178
|
const localAmount = toBigInt2(holding.localAmount);
|
|
@@ -24081,7 +24099,7 @@ async function buildJupiterSwapTransaction(params) {
|
|
|
24081
24099
|
}
|
|
24082
24100
|
|
|
24083
24101
|
// ../jupiter/src/client.ts
|
|
24084
|
-
var
|
|
24102
|
+
var import_common63 = __toESM(require_dist());
|
|
24085
24103
|
|
|
24086
24104
|
// ../jupiter/src/extract.ts
|
|
24087
24105
|
var import_kit17 = require("@solana/kit");
|
|
@@ -24112,7 +24130,7 @@ async function extractJupiterInstruction(transaction, rpc, jupiterProgramId = JU
|
|
|
24112
24130
|
// ../jupiter/src/routePreInstructions.ts
|
|
24113
24131
|
var import_kit18 = require("@solana/kit");
|
|
24114
24132
|
var import_spl_token25 = require("@solana/spl-token");
|
|
24115
|
-
var
|
|
24133
|
+
var import_web337 = require("@solana/web3.js");
|
|
24116
24134
|
async function getJupiterRoutePreInstructions(rpc, quote, user, payer) {
|
|
24117
24135
|
const intermediate = /* @__PURE__ */ new Set();
|
|
24118
24136
|
for (const step of quote.routePlan ?? []) {
|
|
@@ -24137,10 +24155,10 @@ async function getJupiterRoutePreInstructions(rpc, quote, user, payer) {
|
|
|
24137
24155
|
);
|
|
24138
24156
|
}
|
|
24139
24157
|
const ata = (0, import_spl_token25.getAssociatedTokenAddressSync)(
|
|
24140
|
-
new
|
|
24141
|
-
new
|
|
24158
|
+
new import_web337.PublicKey(mint),
|
|
24159
|
+
new import_web337.PublicKey(user),
|
|
24142
24160
|
true,
|
|
24143
|
-
new
|
|
24161
|
+
new import_web337.PublicKey(tokenProgram),
|
|
24144
24162
|
import_spl_token25.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
24145
24163
|
).toBase58();
|
|
24146
24164
|
const existingAta = await rpc.getAccountInfo(ata, { encoding: "base64" }).send();
|
|
@@ -24148,13 +24166,13 @@ async function getJupiterRoutePreInstructions(rpc, quote, user, payer) {
|
|
|
24148
24166
|
continue;
|
|
24149
24167
|
}
|
|
24150
24168
|
instructions2.push(
|
|
24151
|
-
|
|
24169
|
+
toKitInstruction39(
|
|
24152
24170
|
(0, import_spl_token25.createAssociatedTokenAccountIdempotentInstruction)(
|
|
24153
|
-
new
|
|
24154
|
-
new
|
|
24155
|
-
new
|
|
24156
|
-
new
|
|
24157
|
-
new
|
|
24171
|
+
new import_web337.PublicKey(payer),
|
|
24172
|
+
new import_web337.PublicKey(ata),
|
|
24173
|
+
new import_web337.PublicKey(user),
|
|
24174
|
+
new import_web337.PublicKey(mint),
|
|
24175
|
+
new import_web337.PublicKey(tokenProgram),
|
|
24158
24176
|
import_spl_token25.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
24159
24177
|
)
|
|
24160
24178
|
)
|
|
@@ -24163,7 +24181,7 @@ async function getJupiterRoutePreInstructions(rpc, quote, user, payer) {
|
|
|
24163
24181
|
}
|
|
24164
24182
|
return { instructions: instructions2, postSuccessCacheInvalidations };
|
|
24165
24183
|
}
|
|
24166
|
-
function
|
|
24184
|
+
function toKitInstruction39(ix) {
|
|
24167
24185
|
return {
|
|
24168
24186
|
programAddress: ix.programId.toBase58(),
|
|
24169
24187
|
accounts: ix.keys.map((account) => ({
|
|
@@ -24280,7 +24298,7 @@ var JupiterSwapClient = class {
|
|
|
24280
24298
|
}
|
|
24281
24299
|
}
|
|
24282
24300
|
return {
|
|
24283
|
-
cpiType: this.config.cpiType ??
|
|
24301
|
+
cpiType: this.config.cpiType ?? import_common63.CpiTypes.JUPITER_SWAP,
|
|
24284
24302
|
data,
|
|
24285
24303
|
accounts: accounts2,
|
|
24286
24304
|
programId: JUPITER_V6_PROGRAM_ID,
|
|
@@ -24378,7 +24396,7 @@ var LivePriceSource = class {
|
|
|
24378
24396
|
};
|
|
24379
24397
|
|
|
24380
24398
|
// src/services/consensusOracle/sources/managerWalletBalanceSource.ts
|
|
24381
|
-
var
|
|
24399
|
+
var import_web338 = require("@solana/web3.js");
|
|
24382
24400
|
var import_spl_token26 = require("@solana/spl-token");
|
|
24383
24401
|
var RpcManagerWalletBalanceSource = class {
|
|
24384
24402
|
constructor(connection) {
|
|
@@ -24387,7 +24405,7 @@ var RpcManagerWalletBalanceSource = class {
|
|
|
24387
24405
|
async fetchBalances(manager, mints2) {
|
|
24388
24406
|
const wanted = new Set(mints2);
|
|
24389
24407
|
if (wanted.size === 0) return /* @__PURE__ */ new Map();
|
|
24390
|
-
const owner = new
|
|
24408
|
+
const owner = new import_web338.PublicKey(manager);
|
|
24391
24409
|
const programs = [import_spl_token26.TOKEN_PROGRAM_ID, import_spl_token26.TOKEN_2022_PROGRAM_ID];
|
|
24392
24410
|
const responses = await Promise.all(
|
|
24393
24411
|
programs.map(
|
|
@@ -24431,7 +24449,7 @@ var RpcManagerWalletBalanceSource = class {
|
|
|
24431
24449
|
};
|
|
24432
24450
|
|
|
24433
24451
|
// src/services/consensusOracle/sources/mpcWalletBalanceSource.ts
|
|
24434
|
-
var
|
|
24452
|
+
var import_web339 = require("@solana/web3.js");
|
|
24435
24453
|
|
|
24436
24454
|
// src/services/consensusOracle/sources/mpcMarginfiDeposits.ts
|
|
24437
24455
|
var import_kit19 = require("@solana/kit");
|
|
@@ -24520,8 +24538,8 @@ var RpcMpcWalletBalanceSource = class {
|
|
|
24520
24538
|
const wallets = /* @__PURE__ */ new Set();
|
|
24521
24539
|
for (const binding of bindings) {
|
|
24522
24540
|
const { vault, manager, wallet } = binding;
|
|
24523
|
-
for (const key of [vault, manager, wallet]) new
|
|
24524
|
-
if (entries.has(vault) || wallets.has(wallet) || wallet === manager || wallet === vault || wallet ===
|
|
24541
|
+
for (const key of [vault, manager, wallet]) new import_web339.PublicKey(key);
|
|
24542
|
+
if (entries.has(vault) || wallets.has(wallet) || wallet === manager || wallet === vault || wallet === import_web339.PublicKey.default.toBase58())
|
|
24525
24543
|
throw new Error("Invalid or duplicate MPC wallet binding");
|
|
24526
24544
|
entries.set(vault, { ...binding });
|
|
24527
24545
|
wallets.add(wallet);
|
|
@@ -24541,8 +24559,8 @@ var RpcMpcWalletBalanceSource = class {
|
|
|
24541
24559
|
this.tokens.fetchBalances(binding.wallet, mints2),
|
|
24542
24560
|
readMarginfiDepositsForAuthority(
|
|
24543
24561
|
this.connection,
|
|
24544
|
-
new
|
|
24545
|
-
mints2.map((mint) => new
|
|
24562
|
+
new import_web339.PublicKey(binding.wallet),
|
|
24563
|
+
mints2.map((mint) => new import_web339.PublicKey(mint))
|
|
24546
24564
|
)
|
|
24547
24565
|
]);
|
|
24548
24566
|
return { wallet: binding.wallet, tokens, marginfi: deposits };
|
|
@@ -24585,7 +24603,7 @@ var StaticPositionProvider = class {
|
|
|
24585
24603
|
|
|
24586
24604
|
// src/services/consensusOracle/positions/kaminoPositionProvider.ts
|
|
24587
24605
|
var import_kit20 = require("@solana/kit");
|
|
24588
|
-
var
|
|
24606
|
+
var import_web340 = require("@solana/web3.js");
|
|
24589
24607
|
var import_klend_sdk = require("@kamino-finance/klend-sdk");
|
|
24590
24608
|
async function readKaminoBalance(manager, vault, sharesHolder) {
|
|
24591
24609
|
const userShares = await manager.getUserSharesBalanceSingleVault(
|
|
@@ -24622,7 +24640,7 @@ var KaminoPositionProvider = class {
|
|
|
24622
24640
|
const amount = await readKaminoBalance(
|
|
24623
24641
|
manager,
|
|
24624
24642
|
kVault,
|
|
24625
|
-
new
|
|
24643
|
+
new import_web340.PublicKey(sharesHolder)
|
|
24626
24644
|
);
|
|
24627
24645
|
out.push({ mint: ref.mint, amount });
|
|
24628
24646
|
}
|
|
@@ -24631,11 +24649,11 @@ var KaminoPositionProvider = class {
|
|
|
24631
24649
|
};
|
|
24632
24650
|
|
|
24633
24651
|
// src/services/consensusOracle/positions/kaminoLendPositionProvider.ts
|
|
24634
|
-
var
|
|
24652
|
+
var import_web341 = require("@solana/web3.js");
|
|
24635
24653
|
var import_Obligation2 = require("@kamino-finance/klend-sdk/dist/@codegen/klend/accounts/Obligation");
|
|
24636
24654
|
var import_Reserve2 = require("@kamino-finance/klend-sdk/dist/@codegen/klend/accounts/Reserve");
|
|
24637
24655
|
var import_kamino4 = __toESM(require_dist3());
|
|
24638
|
-
var ZERO =
|
|
24656
|
+
var ZERO = import_web341.PublicKey.default.toBase58();
|
|
24639
24657
|
var FRACTION_SCALE = 1n << 60n;
|
|
24640
24658
|
function accountData(info, label) {
|
|
24641
24659
|
if (!info || info.executable || info.owner.toBase58() !== import_kamino4.KLEND_PROGRAM_ID)
|
|
@@ -24676,7 +24694,7 @@ var KaminoLendPositionProvider = class {
|
|
|
24676
24694
|
}
|
|
24677
24695
|
const positions = [];
|
|
24678
24696
|
for (const address18 of obligations) {
|
|
24679
|
-
const key = new
|
|
24697
|
+
const key = new import_web341.PublicKey(address18);
|
|
24680
24698
|
const discovered = decodeObligation(
|
|
24681
24699
|
await this.connection.getAccountInfo(key, "confirmed"),
|
|
24682
24700
|
ctx.vault
|
|
@@ -24686,7 +24704,7 @@ var KaminoLendPositionProvider = class {
|
|
|
24686
24704
|
(deposit) => deposit.depositReserve
|
|
24687
24705
|
);
|
|
24688
24706
|
const infos = await this.connection.getMultipleAccountsInfo(
|
|
24689
|
-
[key, ...reserves.map((reserve) => new
|
|
24707
|
+
[key, ...reserves.map((reserve) => new import_web341.PublicKey(reserve))],
|
|
24690
24708
|
"confirmed"
|
|
24691
24709
|
);
|
|
24692
24710
|
const { obligation, deposits } = decodeObligation(
|
|
@@ -24728,7 +24746,7 @@ var KaminoLendPositionProvider = class {
|
|
|
24728
24746
|
};
|
|
24729
24747
|
|
|
24730
24748
|
// src/services/consensusOracle/positions/marginfiPositionProvider.ts
|
|
24731
|
-
var
|
|
24749
|
+
var import_web342 = require("@solana/web3.js");
|
|
24732
24750
|
var import_marginfi4 = __toESM(require_dist2());
|
|
24733
24751
|
var MarginfiPositionProvider = class {
|
|
24734
24752
|
constructor(connection, log = () => {
|
|
@@ -24739,8 +24757,8 @@ var MarginfiPositionProvider = class {
|
|
|
24739
24757
|
async positionsFor(ctx) {
|
|
24740
24758
|
const refs = ctx.refs.filter((r) => r.kind === "marginfi");
|
|
24741
24759
|
if (refs.length === 0) return [];
|
|
24742
|
-
const explicitBanks = refs.map((r) => r.marginfiBank).filter(Boolean).map((bank) => new
|
|
24743
|
-
const autoAccountPks = refs.filter((r) => !r.marginfiBank).map((r) => r.marginfiAccount).filter(Boolean).map((account) => new
|
|
24760
|
+
const explicitBanks = refs.map((r) => r.marginfiBank).filter(Boolean).map((bank) => new import_web342.PublicKey(bank));
|
|
24761
|
+
const autoAccountPks = refs.filter((r) => !r.marginfiBank).map((r) => r.marginfiAccount).filter(Boolean).map((account) => new import_web342.PublicKey(account));
|
|
24744
24762
|
const autoBanks = [];
|
|
24745
24763
|
for (const accountPk of autoAccountPks) {
|
|
24746
24764
|
try {
|
|
@@ -24769,14 +24787,14 @@ var MarginfiPositionProvider = class {
|
|
|
24769
24787
|
if (bank) {
|
|
24770
24788
|
const amount = await (0, import_marginfi4.readMarginfiBankBalance)(
|
|
24771
24789
|
client,
|
|
24772
|
-
new
|
|
24773
|
-
new
|
|
24790
|
+
new import_web342.PublicKey(account),
|
|
24791
|
+
new import_web342.PublicKey(bank)
|
|
24774
24792
|
);
|
|
24775
24793
|
out.push({ mint: ref.mint, amount });
|
|
24776
24794
|
} else {
|
|
24777
24795
|
const balances = await (0, import_marginfi4.readAllMarginfiBalances)(
|
|
24778
24796
|
client,
|
|
24779
|
-
new
|
|
24797
|
+
new import_web342.PublicKey(account)
|
|
24780
24798
|
);
|
|
24781
24799
|
for (const { mint, amount } of balances) {
|
|
24782
24800
|
out.push({ mint: mint.toBase58(), amount });
|
|
@@ -25046,7 +25064,7 @@ function createLiveConsensusOracleDeps(connection, opts = {}) {
|
|
|
25046
25064
|
}
|
|
25047
25065
|
|
|
25048
25066
|
// src/services/consensusOracle/consensusOracleService.ts
|
|
25049
|
-
var
|
|
25067
|
+
var import_common64 = __toESM(require_dist());
|
|
25050
25068
|
var ConsensusOracleService = class {
|
|
25051
25069
|
constructor(client, deps) {
|
|
25052
25070
|
this.client = client;
|
|
@@ -25082,7 +25100,7 @@ var ConsensusOracleService = class {
|
|
|
25082
25100
|
receiptMints
|
|
25083
25101
|
);
|
|
25084
25102
|
const filteredCount = vaultState.holdings.filter(
|
|
25085
|
-
(holding) => receiptMints.has((0,
|
|
25103
|
+
(holding) => receiptMints.has((0, import_common64.fromWeb3Pk)(holding.mint).toString())
|
|
25086
25104
|
).length;
|
|
25087
25105
|
if (filteredCount > 0) {
|
|
25088
25106
|
log(
|
|
@@ -25351,8 +25369,8 @@ async function runLiveConsensusOracle(env, oracleSigner, opts = {}) {
|
|
|
25351
25369
|
|
|
25352
25370
|
// src/services/externalLiquidityIntegrityService.ts
|
|
25353
25371
|
var import_kit22 = require("@solana/kit");
|
|
25354
|
-
var
|
|
25355
|
-
var
|
|
25372
|
+
var import_web343 = require("@solana/web3.js");
|
|
25373
|
+
var import_common65 = __toESM(require_dist());
|
|
25356
25374
|
var import_marginfi5 = __toESM(require_dist2());
|
|
25357
25375
|
var import_kamino5 = __toESM(require_dist3());
|
|
25358
25376
|
var import_marginfi_client_v23 = require("@mrgnlabs/marginfi-client-v2");
|
|
@@ -25462,7 +25480,7 @@ function parseActiveSlots(externalLiquidity) {
|
|
|
25462
25480
|
if (discriminant === 0) continue;
|
|
25463
25481
|
if (discriminant !== 1 && discriminant !== 2) continue;
|
|
25464
25482
|
const pubkeyBytes = new Uint8Array(data.slice(8, 40));
|
|
25465
|
-
const userAccount = (0,
|
|
25483
|
+
const userAccount = (0, import_common65.toAddress)(new import_web343.PublicKey(pubkeyBytes));
|
|
25466
25484
|
if (isZeroPubkey2(userAccount))
|
|
25467
25485
|
throw new Error("Registered external position has a zero address");
|
|
25468
25486
|
if (results.some((slot) => slot.userAccount === userAccount)) continue;
|
|
@@ -25634,7 +25652,7 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
25634
25652
|
const decimals = Number(holding.decimals ?? 0);
|
|
25635
25653
|
const minRaw = toRawAmount(minAmountUi, decimals);
|
|
25636
25654
|
let targetLocalAmount;
|
|
25637
|
-
if (mintAddress ===
|
|
25655
|
+
if (mintAddress === import_common65.USDC_MINT) {
|
|
25638
25656
|
const tvl = toBigInt3(vaultState.accounting.tvl);
|
|
25639
25657
|
const price = toBigInt3(holding.price);
|
|
25640
25658
|
const stalenessThreshold = Number(toBigInt3(vaultState.config.priceStalenessThresholdSecs)) || DEFAULT_PRICE_STALENESS_THRESHOLD_SECS;
|
|
@@ -25737,25 +25755,25 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
25737
25755
|
* from vault accounting as though it were the balance of each separate slot. */
|
|
25738
25756
|
async loadPositions(vault, mint, slots) {
|
|
25739
25757
|
const marginfi = (0, import_marginfi5.marginfiAccountsForMint)(mint);
|
|
25740
|
-
if (!marginfi && mint !==
|
|
25758
|
+
if (!marginfi && mint !== import_common65.USDC_MINT)
|
|
25741
25759
|
return {
|
|
25742
25760
|
local: 0n,
|
|
25743
25761
|
positions: [],
|
|
25744
|
-
tokenProgram: (0, import_kit22.address)(
|
|
25745
|
-
vaultAta: (0, import_kit22.address)(
|
|
25762
|
+
tokenProgram: (0, import_kit22.address)(import_web343.PublicKey.default.toBase58()),
|
|
25763
|
+
vaultAta: (0, import_kit22.address)(import_web343.PublicKey.default.toBase58())
|
|
25746
25764
|
};
|
|
25747
25765
|
const connection = this.client.provider.connection;
|
|
25748
25766
|
const mintInfo = await connection.getAccountInfo(
|
|
25749
|
-
new
|
|
25767
|
+
new import_web343.PublicKey(mint),
|
|
25750
25768
|
"confirmed"
|
|
25751
25769
|
);
|
|
25752
25770
|
if (!mintInfo) throw new Error(`Missing mint ${mint}`);
|
|
25753
|
-
const tokenProgram = (0,
|
|
25754
|
-
const vaultAta = (0,
|
|
25771
|
+
const tokenProgram = (0, import_common65.fromWeb3Pk)(mintInfo.owner);
|
|
25772
|
+
const vaultAta = (0, import_common65.getAtaAddress)(mint, vault, tokenProgram, true);
|
|
25755
25773
|
const positions = [];
|
|
25756
25774
|
for (const slot of slots) {
|
|
25757
25775
|
if (slot.source === "marginfi" && !marginfi) continue;
|
|
25758
|
-
if (slot.source === "kamino" && mint !==
|
|
25776
|
+
if (slot.source === "kamino" && mint !== import_common65.USDC_MINT) continue;
|
|
25759
25777
|
const kamino = slot.source === "kamino" ? await loadKaminoDeposit({
|
|
25760
25778
|
connection,
|
|
25761
25779
|
vault,
|
|
@@ -25766,7 +25784,7 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
25766
25784
|
throw new Error("Kamino token program mismatch");
|
|
25767
25785
|
const data = Buffer.alloc(256);
|
|
25768
25786
|
data[0] = slot.source === "marginfi" ? 1 : 2;
|
|
25769
|
-
new
|
|
25787
|
+
new import_web343.PublicKey(slot.userAccount).toBuffer().copy(data, 8);
|
|
25770
25788
|
const withdrawal = await loadWithdrawalPosition({
|
|
25771
25789
|
connection,
|
|
25772
25790
|
vault,
|
|
@@ -25802,8 +25820,8 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
25802
25820
|
async executeMoves(args) {
|
|
25803
25821
|
const { vault, mintAddress, hwManager, snapshot: snapshot2, moves, dryRun, log } = args;
|
|
25804
25822
|
const instructions2 = [
|
|
25805
|
-
(0,
|
|
25806
|
-
|
|
25823
|
+
(0, import_common65.toKitInstruction)(
|
|
25824
|
+
import_web343.ComputeBudgetProgram.setComputeUnitLimit({ units: 14e5 })
|
|
25807
25825
|
)
|
|
25808
25826
|
];
|
|
25809
25827
|
const lookupTables = /* @__PURE__ */ new Set();
|
|
@@ -25816,7 +25834,7 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
25816
25834
|
cpiRefs = position.withdrawal.explicitRefs(move.amount);
|
|
25817
25835
|
} else if (position.source === "kamino") {
|
|
25818
25836
|
if (!position.kamino) throw new Error("Missing Kamino reserve");
|
|
25819
|
-
cpiRefs = (0,
|
|
25837
|
+
cpiRefs = (0, import_common65.createCpiRefs)(
|
|
25820
25838
|
(0, import_kamino5.kaminoDepositCpis)({
|
|
25821
25839
|
...position.kamino,
|
|
25822
25840
|
vault,
|
|
@@ -25827,14 +25845,14 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
25827
25845
|
);
|
|
25828
25846
|
} else {
|
|
25829
25847
|
const configured = (0, import_marginfi5.marginfiAccountsForMint)(mintAddress);
|
|
25830
|
-
cpiRefs = (0,
|
|
25848
|
+
cpiRefs = (0, import_common65.createCpiRefs)([
|
|
25831
25849
|
new import_marginfi5.CpiClient({ accounts: configured }).deposit_cpi({
|
|
25832
25850
|
marginfiAccount: position.userAccount,
|
|
25833
25851
|
authority: vault,
|
|
25834
25852
|
signerTokenAccount: snapshot2.vaultAta,
|
|
25835
25853
|
amount: move.amount,
|
|
25836
|
-
lookupTables: (import_marginfi_client_v23.ADDRESS_LOOKUP_TABLE_FOR_GROUP[configured.group] ?? []).map(
|
|
25837
|
-
remainingAccounts: configured.tokenProgram === "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" ? [(0,
|
|
25854
|
+
lookupTables: (import_marginfi_client_v23.ADDRESS_LOOKUP_TABLE_FOR_GROUP[configured.group] ?? []).map(import_common65.fromWeb3Pk),
|
|
25855
|
+
remainingAccounts: configured.tokenProgram === "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" ? [(0, import_common65.toCustomAccountMeta)(mintAddress)] : []
|
|
25838
25856
|
})
|
|
25839
25857
|
]);
|
|
25840
25858
|
}
|
|
@@ -25842,7 +25860,7 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
25842
25860
|
instructions2.push(
|
|
25843
25861
|
await this.client.tx.protocolInteraction.getIx({
|
|
25844
25862
|
vault,
|
|
25845
|
-
hwManager: (0,
|
|
25863
|
+
hwManager: (0, import_common65.fromWeb3Pk)(hwManager.publicKey),
|
|
25846
25864
|
...cpiRefs,
|
|
25847
25865
|
externalLiquidityIndex: position.index,
|
|
25848
25866
|
affectedAssetMint: mintAddress,
|
|
@@ -25876,8 +25894,8 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
25876
25894
|
var import_kit23 = require("@solana/kit");
|
|
25877
25895
|
var import_spl_token27 = require("@solana/spl-token");
|
|
25878
25896
|
var import_marginfi_client_v24 = require("@mrgnlabs/marginfi-client-v2");
|
|
25879
|
-
var
|
|
25880
|
-
var
|
|
25897
|
+
var import_web344 = require("@solana/web3.js");
|
|
25898
|
+
var import_common66 = __toESM(require_dist());
|
|
25881
25899
|
var import_marginfi6 = __toESM(require_dist2());
|
|
25882
25900
|
var IDLE_RESERVE_FLOOR_BPS = 400;
|
|
25883
25901
|
var IDLE_RESERVE_TARGET_BPS = 500;
|
|
@@ -25981,8 +25999,8 @@ var IdleLiquidityService = class {
|
|
|
25981
25999
|
);
|
|
25982
26000
|
}
|
|
25983
26001
|
quote = await jupiter.getQuote({
|
|
25984
|
-
inputMint:
|
|
25985
|
-
outputMint:
|
|
26002
|
+
inputMint: import_common66.PST_MINT,
|
|
26003
|
+
outputMint: import_common66.USDC_MINT,
|
|
25986
26004
|
amount: pstInput,
|
|
25987
26005
|
slippageBps
|
|
25988
26006
|
});
|
|
@@ -26027,8 +26045,8 @@ var IdleLiquidityService = class {
|
|
|
26027
26045
|
/** Read live local, Project0 and Kamino USDC, excluding other deployed capital. */
|
|
26028
26046
|
async fetchIdleUsdc(vault, vaultState) {
|
|
26029
26047
|
const connection = this.client.provider.connection;
|
|
26030
|
-
const vaultPk = new
|
|
26031
|
-
const usdcMint = new
|
|
26048
|
+
const vaultPk = new import_web344.PublicKey(vault);
|
|
26049
|
+
const usdcMint = new import_web344.PublicKey(import_common66.USDC_MINT);
|
|
26032
26050
|
const ata = (0, import_spl_token27.getAssociatedTokenAddressSync)(usdcMint, vaultPk, true);
|
|
26033
26051
|
const tokenInfo = await connection.getAccountInfo(ata, "confirmed");
|
|
26034
26052
|
let localAmount = 0n;
|
|
@@ -26042,7 +26060,7 @@ var IdleLiquidityService = class {
|
|
|
26042
26060
|
const kamino = await this.fetchKaminoUsdc(
|
|
26043
26061
|
vault,
|
|
26044
26062
|
vaultState,
|
|
26045
|
-
(0,
|
|
26063
|
+
(0, import_common66.fromWeb3Pk)(ata)
|
|
26046
26064
|
);
|
|
26047
26065
|
const slotIndex = vaultState.externalLiquidity.findIndex(
|
|
26048
26066
|
(slot) => slot.data[0] === 1
|
|
@@ -26060,12 +26078,12 @@ var IdleLiquidityService = class {
|
|
|
26060
26078
|
if (data.length < 40) {
|
|
26061
26079
|
throw new Error(`Invalid Project0 external-liquidity slot ${slotIndex}`);
|
|
26062
26080
|
}
|
|
26063
|
-
const positionPk = new
|
|
26081
|
+
const positionPk = new import_web344.PublicKey(new Uint8Array(data.slice(8, 40)));
|
|
26064
26082
|
const positionInfo = await connection.getAccountInfo(
|
|
26065
26083
|
positionPk,
|
|
26066
26084
|
"confirmed"
|
|
26067
26085
|
);
|
|
26068
|
-
if (!positionInfo || !positionInfo.owner.equals(new
|
|
26086
|
+
if (!positionInfo || !positionInfo.owner.equals(new import_web344.PublicKey(import_marginfi6.MARGINFI_PROGRAM_ID))) {
|
|
26069
26087
|
throw new Error(
|
|
26070
26088
|
`Invalid Project0 slot-${slotIndex} account: ${positionPk.toBase58()}`
|
|
26071
26089
|
);
|
|
@@ -26114,17 +26132,17 @@ var IdleLiquidityService = class {
|
|
|
26114
26132
|
if (slot.data[0] !== 2) continue;
|
|
26115
26133
|
if (slot.data.length < 40)
|
|
26116
26134
|
throw new Error(`Invalid Kamino external-liquidity slot ${index}`);
|
|
26117
|
-
const key = new
|
|
26118
|
-
if (key.equals(
|
|
26135
|
+
const key = new import_web344.PublicKey(Uint8Array.from(slot.data.slice(8, 40)));
|
|
26136
|
+
if (key.equals(import_web344.PublicKey.default))
|
|
26119
26137
|
throw new Error(`Missing Kamino position in slot ${index}`);
|
|
26120
26138
|
if (seen.has(key.toBase58())) continue;
|
|
26121
26139
|
seen.add(key.toBase58());
|
|
26122
26140
|
const position = await loadWithdrawalPosition({
|
|
26123
26141
|
connection: this.client.provider.connection,
|
|
26124
26142
|
vault,
|
|
26125
|
-
assetMint:
|
|
26143
|
+
assetMint: import_common66.USDC_MINT,
|
|
26126
26144
|
vaultAssetAta,
|
|
26127
|
-
tokenProgram: (0,
|
|
26145
|
+
tokenProgram: (0, import_common66.fromWeb3Pk)(import_spl_token27.TOKEN_PROGRAM_ID),
|
|
26128
26146
|
slot,
|
|
26129
26147
|
index,
|
|
26130
26148
|
requireUsablePosition: true
|
|
@@ -26175,8 +26193,8 @@ var IdleLiquidityService = class {
|
|
|
26175
26193
|
log(`Vault ${vault}: ${reason} \u2014 skipping`);
|
|
26176
26194
|
return { result: { ...empty, status: "no-tvl", reason } };
|
|
26177
26195
|
}
|
|
26178
|
-
const usdc = findHolding2(vaultState,
|
|
26179
|
-
const pst = findHolding2(vaultState,
|
|
26196
|
+
const usdc = findHolding2(vaultState, import_common66.USDC_MINT);
|
|
26197
|
+
const pst = findHolding2(vaultState, import_common66.PST_MINT);
|
|
26180
26198
|
if (!usdc || !pst) {
|
|
26181
26199
|
const reason = `vault has no ${usdc ? "PST" : "USDC"} holding`;
|
|
26182
26200
|
log(`Vault ${vault}: ${reason} \u2014 skipping`);
|
|
@@ -26327,7 +26345,7 @@ var IdleLiquidityService = class {
|
|
|
26327
26345
|
*/
|
|
26328
26346
|
async mintTokenProgram(mint) {
|
|
26329
26347
|
const account = await this.client.provider.connection.getAccountInfo(
|
|
26330
|
-
new
|
|
26348
|
+
new import_web344.PublicKey(mint),
|
|
26331
26349
|
"confirmed"
|
|
26332
26350
|
);
|
|
26333
26351
|
if (!account) throw new Error(`Mint account not found: ${mint}`);
|
|
@@ -26336,7 +26354,7 @@ var IdleLiquidityService = class {
|
|
|
26336
26354
|
`Unsupported token program ${account.owner.toBase58()} for mint ${mint}`
|
|
26337
26355
|
);
|
|
26338
26356
|
}
|
|
26339
|
-
return (0,
|
|
26357
|
+
return (0, import_common66.fromWeb3Pk)(account.owner);
|
|
26340
26358
|
}
|
|
26341
26359
|
/**
|
|
26342
26360
|
* Build, simulate, and (unless `dryRun`) submit the `jupiter_swap`.
|
|
@@ -26356,23 +26374,23 @@ var IdleLiquidityService = class {
|
|
|
26356
26374
|
dryRun,
|
|
26357
26375
|
log
|
|
26358
26376
|
} = params;
|
|
26359
|
-
const signer = (0,
|
|
26377
|
+
const signer = (0, import_common66.fromWeb3Pk)(hwManager.publicKey);
|
|
26360
26378
|
const [sourceTokenProgram, destinationTokenProgram] = await Promise.all([
|
|
26361
|
-
this.mintTokenProgram(
|
|
26362
|
-
this.mintTokenProgram(
|
|
26379
|
+
this.mintTokenProgram(import_common66.PST_MINT),
|
|
26380
|
+
this.mintTokenProgram(import_common66.USDC_MINT)
|
|
26363
26381
|
]);
|
|
26364
26382
|
const jupiterCpi = await jupiter.getSwapCpiData(quote, vault, {
|
|
26365
26383
|
payer: signer
|
|
26366
26384
|
});
|
|
26367
|
-
const { accounts: accounts2, refs, lookupTables } = (0,
|
|
26385
|
+
const { accounts: accounts2, refs, lookupTables } = (0, import_common66.createCpiRefs)([jupiterCpi]);
|
|
26368
26386
|
const vaultTrancheState = coerceBool4(
|
|
26369
26387
|
vaultState.tranchingEnabled
|
|
26370
26388
|
) ? (await this.client.pda.deriveVaultTrancheStatePda(vault))[0] : void 0;
|
|
26371
26389
|
const plan = await this.client.tx.jupiterSwap.getTx({
|
|
26372
26390
|
hwManager: signer,
|
|
26373
26391
|
vault,
|
|
26374
|
-
sourceMint:
|
|
26375
|
-
destinationMint:
|
|
26392
|
+
sourceMint: import_common66.PST_MINT,
|
|
26393
|
+
destinationMint: import_common66.USDC_MINT,
|
|
26376
26394
|
refs,
|
|
26377
26395
|
accounts: accounts2,
|
|
26378
26396
|
sourceTokenProgram,
|
|
@@ -26382,26 +26400,26 @@ var IdleLiquidityService = class {
|
|
|
26382
26400
|
});
|
|
26383
26401
|
const connection = this.client.provider.connection;
|
|
26384
26402
|
const instructions2 = [
|
|
26385
|
-
|
|
26403
|
+
import_web344.ComputeBudgetProgram.setComputeUnitLimit({ units: COMPUTE_UNIT_LIMIT }),
|
|
26386
26404
|
...cuPriceMicroLamports > 0 ? [
|
|
26387
|
-
|
|
26405
|
+
import_web344.ComputeBudgetProgram.setComputeUnitPrice({
|
|
26388
26406
|
microLamports: cuPriceMicroLamports
|
|
26389
26407
|
})
|
|
26390
26408
|
] : [],
|
|
26391
|
-
...(jupiterCpi.preInstructions ?? []).map(
|
|
26392
|
-
...plan.instructions.map(
|
|
26409
|
+
...(jupiterCpi.preInstructions ?? []).map(import_common66.fromKitInstruction),
|
|
26410
|
+
...plan.instructions.map(import_common66.fromKitInstruction)
|
|
26393
26411
|
];
|
|
26394
26412
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
|
|
26395
|
-
const lookupTableAccounts = await (0,
|
|
26413
|
+
const lookupTableAccounts = await (0, import_common66.fetchLookupTables)(
|
|
26396
26414
|
connection,
|
|
26397
26415
|
plan.lookupTables ?? []
|
|
26398
26416
|
);
|
|
26399
|
-
const message2 = new
|
|
26417
|
+
const message2 = new import_web344.TransactionMessage({
|
|
26400
26418
|
payerKey: hwManager.publicKey,
|
|
26401
26419
|
recentBlockhash: blockhash,
|
|
26402
26420
|
instructions: instructions2
|
|
26403
26421
|
}).compileToV0Message(lookupTableAccounts);
|
|
26404
|
-
const transaction = new
|
|
26422
|
+
const transaction = new import_web344.VersionedTransaction(message2);
|
|
26405
26423
|
transaction.sign([hwManager]);
|
|
26406
26424
|
if (!this.client.skipSimulation) {
|
|
26407
26425
|
const simulation = await connection.simulateTransaction(transaction, {
|
|
@@ -26447,9 +26465,9 @@ var IdleLiquidityService = class {
|
|
|
26447
26465
|
|
|
26448
26466
|
// src/services/timelockSettlementService.ts
|
|
26449
26467
|
var import_kit24 = require("@solana/kit");
|
|
26450
|
-
var
|
|
26451
|
-
var
|
|
26452
|
-
var ZERO_PUBKEY =
|
|
26468
|
+
var import_web345 = require("@solana/web3.js");
|
|
26469
|
+
var import_common67 = __toESM(require_dist());
|
|
26470
|
+
var ZERO_PUBKEY = import_web345.PublicKey.default.toBase58();
|
|
26453
26471
|
var CONSENSUS_SIGNER_CAPACITY = 4;
|
|
26454
26472
|
var CONSENSUS_ENTRY_OFFSET = 40;
|
|
26455
26473
|
var CONSENSUS_ENTRY_SIZE = 272;
|
|
@@ -26489,7 +26507,7 @@ function decodePendingConsensusSigners(data) {
|
|
|
26489
26507
|
const signers = [];
|
|
26490
26508
|
for (let i = 0; i < count; i += 1) {
|
|
26491
26509
|
const start = CONSENSUS_PENDING_OFFSET + i * 32;
|
|
26492
|
-
const signer = new
|
|
26510
|
+
const signer = new import_web345.PublicKey(bytes.slice(start, start + 32)).toBase58();
|
|
26493
26511
|
if (signer === ZERO_PUBKEY) {
|
|
26494
26512
|
throw new Error(`pending consensus signer ${i} is unset`);
|
|
26495
26513
|
}
|
|
@@ -26545,7 +26563,7 @@ var TimelockSettlementService = class {
|
|
|
26545
26563
|
});
|
|
26546
26564
|
const dryRun = opts.dryRun ?? false;
|
|
26547
26565
|
const now = opts.now ?? await this.chainTime();
|
|
26548
|
-
const fulfillerAddress = (0,
|
|
26566
|
+
const fulfillerAddress = (0, import_common67.fromWeb3Pk)(fulfiller.publicKey);
|
|
26549
26567
|
const allVaults = opts.vault ? [
|
|
26550
26568
|
{
|
|
26551
26569
|
publicKey: opts.vault,
|
|
@@ -26689,17 +26707,17 @@ var TimelockSettlementService = class {
|
|
|
26689
26707
|
// src/services/nestWithdrawalService.ts
|
|
26690
26708
|
var import_kit25 = require("@solana/kit");
|
|
26691
26709
|
var import_spl_token28 = require("@solana/spl-token");
|
|
26692
|
-
var
|
|
26693
|
-
var
|
|
26710
|
+
var import_web346 = require("@solana/web3.js");
|
|
26711
|
+
var import_common68 = __toESM(require_dist());
|
|
26694
26712
|
var import_nest3 = __toESM(require_dist4());
|
|
26695
26713
|
var import_nest4 = __toESM(require_dist4());
|
|
26696
|
-
var NestOftProgram = new
|
|
26714
|
+
var NestOftProgram = new import_web346.PublicKey(
|
|
26697
26715
|
"ChEfPd3RzLeYiRwp1K9evimmaFSd6DV1S4Mv5q5Aj1th"
|
|
26698
26716
|
);
|
|
26699
|
-
var NestOftStore = new
|
|
26717
|
+
var NestOftStore = new import_web346.PublicKey(
|
|
26700
26718
|
"k8mJj8Gyw2gFAqut21AFVUUZhxb4RVDMnb4PrSYiDhV"
|
|
26701
26719
|
);
|
|
26702
|
-
var UsdcMint = new
|
|
26720
|
+
var UsdcMint = new import_web346.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
|
|
26703
26721
|
var NestPerenaComposer = Buffer.from(
|
|
26704
26722
|
"000000000000000000000000908dcb5531691c2124c54e30bb645cf11647090d",
|
|
26705
26723
|
"hex"
|
|
@@ -26716,7 +26734,7 @@ async function buildNestWithdrawalRequest(args) {
|
|
|
26716
26734
|
return decodeNestWithdrawalRequest({ ...args, txBase64 });
|
|
26717
26735
|
}
|
|
26718
26736
|
async function decodeNestWithdrawalRequest(args) {
|
|
26719
|
-
const transaction =
|
|
26737
|
+
const transaction = import_web346.VersionedTransaction.deserialize(
|
|
26720
26738
|
Buffer.from(args.txBase64, "base64")
|
|
26721
26739
|
);
|
|
26722
26740
|
const message2 = transaction.message;
|
|
@@ -26737,14 +26755,14 @@ async function decodeNestWithdrawalRequest(args) {
|
|
|
26737
26755
|
return value;
|
|
26738
26756
|
})
|
|
26739
26757
|
);
|
|
26740
|
-
const decoded =
|
|
26758
|
+
const decoded = import_web346.TransactionMessage.decompile(message2, {
|
|
26741
26759
|
addressLookupTableAccounts: tables
|
|
26742
26760
|
});
|
|
26743
|
-
const nestMint = new
|
|
26761
|
+
const nestMint = new import_web346.PublicKey(NEST_RWA_SHARE_MINT);
|
|
26744
26762
|
const sourceAta = (0, import_spl_token28.getAssociatedTokenAddressSync)(nestMint, args.owner, true);
|
|
26745
26763
|
const usdcAta = (0, import_spl_token28.getAssociatedTokenAddressSync)(UsdcMint, args.owner, true);
|
|
26746
26764
|
const instructions2 = decoded.instructions.filter(
|
|
26747
|
-
(ix) => !ix.programId.equals(
|
|
26765
|
+
(ix) => !ix.programId.equals(import_web346.ComputeBudgetProgram.programId)
|
|
26748
26766
|
);
|
|
26749
26767
|
let sends = 0;
|
|
26750
26768
|
for (const ix of instructions2) {
|
|
@@ -26766,7 +26784,7 @@ async function decodeNestWithdrawalRequest(args) {
|
|
|
26766
26784
|
if (sends !== 1)
|
|
26767
26785
|
throw new Error("Nest withdrawal must contain exactly one OFT send");
|
|
26768
26786
|
return {
|
|
26769
|
-
instructions: instructions2.map(
|
|
26787
|
+
instructions: instructions2.map(import_common68.toKitInstruction),
|
|
26770
26788
|
lookupTables: tables.map((table) => (0, import_kit25.address)(table.key.toBase58()))
|
|
26771
26789
|
};
|
|
26772
26790
|
}
|
|
@@ -26774,12 +26792,12 @@ async function decodeNestWithdrawalRequest(args) {
|
|
|
26774
26792
|
// src/services/nestDepositService.ts
|
|
26775
26793
|
var import_kit26 = require("@solana/kit");
|
|
26776
26794
|
var import_spl_token29 = require("@solana/spl-token");
|
|
26777
|
-
var
|
|
26778
|
-
var
|
|
26795
|
+
var import_web347 = require("@solana/web3.js");
|
|
26796
|
+
var import_common69 = __toESM(require_dist());
|
|
26779
26797
|
var import_nest5 = __toESM(require_dist4());
|
|
26780
|
-
var Usdc = new
|
|
26781
|
-
var Messenger = new
|
|
26782
|
-
var Transmitter = new
|
|
26798
|
+
var Usdc = new import_web347.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
|
|
26799
|
+
var Messenger = new import_web347.PublicKey("CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe");
|
|
26800
|
+
var Transmitter = new import_web347.PublicKey(
|
|
26783
26801
|
"CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC"
|
|
26784
26802
|
);
|
|
26785
26803
|
var Router = Buffer.from(
|
|
@@ -26832,7 +26850,7 @@ async function decodeNestDepositRequest(args) {
|
|
|
26832
26850
|
"Nest deposit must be a positive, safely representable USDC base-unit amount"
|
|
26833
26851
|
);
|
|
26834
26852
|
}
|
|
26835
|
-
const message2 =
|
|
26853
|
+
const message2 = import_web347.VersionedTransaction.deserialize(
|
|
26836
26854
|
Buffer.from(args.txBase64, "base64")
|
|
26837
26855
|
).message;
|
|
26838
26856
|
if (!message2.staticAccountKeys[0].equals(args.owner))
|
|
@@ -26847,23 +26865,23 @@ async function decodeNestDepositRequest(args) {
|
|
|
26847
26865
|
return value;
|
|
26848
26866
|
})
|
|
26849
26867
|
);
|
|
26850
|
-
const instructions2 =
|
|
26868
|
+
const instructions2 = import_web347.TransactionMessage.decompile(message2, {
|
|
26851
26869
|
addressLookupTableAccounts: tables
|
|
26852
26870
|
}).instructions;
|
|
26853
|
-
const shareMint = new
|
|
26871
|
+
const shareMint = new import_web347.PublicKey(NEST_RWA_SHARE_MINT);
|
|
26854
26872
|
const shareAta = (0, import_spl_token29.getAssociatedTokenAddressSync)(shareMint, args.owner, true);
|
|
26855
26873
|
const usdcAta = (0, import_spl_token29.getAssociatedTokenAddressSync)(Usdc, args.owner, true);
|
|
26856
26874
|
let burn;
|
|
26857
26875
|
for (const ix of instructions2) {
|
|
26858
|
-
if (ix.programId.equals(
|
|
26876
|
+
if (ix.programId.equals(import_web347.ComputeBudgetProgram.programId)) continue;
|
|
26859
26877
|
if (ix.programId.equals(import_spl_token29.ASSOCIATED_TOKEN_PROGRAM_ID)) {
|
|
26860
|
-
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(
|
|
26878
|
+
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_web347.SystemProgram.programId) || !ix.keys[5]?.pubkey.equals(import_spl_token29.TOKEN_PROGRAM_ID))
|
|
26861
26879
|
throw new Error("Unexpected Nest deposit token account creation");
|
|
26862
26880
|
continue;
|
|
26863
26881
|
}
|
|
26864
26882
|
const d = ix.data;
|
|
26865
26883
|
const matches = (index, key) => ix.keys[index]?.pubkey.equals(key);
|
|
26866
|
-
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_token29.TOKEN_PROGRAM_ID) || !matches(15,
|
|
26884
|
+
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_token29.TOKEN_PROGRAM_ID) || !matches(15, import_web347.SystemProgram.programId) || !matches(17, Messenger) || ![0, 1, 11].every((index) => ix.keys[index].isSigner) || ix.keys.some(
|
|
26867
26885
|
(meta, index) => meta.isSigner && ![0, 1, 11].includes(index)
|
|
26868
26886
|
)) {
|
|
26869
26887
|
throw new Error(
|
|
@@ -26889,26 +26907,26 @@ async function decodeNestDepositRequest(args) {
|
|
|
26889
26907
|
shareMint
|
|
26890
26908
|
),
|
|
26891
26909
|
burn
|
|
26892
|
-
].map(
|
|
26910
|
+
].map(import_common69.toKitInstruction),
|
|
26893
26911
|
lookupTables: tables.map((table) => (0, import_kit26.address)(table.key.toBase58())),
|
|
26894
26912
|
ephemeralSignerKeys: [eventKey]
|
|
26895
26913
|
};
|
|
26896
26914
|
}
|
|
26897
26915
|
|
|
26898
26916
|
// src/services/vaultLutManager.ts
|
|
26899
|
-
var
|
|
26917
|
+
var import_web348 = require("@solana/web3.js");
|
|
26900
26918
|
var MAX_LUT_ADDRESSES = 256;
|
|
26901
26919
|
var ACTIVE = (1n << 64n) - 1n;
|
|
26902
26920
|
var asAddress = (key) => key.toBase58();
|
|
26903
26921
|
function uniqueLutAddresses(addresses) {
|
|
26904
|
-
return [...new Set(addresses)].filter((a) => a !==
|
|
26922
|
+
return [...new Set(addresses)].filter((a) => a !== import_web348.PublicKey.default.toBase58()).map((a) => asAddress(new import_web348.PublicKey(a)));
|
|
26905
26923
|
}
|
|
26906
26924
|
var VaultLutManager = class {
|
|
26907
26925
|
constructor(connection) {
|
|
26908
26926
|
this.connection = connection;
|
|
26909
26927
|
}
|
|
26910
26928
|
async fetch(table) {
|
|
26911
|
-
const account = (await this.connection.getAddressLookupTable(new
|
|
26929
|
+
const account = (await this.connection.getAddressLookupTable(new import_web348.PublicKey(table), {
|
|
26912
26930
|
commitment: "confirmed"
|
|
26913
26931
|
})).value;
|
|
26914
26932
|
if (!account) throw new Error(`Lookup table not found: ${table}`);
|
|
@@ -26920,14 +26938,14 @@ var VaultLutManager = class {
|
|
|
26920
26938
|
* mapping is lost. Also accepts older tables containing the vault elsewhere. */
|
|
26921
26939
|
async findForVault(authority, vault) {
|
|
26922
26940
|
const accounts2 = await this.connection.getProgramAccounts(
|
|
26923
|
-
|
|
26941
|
+
import_web348.AddressLookupTableProgram.programId,
|
|
26924
26942
|
{
|
|
26925
26943
|
commitment: "confirmed",
|
|
26926
26944
|
filters: [{ memcmp: { offset: 22, bytes: authority.toBase58() } }]
|
|
26927
26945
|
}
|
|
26928
26946
|
);
|
|
26929
26947
|
return accounts2.flatMap(({ pubkey: pubkey2, account }) => {
|
|
26930
|
-
const state =
|
|
26948
|
+
const state = import_web348.AddressLookupTableAccount.deserialize(account.data);
|
|
26931
26949
|
return state.deactivationSlot === ACTIVE && state.authority?.equals(authority) && state.addresses.some((a) => a.toBase58() === vault) ? [asAddress(pubkey2)] : [];
|
|
26932
26950
|
});
|
|
26933
26951
|
}
|
|
@@ -26959,7 +26977,7 @@ var VaultLutManager = class {
|
|
|
26959
26977
|
let created = false;
|
|
26960
26978
|
const send = async (instructions2) => {
|
|
26961
26979
|
const { blockhash, lastValidBlockHeight } = await this.connection.getLatestBlockhash("confirmed");
|
|
26962
|
-
const tx = new
|
|
26980
|
+
const tx = new import_web348.Transaction({
|
|
26963
26981
|
feePayer: args.payer.publicKey,
|
|
26964
26982
|
blockhash,
|
|
26965
26983
|
lastValidBlockHeight
|
|
@@ -26986,7 +27004,7 @@ var VaultLutManager = class {
|
|
|
26986
27004
|
};
|
|
26987
27005
|
if (!table) {
|
|
26988
27006
|
const hashes = await this.connection.getAccountInfo(
|
|
26989
|
-
|
|
27007
|
+
import_web348.SYSVAR_SLOT_HASHES_PUBKEY,
|
|
26990
27008
|
"confirmed"
|
|
26991
27009
|
);
|
|
26992
27010
|
if (!hashes || hashes.data.length < 48 || hashes.data.readBigUInt64LE(0) === 0n)
|
|
@@ -26994,7 +27012,7 @@ var VaultLutManager = class {
|
|
|
26994
27012
|
const recentSlot = Number(hashes.data.readBigUInt64LE(8));
|
|
26995
27013
|
if (!Number.isSafeInteger(recentSlot))
|
|
26996
27014
|
throw new Error("Recent slot exceeds safe integer range");
|
|
26997
|
-
const [create, key] =
|
|
27015
|
+
const [create, key] = import_web348.AddressLookupTableProgram.createLookupTable({
|
|
26998
27016
|
authority: authority.publicKey,
|
|
26999
27017
|
payer: args.payer.publicKey,
|
|
27000
27018
|
recentSlot
|
|
@@ -27009,11 +27027,11 @@ var VaultLutManager = class {
|
|
|
27009
27027
|
args.onProgress?.(`Creating vault LUT: ${table}`);
|
|
27010
27028
|
await send([
|
|
27011
27029
|
create,
|
|
27012
|
-
|
|
27030
|
+
import_web348.AddressLookupTableProgram.extendLookupTable({
|
|
27013
27031
|
lookupTable: key,
|
|
27014
27032
|
authority: authority.publicKey,
|
|
27015
27033
|
payer: args.payer.publicKey,
|
|
27016
|
-
addresses: [new
|
|
27034
|
+
addresses: [new import_web348.PublicKey(args.vault)]
|
|
27017
27035
|
})
|
|
27018
27036
|
]);
|
|
27019
27037
|
created = true;
|
|
@@ -27033,11 +27051,11 @@ var VaultLutManager = class {
|
|
|
27033
27051
|
for (let i = 0; i < missing.length; i += 20) {
|
|
27034
27052
|
const batch = missing.slice(i, i + 20);
|
|
27035
27053
|
await send([
|
|
27036
|
-
|
|
27037
|
-
lookupTable: new
|
|
27054
|
+
import_web348.AddressLookupTableProgram.extendLookupTable({
|
|
27055
|
+
lookupTable: new import_web348.PublicKey(table),
|
|
27038
27056
|
authority: authority.publicKey,
|
|
27039
27057
|
payer: args.payer.publicKey,
|
|
27040
|
-
addresses: batch.map((a) => new
|
|
27058
|
+
addresses: batch.map((a) => new import_web348.PublicKey(a))
|
|
27041
27059
|
})
|
|
27042
27060
|
]);
|
|
27043
27061
|
args.onProgress?.(
|
|
@@ -27060,12 +27078,12 @@ var VaultLutManager = class {
|
|
|
27060
27078
|
|
|
27061
27079
|
// src/services/vaultLookupTableAccounts.ts
|
|
27062
27080
|
var import_core26 = require("@anchor-lang/core");
|
|
27063
|
-
var
|
|
27081
|
+
var import_web349 = require("@solana/web3.js");
|
|
27064
27082
|
var import_spl_token30 = require("@solana/spl-token");
|
|
27065
27083
|
var import_marginfi_client_v25 = require("@mrgnlabs/marginfi-client-v2");
|
|
27066
27084
|
var import_Obligation3 = require("@kamino-finance/klend-sdk/dist/@codegen/klend/accounts/Obligation");
|
|
27067
27085
|
var import_Reserve3 = require("@kamino-finance/klend-sdk/dist/@codegen/klend/accounts/Reserve");
|
|
27068
|
-
var
|
|
27086
|
+
var import_common70 = __toESM(require_dist());
|
|
27069
27087
|
var import_marginfi7 = __toESM(require_dist2());
|
|
27070
27088
|
var import_kamino6 = __toESM(require_dist3());
|
|
27071
27089
|
async function collectVaultLookupTableAccounts(client, vault, options = {}) {
|
|
@@ -27083,10 +27101,10 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
|
|
|
27083
27101
|
import_spl_token30.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
27084
27102
|
import_spl_token30.TOKEN_PROGRAM_ID,
|
|
27085
27103
|
import_spl_token30.TOKEN_2022_PROGRAM_ID,
|
|
27086
|
-
|
|
27104
|
+
import_web349.SYSVAR_INSTRUCTIONS_PUBKEY
|
|
27087
27105
|
].forEach(add);
|
|
27088
27106
|
const publicKeys = (value) => {
|
|
27089
|
-
if (value instanceof
|
|
27107
|
+
if (value instanceof import_web349.PublicKey) {
|
|
27090
27108
|
add(value);
|
|
27091
27109
|
return;
|
|
27092
27110
|
}
|
|
@@ -27105,7 +27123,7 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
|
|
|
27105
27123
|
}
|
|
27106
27124
|
];
|
|
27107
27125
|
const tranche = await client.program.account.vaultTrancheState.fetchNullable(
|
|
27108
|
-
new
|
|
27126
|
+
new import_web349.PublicKey(tranchePda)
|
|
27109
27127
|
);
|
|
27110
27128
|
if (tranche) {
|
|
27111
27129
|
publicKeys(tranche.config);
|
|
@@ -27125,30 +27143,30 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
|
|
|
27125
27143
|
);
|
|
27126
27144
|
}
|
|
27127
27145
|
const holdings = state.holdings.filter(
|
|
27128
|
-
(h) => !h.mint.equals(
|
|
27146
|
+
(h) => !h.mint.equals(import_web349.PublicKey.default)
|
|
27129
27147
|
);
|
|
27130
27148
|
for (const h of holdings) {
|
|
27131
27149
|
const mint = h.mint.toBase58(), program = tokenProgramAddressFromIdlEnum(h.tokenProgram);
|
|
27132
27150
|
add(mint);
|
|
27133
27151
|
add(program);
|
|
27134
|
-
add((0,
|
|
27135
|
-
add((0,
|
|
27136
|
-
if (options.user) add((0,
|
|
27152
|
+
add((0, import_common70.getAtaAddress)(mint, vault, program, true));
|
|
27153
|
+
add((0, import_common70.getAtaAddress)(mint, fee, program, true));
|
|
27154
|
+
if (options.user) add((0, import_common70.getAtaAddress)(mint, options.user, program, true));
|
|
27137
27155
|
}
|
|
27138
27156
|
for (const share of shares) {
|
|
27139
27157
|
add(share.mint);
|
|
27140
27158
|
add(share.program);
|
|
27141
|
-
add((0,
|
|
27142
|
-
add((0,
|
|
27159
|
+
add((0, import_common70.getAtaAddress)(share.mint, vault, share.program, true));
|
|
27160
|
+
add((0, import_common70.getAtaAddress)(share.mint, fee, share.program, true));
|
|
27143
27161
|
if (options.user)
|
|
27144
|
-
add((0,
|
|
27162
|
+
add((0, import_common70.getAtaAddress)(share.mint, options.user, share.program, true));
|
|
27145
27163
|
}
|
|
27146
27164
|
const slots = state.externalLiquidity.filter(
|
|
27147
27165
|
(s) => [1, 2].includes(s.data[0])
|
|
27148
27166
|
);
|
|
27149
27167
|
for (const slot of slots) {
|
|
27150
|
-
const position = new
|
|
27151
|
-
if (position.equals(
|
|
27168
|
+
const position = new import_web349.PublicKey(Uint8Array.from(slot.data.slice(8, 40)));
|
|
27169
|
+
if (position.equals(import_web349.PublicKey.default)) continue;
|
|
27152
27170
|
add(position);
|
|
27153
27171
|
const info = await connection.getAccountInfo(position, "confirmed");
|
|
27154
27172
|
if (slot.data[0] === 1) {
|
|
@@ -27159,7 +27177,7 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
|
|
|
27159
27177
|
const cpi = new import_marginfi7.CpiClient({ accounts: config }).withdraw_cpi({
|
|
27160
27178
|
marginfiAccount: position.toBase58(),
|
|
27161
27179
|
authority: vault,
|
|
27162
|
-
destinationTokenAccount: (0,
|
|
27180
|
+
destinationTokenAccount: (0, import_common70.getAtaAddress)(
|
|
27163
27181
|
mint,
|
|
27164
27182
|
vault,
|
|
27165
27183
|
config.tokenProgram,
|
|
@@ -27212,7 +27230,7 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
|
|
|
27212
27230
|
if (!reserveKeys.length)
|
|
27213
27231
|
throw new Error(`No reserves found for Kamino obligation ${position}`);
|
|
27214
27232
|
const infos = await connection.getMultipleAccountsInfo(
|
|
27215
|
-
reserveKeys.map((a) => new
|
|
27233
|
+
reserveKeys.map((a) => new import_web349.PublicKey(a)),
|
|
27216
27234
|
"confirmed"
|
|
27217
27235
|
);
|
|
27218
27236
|
const reserves = infos.map((info2, i) => {
|
|
@@ -27242,7 +27260,7 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
|
|
|
27242
27260
|
obligation: position.toBase58(),
|
|
27243
27261
|
reserves,
|
|
27244
27262
|
reserve,
|
|
27245
|
-
destination: (0,
|
|
27263
|
+
destination: (0, import_common70.getAtaAddress)(
|
|
27246
27264
|
reserve.liquidityMint,
|
|
27247
27265
|
vault,
|
|
27248
27266
|
reserve.liquidityTokenProgram,
|
|
@@ -27262,12 +27280,11 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
|
|
|
27262
27280
|
}
|
|
27263
27281
|
|
|
27264
27282
|
// src/index.ts
|
|
27265
|
-
var
|
|
27283
|
+
var import_common71 = __toESM(require_dist());
|
|
27266
27284
|
// Annotate the CommonJS export names for ESM import in node:
|
|
27267
27285
|
0 && (module.exports = {
|
|
27268
27286
|
ASSET_DECIMALS,
|
|
27269
27287
|
ASSET_REBALANCE_COOLDOWN_SECS,
|
|
27270
|
-
ASYNC_REDEMPTION_CANCEL_DELAY_SECS,
|
|
27271
27288
|
AccountClient,
|
|
27272
27289
|
ActivateCircuitBreakerBuilder,
|
|
27273
27290
|
AddIncentiveRecipientBuilder,
|
|
@@ -27456,7 +27473,6 @@ var import_common72 = __toESM(require_dist());
|
|
|
27456
27473
|
defaultKeypairPath,
|
|
27457
27474
|
deleteAccount,
|
|
27458
27475
|
discoverVaultsForSigner,
|
|
27459
|
-
externalWithdrawComputeBudget,
|
|
27460
27476
|
externalWithdrawLookupTables,
|
|
27461
27477
|
fetchExternalPositions,
|
|
27462
27478
|
fetchNestRedemptionQuote,
|
|
@@ -27552,6 +27568,5 @@ var import_common72 = __toESM(require_dist());
|
|
|
27552
27568
|
vaultAuthorityForWallet,
|
|
27553
27569
|
walletReconciliationGuardUpdates,
|
|
27554
27570
|
withDiscoveredYieldAccounts,
|
|
27555
|
-
withVaultLookupTables
|
|
27556
|
-
withdrawalComputeBudget
|
|
27571
|
+
withVaultLookupTables
|
|
27557
27572
|
});
|