@0dotxyz/p0-ts-sdk 2.5.5-alpha.3 → 2.5.5-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +374 -419
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +103 -42
- package/dist/index.d.ts +103 -42
- package/dist/index.js +373 -420
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -20056,12 +20056,8 @@ var NATIVE_STAKE_LUT_KEYS = new Set(
|
|
|
20056
20056
|
Object.values(ADDRESS_LOOKUP_TABLE_FOR_GROUP_NATIVE_STAKE).flat().map((key) => key.toBase58())
|
|
20057
20057
|
);
|
|
20058
20058
|
function selectLutsForBanks(luts, banks) {
|
|
20059
|
-
const nativeStakeLuts = luts.filter(
|
|
20060
|
-
|
|
20061
|
-
);
|
|
20062
|
-
const generalLuts = luts.filter(
|
|
20063
|
-
(lut) => !NATIVE_STAKE_LUT_KEYS.has(lut.key.toBase58())
|
|
20064
|
-
);
|
|
20059
|
+
const nativeStakeLuts = luts.filter((lut) => NATIVE_STAKE_LUT_KEYS.has(lut.key.toBase58()));
|
|
20060
|
+
const generalLuts = luts.filter((lut) => !NATIVE_STAKE_LUT_KEYS.has(lut.key.toBase58()));
|
|
20065
20061
|
const allStakedOrSol = banks.length > 0 && banks.every(
|
|
20066
20062
|
(bank) => bank.config.assetTag === 2 /* STAKED */ || bank.config.assetTag === 1 /* SOL */
|
|
20067
20063
|
);
|
|
@@ -20108,37 +20104,54 @@ async function makeVersionedTransaction(blockhash, transaction, payer, addressLo
|
|
|
20108
20104
|
const versionedMessage = addressLookupTables ? message.compileToV0Message(addressLookupTables) : message.compileToLegacyMessage();
|
|
20109
20105
|
return new VersionedTransaction(versionedMessage);
|
|
20110
20106
|
}
|
|
20107
|
+
function countTxAccountLocks(tx) {
|
|
20108
|
+
const message = tx.message;
|
|
20109
|
+
const lookupKeys = (message.addressTableLookups ?? []).reduce(
|
|
20110
|
+
(count, lookup) => count + lookup.writableIndexes.length + lookup.readonlyIndexes.length,
|
|
20111
|
+
0
|
|
20112
|
+
);
|
|
20113
|
+
return message.staticAccountKeys.length + lookupKeys;
|
|
20114
|
+
}
|
|
20111
20115
|
function splitInstructionsToFitTransactions(mandatoryIxs, ixs, opts) {
|
|
20112
20116
|
const result = [];
|
|
20113
20117
|
let buffer = [];
|
|
20114
|
-
|
|
20118
|
+
const maxSize = MAX_TX_SIZE - (opts.sizeMargin ?? 0);
|
|
20119
|
+
function buildTx(extraIxs) {
|
|
20115
20120
|
const messageV0 = new TransactionMessage({
|
|
20116
|
-
payerKey:
|
|
20117
|
-
recentBlockhash:
|
|
20118
|
-
instructions: [...
|
|
20119
|
-
}).compileToV0Message(
|
|
20121
|
+
payerKey: opts.payerKey,
|
|
20122
|
+
recentBlockhash: opts.blockhash,
|
|
20123
|
+
instructions: [...mandatoryIxs, ...extraIxs]
|
|
20124
|
+
}).compileToV0Message(opts.luts);
|
|
20120
20125
|
return new VersionedTransaction(messageV0);
|
|
20121
20126
|
}
|
|
20127
|
+
function fits(extraIxs) {
|
|
20128
|
+
try {
|
|
20129
|
+
const tx = buildTx(extraIxs);
|
|
20130
|
+
if (getTxSize(tx) > maxSize) return false;
|
|
20131
|
+
if (opts.maxAccountLocks !== void 0 && countTxAccountLocks(tx) > opts.maxAccountLocks) {
|
|
20132
|
+
return false;
|
|
20133
|
+
}
|
|
20134
|
+
return true;
|
|
20135
|
+
} catch {
|
|
20136
|
+
return false;
|
|
20137
|
+
}
|
|
20138
|
+
}
|
|
20122
20139
|
for (const ix of ixs) {
|
|
20123
|
-
|
|
20124
|
-
if (getTxSize(trial) <= MAX_TX_SIZE) {
|
|
20140
|
+
if (fits([...buffer, ix])) {
|
|
20125
20141
|
buffer.push(ix);
|
|
20126
|
-
|
|
20127
|
-
|
|
20128
|
-
|
|
20129
|
-
|
|
20130
|
-
|
|
20131
|
-
|
|
20132
|
-
|
|
20133
|
-
|
|
20134
|
-
|
|
20135
|
-
throw new Error("Single instruction too large to fit in a transaction");
|
|
20136
|
-
}
|
|
20142
|
+
continue;
|
|
20143
|
+
}
|
|
20144
|
+
if (buffer.length === 0) {
|
|
20145
|
+
throw new Error("Single instruction too large to fit in a transaction");
|
|
20146
|
+
}
|
|
20147
|
+
result.push(buildTx(buffer));
|
|
20148
|
+
buffer = [ix];
|
|
20149
|
+
if (!fits(buffer)) {
|
|
20150
|
+
throw new Error("Single instruction too large to fit in a transaction");
|
|
20137
20151
|
}
|
|
20138
20152
|
}
|
|
20139
20153
|
if (buffer.length > 0) {
|
|
20140
|
-
|
|
20141
|
-
result.push(tx);
|
|
20154
|
+
result.push(buildTx(buffer));
|
|
20142
20155
|
}
|
|
20143
20156
|
return result;
|
|
20144
20157
|
}
|
|
@@ -26397,7 +26410,13 @@ BigInt(200);
|
|
|
26397
26410
|
BigInt(82);
|
|
26398
26411
|
|
|
26399
26412
|
// src/services/account/utils/compute/transaction-projection.utils.ts
|
|
26400
|
-
function computeHealthCheckAccounts(
|
|
26413
|
+
function computeHealthCheckAccounts({
|
|
26414
|
+
account,
|
|
26415
|
+
banksMap,
|
|
26416
|
+
mandatoryBanks = [],
|
|
26417
|
+
excludedBanks = []
|
|
26418
|
+
}) {
|
|
26419
|
+
const balances = account.balances;
|
|
26401
26420
|
const activeBalances = balances.filter((b) => b.active);
|
|
26402
26421
|
const mandatoryBanksSet = new Set(mandatoryBanks.map((b) => b.toBase58()));
|
|
26403
26422
|
const excludedBanksSet = new Set(excludedBanks.map((b) => b.toBase58()));
|
|
@@ -26427,7 +26446,11 @@ function computeHealthCheckAccounts(balances, banksMap, mandatoryBanks = [], exc
|
|
|
26427
26446
|
});
|
|
26428
26447
|
return projectedActiveBanks;
|
|
26429
26448
|
}
|
|
26430
|
-
function computeHealthAccountMetas(
|
|
26449
|
+
function computeHealthAccountMetas({
|
|
26450
|
+
banksToInclude,
|
|
26451
|
+
enableSorting = true,
|
|
26452
|
+
trailingBanks = []
|
|
26453
|
+
}) {
|
|
26431
26454
|
let wrapperFn = enableSorting ? composeRemainingAccounts : (banksAndOracles) => banksAndOracles.flat();
|
|
26432
26455
|
const accounts = wrapperFn(banksToInclude.map(computeBankRiskAccountKeys));
|
|
26433
26456
|
for (const bank of trailingBanks) {
|
|
@@ -26457,14 +26480,22 @@ function computeBankRiskAccountKeys(bank) {
|
|
|
26457
26480
|
}
|
|
26458
26481
|
return keys;
|
|
26459
26482
|
}
|
|
26460
|
-
function computeProjectedActiveBanksNoCpi(
|
|
26461
|
-
|
|
26483
|
+
function computeProjectedActiveBanksNoCpi({
|
|
26484
|
+
account,
|
|
26485
|
+
instructions: instructions2,
|
|
26486
|
+
program
|
|
26487
|
+
}) {
|
|
26488
|
+
let projectedBalances = [
|
|
26489
|
+
...account.balances.map((b) => ({ active: b.active, bankPk: b.bankPk }))
|
|
26490
|
+
];
|
|
26462
26491
|
for (let index = 0; index < instructions2.length; index++) {
|
|
26463
26492
|
const ix = instructions2[index];
|
|
26464
26493
|
if (!ix?.programId.equals(program.programId)) continue;
|
|
26465
26494
|
const borshCoder = new BorshInstructionCoder(program.idl);
|
|
26466
26495
|
const decoded = borshCoder.decode(ix.data, "base58");
|
|
26467
26496
|
if (!decoded) continue;
|
|
26497
|
+
const ixMarginfiAccount = ix.keys[1]?.pubkey;
|
|
26498
|
+
if (!ixMarginfiAccount?.equals(account.address)) continue;
|
|
26468
26499
|
const ixArgs = decoded.data;
|
|
26469
26500
|
switch (decoded.name) {
|
|
26470
26501
|
case "lendingAccountBorrow":
|
|
@@ -26512,8 +26543,14 @@ function computeProjectedActiveBanksNoCpi(balances, instructions2, program) {
|
|
|
26512
26543
|
}
|
|
26513
26544
|
return projectedBalances.filter((b) => b.active).map((b) => b.bankPk);
|
|
26514
26545
|
}
|
|
26515
|
-
function computeProjectedActiveBalancesNoCpi(
|
|
26516
|
-
|
|
26546
|
+
function computeProjectedActiveBalancesNoCpi({
|
|
26547
|
+
account,
|
|
26548
|
+
instructions: instructions2,
|
|
26549
|
+
program,
|
|
26550
|
+
banksMap,
|
|
26551
|
+
assetShareValueMultiplierByBank
|
|
26552
|
+
}) {
|
|
26553
|
+
let projectedBalances = account.balances.map((b) => ({
|
|
26517
26554
|
active: b.active,
|
|
26518
26555
|
bankPk: b.bankPk,
|
|
26519
26556
|
assetShares: new BigNumber3(b.assetShares),
|
|
@@ -26530,6 +26567,8 @@ function computeProjectedActiveBalancesNoCpi(balances, instructions2, program, b
|
|
|
26530
26567
|
const borshCoder = new BorshInstructionCoder(program.idl);
|
|
26531
26568
|
const decoded = borshCoder.decode(ix.data, "base58");
|
|
26532
26569
|
if (!decoded) continue;
|
|
26570
|
+
const ixMarginfiAccount = ix.keys[1]?.pubkey;
|
|
26571
|
+
if (!ixMarginfiAccount?.equals(account.address)) continue;
|
|
26533
26572
|
const ixArgs = decoded.data;
|
|
26534
26573
|
switch (decoded.name) {
|
|
26535
26574
|
// Instructions that open or add to a position
|
|
@@ -41539,13 +41578,18 @@ async function makeSetupIx({ connection, authority, tokens }) {
|
|
|
41539
41578
|
return [];
|
|
41540
41579
|
}
|
|
41541
41580
|
}
|
|
41542
|
-
async function makePulseHealthIx2(program,
|
|
41543
|
-
const healthAccounts = computeHealthCheckAccounts(
|
|
41544
|
-
|
|
41581
|
+
async function makePulseHealthIx2(program, marginfiAccount, banks, mandatoryBanks, excludedBanks) {
|
|
41582
|
+
const healthAccounts = computeHealthCheckAccounts({
|
|
41583
|
+
account: marginfiAccount,
|
|
41584
|
+
banksMap: banks,
|
|
41585
|
+
mandatoryBanks,
|
|
41586
|
+
excludedBanks
|
|
41587
|
+
});
|
|
41588
|
+
const accountMetas = computeHealthAccountMetas({ banksToInclude: healthAccounts });
|
|
41545
41589
|
const ix = await instructions_default.makePulseHealthIx(
|
|
41546
41590
|
program,
|
|
41547
41591
|
{
|
|
41548
|
-
marginfiAccount:
|
|
41592
|
+
marginfiAccount: marginfiAccount.address
|
|
41549
41593
|
},
|
|
41550
41594
|
accountMetas.map((account) => ({
|
|
41551
41595
|
pubkey: account,
|
|
@@ -63718,7 +63762,15 @@ async function makeDriftWithdrawIx3({
|
|
|
63718
63762
|
);
|
|
63719
63763
|
withdrawIxs.push(createAtaIdempotentIx);
|
|
63720
63764
|
}
|
|
63721
|
-
const healthAccounts = withdrawAll ? computeHealthCheckAccounts(
|
|
63765
|
+
const healthAccounts = withdrawAll ? computeHealthCheckAccounts({
|
|
63766
|
+
account: marginfiAccount,
|
|
63767
|
+
banksMap: bankMap,
|
|
63768
|
+
excludedBanks: [bank.address]
|
|
63769
|
+
}) : computeHealthCheckAccounts({
|
|
63770
|
+
account: marginfiAccount,
|
|
63771
|
+
banksMap: bankMap,
|
|
63772
|
+
mandatoryBanks: [bank.address]
|
|
63773
|
+
});
|
|
63722
63774
|
const marketIndex = driftSpotMarket.marketIndex;
|
|
63723
63775
|
const driftOracle = driftSpotMarket.oracle;
|
|
63724
63776
|
const { driftState, driftSigner, driftSpotMarketVault } = getAllDerivedDriftAccounts(marketIndex);
|
|
@@ -63728,7 +63780,10 @@ async function makeDriftWithdrawIx3({
|
|
|
63728
63780
|
if (opts.observationBanksOverride) {
|
|
63729
63781
|
remainingAccounts.push(...opts.observationBanksOverride);
|
|
63730
63782
|
} else {
|
|
63731
|
-
const accountMetas = computeHealthAccountMetas(
|
|
63783
|
+
const accountMetas = computeHealthAccountMetas({
|
|
63784
|
+
banksToInclude: healthAccounts,
|
|
63785
|
+
trailingBanks: withdrawAll ? [bank] : []
|
|
63786
|
+
});
|
|
63732
63787
|
remainingAccounts.push(...accountMetas);
|
|
63733
63788
|
}
|
|
63734
63789
|
if (userRewards.length > 2) {
|
|
@@ -63843,19 +63898,7 @@ async function makeDriftWithdrawTx(params) {
|
|
|
63843
63898
|
updateFeedIxs = _updateFeedIxs;
|
|
63844
63899
|
feedLuts = _feedLuts;
|
|
63845
63900
|
}
|
|
63846
|
-
const
|
|
63847
|
-
params.marginfiAccount,
|
|
63848
|
-
params.bankMap,
|
|
63849
|
-
[withdrawIxParams.bank.address],
|
|
63850
|
-
params.bankMetadataMap
|
|
63851
|
-
);
|
|
63852
|
-
const updateDriftMarketIxs = makeUpdateDriftMarketIxs(
|
|
63853
|
-
params.marginfiAccount,
|
|
63854
|
-
params.bankMap,
|
|
63855
|
-
[withdrawIxParams.bank.address],
|
|
63856
|
-
params.bankMetadataMap
|
|
63857
|
-
);
|
|
63858
|
-
const kaminoRefreshIxs = makeRefreshKaminoBanksIxs(
|
|
63901
|
+
const refreshIntegrationIxs = makeRefreshIntegrationBanksIxs(
|
|
63859
63902
|
params.marginfiAccount,
|
|
63860
63903
|
params.bankMap,
|
|
63861
63904
|
[withdrawIxParams.bank.address],
|
|
@@ -63885,23 +63928,13 @@ async function makeDriftWithdrawTx(params) {
|
|
|
63885
63928
|
const withdrawTx = addTransactionMetadata(
|
|
63886
63929
|
new VersionedTransaction(
|
|
63887
63930
|
new TransactionMessage({
|
|
63888
|
-
instructions: [
|
|
63889
|
-
...kaminoRefreshIxs.instructions,
|
|
63890
|
-
...updateDriftMarketIxs.instructions,
|
|
63891
|
-
...updateJupLendRateIxs.instructions,
|
|
63892
|
-
...withdrawIxs.instructions
|
|
63893
|
-
],
|
|
63931
|
+
instructions: [...refreshIntegrationIxs.instructions, ...withdrawIxs.instructions],
|
|
63894
63932
|
payerKey: params.authority,
|
|
63895
63933
|
recentBlockhash: blockhash
|
|
63896
63934
|
}).compileToV0Message(selectedLuts)
|
|
63897
63935
|
),
|
|
63898
63936
|
{
|
|
63899
|
-
signers: [
|
|
63900
|
-
...kaminoRefreshIxs.keys,
|
|
63901
|
-
...updateDriftMarketIxs.keys,
|
|
63902
|
-
...updateJupLendRateIxs.keys,
|
|
63903
|
-
...withdrawIxs.keys
|
|
63904
|
-
],
|
|
63937
|
+
signers: [...refreshIntegrationIxs.keys, ...withdrawIxs.keys],
|
|
63905
63938
|
addressLookupTables: selectedLuts,
|
|
63906
63939
|
type: "WITHDRAW" /* WITHDRAW */
|
|
63907
63940
|
}
|
|
@@ -63937,7 +63970,15 @@ async function makeKaminoWithdrawIx3({
|
|
|
63937
63970
|
);
|
|
63938
63971
|
withdrawIxs.push(createAtaIdempotentIx);
|
|
63939
63972
|
}
|
|
63940
|
-
const healthAccounts = withdrawAll ? computeHealthCheckAccounts(
|
|
63973
|
+
const healthAccounts = withdrawAll ? computeHealthCheckAccounts({
|
|
63974
|
+
account: marginfiAccount,
|
|
63975
|
+
banksMap: bankMap,
|
|
63976
|
+
excludedBanks: [bank.address]
|
|
63977
|
+
}) : computeHealthCheckAccounts({
|
|
63978
|
+
account: marginfiAccount,
|
|
63979
|
+
banksMap: bankMap,
|
|
63980
|
+
mandatoryBanks: [bank.address]
|
|
63981
|
+
});
|
|
63941
63982
|
const lendingMarket = reserve.lendingMarket;
|
|
63942
63983
|
const reserveLiquiditySupply = reserve.liquidity.supplyVault;
|
|
63943
63984
|
const reserveCollateralMint = reserve.collateral.mintPubkey;
|
|
@@ -63957,7 +63998,10 @@ async function makeKaminoWithdrawIx3({
|
|
|
63957
63998
|
if (opts.observationBanksOverride) {
|
|
63958
63999
|
remainingAccounts.push(...opts.observationBanksOverride);
|
|
63959
64000
|
} else {
|
|
63960
|
-
const accountMetas = computeHealthAccountMetas(
|
|
64001
|
+
const accountMetas = computeHealthAccountMetas({
|
|
64002
|
+
banksToInclude: healthAccounts,
|
|
64003
|
+
trailingBanks: withdrawAll ? [bank] : []
|
|
64004
|
+
});
|
|
63961
64005
|
remainingAccounts.push(...accountMetas);
|
|
63962
64006
|
}
|
|
63963
64007
|
const withdrawIx = isSync ? sync_instructions_default.makeKaminoWithdrawIx(
|
|
@@ -64052,7 +64096,15 @@ async function makeWithdrawIx3({
|
|
|
64052
64096
|
);
|
|
64053
64097
|
withdrawIxs.push(createAtaIdempotentIx);
|
|
64054
64098
|
}
|
|
64055
|
-
const healthAccounts = withdrawAll ? computeHealthCheckAccounts(
|
|
64099
|
+
const healthAccounts = withdrawAll ? computeHealthCheckAccounts({
|
|
64100
|
+
account: marginfiAccount,
|
|
64101
|
+
banksMap: bankMap,
|
|
64102
|
+
excludedBanks: [bank.address]
|
|
64103
|
+
}) : computeHealthCheckAccounts({
|
|
64104
|
+
account: marginfiAccount,
|
|
64105
|
+
banksMap: bankMap,
|
|
64106
|
+
mandatoryBanks: [bank.address]
|
|
64107
|
+
});
|
|
64056
64108
|
const remainingAccounts = [];
|
|
64057
64109
|
if (tokenProgram.equals(TOKEN_2022_PROGRAM_ID)) {
|
|
64058
64110
|
remainingAccounts.push(bank.mint);
|
|
@@ -64060,7 +64112,10 @@ async function makeWithdrawIx3({
|
|
|
64060
64112
|
if (opts.observationBanksOverride) {
|
|
64061
64113
|
remainingAccounts.push(...opts.observationBanksOverride);
|
|
64062
64114
|
} else {
|
|
64063
|
-
const accountMetas = computeHealthAccountMetas(
|
|
64115
|
+
const accountMetas = computeHealthAccountMetas({
|
|
64116
|
+
banksToInclude: healthAccounts,
|
|
64117
|
+
trailingBanks: withdrawAll ? [bank] : []
|
|
64118
|
+
});
|
|
64064
64119
|
remainingAccounts.push(...accountMetas);
|
|
64065
64120
|
}
|
|
64066
64121
|
const withdrawIx = isSync ? sync_instructions_default.makeWithdrawIx(
|
|
@@ -64133,19 +64188,7 @@ async function makeWithdrawTx(params) {
|
|
|
64133
64188
|
updateFeedIxs = _updateFeedIxs;
|
|
64134
64189
|
feedLuts = _feedLuts;
|
|
64135
64190
|
}
|
|
64136
|
-
const
|
|
64137
|
-
params.marginfiAccount,
|
|
64138
|
-
params.bankMap,
|
|
64139
|
-
[withdrawIxParams.bank.address],
|
|
64140
|
-
params.bankMetadataMap
|
|
64141
|
-
);
|
|
64142
|
-
const updateDriftMarketIxs = makeUpdateDriftMarketIxs(
|
|
64143
|
-
params.marginfiAccount,
|
|
64144
|
-
params.bankMap,
|
|
64145
|
-
[withdrawIxParams.bank.address],
|
|
64146
|
-
params.bankMetadataMap
|
|
64147
|
-
);
|
|
64148
|
-
const refreshIxs = makeRefreshKaminoBanksIxs(
|
|
64191
|
+
const refreshIntegrationIxs = makeRefreshIntegrationBanksIxs(
|
|
64149
64192
|
params.marginfiAccount,
|
|
64150
64193
|
params.bankMap,
|
|
64151
64194
|
[withdrawIxParams.bank.address],
|
|
@@ -64175,23 +64218,13 @@ async function makeWithdrawTx(params) {
|
|
|
64175
64218
|
const withdrawTx = addTransactionMetadata(
|
|
64176
64219
|
new VersionedTransaction(
|
|
64177
64220
|
new TransactionMessage({
|
|
64178
|
-
instructions: [
|
|
64179
|
-
...refreshIxs.instructions,
|
|
64180
|
-
...updateDriftMarketIxs.instructions,
|
|
64181
|
-
...updateJupLendRateIxs.instructions,
|
|
64182
|
-
...withdrawIxs.instructions
|
|
64183
|
-
],
|
|
64221
|
+
instructions: [...refreshIntegrationIxs.instructions, ...withdrawIxs.instructions],
|
|
64184
64222
|
payerKey: params.authority,
|
|
64185
64223
|
recentBlockhash: blockhash
|
|
64186
64224
|
}).compileToV0Message(selectedLuts)
|
|
64187
64225
|
),
|
|
64188
64226
|
{
|
|
64189
|
-
signers: [
|
|
64190
|
-
...refreshIxs.keys,
|
|
64191
|
-
...updateDriftMarketIxs.keys,
|
|
64192
|
-
...updateJupLendRateIxs.keys,
|
|
64193
|
-
...withdrawIxs.keys
|
|
64194
|
-
],
|
|
64227
|
+
signers: [...refreshIntegrationIxs.keys, ...withdrawIxs.keys],
|
|
64195
64228
|
addressLookupTables: selectedLuts,
|
|
64196
64229
|
type: "WITHDRAW" /* WITHDRAW */
|
|
64197
64230
|
}
|
|
@@ -64213,19 +64246,7 @@ async function makeKaminoWithdrawTx(params) {
|
|
|
64213
64246
|
const { value: amountValue, type: amountType } = resolveAmount(amount);
|
|
64214
64247
|
const multiplier = assetShareValueMultiplierByBank.get(withdrawIxParams.bank.address.toBase58()) ?? new BigNumber(1);
|
|
64215
64248
|
const adjustedAmount = amountType === "cToken" ? new BigNumber(amountValue).toNumber() : new BigNumber(amountValue).div(multiplier).toNumber();
|
|
64216
|
-
const
|
|
64217
|
-
params.marginfiAccount,
|
|
64218
|
-
params.bankMap,
|
|
64219
|
-
[withdrawIxParams.bank.address],
|
|
64220
|
-
params.bankMetadataMap
|
|
64221
|
-
);
|
|
64222
|
-
const refreshIxs = makeRefreshKaminoBanksIxs(
|
|
64223
|
-
params.marginfiAccount,
|
|
64224
|
-
params.bankMap,
|
|
64225
|
-
[withdrawIxParams.bank.address],
|
|
64226
|
-
params.bankMetadataMap
|
|
64227
|
-
);
|
|
64228
|
-
const updateDriftMarketIxs = makeUpdateDriftMarketIxs(
|
|
64249
|
+
const refreshIntegrationIxs = makeRefreshIntegrationBanksIxs(
|
|
64229
64250
|
params.marginfiAccount,
|
|
64230
64251
|
params.bankMap,
|
|
64231
64252
|
[withdrawIxParams.bank.address],
|
|
@@ -64269,23 +64290,13 @@ async function makeKaminoWithdrawTx(params) {
|
|
|
64269
64290
|
const withdrawTx = addTransactionMetadata(
|
|
64270
64291
|
new VersionedTransaction(
|
|
64271
64292
|
new TransactionMessage({
|
|
64272
|
-
instructions: [
|
|
64273
|
-
...refreshIxs.instructions,
|
|
64274
|
-
...updateDriftMarketIxs.instructions,
|
|
64275
|
-
...updateJupLendRateIxs.instructions,
|
|
64276
|
-
...withdrawIxs.instructions
|
|
64277
|
-
],
|
|
64293
|
+
instructions: [...refreshIntegrationIxs.instructions, ...withdrawIxs.instructions],
|
|
64278
64294
|
payerKey: params.authority,
|
|
64279
64295
|
recentBlockhash: blockhash
|
|
64280
64296
|
}).compileToV0Message(selectedLuts)
|
|
64281
64297
|
),
|
|
64282
64298
|
{
|
|
64283
|
-
signers: [
|
|
64284
|
-
...refreshIxs.keys,
|
|
64285
|
-
...updateDriftMarketIxs.keys,
|
|
64286
|
-
...updateJupLendRateIxs.keys,
|
|
64287
|
-
...withdrawIxs.keys
|
|
64288
|
-
],
|
|
64299
|
+
signers: [...refreshIntegrationIxs.keys, ...withdrawIxs.keys],
|
|
64289
64300
|
addressLookupTables: selectedLuts,
|
|
64290
64301
|
type: "WITHDRAW" /* WITHDRAW */
|
|
64291
64302
|
}
|
|
@@ -64320,7 +64331,15 @@ async function makeJuplendWithdrawIx2({
|
|
|
64320
64331
|
);
|
|
64321
64332
|
withdrawIxs.push(createAtaIdempotentIx);
|
|
64322
64333
|
}
|
|
64323
|
-
const healthAccounts = withdrawAll ? computeHealthCheckAccounts(
|
|
64334
|
+
const healthAccounts = withdrawAll ? computeHealthCheckAccounts({
|
|
64335
|
+
account: marginfiAccount,
|
|
64336
|
+
banksMap: bankMap,
|
|
64337
|
+
excludedBanks: [bank.address]
|
|
64338
|
+
}) : computeHealthCheckAccounts({
|
|
64339
|
+
account: marginfiAccount,
|
|
64340
|
+
banksMap: bankMap,
|
|
64341
|
+
mandatoryBanks: [bank.address]
|
|
64342
|
+
});
|
|
64324
64343
|
if (!bank.jupLendIntegrationAccounts) {
|
|
64325
64344
|
throw new Error("Bank has no JupLend integration accounts");
|
|
64326
64345
|
}
|
|
@@ -64333,7 +64352,10 @@ async function makeJuplendWithdrawIx2({
|
|
|
64333
64352
|
if (opts.observationBanksOverride) {
|
|
64334
64353
|
remainingAccounts.push(...opts.observationBanksOverride);
|
|
64335
64354
|
} else {
|
|
64336
|
-
const accountMetas = computeHealthAccountMetas(
|
|
64355
|
+
const accountMetas = computeHealthAccountMetas({
|
|
64356
|
+
banksToInclude: healthAccounts,
|
|
64357
|
+
trailingBanks: withdrawAll ? [bank] : []
|
|
64358
|
+
});
|
|
64337
64359
|
remainingAccounts.push(...accountMetas);
|
|
64338
64360
|
}
|
|
64339
64361
|
const withdrawIx = await instructions_default.makeJuplendWithdrawIx(
|
|
@@ -64407,19 +64429,7 @@ async function makeJuplendWithdrawTx(params) {
|
|
|
64407
64429
|
updateFeedIxs = _updateFeedIxs;
|
|
64408
64430
|
feedLuts = _feedLuts;
|
|
64409
64431
|
}
|
|
64410
|
-
const
|
|
64411
|
-
params.marginfiAccount,
|
|
64412
|
-
params.bankMap,
|
|
64413
|
-
[withdrawIxParams.bank.address],
|
|
64414
|
-
params.bankMetadataMap
|
|
64415
|
-
);
|
|
64416
|
-
const updateDriftMarketIxs = makeUpdateDriftMarketIxs(
|
|
64417
|
-
params.marginfiAccount,
|
|
64418
|
-
params.bankMap,
|
|
64419
|
-
[withdrawIxParams.bank.address],
|
|
64420
|
-
params.bankMetadataMap
|
|
64421
|
-
);
|
|
64422
|
-
const refreshIxs = makeRefreshKaminoBanksIxs(
|
|
64432
|
+
const refreshIntegrationIxs = makeRefreshIntegrationBanksIxs(
|
|
64423
64433
|
params.marginfiAccount,
|
|
64424
64434
|
params.bankMap,
|
|
64425
64435
|
[withdrawIxParams.bank.address],
|
|
@@ -64449,18 +64459,13 @@ async function makeJuplendWithdrawTx(params) {
|
|
|
64449
64459
|
const withdrawTx = addTransactionMetadata(
|
|
64450
64460
|
new VersionedTransaction(
|
|
64451
64461
|
new TransactionMessage({
|
|
64452
|
-
instructions: [
|
|
64453
|
-
...refreshIxs.instructions,
|
|
64454
|
-
...updateDriftMarketIxs.instructions,
|
|
64455
|
-
...updateJupLendRateIxs.instructions,
|
|
64456
|
-
...withdrawIxs.instructions
|
|
64457
|
-
],
|
|
64462
|
+
instructions: [...refreshIntegrationIxs.instructions, ...withdrawIxs.instructions],
|
|
64458
64463
|
payerKey: params.authority,
|
|
64459
64464
|
recentBlockhash: blockhash
|
|
64460
64465
|
}).compileToV0Message(selectedLuts)
|
|
64461
64466
|
),
|
|
64462
64467
|
{
|
|
64463
|
-
signers: [...
|
|
64468
|
+
signers: [...refreshIntegrationIxs.keys, ...withdrawIxs.keys],
|
|
64464
64469
|
addressLookupTables: selectedLuts,
|
|
64465
64470
|
type: "WITHDRAW" /* WITHDRAW */
|
|
64466
64471
|
}
|
|
@@ -64494,12 +64499,11 @@ async function makeBorrowIx3({
|
|
|
64494
64499
|
borrowIxs.push(createAtaIdempotentIx);
|
|
64495
64500
|
}
|
|
64496
64501
|
const mandatoryBanks = [bank.address, ...opts.additionalHealthCheckBanks ?? []];
|
|
64497
|
-
const healthAccounts = computeHealthCheckAccounts(
|
|
64498
|
-
marginfiAccount
|
|
64499
|
-
bankMap,
|
|
64500
|
-
mandatoryBanks
|
|
64501
|
-
|
|
64502
|
-
);
|
|
64502
|
+
const healthAccounts = computeHealthCheckAccounts({
|
|
64503
|
+
account: marginfiAccount,
|
|
64504
|
+
banksMap: bankMap,
|
|
64505
|
+
mandatoryBanks
|
|
64506
|
+
});
|
|
64503
64507
|
const remainingAccounts = [];
|
|
64504
64508
|
if (tokenProgram.equals(TOKEN_2022_PROGRAM_ID)) {
|
|
64505
64509
|
remainingAccounts.push(bank.mint);
|
|
@@ -64507,7 +64511,7 @@ async function makeBorrowIx3({
|
|
|
64507
64511
|
if (opts?.observationBanksOverride) {
|
|
64508
64512
|
remainingAccounts.push(...opts.observationBanksOverride);
|
|
64509
64513
|
} else {
|
|
64510
|
-
const accountMetas = computeHealthAccountMetas(healthAccounts);
|
|
64514
|
+
const accountMetas = computeHealthAccountMetas({ banksToInclude: healthAccounts });
|
|
64511
64515
|
remainingAccounts.push(...accountMetas);
|
|
64512
64516
|
}
|
|
64513
64517
|
const borrowIx = isSync ? sync_instructions_default.makeBorrowIx(
|
|
@@ -64561,19 +64565,7 @@ async function makeBorrowTx(params) {
|
|
|
64561
64565
|
params.bankMap,
|
|
64562
64566
|
borrowIxParams.opts?.additionalHealthCheckBanks
|
|
64563
64567
|
);
|
|
64564
|
-
const
|
|
64565
|
-
params.marginfiAccount,
|
|
64566
|
-
params.bankMap,
|
|
64567
|
-
[borrowIxParams.bank.address],
|
|
64568
|
-
params.bankMetadataMap
|
|
64569
|
-
);
|
|
64570
|
-
const updateDriftMarketIxs = makeUpdateDriftMarketIxs(
|
|
64571
|
-
params.marginfiAccount,
|
|
64572
|
-
params.bankMap,
|
|
64573
|
-
[borrowIxParams.bank.address],
|
|
64574
|
-
params.bankMetadataMap
|
|
64575
|
-
);
|
|
64576
|
-
const kaminoRefreshIxs = makeRefreshKaminoBanksIxs(
|
|
64568
|
+
const refreshIntegrationIxs = makeRefreshIntegrationBanksIxs(
|
|
64577
64569
|
params.marginfiAccount,
|
|
64578
64570
|
params.bankMap,
|
|
64579
64571
|
[borrowIxParams.bank.address],
|
|
@@ -64614,18 +64606,13 @@ async function makeBorrowTx(params) {
|
|
|
64614
64606
|
const borrowTx = addTransactionMetadata(
|
|
64615
64607
|
new VersionedTransaction(
|
|
64616
64608
|
new TransactionMessage({
|
|
64617
|
-
instructions: [
|
|
64618
|
-
...kaminoRefreshIxs.instructions,
|
|
64619
|
-
...updateDriftMarketIxs.instructions,
|
|
64620
|
-
...updateJupLendRateIxs.instructions,
|
|
64621
|
-
...borrowIxs.instructions
|
|
64622
|
-
],
|
|
64609
|
+
instructions: [...refreshIntegrationIxs.instructions, ...borrowIxs.instructions],
|
|
64623
64610
|
payerKey: params.authority,
|
|
64624
64611
|
recentBlockhash: blockhash
|
|
64625
64612
|
}).compileToV0Message(selectedLuts)
|
|
64626
64613
|
),
|
|
64627
64614
|
{
|
|
64628
|
-
signers: [...
|
|
64615
|
+
signers: [...refreshIntegrationIxs.keys, ...borrowIxs.keys],
|
|
64629
64616
|
addressLookupTables: selectedLuts,
|
|
64630
64617
|
type: "BORROW" /* BORROW */
|
|
64631
64618
|
}
|
|
@@ -66129,7 +66116,7 @@ async function makeBeginFlashLoanIx3(program, marginfiAccountPk, endIndex, autho
|
|
|
66129
66116
|
return { instructions: [ix], keys: [] };
|
|
66130
66117
|
}
|
|
66131
66118
|
async function makeEndFlashLoanIx3(program, marginfiAccountPk, projectedActiveBanks, authority, isSync) {
|
|
66132
|
-
const remainingAccounts = computeHealthAccountMetas(projectedActiveBanks);
|
|
66119
|
+
const remainingAccounts = computeHealthAccountMetas({ banksToInclude: projectedActiveBanks });
|
|
66133
66120
|
const ix = isSync && authority ? sync_instructions_default.makeEndFlashLoanIx(
|
|
66134
66121
|
program.programId,
|
|
66135
66122
|
{
|
|
@@ -66166,11 +66153,11 @@ async function makeFlashLoanTx({
|
|
|
66166
66153
|
isSync
|
|
66167
66154
|
}) {
|
|
66168
66155
|
const endIndex = ixs.length + 1;
|
|
66169
|
-
const projectedActiveBanksKeys = computeProjectedActiveBanksNoCpi(
|
|
66170
|
-
marginfiAccount
|
|
66171
|
-
ixs,
|
|
66156
|
+
const projectedActiveBanksKeys = computeProjectedActiveBanksNoCpi({
|
|
66157
|
+
account: marginfiAccount,
|
|
66158
|
+
instructions: ixs,
|
|
66172
66159
|
program
|
|
66173
|
-
);
|
|
66160
|
+
});
|
|
66174
66161
|
const projectedActiveBanks = projectedActiveBanksKeys.map((account) => {
|
|
66175
66162
|
const b = bankMap.get(account.toBase58());
|
|
66176
66163
|
if (!b) throw Error(`Bank ${account.toBase58()} not found, in makeFlashLoanTx function`);
|
|
@@ -66299,23 +66286,12 @@ async function makeRepayWithCollatTx(params) {
|
|
|
66299
66286
|
}
|
|
66300
66287
|
]
|
|
66301
66288
|
});
|
|
66302
|
-
const
|
|
66289
|
+
const refreshIntegrationIxs = makeRefreshIntegrationBanksIxs(
|
|
66303
66290
|
marginfiAccount,
|
|
66304
66291
|
bankMap,
|
|
66305
66292
|
[withdrawOpts.withdrawBank.address],
|
|
66306
|
-
bankMetadataMap
|
|
66307
|
-
|
|
66308
|
-
const updateDriftMarketIxs = makeUpdateDriftMarketIxs(
|
|
66309
|
-
marginfiAccount,
|
|
66310
|
-
bankMap,
|
|
66311
|
-
[withdrawOpts.withdrawBank.address],
|
|
66312
|
-
bankMetadataMap
|
|
66313
|
-
);
|
|
66314
|
-
const kaminoRefreshIxs = makeRefreshKaminoBanksIxs(
|
|
66315
|
-
marginfiAccount,
|
|
66316
|
-
bankMap,
|
|
66317
|
-
[withdrawOpts.withdrawBank.address, repayOpts.repayBank.address],
|
|
66318
|
-
bankMetadataMap
|
|
66293
|
+
bankMetadataMap,
|
|
66294
|
+
[withdrawOpts.withdrawBank.address, repayOpts.repayBank.address]
|
|
66319
66295
|
);
|
|
66320
66296
|
const { flashloanTx, setupInstructions, swapQuote, amountToRepay, withdrawIxs, repayIxs } = await buildRepayWithCollatFlashloanTx({
|
|
66321
66297
|
...params,
|
|
@@ -66345,13 +66321,8 @@ async function makeRepayWithCollatTx(params) {
|
|
|
66345
66321
|
crossbarUrl
|
|
66346
66322
|
});
|
|
66347
66323
|
let additionalTxs = [];
|
|
66348
|
-
if (setupIxs.length > 0 ||
|
|
66349
|
-
const ixs = [
|
|
66350
|
-
...setupIxs,
|
|
66351
|
-
...kaminoRefreshIxs.instructions,
|
|
66352
|
-
...updateDriftMarketIxs.instructions,
|
|
66353
|
-
...updateJuplendMarketIxs.instructions
|
|
66354
|
-
];
|
|
66324
|
+
if (setupIxs.length > 0 || refreshIntegrationIxs.instructions.length > 0) {
|
|
66325
|
+
const ixs = [...setupIxs, ...refreshIntegrationIxs.instructions];
|
|
66355
66326
|
const txs = splitInstructionsToFitTransactions([], ixs, {
|
|
66356
66327
|
blockhash,
|
|
66357
66328
|
payerKey: marginfiAccount.authority,
|
|
@@ -66789,11 +66760,11 @@ function computeFlashLoanNonSwapBudget({
|
|
|
66789
66760
|
bankMap,
|
|
66790
66761
|
addressLookupTableAccounts
|
|
66791
66762
|
}) {
|
|
66792
|
-
const projectedActiveBanksKeys = computeProjectedActiveBanksNoCpi(
|
|
66793
|
-
marginfiAccount
|
|
66794
|
-
ixs,
|
|
66763
|
+
const projectedActiveBanksKeys = computeProjectedActiveBanksNoCpi({
|
|
66764
|
+
account: marginfiAccount,
|
|
66765
|
+
instructions: ixs,
|
|
66795
66766
|
program
|
|
66796
|
-
);
|
|
66767
|
+
});
|
|
66797
66768
|
const projectedActiveBanks = projectedActiveBanksKeys.map((key) => {
|
|
66798
66769
|
const b = bankMap.get(key.toBase58());
|
|
66799
66770
|
if (!b) throw new Error(`Bank ${key.toBase58()} not found in computeFlashLoanNonSwapBudget`);
|
|
@@ -66805,7 +66776,9 @@ function computeFlashLoanNonSwapBudget({
|
|
|
66805
66776
|
{ marginfiAccount: marginfiAccount.address, authority: marginfiAccount.authority },
|
|
66806
66777
|
{ endIndex: new BN9(endIndex) }
|
|
66807
66778
|
);
|
|
66808
|
-
const endFlRemainingAccounts = computeHealthAccountMetas(
|
|
66779
|
+
const endFlRemainingAccounts = computeHealthAccountMetas({
|
|
66780
|
+
banksToInclude: projectedActiveBanks
|
|
66781
|
+
});
|
|
66809
66782
|
const endFlIx = sync_instructions_default.makeEndFlashLoanIx(
|
|
66810
66783
|
program.programId,
|
|
66811
66784
|
{ marginfiAccount: marginfiAccount.address, authority: marginfiAccount.authority },
|
|
@@ -67266,23 +67239,12 @@ async function makeLoopTx(params) {
|
|
|
67266
67239
|
}
|
|
67267
67240
|
]
|
|
67268
67241
|
});
|
|
67269
|
-
const
|
|
67270
|
-
params.marginfiAccount,
|
|
67271
|
-
params.bankMap,
|
|
67272
|
-
[depositOpts.depositBank.address],
|
|
67273
|
-
params.bankMetadataMap
|
|
67274
|
-
);
|
|
67275
|
-
const updateDriftMarketIxs = makeUpdateDriftMarketIxs(
|
|
67242
|
+
const refreshIntegrationIxs = makeRefreshIntegrationBanksIxs(
|
|
67276
67243
|
params.marginfiAccount,
|
|
67277
67244
|
params.bankMap,
|
|
67278
67245
|
[depositOpts.depositBank.address],
|
|
67279
|
-
params.bankMetadataMap
|
|
67280
|
-
|
|
67281
|
-
const kaminoRefreshIxs = makeRefreshKaminoBanksIxs(
|
|
67282
|
-
marginfiAccount,
|
|
67283
|
-
bankMap,
|
|
67284
|
-
[borrowOpts.borrowBank.address, depositOpts.depositBank.address],
|
|
67285
|
-
bankMetadataMap
|
|
67246
|
+
params.bankMetadataMap,
|
|
67247
|
+
[borrowOpts.borrowBank.address, depositOpts.depositBank.address]
|
|
67286
67248
|
);
|
|
67287
67249
|
const { flashloanTx, setupInstructions, swapQuote, depositIxs, borrowIxs } = await buildLoopFlashloanTx({
|
|
67288
67250
|
...params,
|
|
@@ -67317,14 +67279,8 @@ async function makeLoopTx(params) {
|
|
|
67317
67279
|
...makeWrapSolIxs(marginfiAccount.authority, new BigNumber(depositOpts.inputDepositAmount))
|
|
67318
67280
|
);
|
|
67319
67281
|
}
|
|
67320
|
-
if (setupIxs.length > 0 || additionalIxs.length > 0 ||
|
|
67321
|
-
const ixs = [
|
|
67322
|
-
...additionalIxs,
|
|
67323
|
-
...setupIxs,
|
|
67324
|
-
...kaminoRefreshIxs.instructions,
|
|
67325
|
-
...updateDriftMarketIxs.instructions,
|
|
67326
|
-
...updateJupLendRateIxs.instructions
|
|
67327
|
-
];
|
|
67282
|
+
if (setupIxs.length > 0 || additionalIxs.length > 0 || refreshIntegrationIxs.instructions.length > 0) {
|
|
67283
|
+
const ixs = [...additionalIxs, ...setupIxs, ...refreshIntegrationIxs.instructions];
|
|
67328
67284
|
const txs = splitInstructionsToFitTransactions([], ixs, {
|
|
67329
67285
|
blockhash,
|
|
67330
67286
|
payerKey: marginfiAccount.authority,
|
|
@@ -67476,7 +67432,9 @@ async function buildLoopNonSwapIxs(params) {
|
|
|
67476
67432
|
const innerIxs = [...innerIxsBeforeSwap, ...depositIxs.instructions];
|
|
67477
67433
|
const depositIxIndex = innerIxs.findIndex(isDepositIx);
|
|
67478
67434
|
if (depositIxIndex < 0) {
|
|
67479
|
-
throw new Error(
|
|
67435
|
+
throw new Error(
|
|
67436
|
+
"buildLoopNonSwapIxs: could not locate deposit instruction for amount patching"
|
|
67437
|
+
);
|
|
67480
67438
|
}
|
|
67481
67439
|
const descriptor = {
|
|
67482
67440
|
innerIxs,
|
|
@@ -67687,19 +67645,7 @@ async function makeSwapCollateralTx(params) {
|
|
|
67687
67645
|
{ mint: depositOpts.depositBank.mint, tokenProgram: depositOpts.tokenProgram }
|
|
67688
67646
|
]
|
|
67689
67647
|
});
|
|
67690
|
-
const
|
|
67691
|
-
params.marginfiAccount,
|
|
67692
|
-
params.bankMap,
|
|
67693
|
-
[depositOpts.depositBank.address],
|
|
67694
|
-
params.bankMetadataMap
|
|
67695
|
-
);
|
|
67696
|
-
const updateDriftMarketIxs = makeUpdateDriftMarketIxs(
|
|
67697
|
-
marginfiAccount,
|
|
67698
|
-
bankMap,
|
|
67699
|
-
[withdrawOpts.withdrawBank.address],
|
|
67700
|
-
bankMetadataMap
|
|
67701
|
-
);
|
|
67702
|
-
const kaminoRefreshIxs = makeRefreshKaminoBanksIxs(
|
|
67648
|
+
const refreshIntegrationIxs = makeRefreshIntegrationBanksIxs(
|
|
67703
67649
|
marginfiAccount,
|
|
67704
67650
|
bankMap,
|
|
67705
67651
|
[withdrawOpts.withdrawBank.address, depositOpts.depositBank.address],
|
|
@@ -67733,13 +67679,8 @@ async function makeSwapCollateralTx(params) {
|
|
|
67733
67679
|
crossbarUrl
|
|
67734
67680
|
});
|
|
67735
67681
|
let additionalTxs = [];
|
|
67736
|
-
if (setupIxs.length > 0 ||
|
|
67737
|
-
const ixs = [
|
|
67738
|
-
...setupIxs,
|
|
67739
|
-
...kaminoRefreshIxs.instructions,
|
|
67740
|
-
...updateDriftMarketIxs.instructions,
|
|
67741
|
-
...updateJupLendRateIxs.instructions
|
|
67742
|
-
];
|
|
67682
|
+
if (setupIxs.length > 0 || refreshIntegrationIxs.instructions.length > 0) {
|
|
67683
|
+
const ixs = [...setupIxs, ...refreshIntegrationIxs.instructions];
|
|
67743
67684
|
const txs = splitInstructionsToFitTransactions([], ixs, {
|
|
67744
67685
|
blockhash,
|
|
67745
67686
|
payerKey: marginfiAccount.authority,
|
|
@@ -68128,23 +68069,12 @@ async function makeSwapDebtTx(params) {
|
|
|
68128
68069
|
{ mint: borrowOpts.borrowBank.mint, tokenProgram: borrowOpts.tokenProgram }
|
|
68129
68070
|
]
|
|
68130
68071
|
});
|
|
68131
|
-
const
|
|
68132
|
-
params.marginfiAccount,
|
|
68133
|
-
params.bankMap,
|
|
68134
|
-
[],
|
|
68135
|
-
params.bankMetadataMap
|
|
68136
|
-
);
|
|
68137
|
-
const updateDriftMarketIxs = makeUpdateDriftMarketIxs(
|
|
68072
|
+
const refreshIntegrationIxs = makeRefreshIntegrationBanksIxs(
|
|
68138
68073
|
marginfiAccount,
|
|
68139
68074
|
bankMap,
|
|
68140
68075
|
[],
|
|
68141
|
-
bankMetadataMap
|
|
68142
|
-
|
|
68143
|
-
const kaminoRefreshIxs = makeRefreshKaminoBanksIxs(
|
|
68144
|
-
marginfiAccount,
|
|
68145
|
-
bankMap,
|
|
68146
|
-
[repayOpts.repayBank.address, borrowOpts.borrowBank.address],
|
|
68147
|
-
bankMetadataMap
|
|
68076
|
+
bankMetadataMap,
|
|
68077
|
+
[repayOpts.repayBank.address, borrowOpts.borrowBank.address]
|
|
68148
68078
|
);
|
|
68149
68079
|
const { flashloanTx, setupInstructions, swapQuote, borrowIxs, repayIxs } = await buildSwapDebtFlashloanTx({
|
|
68150
68080
|
...params,
|
|
@@ -68174,14 +68104,8 @@ async function makeSwapDebtTx(params) {
|
|
|
68174
68104
|
crossbarUrl
|
|
68175
68105
|
});
|
|
68176
68106
|
let additionalTxs = [];
|
|
68177
|
-
if (setupIxs.length > 0 ||
|
|
68178
|
-
const ixs = [
|
|
68179
|
-
...additionalIxs,
|
|
68180
|
-
...setupIxs,
|
|
68181
|
-
...kaminoRefreshIxs.instructions,
|
|
68182
|
-
...updateDriftMarketIxs.instructions,
|
|
68183
|
-
...updateJupLendRateIxs.instructions
|
|
68184
|
-
];
|
|
68107
|
+
if (setupIxs.length > 0 || refreshIntegrationIxs.instructions.length > 0) {
|
|
68108
|
+
const ixs = [...additionalIxs, ...setupIxs, ...refreshIntegrationIxs.instructions];
|
|
68185
68109
|
const txs = splitInstructionsToFitTransactions([], ixs, {
|
|
68186
68110
|
blockhash,
|
|
68187
68111
|
payerKey: marginfiAccount.authority,
|
|
@@ -69132,7 +69056,12 @@ var MarginfiAccount = class _MarginfiAccount {
|
|
|
69132
69056
|
* @returns Array of banks needed for health checks
|
|
69133
69057
|
*/
|
|
69134
69058
|
getHealthCheckAccounts(banks, mandatoryBanks = [], excludedBanks = []) {
|
|
69135
|
-
return computeHealthCheckAccounts(
|
|
69059
|
+
return computeHealthCheckAccounts({
|
|
69060
|
+
account: this,
|
|
69061
|
+
banksMap: banks,
|
|
69062
|
+
mandatoryBanks,
|
|
69063
|
+
excludedBanks
|
|
69064
|
+
});
|
|
69136
69065
|
}
|
|
69137
69066
|
/**
|
|
69138
69067
|
* Determines which E-mode pairs are currently active for this account.
|
|
@@ -69332,14 +69261,7 @@ var MarginfiAccount = class _MarginfiAccount {
|
|
|
69332
69261
|
* @see {@link makePulseHealthIx} for implementation
|
|
69333
69262
|
*/
|
|
69334
69263
|
async makePulseHealthIx(program, banks, mandatoryBanks, excludedBanks) {
|
|
69335
|
-
return makePulseHealthIx2(
|
|
69336
|
-
program,
|
|
69337
|
-
this.address,
|
|
69338
|
-
banks,
|
|
69339
|
-
this.balances,
|
|
69340
|
-
mandatoryBanks,
|
|
69341
|
-
excludedBanks
|
|
69342
|
-
);
|
|
69264
|
+
return makePulseHealthIx2(program, this, banks, mandatoryBanks, excludedBanks);
|
|
69343
69265
|
}
|
|
69344
69266
|
/**
|
|
69345
69267
|
* Computes which banks will be active after executing the given instructions.
|
|
@@ -69355,7 +69277,7 @@ var MarginfiAccount = class _MarginfiAccount {
|
|
|
69355
69277
|
* @see {@link computeProjectedActiveBanksNoCpi} for implementation
|
|
69356
69278
|
*/
|
|
69357
69279
|
computeProjectedActiveBanksNoCpi(program, instructions2) {
|
|
69358
|
-
return computeProjectedActiveBanksNoCpi(this
|
|
69280
|
+
return computeProjectedActiveBanksNoCpi({ account: this, instructions: instructions2, program });
|
|
69359
69281
|
}
|
|
69360
69282
|
/**
|
|
69361
69283
|
* Computes projected active balances after executing the given instructions.
|
|
@@ -69372,13 +69294,13 @@ var MarginfiAccount = class _MarginfiAccount {
|
|
|
69372
69294
|
* @see {@link computeProjectedActiveBalancesNoCpi} for implementation
|
|
69373
69295
|
*/
|
|
69374
69296
|
computeProjectedActiveBalancesNoCpi(program, instructions2, banksMap, assetShareValueMultiplierByBank) {
|
|
69375
|
-
const { projectedBalances, ...rest } = computeProjectedActiveBalancesNoCpi(
|
|
69376
|
-
this
|
|
69377
|
-
instructions2,
|
|
69297
|
+
const { projectedBalances, ...rest } = computeProjectedActiveBalancesNoCpi({
|
|
69298
|
+
account: this,
|
|
69299
|
+
instructions: instructions2,
|
|
69378
69300
|
program,
|
|
69379
69301
|
banksMap,
|
|
69380
69302
|
assetShareValueMultiplierByBank
|
|
69381
|
-
);
|
|
69303
|
+
});
|
|
69382
69304
|
return {
|
|
69383
69305
|
projectedBalances: projectedBalances.map(Balance.fromBalanceType),
|
|
69384
69306
|
...rest
|
|
@@ -69809,13 +69731,13 @@ function projectAccountAfterFirstLeg(account, firstLegFlashloanTxs, program, ban
|
|
|
69809
69731
|
const luts = tx.addressLookupTables ?? [];
|
|
69810
69732
|
ixs.push(...decompileV0Transaction(tx, luts).instructions);
|
|
69811
69733
|
}
|
|
69812
|
-
const { projectedBalances } = computeProjectedActiveBalancesNoCpi(
|
|
69813
|
-
account
|
|
69814
|
-
ixs,
|
|
69734
|
+
const { projectedBalances } = computeProjectedActiveBalancesNoCpi({
|
|
69735
|
+
account,
|
|
69736
|
+
instructions: ixs,
|
|
69815
69737
|
program,
|
|
69816
69738
|
banksMap,
|
|
69817
|
-
multipliers
|
|
69818
|
-
);
|
|
69739
|
+
assetShareValueMultiplierByBank: multipliers
|
|
69740
|
+
});
|
|
69819
69741
|
return new MarginfiAccount(
|
|
69820
69742
|
account.address,
|
|
69821
69743
|
account.group,
|
|
@@ -70175,7 +70097,7 @@ async function buildInnerIxs(ctx, positions, isSync) {
|
|
|
70175
70097
|
const borrowIxs = [];
|
|
70176
70098
|
const repayIxs = [];
|
|
70177
70099
|
for (const position of collateral) {
|
|
70178
|
-
const observationBanksOverride = ctx.groupRateLimiterEnabled ? computeHealthAccountMetas([],
|
|
70100
|
+
const observationBanksOverride = ctx.groupRateLimiterEnabled ? computeHealthAccountMetas({ banksToInclude: [], trailingBanks: [position.bank] }) : [];
|
|
70179
70101
|
const legs = await buildCollateralLegIxs(ctx, position, isSync, observationBanksOverride);
|
|
70180
70102
|
withdrawIxs.push(...legs.withdrawIxs);
|
|
70181
70103
|
depositIxs.push(...legs.depositIxs);
|
|
@@ -70196,7 +70118,7 @@ async function buildInnerIxs(ctx, positions, isSync) {
|
|
|
70196
70118
|
...collateralBanks,
|
|
70197
70119
|
...borrowedSoFar
|
|
70198
70120
|
]);
|
|
70199
|
-
const observationBanksOverride = computeHealthAccountMetas(activeBanks);
|
|
70121
|
+
const observationBanksOverride = computeHealthAccountMetas({ banksToInclude: activeBanks });
|
|
70200
70122
|
const borrowUi = position.uiAmount.times(1 + ctx.borrowPaddingBps / 1e4);
|
|
70201
70123
|
const borrow = await makeBorrowIx3({
|
|
70202
70124
|
program: ctx.program,
|
|
@@ -70365,15 +70287,8 @@ async function makeTransferPositionsTx(params) {
|
|
|
70365
70287
|
)
|
|
70366
70288
|
);
|
|
70367
70289
|
}
|
|
70368
|
-
const
|
|
70369
|
-
|
|
70370
|
-
);
|
|
70371
|
-
const crankBalanceView = {
|
|
70372
|
-
...accountA,
|
|
70373
|
-
balances: [...accountA.balances, ...destinationOnlyBalances]
|
|
70374
|
-
};
|
|
70375
|
-
const { instructions: updateFeedIxs, luts: feedLuts } = await makeSmartCrankSwbFeedIx({
|
|
70376
|
-
marginfiAccount: crankBalanceView,
|
|
70290
|
+
const { instructions: updateFeedIxs, luts: feedLuts } = await makeSmartCrankSwbFeedIxForAccounts({
|
|
70291
|
+
marginfiAccounts: [accountA, accountB],
|
|
70377
70292
|
bankMap,
|
|
70378
70293
|
oraclePrices,
|
|
70379
70294
|
assetShareValueMultiplierByBank,
|
|
@@ -70403,34 +70318,6 @@ async function makeTransferPositionsTx(params) {
|
|
|
70403
70318
|
};
|
|
70404
70319
|
}
|
|
70405
70320
|
var BULK_TX_SIZE_MARGIN = 128;
|
|
70406
|
-
function computeV0TxSizeSafe(ixs, payer, luts) {
|
|
70407
|
-
try {
|
|
70408
|
-
return computeV0TxSize(ixs, payer, luts);
|
|
70409
|
-
} catch {
|
|
70410
|
-
return { size: Number.MAX_SAFE_INTEGER, accountCount: Number.MAX_SAFE_INTEGER };
|
|
70411
|
-
}
|
|
70412
|
-
}
|
|
70413
|
-
function fitsInTx(ixs, payer, luts) {
|
|
70414
|
-
const { size, accountCount } = computeV0TxSizeSafe(ixs, payer, luts);
|
|
70415
|
-
return size <= MAX_TX_SIZE - BULK_TX_SIZE_MARGIN && accountCount <= MAX_ACCOUNT_LOCKS;
|
|
70416
|
-
}
|
|
70417
|
-
function buildTxRefreshIxs(args) {
|
|
70418
|
-
const { marginfiAccount, bankMap, bankMetadataMap, txBanks } = args;
|
|
70419
|
-
const ixs = [];
|
|
70420
|
-
const kaminoPks = txBanks.filter((b) => b.config.assetTag === 3 /* KAMINO */).map((b) => b.address);
|
|
70421
|
-
if (kaminoPks.length > 0) {
|
|
70422
|
-
ixs.push(
|
|
70423
|
-
...makeRefreshKaminoBanksIxs(marginfiAccount, bankMap, kaminoPks, bankMetadataMap).instructions
|
|
70424
|
-
);
|
|
70425
|
-
}
|
|
70426
|
-
const jupPksInTx = txBanks.filter((b) => b.config.assetTag === 6 /* JUPLEND */).map((b) => b.address);
|
|
70427
|
-
if (jupPksInTx.length > 0) {
|
|
70428
|
-
ixs.push(
|
|
70429
|
-
...makeUpdateJupLendRateIxs(marginfiAccount, bankMap, jupPksInTx, bankMetadataMap).instructions
|
|
70430
|
-
);
|
|
70431
|
-
}
|
|
70432
|
-
return ixs;
|
|
70433
|
-
}
|
|
70434
70321
|
async function makeBulkWithdrawTx(params) {
|
|
70435
70322
|
const {
|
|
70436
70323
|
program,
|
|
@@ -70442,14 +70329,19 @@ async function makeBulkWithdrawTx(params) {
|
|
|
70442
70329
|
oraclePrices,
|
|
70443
70330
|
assetShareValueMultiplierByBank,
|
|
70444
70331
|
tokenProgramsByBank,
|
|
70445
|
-
overrideInferAccounts
|
|
70332
|
+
overrideInferAccounts,
|
|
70333
|
+
luts
|
|
70446
70334
|
} = params;
|
|
70447
|
-
const luts = params.addressLookupTableAccounts ?? [];
|
|
70448
|
-
const groupRateLimiterEnabled = params.groupRateLimiterEnabled ?? false;
|
|
70449
70335
|
const authority = marginfiAccount.authority;
|
|
70450
70336
|
if (bankAddresses.length === 0) throw new Error("no banks to withdraw");
|
|
70451
70337
|
const activeBalances = marginfiAccount.balances.filter((b) => b.active);
|
|
70452
|
-
const
|
|
70338
|
+
const involvedBanks = [
|
|
70339
|
+
...bankAddresses.map((pk2) => requireBank(bankMap, pk2)),
|
|
70340
|
+
...activeBalances.flatMap((b) => bankMap.get(b.bankPk.toBase58()) ?? [])
|
|
70341
|
+
];
|
|
70342
|
+
const selectedLuts = selectLutsForBanks(luts, involvedBanks);
|
|
70343
|
+
const withdrawIxs = [];
|
|
70344
|
+
const setupTokens = [];
|
|
70453
70345
|
const withdrawnSoFar = [];
|
|
70454
70346
|
for (const bankAddress of bankAddresses) {
|
|
70455
70347
|
const bank = requireBank(bankMap, bankAddress);
|
|
@@ -70458,15 +70350,15 @@ async function makeBulkWithdrawTx(params) {
|
|
|
70458
70350
|
if (!balance || !balance.assetShares.gt(0)) {
|
|
70459
70351
|
throw new Error(`no active deposit for bank ${bankAddress.toBase58()}`);
|
|
70460
70352
|
}
|
|
70461
|
-
const
|
|
70462
|
-
|
|
70463
|
-
|
|
70464
|
-
|
|
70465
|
-
|
|
70466
|
-
|
|
70467
|
-
|
|
70468
|
-
|
|
70469
|
-
|
|
70353
|
+
const packBanks = computeHealthCheckAccounts({
|
|
70354
|
+
account: marginfiAccount,
|
|
70355
|
+
banksMap: bankMap,
|
|
70356
|
+
excludedBanks: [...withdrawnSoFar, bankAddress]
|
|
70357
|
+
});
|
|
70358
|
+
const observationBanksOverride = computeHealthAccountMetas({
|
|
70359
|
+
banksToInclude: packBanks,
|
|
70360
|
+
trailingBanks: [bank]
|
|
70361
|
+
});
|
|
70470
70362
|
const shared = {
|
|
70471
70363
|
program,
|
|
70472
70364
|
bank,
|
|
@@ -70475,11 +70367,14 @@ async function makeBulkWithdrawTx(params) {
|
|
|
70475
70367
|
marginfiAccount,
|
|
70476
70368
|
authority,
|
|
70477
70369
|
bankMetadataMap,
|
|
70370
|
+
// every venue's withdraw ix ignores the amount when the withdraw-all flag is
|
|
70371
|
+
// set and derives the full position on-chain, so all legs pass amount 0
|
|
70478
70372
|
withdrawAll: true,
|
|
70479
70373
|
opts: {
|
|
70480
70374
|
createAtas: false,
|
|
70481
70375
|
// ATAs are created in the prelude txs
|
|
70482
|
-
wrapAndUnwrapSol:
|
|
70376
|
+
wrapAndUnwrapSol: false,
|
|
70377
|
+
// one unwrap ix is appended after the last withdraw
|
|
70483
70378
|
overrideInferAccounts,
|
|
70484
70379
|
observationBanksOverride
|
|
70485
70380
|
}
|
|
@@ -70493,7 +70388,7 @@ async function makeBulkWithdrawTx(params) {
|
|
|
70493
70388
|
}
|
|
70494
70389
|
const withdraw = await makeKaminoWithdrawIx3({
|
|
70495
70390
|
...shared,
|
|
70496
|
-
cTokenAmount:
|
|
70391
|
+
cTokenAmount: 0,
|
|
70497
70392
|
reserve
|
|
70498
70393
|
});
|
|
70499
70394
|
instructions2 = withdraw.instructions;
|
|
@@ -70506,7 +70401,7 @@ async function makeBulkWithdrawTx(params) {
|
|
|
70506
70401
|
}
|
|
70507
70402
|
const withdraw = await makeJuplendWithdrawIx2({
|
|
70508
70403
|
...shared,
|
|
70509
|
-
amount:
|
|
70404
|
+
amount: 0,
|
|
70510
70405
|
jupLendingState
|
|
70511
70406
|
});
|
|
70512
70407
|
instructions2 = withdraw.instructions;
|
|
@@ -70519,7 +70414,7 @@ async function makeBulkWithdrawTx(params) {
|
|
|
70519
70414
|
}
|
|
70520
70415
|
const withdraw = await makeDriftWithdrawIx3({
|
|
70521
70416
|
...shared,
|
|
70522
|
-
amount:
|
|
70417
|
+
amount: 0,
|
|
70523
70418
|
driftSpotMarket: driftState.spotMarketState,
|
|
70524
70419
|
userRewards: driftState.userRewards
|
|
70525
70420
|
});
|
|
@@ -70529,76 +70424,49 @@ async function makeBulkWithdrawTx(params) {
|
|
|
70529
70424
|
default: {
|
|
70530
70425
|
const withdraw = await makeWithdrawIx3({
|
|
70531
70426
|
...shared,
|
|
70532
|
-
amount:
|
|
70427
|
+
amount: 0
|
|
70533
70428
|
});
|
|
70534
70429
|
instructions2 = withdraw.instructions;
|
|
70535
70430
|
break;
|
|
70536
70431
|
}
|
|
70537
70432
|
}
|
|
70538
|
-
|
|
70433
|
+
withdrawIxs.push(...instructions2);
|
|
70434
|
+
setupTokens.push({ mint: bank.mint, tokenProgram });
|
|
70539
70435
|
withdrawnSoFar.push(bankAddress);
|
|
70540
70436
|
}
|
|
70541
|
-
|
|
70542
|
-
|
|
70543
|
-
const assembleTxIxs = (bundle) => [
|
|
70544
|
-
...buildTxRefreshIxs({
|
|
70545
|
-
marginfiAccount,
|
|
70546
|
-
bankMap,
|
|
70547
|
-
bankMetadataMap,
|
|
70548
|
-
txBanks: bundle.map((l) => l.bank)
|
|
70549
|
-
}),
|
|
70550
|
-
...bundle.flatMap((l) => l.instructions)
|
|
70551
|
-
];
|
|
70552
|
-
for (const leg of legs) {
|
|
70553
|
-
const candidate = [...current, leg];
|
|
70554
|
-
if (current.length > 0 && !fitsInTx(assembleTxIxs(candidate), authority, luts)) {
|
|
70555
|
-
bundles.push(current);
|
|
70556
|
-
current = [leg];
|
|
70557
|
-
} else {
|
|
70558
|
-
current = candidate;
|
|
70559
|
-
}
|
|
70560
|
-
}
|
|
70561
|
-
if (current.length > 0) bundles.push(current);
|
|
70562
|
-
for (const bundle of bundles) {
|
|
70563
|
-
const ixs = assembleTxIxs(bundle);
|
|
70564
|
-
if (bundle.length === 1 && !fitsInTx(ixs, authority, luts)) {
|
|
70565
|
-
throw new Error(
|
|
70566
|
-
`withdraw for bank ${bundle[0].bank.address.toBase58()} does not fit one transaction`
|
|
70567
|
-
);
|
|
70568
|
-
}
|
|
70437
|
+
if (setupTokens.some((t) => t.mint.equals(NATIVE_MINT))) {
|
|
70438
|
+
withdrawIxs.push(makeUnwrapSolIx(authority));
|
|
70569
70439
|
}
|
|
70570
70440
|
const { blockhash } = await connection.getLatestBlockhash("confirmed");
|
|
70571
|
-
const withdrawTxs =
|
|
70572
|
-
|
|
70573
|
-
|
|
70574
|
-
|
|
70575
|
-
|
|
70576
|
-
|
|
70577
|
-
|
|
70578
|
-
|
|
70441
|
+
const withdrawTxs = splitInstructionsToFitTransactions([], withdrawIxs, {
|
|
70442
|
+
blockhash,
|
|
70443
|
+
payerKey: authority,
|
|
70444
|
+
luts: selectedLuts,
|
|
70445
|
+
sizeMargin: BULK_TX_SIZE_MARGIN,
|
|
70446
|
+
maxAccountLocks: MAX_ACCOUNT_LOCKS
|
|
70447
|
+
}).map(
|
|
70448
|
+
(tx) => addTransactionMetadata(tx, {
|
|
70449
|
+
addressLookupTables: selectedLuts,
|
|
70579
70450
|
type: "WITHDRAW" /* WITHDRAW */
|
|
70580
|
-
})
|
|
70581
|
-
|
|
70451
|
+
})
|
|
70452
|
+
);
|
|
70582
70453
|
const additionalTxs = [];
|
|
70583
70454
|
const setupIxs = await makeSetupIx({
|
|
70584
70455
|
connection,
|
|
70585
70456
|
authority,
|
|
70586
|
-
tokens:
|
|
70587
|
-
mint: l.bank.mint,
|
|
70588
|
-
tokenProgram: requireTokenProgram(tokenProgramsByBank, l.bank.address)
|
|
70589
|
-
}))
|
|
70457
|
+
tokens: setupTokens
|
|
70590
70458
|
});
|
|
70591
70459
|
if (setupIxs.length > 0) {
|
|
70592
70460
|
const setupTxs = splitInstructionsToFitTransactions([], setupIxs, {
|
|
70593
70461
|
blockhash,
|
|
70594
70462
|
payerKey: authority,
|
|
70595
|
-
luts
|
|
70463
|
+
luts: selectedLuts
|
|
70596
70464
|
});
|
|
70597
70465
|
additionalTxs.push(
|
|
70598
70466
|
...setupTxs.map(
|
|
70599
70467
|
(tx) => addTransactionMetadata(tx, {
|
|
70600
70468
|
type: "CREATE_ATA" /* CREATE_ATA */,
|
|
70601
|
-
addressLookupTables:
|
|
70469
|
+
addressLookupTables: selectedLuts
|
|
70602
70470
|
})
|
|
70603
70471
|
)
|
|
70604
70472
|
);
|
|
@@ -70608,11 +70476,10 @@ async function makeBulkWithdrawTx(params) {
|
|
|
70608
70476
|
bankMap,
|
|
70609
70477
|
oraclePrices,
|
|
70610
70478
|
assetShareValueMultiplierByBank,
|
|
70611
|
-
instructions:
|
|
70479
|
+
instructions: withdrawIxs,
|
|
70612
70480
|
program,
|
|
70613
70481
|
connection,
|
|
70614
|
-
crossbarUrl: params.crossbarUrl
|
|
70615
|
-
groupRateLimiterEnabled
|
|
70482
|
+
crossbarUrl: params.crossbarUrl
|
|
70616
70483
|
});
|
|
70617
70484
|
if (crankIxs.length > 0) {
|
|
70618
70485
|
const message = new TransactionMessage({
|
|
@@ -70627,6 +70494,27 @@ async function makeBulkWithdrawTx(params) {
|
|
|
70627
70494
|
})
|
|
70628
70495
|
);
|
|
70629
70496
|
}
|
|
70497
|
+
const refreshIxs = makeRefreshIntegrationBanksIxs(
|
|
70498
|
+
marginfiAccount,
|
|
70499
|
+
bankMap,
|
|
70500
|
+
bankAddresses,
|
|
70501
|
+
bankMetadataMap
|
|
70502
|
+
).instructions;
|
|
70503
|
+
if (refreshIxs.length > 0) {
|
|
70504
|
+
const refreshTxs = splitInstructionsToFitTransactions([], refreshIxs, {
|
|
70505
|
+
blockhash,
|
|
70506
|
+
payerKey: authority,
|
|
70507
|
+
luts: selectedLuts
|
|
70508
|
+
});
|
|
70509
|
+
additionalTxs.push(
|
|
70510
|
+
...refreshTxs.map(
|
|
70511
|
+
(tx) => addTransactionMetadata(tx, {
|
|
70512
|
+
type: "CRANK" /* CRANK */,
|
|
70513
|
+
addressLookupTables: selectedLuts
|
|
70514
|
+
})
|
|
70515
|
+
)
|
|
70516
|
+
);
|
|
70517
|
+
}
|
|
70630
70518
|
return {
|
|
70631
70519
|
transactions: [...additionalTxs, ...withdrawTxs],
|
|
70632
70520
|
actionTxIndex: additionalTxs.length
|
|
@@ -70646,7 +70534,7 @@ async function makeBulkRepayTx(params) {
|
|
|
70646
70534
|
const authority = marginfiAccount.authority;
|
|
70647
70535
|
if (bankAddresses.length === 0) throw new Error("no banks to repay");
|
|
70648
70536
|
const activeBalances = marginfiAccount.balances.filter((b) => b.active);
|
|
70649
|
-
const
|
|
70537
|
+
const repayIxs = [];
|
|
70650
70538
|
for (const bankAddress of bankAddresses) {
|
|
70651
70539
|
const bank = requireBank(bankMap, bankAddress);
|
|
70652
70540
|
const tokenProgram = requireTokenProgram(tokenProgramsByBank, bankAddress);
|
|
@@ -70668,33 +70556,21 @@ async function makeBulkRepayTx(params) {
|
|
|
70668
70556
|
overrideInferAccounts
|
|
70669
70557
|
}
|
|
70670
70558
|
});
|
|
70671
|
-
|
|
70672
|
-
}
|
|
70673
|
-
const bundles = [];
|
|
70674
|
-
let current = [];
|
|
70675
|
-
for (const leg of legs) {
|
|
70676
|
-
const candidate = [...current, leg];
|
|
70677
|
-
const candidateIxs = candidate.flatMap((l) => l.instructions);
|
|
70678
|
-
if (current.length > 0 && !fitsInTx(candidateIxs, authority, luts)) {
|
|
70679
|
-
bundles.push(current);
|
|
70680
|
-
current = [leg];
|
|
70681
|
-
} else {
|
|
70682
|
-
current = candidate;
|
|
70683
|
-
}
|
|
70559
|
+
repayIxs.push(...repay.instructions);
|
|
70684
70560
|
}
|
|
70685
|
-
if (current.length > 0) bundles.push(current);
|
|
70686
70561
|
const { blockhash } = await connection.getLatestBlockhash("confirmed");
|
|
70687
|
-
const transactions =
|
|
70688
|
-
|
|
70689
|
-
|
|
70690
|
-
|
|
70691
|
-
|
|
70692
|
-
|
|
70693
|
-
|
|
70562
|
+
const transactions = splitInstructionsToFitTransactions([], repayIxs, {
|
|
70563
|
+
blockhash,
|
|
70564
|
+
payerKey: authority,
|
|
70565
|
+
luts,
|
|
70566
|
+
sizeMargin: BULK_TX_SIZE_MARGIN,
|
|
70567
|
+
maxAccountLocks: MAX_ACCOUNT_LOCKS
|
|
70568
|
+
}).map(
|
|
70569
|
+
(tx) => addTransactionMetadata(tx, {
|
|
70694
70570
|
addressLookupTables: luts,
|
|
70695
70571
|
type: "REPAY" /* REPAY */
|
|
70696
|
-
})
|
|
70697
|
-
|
|
70572
|
+
})
|
|
70573
|
+
);
|
|
70698
70574
|
return { transactions, actionTxIndex: 0 };
|
|
70699
70575
|
}
|
|
70700
70576
|
|
|
@@ -70833,9 +70709,8 @@ async function simulateAccountHealthCache(params) {
|
|
|
70833
70709
|
);
|
|
70834
70710
|
const healthPulseIxs = await makePulseHealthIx2(
|
|
70835
70711
|
program,
|
|
70836
|
-
marginfiAccount
|
|
70712
|
+
marginfiAccount,
|
|
70837
70713
|
banksMap,
|
|
70838
|
-
marginfiAccount.balances,
|
|
70839
70714
|
activeBalances.map((b) => b.bankPk),
|
|
70840
70715
|
[]
|
|
70841
70716
|
);
|
|
@@ -71023,9 +70898,8 @@ async function getHealthSimulationTransactions({
|
|
|
71023
70898
|
);
|
|
71024
70899
|
const healthPulseIx = await makePulseHealthIx2(
|
|
71025
70900
|
program,
|
|
71026
|
-
marginfiAccount
|
|
70901
|
+
marginfiAccount,
|
|
71027
70902
|
bankMap,
|
|
71028
|
-
marginfiAccount.balances,
|
|
71029
70903
|
mandatoryBanks,
|
|
71030
70904
|
excludedBanks
|
|
71031
70905
|
);
|
|
@@ -71486,13 +71360,13 @@ async function computeSmartCrank({
|
|
|
71486
71360
|
assetShareValueMultiplierByBank,
|
|
71487
71361
|
groupRateLimiterEnabled = false
|
|
71488
71362
|
}) {
|
|
71489
|
-
const { projectedBalances, withdrawnBanks } = computeProjectedActiveBalancesNoCpi(
|
|
71490
|
-
marginfiAccount
|
|
71491
|
-
instructions2,
|
|
71363
|
+
const { projectedBalances, withdrawnBanks } = computeProjectedActiveBalancesNoCpi({
|
|
71364
|
+
account: marginfiAccount,
|
|
71365
|
+
instructions: instructions2,
|
|
71492
71366
|
program,
|
|
71493
|
-
bankMap,
|
|
71367
|
+
banksMap: bankMap,
|
|
71494
71368
|
assetShareValueMultiplierByBank
|
|
71495
|
-
);
|
|
71369
|
+
});
|
|
71496
71370
|
const isSwitchboard = (bank) => getOracleSourceFromBank(bank).key === "switchboard";
|
|
71497
71371
|
const rateLimitBanks = groupRateLimiterEnabled ? withdrawnBanks.map((pk2) => bankMap.get(pk2)).filter((bank) => bank !== void 0).filter(isSwitchboard) : [];
|
|
71498
71372
|
let rateLimitOracles = [];
|
|
@@ -71800,6 +71674,55 @@ async function makeSmartCrankSwbFeedIx(params) {
|
|
|
71800
71674
|
});
|
|
71801
71675
|
return { instructions: instructions2, luts };
|
|
71802
71676
|
}
|
|
71677
|
+
async function makeSmartCrankSwbFeedIxForAccounts(params) {
|
|
71678
|
+
const crankResults = await Promise.all(
|
|
71679
|
+
params.marginfiAccounts.map(
|
|
71680
|
+
(marginfiAccount) => computeSmartCrank({ ...params, marginfiAccount })
|
|
71681
|
+
)
|
|
71682
|
+
);
|
|
71683
|
+
const uncrankableLiabilities = crankResults.flatMap((r) => r.uncrankableLiabilities);
|
|
71684
|
+
const uncrankableAssets = crankResults.flatMap((r) => r.uncrankableAssets);
|
|
71685
|
+
if (uncrankableLiabilities.length > 0) {
|
|
71686
|
+
console.log(
|
|
71687
|
+
"Uncrankable liability details:",
|
|
71688
|
+
uncrankableLiabilities.map((l) => ({
|
|
71689
|
+
symbol: l.bank.tokenSymbol,
|
|
71690
|
+
reason: l.reason
|
|
71691
|
+
}))
|
|
71692
|
+
);
|
|
71693
|
+
}
|
|
71694
|
+
if (uncrankableAssets.length > 0) {
|
|
71695
|
+
console.log(
|
|
71696
|
+
"Uncrankable asset details:",
|
|
71697
|
+
uncrankableAssets.map((a) => ({
|
|
71698
|
+
symbol: a.bank.tokenSymbol,
|
|
71699
|
+
reason: a.reason
|
|
71700
|
+
}))
|
|
71701
|
+
);
|
|
71702
|
+
}
|
|
71703
|
+
if (crankResults.some((r) => !r.isCrankable)) {
|
|
71704
|
+
throw TransactionBuildingError.oracleCrankFailed(
|
|
71705
|
+
uncrankableLiabilities.map((liability) => ({
|
|
71706
|
+
bankAddress: liability.bank.address.toBase58(),
|
|
71707
|
+
mint: liability.bank.mint.toBase58(),
|
|
71708
|
+
symbol: liability.bank.tokenSymbol,
|
|
71709
|
+
reason: liability.reason
|
|
71710
|
+
})),
|
|
71711
|
+
uncrankableAssets.map((asset) => ({
|
|
71712
|
+
bankAddress: asset.bank.address.toBase58(),
|
|
71713
|
+
mint: asset.bank.mint.toBase58(),
|
|
71714
|
+
symbol: asset.bank.tokenSymbol,
|
|
71715
|
+
reason: asset.reason
|
|
71716
|
+
}))
|
|
71717
|
+
);
|
|
71718
|
+
}
|
|
71719
|
+
return makeUpdateSwbFeedIx({
|
|
71720
|
+
swbPullOracles: crankResults.flatMap((r) => r.requiredOracles),
|
|
71721
|
+
feePayer: params.marginfiAccounts[0].authority,
|
|
71722
|
+
connection: params.connection,
|
|
71723
|
+
crossbarUrl: params.crossbarUrl
|
|
71724
|
+
});
|
|
71725
|
+
}
|
|
71803
71726
|
var DEFAULT_CROSSBAR_URL = "https://crossbar.0.xyz";
|
|
71804
71727
|
var DEFAULT_FALLBACK_CROSSBAR_URL = "https://crossbar.switchboard.xyz";
|
|
71805
71728
|
async function makeCrankSwbFeedIx(marginfiAccount, bankMap, newBanksPk, provider, crossbarUrl) {
|
|
@@ -71970,6 +71893,36 @@ function makeUpdateJupLendRateIxs(marginfiAccount, bankMap, banksToExclude, bank
|
|
|
71970
71893
|
keys: []
|
|
71971
71894
|
};
|
|
71972
71895
|
}
|
|
71896
|
+
|
|
71897
|
+
// src/services/price/actions/refresh-integration-banks.ts
|
|
71898
|
+
function makeRefreshIntegrationBanksIxs(marginfiAccount, bankMap, banksToExclude, bankMetadataMap, kaminoNewBanksPk = banksToExclude) {
|
|
71899
|
+
const kaminoRefreshIxs = makeRefreshKaminoBanksIxs(
|
|
71900
|
+
marginfiAccount,
|
|
71901
|
+
bankMap,
|
|
71902
|
+
kaminoNewBanksPk,
|
|
71903
|
+
bankMetadataMap
|
|
71904
|
+
);
|
|
71905
|
+
const updateDriftMarketIxs = makeUpdateDriftMarketIxs(
|
|
71906
|
+
marginfiAccount,
|
|
71907
|
+
bankMap,
|
|
71908
|
+
banksToExclude,
|
|
71909
|
+
bankMetadataMap
|
|
71910
|
+
);
|
|
71911
|
+
const updateJupLendRateIxs = makeUpdateJupLendRateIxs(
|
|
71912
|
+
marginfiAccount,
|
|
71913
|
+
bankMap,
|
|
71914
|
+
banksToExclude,
|
|
71915
|
+
bankMetadataMap
|
|
71916
|
+
);
|
|
71917
|
+
return {
|
|
71918
|
+
instructions: [
|
|
71919
|
+
...kaminoRefreshIxs.instructions,
|
|
71920
|
+
...updateDriftMarketIxs.instructions,
|
|
71921
|
+
...updateJupLendRateIxs.instructions
|
|
71922
|
+
],
|
|
71923
|
+
keys: [...kaminoRefreshIxs.keys, ...updateDriftMarketIxs.keys, ...updateJupLendRateIxs.keys]
|
|
71924
|
+
};
|
|
71925
|
+
}
|
|
71973
71926
|
function bankMetadataMapToDto(bankMetadataMap) {
|
|
71974
71927
|
return Object.fromEntries(
|
|
71975
71928
|
Object.entries(bankMetadataMap).map(([bankPk, bankMetadata]) => [
|
|
@@ -76032,6 +75985,6 @@ var EmodeSettings = class _EmodeSettings {
|
|
|
76032
75985
|
}
|
|
76033
75986
|
};
|
|
76034
75987
|
|
|
76035
|
-
export { ADDRESS_LOOKUP_TABLE_FOR_GROUP, ADDRESS_LOOKUP_TABLE_FOR_GROUP_NATIVE_STAKE, ADDRESS_LOOKUP_TABLE_FOR_SWAP, AccountFlags, AccountType, AssetTag, BUNDLE_TX_SIZE, Balance, Bank, BankConfig, BankConfigFlag, BankVaultType, DEFAULT_CROSSBAR_URL, DEFAULT_FALLBACK_CROSSBAR_URL, DEFAULT_ORACLE_MAX_AGE, DEFAULT_REPAY_ALL_EXTRA_BUFFER_BPS, DISABLED_FLAG, EMPTY_HEALTH_CACHE, EmodeEntryFlags, EmodeFlags, EmodeImpactStatus, EmodeSettings, EmodeTag, FLASHLOAN_ENABLED_FLAG, HOURS_PER_YEAR, HealthCache, HealthCacheFlags, HealthCacheSimulationError, HealthCacheStatus, JUPITER_V6_PROGRAM, JUP_SWAP_LUT_PROGRAM_AUTHORITY_INDEX, LST_MINT, MARGINFI_IDL, MARGINFI_PROGRAM, MARGINFI_PROGRAM_STAGING, MARGINFI_PROGRAM_STAGING_ALT, MARGINFI_SPONSORED_SHARD_ID, MAX_ACCOUNT_LOCKS, MAX_CONFIDENCE_INTERVAL_RATIO, MAX_TX_SIZE, MAX_U64, MPL_METADATA_PROGRAM_ID, MarginRequirementType, MarginfiAccount, MarginfiAccountWrapper, MarginfiGroup, OperationalState, OracleSetup, PDA_BANK_EMISSIONS_AUTH_SEED, PDA_BANK_EMISSIONS_VAULT_SEED, PDA_BANK_FEE_STATE_SEED, PDA_BANK_FEE_VAULT_AUTH_SEED, PDA_BANK_FEE_VAULT_SEED, PDA_BANK_INSURANCE_VAULT_AUTH_SEED, PDA_BANK_INSURANCE_VAULT_SEED, PDA_BANK_LIQUIDITY_VAULT_AUTH_SEED, PDA_BANK_LIQUIDITY_VAULT_SEED, PDA_MARGINFI_ACCOUNT_SEED, PRIORITY_TX_SIZE, PYTH_PRICE_CONF_INTERVALS, PYTH_PUSH_ORACLE_ID, PYTH_SPONSORED_SHARD_ID, PriceBias, Project0Client, RiskTier, SINGLE_POOL_PROGRAM_ID, STAKED_ORACLE_DISABLED_FLAG, STAKED_ORACLE_USES_ONRAMP_FLAG, STAKE_CONFIG_ID, STAKE_PROGRAM_ID, SWAP_ADAPTERS, SWB_PRICE_CONF_INTERVALS, SYSTEM_PROGRAM_ID, SYSVAR_CLOCK_ID, SYSVAR_RENT_ID, SYSVAR_STAKE_HISTORY_ID, SwapProvider, TRANSFER_ACCOUNT_AUTHORITY_FLAG, TransactionArenaKeyMap, TransactionBuildingError, TransactionBuildingErrorCode, TransactionConfigMap, TransactionType, USDC_DECIMALS, USDC_MINT, WSOL_MINT, ZERO_ORACLE_KEY, accountConflictsWithBridge, accountFlagToBN, addOracleToBanksIx, addTransactionMetadata, adjustPriceComponent, aprToApy, apyToApr, balanceToDto, bankConfigRawToDto, bankConfigToBankConfigRaw, bankMetadataMapToDto, bankMetadataToDto, bankRateLimiterRawToDto, bankRawToDto, bigNumberToWrappedI80F48, bpsToPercentile, buildCollateralLegIxs, calculateApyFromInterest, calculateInterestFromApy, capConfidenceInterval, categorizePythBanks, checkBatchOracleCrankability, checkJupiterFeeAccount, checkMultipleOraclesCrankability, checkTitanFeeAccount, chunkedGetRawMultipleAccountInfoOrdered, chunkedGetRawMultipleAccountInfoOrderedWithNulls, chunkedGetRawMultipleAccountInfos, classifyAndValidate, compileFlashloanPrecheck, composeBridgedSwap, composeRemainingAccounts, computeAccountValue, computeActiveEmodePairs, computeAssetHealthComponent, computeAssetUsdValue, computeBalanceUsdValue, computeBankBorrowApy, computeBankBorrowCapRemaining, computeBankDepositCapRemaining, computeBankMetrics, computeBankPoolSize, computeBankSupplyApy, computeBankTotalBorrows, computeBankTotalBorrowsUsd, computeBankTotalDeposits, computeBankTotalDepositsUsd, computeBaseInterestRate, computeBorrowEstimateForRepay, computeClaimedEmissions, computeClosePositionTokenAmount, computeEmodeImpacts, computeFlashLoanNonSwapBudget, computeFlashloanSwapConstraints, computeFreeCollateralFromBalances, computeFreeCollateralFromCache, computeHealthAccountMetas, computeHealthCacheStatus, computeHealthCheckAccounts, computeHealthComponentsFromBalances, computeHealthComponentsFromCache, computeInterestRates, computeLiabilityHealthComponent, computeLiabilityUsdValue, computeLiquidationPriceForBank, computeLoopingParams, computeLowestEmodeWeights, computeMaxBorrowForBank, computeMaxLeverage, computeMaxWithdrawForBank, computeNetApy, computeProjectedActiveBalancesNoCpi, computeProjectedActiveBanksNoCpi, computeQuantity, computeQuantityUi, computeRemainingCapacity, computeSmartCrank, computeStakedBankMultipliers, computeTotalOutstandingEmissions, computeTvl, computeUsdValue, computeUtilizationRate, computeV0TxSize, convertVoteAccCoeffsToBankCoeffs, createActiveEmodePairFromPairs, createEmptyBalance, decodeAccountRaw, decodeBankRaw, decodeInstruction, decompileV0Transaction, deriveBankEmissionsAuth, deriveBankEmissionsVault, deriveBankFeeVault, deriveBankFeeVaultAuthority, deriveBankInsuranceVault, deriveBankInsuranceVaultAuthority, deriveBankLiquidityVault, deriveBankLiquidityVaultAuthority, deriveFeeState, deriveMarginfiAccount, deserializeInstruction, deserializeLut, deserializeSwapEngineRequest, deserializeSwapEngineResult, dtoToBalance, dtoToBank, dtoToBankConfig, dtoToBankConfigRaw, dtoToBankMetadata, dtoToBankMetadataMap, dtoToBankRateLimiter, dtoToBankRateLimiterRaw, dtoToBankRaw, dtoToEmodeSettings, dtoToEmodeSettingsRaw, dtoToGroup, dtoToHealthCache, dtoToInterestRateConfig, dtoToMarginfiAccount, dtoToOraclePrice, dtoToValidatorStakeGroup, emodeSettingsRawToDto, extractPythOracleKeys, fetchBank, fetchBankIntegrationMetadata, fetchMarginfiAccountActiveBalancesForBank, fetchMarginfiAccountAddresses, fetchMarginfiAccountAddressesHoldingBank, fetchMarginfiAccountData, fetchMultipleBanks, fetchNativeStakeAccounts, fetchOracleData, fetchProgramForMints, fetchPythOracleData, fetchPythOraclePricesFromAPI, fetchPythOraclePricesFromChain, fetchStakeAccount, fetchStakePoolActiveStates, fetchStakePoolMev, fetchSwbOracleAccountsFromAPI, fetchSwbOracleAccountsFromChain, fetchSwbOracleData, fetchSwbOraclePricesFromAPI, fetchSwbOraclePricesFromCrossbar, findRandomAvailableAccountIndex, freezeBankConfigIx, generateDummyAccount, getAccountKeys, getActiveAccountFlags, getActiveBalances, getActiveEmodeEntryFlags, getActiveEmodeFlags, getActiveHealthCacheFlags, getAssetQuantity, getAssetShares, getAssetWeight, getBalance, getBalanceUsdValueWithPriceBias, getBankVaultAuthority, getBankVaultSeeds, getBirdeyeFallbackPricesByFeedId, getBirdeyePricesForMints, getConfig, getDriftCTokenMultiplier, getDriftMetadata, getDriftStatesDto, getEmodePairs, getExactOutEstimate, getFallbackPricesByFeedId, getFallbackPricesForMints, getHealthCacheStatusDescription, getHealthSimulationTransactions, getJupLendFTokenMultiplier, getJupLendMetadata, getJupLendStatesDto, getJupiterReferralFeeAccount, getJupiterSwapIxsForFlashloan, getKaminoCTokenMultiplier, getKaminoMetadata, getKaminoStatesDto, getLiabilityQuantity, getLiabilityShares, getLiabilityWeight, getOracleSourceFromBank, getOracleSourceFromOracleSetup, getOracleSourceNameFromKey, getPrice, getPriceWithConfidence, getStakedBankMetadataMap, getSwapAdapter, getSwapIxsForFlashloan, getTitanExactOutEstimate, getTitanSwapIxsForFlashloan, getTotalAccountKeys, getTotalAssetQuantity, getTotalLiabilityQuantity, getTxSize, getValidatorVoteAccountByBank, getWritableAccountKeys, groupToDto, hasAccountFlag, hasEmodeEntryFlag, hasEmodeFlag, hasHealthCacheFlag, healthCacheToDto, isDecomposableSwapError, isDepositIx, isFlashloan, isGroupRateLimiterEnabled, isStandardBorrowable, isStandardDepositable, isV0Tx, isWeightedPrice, isWholePosition, makeAccountTransferToNewAccountTx, makeAddPermissionlessStakedBankIx, makeBeginFlashLoanIx3 as makeBeginFlashLoanIx, makeBorrowIx3 as makeBorrowIx, makeBorrowTx, makeBulkRepayTx, makeBulkWithdrawTx, makeBundleTipIx, makeCloseMarginfiAccountIx, makeCloseMarginfiAccountTx, makeCrankSwbFeedIx, makeCreateAccountIxWithProjection, makeCreateAccountTxWithProjection, makeCreateMarginfiAccountIx, makeCreateMarginfiAccountTx, makeDepositIx3 as makeDepositIx, makeDepositTx, makeDriftDepositIx3 as makeDriftDepositIx, makeDriftDepositTx, makeDriftWithdrawIx3 as makeDriftWithdrawIx, makeDriftWithdrawTx, makeEndFlashLoanIx3 as makeEndFlashLoanIx, makeFlashLoanTx, makeJuplendDepositIx2 as makeJuplendDepositIx, makeJuplendDepositTx, makeJuplendWithdrawIx2 as makeJuplendWithdrawIx, makeJuplendWithdrawTx, makeKaminoDepositIx3 as makeKaminoDepositIx, makeKaminoDepositTx, makeKaminoWithdrawIx3 as makeKaminoWithdrawIx, makeKaminoWithdrawTx, makeLoopTx, makeMergeStakeAccountsTx, makeMintStakedLstIx, makeMintStakedLstTx, makePoolAddBankIx3 as makePoolAddBankIx, makePoolConfigureBankIx3 as makePoolConfigureBankIx, makePriorityFeeIx, makePriorityFeeMicroIx, makePulseHealthIx2 as makePulseHealthIx, makeRedeemStakedLstIx, makeRedeemStakedLstTx, makeRefreshKaminoBanksIxs, makeRepayIx3 as makeRepayIx, makeRepayTx, makeRepayWithCollatTx, makeRollPtTx, makeSetupIx, makeSmartCrankSwbFeedIx, makeSwapCollateralTx, makeSwapDebtTx, makeTransferPositionsTx, makeTxPriorityIx, makeUnwrapSolIx, makeUpdateDriftMarketIxs, makeUpdateJupLendRateIxs, makeUpdateSwbFeedIx, makeVersionedTransaction, makeWithdrawIx3 as makeWithdrawIx, makeWithdrawTx, makeWrapSolIxs, mapBrokenFeedsToOraclePrices, mapJupiterQuoteToSwapQuoteResult, mapPythBanksToOraclePrices, mapSwbBanksToOraclePrices, marginfiAccountToDto, mergeBridgeQuotes, mergeBridgeQuotesDebt, mergeBridgeQuotesLoop, nativeToUi, oraclePriceToDto, parseBalanceRaw, parseBankConfigRaw, parseBankRateLimiterRaw, parseBankRaw, parseEmodeSettingsRaw, parseEmodeTag, parseHealthCacheRaw, parseMarginfiAccountRaw, parseOperationalState, parseOracleSetup, parseOraclePriceData as parsePriceInfo, parseRiskTier, parseRpcPythPriceData, parseSwbOraclePriceData, partitionBanksByCrankability, patchDepositAmount, requireBank, requireTokenProgram, resolveAmount, resolveBridgeBanks, runSwapEngine, selectLutsForAccountAction, selectLutsForBanks, serializeBankConfigOpt, serializeInstruction, serializeInterestRateConfig, serializeLut, serializeOperationalState, serializeOracleSetup, serializeOracleSetupToIndex, serializeRiskTier, serializeSwapEngineRequest, serializeSwapEngineResult, shortenAddress, simulateAccountHealthCache, simulateAccountHealthCacheWithFallback, simulateBundle, splitInstructionsToFitTransactions, swapEngineProvidersFromOpts, swapEngineQuoteFieldsFromOpts, toBankConfigDto, toBankDto, toBankRateLimiterDto, toBigNumber, toEmodeSettingsDto, toInterestRateConfigDto, toJupiterConfig, toNumber, uiToNative, uiToNativeBigNumber, validatorStakeGroupToDto, wrappedI80F48toBigNumber };
|
|
75988
|
+
export { ADDRESS_LOOKUP_TABLE_FOR_GROUP, ADDRESS_LOOKUP_TABLE_FOR_GROUP_NATIVE_STAKE, ADDRESS_LOOKUP_TABLE_FOR_SWAP, AccountFlags, AccountType, AssetTag, BUNDLE_TX_SIZE, Balance, Bank, BankConfig, BankConfigFlag, BankVaultType, DEFAULT_CROSSBAR_URL, DEFAULT_FALLBACK_CROSSBAR_URL, DEFAULT_ORACLE_MAX_AGE, DEFAULT_REPAY_ALL_EXTRA_BUFFER_BPS, DISABLED_FLAG, EMPTY_HEALTH_CACHE, EmodeEntryFlags, EmodeFlags, EmodeImpactStatus, EmodeSettings, EmodeTag, FLASHLOAN_ENABLED_FLAG, HOURS_PER_YEAR, HealthCache, HealthCacheFlags, HealthCacheSimulationError, HealthCacheStatus, JUPITER_V6_PROGRAM, JUP_SWAP_LUT_PROGRAM_AUTHORITY_INDEX, LST_MINT, MARGINFI_IDL, MARGINFI_PROGRAM, MARGINFI_PROGRAM_STAGING, MARGINFI_PROGRAM_STAGING_ALT, MARGINFI_SPONSORED_SHARD_ID, MAX_ACCOUNT_LOCKS, MAX_CONFIDENCE_INTERVAL_RATIO, MAX_TX_SIZE, MAX_U64, MPL_METADATA_PROGRAM_ID, MarginRequirementType, MarginfiAccount, MarginfiAccountWrapper, MarginfiGroup, OperationalState, OracleSetup, PDA_BANK_EMISSIONS_AUTH_SEED, PDA_BANK_EMISSIONS_VAULT_SEED, PDA_BANK_FEE_STATE_SEED, PDA_BANK_FEE_VAULT_AUTH_SEED, PDA_BANK_FEE_VAULT_SEED, PDA_BANK_INSURANCE_VAULT_AUTH_SEED, PDA_BANK_INSURANCE_VAULT_SEED, PDA_BANK_LIQUIDITY_VAULT_AUTH_SEED, PDA_BANK_LIQUIDITY_VAULT_SEED, PDA_MARGINFI_ACCOUNT_SEED, PRIORITY_TX_SIZE, PYTH_PRICE_CONF_INTERVALS, PYTH_PUSH_ORACLE_ID, PYTH_SPONSORED_SHARD_ID, PriceBias, Project0Client, RiskTier, SINGLE_POOL_PROGRAM_ID, STAKED_ORACLE_DISABLED_FLAG, STAKED_ORACLE_USES_ONRAMP_FLAG, STAKE_CONFIG_ID, STAKE_PROGRAM_ID, SWAP_ADAPTERS, SWB_PRICE_CONF_INTERVALS, SYSTEM_PROGRAM_ID, SYSVAR_CLOCK_ID, SYSVAR_RENT_ID, SYSVAR_STAKE_HISTORY_ID, SwapProvider, TRANSFER_ACCOUNT_AUTHORITY_FLAG, TransactionArenaKeyMap, TransactionBuildingError, TransactionBuildingErrorCode, TransactionConfigMap, TransactionType, USDC_DECIMALS, USDC_MINT, WSOL_MINT, ZERO_ORACLE_KEY, accountConflictsWithBridge, accountFlagToBN, addOracleToBanksIx, addTransactionMetadata, adjustPriceComponent, aprToApy, apyToApr, balanceToDto, bankConfigRawToDto, bankConfigToBankConfigRaw, bankMetadataMapToDto, bankMetadataToDto, bankRateLimiterRawToDto, bankRawToDto, bigNumberToWrappedI80F48, bpsToPercentile, buildCollateralLegIxs, calculateApyFromInterest, calculateInterestFromApy, capConfidenceInterval, categorizePythBanks, checkBatchOracleCrankability, checkJupiterFeeAccount, checkMultipleOraclesCrankability, checkTitanFeeAccount, chunkedGetRawMultipleAccountInfoOrdered, chunkedGetRawMultipleAccountInfoOrderedWithNulls, chunkedGetRawMultipleAccountInfos, classifyAndValidate, compileFlashloanPrecheck, composeBridgedSwap, composeRemainingAccounts, computeAccountValue, computeActiveEmodePairs, computeAssetHealthComponent, computeAssetUsdValue, computeBalanceUsdValue, computeBankBorrowApy, computeBankBorrowCapRemaining, computeBankDepositCapRemaining, computeBankMetrics, computeBankPoolSize, computeBankSupplyApy, computeBankTotalBorrows, computeBankTotalBorrowsUsd, computeBankTotalDeposits, computeBankTotalDepositsUsd, computeBaseInterestRate, computeBorrowEstimateForRepay, computeClaimedEmissions, computeClosePositionTokenAmount, computeEmodeImpacts, computeFlashLoanNonSwapBudget, computeFlashloanSwapConstraints, computeFreeCollateralFromBalances, computeFreeCollateralFromCache, computeHealthAccountMetas, computeHealthCacheStatus, computeHealthCheckAccounts, computeHealthComponentsFromBalances, computeHealthComponentsFromCache, computeInterestRates, computeLiabilityHealthComponent, computeLiabilityUsdValue, computeLiquidationPriceForBank, computeLoopingParams, computeLowestEmodeWeights, computeMaxBorrowForBank, computeMaxLeverage, computeMaxWithdrawForBank, computeNetApy, computeProjectedActiveBalancesNoCpi, computeProjectedActiveBanksNoCpi, computeQuantity, computeQuantityUi, computeRemainingCapacity, computeSmartCrank, computeStakedBankMultipliers, computeTotalOutstandingEmissions, computeTvl, computeUsdValue, computeUtilizationRate, computeV0TxSize, convertVoteAccCoeffsToBankCoeffs, createActiveEmodePairFromPairs, createEmptyBalance, decodeAccountRaw, decodeBankRaw, decodeInstruction, decompileV0Transaction, deriveBankEmissionsAuth, deriveBankEmissionsVault, deriveBankFeeVault, deriveBankFeeVaultAuthority, deriveBankInsuranceVault, deriveBankInsuranceVaultAuthority, deriveBankLiquidityVault, deriveBankLiquidityVaultAuthority, deriveFeeState, deriveMarginfiAccount, deserializeInstruction, deserializeLut, deserializeSwapEngineRequest, deserializeSwapEngineResult, dtoToBalance, dtoToBank, dtoToBankConfig, dtoToBankConfigRaw, dtoToBankMetadata, dtoToBankMetadataMap, dtoToBankRateLimiter, dtoToBankRateLimiterRaw, dtoToBankRaw, dtoToEmodeSettings, dtoToEmodeSettingsRaw, dtoToGroup, dtoToHealthCache, dtoToInterestRateConfig, dtoToMarginfiAccount, dtoToOraclePrice, dtoToValidatorStakeGroup, emodeSettingsRawToDto, extractPythOracleKeys, fetchBank, fetchBankIntegrationMetadata, fetchMarginfiAccountActiveBalancesForBank, fetchMarginfiAccountAddresses, fetchMarginfiAccountAddressesHoldingBank, fetchMarginfiAccountData, fetchMultipleBanks, fetchNativeStakeAccounts, fetchOracleData, fetchProgramForMints, fetchPythOracleData, fetchPythOraclePricesFromAPI, fetchPythOraclePricesFromChain, fetchStakeAccount, fetchStakePoolActiveStates, fetchStakePoolMev, fetchSwbOracleAccountsFromAPI, fetchSwbOracleAccountsFromChain, fetchSwbOracleData, fetchSwbOraclePricesFromAPI, fetchSwbOraclePricesFromCrossbar, findRandomAvailableAccountIndex, freezeBankConfigIx, generateDummyAccount, getAccountKeys, getActiveAccountFlags, getActiveBalances, getActiveEmodeEntryFlags, getActiveEmodeFlags, getActiveHealthCacheFlags, getAssetQuantity, getAssetShares, getAssetWeight, getBalance, getBalanceUsdValueWithPriceBias, getBankVaultAuthority, getBankVaultSeeds, getBirdeyeFallbackPricesByFeedId, getBirdeyePricesForMints, getConfig, getDriftCTokenMultiplier, getDriftMetadata, getDriftStatesDto, getEmodePairs, getExactOutEstimate, getFallbackPricesByFeedId, getFallbackPricesForMints, getHealthCacheStatusDescription, getHealthSimulationTransactions, getJupLendFTokenMultiplier, getJupLendMetadata, getJupLendStatesDto, getJupiterReferralFeeAccount, getJupiterSwapIxsForFlashloan, getKaminoCTokenMultiplier, getKaminoMetadata, getKaminoStatesDto, getLiabilityQuantity, getLiabilityShares, getLiabilityWeight, getOracleSourceFromBank, getOracleSourceFromOracleSetup, getOracleSourceNameFromKey, getPrice, getPriceWithConfidence, getStakedBankMetadataMap, getSwapAdapter, getSwapIxsForFlashloan, getTitanExactOutEstimate, getTitanSwapIxsForFlashloan, getTotalAccountKeys, getTotalAssetQuantity, getTotalLiabilityQuantity, getTxSize, getValidatorVoteAccountByBank, getWritableAccountKeys, groupToDto, hasAccountFlag, hasEmodeEntryFlag, hasEmodeFlag, hasHealthCacheFlag, healthCacheToDto, isDecomposableSwapError, isDepositIx, isFlashloan, isGroupRateLimiterEnabled, isStandardBorrowable, isStandardDepositable, isV0Tx, isWeightedPrice, isWholePosition, makeAccountTransferToNewAccountTx, makeAddPermissionlessStakedBankIx, makeBeginFlashLoanIx3 as makeBeginFlashLoanIx, makeBorrowIx3 as makeBorrowIx, makeBorrowTx, makeBulkRepayTx, makeBulkWithdrawTx, makeBundleTipIx, makeCloseMarginfiAccountIx, makeCloseMarginfiAccountTx, makeCrankSwbFeedIx, makeCreateAccountIxWithProjection, makeCreateAccountTxWithProjection, makeCreateMarginfiAccountIx, makeCreateMarginfiAccountTx, makeDepositIx3 as makeDepositIx, makeDepositTx, makeDriftDepositIx3 as makeDriftDepositIx, makeDriftDepositTx, makeDriftWithdrawIx3 as makeDriftWithdrawIx, makeDriftWithdrawTx, makeEndFlashLoanIx3 as makeEndFlashLoanIx, makeFlashLoanTx, makeJuplendDepositIx2 as makeJuplendDepositIx, makeJuplendDepositTx, makeJuplendWithdrawIx2 as makeJuplendWithdrawIx, makeJuplendWithdrawTx, makeKaminoDepositIx3 as makeKaminoDepositIx, makeKaminoDepositTx, makeKaminoWithdrawIx3 as makeKaminoWithdrawIx, makeKaminoWithdrawTx, makeLoopTx, makeMergeStakeAccountsTx, makeMintStakedLstIx, makeMintStakedLstTx, makePoolAddBankIx3 as makePoolAddBankIx, makePoolConfigureBankIx3 as makePoolConfigureBankIx, makePriorityFeeIx, makePriorityFeeMicroIx, makePulseHealthIx2 as makePulseHealthIx, makeRedeemStakedLstIx, makeRedeemStakedLstTx, makeRefreshIntegrationBanksIxs, makeRefreshKaminoBanksIxs, makeRepayIx3 as makeRepayIx, makeRepayTx, makeRepayWithCollatTx, makeRollPtTx, makeSetupIx, makeSmartCrankSwbFeedIx, makeSmartCrankSwbFeedIxForAccounts, makeSwapCollateralTx, makeSwapDebtTx, makeTransferPositionsTx, makeTxPriorityIx, makeUnwrapSolIx, makeUpdateDriftMarketIxs, makeUpdateJupLendRateIxs, makeUpdateSwbFeedIx, makeVersionedTransaction, makeWithdrawIx3 as makeWithdrawIx, makeWithdrawTx, makeWrapSolIxs, mapBrokenFeedsToOraclePrices, mapJupiterQuoteToSwapQuoteResult, mapPythBanksToOraclePrices, mapSwbBanksToOraclePrices, marginfiAccountToDto, mergeBridgeQuotes, mergeBridgeQuotesDebt, mergeBridgeQuotesLoop, nativeToUi, oraclePriceToDto, parseBalanceRaw, parseBankConfigRaw, parseBankRateLimiterRaw, parseBankRaw, parseEmodeSettingsRaw, parseEmodeTag, parseHealthCacheRaw, parseMarginfiAccountRaw, parseOperationalState, parseOracleSetup, parseOraclePriceData as parsePriceInfo, parseRiskTier, parseRpcPythPriceData, parseSwbOraclePriceData, partitionBanksByCrankability, patchDepositAmount, requireBank, requireTokenProgram, resolveAmount, resolveBridgeBanks, runSwapEngine, selectLutsForAccountAction, selectLutsForBanks, serializeBankConfigOpt, serializeInstruction, serializeInterestRateConfig, serializeLut, serializeOperationalState, serializeOracleSetup, serializeOracleSetupToIndex, serializeRiskTier, serializeSwapEngineRequest, serializeSwapEngineResult, shortenAddress, simulateAccountHealthCache, simulateAccountHealthCacheWithFallback, simulateBundle, splitInstructionsToFitTransactions, swapEngineProvidersFromOpts, swapEngineQuoteFieldsFromOpts, toBankConfigDto, toBankDto, toBankRateLimiterDto, toBigNumber, toEmodeSettingsDto, toInterestRateConfigDto, toJupiterConfig, toNumber, uiToNative, uiToNativeBigNumber, validatorStakeGroupToDto, wrappedI80F48toBigNumber };
|
|
76036
75989
|
//# sourceMappingURL=index.js.map
|
|
76037
75990
|
//# sourceMappingURL=index.js.map
|