@0dotxyz/p0-ts-sdk 2.5.4 → 2.5.5-alpha.1
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 +582 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +168 -2
- package/dist/index.d.ts +168 -2
- package/dist/index.js +580 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -100,6 +100,9 @@ var TransactionBuildingErrorCode = /* @__PURE__ */ ((TransactionBuildingErrorCod
|
|
|
100
100
|
TransactionBuildingErrorCode2["JUPLEND_STATE_NOT_FOUND"] = "JUPLEND_STATE_NOT_FOUND";
|
|
101
101
|
TransactionBuildingErrorCode2["SWITCHBOARD_FEED_UPDATE_FAILED"] = "SWITCHBOARD_FEED_UPDATE_FAILED";
|
|
102
102
|
TransactionBuildingErrorCode2["SWAP_QUOTE_FAILED"] = "SWAP_QUOTE_FAILED";
|
|
103
|
+
TransactionBuildingErrorCode2["TRANSFER_POSITIONS_INVALID_SELECTION"] = "TRANSFER_POSITIONS_INVALID_SELECTION";
|
|
104
|
+
TransactionBuildingErrorCode2["TRANSFER_POSITIONS_UNSUPPORTED_BANK"] = "TRANSFER_POSITIONS_UNSUPPORTED_BANK";
|
|
105
|
+
TransactionBuildingErrorCode2["TRANSFER_POSITIONS_UNSPLITTABLE"] = "TRANSFER_POSITIONS_UNSPLITTABLE";
|
|
103
106
|
return TransactionBuildingErrorCode2;
|
|
104
107
|
})(TransactionBuildingErrorCode || {});
|
|
105
108
|
var TransactionBuildingError = class _TransactionBuildingError extends Error {
|
|
@@ -196,6 +199,40 @@ var TransactionBuildingError = class _TransactionBuildingError extends Error {
|
|
|
196
199
|
{ provider, inputMint, outputMint, reason }
|
|
197
200
|
);
|
|
198
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* The requested set of positions to transfer is invalid (inactive bank on the source,
|
|
204
|
+
* destination overlap, capacity/slot conflict, group/authority mismatch, etc.).
|
|
205
|
+
*/
|
|
206
|
+
static transferPositionsInvalidSelection(reason, bankAddresses) {
|
|
207
|
+
return new _TransactionBuildingError(
|
|
208
|
+
"TRANSFER_POSITIONS_INVALID_SELECTION" /* TRANSFER_POSITIONS_INVALID_SELECTION */,
|
|
209
|
+
`Invalid transfer-positions selection: ${reason}`,
|
|
210
|
+
{ reason, bankAddresses }
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* A selected position lives in a bank whose asset tag is not supported by transfer-positions
|
|
215
|
+
* (v1 supports DEFAULT and STAKED only).
|
|
216
|
+
*/
|
|
217
|
+
static transferPositionsUnsupportedBank(bankAddress, assetTag, bankSymbol) {
|
|
218
|
+
return new _TransactionBuildingError(
|
|
219
|
+
"TRANSFER_POSITIONS_UNSUPPORTED_BANK" /* TRANSFER_POSITIONS_UNSUPPORTED_BANK */,
|
|
220
|
+
`Bank ${bankSymbol ?? bankAddress} (asset tag ${assetTag}) is not supported by transfer-positions`,
|
|
221
|
+
{ bankAddress, assetTag, bankSymbol }
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* The built transfer transaction exceeds the v0 size / account-lock limits even at the position
|
|
226
|
+
* cap (most likely several integration positions whose reserve accounts overflow the 64-lock cap).
|
|
227
|
+
* Retry with fewer positions in the selection.
|
|
228
|
+
*/
|
|
229
|
+
static transferPositionsUnsplittable(reason, sizeBytes, accountCount) {
|
|
230
|
+
return new _TransactionBuildingError(
|
|
231
|
+
"TRANSFER_POSITIONS_UNSPLITTABLE" /* TRANSFER_POSITIONS_UNSPLITTABLE */,
|
|
232
|
+
`Transfer does not fit one transaction: ${reason}`,
|
|
233
|
+
{ reason, sizeBytes, accountCount }
|
|
234
|
+
);
|
|
235
|
+
}
|
|
199
236
|
/**
|
|
200
237
|
* Generic escape hatch for custom errors
|
|
201
238
|
*/
|
|
@@ -69406,6 +69443,23 @@ var MarginfiAccount = class _MarginfiAccount {
|
|
|
69406
69443
|
}
|
|
69407
69444
|
});
|
|
69408
69445
|
}
|
|
69446
|
+
/**
|
|
69447
|
+
* Atomically move a selected set of positions from this account to a destination account
|
|
69448
|
+
* (same authority, same group) using flashloans, auto-splitting across transactions as needed.
|
|
69449
|
+
*
|
|
69450
|
+
* @see {@link makeTransferPositionsTx} for detailed implementation
|
|
69451
|
+
*/
|
|
69452
|
+
async makeTransferPositionsTx(params) {
|
|
69453
|
+
return makeTransferPositionsTx({
|
|
69454
|
+
...params,
|
|
69455
|
+
marginfiAccount: this,
|
|
69456
|
+
overrideInferAccounts: {
|
|
69457
|
+
authority: this.authority,
|
|
69458
|
+
group: this.group,
|
|
69459
|
+
...params.overrideInferAccounts
|
|
69460
|
+
}
|
|
69461
|
+
});
|
|
69462
|
+
}
|
|
69409
69463
|
/**
|
|
69410
69464
|
* Creates a transaction to repay debt using collateral.
|
|
69411
69465
|
*
|
|
@@ -69865,6 +69919,499 @@ async function composeBridgedSwap(params) {
|
|
|
69865
69919
|
if (!transactions) return null;
|
|
69866
69920
|
return { transactions, firstLegQuote: firstLeg.quoteResponse, secondLegQuote: secondLeg.quoteResponse };
|
|
69867
69921
|
}
|
|
69922
|
+
var MAX_BALANCES = 16;
|
|
69923
|
+
var DEFAULT_MAX_TRANSFER_POSITIONS = 5;
|
|
69924
|
+
var DEFAULT_BORROW_PADDING_BPS = 10;
|
|
69925
|
+
var CU_IXS = () => [
|
|
69926
|
+
ComputeBudgetProgram.setComputeUnitLimit({ units: 14e5 }),
|
|
69927
|
+
ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 1 })
|
|
69928
|
+
];
|
|
69929
|
+
function requireBank(bankMap, address) {
|
|
69930
|
+
const bank = bankMap.get(address.toBase58());
|
|
69931
|
+
if (!bank) {
|
|
69932
|
+
throw TransactionBuildingError.transferPositionsInvalidSelection(
|
|
69933
|
+
`bank ${address.toBase58()} not found`,
|
|
69934
|
+
[address.toBase58()]
|
|
69935
|
+
);
|
|
69936
|
+
}
|
|
69937
|
+
return bank;
|
|
69938
|
+
}
|
|
69939
|
+
function requireTokenProgram(tokenProgramsByBank, address) {
|
|
69940
|
+
const tp = tokenProgramsByBank.get(address.toBase58());
|
|
69941
|
+
if (!tp) {
|
|
69942
|
+
throw TransactionBuildingError.transferPositionsInvalidSelection(
|
|
69943
|
+
`token program for bank ${address.toBase58()} not provided`,
|
|
69944
|
+
[address.toBase58()]
|
|
69945
|
+
);
|
|
69946
|
+
}
|
|
69947
|
+
return tp;
|
|
69948
|
+
}
|
|
69949
|
+
function classifyAndValidate(params) {
|
|
69950
|
+
const {
|
|
69951
|
+
marginfiAccount: accountA,
|
|
69952
|
+
destinationAccount: accountB,
|
|
69953
|
+
bankAddresses,
|
|
69954
|
+
bankMap,
|
|
69955
|
+
tokenProgramsByBank,
|
|
69956
|
+
assetShareValueMultiplierByBank
|
|
69957
|
+
} = params;
|
|
69958
|
+
const maxPositions = params.maxPositions ?? DEFAULT_MAX_TRANSFER_POSITIONS;
|
|
69959
|
+
if (bankAddresses.length === 0) {
|
|
69960
|
+
throw TransactionBuildingError.transferPositionsInvalidSelection("no positions selected", []);
|
|
69961
|
+
}
|
|
69962
|
+
if (bankAddresses.length > maxPositions) {
|
|
69963
|
+
throw TransactionBuildingError.transferPositionsInvalidSelection(
|
|
69964
|
+
`cannot transfer ${bankAddresses.length} positions in one transaction (max ${maxPositions}); select fewer and transfer in batches`,
|
|
69965
|
+
bankAddresses.map((b) => b.toBase58())
|
|
69966
|
+
);
|
|
69967
|
+
}
|
|
69968
|
+
const activeBalancesA = accountA.balances.filter((b) => b.active);
|
|
69969
|
+
const positions = [];
|
|
69970
|
+
for (const bankAddress of bankAddresses) {
|
|
69971
|
+
const bank = requireBank(bankMap, bankAddress);
|
|
69972
|
+
const tokenProgram = requireTokenProgram(tokenProgramsByBank, bankAddress);
|
|
69973
|
+
const balance = activeBalancesA.find((b) => b.bankPk.equals(bankAddress));
|
|
69974
|
+
if (!balance) {
|
|
69975
|
+
throw TransactionBuildingError.transferPositionsInvalidSelection(
|
|
69976
|
+
`source account has no active position in bank ${bankAddress.toBase58()}`,
|
|
69977
|
+
[bankAddress.toBase58()]
|
|
69978
|
+
);
|
|
69979
|
+
}
|
|
69980
|
+
const side = balance.assetShares.gt(0) ? "collateral" : "debt";
|
|
69981
|
+
const multiplier = assetShareValueMultiplierByBank.get(bankAddress.toBase58());
|
|
69982
|
+
const qty = computeQuantityUi(balance, bank, multiplier);
|
|
69983
|
+
positions.push({
|
|
69984
|
+
bankAddress,
|
|
69985
|
+
side,
|
|
69986
|
+
uiAmount: side === "collateral" ? qty.assets : qty.liabilities,
|
|
69987
|
+
bank,
|
|
69988
|
+
tokenProgram
|
|
69989
|
+
});
|
|
69990
|
+
}
|
|
69991
|
+
const isolatedDebts = positions.filter(
|
|
69992
|
+
(p) => p.side === "debt" && p.bank.config.riskTier === "Isolated" /* Isolated */
|
|
69993
|
+
);
|
|
69994
|
+
if (isolatedDebts.length > 0) {
|
|
69995
|
+
const otherDebts = positions.filter((p) => p.side === "debt").length > 1;
|
|
69996
|
+
const destHasLiabilities = (accountB?.balances ?? []).some(
|
|
69997
|
+
(b) => b.active && b.liabilityShares.gt(0)
|
|
69998
|
+
);
|
|
69999
|
+
if (isolatedDebts.length > 1 || otherDebts || destHasLiabilities) {
|
|
70000
|
+
throw TransactionBuildingError.transferPositionsInvalidSelection(
|
|
70001
|
+
"an isolated-tier debt can only be transferred as the destination account's sole liability",
|
|
70002
|
+
isolatedDebts.map((p) => p.bankAddress.toBase58())
|
|
70003
|
+
);
|
|
70004
|
+
}
|
|
70005
|
+
}
|
|
70006
|
+
if (accountB) {
|
|
70007
|
+
if (!accountB.group.equals(accountA.group)) {
|
|
70008
|
+
throw TransactionBuildingError.transferPositionsInvalidSelection(
|
|
70009
|
+
"destination account is in a different group",
|
|
70010
|
+
[accountB.address.toBase58()]
|
|
70011
|
+
);
|
|
70012
|
+
}
|
|
70013
|
+
if (!accountB.authority.equals(accountA.authority)) {
|
|
70014
|
+
throw TransactionBuildingError.transferPositionsInvalidSelection(
|
|
70015
|
+
"destination account has a different authority",
|
|
70016
|
+
[accountB.address.toBase58()]
|
|
70017
|
+
);
|
|
70018
|
+
}
|
|
70019
|
+
const overlap = positions.filter(
|
|
70020
|
+
(p) => accountB.balances.some((b) => b.active && b.bankPk.equals(p.bankAddress))
|
|
70021
|
+
);
|
|
70022
|
+
if (overlap.length > 0) {
|
|
70023
|
+
throw TransactionBuildingError.transferPositionsInvalidSelection(
|
|
70024
|
+
"destination account already holds a position in a transferred bank",
|
|
70025
|
+
overlap.map((p) => p.bankAddress.toBase58())
|
|
70026
|
+
);
|
|
70027
|
+
}
|
|
70028
|
+
const activeCountB = accountB.balances.filter((b) => b.active).length;
|
|
70029
|
+
if (activeCountB + positions.length > MAX_BALANCES) {
|
|
70030
|
+
throw TransactionBuildingError.transferPositionsInvalidSelection(
|
|
70031
|
+
`destination account cannot hold ${activeCountB + positions.length} positions (max ${MAX_BALANCES})`,
|
|
70032
|
+
positions.map((p) => p.bankAddress.toBase58())
|
|
70033
|
+
);
|
|
70034
|
+
}
|
|
70035
|
+
}
|
|
70036
|
+
return positions;
|
|
70037
|
+
}
|
|
70038
|
+
function buildIntegrationRefreshIxs(args) {
|
|
70039
|
+
const { accountA, destinationAccount, positions, bankMap, bankMetadataMap } = args;
|
|
70040
|
+
const transferredKaminoPks = positions.filter((p) => p.bank.config.assetTag === 3 /* KAMINO */).map((p) => p.bankAddress);
|
|
70041
|
+
const transferredJupPks = positions.filter((p) => p.bank.config.assetTag === 6 /* JUPLEND */).map((p) => p.bankAddress);
|
|
70042
|
+
const ixs = [];
|
|
70043
|
+
ixs.push(
|
|
70044
|
+
...makeRefreshKaminoBanksIxs(accountA, bankMap, transferredKaminoPks, bankMetadataMap).instructions
|
|
70045
|
+
);
|
|
70046
|
+
if (destinationAccount) {
|
|
70047
|
+
ixs.push(
|
|
70048
|
+
...makeRefreshKaminoBanksIxs(destinationAccount, bankMap, [], bankMetadataMap).instructions
|
|
70049
|
+
);
|
|
70050
|
+
}
|
|
70051
|
+
ixs.push(
|
|
70052
|
+
...makeUpdateJupLendRateIxs(accountA, bankMap, transferredJupPks, bankMetadataMap).instructions
|
|
70053
|
+
);
|
|
70054
|
+
if (destinationAccount) {
|
|
70055
|
+
ixs.push(
|
|
70056
|
+
...makeUpdateJupLendRateIxs(destinationAccount, bankMap, transferredJupPks, bankMetadataMap).instructions
|
|
70057
|
+
);
|
|
70058
|
+
}
|
|
70059
|
+
return ixs;
|
|
70060
|
+
}
|
|
70061
|
+
function dedupeBanks(banks) {
|
|
70062
|
+
const seen = /* @__PURE__ */ new Map();
|
|
70063
|
+
for (const bank of banks) seen.set(bank.address.toBase58(), bank);
|
|
70064
|
+
return [...seen.values()];
|
|
70065
|
+
}
|
|
70066
|
+
async function buildCollateralLegIxs(ctx, position, isSync, observationBanksOverride) {
|
|
70067
|
+
const { bank, tokenProgram, uiAmount } = position;
|
|
70068
|
+
const tag = bank.config.assetTag;
|
|
70069
|
+
const key = bank.address.toBase58();
|
|
70070
|
+
if (tag === 3 /* KAMINO */) {
|
|
70071
|
+
const reserve = ctx.bankMetadataMap[key]?.kaminoStates?.reserveState;
|
|
70072
|
+
if (!reserve) {
|
|
70073
|
+
throw TransactionBuildingError.transferPositionsInvalidSelection(
|
|
70074
|
+
`kamino reserve state missing for bank ${key} (populate bankMetadataMap.kaminoStates)`,
|
|
70075
|
+
[key]
|
|
70076
|
+
);
|
|
70077
|
+
}
|
|
70078
|
+
const multiplier = ctx.assetShareValueMultiplierByBank.get(key) ?? new BigNumber(1);
|
|
70079
|
+
const cTokenAmount = uiAmount.div(multiplier);
|
|
70080
|
+
const withdraw2 = await makeKaminoWithdrawIx3({
|
|
70081
|
+
program: ctx.program,
|
|
70082
|
+
bank,
|
|
70083
|
+
bankMap: ctx.bankMap,
|
|
70084
|
+
tokenProgram,
|
|
70085
|
+
cTokenAmount,
|
|
70086
|
+
marginfiAccount: ctx.accountA,
|
|
70087
|
+
authority: ctx.accountA.authority,
|
|
70088
|
+
reserve,
|
|
70089
|
+
bankMetadataMap: ctx.bankMetadataMap,
|
|
70090
|
+
withdrawAll: true,
|
|
70091
|
+
isSync,
|
|
70092
|
+
opts: {
|
|
70093
|
+
createAtas: false,
|
|
70094
|
+
wrapAndUnwrapSol: false,
|
|
70095
|
+
overrideInferAccounts: ctx.overrideInferAccounts,
|
|
70096
|
+
observationBanksOverride
|
|
70097
|
+
}
|
|
70098
|
+
});
|
|
70099
|
+
const deposit2 = await makeKaminoDepositIx3({
|
|
70100
|
+
program: ctx.program,
|
|
70101
|
+
bank,
|
|
70102
|
+
tokenProgram,
|
|
70103
|
+
amount: uiAmount,
|
|
70104
|
+
accountAddress: ctx.accountB.address,
|
|
70105
|
+
authority: ctx.accountA.authority,
|
|
70106
|
+
group: ctx.accountB.group,
|
|
70107
|
+
reserve,
|
|
70108
|
+
isSync,
|
|
70109
|
+
opts: { wrapAndUnwrapSol: false, overrideInferAccounts: ctx.overrideInferAccounts }
|
|
70110
|
+
});
|
|
70111
|
+
return { withdrawIxs: withdraw2.instructions, depositIxs: deposit2.instructions };
|
|
70112
|
+
}
|
|
70113
|
+
if (tag === 6 /* JUPLEND */) {
|
|
70114
|
+
const jupLendingState = ctx.bankMetadataMap[key]?.jupLendStates?.jupLendingState;
|
|
70115
|
+
if (!jupLendingState) {
|
|
70116
|
+
throw TransactionBuildingError.transferPositionsInvalidSelection(
|
|
70117
|
+
`juplend lending state missing for bank ${key} (populate bankMetadataMap.jupLendStates)`,
|
|
70118
|
+
[key]
|
|
70119
|
+
);
|
|
70120
|
+
}
|
|
70121
|
+
const withdraw2 = await makeJuplendWithdrawIx2({
|
|
70122
|
+
program: ctx.program,
|
|
70123
|
+
bank,
|
|
70124
|
+
bankMap: ctx.bankMap,
|
|
70125
|
+
tokenProgram,
|
|
70126
|
+
amount: uiAmount,
|
|
70127
|
+
marginfiAccount: ctx.accountA,
|
|
70128
|
+
authority: ctx.accountA.authority,
|
|
70129
|
+
jupLendingState,
|
|
70130
|
+
bankMetadataMap: ctx.bankMetadataMap,
|
|
70131
|
+
withdrawAll: true,
|
|
70132
|
+
opts: {
|
|
70133
|
+
createAtas: false,
|
|
70134
|
+
wrapAndUnwrapSol: false,
|
|
70135
|
+
overrideInferAccounts: ctx.overrideInferAccounts,
|
|
70136
|
+
observationBanksOverride
|
|
70137
|
+
}
|
|
70138
|
+
});
|
|
70139
|
+
const deposit2 = await makeJuplendDepositIx2({
|
|
70140
|
+
program: ctx.program,
|
|
70141
|
+
bank,
|
|
70142
|
+
tokenProgram,
|
|
70143
|
+
amount: uiAmount,
|
|
70144
|
+
accountAddress: ctx.accountB.address,
|
|
70145
|
+
authority: ctx.accountA.authority,
|
|
70146
|
+
group: ctx.accountB.group,
|
|
70147
|
+
isSync,
|
|
70148
|
+
opts: { wrapAndUnwrapSol: false, overrideInferAccounts: ctx.overrideInferAccounts }
|
|
70149
|
+
});
|
|
70150
|
+
return { withdrawIxs: withdraw2.instructions, depositIxs: deposit2.instructions };
|
|
70151
|
+
}
|
|
70152
|
+
if (tag !== 0 /* DEFAULT */ && tag !== 1 /* SOL */ && tag !== 2 /* STAKED */) {
|
|
70153
|
+
throw TransactionBuildingError.transferPositionsUnsupportedBank(key, tag, bank.tokenSymbol);
|
|
70154
|
+
}
|
|
70155
|
+
const withdraw = await makeWithdrawIx3({
|
|
70156
|
+
program: ctx.program,
|
|
70157
|
+
bank,
|
|
70158
|
+
bankMap: ctx.bankMap,
|
|
70159
|
+
tokenProgram,
|
|
70160
|
+
amount: uiAmount,
|
|
70161
|
+
marginfiAccount: ctx.accountA,
|
|
70162
|
+
authority: ctx.accountA.authority,
|
|
70163
|
+
withdrawAll: true,
|
|
70164
|
+
bankMetadataMap: ctx.bankMetadataMap,
|
|
70165
|
+
isSync,
|
|
70166
|
+
opts: {
|
|
70167
|
+
createAtas: false,
|
|
70168
|
+
wrapAndUnwrapSol: false,
|
|
70169
|
+
overrideInferAccounts: ctx.overrideInferAccounts,
|
|
70170
|
+
observationBanksOverride
|
|
70171
|
+
}
|
|
70172
|
+
});
|
|
70173
|
+
const deposit = await makeDepositIx3({
|
|
70174
|
+
program: ctx.program,
|
|
70175
|
+
bank,
|
|
70176
|
+
tokenProgram,
|
|
70177
|
+
amount: uiAmount,
|
|
70178
|
+
accountAddress: ctx.accountB.address,
|
|
70179
|
+
authority: ctx.accountA.authority,
|
|
70180
|
+
group: ctx.accountB.group,
|
|
70181
|
+
isSync,
|
|
70182
|
+
opts: { wrapAndUnwrapSol: false, overrideInferAccounts: ctx.overrideInferAccounts }
|
|
70183
|
+
});
|
|
70184
|
+
return { withdrawIxs: withdraw.instructions, depositIxs: deposit.instructions };
|
|
70185
|
+
}
|
|
70186
|
+
async function buildInnerIxs(ctx, positions, isSync) {
|
|
70187
|
+
const collateral = positions.filter((p) => p.side === "collateral");
|
|
70188
|
+
const debts = positions.filter((p) => p.side === "debt");
|
|
70189
|
+
const collateralBanks = collateral.map((p) => p.bank);
|
|
70190
|
+
const withdrawIxs = [];
|
|
70191
|
+
const depositIxs = [];
|
|
70192
|
+
const borrowIxs = [];
|
|
70193
|
+
const repayIxs = [];
|
|
70194
|
+
for (const position of collateral) {
|
|
70195
|
+
const observationBanksOverride = ctx.groupRateLimiterEnabled ? computeHealthAccountMetas([], true, [position.bank]) : [];
|
|
70196
|
+
const legs = await buildCollateralLegIxs(ctx, position, isSync, observationBanksOverride);
|
|
70197
|
+
withdrawIxs.push(...legs.withdrawIxs);
|
|
70198
|
+
depositIxs.push(...legs.depositIxs);
|
|
70199
|
+
}
|
|
70200
|
+
const transferredKaminoPks = collateral.filter((p) => p.bank.config.assetTag === 3 /* KAMINO */).map((p) => p.bankAddress);
|
|
70201
|
+
const kaminoReRefreshIxs = transferredKaminoPks.length > 0 ? makeRefreshKaminoBanksIxs(
|
|
70202
|
+
ctx.accountA,
|
|
70203
|
+
ctx.bankMap,
|
|
70204
|
+
transferredKaminoPks,
|
|
70205
|
+
ctx.bankMetadataMap
|
|
70206
|
+
).instructions : [];
|
|
70207
|
+
const borrowedSoFar = [];
|
|
70208
|
+
for (const position of debts) {
|
|
70209
|
+
const { bank, tokenProgram } = position;
|
|
70210
|
+
borrowedSoFar.push(bank);
|
|
70211
|
+
const activeBanks = dedupeBanks([
|
|
70212
|
+
...ctx.destPreexistingBanks,
|
|
70213
|
+
...collateralBanks,
|
|
70214
|
+
...borrowedSoFar
|
|
70215
|
+
]);
|
|
70216
|
+
const observationBanksOverride = computeHealthAccountMetas(activeBanks);
|
|
70217
|
+
const borrowUi = position.uiAmount.times(1 + ctx.borrowPaddingBps / 1e4);
|
|
70218
|
+
const borrow = await makeBorrowIx3({
|
|
70219
|
+
program: ctx.program,
|
|
70220
|
+
bank,
|
|
70221
|
+
bankMap: ctx.bankMap,
|
|
70222
|
+
tokenProgram,
|
|
70223
|
+
amount: borrowUi,
|
|
70224
|
+
marginfiAccount: ctx.accountB,
|
|
70225
|
+
authority: ctx.accountA.authority,
|
|
70226
|
+
isSync,
|
|
70227
|
+
opts: {
|
|
70228
|
+
createAtas: false,
|
|
70229
|
+
wrapAndUnwrapSol: false,
|
|
70230
|
+
overrideInferAccounts: ctx.overrideInferAccounts,
|
|
70231
|
+
observationBanksOverride
|
|
70232
|
+
}
|
|
70233
|
+
});
|
|
70234
|
+
borrowIxs.push(...borrow.instructions);
|
|
70235
|
+
const repay = await makeRepayIx3({
|
|
70236
|
+
program: ctx.program,
|
|
70237
|
+
bank,
|
|
70238
|
+
tokenProgram,
|
|
70239
|
+
amount: position.uiAmount,
|
|
70240
|
+
accountAddress: ctx.accountA.address,
|
|
70241
|
+
authority: ctx.accountA.authority,
|
|
70242
|
+
repayAll: true,
|
|
70243
|
+
isSync,
|
|
70244
|
+
opts: {
|
|
70245
|
+
wrapAndUnwrapSol: false,
|
|
70246
|
+
overrideInferAccounts: ctx.overrideInferAccounts
|
|
70247
|
+
}
|
|
70248
|
+
});
|
|
70249
|
+
repayIxs.push(...repay.instructions);
|
|
70250
|
+
}
|
|
70251
|
+
return [
|
|
70252
|
+
...CU_IXS(),
|
|
70253
|
+
...withdrawIxs,
|
|
70254
|
+
...kaminoReRefreshIxs,
|
|
70255
|
+
...depositIxs,
|
|
70256
|
+
...borrowIxs,
|
|
70257
|
+
...repayIxs
|
|
70258
|
+
];
|
|
70259
|
+
}
|
|
70260
|
+
async function buildTransferFlashloanTx(args) {
|
|
70261
|
+
const { program, accountA, projectedActiveBanksA, innerIxs, preIxs, blockhash, luts } = args;
|
|
70262
|
+
const endIndex = preIxs.length + innerIxs.length + 1;
|
|
70263
|
+
const begin = await makeBeginFlashLoanIx3(program, accountA.address, endIndex, accountA.authority);
|
|
70264
|
+
const end = await makeEndFlashLoanIx3(
|
|
70265
|
+
program,
|
|
70266
|
+
accountA.address,
|
|
70267
|
+
projectedActiveBanksA,
|
|
70268
|
+
accountA.authority
|
|
70269
|
+
);
|
|
70270
|
+
const message = new TransactionMessage({
|
|
70271
|
+
payerKey: accountA.authority,
|
|
70272
|
+
recentBlockhash: blockhash,
|
|
70273
|
+
instructions: [...preIxs, ...begin.instructions, ...innerIxs, ...end.instructions]
|
|
70274
|
+
}).compileToV0Message(luts);
|
|
70275
|
+
return addTransactionMetadata(new VersionedTransaction(message), {
|
|
70276
|
+
addressLookupTables: luts,
|
|
70277
|
+
type: "FLASHLOAN" /* FLASHLOAN */
|
|
70278
|
+
});
|
|
70279
|
+
}
|
|
70280
|
+
function destPreexistingBanksOf(account, bankMap) {
|
|
70281
|
+
if (!account) return [];
|
|
70282
|
+
return dedupeBanks(
|
|
70283
|
+
account.balances.filter((b) => b.active).map((b) => bankMap.get(b.bankPk.toBase58())).filter((b) => Boolean(b))
|
|
70284
|
+
);
|
|
70285
|
+
}
|
|
70286
|
+
async function makeTransferPositionsTx(params) {
|
|
70287
|
+
const {
|
|
70288
|
+
program,
|
|
70289
|
+
connection,
|
|
70290
|
+
marginfiAccount: accountA,
|
|
70291
|
+
bankMap,
|
|
70292
|
+
bankMetadataMap,
|
|
70293
|
+
oraclePrices,
|
|
70294
|
+
assetShareValueMultiplierByBank,
|
|
70295
|
+
addressLookupTableAccounts,
|
|
70296
|
+
crossbarUrl,
|
|
70297
|
+
overrideInferAccounts
|
|
70298
|
+
} = params;
|
|
70299
|
+
const luts = addressLookupTableAccounts ?? [];
|
|
70300
|
+
const borrowPaddingBps = params.borrowPaddingBps ?? DEFAULT_BORROW_PADDING_BPS;
|
|
70301
|
+
const groupRateLimiterEnabled = params.groupRateLimiterEnabled ?? false;
|
|
70302
|
+
const positions = classifyAndValidate(params);
|
|
70303
|
+
let accountB = params.destinationAccount;
|
|
70304
|
+
let createIx;
|
|
70305
|
+
if (!accountB) {
|
|
70306
|
+
const accountIndex = params.createDestinationOpts?.accountIndex ?? await findRandomAvailableAccountIndex(
|
|
70307
|
+
connection,
|
|
70308
|
+
program.programId,
|
|
70309
|
+
accountA.group,
|
|
70310
|
+
accountA.authority
|
|
70311
|
+
);
|
|
70312
|
+
const created = await makeCreateAccountIxWithProjection({
|
|
70313
|
+
program,
|
|
70314
|
+
authority: accountA.authority,
|
|
70315
|
+
group: accountA.group,
|
|
70316
|
+
accountIndex,
|
|
70317
|
+
thirdPartyId: params.createDestinationOpts?.thirdPartyId
|
|
70318
|
+
});
|
|
70319
|
+
accountB = created.account;
|
|
70320
|
+
createIx = created.ix;
|
|
70321
|
+
}
|
|
70322
|
+
const ctx = {
|
|
70323
|
+
program,
|
|
70324
|
+
accountA,
|
|
70325
|
+
accountB,
|
|
70326
|
+
bankMap,
|
|
70327
|
+
bankMetadataMap,
|
|
70328
|
+
assetShareValueMultiplierByBank,
|
|
70329
|
+
borrowPaddingBps,
|
|
70330
|
+
groupRateLimiterEnabled,
|
|
70331
|
+
overrideInferAccounts,
|
|
70332
|
+
destPreexistingBanks: destPreexistingBanksOf(params.destinationAccount, bankMap)
|
|
70333
|
+
};
|
|
70334
|
+
const innerIxs = await buildInnerIxs(ctx, positions, false);
|
|
70335
|
+
const transferred = new Set(positions.map((p) => p.bankAddress.toBase58()));
|
|
70336
|
+
const projectedActiveBanksA = dedupeBanks(
|
|
70337
|
+
accountA.balances.filter((b) => b.active && !transferred.has(b.bankPk.toBase58())).map((b) => requireBank(bankMap, b.bankPk))
|
|
70338
|
+
);
|
|
70339
|
+
const blockhash = (await connection.getLatestBlockhash("confirmed")).blockhash;
|
|
70340
|
+
const preIxs = createIx ? [createIx] : [];
|
|
70341
|
+
const flashloanTx = await buildTransferFlashloanTx({
|
|
70342
|
+
program,
|
|
70343
|
+
accountA,
|
|
70344
|
+
projectedActiveBanksA,
|
|
70345
|
+
innerIxs,
|
|
70346
|
+
preIxs,
|
|
70347
|
+
blockhash,
|
|
70348
|
+
luts
|
|
70349
|
+
});
|
|
70350
|
+
const size = getTxSize(flashloanTx);
|
|
70351
|
+
const keys = getTotalAccountKeys(flashloanTx);
|
|
70352
|
+
if (size > MAX_TX_SIZE || keys > MAX_ACCOUNT_LOCKS) {
|
|
70353
|
+
throw TransactionBuildingError.transferPositionsUnsplittable(
|
|
70354
|
+
`built transaction exceeds size limits (${size} bytes, ${keys} accounts); transfer fewer positions`,
|
|
70355
|
+
size,
|
|
70356
|
+
keys
|
|
70357
|
+
);
|
|
70358
|
+
}
|
|
70359
|
+
const setupIxs = await makeSetupIx({
|
|
70360
|
+
connection,
|
|
70361
|
+
authority: accountA.authority,
|
|
70362
|
+
tokens: positions.map((p) => ({ mint: p.bank.mint, tokenProgram: p.tokenProgram }))
|
|
70363
|
+
});
|
|
70364
|
+
const refreshIxs = buildIntegrationRefreshIxs({
|
|
70365
|
+
accountA,
|
|
70366
|
+
destinationAccount: params.destinationAccount,
|
|
70367
|
+
positions,
|
|
70368
|
+
bankMap,
|
|
70369
|
+
bankMetadataMap
|
|
70370
|
+
});
|
|
70371
|
+
const additionalTxs = [];
|
|
70372
|
+
const preludeIxs = [...setupIxs, ...refreshIxs];
|
|
70373
|
+
if (preludeIxs.length > 0) {
|
|
70374
|
+
const txs = splitInstructionsToFitTransactions([], preludeIxs, {
|
|
70375
|
+
blockhash,
|
|
70376
|
+
payerKey: accountA.authority,
|
|
70377
|
+
luts
|
|
70378
|
+
});
|
|
70379
|
+
additionalTxs.push(
|
|
70380
|
+
...txs.map(
|
|
70381
|
+
(tx) => addTransactionMetadata(tx, { type: "CREATE_ATA" /* CREATE_ATA */, addressLookupTables: luts })
|
|
70382
|
+
)
|
|
70383
|
+
);
|
|
70384
|
+
}
|
|
70385
|
+
const { instructions: updateFeedIxs, luts: feedLuts } = await makeSmartCrankSwbFeedIx({
|
|
70386
|
+
marginfiAccount: accountA,
|
|
70387
|
+
bankMap,
|
|
70388
|
+
oraclePrices,
|
|
70389
|
+
assetShareValueMultiplierByBank,
|
|
70390
|
+
instructions: innerIxs,
|
|
70391
|
+
program,
|
|
70392
|
+
connection,
|
|
70393
|
+
crossbarUrl
|
|
70394
|
+
});
|
|
70395
|
+
if (updateFeedIxs.length > 0) {
|
|
70396
|
+
const message = new TransactionMessage({
|
|
70397
|
+
payerKey: accountA.authority,
|
|
70398
|
+
recentBlockhash: blockhash,
|
|
70399
|
+
instructions: updateFeedIxs
|
|
70400
|
+
}).compileToV0Message(feedLuts);
|
|
70401
|
+
additionalTxs.push(
|
|
70402
|
+
addTransactionMetadata(new VersionedTransaction(message), {
|
|
70403
|
+
addressLookupTables: feedLuts,
|
|
70404
|
+
type: "CRANK" /* CRANK */
|
|
70405
|
+
})
|
|
70406
|
+
);
|
|
70407
|
+
}
|
|
70408
|
+
const transactions = [...additionalTxs, flashloanTx];
|
|
70409
|
+
return {
|
|
70410
|
+
transactions,
|
|
70411
|
+
actionTxIndex: additionalTxs.length,
|
|
70412
|
+
destinationAccount: accountB
|
|
70413
|
+
};
|
|
70414
|
+
}
|
|
69868
70415
|
|
|
69869
70416
|
// src/services/account/services/account-simulation.service.ts
|
|
69870
70417
|
async function simulateAccountHealthCacheWithFallback(params) {
|
|
@@ -70274,7 +70821,7 @@ var GROUP_OFFSET = 8;
|
|
|
70274
70821
|
var BALANCES_OFFSET = 72;
|
|
70275
70822
|
var BALANCE_SIZE = 104;
|
|
70276
70823
|
var BANK_PK_OFFSET_IN_BALANCE = 1;
|
|
70277
|
-
var
|
|
70824
|
+
var MAX_BALANCES2 = 16;
|
|
70278
70825
|
var scanBankSlots = async (program, group, bank, options) => {
|
|
70279
70826
|
const connection = program.provider.connection;
|
|
70280
70827
|
const programId = program.programId;
|
|
@@ -70282,7 +70829,7 @@ var scanBankSlots = async (program, group, bank, options) => {
|
|
|
70282
70829
|
const groupBytes = group.toBase58();
|
|
70283
70830
|
const bankBytes = bank.toBase58();
|
|
70284
70831
|
const slotOffsets = Array.from(
|
|
70285
|
-
{ length:
|
|
70832
|
+
{ length: MAX_BALANCES2 },
|
|
70286
70833
|
(_, n) => BALANCES_OFFSET + BANK_PK_OFFSET_IN_BALANCE + n * BALANCE_SIZE
|
|
70287
70834
|
);
|
|
70288
70835
|
const scanSlot = (offset) => {
|
|
@@ -74313,6 +74860,36 @@ var MarginfiAccountWrapper = class {
|
|
|
74313
74860
|
};
|
|
74314
74861
|
return this.account.makeLoopTx(fullParams);
|
|
74315
74862
|
}
|
|
74863
|
+
/**
|
|
74864
|
+
* Atomically move a selected set of positions from this account to a destination account with
|
|
74865
|
+
* auto-injected client data.
|
|
74866
|
+
*
|
|
74867
|
+
* Auto-injects: program, connection, marginfiAccount, bankMap, oraclePrices, bankMetadataMap,
|
|
74868
|
+
* assetShareValueMultiplierByBank, addressLookupTables, tokenProgramsByBank, groupRateLimiterEnabled.
|
|
74869
|
+
*/
|
|
74870
|
+
async makeTransferPositionsTx(params) {
|
|
74871
|
+
const tokenProgramsByBank = /* @__PURE__ */ new Map();
|
|
74872
|
+
for (const bankAddress of params.bankAddresses) {
|
|
74873
|
+
const bank = this.client.bankMap.get(bankAddress.toBase58());
|
|
74874
|
+
if (!bank) throw new Error(`Bank ${bankAddress.toBase58()} not found`);
|
|
74875
|
+
const mintData = await this.getMintDataFromBank(bank);
|
|
74876
|
+
tokenProgramsByBank.set(bankAddress.toBase58(), mintData.tokenProgram);
|
|
74877
|
+
}
|
|
74878
|
+
const fullParams = {
|
|
74879
|
+
...params,
|
|
74880
|
+
program: this.client.program,
|
|
74881
|
+
connection: this.client.program.provider.connection,
|
|
74882
|
+
marginfiAccount: this.account,
|
|
74883
|
+
bankMap: this.client.bankMap,
|
|
74884
|
+
oraclePrices: this.client.oraclePriceByBank,
|
|
74885
|
+
bankMetadataMap: this.client.bankIntegrationMap,
|
|
74886
|
+
assetShareValueMultiplierByBank: this.client.assetShareValueMultiplierByBank,
|
|
74887
|
+
addressLookupTableAccounts: this.client.addressLookupTables,
|
|
74888
|
+
tokenProgramsByBank,
|
|
74889
|
+
groupRateLimiterEnabled: isGroupRateLimiterEnabled(this.client.group.rateLimiter)
|
|
74890
|
+
};
|
|
74891
|
+
return this.account.makeTransferPositionsTx(fullParams);
|
|
74892
|
+
}
|
|
74316
74893
|
/**
|
|
74317
74894
|
* Creates a repay with collateral transaction with auto-injected client data.
|
|
74318
74895
|
*
|
|
@@ -75154,6 +75731,6 @@ var EmodeSettings = class _EmodeSettings {
|
|
|
75154
75731
|
}
|
|
75155
75732
|
};
|
|
75156
75733
|
|
|
75157
|
-
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, calculateApyFromInterest, calculateInterestFromApy, capConfidenceInterval, categorizePythBanks, checkBatchOracleCrankability, checkJupiterFeeAccount, checkMultipleOraclesCrankability, checkTitanFeeAccount, chunkedGetRawMultipleAccountInfoOrdered, chunkedGetRawMultipleAccountInfoOrderedWithNulls, chunkedGetRawMultipleAccountInfos, 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, 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, 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, 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 };
|
|
75734
|
+
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, 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, 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 };
|
|
75158
75735
|
//# sourceMappingURL=index.js.map
|
|
75159
75736
|
//# sourceMappingURL=index.js.map
|