@0dotxyz/p0-ts-sdk 2.10.0 → 2.11.0
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 +435 -241
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +134 -37
- package/dist/index.d.ts +134 -37
- package/dist/index.js +433 -242
- package/dist/index.js.map +1 -1
- package/dist/instructions.d.cts +1 -1
- package/dist/instructions.d.ts +1 -1
- package/dist/{types-DQD0k0pr.d.cts → types-BO-ZFk04.d.cts} +8 -1
- package/dist/{types--m9sTr2x.d.ts → types-DgVpJ2nB.d.ts} +8 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -188,6 +188,7 @@ var TransactionBuildingErrorCode = /* @__PURE__ */ ((TransactionBuildingErrorCod
|
|
|
188
188
|
TransactionBuildingErrorCode2["BRIDGE_CONFLICT"] = "BRIDGE_CONFLICT";
|
|
189
189
|
TransactionBuildingErrorCode2["ORDER_INVALID_TRIGGER"] = "ORDER_INVALID_TRIGGER";
|
|
190
190
|
TransactionBuildingErrorCode2["ORDER_INVALID_SLIPPAGE"] = "ORDER_INVALID_SLIPPAGE";
|
|
191
|
+
TransactionBuildingErrorCode2["ORDER_CLOSES_DONT_FIT"] = "ORDER_CLOSES_DONT_FIT";
|
|
191
192
|
TransactionBuildingErrorCode2["COSTLY_POSITION_LIMIT_EXCEEDED"] = "COSTLY_POSITION_LIMIT_EXCEEDED";
|
|
192
193
|
TransactionBuildingErrorCode2["ACCOUNT_DISABLED"] = "ACCOUNT_DISABLED";
|
|
193
194
|
return TransactionBuildingErrorCode2;
|
|
@@ -356,6 +357,19 @@ var TransactionBuildingError = class _TransactionBuildingError extends Error {
|
|
|
356
357
|
{ maxSlippagePercent, maxAllowedPercent }
|
|
357
358
|
);
|
|
358
359
|
}
|
|
360
|
+
/**
|
|
361
|
+
* Closing the orders an action touches doesn't fit in one transaction: next to the action, or in
|
|
362
|
+
* the one order transaction after a multi-transaction action. Builders throw rather than leave the
|
|
363
|
+
* closes out, since an order on a changed position can still fire: close the orders on their own
|
|
364
|
+
* first, then retry the action.
|
|
365
|
+
*/
|
|
366
|
+
static orderClosesDontFit(orderAddresses) {
|
|
367
|
+
return new _TransactionBuildingError(
|
|
368
|
+
"ORDER_CLOSES_DONT_FIT" /* ORDER_CLOSES_DONT_FIT */,
|
|
369
|
+
`Closing ${orderAddresses.length} order(s) doesn't fit in one transaction`,
|
|
370
|
+
{ orderAddresses }
|
|
371
|
+
);
|
|
372
|
+
}
|
|
359
373
|
/**
|
|
360
374
|
* The marginfi account is disabled (e.g. already transferred to a new account), so it can't act.
|
|
361
375
|
*/
|
|
@@ -76812,18 +76826,12 @@ function computeHealthComponentsFromBalances(params) {
|
|
|
76812
76826
|
let totalLiabilities = new BigNumber3(0);
|
|
76813
76827
|
for (const accountBalance of filteredBalances) {
|
|
76814
76828
|
const bankKey = accountBalance.bankPk.toBase58();
|
|
76815
|
-
const bank = banksMap.
|
|
76816
|
-
if (!bank) {
|
|
76817
|
-
console.warn(
|
|
76818
|
-
`Bank ${shortenAddress(accountBalance.bankPk)} not found, excluding from health computation`
|
|
76819
|
-
);
|
|
76820
|
-
continue;
|
|
76821
|
-
}
|
|
76829
|
+
const bank = requireBank(banksMap, accountBalance.bankPk);
|
|
76822
76830
|
const oraclePrice = oraclePricesByBank.get(bankKey);
|
|
76823
76831
|
if (!oraclePrice) {
|
|
76824
|
-
|
|
76825
|
-
`
|
|
76826
|
-
|
|
76832
|
+
if (accountBalance.liabilityShares.gt(0)) {
|
|
76833
|
+
throw Error(`Oracle price for ${bankKey} not found`);
|
|
76834
|
+
}
|
|
76827
76835
|
continue;
|
|
76828
76836
|
}
|
|
76829
76837
|
const emodeWeight = activeEmodeWeightsByBank?.get(bankKey);
|
|
@@ -77032,7 +77040,7 @@ function computeLiquidationPriceForBank(params) {
|
|
|
77032
77040
|
const { bank, oraclePrice, marginfiAccount, assetShareValueMultiplier, activeEmodeWeights } = params;
|
|
77033
77041
|
const balance = getBalance(bank.address, marginfiAccount.balances);
|
|
77034
77042
|
if (!balance.active) return null;
|
|
77035
|
-
const { assets: assetBank, liabilities: liabilitiesBank } =
|
|
77043
|
+
const { assets: assetBank, liabilities: liabilitiesBank } = getBalanceUsdValueWithPriceBias({
|
|
77036
77044
|
balance,
|
|
77037
77045
|
bank,
|
|
77038
77046
|
oraclePrice,
|
|
@@ -77046,7 +77054,8 @@ function computeLiquidationPriceForBank(params) {
|
|
|
77046
77054
|
const isLending = balance.liabilityShares.isZero();
|
|
77047
77055
|
const { assets: assetQuantityUi, liabilities: liabQuantitiesUi } = computeQuantityUi(
|
|
77048
77056
|
balance,
|
|
77049
|
-
bank
|
|
77057
|
+
bank,
|
|
77058
|
+
assetShareValueMultiplier
|
|
77050
77059
|
);
|
|
77051
77060
|
let liquidationPrice;
|
|
77052
77061
|
if (isLending) {
|
|
@@ -77152,6 +77161,8 @@ function computeBankRiskAccountKeys(bank) {
|
|
|
77152
77161
|
} else if (bank.stakedOracleUsesOnramp && bank.stakedIntegrationAccounts && !bank.stakedIntegrationAccounts.validatorVoteAccount.equals(PublicKey.default)) {
|
|
77153
77162
|
const pool = findPoolAddress(bank.stakedIntegrationAccounts.validatorVoteAccount);
|
|
77154
77163
|
keys.push(findPoolOnRampAddress(pool));
|
|
77164
|
+
} else {
|
|
77165
|
+
keys.push(PublicKey.default);
|
|
77155
77166
|
}
|
|
77156
77167
|
}
|
|
77157
77168
|
return keys;
|
|
@@ -78190,7 +78201,6 @@ function createJupiterClient(config = {}) {
|
|
|
78190
78201
|
// src/services/account/utils/swap.utils.ts
|
|
78191
78202
|
function resolvePinnedSwapRoute(swapIxs, expectedInAmountNative) {
|
|
78192
78203
|
const { quoteResponse } = swapIxs;
|
|
78193
|
-
const expectedIn = new BN8(expectedInAmountNative);
|
|
78194
78204
|
let minOut;
|
|
78195
78205
|
try {
|
|
78196
78206
|
minOut = new BN8(quoteResponse.otherAmountThreshold);
|
|
@@ -78203,15 +78213,15 @@ function resolvePinnedSwapRoute(swapIxs, expectedInAmountNative) {
|
|
|
78203
78213
|
);
|
|
78204
78214
|
}
|
|
78205
78215
|
const pinnedIn = new BN8(quoteResponse.inAmount);
|
|
78206
|
-
if (!pinnedIn.eq(
|
|
78216
|
+
if (expectedInAmountNative !== void 0 && !pinnedIn.eq(new BN8(expectedInAmountNative))) {
|
|
78207
78217
|
throw new Error(
|
|
78208
|
-
`Pinned swap route (swapOpts.swapIxs) was quoted for a different input amount than the flow will swap: quote inAmount=${pinnedIn.toString()}, flow swap input=${
|
|
78218
|
+
`Pinned swap route (swapOpts.swapIxs) was quoted for a different input amount than the flow will swap: quote inAmount=${pinnedIn.toString()}, flow swap input=${expectedInAmountNative.toString()} (native units). Re-quote the pinned route for the exact flow amount.`
|
|
78209
78219
|
);
|
|
78210
78220
|
}
|
|
78211
78221
|
return {
|
|
78212
78222
|
swapInstructions: swapIxs.instructions,
|
|
78213
78223
|
setupInstructions: [],
|
|
78214
|
-
|
|
78224
|
+
swapLuts: swapIxs.lookupTables,
|
|
78215
78225
|
quoteResponse,
|
|
78216
78226
|
outputAmountNative: minOut
|
|
78217
78227
|
};
|
|
@@ -78325,7 +78335,7 @@ var getSwapIxsForFlashloan = async (params) => {
|
|
|
78325
78335
|
return {
|
|
78326
78336
|
swapInstructions: pinned.swapInstructions,
|
|
78327
78337
|
setupInstructions: pinned.setupInstructions,
|
|
78328
|
-
addressLookupTableAddresses: pinned.
|
|
78338
|
+
addressLookupTableAddresses: pinned.swapLuts,
|
|
78329
78339
|
quoteResponse: pinned.quoteResponse
|
|
78330
78340
|
};
|
|
78331
78341
|
}
|
|
@@ -78523,17 +78533,8 @@ var getJupiterSwapIxsForFlashloan = async ({
|
|
|
78523
78533
|
quoteResponse: mapJupiterQuoteToSwapQuoteResult(swapQuote)
|
|
78524
78534
|
};
|
|
78525
78535
|
};
|
|
78526
|
-
|
|
78527
|
-
// src/services/account/utils/misc.utils.ts
|
|
78528
|
-
function floor(value, decimals) {
|
|
78529
|
-
return Math.floor(value * 10 ** decimals) / 10 ** decimals;
|
|
78530
|
-
}
|
|
78531
|
-
function ceil(value, decimals) {
|
|
78532
|
-
return Math.ceil(value * 10 ** decimals) / 10 ** decimals;
|
|
78533
|
-
}
|
|
78534
78536
|
function computeClosePositionTokenAmount(position, mintDecimals) {
|
|
78535
|
-
|
|
78536
|
-
return closePositionTokenAmount;
|
|
78537
|
+
return new BigNumber(position.amount).decimalPlaces(mintDecimals, position.isLending ? BigNumber.ROUND_FLOOR : BigNumber.ROUND_CEIL).toNumber();
|
|
78537
78538
|
}
|
|
78538
78539
|
function isWholePosition(position, amount, mintDecimals) {
|
|
78539
78540
|
const closePositionTokenAmount = computeClosePositionTokenAmount(position, mintDecimals);
|
|
@@ -78559,6 +78560,162 @@ function exceedsCostlyPositionLimit(balances, bankMap, bank) {
|
|
|
78559
78560
|
}).length;
|
|
78560
78561
|
return held >= MAX_COSTLY_POSITIONS;
|
|
78561
78562
|
}
|
|
78563
|
+
function buildOrderTrigger(params) {
|
|
78564
|
+
const { stopLossUsd, takeProfitUsd } = params;
|
|
78565
|
+
const maxSlippage = percentToMaxSlippageU32(params.maxSlippagePercent);
|
|
78566
|
+
const invalidTrigger = (reason) => TransactionBuildingError.orderInvalidTrigger(
|
|
78567
|
+
reason,
|
|
78568
|
+
takeProfitUsd?.toString(),
|
|
78569
|
+
stopLossUsd?.toString()
|
|
78570
|
+
);
|
|
78571
|
+
if (stopLossUsd && !stopLossUsd.gt(0)) {
|
|
78572
|
+
throw invalidTrigger(`stop-loss threshold (${stopLossUsd}) must be above 0`);
|
|
78573
|
+
}
|
|
78574
|
+
if (takeProfitUsd && !takeProfitUsd.gt(0)) {
|
|
78575
|
+
throw invalidTrigger(`take-profit threshold (${takeProfitUsd}) must be above 0`);
|
|
78576
|
+
}
|
|
78577
|
+
if (stopLossUsd && takeProfitUsd) {
|
|
78578
|
+
if (takeProfitUsd.lte(stopLossUsd)) {
|
|
78579
|
+
throw invalidTrigger(
|
|
78580
|
+
`take-profit threshold (${takeProfitUsd}) must be above stop-loss threshold (${stopLossUsd})`
|
|
78581
|
+
);
|
|
78582
|
+
}
|
|
78583
|
+
return {
|
|
78584
|
+
both: {
|
|
78585
|
+
stopLoss: bigNumberToWrappedI80F48(stopLossUsd),
|
|
78586
|
+
takeProfit: bigNumberToWrappedI80F48(takeProfitUsd),
|
|
78587
|
+
maxSlippage
|
|
78588
|
+
}
|
|
78589
|
+
};
|
|
78590
|
+
}
|
|
78591
|
+
if (stopLossUsd) {
|
|
78592
|
+
return { stopLoss: { threshold: bigNumberToWrappedI80F48(stopLossUsd), maxSlippage } };
|
|
78593
|
+
}
|
|
78594
|
+
if (takeProfitUsd) {
|
|
78595
|
+
return { takeProfit: { threshold: bigNumberToWrappedI80F48(takeProfitUsd), maxSlippage } };
|
|
78596
|
+
}
|
|
78597
|
+
throw invalidTrigger("an order needs a stop-loss threshold, a take-profit threshold, or both");
|
|
78598
|
+
}
|
|
78599
|
+
async function makePlaceOrderIx2(params) {
|
|
78600
|
+
const { program, marginfiAccount, collateralBank, debtBank, trigger, feePayer } = params;
|
|
78601
|
+
const [order] = deriveOrderPda(program.programId, marginfiAccount.address, [
|
|
78602
|
+
collateralBank,
|
|
78603
|
+
debtBank
|
|
78604
|
+
]);
|
|
78605
|
+
const globalFeeWallet = params.globalFeeWallet ?? (await program.account.feeState.fetch(deriveFeeState(program.programId)[0])).globalFeeWallet;
|
|
78606
|
+
const placeOrderIx = await instructions_default3.makePlaceOrderIx(
|
|
78607
|
+
program,
|
|
78608
|
+
{
|
|
78609
|
+
marginfiAccount: marginfiAccount.address,
|
|
78610
|
+
feePayer: feePayer ?? marginfiAccount.authority,
|
|
78611
|
+
authority: marginfiAccount.authority,
|
|
78612
|
+
order,
|
|
78613
|
+
globalFeeWallet,
|
|
78614
|
+
group: marginfiAccount.group
|
|
78615
|
+
},
|
|
78616
|
+
{ bankKeys: [collateralBank, debtBank], trigger: buildOrderTrigger(trigger) }
|
|
78617
|
+
);
|
|
78618
|
+
return { instructions: [placeOrderIx], keys: [] };
|
|
78619
|
+
}
|
|
78620
|
+
async function makeCloseOrderIx2(params) {
|
|
78621
|
+
const { program, marginfiAccount, order, feeRecipient } = params;
|
|
78622
|
+
const closeOrderIx = await instructions_default3.makeCloseOrderIx(program, {
|
|
78623
|
+
marginfiAccount: marginfiAccount.address,
|
|
78624
|
+
authority: marginfiAccount.authority,
|
|
78625
|
+
order,
|
|
78626
|
+
feeRecipient: feeRecipient ?? marginfiAccount.authority,
|
|
78627
|
+
group: marginfiAccount.group
|
|
78628
|
+
});
|
|
78629
|
+
return { instructions: [closeOrderIx], keys: [] };
|
|
78630
|
+
}
|
|
78631
|
+
async function compileOrderTx(params, payerKey, ixs, type) {
|
|
78632
|
+
const blockhash = params.blockhash ?? (await params.connection.getLatestBlockhashAndContext("confirmed")).value.blockhash;
|
|
78633
|
+
return addTransactionMetadata(
|
|
78634
|
+
new VersionedTransaction(
|
|
78635
|
+
new TransactionMessage({
|
|
78636
|
+
instructions: ixs.flatMap((ix) => ix.instructions),
|
|
78637
|
+
payerKey,
|
|
78638
|
+
recentBlockhash: blockhash
|
|
78639
|
+
}).compileToV0Message(params.luts)
|
|
78640
|
+
),
|
|
78641
|
+
{ type, signers: ixs.flatMap((ix) => ix.keys), addressLookupTables: params.luts }
|
|
78642
|
+
);
|
|
78643
|
+
}
|
|
78644
|
+
async function makePlaceOrderTx(params) {
|
|
78645
|
+
const placeIxs = await makePlaceOrderIx2(params);
|
|
78646
|
+
const payerKey = params.feePayer ?? params.marginfiAccount.authority;
|
|
78647
|
+
return compileOrderTx(params, payerKey, [placeIxs], "PLACE_ORDER" /* PLACE_ORDER */);
|
|
78648
|
+
}
|
|
78649
|
+
async function makeCloseOrderTx(params) {
|
|
78650
|
+
const closeIxs = await makeCloseOrderIx2(params);
|
|
78651
|
+
return compileOrderTx(
|
|
78652
|
+
params,
|
|
78653
|
+
params.marginfiAccount.authority,
|
|
78654
|
+
[closeIxs],
|
|
78655
|
+
"CLOSE_ORDER" /* CLOSE_ORDER */
|
|
78656
|
+
);
|
|
78657
|
+
}
|
|
78658
|
+
async function makeUpdateOrderTx(params) {
|
|
78659
|
+
const [order] = deriveOrderPda(params.program.programId, params.marginfiAccount.address, [
|
|
78660
|
+
params.collateralBank,
|
|
78661
|
+
params.debtBank
|
|
78662
|
+
]);
|
|
78663
|
+
const closeIxs = await makeCloseOrderIx2({ ...params, order, feeRecipient: params.feePayer });
|
|
78664
|
+
const placeIxs = await makePlaceOrderIx2(params);
|
|
78665
|
+
const payerKey = params.feePayer ?? params.marginfiAccount.authority;
|
|
78666
|
+
return compileOrderTx(params, payerKey, [closeIxs, placeIxs], "UPDATE_ORDER" /* UPDATE_ORDER */);
|
|
78667
|
+
}
|
|
78668
|
+
var SEND_PIPELINE_MARGINS = {
|
|
78669
|
+
sizeMargin: PRIORITY_TX_SIZE + BUNDLE_TX_SIZE,
|
|
78670
|
+
maxAccountLocks: MAX_ACCOUNT_LOCKS - 3
|
|
78671
|
+
};
|
|
78672
|
+
async function makeOrderChangesIxs(params) {
|
|
78673
|
+
const { program, marginfiAccount, ordersToClose = [], placeOrder } = params;
|
|
78674
|
+
const wrappers = await Promise.all([
|
|
78675
|
+
...ordersToClose.map((order) => makeCloseOrderIx2({ program, marginfiAccount, order })),
|
|
78676
|
+
...placeOrder ? [makePlaceOrderIx2({ ...placeOrder, program, marginfiAccount })] : []
|
|
78677
|
+
]);
|
|
78678
|
+
return wrappers.flatMap((wrapper) => wrapper.instructions);
|
|
78679
|
+
}
|
|
78680
|
+
async function prependOrderCloses(params, actionIxs, luts) {
|
|
78681
|
+
const { program, marginfiAccount, ordersToClose = [] } = params;
|
|
78682
|
+
if (ordersToClose.length === 0) return actionIxs;
|
|
78683
|
+
const closeIxs = await makeOrderChangesIxs({ program, marginfiAccount, ordersToClose });
|
|
78684
|
+
const withCloses = [...closeIxs, ...actionIxs];
|
|
78685
|
+
if (!fitsInOneTransaction(withCloses, {
|
|
78686
|
+
payerKey: params.authority,
|
|
78687
|
+
luts,
|
|
78688
|
+
...SEND_PIPELINE_MARGINS
|
|
78689
|
+
})) {
|
|
78690
|
+
throw TransactionBuildingError.orderClosesDontFit(
|
|
78691
|
+
ordersToClose.map((order) => order.toBase58())
|
|
78692
|
+
);
|
|
78693
|
+
}
|
|
78694
|
+
return withCloses;
|
|
78695
|
+
}
|
|
78696
|
+
async function makeOrderChangesTx(params) {
|
|
78697
|
+
const { program, marginfiAccount, ordersToClose = [], placeOrder, luts } = params;
|
|
78698
|
+
const ixs = await makeOrderChangesIxs(params);
|
|
78699
|
+
if (ixs.length === 0) return void 0;
|
|
78700
|
+
if (!fitsInOneTransaction(ixs, {
|
|
78701
|
+
payerKey: marginfiAccount.authority,
|
|
78702
|
+
luts,
|
|
78703
|
+
...SEND_PIPELINE_MARGINS
|
|
78704
|
+
})) {
|
|
78705
|
+
throw TransactionBuildingError.orderClosesDontFit(
|
|
78706
|
+
ordersToClose.map((order) => order.toBase58())
|
|
78707
|
+
);
|
|
78708
|
+
}
|
|
78709
|
+
let type = "CLOSE_ORDER" /* CLOSE_ORDER */;
|
|
78710
|
+
if (placeOrder) {
|
|
78711
|
+
const [placedOrder] = deriveOrderPda(program.programId, marginfiAccount.address, [
|
|
78712
|
+
placeOrder.collateralBank,
|
|
78713
|
+
placeOrder.debtBank
|
|
78714
|
+
]);
|
|
78715
|
+
type = ordersToClose.some((order) => order.equals(placedOrder)) ? "UPDATE_ORDER" /* UPDATE_ORDER */ : "PLACE_ORDER" /* PLACE_ORDER */;
|
|
78716
|
+
}
|
|
78717
|
+
return compileOrderTx(params, marginfiAccount.authority, [{ instructions: ixs, keys: [] }], type);
|
|
78718
|
+
}
|
|
78562
78719
|
var KAMINO_PROGRAM_ID = new PublicKey("KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD");
|
|
78563
78720
|
var FARMS_PROGRAM_ID2 = new PublicKey("FarmsPZpWu9i7Kky8tPN37rs2TpmMrAZrC7S7vJa91Hr");
|
|
78564
78721
|
function encodeU642(value) {
|
|
@@ -79282,13 +79439,18 @@ async function makeBorrowTx(params) {
|
|
|
79282
79439
|
params.bankMetadataMap
|
|
79283
79440
|
);
|
|
79284
79441
|
const borrowIxs = await makeBorrowIx3(borrowIxParams);
|
|
79442
|
+
const ixs = await prependOrderCloses(
|
|
79443
|
+
params,
|
|
79444
|
+
[...refreshIntegrationIxs.instructions, ...borrowIxs.instructions],
|
|
79445
|
+
selectedLuts
|
|
79446
|
+
);
|
|
79285
79447
|
const {
|
|
79286
79448
|
value: { blockhash }
|
|
79287
79449
|
} = await connection.getLatestBlockhashAndContext("confirmed");
|
|
79288
79450
|
const borrowTx = addTransactionMetadata(
|
|
79289
79451
|
new VersionedTransaction(
|
|
79290
79452
|
new TransactionMessage({
|
|
79291
|
-
instructions:
|
|
79453
|
+
instructions: ixs,
|
|
79292
79454
|
payerKey: params.authority,
|
|
79293
79455
|
recentBlockhash: blockhash
|
|
79294
79456
|
}).compileToV0Message(selectedLuts)
|
|
@@ -79387,9 +79549,14 @@ async function makeDriftDepositTx(params) {
|
|
|
79387
79549
|
amount,
|
|
79388
79550
|
...depositIxParams
|
|
79389
79551
|
});
|
|
79390
|
-
const
|
|
79552
|
+
const actionIxs = await prependOrderCloses(
|
|
79391
79553
|
params,
|
|
79392
79554
|
depositIxs.instructions,
|
|
79555
|
+
selectLutsForBanks(luts, [params.bank])
|
|
79556
|
+
);
|
|
79557
|
+
const { instructions: instructions2, luts: selectedLuts } = await appendPremiumRefresh(
|
|
79558
|
+
params,
|
|
79559
|
+
actionIxs,
|
|
79393
79560
|
[params.bank.address],
|
|
79394
79561
|
[]
|
|
79395
79562
|
);
|
|
@@ -79530,9 +79697,14 @@ async function makeKaminoDepositTx(params) {
|
|
|
79530
79697
|
amount,
|
|
79531
79698
|
...depositIxParams
|
|
79532
79699
|
});
|
|
79533
|
-
const
|
|
79700
|
+
const actionIxs = await prependOrderCloses(
|
|
79534
79701
|
params,
|
|
79535
79702
|
[...refreshIxs, ...depositIxs.instructions],
|
|
79703
|
+
selectLutsForBanks(luts, [params.bank])
|
|
79704
|
+
);
|
|
79705
|
+
const { instructions: instructions2, luts: selectedLuts } = await appendPremiumRefresh(
|
|
79706
|
+
params,
|
|
79707
|
+
actionIxs,
|
|
79536
79708
|
[params.bank.address],
|
|
79537
79709
|
[]
|
|
79538
79710
|
);
|
|
@@ -79621,9 +79793,14 @@ async function makeDepositTx(params) {
|
|
|
79621
79793
|
throw TransactionBuildingError.costlyPositionLimitExceeded(params.bank.address.toBase58());
|
|
79622
79794
|
}
|
|
79623
79795
|
const ixs = await makeDepositIx3(depositIxParams);
|
|
79624
|
-
const
|
|
79796
|
+
const actionIxs = await prependOrderCloses(
|
|
79625
79797
|
params,
|
|
79626
79798
|
ixs.instructions,
|
|
79799
|
+
selectLutsForBanks(luts, [params.bank])
|
|
79800
|
+
);
|
|
79801
|
+
const { instructions: instructions2, luts: selectedLuts } = await appendPremiumRefresh(
|
|
79802
|
+
params,
|
|
79803
|
+
actionIxs,
|
|
79627
79804
|
[params.bank.address],
|
|
79628
79805
|
[]
|
|
79629
79806
|
);
|
|
@@ -79713,9 +79890,14 @@ async function makeJuplendDepositTx(params) {
|
|
|
79713
79890
|
amount,
|
|
79714
79891
|
...depositIxParams
|
|
79715
79892
|
});
|
|
79716
|
-
const
|
|
79893
|
+
const actionIxs = await prependOrderCloses(
|
|
79717
79894
|
params,
|
|
79718
79895
|
depositIxs.instructions,
|
|
79896
|
+
selectLutsForBanks(luts, [params.bank])
|
|
79897
|
+
);
|
|
79898
|
+
const { instructions: instructions2, luts: selectedLuts } = await appendPremiumRefresh(
|
|
79899
|
+
params,
|
|
79900
|
+
actionIxs,
|
|
79719
79901
|
[params.bank.address],
|
|
79720
79902
|
[]
|
|
79721
79903
|
);
|
|
@@ -80491,13 +80673,18 @@ async function makeDriftWithdrawTx(params) {
|
|
|
80491
80673
|
[withdrawIxParams.bank.address],
|
|
80492
80674
|
params.bankMetadataMap
|
|
80493
80675
|
);
|
|
80676
|
+
const ixs = await prependOrderCloses(
|
|
80677
|
+
params,
|
|
80678
|
+
[...refreshIntegrationIxs.instructions, ...withdrawIxs.instructions],
|
|
80679
|
+
selectedLuts
|
|
80680
|
+
);
|
|
80494
80681
|
const {
|
|
80495
80682
|
value: { blockhash }
|
|
80496
80683
|
} = await connection.getLatestBlockhashAndContext("confirmed");
|
|
80497
80684
|
const withdrawTx = addTransactionMetadata(
|
|
80498
80685
|
new VersionedTransaction(
|
|
80499
80686
|
new TransactionMessage({
|
|
80500
|
-
instructions:
|
|
80687
|
+
instructions: ixs,
|
|
80501
80688
|
payerKey: params.authority,
|
|
80502
80689
|
recentBlockhash: blockhash
|
|
80503
80690
|
}).compileToV0Message(selectedLuts)
|
|
@@ -80744,13 +80931,18 @@ async function makeWithdrawTx(params) {
|
|
|
80744
80931
|
[withdrawIxParams.bank.address],
|
|
80745
80932
|
params.bankMetadataMap
|
|
80746
80933
|
);
|
|
80934
|
+
const ixs = await prependOrderCloses(
|
|
80935
|
+
params,
|
|
80936
|
+
[...refreshIntegrationIxs.instructions, ...withdrawIxs.instructions],
|
|
80937
|
+
selectedLuts
|
|
80938
|
+
);
|
|
80747
80939
|
const {
|
|
80748
80940
|
value: { blockhash }
|
|
80749
80941
|
} = await connection.getLatestBlockhashAndContext("confirmed");
|
|
80750
80942
|
const withdrawTx = addTransactionMetadata(
|
|
80751
80943
|
new VersionedTransaction(
|
|
80752
80944
|
new TransactionMessage({
|
|
80753
|
-
instructions:
|
|
80945
|
+
instructions: ixs,
|
|
80754
80946
|
payerKey: params.authority,
|
|
80755
80947
|
recentBlockhash: blockhash
|
|
80756
80948
|
}).compileToV0Message(selectedLuts)
|
|
@@ -80788,13 +80980,18 @@ async function makeKaminoWithdrawTx(params) {
|
|
|
80788
80980
|
cTokenAmount: adjustedAmount,
|
|
80789
80981
|
...withdrawIxParams
|
|
80790
80982
|
});
|
|
80983
|
+
const ixs = await prependOrderCloses(
|
|
80984
|
+
params,
|
|
80985
|
+
[...refreshIntegrationIxs.instructions, ...withdrawIxs.instructions],
|
|
80986
|
+
selectedLuts
|
|
80987
|
+
);
|
|
80791
80988
|
const {
|
|
80792
80989
|
value: { blockhash }
|
|
80793
80990
|
} = await connection.getLatestBlockhashAndContext("confirmed");
|
|
80794
80991
|
const withdrawTx = addTransactionMetadata(
|
|
80795
80992
|
new VersionedTransaction(
|
|
80796
80993
|
new TransactionMessage({
|
|
80797
|
-
instructions:
|
|
80994
|
+
instructions: ixs,
|
|
80798
80995
|
payerKey: params.authority,
|
|
80799
80996
|
recentBlockhash: blockhash
|
|
80800
80997
|
}).compileToV0Message(selectedLuts)
|
|
@@ -80918,13 +81115,18 @@ async function makeJuplendWithdrawTx(params) {
|
|
|
80918
81115
|
[withdrawIxParams.bank.address],
|
|
80919
81116
|
params.bankMetadataMap
|
|
80920
81117
|
);
|
|
81118
|
+
const ixs = await prependOrderCloses(
|
|
81119
|
+
params,
|
|
81120
|
+
[...refreshIntegrationIxs.instructions, ...withdrawIxs.instructions],
|
|
81121
|
+
selectedLuts
|
|
81122
|
+
);
|
|
80921
81123
|
const {
|
|
80922
81124
|
value: { blockhash }
|
|
80923
81125
|
} = await connection.getLatestBlockhashAndContext("confirmed");
|
|
80924
81126
|
const withdrawTx = addTransactionMetadata(
|
|
80925
81127
|
new VersionedTransaction(
|
|
80926
81128
|
new TransactionMessage({
|
|
80927
|
-
instructions:
|
|
81129
|
+
instructions: ixs,
|
|
80928
81130
|
payerKey: params.authority,
|
|
80929
81131
|
recentBlockhash: blockhash
|
|
80930
81132
|
}).compileToV0Message(selectedLuts)
|
|
@@ -80994,10 +81196,15 @@ async function makeRepayIx3({
|
|
|
80994
81196
|
async function makeRepayTx(params) {
|
|
80995
81197
|
const { luts, ...repayIxParams } = params;
|
|
80996
81198
|
const ixs = await makeRepayIx3(repayIxParams);
|
|
81199
|
+
const actionIxs = await prependOrderCloses(
|
|
81200
|
+
params,
|
|
81201
|
+
ixs.instructions,
|
|
81202
|
+
selectLutsForBanks(luts, [params.bank])
|
|
81203
|
+
);
|
|
80997
81204
|
const closedBanks = params.repayAll ? [params.bank.address] : [];
|
|
80998
81205
|
const { instructions: instructions2, luts: selectedLuts } = await appendPremiumRefresh(
|
|
80999
81206
|
params,
|
|
81000
|
-
|
|
81207
|
+
actionIxs,
|
|
81001
81208
|
[],
|
|
81002
81209
|
closedBanks
|
|
81003
81210
|
);
|
|
@@ -81064,12 +81271,18 @@ async function makeRepayWithCollatTx(params) {
|
|
|
81064
81271
|
payerKey: marginfiAccount.authority,
|
|
81065
81272
|
luts: addressLookupTableAccounts ?? []
|
|
81066
81273
|
});
|
|
81274
|
+
const orderTx = await makeOrderChangesTx({
|
|
81275
|
+
...params,
|
|
81276
|
+
luts: addressLookupTableAccounts ?? [],
|
|
81277
|
+
blockhash
|
|
81278
|
+
});
|
|
81067
81279
|
const transactions = [...additionalTxs, flashloanTx];
|
|
81280
|
+
if (orderTx) transactions.push(orderTx);
|
|
81068
81281
|
return {
|
|
81069
81282
|
transactions,
|
|
81070
81283
|
swapQuote,
|
|
81071
81284
|
amountToRepay,
|
|
81072
|
-
mustBeAtomicBundle:
|
|
81285
|
+
mustBeAtomicBundle: transactions.length > 1
|
|
81073
81286
|
};
|
|
81074
81287
|
}
|
|
81075
81288
|
async function buildRepayWithCollatFlashloanTx({
|
|
@@ -83565,7 +83778,8 @@ async function composeBridgedSwap(params) {
|
|
|
83565
83778
|
banksMap,
|
|
83566
83779
|
assetShareValueMultiplierByBank,
|
|
83567
83780
|
feePayer,
|
|
83568
|
-
maxBundleTxs = MAX_BRIDGED_BUNDLE_TXS
|
|
83781
|
+
maxBundleTxs = MAX_BRIDGED_BUNDLE_TXS,
|
|
83782
|
+
reservedTxs = 0
|
|
83569
83783
|
} = params;
|
|
83570
83784
|
if (!firstLeg.quoteResponse) return null;
|
|
83571
83785
|
const projectedAccount = projectAccountAfterFirstLeg(
|
|
@@ -83582,7 +83796,7 @@ async function composeBridgedSwap(params) {
|
|
|
83582
83796
|
secondLeg.transactions,
|
|
83583
83797
|
feePayer,
|
|
83584
83798
|
blockhashOf(firstLeg),
|
|
83585
|
-
maxBundleTxs
|
|
83799
|
+
maxBundleTxs - reservedTxs
|
|
83586
83800
|
);
|
|
83587
83801
|
if (!transactions) return null;
|
|
83588
83802
|
return {
|
|
@@ -83644,12 +83858,18 @@ async function makeSwapDebtTx(params) {
|
|
|
83644
83858
|
luts: addressLookupTableAccounts ?? []
|
|
83645
83859
|
}
|
|
83646
83860
|
);
|
|
83861
|
+
const orderTx = await makeOrderChangesTx({
|
|
83862
|
+
...params,
|
|
83863
|
+
luts: addressLookupTableAccounts ?? [],
|
|
83864
|
+
blockhash
|
|
83865
|
+
});
|
|
83647
83866
|
const transactions = [...additionalTxs, flashloanTx];
|
|
83867
|
+
if (orderTx) transactions.push(orderTx);
|
|
83648
83868
|
return {
|
|
83649
83869
|
transactions,
|
|
83650
|
-
actionTxIndex:
|
|
83870
|
+
actionTxIndex: additionalTxs.length,
|
|
83651
83871
|
quoteResponse: swapQuote,
|
|
83652
|
-
mustBeAtomicBundle:
|
|
83872
|
+
mustBeAtomicBundle: transactions.length > 1
|
|
83653
83873
|
};
|
|
83654
83874
|
}
|
|
83655
83875
|
async function buildSwapDebtFlashloanTx({
|
|
@@ -83726,7 +83946,7 @@ async function buildSwapDebtFlashloanTx({
|
|
|
83726
83946
|
opts: { wrapAndUnwrapSol: false, overrideInferAccounts }
|
|
83727
83947
|
});
|
|
83728
83948
|
const runEngine = swapEngineRunner ?? runSwapEngine;
|
|
83729
|
-
const engineResult = await runEngine({
|
|
83949
|
+
const engineResult = swapOpts.swapIxs ? resolvePinnedSwapRoute(swapOpts.swapIxs) : await runEngine({
|
|
83730
83950
|
inputMint: borrowBank.mint.toBase58(),
|
|
83731
83951
|
outputMint: repayBank.mint.toBase58(),
|
|
83732
83952
|
amountNative: uiToNative(estimatedBorrowAmount, borrowBank.mintDecimals).toNumber(),
|
|
@@ -83752,7 +83972,8 @@ async function buildSwapDebtFlashloanTx({
|
|
|
83752
83972
|
const quoteResponse = engineResult.quoteResponse;
|
|
83753
83973
|
const outAmount = nativeToUi(quoteResponse.outAmount, repayBank.mintDecimals);
|
|
83754
83974
|
const outAmountThreshold = nativeToUi(quoteResponse.otherAmountThreshold, repayBank.mintDecimals);
|
|
83755
|
-
const
|
|
83975
|
+
const repayAll = outAmount > totalPositionAmount;
|
|
83976
|
+
const amountToRepay = repayAll ? totalPositionAmount : outAmountThreshold;
|
|
83756
83977
|
const borrowAmount = nativeToUi(quoteResponse.inAmount, borrowBank.mintDecimals);
|
|
83757
83978
|
const borrowIxs = await makeBorrowIx3({
|
|
83758
83979
|
program,
|
|
@@ -83776,14 +83997,7 @@ async function buildSwapDebtFlashloanTx({
|
|
|
83776
83997
|
amount: amountToRepay,
|
|
83777
83998
|
accountAddress: marginfiAccount.address,
|
|
83778
83999
|
authority: marginfiAccount.authority,
|
|
83779
|
-
repayAll
|
|
83780
|
-
{
|
|
83781
|
-
amount: totalPositionAmount,
|
|
83782
|
-
isLending: false
|
|
83783
|
-
},
|
|
83784
|
-
amountToRepay,
|
|
83785
|
-
repayBank.mintDecimals
|
|
83786
|
-
),
|
|
84000
|
+
repayAll,
|
|
83787
84001
|
isSync: true,
|
|
83788
84002
|
opts: {
|
|
83789
84003
|
wrapAndUnwrapSol: false,
|
|
@@ -83856,6 +84070,10 @@ async function tryBridgedDebtSwap(params, bridgeOpts) {
|
|
|
83856
84070
|
bridgeTokenSide: "borrow",
|
|
83857
84071
|
bridgeCandidateMints: bridgeOpts?.bridgeCandidateMints
|
|
83858
84072
|
});
|
|
84073
|
+
const orderTx = await makeOrderChangesTx({
|
|
84074
|
+
...params,
|
|
84075
|
+
luts: params.addressLookupTableAccounts ?? []
|
|
84076
|
+
});
|
|
83859
84077
|
const tokenProgramCache = new Map(bridgeOpts?.tokenProgramByMint);
|
|
83860
84078
|
return tryBridgeCandidates({
|
|
83861
84079
|
usableBridgeBanks,
|
|
@@ -83909,11 +84127,12 @@ async function tryBridgedDebtSwap(params, bridgeOpts) {
|
|
|
83909
84127
|
banksMap: params.bankMap,
|
|
83910
84128
|
assetShareValueMultiplierByBank: params.assetShareValueMultiplierByBank,
|
|
83911
84129
|
feePayer: params.overrideInferAccounts?.authority ?? params.marginfiAccount.authority,
|
|
83912
|
-
maxBundleTxs: bridgeOpts?.maxBundleTxs
|
|
84130
|
+
maxBundleTxs: bridgeOpts?.maxBundleTxs,
|
|
84131
|
+
reservedTxs: orderTx ? 1 : 0
|
|
83913
84132
|
});
|
|
83914
84133
|
if (!result) return null;
|
|
83915
84134
|
return {
|
|
83916
|
-
transactions: result.transactions,
|
|
84135
|
+
transactions: orderTx ? [...result.transactions, orderTx] : result.transactions,
|
|
83917
84136
|
actionTxIndex: result.transactions.length - 1,
|
|
83918
84137
|
quoteResponse: mergeBridgeQuotesDebt(result.firstLegQuote, result.secondLegQuote),
|
|
83919
84138
|
bridgeMint: bridgeBank.mint,
|
|
@@ -83992,12 +84211,23 @@ async function makeLoopTx(params) {
|
|
|
83992
84211
|
luts: addressLookupTableAccounts ?? []
|
|
83993
84212
|
}
|
|
83994
84213
|
);
|
|
84214
|
+
const orderTx = await makeOrderChangesTx({
|
|
84215
|
+
...params,
|
|
84216
|
+
placeOrder: params.placeOrder && {
|
|
84217
|
+
collateralBank: depositOpts.depositBank.address,
|
|
84218
|
+
debtBank: borrowOpts.borrowBank.address,
|
|
84219
|
+
trigger: params.placeOrder
|
|
84220
|
+
},
|
|
84221
|
+
luts: addressLookupTableAccounts ?? [],
|
|
84222
|
+
blockhash
|
|
84223
|
+
});
|
|
83995
84224
|
const transactions = [...additionalTxs, flashloanTx];
|
|
84225
|
+
if (orderTx) transactions.push(orderTx);
|
|
83996
84226
|
return {
|
|
83997
84227
|
transactions,
|
|
83998
|
-
actionTxIndex:
|
|
84228
|
+
actionTxIndex: additionalTxs.length,
|
|
83999
84229
|
quoteResponse: swapQuote,
|
|
84000
|
-
mustBeAtomicBundle:
|
|
84230
|
+
mustBeAtomicBundle: transactions.length > 1
|
|
84001
84231
|
};
|
|
84002
84232
|
}
|
|
84003
84233
|
async function buildLoopFlashloanTx(params) {
|
|
@@ -84226,16 +84456,7 @@ async function buildDepositIxs(params, amountUi) {
|
|
|
84226
84456
|
}
|
|
84227
84457
|
async function runLoopSwapEngine(descriptor, params) {
|
|
84228
84458
|
const { connection, swapOpts, marginfiAccount, swapEngineRunner } = params;
|
|
84229
|
-
if (swapOpts.swapIxs)
|
|
84230
|
-
const pinned = resolvePinnedSwapRoute(swapOpts.swapIxs, descriptor.inAmountNative);
|
|
84231
|
-
return {
|
|
84232
|
-
swapInstructions: pinned.swapInstructions,
|
|
84233
|
-
setupInstructions: pinned.setupInstructions,
|
|
84234
|
-
swapLuts: pinned.lookupTables,
|
|
84235
|
-
quoteResponse: pinned.quoteResponse,
|
|
84236
|
-
outputAmountNative: pinned.outputAmountNative
|
|
84237
|
-
};
|
|
84238
|
-
}
|
|
84459
|
+
if (swapOpts.swapIxs) return resolvePinnedSwapRoute(swapOpts.swapIxs, descriptor.inAmountNative);
|
|
84239
84460
|
const runEngine = swapEngineRunner ?? runSwapEngine;
|
|
84240
84461
|
const engineResult = await runEngine({
|
|
84241
84462
|
inputMint: descriptor.inputMint,
|
|
@@ -84328,6 +84549,15 @@ async function tryBridgedLoop(params, bridgeOpts) {
|
|
|
84328
84549
|
const oraclePriceOf = (bank) => params.oraclePrices.get(bank.address.toBase58())?.priceRealtime.price.toNumber() ?? 0;
|
|
84329
84550
|
const borrowBankPrice = oraclePriceOf(borrowBank);
|
|
84330
84551
|
if (borrowBankPrice <= 0) return null;
|
|
84552
|
+
const orderTx = await makeOrderChangesTx({
|
|
84553
|
+
...params,
|
|
84554
|
+
placeOrder: params.placeOrder && {
|
|
84555
|
+
collateralBank: depositBank.address,
|
|
84556
|
+
debtBank: borrowBank.address,
|
|
84557
|
+
trigger: params.placeOrder
|
|
84558
|
+
},
|
|
84559
|
+
luts: params.addressLookupTableAccounts ?? []
|
|
84560
|
+
});
|
|
84331
84561
|
const tokenProgramCache = new Map(bridgeOpts?.tokenProgramByMint);
|
|
84332
84562
|
return tryBridgeCandidates({
|
|
84333
84563
|
usableBridgeBanks,
|
|
@@ -84346,6 +84576,9 @@ async function tryBridgedLoop(params, bridgeOpts) {
|
|
|
84346
84576
|
);
|
|
84347
84577
|
const firstLeg = await makeLoopTx({
|
|
84348
84578
|
...params,
|
|
84579
|
+
// The order changes run after the second leg, once the loop's final debt exists
|
|
84580
|
+
ordersToClose: void 0,
|
|
84581
|
+
placeOrder: void 0,
|
|
84349
84582
|
depositOpts: {
|
|
84350
84583
|
...params.depositOpts,
|
|
84351
84584
|
marketPrice: oraclePriceOf(depositBank)
|
|
@@ -84383,11 +84616,12 @@ async function tryBridgedLoop(params, bridgeOpts) {
|
|
|
84383
84616
|
banksMap: params.bankMap,
|
|
84384
84617
|
assetShareValueMultiplierByBank: params.assetShareValueMultiplierByBank,
|
|
84385
84618
|
feePayer: params.overrideInferAccounts?.authority ?? params.marginfiAccount.authority,
|
|
84386
|
-
maxBundleTxs: bridgeOpts?.maxBundleTxs
|
|
84619
|
+
maxBundleTxs: bridgeOpts?.maxBundleTxs,
|
|
84620
|
+
reservedTxs: orderTx ? 1 : 0
|
|
84387
84621
|
});
|
|
84388
84622
|
if (!result) return null;
|
|
84389
84623
|
return {
|
|
84390
|
-
transactions: result.transactions,
|
|
84624
|
+
transactions: orderTx ? [...result.transactions, orderTx] : result.transactions,
|
|
84391
84625
|
actionTxIndex: result.transactions.length - 1,
|
|
84392
84626
|
quoteResponse: mergeBridgeQuotesLoop(result.firstLegQuote, result.secondLegQuote),
|
|
84393
84627
|
bridgeMint: bridgeBank.mint,
|
|
@@ -84443,12 +84677,18 @@ async function makeSwapCollateralTx(params) {
|
|
|
84443
84677
|
payerKey: marginfiAccount.authority,
|
|
84444
84678
|
luts: addressLookupTableAccounts ?? []
|
|
84445
84679
|
});
|
|
84680
|
+
const orderTx = await makeOrderChangesTx({
|
|
84681
|
+
...params,
|
|
84682
|
+
luts: addressLookupTableAccounts ?? [],
|
|
84683
|
+
blockhash
|
|
84684
|
+
});
|
|
84446
84685
|
const transactions = [...additionalTxs, flashloanTx];
|
|
84686
|
+
if (orderTx) transactions.push(orderTx);
|
|
84447
84687
|
return {
|
|
84448
84688
|
transactions,
|
|
84449
|
-
actionTxIndex:
|
|
84689
|
+
actionTxIndex: additionalTxs.length,
|
|
84450
84690
|
quoteResponse: swapQuote,
|
|
84451
|
-
mustBeAtomicBundle:
|
|
84691
|
+
mustBeAtomicBundle: transactions.length > 1
|
|
84452
84692
|
};
|
|
84453
84693
|
}
|
|
84454
84694
|
async function buildSwapCollateralFlashloanTx({
|
|
@@ -84712,10 +84952,11 @@ async function buildSwapCollateralFlashloanTx({
|
|
|
84712
84952
|
});
|
|
84713
84953
|
sizeConstraintUsed = swapConstraints.sizeConstraint;
|
|
84714
84954
|
const runEngine = swapEngineRunner ?? runSwapEngine;
|
|
84715
|
-
const
|
|
84955
|
+
const amountNative = uiToNative(actualWithdrawAmount, withdrawBank.mintDecimals);
|
|
84956
|
+
const engineResult = swapOpts.swapIxs ? resolvePinnedSwapRoute(swapOpts.swapIxs, amountNative) : await runEngine({
|
|
84716
84957
|
inputMint: withdrawBank.mint.toBase58(),
|
|
84717
84958
|
outputMint: depositBank.mint.toBase58(),
|
|
84718
|
-
amountNative:
|
|
84959
|
+
amountNative: amountNative.toNumber(),
|
|
84719
84960
|
inputDecimals: withdrawBank.mintDecimals,
|
|
84720
84961
|
outputDecimals: depositBank.mintDecimals,
|
|
84721
84962
|
...swapEngineQuoteFieldsFromOpts(swapOpts),
|
|
@@ -84723,7 +84964,11 @@ async function buildSwapCollateralFlashloanTx({
|
|
|
84723
84964
|
destinationTokenAccount,
|
|
84724
84965
|
connection,
|
|
84725
84966
|
footprint: {
|
|
84726
|
-
instructions: [
|
|
84967
|
+
instructions: [
|
|
84968
|
+
...cuRequestIxs,
|
|
84969
|
+
...withdrawIxs.instructions,
|
|
84970
|
+
...depositIxs.instructions
|
|
84971
|
+
],
|
|
84727
84972
|
luts: addressLookupTableAccounts ?? [],
|
|
84728
84973
|
payer: marginfiAccount.authority,
|
|
84729
84974
|
sizeConstraint: swapConstraints.sizeConstraint,
|
|
@@ -84809,6 +85054,10 @@ async function tryBridgedCollateralSwap(params, bridgeOpts) {
|
|
|
84809
85054
|
bridgeTokenSide: "deposit",
|
|
84810
85055
|
bridgeCandidateMints: bridgeOpts?.bridgeCandidateMints
|
|
84811
85056
|
});
|
|
85057
|
+
const orderTx = await makeOrderChangesTx({
|
|
85058
|
+
...params,
|
|
85059
|
+
luts: params.addressLookupTableAccounts ?? []
|
|
85060
|
+
});
|
|
84812
85061
|
const tokenProgramCache = new Map(bridgeOpts?.tokenProgramByMint);
|
|
84813
85062
|
return tryBridgeCandidates({
|
|
84814
85063
|
usableBridgeBanks,
|
|
@@ -84858,11 +85107,12 @@ async function tryBridgedCollateralSwap(params, bridgeOpts) {
|
|
|
84858
85107
|
banksMap: params.bankMap,
|
|
84859
85108
|
assetShareValueMultiplierByBank: params.assetShareValueMultiplierByBank,
|
|
84860
85109
|
feePayer: params.overrideInferAccounts?.authority ?? params.marginfiAccount.authority,
|
|
84861
|
-
maxBundleTxs: bridgeOpts?.maxBundleTxs
|
|
85110
|
+
maxBundleTxs: bridgeOpts?.maxBundleTxs,
|
|
85111
|
+
reservedTxs: orderTx ? 1 : 0
|
|
84862
85112
|
});
|
|
84863
85113
|
if (!result) return null;
|
|
84864
85114
|
return {
|
|
84865
|
-
transactions: result.transactions,
|
|
85115
|
+
transactions: orderTx ? [...result.transactions, orderTx] : result.transactions,
|
|
84866
85116
|
actionTxIndex: result.transactions.length - 1,
|
|
84867
85117
|
quoteResponse: mergeBridgeQuotes(result.firstLegQuote, result.secondLegQuote),
|
|
84868
85118
|
bridgeMint: bridgeBank.mint,
|
|
@@ -84930,12 +85180,18 @@ async function makeRollPtTx(params) {
|
|
|
84930
85180
|
payerKey: marginfiAccount.authority,
|
|
84931
85181
|
luts: addressLookupTableAccounts ?? []
|
|
84932
85182
|
});
|
|
85183
|
+
const orderTx = await makeOrderChangesTx({
|
|
85184
|
+
...params,
|
|
85185
|
+
luts: addressLookupTableAccounts ?? [],
|
|
85186
|
+
blockhash
|
|
85187
|
+
});
|
|
84933
85188
|
const transactions = [...additionalTxs, flashloanTx];
|
|
85189
|
+
if (orderTx) transactions.push(orderTx);
|
|
84934
85190
|
return {
|
|
84935
85191
|
transactions,
|
|
84936
|
-
actionTxIndex:
|
|
85192
|
+
actionTxIndex: additionalTxs.length,
|
|
84937
85193
|
quoteResponse: swapQuote,
|
|
84938
|
-
mustBeAtomicBundle:
|
|
85194
|
+
mustBeAtomicBundle: transactions.length > 1
|
|
84939
85195
|
};
|
|
84940
85196
|
}
|
|
84941
85197
|
async function buildRollPtFlashloanTx({
|
|
@@ -85630,12 +85886,22 @@ async function makeTransferPositionsTx(params) {
|
|
|
85630
85886
|
payerKey: accountA.authority,
|
|
85631
85887
|
luts
|
|
85632
85888
|
});
|
|
85889
|
+
const sourceOrderTx = await makeOrderChangesTx({ ...params, luts, blockhash });
|
|
85890
|
+
const destinationOrderTx = await makeOrderChangesTx({
|
|
85891
|
+
...params,
|
|
85892
|
+
marginfiAccount: accountB,
|
|
85893
|
+
ordersToClose: params.destinationOrdersToClose,
|
|
85894
|
+
luts,
|
|
85895
|
+
blockhash
|
|
85896
|
+
});
|
|
85633
85897
|
const transactions = [...additionalTxs, flashloanTx];
|
|
85898
|
+
if (sourceOrderTx) transactions.push(sourceOrderTx);
|
|
85899
|
+
if (destinationOrderTx) transactions.push(destinationOrderTx);
|
|
85634
85900
|
return {
|
|
85635
85901
|
transactions,
|
|
85636
85902
|
actionTxIndex: additionalTxs.length,
|
|
85637
85903
|
destinationAccount: accountB,
|
|
85638
|
-
mustBeAtomicBundle:
|
|
85904
|
+
mustBeAtomicBundle: transactions.length > 1
|
|
85639
85905
|
};
|
|
85640
85906
|
}
|
|
85641
85907
|
|
|
@@ -85758,8 +86024,10 @@ async function makeBulkWithdrawTx(params) {
|
|
|
85758
86024
|
if (setupTokens.some((t) => t.mint.equals(NATIVE_MINT))) {
|
|
85759
86025
|
withdrawIxs.push(makeUnwrapSolIx(authority));
|
|
85760
86026
|
}
|
|
86027
|
+
const closeIxs = await makeOrderChangesIxs(params);
|
|
86028
|
+
const actionIxs = [...closeIxs, ...withdrawIxs];
|
|
85761
86029
|
const { blockhash } = await connection.getLatestBlockhash("confirmed");
|
|
85762
|
-
const withdrawTxs = splitInstructionsToFitTransactions([],
|
|
86030
|
+
const withdrawTxs = splitInstructionsToFitTransactions([], actionIxs, {
|
|
85763
86031
|
blockhash,
|
|
85764
86032
|
payerKey: authority,
|
|
85765
86033
|
luts: selectedLuts,
|
|
@@ -85790,7 +86058,8 @@ async function makeBulkWithdrawTx(params) {
|
|
|
85790
86058
|
return {
|
|
85791
86059
|
transactions: [...additionalTxs, ...withdrawTxs],
|
|
85792
86060
|
actionTxIndex: additionalTxs.length,
|
|
85793
|
-
|
|
86061
|
+
// Order closes must land with every withdraw
|
|
86062
|
+
mustBeAtomicBundle: refreshIxs.length > 0 || closeIxs.length > 0 && withdrawTxs.length > 1
|
|
85794
86063
|
};
|
|
85795
86064
|
}
|
|
85796
86065
|
async function makeBulkRepayTx(params) {
|
|
@@ -85837,8 +86106,10 @@ async function makeBulkRepayTx(params) {
|
|
|
85837
86106
|
[],
|
|
85838
86107
|
bankAddresses
|
|
85839
86108
|
) : [];
|
|
86109
|
+
const closeIxs = await makeOrderChangesIxs(params);
|
|
86110
|
+
const actionIxs = [...closeIxs, ...repayIxs, ...premiumIxs];
|
|
85840
86111
|
const { blockhash } = await connection.getLatestBlockhash("confirmed");
|
|
85841
|
-
const transactions = splitInstructionsToFitTransactions([],
|
|
86112
|
+
const transactions = splitInstructionsToFitTransactions([], actionIxs, {
|
|
85842
86113
|
blockhash,
|
|
85843
86114
|
payerKey: authority,
|
|
85844
86115
|
luts,
|
|
@@ -85853,115 +86124,11 @@ async function makeBulkRepayTx(params) {
|
|
|
85853
86124
|
return {
|
|
85854
86125
|
transactions,
|
|
85855
86126
|
actionTxIndex: 0,
|
|
85856
|
-
// Venue refreshes only count in the pulse's slot, and the pulse must follow every repay
|
|
85857
|
-
|
|
86127
|
+
// Venue refreshes only count in the pulse's slot, and the pulse must follow every repay;
|
|
86128
|
+
// order closes must land with every repay
|
|
86129
|
+
mustBeAtomicBundle: (premiumIxs.length > 0 || closeIxs.length > 0) && transactions.length > 1
|
|
85858
86130
|
};
|
|
85859
86131
|
}
|
|
85860
|
-
function buildOrderTrigger(params) {
|
|
85861
|
-
const { stopLossUsd, takeProfitUsd } = params;
|
|
85862
|
-
const maxSlippage = percentToMaxSlippageU32(params.maxSlippagePercent);
|
|
85863
|
-
const invalidTrigger = (reason) => TransactionBuildingError.orderInvalidTrigger(
|
|
85864
|
-
reason,
|
|
85865
|
-
takeProfitUsd?.toString(),
|
|
85866
|
-
stopLossUsd?.toString()
|
|
85867
|
-
);
|
|
85868
|
-
if (stopLossUsd && !stopLossUsd.gt(0)) {
|
|
85869
|
-
throw invalidTrigger(`stop-loss threshold (${stopLossUsd}) must be above 0`);
|
|
85870
|
-
}
|
|
85871
|
-
if (takeProfitUsd && !takeProfitUsd.gt(0)) {
|
|
85872
|
-
throw invalidTrigger(`take-profit threshold (${takeProfitUsd}) must be above 0`);
|
|
85873
|
-
}
|
|
85874
|
-
if (stopLossUsd && takeProfitUsd) {
|
|
85875
|
-
if (takeProfitUsd.lte(stopLossUsd)) {
|
|
85876
|
-
throw invalidTrigger(
|
|
85877
|
-
`take-profit threshold (${takeProfitUsd}) must be above stop-loss threshold (${stopLossUsd})`
|
|
85878
|
-
);
|
|
85879
|
-
}
|
|
85880
|
-
return {
|
|
85881
|
-
both: {
|
|
85882
|
-
stopLoss: bigNumberToWrappedI80F48(stopLossUsd),
|
|
85883
|
-
takeProfit: bigNumberToWrappedI80F48(takeProfitUsd),
|
|
85884
|
-
maxSlippage
|
|
85885
|
-
}
|
|
85886
|
-
};
|
|
85887
|
-
}
|
|
85888
|
-
if (stopLossUsd) {
|
|
85889
|
-
return { stopLoss: { threshold: bigNumberToWrappedI80F48(stopLossUsd), maxSlippage } };
|
|
85890
|
-
}
|
|
85891
|
-
if (takeProfitUsd) {
|
|
85892
|
-
return { takeProfit: { threshold: bigNumberToWrappedI80F48(takeProfitUsd), maxSlippage } };
|
|
85893
|
-
}
|
|
85894
|
-
throw invalidTrigger("an order needs a stop-loss threshold, a take-profit threshold, or both");
|
|
85895
|
-
}
|
|
85896
|
-
async function makePlaceOrderIx2(params) {
|
|
85897
|
-
const { program, marginfiAccount, collateralBank, debtBank, trigger, feePayer } = params;
|
|
85898
|
-
const [order] = deriveOrderPda(program.programId, marginfiAccount.address, [
|
|
85899
|
-
collateralBank,
|
|
85900
|
-
debtBank
|
|
85901
|
-
]);
|
|
85902
|
-
const globalFeeWallet = params.globalFeeWallet ?? (await program.account.feeState.fetch(deriveFeeState(program.programId)[0])).globalFeeWallet;
|
|
85903
|
-
const placeOrderIx = await instructions_default3.makePlaceOrderIx(
|
|
85904
|
-
program,
|
|
85905
|
-
{
|
|
85906
|
-
marginfiAccount: marginfiAccount.address,
|
|
85907
|
-
feePayer: feePayer ?? marginfiAccount.authority,
|
|
85908
|
-
authority: marginfiAccount.authority,
|
|
85909
|
-
order,
|
|
85910
|
-
globalFeeWallet,
|
|
85911
|
-
group: marginfiAccount.group
|
|
85912
|
-
},
|
|
85913
|
-
{ bankKeys: [collateralBank, debtBank], trigger: buildOrderTrigger(trigger) }
|
|
85914
|
-
);
|
|
85915
|
-
return { instructions: [placeOrderIx], keys: [] };
|
|
85916
|
-
}
|
|
85917
|
-
async function makeCloseOrderIx2(params) {
|
|
85918
|
-
const { program, marginfiAccount, order, feeRecipient } = params;
|
|
85919
|
-
const closeOrderIx = await instructions_default3.makeCloseOrderIx(program, {
|
|
85920
|
-
marginfiAccount: marginfiAccount.address,
|
|
85921
|
-
authority: marginfiAccount.authority,
|
|
85922
|
-
order,
|
|
85923
|
-
feeRecipient: feeRecipient ?? marginfiAccount.authority,
|
|
85924
|
-
group: marginfiAccount.group
|
|
85925
|
-
});
|
|
85926
|
-
return { instructions: [closeOrderIx], keys: [] };
|
|
85927
|
-
}
|
|
85928
|
-
async function compileOrderTx(params, payerKey, ixs, type) {
|
|
85929
|
-
const blockhash = params.blockhash ?? (await params.connection.getLatestBlockhashAndContext("confirmed")).value.blockhash;
|
|
85930
|
-
return addTransactionMetadata(
|
|
85931
|
-
new VersionedTransaction(
|
|
85932
|
-
new TransactionMessage({
|
|
85933
|
-
instructions: ixs.flatMap((ix) => ix.instructions),
|
|
85934
|
-
payerKey,
|
|
85935
|
-
recentBlockhash: blockhash
|
|
85936
|
-
}).compileToV0Message(params.luts)
|
|
85937
|
-
),
|
|
85938
|
-
{ type, signers: ixs.flatMap((ix) => ix.keys), addressLookupTables: params.luts }
|
|
85939
|
-
);
|
|
85940
|
-
}
|
|
85941
|
-
async function makePlaceOrderTx(params) {
|
|
85942
|
-
const placeIxs = await makePlaceOrderIx2(params);
|
|
85943
|
-
const payerKey = params.feePayer ?? params.marginfiAccount.authority;
|
|
85944
|
-
return compileOrderTx(params, payerKey, [placeIxs], "PLACE_ORDER" /* PLACE_ORDER */);
|
|
85945
|
-
}
|
|
85946
|
-
async function makeCloseOrderTx(params) {
|
|
85947
|
-
const closeIxs = await makeCloseOrderIx2(params);
|
|
85948
|
-
return compileOrderTx(
|
|
85949
|
-
params,
|
|
85950
|
-
params.marginfiAccount.authority,
|
|
85951
|
-
[closeIxs],
|
|
85952
|
-
"CLOSE_ORDER" /* CLOSE_ORDER */
|
|
85953
|
-
);
|
|
85954
|
-
}
|
|
85955
|
-
async function makeUpdateOrderTx(params) {
|
|
85956
|
-
const [order] = deriveOrderPda(params.program.programId, params.marginfiAccount.address, [
|
|
85957
|
-
params.collateralBank,
|
|
85958
|
-
params.debtBank
|
|
85959
|
-
]);
|
|
85960
|
-
const closeIxs = await makeCloseOrderIx2({ ...params, order, feeRecipient: params.feePayer });
|
|
85961
|
-
const placeIxs = await makePlaceOrderIx2(params);
|
|
85962
|
-
const payerKey = params.feePayer ?? params.marginfiAccount.authority;
|
|
85963
|
-
return compileOrderTx(params, payerKey, [closeIxs, placeIxs], "UPDATE_ORDER" /* UPDATE_ORDER */);
|
|
85964
|
-
}
|
|
85965
86132
|
|
|
85966
86133
|
// src/services/account/services/account-simulation.service.ts
|
|
85967
86134
|
async function simulateAccountHealthCacheWithFallback(params) {
|
|
@@ -86500,7 +86667,7 @@ var fetchStakePoolActiveStates = async (connection, validatorVoteAccounts) => {
|
|
|
86500
86667
|
});
|
|
86501
86668
|
const poolStakeAddressKeys = Object.keys(poolStakeAddressRecord);
|
|
86502
86669
|
const poolStakeAccounts = Object.fromEntries(
|
|
86503
|
-
(await
|
|
86670
|
+
(await chunkedGetRawMultipleAccountInfoOrderedWithNulls(connection, poolStakeAddressKeys)).map((ai, index) => {
|
|
86504
86671
|
const key = poolStakeAddressKeys[index];
|
|
86505
86672
|
const validatorVote = key ? poolStakeAddressRecord[key] : void 0;
|
|
86506
86673
|
return [validatorVote, ai?.data || null];
|
|
@@ -86508,7 +86675,8 @@ var fetchStakePoolActiveStates = async (connection, validatorVoteAccounts) => {
|
|
|
86508
86675
|
);
|
|
86509
86676
|
validatorVoteAccounts.map((validatorVoteAccount) => {
|
|
86510
86677
|
const voteAccountKey = validatorVoteAccount.toBase58();
|
|
86511
|
-
const
|
|
86678
|
+
const stakeData = poolStakeAccounts[voteAccountKey];
|
|
86679
|
+
const stakeAccount = stakeData ? fetchStakeAccount(stakeData) : null;
|
|
86512
86680
|
const poolMintAddress = poolMintAddressRecord[voteAccountKey];
|
|
86513
86681
|
if (!poolMintAddress) {
|
|
86514
86682
|
return;
|
|
@@ -86595,26 +86763,28 @@ var fetchStakePoolMev = async (connection, validatorVoteAccounts) => {
|
|
|
86595
86763
|
const allAddresses = [...poolStakeAddresses, ...onRampAddresses].map(
|
|
86596
86764
|
(address) => address.toBase58()
|
|
86597
86765
|
);
|
|
86598
|
-
return
|
|
86599
|
-
|
|
86600
|
-
|
|
86601
|
-
|
|
86602
|
-
|
|
86603
|
-
|
|
86604
|
-
|
|
86605
|
-
|
|
86606
|
-
|
|
86607
|
-
|
|
86608
|
-
|
|
86609
|
-
|
|
86610
|
-
|
|
86611
|
-
|
|
86612
|
-
|
|
86613
|
-
|
|
86614
|
-
|
|
86615
|
-
|
|
86616
|
-
|
|
86617
|
-
|
|
86766
|
+
return chunkedGetRawMultipleAccountInfoOrderedWithNulls(connection, allAddresses).then(
|
|
86767
|
+
(accountInfos) => {
|
|
86768
|
+
const poolStakeInfos = accountInfos.slice(0, poolStakeAddresses.length);
|
|
86769
|
+
const onRampInfos = accountInfos.slice(poolStakeAddresses.length);
|
|
86770
|
+
const rent = 2282280;
|
|
86771
|
+
validatorVoteAccounts.forEach((validatorVoteAccount, index) => {
|
|
86772
|
+
const poolStakeInfo = poolStakeInfos[index];
|
|
86773
|
+
const onRampInfo = onRampInfos[index];
|
|
86774
|
+
if (poolStakeInfo && onRampInfo) {
|
|
86775
|
+
const stakeDecoded = fetchStakeAccount(poolStakeInfo.data);
|
|
86776
|
+
const onrampDecoded = fetchStakeAccount(onRampInfo.data);
|
|
86777
|
+
const poolLamps = poolStakeInfo.lamports - rent - Number(stakeDecoded.stake.delegation.stake.toString());
|
|
86778
|
+
const onrampStake = Number(onrampDecoded.stake.delegation.stake.toString());
|
|
86779
|
+
mev.set(validatorVoteAccount.toBase58(), {
|
|
86780
|
+
pool: poolLamps >= 1e3 ? poolLamps : 0,
|
|
86781
|
+
onramp: onrampStake
|
|
86782
|
+
});
|
|
86783
|
+
}
|
|
86784
|
+
});
|
|
86785
|
+
return mev;
|
|
86786
|
+
}
|
|
86787
|
+
);
|
|
86618
86788
|
};
|
|
86619
86789
|
|
|
86620
86790
|
// src/services/native-stake/utils/serialize.utils.ts
|
|
@@ -87054,55 +87224,67 @@ function getValidatorVoteAccountByBank() {
|
|
|
87054
87224
|
}
|
|
87055
87225
|
return _voteAccountByBank;
|
|
87056
87226
|
}
|
|
87227
|
+
var POOL_BOOTSTRAP_LAMPORTS = 1000000000n;
|
|
87228
|
+
var STAKE_STATE_DELEGATED = 2;
|
|
87057
87229
|
async function computeStakedBankMultipliers(stakedBanks, connection) {
|
|
87058
87230
|
const multiplierByBank = /* @__PURE__ */ new Map();
|
|
87059
87231
|
if (stakedBanks.length === 0) {
|
|
87060
87232
|
return multiplierByBank;
|
|
87061
87233
|
}
|
|
87062
87234
|
const metadataMap = getStakedBankMetadataMap();
|
|
87063
|
-
const
|
|
87235
|
+
const resolvedBanks = [];
|
|
87064
87236
|
const poolStakeAddresses = [];
|
|
87065
87237
|
const lstMintAddresses = [];
|
|
87238
|
+
const onrampAddresses = [];
|
|
87066
87239
|
for (const bank of stakedBanks) {
|
|
87067
87240
|
const metadata = metadataMap.get(bank.address.toBase58());
|
|
87068
87241
|
if (!metadata) {
|
|
87069
|
-
multiplierByBank.set(bank.address.toBase58(), new
|
|
87242
|
+
multiplierByBank.set(bank.address.toBase58(), new BigNumber(1));
|
|
87070
87243
|
continue;
|
|
87071
87244
|
}
|
|
87072
87245
|
const pool = findPoolAddress(new PublicKey(metadata.validatorVoteAccount));
|
|
87073
|
-
|
|
87246
|
+
resolvedBanks.push(bank);
|
|
87074
87247
|
poolStakeAddresses.push(findPoolStakeAddress(pool));
|
|
87075
87248
|
lstMintAddresses.push(findPoolMintAddress(pool));
|
|
87249
|
+
onrampAddresses.push(findPoolOnRampAddress(pool));
|
|
87076
87250
|
}
|
|
87077
|
-
if (
|
|
87251
|
+
if (resolvedBanks.length === 0) {
|
|
87078
87252
|
return multiplierByBank;
|
|
87079
87253
|
}
|
|
87080
|
-
const allAddresses = [
|
|
87081
|
-
|
|
87082
|
-
|
|
87083
|
-
]
|
|
87084
|
-
|
|
87085
|
-
|
|
87086
|
-
|
|
87087
|
-
|
|
87088
|
-
|
|
87089
|
-
|
|
87090
|
-
const
|
|
87091
|
-
|
|
87092
|
-
|
|
87093
|
-
|
|
87254
|
+
const allAddresses = [...poolStakeAddresses, ...lstMintAddresses, ...onrampAddresses].map(
|
|
87255
|
+
(a) => a.toBase58()
|
|
87256
|
+
);
|
|
87257
|
+
const [accountInfos, stakeRent] = await Promise.all([
|
|
87258
|
+
chunkedGetRawMultipleAccountInfoOrderedWithNulls(connection, allAddresses),
|
|
87259
|
+
resolvedBanks.some((bank) => bank.stakedOracleUsesOnramp) ? connection.getMinimumBalanceForRentExemption(StakeProgram.space) : 0
|
|
87260
|
+
]);
|
|
87261
|
+
const count = resolvedBanks.length;
|
|
87262
|
+
const aboveRent = (lamports) => Math.max(lamports - stakeRent, 0);
|
|
87263
|
+
resolvedBanks.forEach((bank, i) => {
|
|
87264
|
+
const bankAddr = bank.address.toBase58();
|
|
87265
|
+
const poolStakeInfo = accountInfos[i];
|
|
87266
|
+
const lstMintInfo = accountInfos[count + i];
|
|
87267
|
+
const onrampInfo = accountInfos[2 * count + i];
|
|
87268
|
+
const lstMintSupply = lstMintInfo ? Buffer$1.from(lstMintInfo.data.subarray(36, 44)).readBigUInt64LE(0) : 0n;
|
|
87269
|
+
if (!poolStakeInfo || lstMintSupply === 0n) {
|
|
87270
|
+
multiplierByBank.set(bankAddr, new BigNumber(1));
|
|
87271
|
+
return;
|
|
87094
87272
|
}
|
|
87095
|
-
|
|
87096
|
-
|
|
87097
|
-
|
|
87098
|
-
|
|
87099
|
-
|
|
87100
|
-
|
|
87273
|
+
if (bank.stakedOracleUsesOnramp) {
|
|
87274
|
+
const value = aboveRent(poolStakeInfo.lamports) + (onrampInfo ? aboveRent(onrampInfo.lamports) : 0);
|
|
87275
|
+
multiplierByBank.set(
|
|
87276
|
+
bankAddr,
|
|
87277
|
+
new BigNumber(value).dividedBy((lstMintSupply + POOL_BOOTSTRAP_LAMPORTS).toString())
|
|
87278
|
+
);
|
|
87279
|
+
return;
|
|
87101
87280
|
}
|
|
87102
|
-
const
|
|
87103
|
-
const
|
|
87104
|
-
multiplierByBank.set(
|
|
87105
|
-
|
|
87281
|
+
const delegated = poolStakeInfo.data.readUInt32LE(0) === STAKE_STATE_DELEGATED ? fetchStakeAccount(poolStakeInfo.data).stake.delegation.stake : 0n;
|
|
87282
|
+
const delegatedAboveBootstrap = delegated > POOL_BOOTSTRAP_LAMPORTS ? delegated - POOL_BOOTSTRAP_LAMPORTS : 0n;
|
|
87283
|
+
multiplierByBank.set(
|
|
87284
|
+
bankAddr,
|
|
87285
|
+
new BigNumber(delegatedAboveBootstrap.toString()).dividedBy(lstMintSupply.toString())
|
|
87286
|
+
);
|
|
87287
|
+
});
|
|
87106
87288
|
return multiplierByBank;
|
|
87107
87289
|
}
|
|
87108
87290
|
var SYSVAR_CLOCK_ID2 = new PublicKey("SysvarC1ock11111111111111111111111111111111");
|
|
@@ -87931,7 +88113,7 @@ async function fetchBankIntegrationMetadata(options) {
|
|
|
87931
88113
|
|
|
87932
88114
|
// src/models/bank.ts
|
|
87933
88115
|
var Bank = class _Bank {
|
|
87934
|
-
constructor(address, mint, mintDecimals, group, assetShareValue, liabilityShareValue, liquidityVault, liquidityVaultBump, liquidityVaultAuthorityBump, insuranceVault, insuranceVaultBump, insuranceVaultAuthorityBump, collectedInsuranceFeesOutstanding, feeVault, feeVaultBump, feeVaultAuthorityBump, collectedGroupFeesOutstanding, lastUpdate, config, totalAssetShares, totalLiabilityShares, emissionsActiveBorrowing, emissionsActiveLending, emissionsRate, emissionsMint, emissionsRemaining, collectedProgramFeesOutstanding, oracleKey, emode, premiumTag, premiumActive, premiumActivatedAt, kaminoEmergency, rateLimiter, kaminoIntegrationAccounts, driftIntegrationAccounts, solendIntegrationAccounts, jupLendIntegrationAccounts, feesDestinationAccount, lendingPositionCount, borrowingPositionCount, tokenSymbol) {
|
|
88116
|
+
constructor(address, mint, mintDecimals, group, assetShareValue, liabilityShareValue, liquidityVault, liquidityVaultBump, liquidityVaultAuthorityBump, insuranceVault, insuranceVaultBump, insuranceVaultAuthorityBump, collectedInsuranceFeesOutstanding, feeVault, feeVaultBump, feeVaultAuthorityBump, collectedGroupFeesOutstanding, lastUpdate, config, totalAssetShares, totalLiabilityShares, emissionsActiveBorrowing, emissionsActiveLending, emissionsRate, emissionsMint, emissionsRemaining, collectedProgramFeesOutstanding, oracleKey, emode, premiumTag, premiumActive, premiumActivatedAt, kaminoEmergency, rateLimiter, kaminoIntegrationAccounts, driftIntegrationAccounts, solendIntegrationAccounts, jupLendIntegrationAccounts, feesDestinationAccount, lendingPositionCount, borrowingPositionCount, tokenSymbol, stakedOracleDisabled, stakedOracleUsesOnramp, stakedIntegrationAccounts) {
|
|
87935
88117
|
this.address = address;
|
|
87936
88118
|
this.mint = mint;
|
|
87937
88119
|
this.mintDecimals = mintDecimals;
|
|
@@ -87974,6 +88156,9 @@ var Bank = class _Bank {
|
|
|
87974
88156
|
this.lendingPositionCount = lendingPositionCount;
|
|
87975
88157
|
this.borrowingPositionCount = borrowingPositionCount;
|
|
87976
88158
|
this.tokenSymbol = tokenSymbol;
|
|
88159
|
+
this.stakedOracleDisabled = stakedOracleDisabled;
|
|
88160
|
+
this.stakedOracleUsesOnramp = stakedOracleUsesOnramp;
|
|
88161
|
+
this.stakedIntegrationAccounts = stakedIntegrationAccounts;
|
|
87977
88162
|
}
|
|
87978
88163
|
static async fetch(address, program, bankMetadata) {
|
|
87979
88164
|
const data = await program.account.bank.fetch(address);
|
|
@@ -88049,7 +88234,10 @@ var Bank = class _Bank {
|
|
|
88049
88234
|
bankType.feesDestinationAccount,
|
|
88050
88235
|
bankType.lendingPositionCount,
|
|
88051
88236
|
bankType.borrowingPositionCount,
|
|
88052
|
-
bankType.tokenSymbol
|
|
88237
|
+
bankType.tokenSymbol,
|
|
88238
|
+
bankType.stakedOracleDisabled,
|
|
88239
|
+
bankType.stakedOracleUsesOnramp,
|
|
88240
|
+
bankType.stakedIntegrationAccounts
|
|
88053
88241
|
);
|
|
88054
88242
|
}
|
|
88055
88243
|
static fromAccountParsed(address, accountParsed, bankMetadata) {
|
|
@@ -88096,7 +88284,10 @@ var Bank = class _Bank {
|
|
|
88096
88284
|
props.feesDestinationAccount,
|
|
88097
88285
|
props.lendingPositionCount,
|
|
88098
88286
|
props.borrowingPositionCount,
|
|
88099
|
-
props.tokenSymbol
|
|
88287
|
+
props.tokenSymbol,
|
|
88288
|
+
props.stakedOracleDisabled,
|
|
88289
|
+
props.stakedOracleUsesOnramp,
|
|
88290
|
+
props.stakedIntegrationAccounts
|
|
88100
88291
|
);
|
|
88101
88292
|
}
|
|
88102
88293
|
static withEmodeWeights(bank, emodeWeights) {
|
|
@@ -89658,6 +89849,6 @@ var EmodeSettings = class _EmodeSettings {
|
|
|
89658
89849
|
}
|
|
89659
89850
|
};
|
|
89660
89851
|
|
|
89661
|
-
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_BRIDGE_MINTS, DEFAULT_ORACLE_MAX_AGE, DEFAULT_REPAY_ALL_EXTRA_BUFFER_BPS, DISABLED_FLAG, EMPTY_HEALTH_CACHE, EXECUTION_HEADROOM_SECONDS, EmodeEntryFlags, EmodeFlags, EmodeImpactStatus, EmodeSettings, EmodeTag, FLASHLOAN_ENABLED_FLAG, HOURS_PER_YEAR, HealthCache, HealthCacheFlags, HealthCacheSimulationError, HealthCacheStatus, JUPITER_V6_PROGRAM, JUP_SWAP_LUT_PROGRAM_AUTHORITY_INDEX, KAMINO_MARKET_EMERGENCY_FLAG, 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_COSTLY_POSITIONS, 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, PDA_ORDER_SEED, PDA_REBALANCE_FEE_POOL_SEED, PREMIUM_ACTIVE_FLAG, PRIORITY_TX_SIZE, PYTH_PRICE_CONF_INTERVALS, PYTH_PUSH_ORACLE_ID, PYTH_SPONSORED_SHARD_ID, PriceBias, Project0Client, RiskTier, SECONDS_PER_YEAR, SINGLE_POOL_PROGRAM_ID, STAKED_ORACLE_DISABLED_FLAG, STAKED_ORACLE_USES_ONRAMP_FLAG, STAKE_CONFIG_ID, STAKE_PROGRAM_ID, SWAP_ADAPTERS, SYSTEM_PROGRAM_ID, SYSVAR_CLOCK_ID, SYSVAR_RENT_ID, SYSVAR_STAKE_HISTORY_ID, SwapProvider, TRANSFER_ACCOUNT_AUTHORITY_FLAG, TransactionArenaKeyMap, TransactionBuildingError, TransactionBuildingErrorCode, TransactionConfigMap, TransactionType, U64_MAX2 as U64_MAX, USDC_DECIMALS, USDC_MINT, USDT_MINT, VENUE_AVAILABLE_LIQUIDITY_BUFFER, WSOL_MINT, ZERO_ORACLE_KEY, accountConflictsWithBridgeBank, accountFlagToBN, addOracleToBanksIx, addTransactionMetadata, adjustPriceComponent, appendPremiumRefresh, aprToApy, apyToApr, balanceToDto, bankConfigRawToDto, bankConfigToBankConfigRaw, bankMetadataMapToDto, bankMetadataToDto, bankRateLimiterRawToDto, bankRawToDto, bigNumberToWrappedI80F48, bpsToPercentile, buildCollateralLegIxs, buildOrderTrigger, calculateApyFromInterest, calculateInterestFromApy, capConfidenceInterval, categorizePythBanks, checkJupiterFeeAccount, checkTitanFeeAccount, chunkedGetRawMultipleAccountInfoOrdered, chunkedGetRawMultipleAccountInfoOrderedWithNulls, chunkedGetRawMultipleAccountInfos, classifyAndValidate, compileFlashloanPrecheck, composeBridgedSwap, composeRemainingAccounts, computeAccountValue, computeAccrualProjectionSeconds, computeActiveEmodePairs, computeAssetHealthComponent, computeAssetUsdValue, computeBalancePremium, computeBalanceUsdValue, computeBankAvailableLiquidity, computeBankBorrowApy, computeBankBorrowCapRemaining, computeBankDepositCapRemaining, computeBankMetrics, computeBankOutflowRateLimit, computeBankPoolSize, computeBankProjectedAvailableLiquidity, computeBankRateLimitRemaining, computeBankSupplyApy, computeBankTotalBorrows, computeBankTotalBorrowsUsd, computeBankTotalDeposits, computeBankTotalDepositsUsd, computeBaseInterestRate, computeBorrowEstimateForRepay, computeClosePositionTokenAmount, computeEmodeImpacts, computeFlashLoanNonSwapBudget, computeFlashloanSwapConstraints, computeFreeCollateralFromBalances, computeFreeCollateralFromCache, computeGroupRateLimitRemainingUsd, computeHealthAccountMetas, computeHealthCacheStatus, computeHealthCheckAccounts, computeHealthComponentsFromBalances, computeHealthComponentsFromCache, computeInterestRates, computeLiabilityHealthComponent, computeLiabilityUsdValue, computeLiquidationPriceForBank, computeLoopingParams, computeLowestEmodeWeights, computeMaxBorrowForBank, computeMaxDepositForBank, computeMaxLeverage, computeMaxWithdrawForBank, computeNetApy, computeOracleMultiplier, computeOracleMultipliers, computeOrderPairNetValue, computePremiumBreakdown, computePremiumImpact, computePremiumRatesByBank, computeProjectedActiveBalancesNoCpi, computeProjectedActiveBanksNoCpi, computePtMultiplier, computeQuantity, computeQuantityUi, computeRateLimitWindowRemainingCapacity, computeRateLimiterRemainingCapacity, computeRemainingCapacity, computeStakedBankMultipliers, computeTvl, computeUsdValue, computeUtilizationRate, computeV0TxSize, computeVenueAvailableLiquidity, configureScopeOracleIx, convertVoteAccCoeffsToBankCoeffs, createActiveEmodePairFromPairs, createEmptyBalance, decodeAccountRaw, decodeBankRaw, decodeInstruction, decodeMultiplierAccount, decompileV0Transaction, deriveBankEmissionsAuth, deriveBankEmissionsVault, deriveBankFeeVault, deriveBankFeeVaultAuthority, deriveBankInsuranceVault, deriveBankInsuranceVaultAuthority, deriveBankLiquidityVault, deriveBankLiquidityVaultAuthority, deriveFeeState, deriveMarginfiAccount, deriveOrderPda, deriveRebalanceFeePool, deserializeInstruction, deserializeLut, deserializeSwapEngineRequest, deserializeSwapEngineResult, dtoToBalance, dtoToBank, dtoToBankConfig, dtoToBankConfigRaw, dtoToBankMetadata, dtoToBankMetadataMap, dtoToBankRateLimiter, dtoToBankRateLimiterRaw, dtoToBankRaw, dtoToEmodeSettings, dtoToEmodeSettingsRaw, dtoToGroup, dtoToHealthCache, dtoToInterestRateConfig, dtoToMarginfiAccount, dtoToOraclePrice, dtoToValidatorStakeGroup, emodeSettingsRawToDto, exceedsCostlyPositionLimit, extractPythOracleKeys, fetchBank, fetchBankIntegrationMetadata, fetchGammaLpVault, fetchGammaWithdrawReceipt, fetchMarginfiAccountActiveBalancesForBank, fetchMarginfiAccountAddresses, fetchMarginfiAccountAddressesHoldingBank, fetchMarginfiAccountData, fetchMultipleBanks, fetchMultiplierAccountStates, fetchMultiplierAccountStatesFromAPI, fetchNativeStakeAccounts, fetchOracleData, fetchOracleMultipliers, fetchOracleMultipliersFromAPI, fetchOracleMultipliersFromChain, fetchOrderFees, fetchOrdersForAccount, fetchProgramForMints, fetchPythOracleData, fetchPythOraclePricesFromAPI, fetchPythOraclePricesFromChain, fetchScopeOracleData, fetchScopeOraclePricesFromAPI, fetchScopeOraclePricesFromChain, fetchStakeAccount, fetchStakePoolActiveStates, fetchStakePoolMev, findRandomAvailableAccountIndex, fitsInOneTransaction, freezeBankConfigIx, generateDummyAccount, getAccountKeys, getActiveAccountFlags, getActiveBalances, getActiveEmodeEntryFlags, getActiveEmodeFlags, getActiveHealthCacheFlags, getAssetQuantity, getAssetShares, getAssetWeight, getBalance, getBalanceUsdValueWithPriceBias, getBankVaultAuthority, getBankVaultSeeds, getBirdeyeFallbackPricesByFeedId, getBirdeyePricesForMints, getConfig, getDriftCTokenMultiplier, getDriftMetadata, getDriftStatesDto, getEffectiveDepositLimit, getEmodePairs, getExactOutEstimate, getFallbackPricesByFeedId, getFallbackPricesForMints, getHealthCacheStatusDescription, getHealthSimulationTransactions, getJupLendFTokenMultiplier, getJupLendMetadata, getJupLendStatesDto, getJupiterReferralFeeAccount, getJupiterSwapIxsForFlashloan, getKaminoCTokenMultiplier, getKaminoMetadata, getKaminoStatesDto, getLiabilityQuantity, getLiabilityShares, getLiabilityWeight, getOracleMultiplierBankInput, getOracleSourceFromBank, getOracleSourceFromOracleSetup, getOracleSourceNameFromKey, getPrice, getPriceWithConfidence, getStakedBankMetadataMap, getSwapAdapter, getSwapIxsForFlashloan, getTitanExactOutEstimate, getTitanSwapIxsForFlashloan, getTotalAccountKeys, getTotalAssetQuantity, getTotalLiabilityQuantity, getTxSize, getValidatorVoteAccountByBank, getWritableAccountKeys, groupToDto, hasAccountFlag, hasEmodeEntryFlag, hasEmodeFlag, hasHealthCacheFlag, healthCacheToDto, isBorrowLimitActive, isBridgeConflictError, isCostlyBank, isDecomposableSwapError, isDepositIx, isDepositLimitActive, isFlashloan, isGroupRateLimiterEnabled, isStandardBorrowable, isStandardDepositable, isV0Tx, isWeightedPrice, isWholePosition, makeAccountTransferToNewAccountTx, makeAddPermissionlessStakedBankIx, makeBeginFlashLoanIx3 as makeBeginFlashLoanIx, makeBorrowIx3 as makeBorrowIx, makeBorrowTx, makeBridgedLoopTx, makeBridgedSwapCollateralTx, makeBridgedSwapDebtTx, makeBulkRepayTx, makeBulkWithdrawTx, makeBundleTipIx, makeCloseMarginfiAccountIx, makeCloseMarginfiAccountTx, makeCloseOrderIx2 as makeCloseOrderIx, makeCloseOrderTx, 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, makePlaceOrderIx2 as makePlaceOrderIx, makePlaceOrderTx, makePoolAddBankIx2 as makePoolAddBankIx, makePoolConfigureBankGovIx2 as makePoolConfigureBankGovIx, makePoolConfigureBankIx2 as makePoolConfigureBankIx, makePreludeTxs, makePremiumRefreshIxs, makePriorityFeeIx, makePriorityFeeMicroIx, makePulseHealthIx3 as makePulseHealthIx, makeRedeemStakedLstIx, makeRedeemStakedLstTx, makeRefreshIntegrationBanksIxs, makeRefreshKaminoBanksIxs, makeRepayIx3 as makeRepayIx, makeRepayTx, makeRepayWithCollatTx, makeRollPtTx, makeSetupIx, makeSwapCollateralTx, makeSwapDebtTx, makeTransferPositionsTx, makeTxPriorityIx, makeUnwrapSolIx, makeUpdateDriftMarketIxs, makeUpdateJupLendRateIxs, makeUpdateOrderTx, makeVaultCompleteWithdrawalIx, makeVaultCompleteWithdrawalTx, makeVaultDepositIx, makeVaultDepositTx, makeVaultDepositWithSwapTx, makeVaultWithdrawIx, makeVaultWithdrawTx, makeVersionedTransaction, makeWithdrawIx3 as makeWithdrawIx, makeWithdrawTx, makeWrapSolIxs, mapJupiterQuoteToSwapQuoteResult, mapPythBanksToOraclePrices, marginfiAccountToDto, maxSlippageU32ToPercent, mergeBridgeQuotes, mergeBridgeQuotesDebt, mergeBridgeQuotesLoop, nativeToUi, needsPremiumRefresh, oraclePriceToDto, parseBalanceRaw, parseBankConfigRaw, parseBankRateLimiterRaw, parseBankRaw, parseEmodeSettingsRaw, parseEmodeTag, parseHealthCacheRaw, parseMarginfiAccountRaw, parseOperationalState, parseOracleSetup, parseOrderRaw, parseOraclePriceData as parsePriceInfo, parseRiskTier, parseRpcPythPriceData, patchDepositAmount, percentToMaxSlippageU32, rateFromU32, requireBank, requireTokenProgram, resolveAmount, resolveBridgeCandidateBanks, resolveOrderLegs, resolvePinnedSwapRoute, resolveTokenProgramForMint, resolveVaultTokenProgram, runSwapEngine, selectLutsForAccountAction, selectLutsForBanks, selectSwapBridges, serializeBankConfigOpt, serializeInstruction, serializeInterestRateConfig, serializeLut, serializeOperationalState, serializeOracleSetup, serializeOracleSetupToIndex, serializeRiskTier, serializeSwapEngineRequest, serializeSwapEngineResult, setOraclePriceIx, sharedBridgeLegContext, shortenAddress, simulateAccountHealthCache, simulateAccountHealthCacheWithFallback, simulateBundle, splitInstructionsToFitTransactions, swapEngineProvidersFromOpts, swapEngineQuoteFieldsFromOpts, toBankConfigDto, toBankDto, toBankRateLimiterDto, toBigNumber, toEmodeSettingsDto, toInterestRateConfigDto, toJupiterConfig, toNumber, tryBridgeCandidates, uiToNative, uiToNativeBigNumber, validatorStakeGroupToDto, withKaminoReserveEmergency, wrappedI80F48toBigNumber };
|
|
89852
|
+
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_BRIDGE_MINTS, DEFAULT_ORACLE_MAX_AGE, DEFAULT_REPAY_ALL_EXTRA_BUFFER_BPS, DISABLED_FLAG, EMPTY_HEALTH_CACHE, EXECUTION_HEADROOM_SECONDS, EmodeEntryFlags, EmodeFlags, EmodeImpactStatus, EmodeSettings, EmodeTag, FLASHLOAN_ENABLED_FLAG, HOURS_PER_YEAR, HealthCache, HealthCacheFlags, HealthCacheSimulationError, HealthCacheStatus, JUPITER_V6_PROGRAM, JUP_SWAP_LUT_PROGRAM_AUTHORITY_INDEX, KAMINO_MARKET_EMERGENCY_FLAG, 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_COSTLY_POSITIONS, 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, PDA_ORDER_SEED, PDA_REBALANCE_FEE_POOL_SEED, PREMIUM_ACTIVE_FLAG, PRIORITY_TX_SIZE, PYTH_PRICE_CONF_INTERVALS, PYTH_PUSH_ORACLE_ID, PYTH_SPONSORED_SHARD_ID, PriceBias, Project0Client, RiskTier, SECONDS_PER_YEAR, SINGLE_POOL_PROGRAM_ID, STAKED_ORACLE_DISABLED_FLAG, STAKED_ORACLE_USES_ONRAMP_FLAG, STAKE_CONFIG_ID, STAKE_PROGRAM_ID, SWAP_ADAPTERS, SYSTEM_PROGRAM_ID, SYSVAR_CLOCK_ID, SYSVAR_RENT_ID, SYSVAR_STAKE_HISTORY_ID, SwapProvider, TRANSFER_ACCOUNT_AUTHORITY_FLAG, TransactionArenaKeyMap, TransactionBuildingError, TransactionBuildingErrorCode, TransactionConfigMap, TransactionType, U64_MAX2 as U64_MAX, USDC_DECIMALS, USDC_MINT, USDT_MINT, VENUE_AVAILABLE_LIQUIDITY_BUFFER, WSOL_MINT, ZERO_ORACLE_KEY, accountConflictsWithBridgeBank, accountFlagToBN, addOracleToBanksIx, addTransactionMetadata, adjustPriceComponent, appendPremiumRefresh, aprToApy, apyToApr, balanceToDto, bankConfigRawToDto, bankConfigToBankConfigRaw, bankMetadataMapToDto, bankMetadataToDto, bankRateLimiterRawToDto, bankRawToDto, bigNumberToWrappedI80F48, bpsToPercentile, buildCollateralLegIxs, buildOrderTrigger, calculateApyFromInterest, calculateInterestFromApy, capConfidenceInterval, categorizePythBanks, checkJupiterFeeAccount, checkTitanFeeAccount, chunkedGetRawMultipleAccountInfoOrdered, chunkedGetRawMultipleAccountInfoOrderedWithNulls, chunkedGetRawMultipleAccountInfos, classifyAndValidate, compileFlashloanPrecheck, composeBridgedSwap, composeRemainingAccounts, computeAccountValue, computeAccrualProjectionSeconds, computeActiveEmodePairs, computeAssetHealthComponent, computeAssetUsdValue, computeBalancePremium, computeBalanceUsdValue, computeBankAvailableLiquidity, computeBankBorrowApy, computeBankBorrowCapRemaining, computeBankDepositCapRemaining, computeBankMetrics, computeBankOutflowRateLimit, computeBankPoolSize, computeBankProjectedAvailableLiquidity, computeBankRateLimitRemaining, computeBankSupplyApy, computeBankTotalBorrows, computeBankTotalBorrowsUsd, computeBankTotalDeposits, computeBankTotalDepositsUsd, computeBaseInterestRate, computeBorrowEstimateForRepay, computeClosePositionTokenAmount, computeEmodeImpacts, computeFlashLoanNonSwapBudget, computeFlashloanSwapConstraints, computeFreeCollateralFromBalances, computeFreeCollateralFromCache, computeGroupRateLimitRemainingUsd, computeHealthAccountMetas, computeHealthCacheStatus, computeHealthCheckAccounts, computeHealthComponentsFromBalances, computeHealthComponentsFromCache, computeInterestRates, computeLiabilityHealthComponent, computeLiabilityUsdValue, computeLiquidationPriceForBank, computeLoopingParams, computeLowestEmodeWeights, computeMaxBorrowForBank, computeMaxDepositForBank, computeMaxLeverage, computeMaxWithdrawForBank, computeNetApy, computeOracleMultiplier, computeOracleMultipliers, computeOrderPairNetValue, computePremiumBreakdown, computePremiumImpact, computePremiumRatesByBank, computeProjectedActiveBalancesNoCpi, computeProjectedActiveBanksNoCpi, computePtMultiplier, computeQuantity, computeQuantityUi, computeRateLimitWindowRemainingCapacity, computeRateLimiterRemainingCapacity, computeRemainingCapacity, computeStakedBankMultipliers, computeTvl, computeUsdValue, computeUtilizationRate, computeV0TxSize, computeVenueAvailableLiquidity, configureScopeOracleIx, convertVoteAccCoeffsToBankCoeffs, createActiveEmodePairFromPairs, createEmptyBalance, decodeAccountRaw, decodeBankRaw, decodeInstruction, decodeMultiplierAccount, decompileV0Transaction, deriveBankEmissionsAuth, deriveBankEmissionsVault, deriveBankFeeVault, deriveBankFeeVaultAuthority, deriveBankInsuranceVault, deriveBankInsuranceVaultAuthority, deriveBankLiquidityVault, deriveBankLiquidityVaultAuthority, deriveFeeState, deriveMarginfiAccount, deriveOrderPda, deriveRebalanceFeePool, deserializeInstruction, deserializeLut, deserializeSwapEngineRequest, deserializeSwapEngineResult, dtoToBalance, dtoToBank, dtoToBankConfig, dtoToBankConfigRaw, dtoToBankMetadata, dtoToBankMetadataMap, dtoToBankRateLimiter, dtoToBankRateLimiterRaw, dtoToBankRaw, dtoToEmodeSettings, dtoToEmodeSettingsRaw, dtoToGroup, dtoToHealthCache, dtoToInterestRateConfig, dtoToMarginfiAccount, dtoToOraclePrice, dtoToValidatorStakeGroup, emodeSettingsRawToDto, exceedsCostlyPositionLimit, extractPythOracleKeys, fetchBank, fetchBankIntegrationMetadata, fetchGammaLpVault, fetchGammaWithdrawReceipt, fetchMarginfiAccountActiveBalancesForBank, fetchMarginfiAccountAddresses, fetchMarginfiAccountAddressesHoldingBank, fetchMarginfiAccountData, fetchMultipleBanks, fetchMultiplierAccountStates, fetchMultiplierAccountStatesFromAPI, fetchNativeStakeAccounts, fetchOracleData, fetchOracleMultipliers, fetchOracleMultipliersFromAPI, fetchOracleMultipliersFromChain, fetchOrderFees, fetchOrdersForAccount, fetchProgramForMints, fetchPythOracleData, fetchPythOraclePricesFromAPI, fetchPythOraclePricesFromChain, fetchScopeOracleData, fetchScopeOraclePricesFromAPI, fetchScopeOraclePricesFromChain, fetchStakeAccount, fetchStakePoolActiveStates, fetchStakePoolMev, findRandomAvailableAccountIndex, fitsInOneTransaction, freezeBankConfigIx, generateDummyAccount, getAccountKeys, getActiveAccountFlags, getActiveBalances, getActiveEmodeEntryFlags, getActiveEmodeFlags, getActiveHealthCacheFlags, getAssetQuantity, getAssetShares, getAssetWeight, getBalance, getBalanceUsdValueWithPriceBias, getBankVaultAuthority, getBankVaultSeeds, getBirdeyeFallbackPricesByFeedId, getBirdeyePricesForMints, getConfig, getDriftCTokenMultiplier, getDriftMetadata, getDriftStatesDto, getEffectiveDepositLimit, getEmodePairs, getExactOutEstimate, getFallbackPricesByFeedId, getFallbackPricesForMints, getHealthCacheStatusDescription, getHealthSimulationTransactions, getJupLendFTokenMultiplier, getJupLendMetadata, getJupLendStatesDto, getJupiterReferralFeeAccount, getJupiterSwapIxsForFlashloan, getKaminoCTokenMultiplier, getKaminoMetadata, getKaminoStatesDto, getLiabilityQuantity, getLiabilityShares, getLiabilityWeight, getOracleMultiplierBankInput, getOracleSourceFromBank, getOracleSourceFromOracleSetup, getOracleSourceNameFromKey, getPrice, getPriceWithConfidence, getStakedBankMetadataMap, getSwapAdapter, getSwapIxsForFlashloan, getTitanExactOutEstimate, getTitanSwapIxsForFlashloan, getTotalAccountKeys, getTotalAssetQuantity, getTotalLiabilityQuantity, getTxSize, getValidatorVoteAccountByBank, getWritableAccountKeys, groupToDto, hasAccountFlag, hasEmodeEntryFlag, hasEmodeFlag, hasHealthCacheFlag, healthCacheToDto, isBorrowLimitActive, isBridgeConflictError, isCostlyBank, isDecomposableSwapError, isDepositIx, isDepositLimitActive, isFlashloan, isGroupRateLimiterEnabled, isStandardBorrowable, isStandardDepositable, isV0Tx, isWeightedPrice, isWholePosition, makeAccountTransferToNewAccountTx, makeAddPermissionlessStakedBankIx, makeBeginFlashLoanIx3 as makeBeginFlashLoanIx, makeBorrowIx3 as makeBorrowIx, makeBorrowTx, makeBridgedLoopTx, makeBridgedSwapCollateralTx, makeBridgedSwapDebtTx, makeBulkRepayTx, makeBulkWithdrawTx, makeBundleTipIx, makeCloseMarginfiAccountIx, makeCloseMarginfiAccountTx, makeCloseOrderIx2 as makeCloseOrderIx, makeCloseOrderTx, 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, makeOrderChangesIxs, makeOrderChangesTx, makePlaceOrderIx2 as makePlaceOrderIx, makePlaceOrderTx, makePoolAddBankIx2 as makePoolAddBankIx, makePoolConfigureBankGovIx2 as makePoolConfigureBankGovIx, makePoolConfigureBankIx2 as makePoolConfigureBankIx, makePreludeTxs, makePremiumRefreshIxs, makePriorityFeeIx, makePriorityFeeMicroIx, makePulseHealthIx3 as makePulseHealthIx, makeRedeemStakedLstIx, makeRedeemStakedLstTx, makeRefreshIntegrationBanksIxs, makeRefreshKaminoBanksIxs, makeRepayIx3 as makeRepayIx, makeRepayTx, makeRepayWithCollatTx, makeRollPtTx, makeSetupIx, makeSwapCollateralTx, makeSwapDebtTx, makeTransferPositionsTx, makeTxPriorityIx, makeUnwrapSolIx, makeUpdateDriftMarketIxs, makeUpdateJupLendRateIxs, makeUpdateOrderTx, makeVaultCompleteWithdrawalIx, makeVaultCompleteWithdrawalTx, makeVaultDepositIx, makeVaultDepositTx, makeVaultDepositWithSwapTx, makeVaultWithdrawIx, makeVaultWithdrawTx, makeVersionedTransaction, makeWithdrawIx3 as makeWithdrawIx, makeWithdrawTx, makeWrapSolIxs, mapJupiterQuoteToSwapQuoteResult, mapPythBanksToOraclePrices, marginfiAccountToDto, maxSlippageU32ToPercent, mergeBridgeQuotes, mergeBridgeQuotesDebt, mergeBridgeQuotesLoop, nativeToUi, needsPremiumRefresh, oraclePriceToDto, parseBalanceRaw, parseBankConfigRaw, parseBankRateLimiterRaw, parseBankRaw, parseEmodeSettingsRaw, parseEmodeTag, parseHealthCacheRaw, parseMarginfiAccountRaw, parseOperationalState, parseOracleSetup, parseOrderRaw, parseOraclePriceData as parsePriceInfo, parseRiskTier, parseRpcPythPriceData, patchDepositAmount, percentToMaxSlippageU32, prependOrderCloses, rateFromU32, requireBank, requireTokenProgram, resolveAmount, resolveBridgeCandidateBanks, resolveOrderLegs, resolvePinnedSwapRoute, resolveTokenProgramForMint, resolveVaultTokenProgram, runSwapEngine, selectLutsForAccountAction, selectLutsForBanks, selectSwapBridges, serializeBankConfigOpt, serializeInstruction, serializeInterestRateConfig, serializeLut, serializeOperationalState, serializeOracleSetup, serializeOracleSetupToIndex, serializeRiskTier, serializeSwapEngineRequest, serializeSwapEngineResult, setOraclePriceIx, sharedBridgeLegContext, shortenAddress, simulateAccountHealthCache, simulateAccountHealthCacheWithFallback, simulateBundle, splitInstructionsToFitTransactions, swapEngineProvidersFromOpts, swapEngineQuoteFieldsFromOpts, toBankConfigDto, toBankDto, toBankRateLimiterDto, toBigNumber, toEmodeSettingsDto, toInterestRateConfigDto, toJupiterConfig, toNumber, tryBridgeCandidates, uiToNative, uiToNativeBigNumber, validatorStakeGroupToDto, withKaminoReserveEmergency, wrappedI80F48toBigNumber };
|
|
89662
89853
|
//# sourceMappingURL=index.js.map
|
|
89663
89854
|
//# sourceMappingURL=index.js.map
|