@perena/vault-sdk 1.0.70 → 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 +9 -6
- package/dist/index.d.ts +2 -8
- package/dist/index.js +571 -621
- 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),
|
|
@@ -2074,7 +2074,7 @@ __export(index_exports, {
|
|
|
2074
2074
|
DEFAULT_JUNIOR_WITHDRAWAL_LOCKUP_SECS: () => DEFAULT_JUNIOR_WITHDRAWAL_LOCKUP_SECS,
|
|
2075
2075
|
DEFAULT_MARGINFI_WEIGHT_BPS: () => DEFAULT_MARGINFI_WEIGHT_BPS,
|
|
2076
2076
|
DEFAULT_MAX_ACCEPTABLE_APY_BPS: () => DEFAULT_MAX_ACCEPTABLE_APY_BPS,
|
|
2077
|
-
DEFAULT_MINTS: () =>
|
|
2077
|
+
DEFAULT_MINTS: () => import_common71.DEFAULT_MINTS,
|
|
2078
2078
|
DEFAULT_MIN_AMOUNT_UI: () => DEFAULT_MIN_AMOUNT_UI,
|
|
2079
2079
|
DEFAULT_ORACLE_STALENESS_THRESHOLD_SECS: () => DEFAULT_ORACLE_STALENESS_THRESHOLD_SECS,
|
|
2080
2080
|
DEFAULT_PRICE_ORACLE_ACCOUNT: () => DEFAULT_PRICE_ORACLE_ACCOUNT,
|
|
@@ -2130,7 +2130,7 @@ __export(index_exports, {
|
|
|
2130
2130
|
ManagerRedepositAssetBuilder: () => ManagerRedepositAssetBuilder,
|
|
2131
2131
|
ManagerWithdrawAssetBuilder: () => ManagerWithdrawAssetBuilder,
|
|
2132
2132
|
MarginfiPositionProvider: () => MarginfiPositionProvider,
|
|
2133
|
-
MintRegistry: () =>
|
|
2133
|
+
MintRegistry: () => import_common71.MintRegistry,
|
|
2134
2134
|
MockYieldTracker: () => MockYieldTracker,
|
|
2135
2135
|
NEST_API_BASE_URL: () => import_nest2.NEST_API_BASE_URL,
|
|
2136
2136
|
NEST_RWA_SHARE_MINT: () => NEST_RWA_SHARE_MINT,
|
|
@@ -2236,7 +2236,6 @@ __export(index_exports, {
|
|
|
2236
2236
|
defaultKeypairPath: () => defaultKeypairPath,
|
|
2237
2237
|
deleteAccount: () => deleteAccount,
|
|
2238
2238
|
discoverVaultsForSigner: () => discoverVaultsForSigner,
|
|
2239
|
-
externalWithdrawComputeBudget: () => externalWithdrawComputeBudget,
|
|
2240
2239
|
externalWithdrawLookupTables: () => externalWithdrawLookupTables,
|
|
2241
2240
|
fetchExternalPositions: () => fetchExternalPositions,
|
|
2242
2241
|
fetchNestRedemptionQuote: () => import_nest4.fetchNestRedemptionQuote,
|
|
@@ -2286,7 +2285,7 @@ __export(index_exports, {
|
|
|
2286
2285
|
makeProvider: () => makeProvider,
|
|
2287
2286
|
managerReconciliationStateKey: () => managerReconciliationStateKey,
|
|
2288
2287
|
mintTokensTo: () => mintTokensTo,
|
|
2289
|
-
mints: () =>
|
|
2288
|
+
mints: () => import_common71.mints,
|
|
2290
2289
|
mostFrequent: () => mostFrequent,
|
|
2291
2290
|
parseExternalLiquidityRefs: () => parseExternalLiquidityRefs,
|
|
2292
2291
|
planExternalAllocation: () => planExternalAllocation,
|
|
@@ -2332,8 +2331,7 @@ __export(index_exports, {
|
|
|
2332
2331
|
vaultAuthorityForWallet: () => vaultAuthorityForWallet,
|
|
2333
2332
|
walletReconciliationGuardUpdates: () => walletReconciliationGuardUpdates,
|
|
2334
2333
|
withDiscoveredYieldAccounts: () => withDiscoveredYieldAccounts,
|
|
2335
|
-
withVaultLookupTables: () => withVaultLookupTables
|
|
2336
|
-
withdrawalComputeBudget: () => withdrawalComputeBudget
|
|
2334
|
+
withVaultLookupTables: () => withVaultLookupTables
|
|
2337
2335
|
});
|
|
2338
2336
|
module.exports = __toCommonJS(index_exports);
|
|
2339
2337
|
|
|
@@ -2438,15 +2436,15 @@ var import_fs = __toESM(require("fs"));
|
|
|
2438
2436
|
var import_os = __toESM(require("os"));
|
|
2439
2437
|
var import_path = __toESM(require("path"));
|
|
2440
2438
|
var import_core23 = require("@anchor-lang/core");
|
|
2441
|
-
var
|
|
2439
|
+
var import_web330 = require("@solana/web3.js");
|
|
2442
2440
|
var import_kit11 = require("@solana/kit");
|
|
2443
|
-
var
|
|
2441
|
+
var import_common50 = __toESM(require_dist());
|
|
2444
2442
|
|
|
2445
2443
|
// src/client/client.ts
|
|
2446
2444
|
var import_core22 = require("@anchor-lang/core");
|
|
2447
2445
|
var import_kit10 = require("@solana/kit");
|
|
2448
|
-
var
|
|
2449
|
-
var
|
|
2446
|
+
var import_web329 = require("@solana/web3.js");
|
|
2447
|
+
var import_common49 = __toESM(require_dist());
|
|
2450
2448
|
|
|
2451
2449
|
// src/idl/vault.ts
|
|
2452
2450
|
var IDL = {
|
|
@@ -16892,11 +16890,10 @@ var ExecuteTrancheDepositBuilder = class extends VaultBuilderBase {
|
|
|
16892
16890
|
var import_core13 = require("@anchor-lang/core");
|
|
16893
16891
|
var import_spl_token13 = require("@solana/spl-token");
|
|
16894
16892
|
var import_web319 = require("@solana/web3.js");
|
|
16895
|
-
var
|
|
16893
|
+
var import_common36 = __toESM(require_dist());
|
|
16896
16894
|
|
|
16897
16895
|
// src/client/builders/withdrawalPlan.ts
|
|
16898
16896
|
var import_web317 = require("@solana/web3.js");
|
|
16899
|
-
var import_common35 = __toESM(require_dist());
|
|
16900
16897
|
|
|
16901
16898
|
// src/client/builders/withdrawalLiquidity.ts
|
|
16902
16899
|
var import_core12 = require("@anchor-lang/core");
|
|
@@ -17477,28 +17474,12 @@ async function resolveWithdrawalPlan(args) {
|
|
|
17477
17474
|
positions: positions()
|
|
17478
17475
|
});
|
|
17479
17476
|
}
|
|
17480
|
-
function withdrawalComputeBudget(legs) {
|
|
17481
|
-
const external = legs.filter((l) => l.externalWithdrawIxRefs !== null);
|
|
17482
|
-
if (!external.length) return [];
|
|
17483
|
-
const units = Math.min(
|
|
17484
|
-
14e5,
|
|
17485
|
-
external.reduce(
|
|
17486
|
-
(sum, l) => sum + (l.externalWithdrawIxRefs.cpi.types.includes(
|
|
17487
|
-
import_common35.CpiTypes.KLEND_WITHDRAW_AND_REDEEM_V2
|
|
17488
|
-
) ? 1e6 : 4e5),
|
|
17489
|
-
0
|
|
17490
|
-
)
|
|
17491
|
-
);
|
|
17492
|
-
return [
|
|
17493
|
-
(0, import_common35.toKitInstruction)(import_web317.ComputeBudgetProgram.setComputeUnitLimit({ units }))
|
|
17494
|
-
];
|
|
17495
|
-
}
|
|
17496
17477
|
|
|
17497
17478
|
// src/client/builders/externalLiquidity.ts
|
|
17498
17479
|
var import_kit8 = require("@solana/kit");
|
|
17499
17480
|
var import_web318 = require("@solana/web3.js");
|
|
17500
17481
|
var import_kamino3 = __toESM(require_dist3());
|
|
17501
|
-
var
|
|
17482
|
+
var import_common35 = __toESM(require_dist());
|
|
17502
17483
|
var import_marginfi2 = __toESM(require_dist2());
|
|
17503
17484
|
function parseMarginfiSlot(slot) {
|
|
17504
17485
|
const data = slot?.data;
|
|
@@ -17515,21 +17496,12 @@ function toWeb3AccountMeta(account) {
|
|
|
17515
17496
|
isSigner: account.role === import_kit8.AccountRole.READONLY_SIGNER || account.role === import_kit8.AccountRole.WRITABLE_SIGNER
|
|
17516
17497
|
};
|
|
17517
17498
|
}
|
|
17518
|
-
function externalWithdrawComputeBudget(refs) {
|
|
17519
|
-
return refs?.cpi.types.some(
|
|
17520
|
-
(t) => t === import_common36.CpiTypes.KLEND_WITHDRAW_AND_REDEEM_V2 || t === import_common36.CpiTypes.KLEND_DEPOSIT_AND_COLLATERALIZE_V2
|
|
17521
|
-
) ? [
|
|
17522
|
-
(0, import_common36.toKitInstruction)(
|
|
17523
|
-
import_web318.ComputeBudgetProgram.setComputeUnitLimit({ units: 1e6 })
|
|
17524
|
-
)
|
|
17525
|
-
] : [];
|
|
17526
|
-
}
|
|
17527
17499
|
function externalWithdrawLookupTables(refs, tables = []) {
|
|
17528
17500
|
return [
|
|
17529
17501
|
.../* @__PURE__ */ new Set([
|
|
17530
17502
|
...tables,
|
|
17531
17503
|
...refs?.cpi.types.some(
|
|
17532
|
-
(t) => t ===
|
|
17504
|
+
(t) => t === import_common35.CpiTypes.KLEND_WITHDRAW_AND_REDEEM_V2 || t === import_common35.CpiTypes.KLEND_DEPOSIT_AND_COLLATERALIZE_V2
|
|
17533
17505
|
) ? [import_kamino3.KAMINO_LENDING_LOOKUP_TABLE] : []
|
|
17534
17506
|
])
|
|
17535
17507
|
];
|
|
@@ -17561,7 +17533,7 @@ async function resolveExternalWithdraw({
|
|
|
17561
17533
|
const marginfiAccounts = marginfi && (0, import_marginfi2.marginfiAccountsForMint)(assetMint);
|
|
17562
17534
|
if (marginfi && marginfiAccounts) {
|
|
17563
17535
|
const client = new import_marginfi2.CpiClient({ accounts: marginfiAccounts });
|
|
17564
|
-
const refs = (0,
|
|
17536
|
+
const refs = (0, import_common35.createCpiRefs)([
|
|
17565
17537
|
client.withdraw_cpi({
|
|
17566
17538
|
marginfiAccount: marginfi.userAccount,
|
|
17567
17539
|
authority: vault,
|
|
@@ -17585,7 +17557,7 @@ async function resolveExternalWithdraw({
|
|
|
17585
17557
|
assetMint
|
|
17586
17558
|
});
|
|
17587
17559
|
if (context) {
|
|
17588
|
-
const refs = (0,
|
|
17560
|
+
const refs = (0, import_common35.createCpiRefs)(
|
|
17589
17561
|
(0, import_kamino3.kaminoWithdrawCpis)({
|
|
17590
17562
|
...context,
|
|
17591
17563
|
vault,
|
|
@@ -17618,14 +17590,14 @@ function buildMarginfiWithdrawInteraction(args) {
|
|
|
17618
17590
|
`No Marginfi market is configured for asset mint ${args.assetMint}`
|
|
17619
17591
|
);
|
|
17620
17592
|
}
|
|
17621
|
-
const vaultAssetAta = (0,
|
|
17593
|
+
const vaultAssetAta = (0, import_common35.getAtaAddress)(
|
|
17622
17594
|
args.assetMint,
|
|
17623
17595
|
args.vault,
|
|
17624
17596
|
marginfiAccounts.tokenProgram,
|
|
17625
17597
|
true
|
|
17626
17598
|
);
|
|
17627
17599
|
const marginfiClient = new import_marginfi2.CpiClient({ accounts: marginfiAccounts });
|
|
17628
|
-
const withdraw = (0,
|
|
17600
|
+
const withdraw = (0, import_common35.createCpiRefs)([
|
|
17629
17601
|
marginfiClient.withdraw_cpi({
|
|
17630
17602
|
marginfiAccount: args.marginfiAccount,
|
|
17631
17603
|
authority: args.vault,
|
|
@@ -17707,12 +17679,9 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
17707
17679
|
}
|
|
17708
17680
|
async getTx(txArgs) {
|
|
17709
17681
|
const legs = await this.getIxArgs(txArgs);
|
|
17710
|
-
const preamble =
|
|
17711
|
-
(ix) => ix.programAddress !== import_web319.ComputeBudgetProgram.programId.toBase58()
|
|
17712
|
-
);
|
|
17682
|
+
const preamble = await this.buildPreambleInstructions(legs[0]);
|
|
17713
17683
|
return this.withVaultLookupTables({
|
|
17714
17684
|
instructions: [
|
|
17715
|
-
...withdrawalComputeBudget(legs),
|
|
17716
17685
|
...preamble,
|
|
17717
17686
|
...await Promise.all(legs.map((args) => this.getIx(args)))
|
|
17718
17687
|
],
|
|
@@ -17722,17 +17691,17 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
17722
17691
|
}
|
|
17723
17692
|
getIxAccounts(args) {
|
|
17724
17693
|
return {
|
|
17725
|
-
user: (0,
|
|
17726
|
-
vault: (0,
|
|
17727
|
-
vaultOracle: (0,
|
|
17728
|
-
vaultTrancheState: (0,
|
|
17729
|
-
assetMint: (0,
|
|
17730
|
-
trancheShareMint: (0,
|
|
17731
|
-
userAssetAta: (0,
|
|
17732
|
-
vaultAssetAta: (0,
|
|
17733
|
-
userTrancheShareAta: (0,
|
|
17734
|
-
assetTokenProgram: (0,
|
|
17735
|
-
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),
|
|
17736
17705
|
associatedTokenProgram: import_spl_token13.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
17737
17706
|
systemProgram: import_web319.SystemProgram.programId
|
|
17738
17707
|
};
|
|
@@ -17771,7 +17740,7 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
17771
17740
|
);
|
|
17772
17741
|
return methods.accountsPartial(
|
|
17773
17742
|
this.getIxAccounts(args)
|
|
17774
|
-
).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(
|
|
17743
|
+
).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(import_common36.toKitInstruction);
|
|
17775
17744
|
}
|
|
17776
17745
|
async deriveIxArgs(txArgs) {
|
|
17777
17746
|
const connection = this.program.provider.connection;
|
|
@@ -17792,7 +17761,7 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
17792
17761
|
txArgs.assetTokenProgram
|
|
17793
17762
|
);
|
|
17794
17763
|
const { mint: trancheShareMint, tokenProgram: shareTokenProgram } = trancheShare;
|
|
17795
|
-
const vaultAssetAta = (0,
|
|
17764
|
+
const vaultAssetAta = (0, import_common36.getAtaAddress)(
|
|
17796
17765
|
txArgs.assetMint,
|
|
17797
17766
|
txArgs.vault,
|
|
17798
17767
|
assetTokenProgram,
|
|
@@ -17822,13 +17791,13 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
17822
17791
|
addressSeeds: txArgs.addressSeeds,
|
|
17823
17792
|
assetTokenProgram,
|
|
17824
17793
|
shareTokenProgram,
|
|
17825
|
-
userAssetAta: (0,
|
|
17794
|
+
userAssetAta: (0, import_common36.getAtaAddress)(
|
|
17826
17795
|
txArgs.assetMint,
|
|
17827
17796
|
txArgs.user,
|
|
17828
17797
|
assetTokenProgram
|
|
17829
17798
|
),
|
|
17830
17799
|
vaultAssetAta,
|
|
17831
|
-
userTrancheShareAta: (0,
|
|
17800
|
+
userTrancheShareAta: (0, import_common36.getAtaAddress)(
|
|
17832
17801
|
trancheShareMint,
|
|
17833
17802
|
txArgs.user,
|
|
17834
17803
|
shareTokenProgram
|
|
@@ -17845,19 +17814,16 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
17845
17814
|
);
|
|
17846
17815
|
}
|
|
17847
17816
|
async buildPreambleInstructions(args) {
|
|
17848
|
-
const payer = (0,
|
|
17817
|
+
const payer = (0, import_common36.toWeb3Pk)(args.user);
|
|
17849
17818
|
const createUserAssetAta = (0, import_spl_token13.createAssociatedTokenAccountIdempotentInstruction)(
|
|
17850
17819
|
payer,
|
|
17851
|
-
(0,
|
|
17820
|
+
(0, import_common36.toWeb3Pk)(args.userAssetAta),
|
|
17852
17821
|
payer,
|
|
17853
|
-
(0,
|
|
17854
|
-
(0,
|
|
17822
|
+
(0, import_common36.toWeb3Pk)(args.assetMint),
|
|
17823
|
+
(0, import_common36.toWeb3Pk)(args.assetTokenProgram),
|
|
17855
17824
|
import_spl_token13.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
17856
17825
|
);
|
|
17857
|
-
return [
|
|
17858
|
-
...externalWithdrawComputeBudget(args.externalWithdrawIxRefs),
|
|
17859
|
-
(0, import_common37.toKitInstruction)(createUserAssetAta)
|
|
17860
|
-
];
|
|
17826
|
+
return [(0, import_common36.toKitInstruction)(createUserAssetAta)];
|
|
17861
17827
|
}
|
|
17862
17828
|
async buildPlanExtras(args) {
|
|
17863
17829
|
return {
|
|
@@ -17870,9 +17836,8 @@ var ExecuteTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
17870
17836
|
|
|
17871
17837
|
// src/client/builders/executeWithdraw.ts
|
|
17872
17838
|
var import_core14 = require("@anchor-lang/core");
|
|
17873
|
-
var import_web320 = require("@solana/web3.js");
|
|
17874
17839
|
var import_spl_token14 = require("@solana/spl-token");
|
|
17875
|
-
var
|
|
17840
|
+
var import_common37 = __toESM(require_dist());
|
|
17876
17841
|
var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
17877
17842
|
/** Ordered arguments, including CPI data/account refs, for every partial burn. */
|
|
17878
17843
|
async getIxArgs(txArgs) {
|
|
@@ -17935,12 +17900,9 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
17935
17900
|
}
|
|
17936
17901
|
async getTx(txArgs) {
|
|
17937
17902
|
const legs = await this.getIxArgs(txArgs);
|
|
17938
|
-
const preamble =
|
|
17939
|
-
(ix) => ix.programAddress !== import_web320.ComputeBudgetProgram.programId.toBase58()
|
|
17940
|
-
);
|
|
17903
|
+
const preamble = await this.buildPreambleInstructions(legs[0]);
|
|
17941
17904
|
return this.withVaultLookupTables({
|
|
17942
17905
|
instructions: [
|
|
17943
|
-
...withdrawalComputeBudget(legs),
|
|
17944
17906
|
...preamble,
|
|
17945
17907
|
...await Promise.all(legs.map((args) => this.getIx(args)))
|
|
17946
17908
|
],
|
|
@@ -17950,19 +17912,19 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
17950
17912
|
}
|
|
17951
17913
|
getIxAccounts(args) {
|
|
17952
17914
|
return {
|
|
17953
|
-
user: (0,
|
|
17954
|
-
vault: (0,
|
|
17955
|
-
vaultOracle: (0,
|
|
17956
|
-
vaultTrancheState: args.vaultTrancheState ? (0,
|
|
17957
|
-
assetMint: (0,
|
|
17958
|
-
shareMint: (0,
|
|
17959
|
-
userAssetAta: (0,
|
|
17960
|
-
vaultAssetAta: (0,
|
|
17961
|
-
feeVault: (0,
|
|
17962
|
-
feeVaultAta: (0,
|
|
17963
|
-
userShareAta: (0,
|
|
17964
|
-
assetTokenProgram: (0,
|
|
17965
|
-
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)
|
|
17966
17928
|
};
|
|
17967
17929
|
}
|
|
17968
17930
|
getIxData(args) {
|
|
@@ -17992,7 +17954,7 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
17992
17954
|
) : this.program.methods.executeWithdraw(data.shareAmount);
|
|
17993
17955
|
return methods.accountsPartial(
|
|
17994
17956
|
this.getIxAccounts(args)
|
|
17995
|
-
).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(
|
|
17957
|
+
).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(import_common37.toKitInstruction);
|
|
17996
17958
|
}
|
|
17997
17959
|
async deriveIxArgs(txArgs) {
|
|
17998
17960
|
const connection = this.program.provider.connection;
|
|
@@ -18026,7 +17988,7 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
18026
17988
|
),
|
|
18027
17989
|
this.account.fetchVault(txArgs.vault)
|
|
18028
17990
|
]);
|
|
18029
|
-
const vaultAssetAta = (0,
|
|
17991
|
+
const vaultAssetAta = (0, import_common37.getAtaAddress)(
|
|
18030
17992
|
txArgs.assetMint,
|
|
18031
17993
|
txArgs.vault,
|
|
18032
17994
|
assetTokenProgram,
|
|
@@ -18054,16 +18016,16 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
18054
18016
|
shareAmount: new import_core14.BN(txArgs.shareAmount.toString()),
|
|
18055
18017
|
assetTokenProgram,
|
|
18056
18018
|
shareTokenProgram,
|
|
18057
|
-
userAssetAta: txArgs.userAssetAta ?? (0,
|
|
18019
|
+
userAssetAta: txArgs.userAssetAta ?? (0, import_common37.getAtaAddress)(txArgs.assetMint, txArgs.user, assetTokenProgram),
|
|
18058
18020
|
vaultAssetAta,
|
|
18059
18021
|
feeVault,
|
|
18060
|
-
feeVaultAta: (0,
|
|
18022
|
+
feeVaultAta: (0, import_common37.getAtaAddress)(
|
|
18061
18023
|
txArgs.assetMint,
|
|
18062
18024
|
feeVault,
|
|
18063
18025
|
assetTokenProgram,
|
|
18064
18026
|
true
|
|
18065
18027
|
),
|
|
18066
|
-
userShareAta: txArgs.userShareAta ?? (0,
|
|
18028
|
+
userShareAta: txArgs.userShareAta ?? (0, import_common37.getAtaAddress)(txArgs.shareMint, txArgs.user, shareTokenProgram),
|
|
18067
18029
|
externalWithdrawIxRefs,
|
|
18068
18030
|
externalLiquiditySource,
|
|
18069
18031
|
externalWithdrawAccounts,
|
|
@@ -18077,34 +18039,31 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
18077
18039
|
);
|
|
18078
18040
|
}
|
|
18079
18041
|
async buildPreambleInstructions(args) {
|
|
18080
|
-
const defaultUserAssetAta = (0,
|
|
18042
|
+
const defaultUserAssetAta = (0, import_common37.getAtaAddress)(
|
|
18081
18043
|
args.assetMint,
|
|
18082
18044
|
args.user,
|
|
18083
18045
|
args.assetTokenProgram
|
|
18084
18046
|
);
|
|
18085
|
-
const payer = (0,
|
|
18086
|
-
const createUserAssetAta = (0,
|
|
18087
|
-
(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)
|
|
18088
18050
|
) ? (0, import_spl_token14.createAssociatedTokenAccountIdempotentInstruction)(
|
|
18089
18051
|
payer,
|
|
18090
|
-
(0,
|
|
18052
|
+
(0, import_common37.toWeb3Pk)(args.userAssetAta),
|
|
18091
18053
|
payer,
|
|
18092
|
-
(0,
|
|
18093
|
-
(0,
|
|
18054
|
+
(0, import_common37.toWeb3Pk)(args.assetMint),
|
|
18055
|
+
(0, import_common37.toWeb3Pk)(args.assetTokenProgram),
|
|
18094
18056
|
import_spl_token14.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
18095
18057
|
) : null;
|
|
18096
18058
|
const createFeeVaultAta = (0, import_spl_token14.createAssociatedTokenAccountIdempotentInstruction)(
|
|
18097
18059
|
payer,
|
|
18098
|
-
(0,
|
|
18099
|
-
(0,
|
|
18100
|
-
(0,
|
|
18101
|
-
(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),
|
|
18102
18064
|
import_spl_token14.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
18103
18065
|
);
|
|
18104
|
-
return [
|
|
18105
|
-
...externalWithdrawComputeBudget(args.externalWithdrawIxRefs),
|
|
18106
|
-
...[createUserAssetAta, createFeeVaultAta].filter((ix) => ix != null).map(import_common38.toKitInstruction)
|
|
18107
|
-
];
|
|
18066
|
+
return [createUserAssetAta, createFeeVaultAta].filter((ix) => ix != null).map(import_common37.toKitInstruction);
|
|
18108
18067
|
}
|
|
18109
18068
|
async buildPlanExtras(args) {
|
|
18110
18069
|
return {
|
|
@@ -18115,8 +18074,8 @@ var ExecuteWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
18115
18074
|
|
|
18116
18075
|
// src/client/builders/fulfillJuniorTrancheWithdraw.ts
|
|
18117
18076
|
var import_spl_token15 = require("@solana/spl-token");
|
|
18118
|
-
var
|
|
18119
|
-
var
|
|
18077
|
+
var import_web320 = require("@solana/web3.js");
|
|
18078
|
+
var import_common38 = __toESM(require_dist());
|
|
18120
18079
|
var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
18121
18080
|
async getIx(args) {
|
|
18122
18081
|
const externalWithdrawIxRefs = args.externalWithdrawIxRefs ?? null;
|
|
@@ -18130,24 +18089,24 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
18130
18089
|
externalLiquiditySource
|
|
18131
18090
|
);
|
|
18132
18091
|
return methods.accountsPartial({
|
|
18133
|
-
signer: (0,
|
|
18134
|
-
owner: (0,
|
|
18135
|
-
queuePayer: (0,
|
|
18136
|
-
vault: (0,
|
|
18137
|
-
vaultOracle: (0,
|
|
18138
|
-
vaultTrancheState: (0,
|
|
18139
|
-
withdrawalQueue: (0,
|
|
18140
|
-
outputMint: (0,
|
|
18141
|
-
inputMint: (0,
|
|
18142
|
-
ownerInputAta: (0,
|
|
18143
|
-
ownerOutputAta: (0,
|
|
18144
|
-
vaultOutputAta: (0,
|
|
18145
|
-
queueInputAta: (0,
|
|
18146
|
-
assetTokenProgram: (0,
|
|
18147
|
-
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),
|
|
18148
18107
|
associatedTokenProgram: import_spl_token15.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
18149
|
-
systemProgram:
|
|
18150
|
-
}).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(
|
|
18108
|
+
systemProgram: import_web320.SystemProgram.programId
|
|
18109
|
+
}).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(import_common38.toKitInstruction);
|
|
18151
18110
|
}
|
|
18152
18111
|
async deriveIxArgs(txArgs) {
|
|
18153
18112
|
const connection = this.program.provider.connection;
|
|
@@ -18188,7 +18147,7 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
18188
18147
|
]);
|
|
18189
18148
|
const { mint: juniorShareMint, tokenProgram: shareTokenProgram } = juniorShare;
|
|
18190
18149
|
const queuePda = txArgs.withdrawalQueue ?? withdrawalQueue;
|
|
18191
|
-
const vaultOutputAta = (0,
|
|
18150
|
+
const vaultOutputAta = (0, import_common38.getAtaAddress)(
|
|
18192
18151
|
txArgs.assetMint,
|
|
18193
18152
|
txArgs.vault,
|
|
18194
18153
|
assetTokenProgram,
|
|
@@ -18218,14 +18177,14 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
18218
18177
|
inputMint: juniorShareMint,
|
|
18219
18178
|
assetTokenProgram,
|
|
18220
18179
|
shareTokenProgram,
|
|
18221
|
-
ownerInputAta: txArgs.ownerInputAta ?? (0,
|
|
18222
|
-
ownerOutputAta: (0,
|
|
18180
|
+
ownerInputAta: txArgs.ownerInputAta ?? (0, import_common38.getAtaAddress)(juniorShareMint, txArgs.owner, shareTokenProgram),
|
|
18181
|
+
ownerOutputAta: (0, import_common38.getAtaAddress)(
|
|
18223
18182
|
txArgs.assetMint,
|
|
18224
18183
|
txArgs.owner,
|
|
18225
18184
|
assetTokenProgram
|
|
18226
18185
|
),
|
|
18227
18186
|
vaultOutputAta,
|
|
18228
|
-
queueInputAta: (0,
|
|
18187
|
+
queueInputAta: (0, import_common38.getAtaAddress)(
|
|
18229
18188
|
juniorShareMint,
|
|
18230
18189
|
queuePda,
|
|
18231
18190
|
shareTokenProgram,
|
|
@@ -18244,23 +18203,22 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
18244
18203
|
);
|
|
18245
18204
|
}
|
|
18246
18205
|
async buildPreambleInstructions(args) {
|
|
18247
|
-
const defaultOwnerInputAta = (0,
|
|
18206
|
+
const defaultOwnerInputAta = (0, import_common38.getAtaAddress)(
|
|
18248
18207
|
args.inputMint,
|
|
18249
18208
|
args.owner,
|
|
18250
18209
|
args.shareTokenProgram
|
|
18251
18210
|
);
|
|
18252
|
-
if (!(0,
|
|
18253
|
-
return
|
|
18211
|
+
if (!(0, import_common38.toWeb3Pk)(args.ownerInputAta).equals((0, import_common38.toWeb3Pk)(defaultOwnerInputAta))) {
|
|
18212
|
+
return [];
|
|
18254
18213
|
}
|
|
18255
18214
|
return [
|
|
18256
|
-
|
|
18257
|
-
(0, import_common39.toKitInstruction)(
|
|
18215
|
+
(0, import_common38.toKitInstruction)(
|
|
18258
18216
|
(0, import_spl_token15.createAssociatedTokenAccountIdempotentInstruction)(
|
|
18259
|
-
(0,
|
|
18260
|
-
(0,
|
|
18261
|
-
(0,
|
|
18262
|
-
(0,
|
|
18263
|
-
(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),
|
|
18264
18222
|
import_spl_token15.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
18265
18223
|
)
|
|
18266
18224
|
)
|
|
@@ -18281,7 +18239,7 @@ var FulfillJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
18281
18239
|
|
|
18282
18240
|
// src/client/builders/updateTrancheConfig.ts
|
|
18283
18241
|
var import_core15 = require("@anchor-lang/core");
|
|
18284
|
-
var
|
|
18242
|
+
var import_common39 = __toESM(require_dist());
|
|
18285
18243
|
var UpdateTrancheConfigBuilder = class extends VaultBuilderBase {
|
|
18286
18244
|
async getIx(args) {
|
|
18287
18245
|
return this.program.methods.vaultUpdateTrancheConfig({
|
|
@@ -18292,11 +18250,11 @@ var UpdateTrancheConfigBuilder = class extends VaultBuilderBase {
|
|
|
18292
18250
|
targetLockupDurationSecs: args.targetLockupDurationSecs,
|
|
18293
18251
|
juniorDepositCap: args.juniorDepositCap
|
|
18294
18252
|
}).accountsPartial({
|
|
18295
|
-
curator: (0,
|
|
18296
|
-
vault: (0,
|
|
18297
|
-
vaultTrancheState: (0,
|
|
18298
|
-
vaultOracle: (0,
|
|
18299
|
-
}).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);
|
|
18300
18258
|
}
|
|
18301
18259
|
async deriveIxArgs(txArgs) {
|
|
18302
18260
|
const [vaultTrancheState] = await this.pda.deriveVaultTrancheStatePda(
|
|
@@ -18328,23 +18286,23 @@ var UpdateTrancheConfigBuilder = class extends VaultBuilderBase {
|
|
|
18328
18286
|
// src/client/builders/managerRedepositAsset.ts
|
|
18329
18287
|
var import_core16 = require("@anchor-lang/core");
|
|
18330
18288
|
var import_spl_token16 = require("@solana/spl-token");
|
|
18331
|
-
var
|
|
18332
|
-
var
|
|
18289
|
+
var import_web321 = require("@solana/web3.js");
|
|
18290
|
+
var import_common40 = __toESM(require_dist());
|
|
18333
18291
|
var ManagerRedepositAssetBuilder = class extends VaultBuilderBase {
|
|
18334
18292
|
async getIx(args) {
|
|
18335
18293
|
return this.program.methods.managerRedepositAsset({
|
|
18336
18294
|
depositAmount: args.depositAmount,
|
|
18337
18295
|
externalAmount: args.externalAmount
|
|
18338
18296
|
}).accountsPartial({
|
|
18339
|
-
manager: (0,
|
|
18340
|
-
vault: (0,
|
|
18341
|
-
assetMint: (0,
|
|
18342
|
-
vaultAssetAta: (0,
|
|
18343
|
-
managerAssetAta: (0,
|
|
18344
|
-
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),
|
|
18345
18303
|
associatedTokenProgram: import_spl_token16.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
18346
|
-
systemProgram:
|
|
18347
|
-
}).instruction().then(
|
|
18304
|
+
systemProgram: import_web321.SystemProgram.programId
|
|
18305
|
+
}).instruction().then(import_common40.toKitInstruction);
|
|
18348
18306
|
}
|
|
18349
18307
|
async deriveIxArgs(txArgs) {
|
|
18350
18308
|
const connection = this.program.provider.connection;
|
|
@@ -18361,7 +18319,7 @@ var ManagerRedepositAssetBuilder = class extends VaultBuilderBase {
|
|
|
18361
18319
|
depositAmount: new import_core16.BN(txArgs.depositAmount.toString()),
|
|
18362
18320
|
externalAmount: new import_core16.BN(externalAmount.toString()),
|
|
18363
18321
|
assetTokenProgram,
|
|
18364
|
-
vaultAssetAta: (0,
|
|
18322
|
+
vaultAssetAta: (0, import_common40.getAtaAddress)(
|
|
18365
18323
|
txArgs.assetMint,
|
|
18366
18324
|
txArgs.vault,
|
|
18367
18325
|
assetTokenProgram,
|
|
@@ -18369,7 +18327,7 @@ var ManagerRedepositAssetBuilder = class extends VaultBuilderBase {
|
|
|
18369
18327
|
),
|
|
18370
18328
|
// The manager may be a PDA (e.g. a Squads vault), so allow off-curve
|
|
18371
18329
|
// owners when deriving its ATA.
|
|
18372
|
-
managerAssetAta: (0,
|
|
18330
|
+
managerAssetAta: (0, import_common40.getAtaAddress)(
|
|
18373
18331
|
txArgs.assetMint,
|
|
18374
18332
|
txArgs.manager,
|
|
18375
18333
|
assetTokenProgram,
|
|
@@ -18387,21 +18345,21 @@ var ManagerRedepositAssetBuilder = class extends VaultBuilderBase {
|
|
|
18387
18345
|
// src/client/builders/managerWithdrawAsset.ts
|
|
18388
18346
|
var import_core17 = require("@anchor-lang/core");
|
|
18389
18347
|
var import_spl_token17 = require("@solana/spl-token");
|
|
18390
|
-
var
|
|
18391
|
-
var
|
|
18348
|
+
var import_web322 = require("@solana/web3.js");
|
|
18349
|
+
var import_common41 = __toESM(require_dist());
|
|
18392
18350
|
var ManagerWithdrawAssetBuilder = class extends VaultBuilderBase {
|
|
18393
18351
|
async getIx(args) {
|
|
18394
18352
|
return this.program.methods.managerWithdrawAsset(args.amount).accountsPartial({
|
|
18395
|
-
manager: (0,
|
|
18396
|
-
vault: (0,
|
|
18397
|
-
assetMint: (0,
|
|
18398
|
-
vaultAssetAta: (0,
|
|
18399
|
-
destination: (0,
|
|
18400
|
-
destinationAssetAta: (0,
|
|
18401
|
-
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),
|
|
18402
18360
|
associatedTokenProgram: import_spl_token17.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
18403
|
-
systemProgram:
|
|
18404
|
-
}).instruction().then(
|
|
18361
|
+
systemProgram: import_web322.SystemProgram.programId
|
|
18362
|
+
}).instruction().then(import_common41.toKitInstruction);
|
|
18405
18363
|
}
|
|
18406
18364
|
async deriveIxArgs(txArgs) {
|
|
18407
18365
|
const connection = this.program.provider.connection;
|
|
@@ -18418,13 +18376,13 @@ var ManagerWithdrawAssetBuilder = class extends VaultBuilderBase {
|
|
|
18418
18376
|
destination,
|
|
18419
18377
|
amount: new import_core17.BN(txArgs.amount.toString()),
|
|
18420
18378
|
assetTokenProgram,
|
|
18421
|
-
vaultAssetAta: (0,
|
|
18379
|
+
vaultAssetAta: (0, import_common41.getAtaAddress)(
|
|
18422
18380
|
txArgs.assetMint,
|
|
18423
18381
|
txArgs.vault,
|
|
18424
18382
|
assetTokenProgram,
|
|
18425
18383
|
true
|
|
18426
18384
|
),
|
|
18427
|
-
destinationAssetAta: (0,
|
|
18385
|
+
destinationAssetAta: (0, import_common41.getAtaAddress)(
|
|
18428
18386
|
txArgs.assetMint,
|
|
18429
18387
|
destination,
|
|
18430
18388
|
assetTokenProgram,
|
|
@@ -18444,8 +18402,8 @@ var ManagerWithdrawAssetBuilder = class extends VaultBuilderBase {
|
|
|
18444
18402
|
var import_core18 = require("@anchor-lang/core");
|
|
18445
18403
|
var import_kit9 = require("@solana/kit");
|
|
18446
18404
|
var import_spl_token18 = require("@solana/spl-token");
|
|
18447
|
-
var
|
|
18448
|
-
var
|
|
18405
|
+
var import_web323 = require("@solana/web3.js");
|
|
18406
|
+
var import_common42 = __toESM(require_dist());
|
|
18449
18407
|
var DEFAULT_PYTH_PRICE_MAX_AGE_SECS = 90n;
|
|
18450
18408
|
function toAssetPriceOracleConfig(args) {
|
|
18451
18409
|
return {
|
|
@@ -18460,12 +18418,12 @@ function toAssetPriceOracleConfig(args) {
|
|
|
18460
18418
|
function toAnchorAssetPriceOracleConfig(config) {
|
|
18461
18419
|
return {
|
|
18462
18420
|
...config,
|
|
18463
|
-
priceOracleAccount: (0,
|
|
18421
|
+
priceOracleAccount: (0, import_common42.toWeb3Pk)(config.priceOracleAccount)
|
|
18464
18422
|
};
|
|
18465
18423
|
}
|
|
18466
18424
|
function toWeb3AccountMeta2(account) {
|
|
18467
18425
|
return {
|
|
18468
|
-
pubkey: new
|
|
18426
|
+
pubkey: new import_web323.PublicKey(account.address),
|
|
18469
18427
|
isWritable: account.role === import_kit9.AccountRole.WRITABLE || account.role === import_kit9.AccountRole.WRITABLE_SIGNER,
|
|
18470
18428
|
isSigner: account.role === import_kit9.AccountRole.READONLY_SIGNER || account.role === import_kit9.AccountRole.WRITABLE_SIGNER
|
|
18471
18429
|
};
|
|
@@ -18474,14 +18432,14 @@ var ProtocolInteractionBuilder = class extends VaultBuilderBase {
|
|
|
18474
18432
|
async getIx(args) {
|
|
18475
18433
|
return this.program.methods.protocolInteraction(args.refs, {
|
|
18476
18434
|
externalLiquidityIndex: args.externalLiquidityIndex,
|
|
18477
|
-
affectedAssetMint: args.affectedAssetMint ? (0,
|
|
18435
|
+
affectedAssetMint: args.affectedAssetMint ? (0, import_common42.toWeb3Pk)(args.affectedAssetMint) : null
|
|
18478
18436
|
}).accountsPartial({
|
|
18479
|
-
hwManager: (0,
|
|
18480
|
-
vault: (0,
|
|
18481
|
-
affectedAssetMint: args.affectedAssetMint ? (0,
|
|
18482
|
-
affectedVaultAta: args.affectedVaultAta ? (0,
|
|
18483
|
-
affectedTokenProgram: args.affectedTokenProgram ? (0,
|
|
18484
|
-
}).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);
|
|
18485
18443
|
}
|
|
18486
18444
|
async deriveIxArgs(txArgs) {
|
|
18487
18445
|
const affectedTokenProgram = txArgs.affectedAssetMint ? txArgs.affectedTokenProgram ?? TOKEN_PROGRAM_ID : null;
|
|
@@ -18493,7 +18451,7 @@ var ProtocolInteractionBuilder = class extends VaultBuilderBase {
|
|
|
18493
18451
|
accounts: txArgs.accounts,
|
|
18494
18452
|
affectedAssetMint: txArgs.affectedAssetMint ?? null,
|
|
18495
18453
|
affectedTokenProgram,
|
|
18496
|
-
affectedVaultAta: txArgs.affectedAssetMint && affectedTokenProgram ? (0,
|
|
18454
|
+
affectedVaultAta: txArgs.affectedAssetMint && affectedTokenProgram ? (0, import_common42.getAtaAddress)(
|
|
18497
18455
|
txArgs.affectedAssetMint,
|
|
18498
18456
|
txArgs.vault,
|
|
18499
18457
|
affectedTokenProgram,
|
|
@@ -18504,9 +18462,6 @@ var ProtocolInteractionBuilder = class extends VaultBuilderBase {
|
|
|
18504
18462
|
async buildLookupTables(args, txArgs) {
|
|
18505
18463
|
return externalWithdrawLookupTables(args.refs, txArgs.lookupTables);
|
|
18506
18464
|
}
|
|
18507
|
-
async buildPreambleInstructions(args) {
|
|
18508
|
-
return externalWithdrawComputeBudget(args.refs);
|
|
18509
|
-
}
|
|
18510
18465
|
};
|
|
18511
18466
|
var JupiterSwapBuilder = class extends VaultBuilderBase {
|
|
18512
18467
|
async getIx(args) {
|
|
@@ -18515,18 +18470,18 @@ var JupiterSwapBuilder = class extends VaultBuilderBase {
|
|
|
18515
18470
|
args.destinationPriceOracle
|
|
18516
18471
|
)
|
|
18517
18472
|
}).accountsPartial({
|
|
18518
|
-
hwManager: (0,
|
|
18519
|
-
vault: (0,
|
|
18520
|
-
sourceMint: (0,
|
|
18521
|
-
destinationMint: (0,
|
|
18522
|
-
vaultSourceAta: (0,
|
|
18523
|
-
vaultDestinationAta: (0,
|
|
18524
|
-
sourceTokenProgram: (0,
|
|
18525
|
-
destinationTokenProgram: (0,
|
|
18526
|
-
destinationOracleAccount: args.destinationOracleAccount ? (0,
|
|
18527
|
-
vaultOracle: (0,
|
|
18528
|
-
vaultTrancheState: args.vaultTrancheState ? (0,
|
|
18529
|
-
}).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);
|
|
18530
18485
|
}
|
|
18531
18486
|
async deriveIxArgs(txArgs) {
|
|
18532
18487
|
const sourceTokenProgram = txArgs.sourceTokenProgram ?? TOKEN_PROGRAM_ID;
|
|
@@ -18547,13 +18502,13 @@ var JupiterSwapBuilder = class extends VaultBuilderBase {
|
|
|
18547
18502
|
accounts: txArgs.accounts,
|
|
18548
18503
|
sourceTokenProgram,
|
|
18549
18504
|
destinationTokenProgram,
|
|
18550
|
-
vaultSourceAta: (0,
|
|
18505
|
+
vaultSourceAta: (0, import_common42.getAtaAddress)(
|
|
18551
18506
|
txArgs.sourceMint,
|
|
18552
18507
|
txArgs.vault,
|
|
18553
18508
|
sourceTokenProgram,
|
|
18554
18509
|
true
|
|
18555
18510
|
),
|
|
18556
|
-
vaultDestinationAta: (0,
|
|
18511
|
+
vaultDestinationAta: (0, import_common42.getAtaAddress)(
|
|
18557
18512
|
txArgs.destinationMint,
|
|
18558
18513
|
txArgs.vault,
|
|
18559
18514
|
destinationTokenProgram,
|
|
@@ -18562,24 +18517,24 @@ var JupiterSwapBuilder = class extends VaultBuilderBase {
|
|
|
18562
18517
|
};
|
|
18563
18518
|
}
|
|
18564
18519
|
async buildPreambleInstructions(args) {
|
|
18565
|
-
const payer = (0,
|
|
18520
|
+
const payer = (0, import_common42.toWeb3Pk)(args.hwManager);
|
|
18566
18521
|
const createSourceAta = (0, import_spl_token18.createAssociatedTokenAccountIdempotentInstruction)(
|
|
18567
18522
|
payer,
|
|
18568
|
-
(0,
|
|
18569
|
-
(0,
|
|
18570
|
-
(0,
|
|
18571
|
-
(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),
|
|
18572
18527
|
import_spl_token18.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
18573
18528
|
);
|
|
18574
18529
|
const createDestinationAta = (0, import_spl_token18.createAssociatedTokenAccountIdempotentInstruction)(
|
|
18575
18530
|
payer,
|
|
18576
|
-
(0,
|
|
18577
|
-
(0,
|
|
18578
|
-
(0,
|
|
18579
|
-
(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),
|
|
18580
18535
|
import_spl_token18.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
18581
18536
|
);
|
|
18582
|
-
return [createSourceAta, createDestinationAta].map(
|
|
18537
|
+
return [createSourceAta, createDestinationAta].map(import_common42.toKitInstruction);
|
|
18583
18538
|
}
|
|
18584
18539
|
async buildLookupTables(_args, txArgs) {
|
|
18585
18540
|
return txArgs.lookupTables;
|
|
@@ -18614,25 +18569,25 @@ var JupiterSwapBuilder = class extends VaultBuilderBase {
|
|
|
18614
18569
|
// src/client/builders/requestJuniorTrancheWithdraw.ts
|
|
18615
18570
|
var import_core19 = require("@anchor-lang/core");
|
|
18616
18571
|
var import_spl_token19 = require("@solana/spl-token");
|
|
18617
|
-
var
|
|
18618
|
-
var
|
|
18572
|
+
var import_web324 = require("@solana/web3.js");
|
|
18573
|
+
var import_common43 = __toESM(require_dist());
|
|
18619
18574
|
var RequestJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
18620
18575
|
async getIx(args) {
|
|
18621
18576
|
return this.program.methods.requestJuniorTrancheWithdraw(args.queueId, args.shareAmount).accountsPartial({
|
|
18622
|
-
user: (0,
|
|
18623
|
-
payer: (0,
|
|
18624
|
-
vault: (0,
|
|
18625
|
-
vaultOracle: (0,
|
|
18626
|
-
vaultTrancheState: (0,
|
|
18627
|
-
withdrawalQueue: (0,
|
|
18628
|
-
outputMint: (0,
|
|
18629
|
-
inputMint: (0,
|
|
18630
|
-
userInputAta: (0,
|
|
18631
|
-
queueInputAta: (0,
|
|
18632
|
-
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),
|
|
18633
18588
|
associatedTokenProgram: import_spl_token19.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
18634
|
-
systemProgram:
|
|
18635
|
-
}).instruction().then(
|
|
18589
|
+
systemProgram: import_web324.SystemProgram.programId
|
|
18590
|
+
}).instruction().then(import_common43.toKitInstruction);
|
|
18636
18591
|
}
|
|
18637
18592
|
async deriveIxArgs(txArgs) {
|
|
18638
18593
|
const payer = txArgs.payer ?? txArgs.user;
|
|
@@ -18668,8 +18623,8 @@ var RequestJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
18668
18623
|
queueId: txArgs.queueId,
|
|
18669
18624
|
shareAmount: new import_core19.BN(txArgs.shareAmount.toString()),
|
|
18670
18625
|
shareTokenProgram,
|
|
18671
|
-
userInputAta: txArgs.userInputAta ?? (0,
|
|
18672
|
-
queueInputAta: (0,
|
|
18626
|
+
userInputAta: txArgs.userInputAta ?? (0, import_common43.getAtaAddress)(juniorShareMint, txArgs.user, shareTokenProgram),
|
|
18627
|
+
queueInputAta: (0, import_common43.getAtaAddress)(
|
|
18673
18628
|
juniorShareMint,
|
|
18674
18629
|
queuePda,
|
|
18675
18630
|
shareTokenProgram,
|
|
@@ -18693,8 +18648,8 @@ var RequestJuniorTrancheWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
18693
18648
|
// src/client/builders/vaultReallocation.ts
|
|
18694
18649
|
var import_core20 = require("@anchor-lang/core");
|
|
18695
18650
|
var import_spl_token20 = require("@solana/spl-token");
|
|
18696
|
-
var
|
|
18697
|
-
var
|
|
18651
|
+
var import_web325 = require("@solana/web3.js");
|
|
18652
|
+
var import_common44 = __toESM(require_dist());
|
|
18698
18653
|
var DEFAULT_PYTH_PRICE_MAX_AGE_SECS2 = 90n;
|
|
18699
18654
|
function toAssetPriceOracleConfig2(args) {
|
|
18700
18655
|
return {
|
|
@@ -18709,7 +18664,7 @@ function toAssetPriceOracleConfig2(args) {
|
|
|
18709
18664
|
function toAnchorAssetPriceOracleConfig2(config) {
|
|
18710
18665
|
return {
|
|
18711
18666
|
...config,
|
|
18712
|
-
priceOracleAccount: (0,
|
|
18667
|
+
priceOracleAccount: (0, import_common44.toWeb3Pk)(config.priceOracleAccount)
|
|
18713
18668
|
};
|
|
18714
18669
|
}
|
|
18715
18670
|
var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
@@ -18718,35 +18673,35 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
18718
18673
|
amount: args.amount,
|
|
18719
18674
|
assetPriceOracle: toAnchorAssetPriceOracleConfig2(args.assetPriceOracle)
|
|
18720
18675
|
}).accountsPartial({
|
|
18721
|
-
manager: (0,
|
|
18722
|
-
allocationVault: (0,
|
|
18723
|
-
sourceVault: args.sourceVault ? (0,
|
|
18724
|
-
sourceVaultOracle: args.sourceVaultOracle ? (0,
|
|
18725
|
-
destinationVault: (0,
|
|
18726
|
-
destinationVaultOracle: (0,
|
|
18727
|
-
mint: (0,
|
|
18728
|
-
sourceShareMint: args.sourceShareMint ? (0,
|
|
18729
|
-
destinationShareMint: (0,
|
|
18730
|
-
allocationMintAta: (0,
|
|
18731
|
-
sourceVaultMintAta: args.sourceVaultMintAta ? (0,
|
|
18732
|
-
destinationVaultMintAta: (0,
|
|
18733
|
-
destinationFeeVault: (0,
|
|
18734
|
-
destinationFeeVaultMintAta: (0,
|
|
18735
|
-
allocationSourceShareAta: args.allocationSourceShareAta ? (0,
|
|
18736
|
-
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)(
|
|
18737
18692
|
args.allocationDestinationShareAta
|
|
18738
18693
|
),
|
|
18739
|
-
sourceVaultTrancheState: args.sourceVaultTrancheState ? (0,
|
|
18740
|
-
destinationVaultTrancheState: args.destinationVaultTrancheState ? (0,
|
|
18741
|
-
assetOracleAccount: args.assetOracleAccount ? (0,
|
|
18742
|
-
assetTokenProgram: (0,
|
|
18743
|
-
sourceShareTokenProgram: (0,
|
|
18744
|
-
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)(
|
|
18745
18700
|
args.destinationShareTokenProgram
|
|
18746
18701
|
),
|
|
18747
18702
|
associatedTokenProgram: import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
18748
|
-
systemProgram:
|
|
18749
|
-
}).instruction().then(
|
|
18703
|
+
systemProgram: import_web325.SystemProgram.programId
|
|
18704
|
+
}).instruction().then(import_common44.toKitInstruction);
|
|
18750
18705
|
}
|
|
18751
18706
|
async deriveIxArgs(txArgs) {
|
|
18752
18707
|
const assetTokenProgram = txArgs.assetTokenProgram ?? TOKEN_PROGRAM_ID;
|
|
@@ -18779,33 +18734,33 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
18779
18734
|
assetTokenProgram,
|
|
18780
18735
|
sourceShareTokenProgram,
|
|
18781
18736
|
destinationShareTokenProgram,
|
|
18782
|
-
allocationMintAta: (0,
|
|
18737
|
+
allocationMintAta: (0, import_common44.getAtaAddress)(
|
|
18783
18738
|
txArgs.mint,
|
|
18784
18739
|
txArgs.allocationVault,
|
|
18785
18740
|
assetTokenProgram,
|
|
18786
18741
|
true
|
|
18787
18742
|
),
|
|
18788
|
-
sourceVaultMintAta: sourceVault ? (0,
|
|
18789
|
-
destinationVaultMintAta: (0,
|
|
18743
|
+
sourceVaultMintAta: sourceVault ? (0, import_common44.getAtaAddress)(txArgs.mint, sourceVault, assetTokenProgram, true) : null,
|
|
18744
|
+
destinationVaultMintAta: (0, import_common44.getAtaAddress)(
|
|
18790
18745
|
txArgs.mint,
|
|
18791
18746
|
txArgs.destinationVault,
|
|
18792
18747
|
assetTokenProgram,
|
|
18793
18748
|
true
|
|
18794
18749
|
),
|
|
18795
18750
|
destinationFeeVault,
|
|
18796
|
-
destinationFeeVaultMintAta: (0,
|
|
18751
|
+
destinationFeeVaultMintAta: (0, import_common44.getAtaAddress)(
|
|
18797
18752
|
txArgs.mint,
|
|
18798
18753
|
destinationFeeVault,
|
|
18799
18754
|
assetTokenProgram,
|
|
18800
18755
|
true
|
|
18801
18756
|
),
|
|
18802
|
-
allocationSourceShareAta: sourceShareMint && sourceVault ? (0,
|
|
18757
|
+
allocationSourceShareAta: sourceShareMint && sourceVault ? (0, import_common44.getAtaAddress)(
|
|
18803
18758
|
sourceShareMint,
|
|
18804
18759
|
txArgs.allocationVault,
|
|
18805
18760
|
sourceShareTokenProgram,
|
|
18806
18761
|
true
|
|
18807
18762
|
) : null,
|
|
18808
|
-
allocationDestinationShareAta: (0,
|
|
18763
|
+
allocationDestinationShareAta: (0, import_common44.getAtaAddress)(
|
|
18809
18764
|
txArgs.destinationShareMint,
|
|
18810
18765
|
txArgs.allocationVault,
|
|
18811
18766
|
destinationShareTokenProgram,
|
|
@@ -18814,38 +18769,38 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
18814
18769
|
};
|
|
18815
18770
|
}
|
|
18816
18771
|
async buildPreambleInstructions(args) {
|
|
18817
|
-
const payer = (0,
|
|
18772
|
+
const payer = (0, import_common44.toWeb3Pk)(args.manager);
|
|
18818
18773
|
const instructions2 = [
|
|
18819
18774
|
(0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
|
|
18820
18775
|
payer,
|
|
18821
|
-
(0,
|
|
18822
|
-
(0,
|
|
18823
|
-
(0,
|
|
18824
|
-
(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),
|
|
18825
18780
|
import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
18826
18781
|
),
|
|
18827
18782
|
(0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
|
|
18828
18783
|
payer,
|
|
18829
|
-
(0,
|
|
18830
|
-
(0,
|
|
18831
|
-
(0,
|
|
18832
|
-
(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),
|
|
18833
18788
|
import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
18834
18789
|
),
|
|
18835
18790
|
(0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
|
|
18836
18791
|
payer,
|
|
18837
|
-
(0,
|
|
18838
|
-
(0,
|
|
18839
|
-
(0,
|
|
18840
|
-
(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),
|
|
18841
18796
|
import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
18842
18797
|
),
|
|
18843
18798
|
(0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
|
|
18844
18799
|
payer,
|
|
18845
|
-
(0,
|
|
18846
|
-
(0,
|
|
18847
|
-
(0,
|
|
18848
|
-
(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),
|
|
18849
18804
|
import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
18850
18805
|
)
|
|
18851
18806
|
];
|
|
@@ -18853,23 +18808,23 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
18853
18808
|
instructions2.push(
|
|
18854
18809
|
(0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
|
|
18855
18810
|
payer,
|
|
18856
|
-
(0,
|
|
18857
|
-
(0,
|
|
18858
|
-
(0,
|
|
18859
|
-
(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),
|
|
18860
18815
|
import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
18861
18816
|
),
|
|
18862
18817
|
(0, import_spl_token20.createAssociatedTokenAccountIdempotentInstruction)(
|
|
18863
18818
|
payer,
|
|
18864
|
-
(0,
|
|
18865
|
-
(0,
|
|
18866
|
-
(0,
|
|
18867
|
-
(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),
|
|
18868
18823
|
import_spl_token20.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
18869
18824
|
)
|
|
18870
18825
|
);
|
|
18871
18826
|
}
|
|
18872
|
-
return instructions2.map(
|
|
18827
|
+
return instructions2.map(import_common44.toKitInstruction);
|
|
18873
18828
|
}
|
|
18874
18829
|
async buildPlanExtras(args) {
|
|
18875
18830
|
return {
|
|
@@ -18907,24 +18862,24 @@ var VaultReallocationBuilder = class extends VaultBuilderBase {
|
|
|
18907
18862
|
// src/client/builders/requestAsyncWithdraw.ts
|
|
18908
18863
|
var import_core21 = require("@anchor-lang/core");
|
|
18909
18864
|
var import_spl_token21 = require("@solana/spl-token");
|
|
18910
|
-
var
|
|
18911
|
-
var
|
|
18865
|
+
var import_web326 = require("@solana/web3.js");
|
|
18866
|
+
var import_common45 = __toESM(require_dist());
|
|
18912
18867
|
var RequestAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
18913
18868
|
async getIx(args) {
|
|
18914
18869
|
return this.program.methods.requestAsyncWithdraw(args.queueId, args.shareAmount).accountsPartial({
|
|
18915
|
-
user: (0,
|
|
18916
|
-
payer: (0,
|
|
18917
|
-
vault: (0,
|
|
18918
|
-
vaultOracle: (0,
|
|
18919
|
-
withdrawalQueue: (0,
|
|
18920
|
-
outputMint: (0,
|
|
18921
|
-
inputMint: (0,
|
|
18922
|
-
userInputAta: (0,
|
|
18923
|
-
queueInputAta: (0,
|
|
18924
|
-
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),
|
|
18925
18880
|
associatedTokenProgram: import_spl_token21.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
18926
|
-
systemProgram:
|
|
18927
|
-
}).instruction().then(
|
|
18881
|
+
systemProgram: import_web326.SystemProgram.programId
|
|
18882
|
+
}).instruction().then(import_common45.toKitInstruction);
|
|
18928
18883
|
}
|
|
18929
18884
|
async deriveIxArgs(txArgs) {
|
|
18930
18885
|
const payer = txArgs.payer ?? txArgs.user;
|
|
@@ -18942,7 +18897,7 @@ var RequestAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
18942
18897
|
),
|
|
18943
18898
|
this.account.fetchVault(txArgs.vault)
|
|
18944
18899
|
]);
|
|
18945
|
-
const shareMint = txArgs.shareMint ?? (0,
|
|
18900
|
+
const shareMint = txArgs.shareMint ?? (0, import_common45.fromWeb3Pk)(vaultData.mint);
|
|
18946
18901
|
const queuePda = txArgs.withdrawalQueue ?? withdrawalQueue;
|
|
18947
18902
|
return {
|
|
18948
18903
|
user: txArgs.user,
|
|
@@ -18955,8 +18910,8 @@ var RequestAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
18955
18910
|
queueId: txArgs.queueId,
|
|
18956
18911
|
shareAmount: new import_core21.BN(txArgs.shareAmount.toString()),
|
|
18957
18912
|
shareTokenProgram,
|
|
18958
|
-
userInputAta: txArgs.userInputAta ?? (0,
|
|
18959
|
-
queueInputAta: (0,
|
|
18913
|
+
userInputAta: txArgs.userInputAta ?? (0, import_common45.getAtaAddress)(shareMint, txArgs.user, shareTokenProgram, true),
|
|
18914
|
+
queueInputAta: (0, import_common45.getAtaAddress)(
|
|
18960
18915
|
shareMint,
|
|
18961
18916
|
queuePda,
|
|
18962
18917
|
shareTokenProgram,
|
|
@@ -18978,8 +18933,8 @@ var RequestAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
18978
18933
|
|
|
18979
18934
|
// src/client/builders/fulfillAsyncWithdraw.ts
|
|
18980
18935
|
var import_spl_token22 = require("@solana/spl-token");
|
|
18981
|
-
var
|
|
18982
|
-
var
|
|
18936
|
+
var import_web327 = require("@solana/web3.js");
|
|
18937
|
+
var import_common46 = __toESM(require_dist());
|
|
18983
18938
|
var FulfillAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
18984
18939
|
async getIx(args) {
|
|
18985
18940
|
const externalWithdrawIxRefs = args.externalWithdrawIxRefs ?? null;
|
|
@@ -18989,24 +18944,24 @@ var FulfillAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
18989
18944
|
externalLiquiditySource
|
|
18990
18945
|
);
|
|
18991
18946
|
return methods.accountsPartial({
|
|
18992
|
-
signer: (0,
|
|
18993
|
-
owner: (0,
|
|
18994
|
-
queuePayer: (0,
|
|
18995
|
-
vault: (0,
|
|
18996
|
-
vaultOracle: (0,
|
|
18997
|
-
vaultTrancheState: args.vaultTrancheState ? (0,
|
|
18998
|
-
withdrawalQueue: (0,
|
|
18999
|
-
outputMint: (0,
|
|
19000
|
-
inputMint: (0,
|
|
19001
|
-
ownerInputAta: (0,
|
|
19002
|
-
ownerOutputAta: (0,
|
|
19003
|
-
vaultOutputAta: (0,
|
|
19004
|
-
queueInputAta: (0,
|
|
19005
|
-
assetTokenProgram: (0,
|
|
19006
|
-
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),
|
|
19007
18962
|
associatedTokenProgram: import_spl_token22.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
19008
|
-
systemProgram:
|
|
19009
|
-
}).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(
|
|
18963
|
+
systemProgram: import_web327.SystemProgram.programId
|
|
18964
|
+
}).remainingAccounts(args.externalWithdrawAccounts.map(toWeb3AccountMeta)).instruction().then(import_common46.toKitInstruction);
|
|
19010
18965
|
}
|
|
19011
18966
|
async deriveIxArgs(txArgs) {
|
|
19012
18967
|
const connection = this.program.provider.connection;
|
|
@@ -19045,13 +19000,13 @@ var FulfillAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
19045
19000
|
),
|
|
19046
19001
|
this.account.fetchVault(txArgs.vault, { fresh: true })
|
|
19047
19002
|
]);
|
|
19048
|
-
const shareMint = txArgs.shareMint ?? (0,
|
|
19003
|
+
const shareMint = txArgs.shareMint ?? (0, import_common46.fromWeb3Pk)(vaultData.mint);
|
|
19049
19004
|
const queuePda = txArgs.withdrawalQueue ?? withdrawalQueue;
|
|
19050
19005
|
const queue = await this.account.fetchVaultWithdrawalQueue(queuePda, {
|
|
19051
19006
|
fresh: true
|
|
19052
19007
|
});
|
|
19053
|
-
const queuePayer = txArgs.queuePayer ?? (0,
|
|
19054
|
-
const vaultOutputAta = (0,
|
|
19008
|
+
const queuePayer = txArgs.queuePayer ?? (0, import_common46.fromWeb3Pk)(queue.parties.payer);
|
|
19009
|
+
const vaultOutputAta = (0, import_common46.getAtaAddress)(
|
|
19055
19010
|
txArgs.assetMint,
|
|
19056
19011
|
txArgs.vault,
|
|
19057
19012
|
assetTokenProgram,
|
|
@@ -19070,7 +19025,7 @@ var FulfillAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
19070
19025
|
skipExternalLiquidity = localAmount >= BigInt(queue.request.outputAmount.toString());
|
|
19071
19026
|
} else {
|
|
19072
19027
|
const holding = vaultData.holdings.find(
|
|
19073
|
-
(h) => (0,
|
|
19028
|
+
(h) => (0, import_common46.fromWeb3Pk)(h.mint) === txArgs.assetMint
|
|
19074
19029
|
);
|
|
19075
19030
|
if (!holding)
|
|
19076
19031
|
throw new Error("Withdrawal asset is not a vault holding");
|
|
@@ -19088,7 +19043,7 @@ var FulfillAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
19088
19043
|
decimals: holding.decimals,
|
|
19089
19044
|
// The queue owner receives the exemption, not the fulfiller.
|
|
19090
19045
|
feeBps: WALLET_FEE_EXEMPT_WHITELIST.includes(
|
|
19091
|
-
(0,
|
|
19046
|
+
(0, import_common46.fromWeb3Pk)(queue.parties.owner)
|
|
19092
19047
|
) ? 0 : vaultData.config.fees.burnFeeBps
|
|
19093
19048
|
},
|
|
19094
19049
|
BigInt(queue.request.inputAmount.toString())
|
|
@@ -19124,15 +19079,15 @@ var FulfillAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
19124
19079
|
inputMint: shareMint,
|
|
19125
19080
|
assetTokenProgram,
|
|
19126
19081
|
shareTokenProgram,
|
|
19127
|
-
ownerInputAta: txArgs.ownerInputAta ?? (0,
|
|
19128
|
-
ownerOutputAta: (0,
|
|
19082
|
+
ownerInputAta: txArgs.ownerInputAta ?? (0, import_common46.getAtaAddress)(shareMint, txArgs.owner, shareTokenProgram, true),
|
|
19083
|
+
ownerOutputAta: (0, import_common46.getAtaAddress)(
|
|
19129
19084
|
txArgs.assetMint,
|
|
19130
19085
|
txArgs.owner,
|
|
19131
19086
|
assetTokenProgram,
|
|
19132
19087
|
true
|
|
19133
19088
|
),
|
|
19134
19089
|
vaultOutputAta,
|
|
19135
|
-
queueInputAta: (0,
|
|
19090
|
+
queueInputAta: (0, import_common46.getAtaAddress)(
|
|
19136
19091
|
shareMint,
|
|
19137
19092
|
queuePda,
|
|
19138
19093
|
shareTokenProgram,
|
|
@@ -19150,7 +19105,7 @@ var FulfillAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
19150
19105
|
);
|
|
19151
19106
|
}
|
|
19152
19107
|
async buildPreambleInstructions(args) {
|
|
19153
|
-
const defaultOwnerInputAta = (0,
|
|
19108
|
+
const defaultOwnerInputAta = (0, import_common46.getAtaAddress)(
|
|
19154
19109
|
args.inputMint,
|
|
19155
19110
|
args.owner,
|
|
19156
19111
|
args.shareTokenProgram,
|
|
@@ -19163,27 +19118,24 @@ var FulfillAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
19163
19118
|
program: args.assetTokenProgram
|
|
19164
19119
|
}
|
|
19165
19120
|
];
|
|
19166
|
-
if ((0,
|
|
19121
|
+
if ((0, import_common46.toWeb3Pk)(args.ownerInputAta).equals((0, import_common46.toWeb3Pk)(defaultOwnerInputAta))) {
|
|
19167
19122
|
atas.push({
|
|
19168
19123
|
mint: args.inputMint,
|
|
19169
19124
|
ata: args.ownerInputAta,
|
|
19170
19125
|
program: args.shareTokenProgram
|
|
19171
19126
|
});
|
|
19172
19127
|
}
|
|
19173
|
-
return
|
|
19174
|
-
|
|
19175
|
-
|
|
19176
|
-
|
|
19177
|
-
(0,
|
|
19178
|
-
|
|
19179
|
-
|
|
19180
|
-
|
|
19181
|
-
(0, import_common47.toWeb3Pk)(mint),
|
|
19182
|
-
(0, import_common47.toWeb3Pk)(program)
|
|
19183
|
-
)
|
|
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)
|
|
19184
19136
|
)
|
|
19185
19137
|
)
|
|
19186
|
-
|
|
19138
|
+
);
|
|
19187
19139
|
}
|
|
19188
19140
|
async buildPlanExtras(args) {
|
|
19189
19141
|
return {
|
|
@@ -19199,16 +19151,16 @@ var FulfillAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
19199
19151
|
};
|
|
19200
19152
|
|
|
19201
19153
|
// src/client/builders/priceAsyncWithdraw.ts
|
|
19202
|
-
var
|
|
19154
|
+
var import_common47 = __toESM(require_dist());
|
|
19203
19155
|
var PriceAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
19204
19156
|
async getIx(args) {
|
|
19205
19157
|
return this.program.methods.priceAsyncWithdraw().accountsPartial({
|
|
19206
|
-
hwManager: (0,
|
|
19207
|
-
vault: (0,
|
|
19208
|
-
vaultOracle: (0,
|
|
19209
|
-
vaultTrancheState: args.vaultTrancheState ? (0,
|
|
19210
|
-
withdrawalQueue: (0,
|
|
19211
|
-
}).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);
|
|
19212
19164
|
}
|
|
19213
19165
|
async deriveIxArgs(args) {
|
|
19214
19166
|
const [[oracle], tranche] = await Promise.all([
|
|
@@ -19237,22 +19189,22 @@ var PriceAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
19237
19189
|
|
|
19238
19190
|
// src/client/builders/cancelAsyncWithdraw.ts
|
|
19239
19191
|
var import_spl_token23 = require("@solana/spl-token");
|
|
19240
|
-
var
|
|
19241
|
-
var
|
|
19192
|
+
var import_web328 = require("@solana/web3.js");
|
|
19193
|
+
var import_common48 = __toESM(require_dist());
|
|
19242
19194
|
var CancelAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
19243
19195
|
async getIx(args) {
|
|
19244
19196
|
return this.program.methods.cancelAsyncWithdraw().accountsPartial({
|
|
19245
|
-
user: (0,
|
|
19246
|
-
payer: (0,
|
|
19247
|
-
vault: (0,
|
|
19248
|
-
withdrawalQueue: (0,
|
|
19249
|
-
inputMint: (0,
|
|
19250
|
-
userInputAta: (0,
|
|
19251
|
-
queueInputAta: (0,
|
|
19252
|
-
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),
|
|
19253
19205
|
associatedTokenProgram: import_spl_token23.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
19254
|
-
systemProgram:
|
|
19255
|
-
}).instruction().then(
|
|
19206
|
+
systemProgram: import_web328.SystemProgram.programId
|
|
19207
|
+
}).instruction().then(import_common48.toKitInstruction);
|
|
19256
19208
|
}
|
|
19257
19209
|
async deriveIxArgs(args) {
|
|
19258
19210
|
const [[derived], vault] = await Promise.all([
|
|
@@ -19268,7 +19220,7 @@ var CancelAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
19268
19220
|
withdrawalQueue,
|
|
19269
19221
|
{ fresh: true }
|
|
19270
19222
|
);
|
|
19271
|
-
const inputMint = (0,
|
|
19223
|
+
const inputMint = (0, import_common48.fromWeb3Pk)(vault.mint);
|
|
19272
19224
|
const shareTokenProgram = tokenProgramAddressFromIdlEnum(
|
|
19273
19225
|
vault.mintTokenProgram
|
|
19274
19226
|
);
|
|
@@ -19278,9 +19230,9 @@ var CancelAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
19278
19230
|
withdrawalQueue,
|
|
19279
19231
|
inputMint,
|
|
19280
19232
|
shareTokenProgram,
|
|
19281
|
-
payer: (0,
|
|
19282
|
-
userInputAta: args.userInputAta ?? (0,
|
|
19283
|
-
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)(
|
|
19284
19236
|
inputMint,
|
|
19285
19237
|
withdrawalQueue,
|
|
19286
19238
|
shareTokenProgram,
|
|
@@ -19289,7 +19241,7 @@ var CancelAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
19289
19241
|
};
|
|
19290
19242
|
}
|
|
19291
19243
|
async buildPreambleInstructions(args) {
|
|
19292
|
-
const ata = (0,
|
|
19244
|
+
const ata = (0, import_common48.getAtaAddress)(
|
|
19293
19245
|
args.inputMint,
|
|
19294
19246
|
args.user,
|
|
19295
19247
|
args.shareTokenProgram,
|
|
@@ -19297,13 +19249,13 @@ var CancelAsyncWithdrawBuilder = class extends VaultBuilderBase {
|
|
|
19297
19249
|
);
|
|
19298
19250
|
if (ata !== args.userInputAta) return [];
|
|
19299
19251
|
return [
|
|
19300
|
-
(0,
|
|
19252
|
+
(0, import_common48.toKitInstruction)(
|
|
19301
19253
|
(0, import_spl_token23.createAssociatedTokenAccountIdempotentInstruction)(
|
|
19302
|
-
(0,
|
|
19303
|
-
(0,
|
|
19304
|
-
(0,
|
|
19305
|
-
(0,
|
|
19306
|
-
(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)
|
|
19307
19259
|
)
|
|
19308
19260
|
)
|
|
19309
19261
|
];
|
|
@@ -19414,15 +19366,15 @@ var VaultClient = class {
|
|
|
19414
19366
|
this.vaultLookupTables
|
|
19415
19367
|
);
|
|
19416
19368
|
const { blockhash, lastValidBlockHeight } = await this.provider.connection.getLatestBlockhash("confirmed");
|
|
19417
|
-
const instructions2 = plan.instructions.map(
|
|
19369
|
+
const instructions2 = plan.instructions.map(import_common49.fromKitInstruction);
|
|
19418
19370
|
let tx;
|
|
19419
19371
|
if (plan.lookupTables?.length) {
|
|
19420
|
-
const tables = await (0,
|
|
19372
|
+
const tables = await (0, import_common49.fetchLookupTables)(
|
|
19421
19373
|
this.provider.connection,
|
|
19422
19374
|
plan.lookupTables
|
|
19423
19375
|
);
|
|
19424
|
-
tx = new
|
|
19425
|
-
new
|
|
19376
|
+
tx = new import_web329.VersionedTransaction(
|
|
19377
|
+
new import_web329.TransactionMessage({
|
|
19426
19378
|
payerKey: payer.publicKey,
|
|
19427
19379
|
recentBlockhash: blockhash,
|
|
19428
19380
|
instructions: instructions2
|
|
@@ -19430,7 +19382,7 @@ var VaultClient = class {
|
|
|
19430
19382
|
);
|
|
19431
19383
|
tx.sign([payer, ...extraSigners]);
|
|
19432
19384
|
} else {
|
|
19433
|
-
tx = new
|
|
19385
|
+
tx = new import_web329.Transaction().add(...instructions2);
|
|
19434
19386
|
tx.feePayer = payer.publicKey;
|
|
19435
19387
|
tx.recentBlockhash = blockhash;
|
|
19436
19388
|
tx.sign(payer, ...extraSigners);
|
|
@@ -19469,13 +19421,13 @@ var VaultClient = class {
|
|
|
19469
19421
|
const { blockhash } = await this.provider.connection.getLatestBlockhash(
|
|
19470
19422
|
"confirmed"
|
|
19471
19423
|
);
|
|
19472
|
-
const lookupTableAccounts = plan.lookupTables?.length ? await (0,
|
|
19473
|
-
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({
|
|
19474
19426
|
payerKey: payer.publicKey,
|
|
19475
19427
|
recentBlockhash: blockhash,
|
|
19476
|
-
instructions: plan.instructions.map(
|
|
19428
|
+
instructions: plan.instructions.map(import_common49.fromKitInstruction)
|
|
19477
19429
|
}).compileToV0Message(lookupTableAccounts);
|
|
19478
|
-
const tx = new
|
|
19430
|
+
const tx = new import_web329.VersionedTransaction(message2);
|
|
19479
19431
|
const result = await this.provider.connection.simulateTransaction(tx, {
|
|
19480
19432
|
sigVerify: false,
|
|
19481
19433
|
commitment: "processed"
|
|
@@ -19549,7 +19501,7 @@ function resolveKeypairPath(keypairPath) {
|
|
|
19549
19501
|
}
|
|
19550
19502
|
function loadKeypair(keypairPath) {
|
|
19551
19503
|
const raw = import_fs.default.readFileSync(resolveKeypairPath(keypairPath), "utf-8");
|
|
19552
|
-
return
|
|
19504
|
+
return import_web330.Keypair.fromSecretKey(new Uint8Array(JSON.parse(raw)));
|
|
19553
19505
|
}
|
|
19554
19506
|
var ENV_AGNOSTIC_ROLES = /* @__PURE__ */ new Set(["fulfiller", "rebalancer"]);
|
|
19555
19507
|
function defaultKeypairPath(env, role = "vault") {
|
|
@@ -19560,7 +19512,7 @@ function defaultKeypairPath(env, role = "vault") {
|
|
|
19560
19512
|
}
|
|
19561
19513
|
function createVaultClient(env, opts = {}) {
|
|
19562
19514
|
const payer = opts.keypair ?? loadKeypair(opts.keypairPath ?? defaultKeypairPath(env, opts.role));
|
|
19563
|
-
const connection = new
|
|
19515
|
+
const connection = new import_web330.Connection(opts.rpcUrl ?? getRpcUrl(env), "confirmed");
|
|
19564
19516
|
const provider = new import_core23.AnchorProvider(connection, new import_core23.Wallet(payer), {
|
|
19565
19517
|
commitment: "confirmed"
|
|
19566
19518
|
});
|
|
@@ -19577,11 +19529,11 @@ function createVaultClient(env, opts = {}) {
|
|
|
19577
19529
|
client,
|
|
19578
19530
|
provider,
|
|
19579
19531
|
payer,
|
|
19580
|
-
signer: (0,
|
|
19532
|
+
signer: (0, import_common50.fromWeb3Pk)(payer.publicKey)
|
|
19581
19533
|
};
|
|
19582
19534
|
}
|
|
19583
19535
|
function keypairAddress(keypairPath) {
|
|
19584
|
-
return (0,
|
|
19536
|
+
return (0, import_common50.fromWeb3Pk)(loadKeypair(keypairPath).publicKey);
|
|
19585
19537
|
}
|
|
19586
19538
|
|
|
19587
19539
|
// src/utils/math.ts
|
|
@@ -19604,7 +19556,7 @@ function makeProvider(connection, payer) {
|
|
|
19604
19556
|
|
|
19605
19557
|
// src/utils/squads.ts
|
|
19606
19558
|
var squads = __toESM(require("@sqds/multisig"));
|
|
19607
|
-
var
|
|
19559
|
+
var import_web331 = require("@solana/web3.js");
|
|
19608
19560
|
var SQUADS_SIMULATION_COMMITMENT = "processed";
|
|
19609
19561
|
var SquadsProposalExecutionSimulationError = class extends Error {
|
|
19610
19562
|
constructor(transactionError, logs, unitsConsumed) {
|
|
@@ -19628,8 +19580,8 @@ function validateVaultIndex(vaultIndex) {
|
|
|
19628
19580
|
}
|
|
19629
19581
|
function resolveSquadsWalletRoute(route) {
|
|
19630
19582
|
validateVaultIndex(route.vaultIndex);
|
|
19631
|
-
const wallet = new
|
|
19632
|
-
const multisigPda = new
|
|
19583
|
+
const wallet = new import_web331.PublicKey(route.wallet);
|
|
19584
|
+
const multisigPda = new import_web331.PublicKey(route.multisigPda);
|
|
19633
19585
|
const [vaultPda] = squads.getVaultPda({
|
|
19634
19586
|
multisigPda,
|
|
19635
19587
|
index: route.vaultIndex
|
|
@@ -19637,7 +19589,7 @@ function resolveSquadsWalletRoute(route) {
|
|
|
19637
19589
|
return { ...route, wallet, multisigPda, vaultPda };
|
|
19638
19590
|
}
|
|
19639
19591
|
function findSquadsWalletRoute(wallet, routes) {
|
|
19640
|
-
const walletKey = typeof wallet === "string" ? new
|
|
19592
|
+
const walletKey = typeof wallet === "string" ? new import_web331.PublicKey(wallet) : wallet;
|
|
19641
19593
|
const route = routes.find(
|
|
19642
19594
|
(candidate) => candidate.wallet === walletKey.toBase58()
|
|
19643
19595
|
);
|
|
@@ -19655,18 +19607,18 @@ function validateSquadsWalletRoutes(routes) {
|
|
|
19655
19607
|
}
|
|
19656
19608
|
}
|
|
19657
19609
|
function vaultAuthorityForWallet(wallet, routes) {
|
|
19658
|
-
const walletKey = typeof wallet === "string" ? new
|
|
19610
|
+
const walletKey = typeof wallet === "string" ? new import_web331.PublicKey(wallet) : wallet;
|
|
19659
19611
|
return findSquadsWalletRoute(walletKey, routes)?.vaultPda ?? walletKey;
|
|
19660
19612
|
}
|
|
19661
19613
|
async function simulateSquadsProposalExecution(args) {
|
|
19662
19614
|
const { connection, feePayer, instructions: instructions2 } = args;
|
|
19663
19615
|
const recentBlockhash = args.recentBlockhash ?? (await connection.getLatestBlockhash(SQUADS_SIMULATION_COMMITMENT)).blockhash;
|
|
19664
|
-
const message2 = new
|
|
19616
|
+
const message2 = new import_web331.TransactionMessage({
|
|
19665
19617
|
payerKey: feePayer,
|
|
19666
19618
|
recentBlockhash,
|
|
19667
19619
|
instructions: [...instructions2]
|
|
19668
19620
|
}).compileToV0Message(args.addressLookupTableAccounts);
|
|
19669
|
-
const transaction = new
|
|
19621
|
+
const transaction = new import_web331.VersionedTransaction(message2);
|
|
19670
19622
|
const { value } = await connection.simulateTransaction(transaction, {
|
|
19671
19623
|
sigVerify: false,
|
|
19672
19624
|
commitment: SQUADS_SIMULATION_COMMITMENT,
|
|
@@ -19691,7 +19643,7 @@ async function prepareVaultTransaction(args) {
|
|
|
19691
19643
|
throw new Error("Ephemeral signers require a Squads route");
|
|
19692
19644
|
return {
|
|
19693
19645
|
kind: "direct",
|
|
19694
|
-
transaction: new
|
|
19646
|
+
transaction: new import_web331.Transaction().add(...instructions2),
|
|
19695
19647
|
authority: proposer
|
|
19696
19648
|
};
|
|
19697
19649
|
}
|
|
@@ -19744,7 +19696,7 @@ async function prepareVaultTransaction(args) {
|
|
|
19744
19696
|
});
|
|
19745
19697
|
if (replacements.size) {
|
|
19746
19698
|
instructions2 = instructions2.map(
|
|
19747
|
-
(ix) => new
|
|
19699
|
+
(ix) => new import_web331.TransactionInstruction({
|
|
19748
19700
|
programId: ix.programId,
|
|
19749
19701
|
data: ix.data,
|
|
19750
19702
|
keys: ix.keys.map((meta) => ({
|
|
@@ -19772,7 +19724,7 @@ async function prepareVaultTransaction(args) {
|
|
|
19772
19724
|
executionSimulationError = error;
|
|
19773
19725
|
}
|
|
19774
19726
|
}
|
|
19775
|
-
const transactionMessage = new
|
|
19727
|
+
const transactionMessage = new import_web331.TransactionMessage({
|
|
19776
19728
|
payerKey: route.vaultPda,
|
|
19777
19729
|
recentBlockhash: blockhash,
|
|
19778
19730
|
instructions: [...instructions2]
|
|
@@ -19802,7 +19754,7 @@ async function prepareVaultTransaction(args) {
|
|
|
19802
19754
|
});
|
|
19803
19755
|
return {
|
|
19804
19756
|
kind: "squads",
|
|
19805
|
-
transaction: new
|
|
19757
|
+
transaction: new import_web331.Transaction().add(
|
|
19806
19758
|
createVaultTransactionIx,
|
|
19807
19759
|
createProposalIx
|
|
19808
19760
|
),
|
|
@@ -19818,16 +19770,16 @@ async function prepareVaultTransaction(args) {
|
|
|
19818
19770
|
|
|
19819
19771
|
// src/utils/squadsBuffer.ts
|
|
19820
19772
|
var squads2 = __toESM(require("@sqds/multisig"));
|
|
19821
|
-
var
|
|
19773
|
+
var import_web332 = require("@solana/web3.js");
|
|
19822
19774
|
var PacketSize = 1232;
|
|
19823
19775
|
var BufferChunkSize = 700;
|
|
19824
19776
|
var MaxBufferSize = 4e3;
|
|
19825
19777
|
async function prepareSquadsProposalUpload(args) {
|
|
19826
19778
|
const { connection, proposer, prepared } = args;
|
|
19827
19779
|
const transaction = prepared.transaction;
|
|
19828
|
-
const sizeProbe = new
|
|
19780
|
+
const sizeProbe = new import_web332.Transaction({
|
|
19829
19781
|
feePayer: proposer,
|
|
19830
|
-
recentBlockhash:
|
|
19782
|
+
recentBlockhash: import_web332.PublicKey.default.toBase58()
|
|
19831
19783
|
}).add(...transaction.instructions);
|
|
19832
19784
|
let fits = false;
|
|
19833
19785
|
try {
|
|
@@ -19847,7 +19799,7 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
19847
19799
|
let bufferPda;
|
|
19848
19800
|
let bufferIndex = 0;
|
|
19849
19801
|
for (; bufferIndex <= 255; bufferIndex++) {
|
|
19850
|
-
const [candidate] =
|
|
19802
|
+
const [candidate] = import_web332.PublicKey.findProgramAddressSync(
|
|
19851
19803
|
[
|
|
19852
19804
|
Buffer.from("multisig"),
|
|
19853
19805
|
prepared.multisigPda.toBuffer(),
|
|
@@ -19875,7 +19827,7 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
19875
19827
|
creator: proposer
|
|
19876
19828
|
};
|
|
19877
19829
|
const setupTransactions = [
|
|
19878
|
-
new
|
|
19830
|
+
new import_web332.Transaction().add(
|
|
19879
19831
|
squads2.generated.createTransactionBufferCreateInstruction(
|
|
19880
19832
|
{
|
|
19881
19833
|
...accounts2,
|
|
@@ -19895,7 +19847,7 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
19895
19847
|
];
|
|
19896
19848
|
for (let offset = BufferChunkSize; offset < bytes.length; offset += BufferChunkSize) {
|
|
19897
19849
|
setupTransactions.push(
|
|
19898
|
-
new
|
|
19850
|
+
new import_web332.Transaction().add(
|
|
19899
19851
|
squads2.generated.createTransactionBufferExtendInstruction(accounts2, {
|
|
19900
19852
|
args: { buffer: bytes.slice(offset, offset + BufferChunkSize) }
|
|
19901
19853
|
})
|
|
@@ -19908,7 +19860,7 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
19908
19860
|
vaultTransactionCreateItemTransaction: prepared.vaultTransactionPda,
|
|
19909
19861
|
vaultTransactionCreateItemCreator: proposer,
|
|
19910
19862
|
vaultTransactionCreateItemRentPayer: proposer,
|
|
19911
|
-
vaultTransactionCreateItemSystemProgram:
|
|
19863
|
+
vaultTransactionCreateItemSystemProgram: import_web332.SystemProgram.programId,
|
|
19912
19864
|
transactionBuffer: bufferPda,
|
|
19913
19865
|
creator: proposer
|
|
19914
19866
|
},
|
|
@@ -19920,7 +19872,7 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
19920
19872
|
).isWritable = true;
|
|
19921
19873
|
return {
|
|
19922
19874
|
setupTransactions,
|
|
19923
|
-
proposalTransaction: new
|
|
19875
|
+
proposalTransaction: new import_web332.Transaction().add(
|
|
19924
19876
|
finalize,
|
|
19925
19877
|
...transaction.instructions.slice(1)
|
|
19926
19878
|
),
|
|
@@ -19931,13 +19883,13 @@ async function prepareSquadsProposalUpload(args) {
|
|
|
19931
19883
|
|
|
19932
19884
|
// src/utils/token.ts
|
|
19933
19885
|
var import_spl_token24 = require("@solana/spl-token");
|
|
19934
|
-
var
|
|
19935
|
-
var
|
|
19886
|
+
var import_web333 = require("@solana/web3.js");
|
|
19887
|
+
var import_common51 = __toESM(require_dist());
|
|
19936
19888
|
async function createTokenMintIxs(connection, payer, authority, decimals, tokenProgram = import_spl_token24.TOKEN_2022_PROGRAM_ID) {
|
|
19937
|
-
const mint =
|
|
19889
|
+
const mint = import_web333.Keypair.generate();
|
|
19938
19890
|
const lamports = await (0, import_spl_token24.getMinimumBalanceForRentExemptMint)(connection);
|
|
19939
19891
|
const ixs = [
|
|
19940
|
-
|
|
19892
|
+
import_web333.SystemProgram.createAccount({
|
|
19941
19893
|
fromPubkey: payer,
|
|
19942
19894
|
newAccountPubkey: mint.publicKey,
|
|
19943
19895
|
space: import_spl_token24.MINT_SIZE,
|
|
@@ -19963,7 +19915,7 @@ async function createTokenMint(connection, payer, decimals, tokenProgram = impor
|
|
|
19963
19915
|
tokenProgram
|
|
19964
19916
|
);
|
|
19965
19917
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
|
|
19966
|
-
const tx = new
|
|
19918
|
+
const tx = new import_web333.Transaction().add(...ixs);
|
|
19967
19919
|
tx.feePayer = payer.publicKey;
|
|
19968
19920
|
tx.recentBlockhash = blockhash;
|
|
19969
19921
|
tx.sign(payer, mint);
|
|
@@ -19977,7 +19929,7 @@ async function createTokenMint(connection, payer, decimals, tokenProgram = impor
|
|
|
19977
19929
|
return mint.publicKey;
|
|
19978
19930
|
}
|
|
19979
19931
|
async function mintTokensTo(connection, payer, mint, destination, amount, tokenProgram = import_spl_token24.TOKEN_2022_PROGRAM_ID, allowOwnerOffCurve = true) {
|
|
19980
|
-
const tokenProgramPk = (0,
|
|
19932
|
+
const tokenProgramPk = (0, import_common51.asWeb3PublicKey)(tokenProgram);
|
|
19981
19933
|
const ata = (0, import_spl_token24.getAssociatedTokenAddressSync)(
|
|
19982
19934
|
mint,
|
|
19983
19935
|
destination,
|
|
@@ -20002,7 +19954,7 @@ async function mintTokensTo(connection, payer, mint, destination, amount, tokenP
|
|
|
20002
19954
|
tokenProgramPk
|
|
20003
19955
|
)
|
|
20004
19956
|
];
|
|
20005
|
-
const tx = new
|
|
19957
|
+
const tx = new import_web333.Transaction().add(...ixs);
|
|
20006
19958
|
await connection.sendTransaction(tx, [payer]);
|
|
20007
19959
|
}
|
|
20008
19960
|
|
|
@@ -20392,7 +20344,7 @@ async function getTotalTrackedValue(accountNames, start, end, onAccountValue) {
|
|
|
20392
20344
|
}
|
|
20393
20345
|
|
|
20394
20346
|
// src/services/withdrawalQueueService.ts
|
|
20395
|
-
var
|
|
20347
|
+
var import_common52 = __toESM(require_dist());
|
|
20396
20348
|
function bnToBigInt(value) {
|
|
20397
20349
|
return BigInt(value.toString());
|
|
20398
20350
|
}
|
|
@@ -20458,10 +20410,10 @@ var WithdrawalQueueService = class {
|
|
|
20458
20410
|
const vault = await this.client.account.fetchVault(queue.vault, {
|
|
20459
20411
|
fresh: true
|
|
20460
20412
|
});
|
|
20461
|
-
if (queue.inputMint === (0,
|
|
20413
|
+
if (queue.inputMint === (0, import_common52.fromWeb3Pk)(vault.mint)) {
|
|
20462
20414
|
const plan2 = await this.client.tx.fulfillAsyncWithdraw.getTx({
|
|
20463
20415
|
owner: queue.owner,
|
|
20464
|
-
signer: (0,
|
|
20416
|
+
signer: (0, import_common52.fromWeb3Pk)(signer.publicKey),
|
|
20465
20417
|
queuePayer: queue.payer,
|
|
20466
20418
|
vault: queue.vault,
|
|
20467
20419
|
withdrawalQueue: queue.pda,
|
|
@@ -20475,14 +20427,14 @@ var WithdrawalQueueService = class {
|
|
|
20475
20427
|
queue.vault,
|
|
20476
20428
|
{ fresh: true }
|
|
20477
20429
|
);
|
|
20478
|
-
if (queue.inputMint !== (0,
|
|
20430
|
+
if (queue.inputMint !== (0, import_common52.fromWeb3Pk)(tranche.config.juniorMint)) {
|
|
20479
20431
|
throw new Error(
|
|
20480
20432
|
`Unsupported withdrawal queue input mint: ${queue.inputMint}`
|
|
20481
20433
|
);
|
|
20482
20434
|
}
|
|
20483
20435
|
const plan = await this.client.tx.fulfillJuniorTrancheWithdraw.getTx({
|
|
20484
20436
|
owner: queue.owner,
|
|
20485
|
-
signer: (0,
|
|
20437
|
+
signer: (0, import_common52.fromWeb3Pk)(signer.publicKey),
|
|
20486
20438
|
queuePayer: queue.payer,
|
|
20487
20439
|
vault: queue.vault,
|
|
20488
20440
|
withdrawalQueue: queue.pda,
|
|
@@ -20518,7 +20470,7 @@ var WithdrawalQueueService = class {
|
|
|
20518
20470
|
let regularBlocked = false;
|
|
20519
20471
|
let regularMint;
|
|
20520
20472
|
try {
|
|
20521
|
-
regularMint = (0,
|
|
20473
|
+
regularMint = (0, import_common52.fromWeb3Pk)(
|
|
20522
20474
|
(await this.client.account.fetchVault(vault2, { fresh: true })).mint
|
|
20523
20475
|
);
|
|
20524
20476
|
} catch (err) {
|
|
@@ -20582,12 +20534,12 @@ var WithdrawalQueueService = class {
|
|
|
20582
20534
|
const a = account;
|
|
20583
20535
|
return {
|
|
20584
20536
|
pda,
|
|
20585
|
-
vault: (0,
|
|
20586
|
-
owner: (0,
|
|
20587
|
-
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),
|
|
20588
20540
|
queueId: a.header.queueId,
|
|
20589
|
-
inputMint: (0,
|
|
20590
|
-
outputMint: (0,
|
|
20541
|
+
inputMint: (0, import_common52.fromWeb3Pk)(a.mints.inputMint),
|
|
20542
|
+
outputMint: (0, import_common52.fromWeb3Pk)(a.mints.outputMint),
|
|
20591
20543
|
inputAmount: bnToBigInt(a.request.inputAmount),
|
|
20592
20544
|
requestTs: bnToNumber(a.request.requestTs),
|
|
20593
20545
|
expiryTs: bnToNumber(a.request.expiryTs),
|
|
@@ -20599,7 +20551,7 @@ var WithdrawalQueueService = class {
|
|
|
20599
20551
|
|
|
20600
20552
|
// src/services/oracleService.ts
|
|
20601
20553
|
var import_kit12 = require("@solana/kit");
|
|
20602
|
-
var
|
|
20554
|
+
var import_common53 = __toESM(require_dist());
|
|
20603
20555
|
var SYSTEM_PROGRAM2 = "11111111111111111111111111111111";
|
|
20604
20556
|
var DEFAULT_PRICE_STALENESS_THRESHOLD_SECS2 = 86400n;
|
|
20605
20557
|
var PRICE_ORACLE_TYPES_BY_INDEX2 = [
|
|
@@ -20663,7 +20615,7 @@ var OracleService = class {
|
|
|
20663
20615
|
*/
|
|
20664
20616
|
async updateAssetConsensusPrice(signer, args, log) {
|
|
20665
20617
|
const plan = await this.client.tx.updateConsensusOracle.getTx({
|
|
20666
|
-
signer: (0,
|
|
20618
|
+
signer: (0, import_common53.fromWeb3Pk)(signer.publicKey),
|
|
20667
20619
|
vault: args.vault,
|
|
20668
20620
|
updates: args.updates,
|
|
20669
20621
|
assetMint: args.assetMint,
|
|
@@ -20683,14 +20635,14 @@ var OracleService = class {
|
|
|
20683
20635
|
*/
|
|
20684
20636
|
async updateAssetConsensusPriceAndCrankNavIfReady(signer, args, log, beforeSubmit) {
|
|
20685
20637
|
const updatePlan = await this.client.tx.updateConsensusOracle.getTx({
|
|
20686
|
-
signer: (0,
|
|
20638
|
+
signer: (0, import_common53.fromWeb3Pk)(signer.publicKey),
|
|
20687
20639
|
...args
|
|
20688
20640
|
});
|
|
20689
20641
|
let plan = updatePlan;
|
|
20690
20642
|
let crankSkippedReason;
|
|
20691
20643
|
try {
|
|
20692
20644
|
const crankPlan = await this.client.tx.crankNav.getTx({
|
|
20693
|
-
cranker: (0,
|
|
20645
|
+
cranker: (0, import_common53.fromWeb3Pk)(signer.publicKey),
|
|
20694
20646
|
vault: args.vault
|
|
20695
20647
|
});
|
|
20696
20648
|
const combinedPlan = {
|
|
@@ -20737,7 +20689,7 @@ var OracleService = class {
|
|
|
20737
20689
|
/** Settle the vault NAV from its current holdings (permissionless). */
|
|
20738
20690
|
async crankNav(cranker, args, log) {
|
|
20739
20691
|
const plan = await this.client.tx.crankNav.getTx({
|
|
20740
|
-
cranker: (0,
|
|
20692
|
+
cranker: (0, import_common53.fromWeb3Pk)(cranker.publicKey),
|
|
20741
20693
|
vault: args.vault,
|
|
20742
20694
|
vaultTrancheState: args.vaultTrancheState
|
|
20743
20695
|
});
|
|
@@ -20810,7 +20762,7 @@ var OracleService = class {
|
|
|
20810
20762
|
/** Re-price one live-oracle holding from its bound Pyth/nested-vault account. */
|
|
20811
20763
|
async refreshAssetPrice(updater, args, log) {
|
|
20812
20764
|
const plan = await this.client.tx.updateAssetPrice.getTx({
|
|
20813
|
-
updater: (0,
|
|
20765
|
+
updater: (0, import_common53.fromWeb3Pk)(updater.publicKey),
|
|
20814
20766
|
vault: args.vault,
|
|
20815
20767
|
mint: args.mint,
|
|
20816
20768
|
oracleAccount: args.oracleAccount,
|
|
@@ -20906,11 +20858,11 @@ function toBigInt2(value) {
|
|
|
20906
20858
|
}
|
|
20907
20859
|
|
|
20908
20860
|
// src/services/consensusOracle/utils/holdings.ts
|
|
20909
|
-
var
|
|
20910
|
-
var
|
|
20861
|
+
var import_web334 = require("@solana/web3.js");
|
|
20862
|
+
var import_common54 = __toESM(require_dist());
|
|
20911
20863
|
function selectReportableHoldings(holdings, excludedMints = /* @__PURE__ */ new Set()) {
|
|
20912
20864
|
return holdings.map((holding, holdingIndex) => ({ holding, holdingIndex })).filter(({ holding }) => {
|
|
20913
|
-
const mint = (0,
|
|
20865
|
+
const mint = (0, import_common54.fromWeb3Pk)(holding.mint);
|
|
20914
20866
|
return mint !== SYSTEM_PROGRAM && !excludedMints.has(mint.toString()) && REPORTABLE_ORACLE_VARIANTS.has(
|
|
20915
20867
|
variantName2(holding.priceOracleType).toLowerCase()
|
|
20916
20868
|
);
|
|
@@ -20945,7 +20897,7 @@ function parseExternalLiquidityRefs(vaultState) {
|
|
|
20945
20897
|
if (!data || data.length < 40) continue;
|
|
20946
20898
|
if (data[0] !== 1 && data[0] !== 2) continue;
|
|
20947
20899
|
const pubkeyBytes = new Uint8Array(data.slice(8, 40));
|
|
20948
|
-
const userAccount = new
|
|
20900
|
+
const userAccount = new import_web334.PublicKey(pubkeyBytes).toBase58();
|
|
20949
20901
|
refs.push(
|
|
20950
20902
|
data[0] === 1 ? { kind: "marginfi", mint: "", marginfiAccount: userAccount } : {
|
|
20951
20903
|
kind: "kamino-lend",
|
|
@@ -21173,12 +21125,12 @@ function formatBpsAsPercent(bps) {
|
|
|
21173
21125
|
}
|
|
21174
21126
|
|
|
21175
21127
|
// src/services/consensusOracle/pipeline/dryRunSettlement.ts
|
|
21176
|
-
var
|
|
21177
|
-
var
|
|
21128
|
+
var import_web336 = require("@solana/web3.js");
|
|
21129
|
+
var import_common55 = __toESM(require_dist());
|
|
21178
21130
|
|
|
21179
21131
|
// src/services/consensusOracle/settlement/settlementSimulator.ts
|
|
21180
21132
|
var import_kit13 = require("@solana/kit");
|
|
21181
|
-
var
|
|
21133
|
+
var import_web335 = require("@solana/web3.js");
|
|
21182
21134
|
var DEFAULT_SHARE_PRICE = 1000000n;
|
|
21183
21135
|
var BPS_DENOMINATOR3 = 10000n;
|
|
21184
21136
|
var NAV_LOSS_TOLERANCE_BPS = 1n;
|
|
@@ -21451,7 +21403,7 @@ function applyConsensus(holdings, entries, nowTs, stalenessThresholdSecs) {
|
|
|
21451
21403
|
continue;
|
|
21452
21404
|
}
|
|
21453
21405
|
const reports = entries.filter(
|
|
21454
|
-
(entry) => entry.signer !==
|
|
21406
|
+
(entry) => entry.signer !== import_web335.PublicKey.default.toBase58() && isFresh(entry.lastUpdateTs, nowTs, stalenessThresholdSecs) && (entry.prices[index] ?? 0n) > 0n
|
|
21455
21407
|
);
|
|
21456
21408
|
const usesConsensusPrice = holding.priceOracleType === "consensusoracle";
|
|
21457
21409
|
const prices = reports.map((entry) => entry.prices[index] ?? 0n);
|
|
@@ -21952,7 +21904,7 @@ function decodeOracleData(data, nowTs) {
|
|
|
21952
21904
|
(_, holdingIndex) => readU64(data, offset + EXTERNAL_OFFSET + holdingIndex * 8)
|
|
21953
21905
|
);
|
|
21954
21906
|
entries.push({
|
|
21955
|
-
signer: new
|
|
21907
|
+
signer: new import_web335.PublicKey(signerBytes).toBase58(),
|
|
21956
21908
|
lastUpdateTs: readI64(data, offset + 32),
|
|
21957
21909
|
prices,
|
|
21958
21910
|
externalAmounts
|
|
@@ -21967,7 +21919,7 @@ function decodeOracleData(data, nowTs) {
|
|
|
21967
21919
|
data.slice(pendingOffset + index * 32, pendingOffset + (index + 1) * 32)
|
|
21968
21920
|
);
|
|
21969
21921
|
entries[index] = {
|
|
21970
|
-
signer: index < pendingCount ? new
|
|
21922
|
+
signer: index < pendingCount ? new import_web335.PublicKey(signerBytes).toBase58() : import_web335.PublicKey.default.toBase58(),
|
|
21971
21923
|
lastUpdateTs: 0n,
|
|
21972
21924
|
prices: Array(MAX_HOLDINGS).fill(0n),
|
|
21973
21925
|
externalAmounts: Array(MAX_HOLDINGS).fill(0n)
|
|
@@ -21995,7 +21947,7 @@ function decodeHolding(value) {
|
|
|
21995
21947
|
externalAmount: bigint(holding.externalAmount),
|
|
21996
21948
|
price: bigint(holding.price),
|
|
21997
21949
|
lastUpdateTs: bigint(holding.lastUpdateTs),
|
|
21998
|
-
cleared: mintString ===
|
|
21950
|
+
cleared: mintString === import_web335.PublicKey.default.toBase58()
|
|
21999
21951
|
};
|
|
22000
21952
|
}
|
|
22001
21953
|
function decodeTrancheState(decoded, args, warnings, blockers) {
|
|
@@ -22478,11 +22430,11 @@ async function fetchSimulationArgs({
|
|
|
22478
22430
|
client.account.fetchVaultOracleForVault(vault, { fresh: true }),
|
|
22479
22431
|
tranchingEnabled ? client.account.fetchVaultTrancheStateForVault(vault, { fresh: true }) : Promise.resolve(void 0)
|
|
22480
22432
|
]);
|
|
22481
|
-
const mintKeys = [new
|
|
22433
|
+
const mintKeys = [new import_web336.PublicKey(vaultState.mint)];
|
|
22482
22434
|
if (trancheState) {
|
|
22483
22435
|
mintKeys.push(
|
|
22484
|
-
new
|
|
22485
|
-
new
|
|
22436
|
+
new import_web336.PublicKey(trancheState.config.juniorMint),
|
|
22437
|
+
new import_web336.PublicKey(trancheState.config.seniorMint)
|
|
22486
22438
|
);
|
|
22487
22439
|
}
|
|
22488
22440
|
const mintAccounts = await client.provider.connection.getMultipleAccountsInfo(
|
|
@@ -22498,7 +22450,7 @@ async function fetchSimulationArgs({
|
|
|
22498
22450
|
oracleData: oracleState.data,
|
|
22499
22451
|
trancheState,
|
|
22500
22452
|
updates,
|
|
22501
|
-
signer: (0,
|
|
22453
|
+
signer: (0, import_common55.fromWeb3Pk)(signer.publicKey),
|
|
22502
22454
|
nowTs: nowSecs,
|
|
22503
22455
|
physicalShareSupply: supplies[0],
|
|
22504
22456
|
physicalJuniorSupply: tranchingEnabled ? supplies[1] : void 0,
|
|
@@ -22507,7 +22459,7 @@ async function fetchSimulationArgs({
|
|
|
22507
22459
|
}
|
|
22508
22460
|
|
|
22509
22461
|
// src/services/consensusOracle/pipeline/holdingUpdates.ts
|
|
22510
|
-
var
|
|
22462
|
+
var import_common56 = __toESM(require_dist());
|
|
22511
22463
|
async function buildUpdates(yieldTracker, reportableHoldings, inputs) {
|
|
22512
22464
|
const updates = [];
|
|
22513
22465
|
for (const entry of reportableHoldings) {
|
|
@@ -22517,7 +22469,7 @@ async function buildUpdates(yieldTracker, reportableHoldings, inputs) {
|
|
|
22517
22469
|
}
|
|
22518
22470
|
async function buildHoldingUpdate(yieldTracker, entry, inputs) {
|
|
22519
22471
|
const { holding, holdingIndex } = entry;
|
|
22520
|
-
const mint = (0,
|
|
22472
|
+
const mint = (0, import_common56.fromWeb3Pk)(holding.mint);
|
|
22521
22473
|
const mintKey = mint.toString();
|
|
22522
22474
|
const oracleType = variantName2(holding.priceOracleType).toLowerCase();
|
|
22523
22475
|
let usd;
|
|
@@ -22579,9 +22531,9 @@ async function resolveTrackedAmounts(yieldTracker, cfg, decimals) {
|
|
|
22579
22531
|
);
|
|
22580
22532
|
}
|
|
22581
22533
|
return {
|
|
22582
|
-
trackedValueAmount: tracked.totalValue > 0 ? (0,
|
|
22583
|
-
principalAmount: tracked.principal > 0 ? (0,
|
|
22584
|
-
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
|
|
22585
22537
|
};
|
|
22586
22538
|
}
|
|
22587
22539
|
|
|
@@ -22615,7 +22567,7 @@ function assertOracleImpliedApy(vault, simulation, label) {
|
|
|
22615
22567
|
}
|
|
22616
22568
|
|
|
22617
22569
|
// src/services/consensusOracle/pipeline/livePriceRefresh.ts
|
|
22618
|
-
var
|
|
22570
|
+
var import_common57 = __toESM(require_dist());
|
|
22619
22571
|
async function refreshLiveOraclePrices({
|
|
22620
22572
|
oracle,
|
|
22621
22573
|
signer,
|
|
@@ -22634,7 +22586,7 @@ async function refreshLiveOraclePrices({
|
|
|
22634
22586
|
for (const holding of vaultState.holdings) {
|
|
22635
22587
|
const oracleType = variantName2(holding.priceOracleType).toLowerCase();
|
|
22636
22588
|
if (!LIVE_ORACLE_VARIANTS.has(oracleType)) continue;
|
|
22637
|
-
const mint = (0,
|
|
22589
|
+
const mint = (0, import_common57.fromWeb3Pk)(holding.mint);
|
|
22638
22590
|
if (mint.toString() === SYSTEM_PROGRAM) continue;
|
|
22639
22591
|
const activeAmount = toBigInt2(holding.localAmount) + toBigInt2(holding.externalAmount);
|
|
22640
22592
|
if (activeAmount === 0n) continue;
|
|
@@ -22649,7 +22601,7 @@ async function refreshLiveOraclePrices({
|
|
|
22649
22601
|
);
|
|
22650
22602
|
continue;
|
|
22651
22603
|
}
|
|
22652
|
-
const oracleAccount = (0,
|
|
22604
|
+
const oracleAccount = (0, import_common57.fromWeb3Pk)(holding.priceOracleAccount);
|
|
22653
22605
|
if (oracleAccount.toString() === SYSTEM_PROGRAM) {
|
|
22654
22606
|
log(
|
|
22655
22607
|
`vault ${vault}: cannot refresh ${mint}; ${oracleType} holding has no oracle account`
|
|
@@ -22673,7 +22625,7 @@ async function refreshLiveOraclePrices({
|
|
|
22673
22625
|
}
|
|
22674
22626
|
|
|
22675
22627
|
// src/services/consensusOracle/pipeline/managerWalletReconciliation.ts
|
|
22676
|
-
var
|
|
22628
|
+
var import_common58 = __toESM(require_dist());
|
|
22677
22629
|
|
|
22678
22630
|
// src/services/consensusOracle/sources/nestPriceSource.ts
|
|
22679
22631
|
var import_kit14 = require("@solana/kit");
|
|
@@ -22720,13 +22672,13 @@ function candidateGrossNav(state, updates) {
|
|
|
22720
22672
|
const byIndex = /* @__PURE__ */ new Map();
|
|
22721
22673
|
for (const update of updates) {
|
|
22722
22674
|
const holding = state.holdings[update.holdingIndex];
|
|
22723
|
-
if (!holding || (0,
|
|
22675
|
+
if (!holding || (0, import_common58.fromWeb3Pk)(holding.mint) !== update.mint || holding.decimals !== update.decimals || byIndex.has(update.holdingIndex)) {
|
|
22724
22676
|
throw new Error(`Invalid NAV update for holding #${update.holdingIndex}`);
|
|
22725
22677
|
}
|
|
22726
22678
|
byIndex.set(update.holdingIndex, update);
|
|
22727
22679
|
}
|
|
22728
22680
|
return state.holdings.reduce((nav, holding, index) => {
|
|
22729
|
-
if ((0,
|
|
22681
|
+
if ((0, import_common58.fromWeb3Pk)(holding.mint) === SYSTEM_PROGRAM) return nav;
|
|
22730
22682
|
const update = byIndex.get(index);
|
|
22731
22683
|
const local = toBigInt2(holding.localAmount);
|
|
22732
22684
|
const external = update?.externalAmount ?? toBigInt2(holding.externalAmount);
|
|
@@ -22793,13 +22745,13 @@ async function reconcileManagerWalletBalances({
|
|
|
22793
22745
|
throw new Error("Duplicate base mint in manager reconciliation");
|
|
22794
22746
|
}
|
|
22795
22747
|
if (vaultState.holdings.some(
|
|
22796
|
-
(holding) => coerceBool3(holding.isBase) && !mints2.includes((0,
|
|
22748
|
+
(holding) => coerceBool3(holding.isBase) && !mints2.includes((0, import_common58.fromWeb3Pk)(holding.mint))
|
|
22797
22749
|
)) {
|
|
22798
22750
|
throw new Error(
|
|
22799
22751
|
"Cannot reconcile all vault base assets with oracle reports"
|
|
22800
22752
|
);
|
|
22801
22753
|
}
|
|
22802
|
-
const manager = (0,
|
|
22754
|
+
const manager = (0, import_common58.fromWeb3Pk)(vaultState.roles.manager);
|
|
22803
22755
|
if (manager === SYSTEM_PROGRAM || manager === vault) {
|
|
22804
22756
|
throw new Error("Invalid manager wallet for NAV reconciliation");
|
|
22805
22757
|
}
|
|
@@ -22885,13 +22837,13 @@ function walletReconciliationGuardUpdates(state, reconciliation) {
|
|
|
22885
22837
|
}
|
|
22886
22838
|
function managerReconciliationStateKey(state) {
|
|
22887
22839
|
return JSON.stringify({
|
|
22888
|
-
manager: (0,
|
|
22840
|
+
manager: (0, import_common58.fromWeb3Pk)(state.roles.manager),
|
|
22889
22841
|
assetDecimals: state.config.assetDecimals,
|
|
22890
22842
|
holdings: state.holdings.map((holding) => [
|
|
22891
|
-
(0,
|
|
22843
|
+
(0, import_common58.fromWeb3Pk)(holding.mint),
|
|
22892
22844
|
holding.decimals,
|
|
22893
22845
|
variantName2(holding.priceOracleType),
|
|
22894
|
-
holding.priceOracleAccount ? (0,
|
|
22846
|
+
holding.priceOracleAccount ? (0, import_common58.fromWeb3Pk)(holding.priceOracleAccount) : void 0,
|
|
22895
22847
|
coerceBool3(holding.isBase),
|
|
22896
22848
|
toBigInt2(holding.localAmount).toString()
|
|
22897
22849
|
])
|
|
@@ -22930,14 +22882,14 @@ function assertReconciliationExternalValues(initial, current, errorPrefix) {
|
|
|
22930
22882
|
}
|
|
22931
22883
|
|
|
22932
22884
|
// src/services/consensusOracle/pipeline/pricingInputs.ts
|
|
22933
|
-
var
|
|
22885
|
+
var import_common59 = __toESM(require_dist());
|
|
22934
22886
|
async function gatherPricingInputs(deps, target, vaultState, reportableHoldings, log = () => {
|
|
22935
22887
|
}) {
|
|
22936
22888
|
const consensusMints = reportableHoldings.filter(
|
|
22937
22889
|
({ holding }) => variantName2(holding.priceOracleType).toLowerCase() === CONSENSUS_ORACLE_VARIANT
|
|
22938
|
-
).map(({ holding }) => (0,
|
|
22890
|
+
).map(({ holding }) => (0, import_common59.fromWeb3Pk)(holding.mint));
|
|
22939
22891
|
const baseHolding = vaultState.holdings.find((h) => coerceBool3(h.isBase));
|
|
22940
|
-
const baseMint = baseHolding ? (0,
|
|
22892
|
+
const baseMint = baseHolding ? (0, import_common59.fromWeb3Pk)(baseHolding.mint) : consensusMints[0];
|
|
22941
22893
|
if (!baseMint) {
|
|
22942
22894
|
throw new Error(`vault has no holdings \u2014 cannot determine base asset`);
|
|
22943
22895
|
}
|
|
@@ -23023,11 +22975,11 @@ function reconcilePositionSnapshots(snapshots, vault, log) {
|
|
|
23023
22975
|
}
|
|
23024
22976
|
|
|
23025
22977
|
// src/services/consensusOracle/pipeline/receiptMints.ts
|
|
23026
|
-
var
|
|
22978
|
+
var import_common60 = __toESM(require_dist());
|
|
23027
22979
|
async function fetchReceiptMints(client, vault, vaultState) {
|
|
23028
22980
|
const receiptMints = /* @__PURE__ */ new Set();
|
|
23029
22981
|
if (vaultState.mint) {
|
|
23030
|
-
receiptMints.add((0,
|
|
22982
|
+
receiptMints.add((0, import_common60.fromWeb3Pk)(vaultState.mint).toString());
|
|
23031
22983
|
}
|
|
23032
22984
|
if (!coerceBool3(vaultState.tranchingEnabled)) return receiptMints;
|
|
23033
22985
|
const trancheState = await client.account.fetchVaultTrancheStateForVault(
|
|
@@ -23035,19 +22987,19 @@ async function fetchReceiptMints(client, vault, vaultState) {
|
|
|
23035
22987
|
{ fresh: true }
|
|
23036
22988
|
);
|
|
23037
22989
|
receiptMints.add(
|
|
23038
|
-
(0,
|
|
22990
|
+
(0, import_common60.fromWeb3Pk)(trancheState.config.juniorMint).toString()
|
|
23039
22991
|
);
|
|
23040
22992
|
receiptMints.add(
|
|
23041
|
-
(0,
|
|
22993
|
+
(0, import_common60.fromWeb3Pk)(trancheState.config.seniorMint).toString()
|
|
23042
22994
|
);
|
|
23043
22995
|
return receiptMints;
|
|
23044
22996
|
}
|
|
23045
22997
|
|
|
23046
22998
|
// src/services/consensusOracle/pipeline/settlement.ts
|
|
23047
|
-
var
|
|
22999
|
+
var import_common62 = __toESM(require_dist());
|
|
23048
23000
|
|
|
23049
23001
|
// src/services/consensusOracle/pipeline/yieldAccounts.ts
|
|
23050
|
-
var
|
|
23002
|
+
var import_common61 = __toESM(require_dist());
|
|
23051
23003
|
async function assertNoUnconfirmedYieldPayments(yieldTracker, target) {
|
|
23052
23004
|
const accountNames = [
|
|
23053
23005
|
...new Set(
|
|
@@ -23089,7 +23041,7 @@ async function withDiscoveredYieldAccounts(yieldTracker, target, vaultState, exc
|
|
|
23089
23041
|
);
|
|
23090
23042
|
if (namesToAttach.length === 0) return target;
|
|
23091
23043
|
const baseHolding = vaultState.holdings.find((holding) => {
|
|
23092
|
-
const mint = (0,
|
|
23044
|
+
const mint = (0, import_common61.fromWeb3Pk)(holding.mint).toString();
|
|
23093
23045
|
return coerceBool3(holding.isBase) && !excludedMints.has(mint);
|
|
23094
23046
|
});
|
|
23095
23047
|
if (!baseHolding) {
|
|
@@ -23097,7 +23049,7 @@ async function withDiscoveredYieldAccounts(yieldTracker, target, vaultState, exc
|
|
|
23097
23049
|
`vault ${target.vault}: tagged yield accounts found but no base holding is available`
|
|
23098
23050
|
);
|
|
23099
23051
|
}
|
|
23100
|
-
const baseMint = (0,
|
|
23052
|
+
const baseMint = (0, import_common61.fromWeb3Pk)(baseHolding.mint);
|
|
23101
23053
|
const holdings = [...target.holdings ?? []];
|
|
23102
23054
|
const existingIndex = holdings.findIndex(
|
|
23103
23055
|
(holding) => holding.mint.toString() === baseMint.toString()
|
|
@@ -23220,7 +23172,7 @@ async function logProspectiveApy({
|
|
|
23220
23172
|
);
|
|
23221
23173
|
const prospectiveNav = vaultState.holdings.reduce(
|
|
23222
23174
|
(sum, holding, holdingIndex) => {
|
|
23223
|
-
const mint = (0,
|
|
23175
|
+
const mint = (0, import_common62.fromWeb3Pk)(holding.mint).toString();
|
|
23224
23176
|
if (mint === SYSTEM_PROGRAM) return sum;
|
|
23225
23177
|
const update = updatesByIndex.get(holdingIndex);
|
|
23226
23178
|
const localAmount = toBigInt2(holding.localAmount);
|
|
@@ -24147,7 +24099,7 @@ async function buildJupiterSwapTransaction(params) {
|
|
|
24147
24099
|
}
|
|
24148
24100
|
|
|
24149
24101
|
// ../jupiter/src/client.ts
|
|
24150
|
-
var
|
|
24102
|
+
var import_common63 = __toESM(require_dist());
|
|
24151
24103
|
|
|
24152
24104
|
// ../jupiter/src/extract.ts
|
|
24153
24105
|
var import_kit17 = require("@solana/kit");
|
|
@@ -24178,7 +24130,7 @@ async function extractJupiterInstruction(transaction, rpc, jupiterProgramId = JU
|
|
|
24178
24130
|
// ../jupiter/src/routePreInstructions.ts
|
|
24179
24131
|
var import_kit18 = require("@solana/kit");
|
|
24180
24132
|
var import_spl_token25 = require("@solana/spl-token");
|
|
24181
|
-
var
|
|
24133
|
+
var import_web337 = require("@solana/web3.js");
|
|
24182
24134
|
async function getJupiterRoutePreInstructions(rpc, quote, user, payer) {
|
|
24183
24135
|
const intermediate = /* @__PURE__ */ new Set();
|
|
24184
24136
|
for (const step of quote.routePlan ?? []) {
|
|
@@ -24203,10 +24155,10 @@ async function getJupiterRoutePreInstructions(rpc, quote, user, payer) {
|
|
|
24203
24155
|
);
|
|
24204
24156
|
}
|
|
24205
24157
|
const ata = (0, import_spl_token25.getAssociatedTokenAddressSync)(
|
|
24206
|
-
new
|
|
24207
|
-
new
|
|
24158
|
+
new import_web337.PublicKey(mint),
|
|
24159
|
+
new import_web337.PublicKey(user),
|
|
24208
24160
|
true,
|
|
24209
|
-
new
|
|
24161
|
+
new import_web337.PublicKey(tokenProgram),
|
|
24210
24162
|
import_spl_token25.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
24211
24163
|
).toBase58();
|
|
24212
24164
|
const existingAta = await rpc.getAccountInfo(ata, { encoding: "base64" }).send();
|
|
@@ -24214,13 +24166,13 @@ async function getJupiterRoutePreInstructions(rpc, quote, user, payer) {
|
|
|
24214
24166
|
continue;
|
|
24215
24167
|
}
|
|
24216
24168
|
instructions2.push(
|
|
24217
|
-
|
|
24169
|
+
toKitInstruction39(
|
|
24218
24170
|
(0, import_spl_token25.createAssociatedTokenAccountIdempotentInstruction)(
|
|
24219
|
-
new
|
|
24220
|
-
new
|
|
24221
|
-
new
|
|
24222
|
-
new
|
|
24223
|
-
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),
|
|
24224
24176
|
import_spl_token25.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
24225
24177
|
)
|
|
24226
24178
|
)
|
|
@@ -24229,7 +24181,7 @@ async function getJupiterRoutePreInstructions(rpc, quote, user, payer) {
|
|
|
24229
24181
|
}
|
|
24230
24182
|
return { instructions: instructions2, postSuccessCacheInvalidations };
|
|
24231
24183
|
}
|
|
24232
|
-
function
|
|
24184
|
+
function toKitInstruction39(ix) {
|
|
24233
24185
|
return {
|
|
24234
24186
|
programAddress: ix.programId.toBase58(),
|
|
24235
24187
|
accounts: ix.keys.map((account) => ({
|
|
@@ -24346,7 +24298,7 @@ var JupiterSwapClient = class {
|
|
|
24346
24298
|
}
|
|
24347
24299
|
}
|
|
24348
24300
|
return {
|
|
24349
|
-
cpiType: this.config.cpiType ??
|
|
24301
|
+
cpiType: this.config.cpiType ?? import_common63.CpiTypes.JUPITER_SWAP,
|
|
24350
24302
|
data,
|
|
24351
24303
|
accounts: accounts2,
|
|
24352
24304
|
programId: JUPITER_V6_PROGRAM_ID,
|
|
@@ -24444,7 +24396,7 @@ var LivePriceSource = class {
|
|
|
24444
24396
|
};
|
|
24445
24397
|
|
|
24446
24398
|
// src/services/consensusOracle/sources/managerWalletBalanceSource.ts
|
|
24447
|
-
var
|
|
24399
|
+
var import_web338 = require("@solana/web3.js");
|
|
24448
24400
|
var import_spl_token26 = require("@solana/spl-token");
|
|
24449
24401
|
var RpcManagerWalletBalanceSource = class {
|
|
24450
24402
|
constructor(connection) {
|
|
@@ -24453,7 +24405,7 @@ var RpcManagerWalletBalanceSource = class {
|
|
|
24453
24405
|
async fetchBalances(manager, mints2) {
|
|
24454
24406
|
const wanted = new Set(mints2);
|
|
24455
24407
|
if (wanted.size === 0) return /* @__PURE__ */ new Map();
|
|
24456
|
-
const owner = new
|
|
24408
|
+
const owner = new import_web338.PublicKey(manager);
|
|
24457
24409
|
const programs = [import_spl_token26.TOKEN_PROGRAM_ID, import_spl_token26.TOKEN_2022_PROGRAM_ID];
|
|
24458
24410
|
const responses = await Promise.all(
|
|
24459
24411
|
programs.map(
|
|
@@ -24497,7 +24449,7 @@ var RpcManagerWalletBalanceSource = class {
|
|
|
24497
24449
|
};
|
|
24498
24450
|
|
|
24499
24451
|
// src/services/consensusOracle/sources/mpcWalletBalanceSource.ts
|
|
24500
|
-
var
|
|
24452
|
+
var import_web339 = require("@solana/web3.js");
|
|
24501
24453
|
|
|
24502
24454
|
// src/services/consensusOracle/sources/mpcMarginfiDeposits.ts
|
|
24503
24455
|
var import_kit19 = require("@solana/kit");
|
|
@@ -24586,8 +24538,8 @@ var RpcMpcWalletBalanceSource = class {
|
|
|
24586
24538
|
const wallets = /* @__PURE__ */ new Set();
|
|
24587
24539
|
for (const binding of bindings) {
|
|
24588
24540
|
const { vault, manager, wallet } = binding;
|
|
24589
|
-
for (const key of [vault, manager, wallet]) new
|
|
24590
|
-
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())
|
|
24591
24543
|
throw new Error("Invalid or duplicate MPC wallet binding");
|
|
24592
24544
|
entries.set(vault, { ...binding });
|
|
24593
24545
|
wallets.add(wallet);
|
|
@@ -24607,8 +24559,8 @@ var RpcMpcWalletBalanceSource = class {
|
|
|
24607
24559
|
this.tokens.fetchBalances(binding.wallet, mints2),
|
|
24608
24560
|
readMarginfiDepositsForAuthority(
|
|
24609
24561
|
this.connection,
|
|
24610
|
-
new
|
|
24611
|
-
mints2.map((mint) => new
|
|
24562
|
+
new import_web339.PublicKey(binding.wallet),
|
|
24563
|
+
mints2.map((mint) => new import_web339.PublicKey(mint))
|
|
24612
24564
|
)
|
|
24613
24565
|
]);
|
|
24614
24566
|
return { wallet: binding.wallet, tokens, marginfi: deposits };
|
|
@@ -24651,7 +24603,7 @@ var StaticPositionProvider = class {
|
|
|
24651
24603
|
|
|
24652
24604
|
// src/services/consensusOracle/positions/kaminoPositionProvider.ts
|
|
24653
24605
|
var import_kit20 = require("@solana/kit");
|
|
24654
|
-
var
|
|
24606
|
+
var import_web340 = require("@solana/web3.js");
|
|
24655
24607
|
var import_klend_sdk = require("@kamino-finance/klend-sdk");
|
|
24656
24608
|
async function readKaminoBalance(manager, vault, sharesHolder) {
|
|
24657
24609
|
const userShares = await manager.getUserSharesBalanceSingleVault(
|
|
@@ -24688,7 +24640,7 @@ var KaminoPositionProvider = class {
|
|
|
24688
24640
|
const amount = await readKaminoBalance(
|
|
24689
24641
|
manager,
|
|
24690
24642
|
kVault,
|
|
24691
|
-
new
|
|
24643
|
+
new import_web340.PublicKey(sharesHolder)
|
|
24692
24644
|
);
|
|
24693
24645
|
out.push({ mint: ref.mint, amount });
|
|
24694
24646
|
}
|
|
@@ -24697,11 +24649,11 @@ var KaminoPositionProvider = class {
|
|
|
24697
24649
|
};
|
|
24698
24650
|
|
|
24699
24651
|
// src/services/consensusOracle/positions/kaminoLendPositionProvider.ts
|
|
24700
|
-
var
|
|
24652
|
+
var import_web341 = require("@solana/web3.js");
|
|
24701
24653
|
var import_Obligation2 = require("@kamino-finance/klend-sdk/dist/@codegen/klend/accounts/Obligation");
|
|
24702
24654
|
var import_Reserve2 = require("@kamino-finance/klend-sdk/dist/@codegen/klend/accounts/Reserve");
|
|
24703
24655
|
var import_kamino4 = __toESM(require_dist3());
|
|
24704
|
-
var ZERO =
|
|
24656
|
+
var ZERO = import_web341.PublicKey.default.toBase58();
|
|
24705
24657
|
var FRACTION_SCALE = 1n << 60n;
|
|
24706
24658
|
function accountData(info, label) {
|
|
24707
24659
|
if (!info || info.executable || info.owner.toBase58() !== import_kamino4.KLEND_PROGRAM_ID)
|
|
@@ -24742,7 +24694,7 @@ var KaminoLendPositionProvider = class {
|
|
|
24742
24694
|
}
|
|
24743
24695
|
const positions = [];
|
|
24744
24696
|
for (const address18 of obligations) {
|
|
24745
|
-
const key = new
|
|
24697
|
+
const key = new import_web341.PublicKey(address18);
|
|
24746
24698
|
const discovered = decodeObligation(
|
|
24747
24699
|
await this.connection.getAccountInfo(key, "confirmed"),
|
|
24748
24700
|
ctx.vault
|
|
@@ -24752,7 +24704,7 @@ var KaminoLendPositionProvider = class {
|
|
|
24752
24704
|
(deposit) => deposit.depositReserve
|
|
24753
24705
|
);
|
|
24754
24706
|
const infos = await this.connection.getMultipleAccountsInfo(
|
|
24755
|
-
[key, ...reserves.map((reserve) => new
|
|
24707
|
+
[key, ...reserves.map((reserve) => new import_web341.PublicKey(reserve))],
|
|
24756
24708
|
"confirmed"
|
|
24757
24709
|
);
|
|
24758
24710
|
const { obligation, deposits } = decodeObligation(
|
|
@@ -24794,7 +24746,7 @@ var KaminoLendPositionProvider = class {
|
|
|
24794
24746
|
};
|
|
24795
24747
|
|
|
24796
24748
|
// src/services/consensusOracle/positions/marginfiPositionProvider.ts
|
|
24797
|
-
var
|
|
24749
|
+
var import_web342 = require("@solana/web3.js");
|
|
24798
24750
|
var import_marginfi4 = __toESM(require_dist2());
|
|
24799
24751
|
var MarginfiPositionProvider = class {
|
|
24800
24752
|
constructor(connection, log = () => {
|
|
@@ -24805,8 +24757,8 @@ var MarginfiPositionProvider = class {
|
|
|
24805
24757
|
async positionsFor(ctx) {
|
|
24806
24758
|
const refs = ctx.refs.filter((r) => r.kind === "marginfi");
|
|
24807
24759
|
if (refs.length === 0) return [];
|
|
24808
|
-
const explicitBanks = refs.map((r) => r.marginfiBank).filter(Boolean).map((bank) => new
|
|
24809
|
-
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));
|
|
24810
24762
|
const autoBanks = [];
|
|
24811
24763
|
for (const accountPk of autoAccountPks) {
|
|
24812
24764
|
try {
|
|
@@ -24835,14 +24787,14 @@ var MarginfiPositionProvider = class {
|
|
|
24835
24787
|
if (bank) {
|
|
24836
24788
|
const amount = await (0, import_marginfi4.readMarginfiBankBalance)(
|
|
24837
24789
|
client,
|
|
24838
|
-
new
|
|
24839
|
-
new
|
|
24790
|
+
new import_web342.PublicKey(account),
|
|
24791
|
+
new import_web342.PublicKey(bank)
|
|
24840
24792
|
);
|
|
24841
24793
|
out.push({ mint: ref.mint, amount });
|
|
24842
24794
|
} else {
|
|
24843
24795
|
const balances = await (0, import_marginfi4.readAllMarginfiBalances)(
|
|
24844
24796
|
client,
|
|
24845
|
-
new
|
|
24797
|
+
new import_web342.PublicKey(account)
|
|
24846
24798
|
);
|
|
24847
24799
|
for (const { mint, amount } of balances) {
|
|
24848
24800
|
out.push({ mint: mint.toBase58(), amount });
|
|
@@ -25112,7 +25064,7 @@ function createLiveConsensusOracleDeps(connection, opts = {}) {
|
|
|
25112
25064
|
}
|
|
25113
25065
|
|
|
25114
25066
|
// src/services/consensusOracle/consensusOracleService.ts
|
|
25115
|
-
var
|
|
25067
|
+
var import_common64 = __toESM(require_dist());
|
|
25116
25068
|
var ConsensusOracleService = class {
|
|
25117
25069
|
constructor(client, deps) {
|
|
25118
25070
|
this.client = client;
|
|
@@ -25148,7 +25100,7 @@ var ConsensusOracleService = class {
|
|
|
25148
25100
|
receiptMints
|
|
25149
25101
|
);
|
|
25150
25102
|
const filteredCount = vaultState.holdings.filter(
|
|
25151
|
-
(holding) => receiptMints.has((0,
|
|
25103
|
+
(holding) => receiptMints.has((0, import_common64.fromWeb3Pk)(holding.mint).toString())
|
|
25152
25104
|
).length;
|
|
25153
25105
|
if (filteredCount > 0) {
|
|
25154
25106
|
log(
|
|
@@ -25417,8 +25369,8 @@ async function runLiveConsensusOracle(env, oracleSigner, opts = {}) {
|
|
|
25417
25369
|
|
|
25418
25370
|
// src/services/externalLiquidityIntegrityService.ts
|
|
25419
25371
|
var import_kit22 = require("@solana/kit");
|
|
25420
|
-
var
|
|
25421
|
-
var
|
|
25372
|
+
var import_web343 = require("@solana/web3.js");
|
|
25373
|
+
var import_common65 = __toESM(require_dist());
|
|
25422
25374
|
var import_marginfi5 = __toESM(require_dist2());
|
|
25423
25375
|
var import_kamino5 = __toESM(require_dist3());
|
|
25424
25376
|
var import_marginfi_client_v23 = require("@mrgnlabs/marginfi-client-v2");
|
|
@@ -25528,7 +25480,7 @@ function parseActiveSlots(externalLiquidity) {
|
|
|
25528
25480
|
if (discriminant === 0) continue;
|
|
25529
25481
|
if (discriminant !== 1 && discriminant !== 2) continue;
|
|
25530
25482
|
const pubkeyBytes = new Uint8Array(data.slice(8, 40));
|
|
25531
|
-
const userAccount = (0,
|
|
25483
|
+
const userAccount = (0, import_common65.toAddress)(new import_web343.PublicKey(pubkeyBytes));
|
|
25532
25484
|
if (isZeroPubkey2(userAccount))
|
|
25533
25485
|
throw new Error("Registered external position has a zero address");
|
|
25534
25486
|
if (results.some((slot) => slot.userAccount === userAccount)) continue;
|
|
@@ -25700,7 +25652,7 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
25700
25652
|
const decimals = Number(holding.decimals ?? 0);
|
|
25701
25653
|
const minRaw = toRawAmount(minAmountUi, decimals);
|
|
25702
25654
|
let targetLocalAmount;
|
|
25703
|
-
if (mintAddress ===
|
|
25655
|
+
if (mintAddress === import_common65.USDC_MINT) {
|
|
25704
25656
|
const tvl = toBigInt3(vaultState.accounting.tvl);
|
|
25705
25657
|
const price = toBigInt3(holding.price);
|
|
25706
25658
|
const stalenessThreshold = Number(toBigInt3(vaultState.config.priceStalenessThresholdSecs)) || DEFAULT_PRICE_STALENESS_THRESHOLD_SECS;
|
|
@@ -25803,25 +25755,25 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
25803
25755
|
* from vault accounting as though it were the balance of each separate slot. */
|
|
25804
25756
|
async loadPositions(vault, mint, slots) {
|
|
25805
25757
|
const marginfi = (0, import_marginfi5.marginfiAccountsForMint)(mint);
|
|
25806
|
-
if (!marginfi && mint !==
|
|
25758
|
+
if (!marginfi && mint !== import_common65.USDC_MINT)
|
|
25807
25759
|
return {
|
|
25808
25760
|
local: 0n,
|
|
25809
25761
|
positions: [],
|
|
25810
|
-
tokenProgram: (0, import_kit22.address)(
|
|
25811
|
-
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())
|
|
25812
25764
|
};
|
|
25813
25765
|
const connection = this.client.provider.connection;
|
|
25814
25766
|
const mintInfo = await connection.getAccountInfo(
|
|
25815
|
-
new
|
|
25767
|
+
new import_web343.PublicKey(mint),
|
|
25816
25768
|
"confirmed"
|
|
25817
25769
|
);
|
|
25818
25770
|
if (!mintInfo) throw new Error(`Missing mint ${mint}`);
|
|
25819
|
-
const tokenProgram = (0,
|
|
25820
|
-
const vaultAta = (0,
|
|
25771
|
+
const tokenProgram = (0, import_common65.fromWeb3Pk)(mintInfo.owner);
|
|
25772
|
+
const vaultAta = (0, import_common65.getAtaAddress)(mint, vault, tokenProgram, true);
|
|
25821
25773
|
const positions = [];
|
|
25822
25774
|
for (const slot of slots) {
|
|
25823
25775
|
if (slot.source === "marginfi" && !marginfi) continue;
|
|
25824
|
-
if (slot.source === "kamino" && mint !==
|
|
25776
|
+
if (slot.source === "kamino" && mint !== import_common65.USDC_MINT) continue;
|
|
25825
25777
|
const kamino = slot.source === "kamino" ? await loadKaminoDeposit({
|
|
25826
25778
|
connection,
|
|
25827
25779
|
vault,
|
|
@@ -25832,7 +25784,7 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
25832
25784
|
throw new Error("Kamino token program mismatch");
|
|
25833
25785
|
const data = Buffer.alloc(256);
|
|
25834
25786
|
data[0] = slot.source === "marginfi" ? 1 : 2;
|
|
25835
|
-
new
|
|
25787
|
+
new import_web343.PublicKey(slot.userAccount).toBuffer().copy(data, 8);
|
|
25836
25788
|
const withdrawal = await loadWithdrawalPosition({
|
|
25837
25789
|
connection,
|
|
25838
25790
|
vault,
|
|
@@ -25868,8 +25820,8 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
25868
25820
|
async executeMoves(args) {
|
|
25869
25821
|
const { vault, mintAddress, hwManager, snapshot: snapshot2, moves, dryRun, log } = args;
|
|
25870
25822
|
const instructions2 = [
|
|
25871
|
-
(0,
|
|
25872
|
-
|
|
25823
|
+
(0, import_common65.toKitInstruction)(
|
|
25824
|
+
import_web343.ComputeBudgetProgram.setComputeUnitLimit({ units: 14e5 })
|
|
25873
25825
|
)
|
|
25874
25826
|
];
|
|
25875
25827
|
const lookupTables = /* @__PURE__ */ new Set();
|
|
@@ -25882,7 +25834,7 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
25882
25834
|
cpiRefs = position.withdrawal.explicitRefs(move.amount);
|
|
25883
25835
|
} else if (position.source === "kamino") {
|
|
25884
25836
|
if (!position.kamino) throw new Error("Missing Kamino reserve");
|
|
25885
|
-
cpiRefs = (0,
|
|
25837
|
+
cpiRefs = (0, import_common65.createCpiRefs)(
|
|
25886
25838
|
(0, import_kamino5.kaminoDepositCpis)({
|
|
25887
25839
|
...position.kamino,
|
|
25888
25840
|
vault,
|
|
@@ -25893,14 +25845,14 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
25893
25845
|
);
|
|
25894
25846
|
} else {
|
|
25895
25847
|
const configured = (0, import_marginfi5.marginfiAccountsForMint)(mintAddress);
|
|
25896
|
-
cpiRefs = (0,
|
|
25848
|
+
cpiRefs = (0, import_common65.createCpiRefs)([
|
|
25897
25849
|
new import_marginfi5.CpiClient({ accounts: configured }).deposit_cpi({
|
|
25898
25850
|
marginfiAccount: position.userAccount,
|
|
25899
25851
|
authority: vault,
|
|
25900
25852
|
signerTokenAccount: snapshot2.vaultAta,
|
|
25901
25853
|
amount: move.amount,
|
|
25902
|
-
lookupTables: (import_marginfi_client_v23.ADDRESS_LOOKUP_TABLE_FOR_GROUP[configured.group] ?? []).map(
|
|
25903
|
-
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)] : []
|
|
25904
25856
|
})
|
|
25905
25857
|
]);
|
|
25906
25858
|
}
|
|
@@ -25908,7 +25860,7 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
25908
25860
|
instructions2.push(
|
|
25909
25861
|
await this.client.tx.protocolInteraction.getIx({
|
|
25910
25862
|
vault,
|
|
25911
|
-
hwManager: (0,
|
|
25863
|
+
hwManager: (0, import_common65.fromWeb3Pk)(hwManager.publicKey),
|
|
25912
25864
|
...cpiRefs,
|
|
25913
25865
|
externalLiquidityIndex: position.index,
|
|
25914
25866
|
affectedAssetMint: mintAddress,
|
|
@@ -25942,8 +25894,8 @@ var ExternalLiquidityIntegrityService = class {
|
|
|
25942
25894
|
var import_kit23 = require("@solana/kit");
|
|
25943
25895
|
var import_spl_token27 = require("@solana/spl-token");
|
|
25944
25896
|
var import_marginfi_client_v24 = require("@mrgnlabs/marginfi-client-v2");
|
|
25945
|
-
var
|
|
25946
|
-
var
|
|
25897
|
+
var import_web344 = require("@solana/web3.js");
|
|
25898
|
+
var import_common66 = __toESM(require_dist());
|
|
25947
25899
|
var import_marginfi6 = __toESM(require_dist2());
|
|
25948
25900
|
var IDLE_RESERVE_FLOOR_BPS = 400;
|
|
25949
25901
|
var IDLE_RESERVE_TARGET_BPS = 500;
|
|
@@ -26047,8 +25999,8 @@ var IdleLiquidityService = class {
|
|
|
26047
25999
|
);
|
|
26048
26000
|
}
|
|
26049
26001
|
quote = await jupiter.getQuote({
|
|
26050
|
-
inputMint:
|
|
26051
|
-
outputMint:
|
|
26002
|
+
inputMint: import_common66.PST_MINT,
|
|
26003
|
+
outputMint: import_common66.USDC_MINT,
|
|
26052
26004
|
amount: pstInput,
|
|
26053
26005
|
slippageBps
|
|
26054
26006
|
});
|
|
@@ -26093,8 +26045,8 @@ var IdleLiquidityService = class {
|
|
|
26093
26045
|
/** Read live local, Project0 and Kamino USDC, excluding other deployed capital. */
|
|
26094
26046
|
async fetchIdleUsdc(vault, vaultState) {
|
|
26095
26047
|
const connection = this.client.provider.connection;
|
|
26096
|
-
const vaultPk = new
|
|
26097
|
-
const usdcMint = new
|
|
26048
|
+
const vaultPk = new import_web344.PublicKey(vault);
|
|
26049
|
+
const usdcMint = new import_web344.PublicKey(import_common66.USDC_MINT);
|
|
26098
26050
|
const ata = (0, import_spl_token27.getAssociatedTokenAddressSync)(usdcMint, vaultPk, true);
|
|
26099
26051
|
const tokenInfo = await connection.getAccountInfo(ata, "confirmed");
|
|
26100
26052
|
let localAmount = 0n;
|
|
@@ -26108,7 +26060,7 @@ var IdleLiquidityService = class {
|
|
|
26108
26060
|
const kamino = await this.fetchKaminoUsdc(
|
|
26109
26061
|
vault,
|
|
26110
26062
|
vaultState,
|
|
26111
|
-
(0,
|
|
26063
|
+
(0, import_common66.fromWeb3Pk)(ata)
|
|
26112
26064
|
);
|
|
26113
26065
|
const slotIndex = vaultState.externalLiquidity.findIndex(
|
|
26114
26066
|
(slot) => slot.data[0] === 1
|
|
@@ -26126,12 +26078,12 @@ var IdleLiquidityService = class {
|
|
|
26126
26078
|
if (data.length < 40) {
|
|
26127
26079
|
throw new Error(`Invalid Project0 external-liquidity slot ${slotIndex}`);
|
|
26128
26080
|
}
|
|
26129
|
-
const positionPk = new
|
|
26081
|
+
const positionPk = new import_web344.PublicKey(new Uint8Array(data.slice(8, 40)));
|
|
26130
26082
|
const positionInfo = await connection.getAccountInfo(
|
|
26131
26083
|
positionPk,
|
|
26132
26084
|
"confirmed"
|
|
26133
26085
|
);
|
|
26134
|
-
if (!positionInfo || !positionInfo.owner.equals(new
|
|
26086
|
+
if (!positionInfo || !positionInfo.owner.equals(new import_web344.PublicKey(import_marginfi6.MARGINFI_PROGRAM_ID))) {
|
|
26135
26087
|
throw new Error(
|
|
26136
26088
|
`Invalid Project0 slot-${slotIndex} account: ${positionPk.toBase58()}`
|
|
26137
26089
|
);
|
|
@@ -26180,17 +26132,17 @@ var IdleLiquidityService = class {
|
|
|
26180
26132
|
if (slot.data[0] !== 2) continue;
|
|
26181
26133
|
if (slot.data.length < 40)
|
|
26182
26134
|
throw new Error(`Invalid Kamino external-liquidity slot ${index}`);
|
|
26183
|
-
const key = new
|
|
26184
|
-
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))
|
|
26185
26137
|
throw new Error(`Missing Kamino position in slot ${index}`);
|
|
26186
26138
|
if (seen.has(key.toBase58())) continue;
|
|
26187
26139
|
seen.add(key.toBase58());
|
|
26188
26140
|
const position = await loadWithdrawalPosition({
|
|
26189
26141
|
connection: this.client.provider.connection,
|
|
26190
26142
|
vault,
|
|
26191
|
-
assetMint:
|
|
26143
|
+
assetMint: import_common66.USDC_MINT,
|
|
26192
26144
|
vaultAssetAta,
|
|
26193
|
-
tokenProgram: (0,
|
|
26145
|
+
tokenProgram: (0, import_common66.fromWeb3Pk)(import_spl_token27.TOKEN_PROGRAM_ID),
|
|
26194
26146
|
slot,
|
|
26195
26147
|
index,
|
|
26196
26148
|
requireUsablePosition: true
|
|
@@ -26241,8 +26193,8 @@ var IdleLiquidityService = class {
|
|
|
26241
26193
|
log(`Vault ${vault}: ${reason} \u2014 skipping`);
|
|
26242
26194
|
return { result: { ...empty, status: "no-tvl", reason } };
|
|
26243
26195
|
}
|
|
26244
|
-
const usdc = findHolding2(vaultState,
|
|
26245
|
-
const pst = findHolding2(vaultState,
|
|
26196
|
+
const usdc = findHolding2(vaultState, import_common66.USDC_MINT);
|
|
26197
|
+
const pst = findHolding2(vaultState, import_common66.PST_MINT);
|
|
26246
26198
|
if (!usdc || !pst) {
|
|
26247
26199
|
const reason = `vault has no ${usdc ? "PST" : "USDC"} holding`;
|
|
26248
26200
|
log(`Vault ${vault}: ${reason} \u2014 skipping`);
|
|
@@ -26393,7 +26345,7 @@ var IdleLiquidityService = class {
|
|
|
26393
26345
|
*/
|
|
26394
26346
|
async mintTokenProgram(mint) {
|
|
26395
26347
|
const account = await this.client.provider.connection.getAccountInfo(
|
|
26396
|
-
new
|
|
26348
|
+
new import_web344.PublicKey(mint),
|
|
26397
26349
|
"confirmed"
|
|
26398
26350
|
);
|
|
26399
26351
|
if (!account) throw new Error(`Mint account not found: ${mint}`);
|
|
@@ -26402,7 +26354,7 @@ var IdleLiquidityService = class {
|
|
|
26402
26354
|
`Unsupported token program ${account.owner.toBase58()} for mint ${mint}`
|
|
26403
26355
|
);
|
|
26404
26356
|
}
|
|
26405
|
-
return (0,
|
|
26357
|
+
return (0, import_common66.fromWeb3Pk)(account.owner);
|
|
26406
26358
|
}
|
|
26407
26359
|
/**
|
|
26408
26360
|
* Build, simulate, and (unless `dryRun`) submit the `jupiter_swap`.
|
|
@@ -26422,23 +26374,23 @@ var IdleLiquidityService = class {
|
|
|
26422
26374
|
dryRun,
|
|
26423
26375
|
log
|
|
26424
26376
|
} = params;
|
|
26425
|
-
const signer = (0,
|
|
26377
|
+
const signer = (0, import_common66.fromWeb3Pk)(hwManager.publicKey);
|
|
26426
26378
|
const [sourceTokenProgram, destinationTokenProgram] = await Promise.all([
|
|
26427
|
-
this.mintTokenProgram(
|
|
26428
|
-
this.mintTokenProgram(
|
|
26379
|
+
this.mintTokenProgram(import_common66.PST_MINT),
|
|
26380
|
+
this.mintTokenProgram(import_common66.USDC_MINT)
|
|
26429
26381
|
]);
|
|
26430
26382
|
const jupiterCpi = await jupiter.getSwapCpiData(quote, vault, {
|
|
26431
26383
|
payer: signer
|
|
26432
26384
|
});
|
|
26433
|
-
const { accounts: accounts2, refs, lookupTables } = (0,
|
|
26385
|
+
const { accounts: accounts2, refs, lookupTables } = (0, import_common66.createCpiRefs)([jupiterCpi]);
|
|
26434
26386
|
const vaultTrancheState = coerceBool4(
|
|
26435
26387
|
vaultState.tranchingEnabled
|
|
26436
26388
|
) ? (await this.client.pda.deriveVaultTrancheStatePda(vault))[0] : void 0;
|
|
26437
26389
|
const plan = await this.client.tx.jupiterSwap.getTx({
|
|
26438
26390
|
hwManager: signer,
|
|
26439
26391
|
vault,
|
|
26440
|
-
sourceMint:
|
|
26441
|
-
destinationMint:
|
|
26392
|
+
sourceMint: import_common66.PST_MINT,
|
|
26393
|
+
destinationMint: import_common66.USDC_MINT,
|
|
26442
26394
|
refs,
|
|
26443
26395
|
accounts: accounts2,
|
|
26444
26396
|
sourceTokenProgram,
|
|
@@ -26448,26 +26400,26 @@ var IdleLiquidityService = class {
|
|
|
26448
26400
|
});
|
|
26449
26401
|
const connection = this.client.provider.connection;
|
|
26450
26402
|
const instructions2 = [
|
|
26451
|
-
|
|
26403
|
+
import_web344.ComputeBudgetProgram.setComputeUnitLimit({ units: COMPUTE_UNIT_LIMIT }),
|
|
26452
26404
|
...cuPriceMicroLamports > 0 ? [
|
|
26453
|
-
|
|
26405
|
+
import_web344.ComputeBudgetProgram.setComputeUnitPrice({
|
|
26454
26406
|
microLamports: cuPriceMicroLamports
|
|
26455
26407
|
})
|
|
26456
26408
|
] : [],
|
|
26457
|
-
...(jupiterCpi.preInstructions ?? []).map(
|
|
26458
|
-
...plan.instructions.map(
|
|
26409
|
+
...(jupiterCpi.preInstructions ?? []).map(import_common66.fromKitInstruction),
|
|
26410
|
+
...plan.instructions.map(import_common66.fromKitInstruction)
|
|
26459
26411
|
];
|
|
26460
26412
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
|
|
26461
|
-
const lookupTableAccounts = await (0,
|
|
26413
|
+
const lookupTableAccounts = await (0, import_common66.fetchLookupTables)(
|
|
26462
26414
|
connection,
|
|
26463
26415
|
plan.lookupTables ?? []
|
|
26464
26416
|
);
|
|
26465
|
-
const message2 = new
|
|
26417
|
+
const message2 = new import_web344.TransactionMessage({
|
|
26466
26418
|
payerKey: hwManager.publicKey,
|
|
26467
26419
|
recentBlockhash: blockhash,
|
|
26468
26420
|
instructions: instructions2
|
|
26469
26421
|
}).compileToV0Message(lookupTableAccounts);
|
|
26470
|
-
const transaction = new
|
|
26422
|
+
const transaction = new import_web344.VersionedTransaction(message2);
|
|
26471
26423
|
transaction.sign([hwManager]);
|
|
26472
26424
|
if (!this.client.skipSimulation) {
|
|
26473
26425
|
const simulation = await connection.simulateTransaction(transaction, {
|
|
@@ -26513,9 +26465,9 @@ var IdleLiquidityService = class {
|
|
|
26513
26465
|
|
|
26514
26466
|
// src/services/timelockSettlementService.ts
|
|
26515
26467
|
var import_kit24 = require("@solana/kit");
|
|
26516
|
-
var
|
|
26517
|
-
var
|
|
26518
|
-
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();
|
|
26519
26471
|
var CONSENSUS_SIGNER_CAPACITY = 4;
|
|
26520
26472
|
var CONSENSUS_ENTRY_OFFSET = 40;
|
|
26521
26473
|
var CONSENSUS_ENTRY_SIZE = 272;
|
|
@@ -26555,7 +26507,7 @@ function decodePendingConsensusSigners(data) {
|
|
|
26555
26507
|
const signers = [];
|
|
26556
26508
|
for (let i = 0; i < count; i += 1) {
|
|
26557
26509
|
const start = CONSENSUS_PENDING_OFFSET + i * 32;
|
|
26558
|
-
const signer = new
|
|
26510
|
+
const signer = new import_web345.PublicKey(bytes.slice(start, start + 32)).toBase58();
|
|
26559
26511
|
if (signer === ZERO_PUBKEY) {
|
|
26560
26512
|
throw new Error(`pending consensus signer ${i} is unset`);
|
|
26561
26513
|
}
|
|
@@ -26611,7 +26563,7 @@ var TimelockSettlementService = class {
|
|
|
26611
26563
|
});
|
|
26612
26564
|
const dryRun = opts.dryRun ?? false;
|
|
26613
26565
|
const now = opts.now ?? await this.chainTime();
|
|
26614
|
-
const fulfillerAddress = (0,
|
|
26566
|
+
const fulfillerAddress = (0, import_common67.fromWeb3Pk)(fulfiller.publicKey);
|
|
26615
26567
|
const allVaults = opts.vault ? [
|
|
26616
26568
|
{
|
|
26617
26569
|
publicKey: opts.vault,
|
|
@@ -26755,17 +26707,17 @@ var TimelockSettlementService = class {
|
|
|
26755
26707
|
// src/services/nestWithdrawalService.ts
|
|
26756
26708
|
var import_kit25 = require("@solana/kit");
|
|
26757
26709
|
var import_spl_token28 = require("@solana/spl-token");
|
|
26758
|
-
var
|
|
26759
|
-
var
|
|
26710
|
+
var import_web346 = require("@solana/web3.js");
|
|
26711
|
+
var import_common68 = __toESM(require_dist());
|
|
26760
26712
|
var import_nest3 = __toESM(require_dist4());
|
|
26761
26713
|
var import_nest4 = __toESM(require_dist4());
|
|
26762
|
-
var NestOftProgram = new
|
|
26714
|
+
var NestOftProgram = new import_web346.PublicKey(
|
|
26763
26715
|
"ChEfPd3RzLeYiRwp1K9evimmaFSd6DV1S4Mv5q5Aj1th"
|
|
26764
26716
|
);
|
|
26765
|
-
var NestOftStore = new
|
|
26717
|
+
var NestOftStore = new import_web346.PublicKey(
|
|
26766
26718
|
"k8mJj8Gyw2gFAqut21AFVUUZhxb4RVDMnb4PrSYiDhV"
|
|
26767
26719
|
);
|
|
26768
|
-
var UsdcMint = new
|
|
26720
|
+
var UsdcMint = new import_web346.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
|
|
26769
26721
|
var NestPerenaComposer = Buffer.from(
|
|
26770
26722
|
"000000000000000000000000908dcb5531691c2124c54e30bb645cf11647090d",
|
|
26771
26723
|
"hex"
|
|
@@ -26782,7 +26734,7 @@ async function buildNestWithdrawalRequest(args) {
|
|
|
26782
26734
|
return decodeNestWithdrawalRequest({ ...args, txBase64 });
|
|
26783
26735
|
}
|
|
26784
26736
|
async function decodeNestWithdrawalRequest(args) {
|
|
26785
|
-
const transaction =
|
|
26737
|
+
const transaction = import_web346.VersionedTransaction.deserialize(
|
|
26786
26738
|
Buffer.from(args.txBase64, "base64")
|
|
26787
26739
|
);
|
|
26788
26740
|
const message2 = transaction.message;
|
|
@@ -26803,14 +26755,14 @@ async function decodeNestWithdrawalRequest(args) {
|
|
|
26803
26755
|
return value;
|
|
26804
26756
|
})
|
|
26805
26757
|
);
|
|
26806
|
-
const decoded =
|
|
26758
|
+
const decoded = import_web346.TransactionMessage.decompile(message2, {
|
|
26807
26759
|
addressLookupTableAccounts: tables
|
|
26808
26760
|
});
|
|
26809
|
-
const nestMint = new
|
|
26761
|
+
const nestMint = new import_web346.PublicKey(NEST_RWA_SHARE_MINT);
|
|
26810
26762
|
const sourceAta = (0, import_spl_token28.getAssociatedTokenAddressSync)(nestMint, args.owner, true);
|
|
26811
26763
|
const usdcAta = (0, import_spl_token28.getAssociatedTokenAddressSync)(UsdcMint, args.owner, true);
|
|
26812
26764
|
const instructions2 = decoded.instructions.filter(
|
|
26813
|
-
(ix) => !ix.programId.equals(
|
|
26765
|
+
(ix) => !ix.programId.equals(import_web346.ComputeBudgetProgram.programId)
|
|
26814
26766
|
);
|
|
26815
26767
|
let sends = 0;
|
|
26816
26768
|
for (const ix of instructions2) {
|
|
@@ -26832,7 +26784,7 @@ async function decodeNestWithdrawalRequest(args) {
|
|
|
26832
26784
|
if (sends !== 1)
|
|
26833
26785
|
throw new Error("Nest withdrawal must contain exactly one OFT send");
|
|
26834
26786
|
return {
|
|
26835
|
-
instructions: instructions2.map(
|
|
26787
|
+
instructions: instructions2.map(import_common68.toKitInstruction),
|
|
26836
26788
|
lookupTables: tables.map((table) => (0, import_kit25.address)(table.key.toBase58()))
|
|
26837
26789
|
};
|
|
26838
26790
|
}
|
|
@@ -26840,12 +26792,12 @@ async function decodeNestWithdrawalRequest(args) {
|
|
|
26840
26792
|
// src/services/nestDepositService.ts
|
|
26841
26793
|
var import_kit26 = require("@solana/kit");
|
|
26842
26794
|
var import_spl_token29 = require("@solana/spl-token");
|
|
26843
|
-
var
|
|
26844
|
-
var
|
|
26795
|
+
var import_web347 = require("@solana/web3.js");
|
|
26796
|
+
var import_common69 = __toESM(require_dist());
|
|
26845
26797
|
var import_nest5 = __toESM(require_dist4());
|
|
26846
|
-
var Usdc = new
|
|
26847
|
-
var Messenger = new
|
|
26848
|
-
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(
|
|
26849
26801
|
"CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC"
|
|
26850
26802
|
);
|
|
26851
26803
|
var Router = Buffer.from(
|
|
@@ -26898,7 +26850,7 @@ async function decodeNestDepositRequest(args) {
|
|
|
26898
26850
|
"Nest deposit must be a positive, safely representable USDC base-unit amount"
|
|
26899
26851
|
);
|
|
26900
26852
|
}
|
|
26901
|
-
const message2 =
|
|
26853
|
+
const message2 = import_web347.VersionedTransaction.deserialize(
|
|
26902
26854
|
Buffer.from(args.txBase64, "base64")
|
|
26903
26855
|
).message;
|
|
26904
26856
|
if (!message2.staticAccountKeys[0].equals(args.owner))
|
|
@@ -26913,23 +26865,23 @@ async function decodeNestDepositRequest(args) {
|
|
|
26913
26865
|
return value;
|
|
26914
26866
|
})
|
|
26915
26867
|
);
|
|
26916
|
-
const instructions2 =
|
|
26868
|
+
const instructions2 = import_web347.TransactionMessage.decompile(message2, {
|
|
26917
26869
|
addressLookupTableAccounts: tables
|
|
26918
26870
|
}).instructions;
|
|
26919
|
-
const shareMint = new
|
|
26871
|
+
const shareMint = new import_web347.PublicKey(NEST_RWA_SHARE_MINT);
|
|
26920
26872
|
const shareAta = (0, import_spl_token29.getAssociatedTokenAddressSync)(shareMint, args.owner, true);
|
|
26921
26873
|
const usdcAta = (0, import_spl_token29.getAssociatedTokenAddressSync)(Usdc, args.owner, true);
|
|
26922
26874
|
let burn;
|
|
26923
26875
|
for (const ix of instructions2) {
|
|
26924
|
-
if (ix.programId.equals(
|
|
26876
|
+
if (ix.programId.equals(import_web347.ComputeBudgetProgram.programId)) continue;
|
|
26925
26877
|
if (ix.programId.equals(import_spl_token29.ASSOCIATED_TOKEN_PROGRAM_ID)) {
|
|
26926
|
-
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))
|
|
26927
26879
|
throw new Error("Unexpected Nest deposit token account creation");
|
|
26928
26880
|
continue;
|
|
26929
26881
|
}
|
|
26930
26882
|
const d = ix.data;
|
|
26931
26883
|
const matches = (index, key) => ix.keys[index]?.pubkey.equals(key);
|
|
26932
|
-
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(
|
|
26933
26885
|
(meta, index) => meta.isSigner && ![0, 1, 11].includes(index)
|
|
26934
26886
|
)) {
|
|
26935
26887
|
throw new Error(
|
|
@@ -26955,26 +26907,26 @@ async function decodeNestDepositRequest(args) {
|
|
|
26955
26907
|
shareMint
|
|
26956
26908
|
),
|
|
26957
26909
|
burn
|
|
26958
|
-
].map(
|
|
26910
|
+
].map(import_common69.toKitInstruction),
|
|
26959
26911
|
lookupTables: tables.map((table) => (0, import_kit26.address)(table.key.toBase58())),
|
|
26960
26912
|
ephemeralSignerKeys: [eventKey]
|
|
26961
26913
|
};
|
|
26962
26914
|
}
|
|
26963
26915
|
|
|
26964
26916
|
// src/services/vaultLutManager.ts
|
|
26965
|
-
var
|
|
26917
|
+
var import_web348 = require("@solana/web3.js");
|
|
26966
26918
|
var MAX_LUT_ADDRESSES = 256;
|
|
26967
26919
|
var ACTIVE = (1n << 64n) - 1n;
|
|
26968
26920
|
var asAddress = (key) => key.toBase58();
|
|
26969
26921
|
function uniqueLutAddresses(addresses) {
|
|
26970
|
-
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)));
|
|
26971
26923
|
}
|
|
26972
26924
|
var VaultLutManager = class {
|
|
26973
26925
|
constructor(connection) {
|
|
26974
26926
|
this.connection = connection;
|
|
26975
26927
|
}
|
|
26976
26928
|
async fetch(table) {
|
|
26977
|
-
const account = (await this.connection.getAddressLookupTable(new
|
|
26929
|
+
const account = (await this.connection.getAddressLookupTable(new import_web348.PublicKey(table), {
|
|
26978
26930
|
commitment: "confirmed"
|
|
26979
26931
|
})).value;
|
|
26980
26932
|
if (!account) throw new Error(`Lookup table not found: ${table}`);
|
|
@@ -26986,14 +26938,14 @@ var VaultLutManager = class {
|
|
|
26986
26938
|
* mapping is lost. Also accepts older tables containing the vault elsewhere. */
|
|
26987
26939
|
async findForVault(authority, vault) {
|
|
26988
26940
|
const accounts2 = await this.connection.getProgramAccounts(
|
|
26989
|
-
|
|
26941
|
+
import_web348.AddressLookupTableProgram.programId,
|
|
26990
26942
|
{
|
|
26991
26943
|
commitment: "confirmed",
|
|
26992
26944
|
filters: [{ memcmp: { offset: 22, bytes: authority.toBase58() } }]
|
|
26993
26945
|
}
|
|
26994
26946
|
);
|
|
26995
26947
|
return accounts2.flatMap(({ pubkey: pubkey2, account }) => {
|
|
26996
|
-
const state =
|
|
26948
|
+
const state = import_web348.AddressLookupTableAccount.deserialize(account.data);
|
|
26997
26949
|
return state.deactivationSlot === ACTIVE && state.authority?.equals(authority) && state.addresses.some((a) => a.toBase58() === vault) ? [asAddress(pubkey2)] : [];
|
|
26998
26950
|
});
|
|
26999
26951
|
}
|
|
@@ -27025,7 +26977,7 @@ var VaultLutManager = class {
|
|
|
27025
26977
|
let created = false;
|
|
27026
26978
|
const send = async (instructions2) => {
|
|
27027
26979
|
const { blockhash, lastValidBlockHeight } = await this.connection.getLatestBlockhash("confirmed");
|
|
27028
|
-
const tx = new
|
|
26980
|
+
const tx = new import_web348.Transaction({
|
|
27029
26981
|
feePayer: args.payer.publicKey,
|
|
27030
26982
|
blockhash,
|
|
27031
26983
|
lastValidBlockHeight
|
|
@@ -27052,7 +27004,7 @@ var VaultLutManager = class {
|
|
|
27052
27004
|
};
|
|
27053
27005
|
if (!table) {
|
|
27054
27006
|
const hashes = await this.connection.getAccountInfo(
|
|
27055
|
-
|
|
27007
|
+
import_web348.SYSVAR_SLOT_HASHES_PUBKEY,
|
|
27056
27008
|
"confirmed"
|
|
27057
27009
|
);
|
|
27058
27010
|
if (!hashes || hashes.data.length < 48 || hashes.data.readBigUInt64LE(0) === 0n)
|
|
@@ -27060,7 +27012,7 @@ var VaultLutManager = class {
|
|
|
27060
27012
|
const recentSlot = Number(hashes.data.readBigUInt64LE(8));
|
|
27061
27013
|
if (!Number.isSafeInteger(recentSlot))
|
|
27062
27014
|
throw new Error("Recent slot exceeds safe integer range");
|
|
27063
|
-
const [create, key] =
|
|
27015
|
+
const [create, key] = import_web348.AddressLookupTableProgram.createLookupTable({
|
|
27064
27016
|
authority: authority.publicKey,
|
|
27065
27017
|
payer: args.payer.publicKey,
|
|
27066
27018
|
recentSlot
|
|
@@ -27075,11 +27027,11 @@ var VaultLutManager = class {
|
|
|
27075
27027
|
args.onProgress?.(`Creating vault LUT: ${table}`);
|
|
27076
27028
|
await send([
|
|
27077
27029
|
create,
|
|
27078
|
-
|
|
27030
|
+
import_web348.AddressLookupTableProgram.extendLookupTable({
|
|
27079
27031
|
lookupTable: key,
|
|
27080
27032
|
authority: authority.publicKey,
|
|
27081
27033
|
payer: args.payer.publicKey,
|
|
27082
|
-
addresses: [new
|
|
27034
|
+
addresses: [new import_web348.PublicKey(args.vault)]
|
|
27083
27035
|
})
|
|
27084
27036
|
]);
|
|
27085
27037
|
created = true;
|
|
@@ -27099,11 +27051,11 @@ var VaultLutManager = class {
|
|
|
27099
27051
|
for (let i = 0; i < missing.length; i += 20) {
|
|
27100
27052
|
const batch = missing.slice(i, i + 20);
|
|
27101
27053
|
await send([
|
|
27102
|
-
|
|
27103
|
-
lookupTable: new
|
|
27054
|
+
import_web348.AddressLookupTableProgram.extendLookupTable({
|
|
27055
|
+
lookupTable: new import_web348.PublicKey(table),
|
|
27104
27056
|
authority: authority.publicKey,
|
|
27105
27057
|
payer: args.payer.publicKey,
|
|
27106
|
-
addresses: batch.map((a) => new
|
|
27058
|
+
addresses: batch.map((a) => new import_web348.PublicKey(a))
|
|
27107
27059
|
})
|
|
27108
27060
|
]);
|
|
27109
27061
|
args.onProgress?.(
|
|
@@ -27126,12 +27078,12 @@ var VaultLutManager = class {
|
|
|
27126
27078
|
|
|
27127
27079
|
// src/services/vaultLookupTableAccounts.ts
|
|
27128
27080
|
var import_core26 = require("@anchor-lang/core");
|
|
27129
|
-
var
|
|
27081
|
+
var import_web349 = require("@solana/web3.js");
|
|
27130
27082
|
var import_spl_token30 = require("@solana/spl-token");
|
|
27131
27083
|
var import_marginfi_client_v25 = require("@mrgnlabs/marginfi-client-v2");
|
|
27132
27084
|
var import_Obligation3 = require("@kamino-finance/klend-sdk/dist/@codegen/klend/accounts/Obligation");
|
|
27133
27085
|
var import_Reserve3 = require("@kamino-finance/klend-sdk/dist/@codegen/klend/accounts/Reserve");
|
|
27134
|
-
var
|
|
27086
|
+
var import_common70 = __toESM(require_dist());
|
|
27135
27087
|
var import_marginfi7 = __toESM(require_dist2());
|
|
27136
27088
|
var import_kamino6 = __toESM(require_dist3());
|
|
27137
27089
|
async function collectVaultLookupTableAccounts(client, vault, options = {}) {
|
|
@@ -27149,10 +27101,10 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
|
|
|
27149
27101
|
import_spl_token30.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
27150
27102
|
import_spl_token30.TOKEN_PROGRAM_ID,
|
|
27151
27103
|
import_spl_token30.TOKEN_2022_PROGRAM_ID,
|
|
27152
|
-
|
|
27104
|
+
import_web349.SYSVAR_INSTRUCTIONS_PUBKEY
|
|
27153
27105
|
].forEach(add);
|
|
27154
27106
|
const publicKeys = (value) => {
|
|
27155
|
-
if (value instanceof
|
|
27107
|
+
if (value instanceof import_web349.PublicKey) {
|
|
27156
27108
|
add(value);
|
|
27157
27109
|
return;
|
|
27158
27110
|
}
|
|
@@ -27171,7 +27123,7 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
|
|
|
27171
27123
|
}
|
|
27172
27124
|
];
|
|
27173
27125
|
const tranche = await client.program.account.vaultTrancheState.fetchNullable(
|
|
27174
|
-
new
|
|
27126
|
+
new import_web349.PublicKey(tranchePda)
|
|
27175
27127
|
);
|
|
27176
27128
|
if (tranche) {
|
|
27177
27129
|
publicKeys(tranche.config);
|
|
@@ -27191,30 +27143,30 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
|
|
|
27191
27143
|
);
|
|
27192
27144
|
}
|
|
27193
27145
|
const holdings = state.holdings.filter(
|
|
27194
|
-
(h) => !h.mint.equals(
|
|
27146
|
+
(h) => !h.mint.equals(import_web349.PublicKey.default)
|
|
27195
27147
|
);
|
|
27196
27148
|
for (const h of holdings) {
|
|
27197
27149
|
const mint = h.mint.toBase58(), program = tokenProgramAddressFromIdlEnum(h.tokenProgram);
|
|
27198
27150
|
add(mint);
|
|
27199
27151
|
add(program);
|
|
27200
|
-
add((0,
|
|
27201
|
-
add((0,
|
|
27202
|
-
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));
|
|
27203
27155
|
}
|
|
27204
27156
|
for (const share of shares) {
|
|
27205
27157
|
add(share.mint);
|
|
27206
27158
|
add(share.program);
|
|
27207
|
-
add((0,
|
|
27208
|
-
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));
|
|
27209
27161
|
if (options.user)
|
|
27210
|
-
add((0,
|
|
27162
|
+
add((0, import_common70.getAtaAddress)(share.mint, options.user, share.program, true));
|
|
27211
27163
|
}
|
|
27212
27164
|
const slots = state.externalLiquidity.filter(
|
|
27213
27165
|
(s) => [1, 2].includes(s.data[0])
|
|
27214
27166
|
);
|
|
27215
27167
|
for (const slot of slots) {
|
|
27216
|
-
const position = new
|
|
27217
|
-
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;
|
|
27218
27170
|
add(position);
|
|
27219
27171
|
const info = await connection.getAccountInfo(position, "confirmed");
|
|
27220
27172
|
if (slot.data[0] === 1) {
|
|
@@ -27225,7 +27177,7 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
|
|
|
27225
27177
|
const cpi = new import_marginfi7.CpiClient({ accounts: config }).withdraw_cpi({
|
|
27226
27178
|
marginfiAccount: position.toBase58(),
|
|
27227
27179
|
authority: vault,
|
|
27228
|
-
destinationTokenAccount: (0,
|
|
27180
|
+
destinationTokenAccount: (0, import_common70.getAtaAddress)(
|
|
27229
27181
|
mint,
|
|
27230
27182
|
vault,
|
|
27231
27183
|
config.tokenProgram,
|
|
@@ -27278,7 +27230,7 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
|
|
|
27278
27230
|
if (!reserveKeys.length)
|
|
27279
27231
|
throw new Error(`No reserves found for Kamino obligation ${position}`);
|
|
27280
27232
|
const infos = await connection.getMultipleAccountsInfo(
|
|
27281
|
-
reserveKeys.map((a) => new
|
|
27233
|
+
reserveKeys.map((a) => new import_web349.PublicKey(a)),
|
|
27282
27234
|
"confirmed"
|
|
27283
27235
|
);
|
|
27284
27236
|
const reserves = infos.map((info2, i) => {
|
|
@@ -27308,7 +27260,7 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
|
|
|
27308
27260
|
obligation: position.toBase58(),
|
|
27309
27261
|
reserves,
|
|
27310
27262
|
reserve,
|
|
27311
|
-
destination: (0,
|
|
27263
|
+
destination: (0, import_common70.getAtaAddress)(
|
|
27312
27264
|
reserve.liquidityMint,
|
|
27313
27265
|
vault,
|
|
27314
27266
|
reserve.liquidityTokenProgram,
|
|
@@ -27328,7 +27280,7 @@ async function collectVaultLookupTableAccounts(client, vault, options = {}) {
|
|
|
27328
27280
|
}
|
|
27329
27281
|
|
|
27330
27282
|
// src/index.ts
|
|
27331
|
-
var
|
|
27283
|
+
var import_common71 = __toESM(require_dist());
|
|
27332
27284
|
// Annotate the CommonJS export names for ESM import in node:
|
|
27333
27285
|
0 && (module.exports = {
|
|
27334
27286
|
ASSET_DECIMALS,
|
|
@@ -27521,7 +27473,6 @@ var import_common72 = __toESM(require_dist());
|
|
|
27521
27473
|
defaultKeypairPath,
|
|
27522
27474
|
deleteAccount,
|
|
27523
27475
|
discoverVaultsForSigner,
|
|
27524
|
-
externalWithdrawComputeBudget,
|
|
27525
27476
|
externalWithdrawLookupTables,
|
|
27526
27477
|
fetchExternalPositions,
|
|
27527
27478
|
fetchNestRedemptionQuote,
|
|
@@ -27617,6 +27568,5 @@ var import_common72 = __toESM(require_dist());
|
|
|
27617
27568
|
vaultAuthorityForWallet,
|
|
27618
27569
|
walletReconciliationGuardUpdates,
|
|
27619
27570
|
withDiscoveredYieldAccounts,
|
|
27620
|
-
withVaultLookupTables
|
|
27621
|
-
withdrawalComputeBudget
|
|
27571
|
+
withVaultLookupTables
|
|
27622
27572
|
});
|