@0dotxyz/p0-ts-sdk 2.5.3 → 2.5.5-alpha.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 +577 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +170 -4
- package/dist/index.d.ts +170 -4
- package/dist/index.js +575 -3
- package/dist/index.js.map +1 -1
- package/dist/instructions.d.cts +1 -1
- package/dist/instructions.d.ts +1 -1
- package/dist/{types-Bv7AjHar.d.ts → types-D1QBbDkU.d.ts} +4 -1
- package/dist/{types-f-ZjRBYz.d.cts → types-DrxdJJIi.d.cts} +4 -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
|
*/
|
|
@@ -19875,6 +19912,7 @@ var EmodeFlags = /* @__PURE__ */ ((EmodeFlags3) => {
|
|
|
19875
19912
|
var EmodeTag = /* @__PURE__ */ ((EmodeTag3) => {
|
|
19876
19913
|
EmodeTag3[EmodeTag3["UNSET"] = 0] = "UNSET";
|
|
19877
19914
|
EmodeTag3[EmodeTag3["SOL"] = 501] = "SOL";
|
|
19915
|
+
EmodeTag3[EmodeTag3["SOL_T2"] = 502] = "SOL_T2";
|
|
19878
19916
|
EmodeTag3[EmodeTag3["LST_T1"] = 1571] = "LST_T1";
|
|
19879
19917
|
EmodeTag3[EmodeTag3["LST_T2"] = 1572] = "LST_T2";
|
|
19880
19918
|
EmodeTag3[EmodeTag3["LST_PT"] = 15787] = "LST_PT";
|
|
@@ -19883,6 +19921,8 @@ var EmodeTag = /* @__PURE__ */ ((EmodeTag3) => {
|
|
|
19883
19921
|
EmodeTag3[EmodeTag3["STABLE_T2"] = 57482] = "STABLE_T2";
|
|
19884
19922
|
EmodeTag3[EmodeTag3["BTC_T1"] = 871] = "BTC_T1";
|
|
19885
19923
|
EmodeTag3[EmodeTag3["BTC_T2"] = 872] = "BTC_T2";
|
|
19924
|
+
EmodeTag3[EmodeTag3["HYUSD"] = 47050] = "HYUSD";
|
|
19925
|
+
EmodeTag3[EmodeTag3["PT_HYUSD"] = 8747] = "PT_HYUSD";
|
|
19886
19926
|
return EmodeTag3;
|
|
19887
19927
|
})(EmodeTag || {});
|
|
19888
19928
|
var EmodeImpactStatus = /* @__PURE__ */ ((EmodeImpactStatus3) => {
|
|
@@ -21706,6 +21746,8 @@ function parseEmodeTag(emodeTagRaw) {
|
|
|
21706
21746
|
switch (emodeTagRaw) {
|
|
21707
21747
|
case 501:
|
|
21708
21748
|
return 501 /* SOL */;
|
|
21749
|
+
case 502:
|
|
21750
|
+
return 502 /* SOL_T2 */;
|
|
21709
21751
|
case 1571:
|
|
21710
21752
|
return 1571 /* LST_T1 */;
|
|
21711
21753
|
case 1572:
|
|
@@ -21722,6 +21764,10 @@ function parseEmodeTag(emodeTagRaw) {
|
|
|
21722
21764
|
return 871 /* BTC_T1 */;
|
|
21723
21765
|
case 872:
|
|
21724
21766
|
return 872 /* BTC_T2 */;
|
|
21767
|
+
case 47050:
|
|
21768
|
+
return 47050 /* HYUSD */;
|
|
21769
|
+
case 8747:
|
|
21770
|
+
return 8747 /* PT_HYUSD */;
|
|
21725
21771
|
case 0:
|
|
21726
21772
|
default:
|
|
21727
21773
|
return 0 /* UNSET */;
|
|
@@ -69397,6 +69443,23 @@ var MarginfiAccount = class _MarginfiAccount {
|
|
|
69397
69443
|
}
|
|
69398
69444
|
});
|
|
69399
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
|
+
}
|
|
69400
69463
|
/**
|
|
69401
69464
|
* Creates a transaction to repay debt using collateral.
|
|
69402
69465
|
*
|
|
@@ -69856,6 +69919,485 @@ async function composeBridgedSwap(params) {
|
|
|
69856
69919
|
if (!transactions) return null;
|
|
69857
69920
|
return { transactions, firstLegQuote: firstLeg.quoteResponse, secondLegQuote: secondLeg.quoteResponse };
|
|
69858
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 borrowedSoFar = [];
|
|
70201
|
+
for (const position of debts) {
|
|
70202
|
+
const { bank, tokenProgram } = position;
|
|
70203
|
+
borrowedSoFar.push(bank);
|
|
70204
|
+
const activeBanks = dedupeBanks([
|
|
70205
|
+
...ctx.destPreexistingBanks,
|
|
70206
|
+
...collateralBanks,
|
|
70207
|
+
...borrowedSoFar
|
|
70208
|
+
]);
|
|
70209
|
+
const observationBanksOverride = computeHealthAccountMetas(activeBanks);
|
|
70210
|
+
const borrowUi = position.uiAmount.times(1 + ctx.borrowPaddingBps / 1e4);
|
|
70211
|
+
const borrow = await makeBorrowIx3({
|
|
70212
|
+
program: ctx.program,
|
|
70213
|
+
bank,
|
|
70214
|
+
bankMap: ctx.bankMap,
|
|
70215
|
+
tokenProgram,
|
|
70216
|
+
amount: borrowUi,
|
|
70217
|
+
marginfiAccount: ctx.accountB,
|
|
70218
|
+
authority: ctx.accountA.authority,
|
|
70219
|
+
isSync,
|
|
70220
|
+
opts: {
|
|
70221
|
+
createAtas: false,
|
|
70222
|
+
wrapAndUnwrapSol: false,
|
|
70223
|
+
overrideInferAccounts: ctx.overrideInferAccounts,
|
|
70224
|
+
observationBanksOverride
|
|
70225
|
+
}
|
|
70226
|
+
});
|
|
70227
|
+
borrowIxs.push(...borrow.instructions);
|
|
70228
|
+
const repay = await makeRepayIx3({
|
|
70229
|
+
program: ctx.program,
|
|
70230
|
+
bank,
|
|
70231
|
+
tokenProgram,
|
|
70232
|
+
amount: position.uiAmount,
|
|
70233
|
+
accountAddress: ctx.accountA.address,
|
|
70234
|
+
authority: ctx.accountA.authority,
|
|
70235
|
+
repayAll: true,
|
|
70236
|
+
isSync,
|
|
70237
|
+
opts: {
|
|
70238
|
+
wrapAndUnwrapSol: false,
|
|
70239
|
+
overrideInferAccounts: ctx.overrideInferAccounts
|
|
70240
|
+
}
|
|
70241
|
+
});
|
|
70242
|
+
repayIxs.push(...repay.instructions);
|
|
70243
|
+
}
|
|
70244
|
+
return [...CU_IXS(), ...withdrawIxs, ...depositIxs, ...borrowIxs, ...repayIxs];
|
|
70245
|
+
}
|
|
70246
|
+
async function buildTransferFlashloanTx(args) {
|
|
70247
|
+
const { program, accountA, projectedActiveBanksA, innerIxs, preIxs, blockhash, luts } = args;
|
|
70248
|
+
const endIndex = preIxs.length + innerIxs.length + 1;
|
|
70249
|
+
const begin = await makeBeginFlashLoanIx3(program, accountA.address, endIndex, accountA.authority);
|
|
70250
|
+
const end = await makeEndFlashLoanIx3(
|
|
70251
|
+
program,
|
|
70252
|
+
accountA.address,
|
|
70253
|
+
projectedActiveBanksA,
|
|
70254
|
+
accountA.authority
|
|
70255
|
+
);
|
|
70256
|
+
const message = new TransactionMessage({
|
|
70257
|
+
payerKey: accountA.authority,
|
|
70258
|
+
recentBlockhash: blockhash,
|
|
70259
|
+
instructions: [...preIxs, ...begin.instructions, ...innerIxs, ...end.instructions]
|
|
70260
|
+
}).compileToV0Message(luts);
|
|
70261
|
+
return addTransactionMetadata(new VersionedTransaction(message), {
|
|
70262
|
+
addressLookupTables: luts,
|
|
70263
|
+
type: "FLASHLOAN" /* FLASHLOAN */
|
|
70264
|
+
});
|
|
70265
|
+
}
|
|
70266
|
+
function destPreexistingBanksOf(account, bankMap) {
|
|
70267
|
+
if (!account) return [];
|
|
70268
|
+
return dedupeBanks(
|
|
70269
|
+
account.balances.filter((b) => b.active).map((b) => bankMap.get(b.bankPk.toBase58())).filter((b) => Boolean(b))
|
|
70270
|
+
);
|
|
70271
|
+
}
|
|
70272
|
+
async function makeTransferPositionsTx(params) {
|
|
70273
|
+
const {
|
|
70274
|
+
program,
|
|
70275
|
+
connection,
|
|
70276
|
+
marginfiAccount: accountA,
|
|
70277
|
+
bankMap,
|
|
70278
|
+
bankMetadataMap,
|
|
70279
|
+
oraclePrices,
|
|
70280
|
+
assetShareValueMultiplierByBank,
|
|
70281
|
+
addressLookupTableAccounts,
|
|
70282
|
+
crossbarUrl,
|
|
70283
|
+
overrideInferAccounts
|
|
70284
|
+
} = params;
|
|
70285
|
+
const luts = addressLookupTableAccounts ?? [];
|
|
70286
|
+
const borrowPaddingBps = params.borrowPaddingBps ?? DEFAULT_BORROW_PADDING_BPS;
|
|
70287
|
+
const groupRateLimiterEnabled = params.groupRateLimiterEnabled ?? false;
|
|
70288
|
+
const positions = classifyAndValidate(params);
|
|
70289
|
+
let accountB = params.destinationAccount;
|
|
70290
|
+
let createIx;
|
|
70291
|
+
if (!accountB) {
|
|
70292
|
+
const accountIndex = params.createDestinationOpts?.accountIndex ?? await findRandomAvailableAccountIndex(
|
|
70293
|
+
connection,
|
|
70294
|
+
program.programId,
|
|
70295
|
+
accountA.group,
|
|
70296
|
+
accountA.authority
|
|
70297
|
+
);
|
|
70298
|
+
const created = await makeCreateAccountIxWithProjection({
|
|
70299
|
+
program,
|
|
70300
|
+
authority: accountA.authority,
|
|
70301
|
+
group: accountA.group,
|
|
70302
|
+
accountIndex,
|
|
70303
|
+
thirdPartyId: params.createDestinationOpts?.thirdPartyId
|
|
70304
|
+
});
|
|
70305
|
+
accountB = created.account;
|
|
70306
|
+
createIx = created.ix;
|
|
70307
|
+
}
|
|
70308
|
+
const ctx = {
|
|
70309
|
+
program,
|
|
70310
|
+
accountA,
|
|
70311
|
+
accountB,
|
|
70312
|
+
bankMap,
|
|
70313
|
+
bankMetadataMap,
|
|
70314
|
+
assetShareValueMultiplierByBank,
|
|
70315
|
+
borrowPaddingBps,
|
|
70316
|
+
groupRateLimiterEnabled,
|
|
70317
|
+
overrideInferAccounts,
|
|
70318
|
+
destPreexistingBanks: destPreexistingBanksOf(params.destinationAccount, bankMap)
|
|
70319
|
+
};
|
|
70320
|
+
const innerIxs = await buildInnerIxs(ctx, positions, false);
|
|
70321
|
+
const transferred = new Set(positions.map((p) => p.bankAddress.toBase58()));
|
|
70322
|
+
const projectedActiveBanksA = dedupeBanks(
|
|
70323
|
+
accountA.balances.filter((b) => b.active && !transferred.has(b.bankPk.toBase58())).map((b) => requireBank(bankMap, b.bankPk))
|
|
70324
|
+
);
|
|
70325
|
+
const blockhash = (await connection.getLatestBlockhash("confirmed")).blockhash;
|
|
70326
|
+
const preIxs = createIx ? [createIx] : [];
|
|
70327
|
+
const flashloanTx = await buildTransferFlashloanTx({
|
|
70328
|
+
program,
|
|
70329
|
+
accountA,
|
|
70330
|
+
projectedActiveBanksA,
|
|
70331
|
+
innerIxs,
|
|
70332
|
+
preIxs,
|
|
70333
|
+
blockhash,
|
|
70334
|
+
luts
|
|
70335
|
+
});
|
|
70336
|
+
const size = getTxSize(flashloanTx);
|
|
70337
|
+
const keys = getTotalAccountKeys(flashloanTx);
|
|
70338
|
+
if (size > MAX_TX_SIZE || keys > MAX_ACCOUNT_LOCKS) {
|
|
70339
|
+
throw TransactionBuildingError.transferPositionsUnsplittable(
|
|
70340
|
+
`built transaction exceeds size limits (${size} bytes, ${keys} accounts); transfer fewer positions`,
|
|
70341
|
+
size,
|
|
70342
|
+
keys
|
|
70343
|
+
);
|
|
70344
|
+
}
|
|
70345
|
+
const setupIxs = await makeSetupIx({
|
|
70346
|
+
connection,
|
|
70347
|
+
authority: accountA.authority,
|
|
70348
|
+
tokens: positions.map((p) => ({ mint: p.bank.mint, tokenProgram: p.tokenProgram }))
|
|
70349
|
+
});
|
|
70350
|
+
const refreshIxs = buildIntegrationRefreshIxs({
|
|
70351
|
+
accountA,
|
|
70352
|
+
destinationAccount: params.destinationAccount,
|
|
70353
|
+
positions,
|
|
70354
|
+
bankMap,
|
|
70355
|
+
bankMetadataMap
|
|
70356
|
+
});
|
|
70357
|
+
const additionalTxs = [];
|
|
70358
|
+
const preludeIxs = [...setupIxs, ...refreshIxs];
|
|
70359
|
+
if (preludeIxs.length > 0) {
|
|
70360
|
+
const txs = splitInstructionsToFitTransactions([], preludeIxs, {
|
|
70361
|
+
blockhash,
|
|
70362
|
+
payerKey: accountA.authority,
|
|
70363
|
+
luts
|
|
70364
|
+
});
|
|
70365
|
+
additionalTxs.push(
|
|
70366
|
+
...txs.map(
|
|
70367
|
+
(tx) => addTransactionMetadata(tx, { type: "CREATE_ATA" /* CREATE_ATA */, addressLookupTables: luts })
|
|
70368
|
+
)
|
|
70369
|
+
);
|
|
70370
|
+
}
|
|
70371
|
+
const { instructions: updateFeedIxs, luts: feedLuts } = await makeSmartCrankSwbFeedIx({
|
|
70372
|
+
marginfiAccount: accountA,
|
|
70373
|
+
bankMap,
|
|
70374
|
+
oraclePrices,
|
|
70375
|
+
assetShareValueMultiplierByBank,
|
|
70376
|
+
instructions: innerIxs,
|
|
70377
|
+
program,
|
|
70378
|
+
connection,
|
|
70379
|
+
crossbarUrl
|
|
70380
|
+
});
|
|
70381
|
+
if (updateFeedIxs.length > 0) {
|
|
70382
|
+
const message = new TransactionMessage({
|
|
70383
|
+
payerKey: accountA.authority,
|
|
70384
|
+
recentBlockhash: blockhash,
|
|
70385
|
+
instructions: updateFeedIxs
|
|
70386
|
+
}).compileToV0Message(feedLuts);
|
|
70387
|
+
additionalTxs.push(
|
|
70388
|
+
addTransactionMetadata(new VersionedTransaction(message), {
|
|
70389
|
+
addressLookupTables: feedLuts,
|
|
70390
|
+
type: "CRANK" /* CRANK */
|
|
70391
|
+
})
|
|
70392
|
+
);
|
|
70393
|
+
}
|
|
70394
|
+
const transactions = [...additionalTxs, flashloanTx];
|
|
70395
|
+
return {
|
|
70396
|
+
transactions,
|
|
70397
|
+
actionTxIndex: additionalTxs.length,
|
|
70398
|
+
destinationAccount: accountB
|
|
70399
|
+
};
|
|
70400
|
+
}
|
|
69859
70401
|
|
|
69860
70402
|
// src/services/account/services/account-simulation.service.ts
|
|
69861
70403
|
async function simulateAccountHealthCacheWithFallback(params) {
|
|
@@ -70265,7 +70807,7 @@ var GROUP_OFFSET = 8;
|
|
|
70265
70807
|
var BALANCES_OFFSET = 72;
|
|
70266
70808
|
var BALANCE_SIZE = 104;
|
|
70267
70809
|
var BANK_PK_OFFSET_IN_BALANCE = 1;
|
|
70268
|
-
var
|
|
70810
|
+
var MAX_BALANCES2 = 16;
|
|
70269
70811
|
var scanBankSlots = async (program, group, bank, options) => {
|
|
70270
70812
|
const connection = program.provider.connection;
|
|
70271
70813
|
const programId = program.programId;
|
|
@@ -70273,7 +70815,7 @@ var scanBankSlots = async (program, group, bank, options) => {
|
|
|
70273
70815
|
const groupBytes = group.toBase58();
|
|
70274
70816
|
const bankBytes = bank.toBase58();
|
|
70275
70817
|
const slotOffsets = Array.from(
|
|
70276
|
-
{ length:
|
|
70818
|
+
{ length: MAX_BALANCES2 },
|
|
70277
70819
|
(_, n) => BALANCES_OFFSET + BANK_PK_OFFSET_IN_BALANCE + n * BALANCE_SIZE
|
|
70278
70820
|
);
|
|
70279
70821
|
const scanSlot = (offset) => {
|
|
@@ -74304,6 +74846,36 @@ var MarginfiAccountWrapper = class {
|
|
|
74304
74846
|
};
|
|
74305
74847
|
return this.account.makeLoopTx(fullParams);
|
|
74306
74848
|
}
|
|
74849
|
+
/**
|
|
74850
|
+
* Atomically move a selected set of positions from this account to a destination account with
|
|
74851
|
+
* auto-injected client data.
|
|
74852
|
+
*
|
|
74853
|
+
* Auto-injects: program, connection, marginfiAccount, bankMap, oraclePrices, bankMetadataMap,
|
|
74854
|
+
* assetShareValueMultiplierByBank, addressLookupTables, tokenProgramsByBank, groupRateLimiterEnabled.
|
|
74855
|
+
*/
|
|
74856
|
+
async makeTransferPositionsTx(params) {
|
|
74857
|
+
const tokenProgramsByBank = /* @__PURE__ */ new Map();
|
|
74858
|
+
for (const bankAddress of params.bankAddresses) {
|
|
74859
|
+
const bank = this.client.bankMap.get(bankAddress.toBase58());
|
|
74860
|
+
if (!bank) throw new Error(`Bank ${bankAddress.toBase58()} not found`);
|
|
74861
|
+
const mintData = await this.getMintDataFromBank(bank);
|
|
74862
|
+
tokenProgramsByBank.set(bankAddress.toBase58(), mintData.tokenProgram);
|
|
74863
|
+
}
|
|
74864
|
+
const fullParams = {
|
|
74865
|
+
...params,
|
|
74866
|
+
program: this.client.program,
|
|
74867
|
+
connection: this.client.program.provider.connection,
|
|
74868
|
+
marginfiAccount: this.account,
|
|
74869
|
+
bankMap: this.client.bankMap,
|
|
74870
|
+
oraclePrices: this.client.oraclePriceByBank,
|
|
74871
|
+
bankMetadataMap: this.client.bankIntegrationMap,
|
|
74872
|
+
assetShareValueMultiplierByBank: this.client.assetShareValueMultiplierByBank,
|
|
74873
|
+
addressLookupTableAccounts: this.client.addressLookupTables,
|
|
74874
|
+
tokenProgramsByBank,
|
|
74875
|
+
groupRateLimiterEnabled: isGroupRateLimiterEnabled(this.client.group.rateLimiter)
|
|
74876
|
+
};
|
|
74877
|
+
return this.account.makeTransferPositionsTx(fullParams);
|
|
74878
|
+
}
|
|
74307
74879
|
/**
|
|
74308
74880
|
* Creates a repay with collateral transaction with auto-injected client data.
|
|
74309
74881
|
*
|
|
@@ -75145,6 +75717,6 @@ var EmodeSettings = class _EmodeSettings {
|
|
|
75145
75717
|
}
|
|
75146
75718
|
};
|
|
75147
75719
|
|
|
75148
|
-
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 };
|
|
75720
|
+
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 };
|
|
75149
75721
|
//# sourceMappingURL=index.js.map
|
|
75150
75722
|
//# sourceMappingURL=index.js.map
|