@0dotxyz/p0-ts-sdk 2.9.0-alpha.0 → 2.9.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 +151 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +123 -24
- package/dist/index.d.ts +123 -24
- package/dist/index.js +148 -43
- package/dist/index.js.map +1 -1
- package/dist/instructions.d.cts +1 -1
- package/dist/instructions.d.ts +1 -1
- package/dist/{types-CvvHQs7G.d.cts → types-B5hbKbQJ.d.cts} +7 -1
- package/dist/{types-Auh-s318.d.ts → types-C3ArshQA.d.ts} +7 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -125,6 +125,8 @@ var TransactionBuildingErrorCode = /* @__PURE__ */ ((TransactionBuildingErrorCod
|
|
|
125
125
|
TransactionBuildingErrorCode2["TRANSFER_POSITIONS_UNSUPPORTED_BANK"] = "TRANSFER_POSITIONS_UNSUPPORTED_BANK";
|
|
126
126
|
TransactionBuildingErrorCode2["TRANSFER_POSITIONS_UNSPLITTABLE"] = "TRANSFER_POSITIONS_UNSPLITTABLE";
|
|
127
127
|
TransactionBuildingErrorCode2["BRIDGE_CONFLICT"] = "BRIDGE_CONFLICT";
|
|
128
|
+
TransactionBuildingErrorCode2["ORDER_INVALID_TRIGGER"] = "ORDER_INVALID_TRIGGER";
|
|
129
|
+
TransactionBuildingErrorCode2["ORDER_INVALID_SLIPPAGE"] = "ORDER_INVALID_SLIPPAGE";
|
|
128
130
|
return TransactionBuildingErrorCode2;
|
|
129
131
|
})(TransactionBuildingErrorCode || {});
|
|
130
132
|
var TransactionBuildingError = class _TransactionBuildingError extends Error {
|
|
@@ -258,6 +260,28 @@ var TransactionBuildingError = class _TransactionBuildingError extends Error {
|
|
|
258
260
|
{ conflictingBanks, bridgeTokenSide }
|
|
259
261
|
);
|
|
260
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
* The order trigger can't be placed: no threshold set, a threshold not above 0, or take-profit
|
|
265
|
+
* at or below stop-loss (the program rejects all three with `InvalidOrderTakeProfitOrStopLoss`).
|
|
266
|
+
*/
|
|
267
|
+
static orderInvalidTrigger(reason, takeProfitUsd, stopLossUsd) {
|
|
268
|
+
return new _TransactionBuildingError(
|
|
269
|
+
"ORDER_INVALID_TRIGGER" /* ORDER_INVALID_TRIGGER */,
|
|
270
|
+
`Invalid order trigger: ${reason}`,
|
|
271
|
+
{ reason, takeProfitUsd, stopLossUsd }
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* The order's max slippage is outside (0, cap]. The program accepts 0, but a keeper can't
|
|
276
|
+
* execute an order that allows no slippage, so the SDK rejects it.
|
|
277
|
+
*/
|
|
278
|
+
static orderInvalidSlippage(maxSlippagePercent, maxAllowedPercent) {
|
|
279
|
+
return new _TransactionBuildingError(
|
|
280
|
+
"ORDER_INVALID_SLIPPAGE" /* ORDER_INVALID_SLIPPAGE */,
|
|
281
|
+
`Max slippage percent must be in (0, ${maxAllowedPercent}], got ${maxSlippagePercent}`,
|
|
282
|
+
{ maxSlippagePercent, maxAllowedPercent }
|
|
283
|
+
);
|
|
284
|
+
}
|
|
261
285
|
/**
|
|
262
286
|
* Generic escape hatch for custom errors
|
|
263
287
|
*/
|
|
@@ -535,11 +559,9 @@ var U32_MAX = 4294967295;
|
|
|
535
559
|
var MAX_ORDER_SLIPPAGE_PERCENT = 10;
|
|
536
560
|
function percentToMaxSlippageU32(percent) {
|
|
537
561
|
if (!(percent > 0) || percent > MAX_ORDER_SLIPPAGE_PERCENT) {
|
|
538
|
-
throw
|
|
539
|
-
`Max slippage percent must be in (0, ${MAX_ORDER_SLIPPAGE_PERCENT}], got ${percent}`
|
|
540
|
-
);
|
|
562
|
+
throw TransactionBuildingError.orderInvalidSlippage(percent, MAX_ORDER_SLIPPAGE_PERCENT);
|
|
541
563
|
}
|
|
542
|
-
return Math.
|
|
564
|
+
return Math.floor(percent / 100 * U32_MAX);
|
|
543
565
|
}
|
|
544
566
|
function maxSlippageU32ToPercent(maxSlippage) {
|
|
545
567
|
return maxSlippage / U32_MAX * 100;
|
|
@@ -22696,6 +22718,10 @@ var AccountFlags = /* @__PURE__ */ ((AccountFlags2) => {
|
|
|
22696
22718
|
AccountFlags2[AccountFlags2["ACCOUNT_IN_FLASHLOAN"] = 2] = "ACCOUNT_IN_FLASHLOAN";
|
|
22697
22719
|
AccountFlags2[AccountFlags2["ACCOUNT_FLAG_DEPRECATED"] = 4] = "ACCOUNT_FLAG_DEPRECATED";
|
|
22698
22720
|
AccountFlags2[AccountFlags2["ACCOUNT_TRANSFER_AUTHORITY_ALLOWED"] = 8] = "ACCOUNT_TRANSFER_AUTHORITY_ALLOWED";
|
|
22721
|
+
AccountFlags2[AccountFlags2["ACCOUNT_IN_RECEIVERSHIP"] = 16] = "ACCOUNT_IN_RECEIVERSHIP";
|
|
22722
|
+
AccountFlags2[AccountFlags2["ACCOUNT_IN_DELEVERAGE"] = 32] = "ACCOUNT_IN_DELEVERAGE";
|
|
22723
|
+
AccountFlags2[AccountFlags2["ACCOUNT_FROZEN"] = 64] = "ACCOUNT_FROZEN";
|
|
22724
|
+
AccountFlags2[AccountFlags2["ACCOUNT_IN_ORDER_EXECUTION"] = 128] = "ACCOUNT_IN_ORDER_EXECUTION";
|
|
22699
22725
|
return AccountFlags2;
|
|
22700
22726
|
})(AccountFlags || {});
|
|
22701
22727
|
var MarginRequirementType = /* @__PURE__ */ ((MarginRequirementType5) => {
|
|
@@ -72253,7 +72279,8 @@ function parseMarginfiAccountRaw(marginfiAccountPk, accountData) {
|
|
|
72253
72279
|
balances,
|
|
72254
72280
|
accountFlags,
|
|
72255
72281
|
emissionsDestinationAccount,
|
|
72256
|
-
healthCache
|
|
72282
|
+
healthCache,
|
|
72283
|
+
activeOrders: accountData.activeOrders
|
|
72257
72284
|
};
|
|
72258
72285
|
}
|
|
72259
72286
|
function getActiveAccountFlags(flags) {
|
|
@@ -72309,7 +72336,8 @@ function dtoToMarginfiAccount(marginfiAccountDto) {
|
|
|
72309
72336
|
balances: marginfiAccountDto.balances.map(dtoToBalance),
|
|
72310
72337
|
accountFlags: marginfiAccountDto.accountFlags,
|
|
72311
72338
|
emissionsDestinationAccount: new web3_js.PublicKey(marginfiAccountDto.emissionsDestinationAccount),
|
|
72312
|
-
healthCache: dtoToHealthCache(marginfiAccountDto.healthCache)
|
|
72339
|
+
healthCache: dtoToHealthCache(marginfiAccountDto.healthCache),
|
|
72340
|
+
activeOrders: marginfiAccountDto.activeOrders ?? 0
|
|
72313
72341
|
};
|
|
72314
72342
|
}
|
|
72315
72343
|
function dtoToBalance(balanceDto) {
|
|
@@ -72348,7 +72376,8 @@ function marginfiAccountToDto(marginfiAccount) {
|
|
|
72348
72376
|
balances: marginfiAccount.balances.map(balanceToDto),
|
|
72349
72377
|
accountFlags: marginfiAccount.accountFlags,
|
|
72350
72378
|
emissionsDestinationAccount: marginfiAccount.emissionsDestinationAccount.toBase58(),
|
|
72351
|
-
healthCache: healthCacheToDto(marginfiAccount.healthCache)
|
|
72379
|
+
healthCache: healthCacheToDto(marginfiAccount.healthCache),
|
|
72380
|
+
activeOrders: marginfiAccount.activeOrders
|
|
72352
72381
|
};
|
|
72353
72382
|
}
|
|
72354
72383
|
function balanceToDto(balance) {
|
|
@@ -72664,6 +72693,23 @@ function getBalanceUsdValueWithPriceBias(params) {
|
|
|
72664
72693
|
});
|
|
72665
72694
|
return { assets: assetsValue, liabilities: liabilitiesValue };
|
|
72666
72695
|
}
|
|
72696
|
+
function computeOrderPairNetValue(params) {
|
|
72697
|
+
const { collateral, debt } = params;
|
|
72698
|
+
const { assets: collateralUsd } = getBalanceUsdValueWithPriceBias({
|
|
72699
|
+
balance: collateral.balance,
|
|
72700
|
+
bank: collateral.bank,
|
|
72701
|
+
oraclePrice: collateral.oraclePrice,
|
|
72702
|
+
marginRequirement: 2 /* Equity */,
|
|
72703
|
+
assetShareValueMultiplier: collateral.assetShareValueMultiplier
|
|
72704
|
+
});
|
|
72705
|
+
const { liabilities: debtUsd } = getBalanceUsdValueWithPriceBias({
|
|
72706
|
+
balance: debt.balance,
|
|
72707
|
+
bank: debt.bank,
|
|
72708
|
+
oraclePrice: debt.oraclePrice,
|
|
72709
|
+
marginRequirement: 2 /* Equity */
|
|
72710
|
+
});
|
|
72711
|
+
return { collateralUsd, debtUsd, netUsd: collateralUsd.minus(debtUsd) };
|
|
72712
|
+
}
|
|
72667
72713
|
function computeQuantity(balance, bank) {
|
|
72668
72714
|
const assetsQuantity = getAssetQuantity(bank, balance.assetShares);
|
|
72669
72715
|
const liabilitiesQuantity = getLiabilityQuantity(bank, balance.liabilityShares);
|
|
@@ -72887,6 +72933,18 @@ function getActiveBalances(balances) {
|
|
|
72887
72933
|
function getBalance(bankAddress, balances) {
|
|
72888
72934
|
return balances.filter((b) => b.active).find((b) => b.bankPk.equals(bankAddress)) ?? createEmptyBalance(bankAddress);
|
|
72889
72935
|
}
|
|
72936
|
+
var EMPTY_BALANCE_THRESHOLD = 1;
|
|
72937
|
+
function resolveOrderLegs(marginfiAccount, order) {
|
|
72938
|
+
const taggedBalances = marginfiAccount.balances.filter(
|
|
72939
|
+
(balance) => balance.active && balance.tag !== 0 && order.tags.includes(balance.tag)
|
|
72940
|
+
);
|
|
72941
|
+
return {
|
|
72942
|
+
collateralBank: taggedBalances.find(
|
|
72943
|
+
(balance) => balance.liabilityShares.lt(EMPTY_BALANCE_THRESHOLD) && balance.assetShares.gte(EMPTY_BALANCE_THRESHOLD)
|
|
72944
|
+
)?.bankPk ?? null,
|
|
72945
|
+
debtBank: taggedBalances.find((balance) => balance.liabilityShares.gte(EMPTY_BALANCE_THRESHOLD))?.bankPk ?? null
|
|
72946
|
+
};
|
|
72947
|
+
}
|
|
72890
72948
|
function computeAccountValue(marginfiAccount) {
|
|
72891
72949
|
const { assets, liabilities } = computeHealthComponentsFromCache(
|
|
72892
72950
|
marginfiAccount,
|
|
@@ -73450,11 +73508,6 @@ var fetchMarginfiAccountData = async (program, marginfiAccountPk, banksMap, bank
|
|
|
73450
73508
|
return { marginfiAccount };
|
|
73451
73509
|
}
|
|
73452
73510
|
};
|
|
73453
|
-
var fetchOrder = async (program, orderAddress) => {
|
|
73454
|
-
const orderRaw = await program.account.order.fetchNullable(orderAddress);
|
|
73455
|
-
if (!orderRaw) return null;
|
|
73456
|
-
return parseOrderRaw(orderAddress, orderRaw);
|
|
73457
|
-
};
|
|
73458
73511
|
var fetchOrdersForAccount = async (program, marginfiAccount) => {
|
|
73459
73512
|
const orders = await program.account.order.all([
|
|
73460
73513
|
{
|
|
@@ -73467,18 +73520,13 @@ var fetchOrdersForAccount = async (program, marginfiAccount) => {
|
|
|
73467
73520
|
]);
|
|
73468
73521
|
return orders.map(({ publicKey: publicKey5, account }) => parseOrderRaw(publicKey5, account));
|
|
73469
73522
|
};
|
|
73470
|
-
var
|
|
73471
|
-
const
|
|
73472
|
-
|
|
73473
|
-
|
|
73474
|
-
|
|
73475
|
-
|
|
73476
|
-
|
|
73477
|
-
throw new Error(
|
|
73478
|
-
`Could not resolve banks for order ${order.address.toBase58()}: tagged balances are missing or closed`
|
|
73479
|
-
);
|
|
73480
|
-
}
|
|
73481
|
-
return { collateralBank: collateral.bankPk, debtBank: debt.bankPk };
|
|
73523
|
+
var fetchOrderFees = async (program) => {
|
|
73524
|
+
const [feeStateAddress] = deriveFeeState(program.programId);
|
|
73525
|
+
const feeState = await program.account.feeState.fetch(feeStateAddress);
|
|
73526
|
+
return {
|
|
73527
|
+
placementFeeLamports: feeState.orderInitFlatSolFee,
|
|
73528
|
+
executionMaxFee: wrappedI80F48toBigNumber(feeState.orderExecutionMaxFee)
|
|
73529
|
+
};
|
|
73482
73530
|
};
|
|
73483
73531
|
function randomDistinctIndices(count, maxExclusive) {
|
|
73484
73532
|
const chosen = /* @__PURE__ */ new Set();
|
|
@@ -73603,18 +73651,27 @@ function computeMaxBorrowForBank(params) {
|
|
|
73603
73651
|
BigNumber3__default.default.min(healthMaxBorrow, borrowCapRemaining, availableLiquidity, rateLimitRemaining)
|
|
73604
73652
|
);
|
|
73605
73653
|
}
|
|
73606
|
-
function
|
|
73654
|
+
function computeBankOutflowRateLimit(bank, assetShareValueMultiplier) {
|
|
73655
|
+
if (!bank.rateLimiter) return null;
|
|
73607
73656
|
const nowSeconds = Date.now() / 1e3;
|
|
73608
|
-
|
|
73609
|
-
let
|
|
73610
|
-
|
|
73611
|
-
const
|
|
73612
|
-
|
|
73613
|
-
|
|
73614
|
-
|
|
73615
|
-
|
|
73657
|
+
const limiterToUnderlying = bank.config.assetTag === 2 /* STAKED */ && assetShareValueMultiplier?.gt(0) ? assetShareValueMultiplier : new BigNumber3__default.default(1);
|
|
73658
|
+
let tightest = null;
|
|
73659
|
+
for (const window of ["hourly", "daily"]) {
|
|
73660
|
+
const remainingNative = computeRateLimitWindowRemainingCapacity(
|
|
73661
|
+
bank.rateLimiter[window],
|
|
73662
|
+
nowSeconds
|
|
73663
|
+
);
|
|
73664
|
+
if (!remainingNative) continue;
|
|
73665
|
+
const remaining = BigNumber3__default.default.max(0, nativeToUi(remainingNative, bank.mintDecimals)).times(
|
|
73666
|
+
limiterToUnderlying
|
|
73667
|
+
);
|
|
73668
|
+
if (!tightest || remaining.lt(tightest.remaining)) tightest = { window, remaining };
|
|
73616
73669
|
}
|
|
73617
|
-
|
|
73670
|
+
return tightest;
|
|
73671
|
+
}
|
|
73672
|
+
function computeOutflowRateLimitRemaining(bank, oraclePrice, groupRateLimiter, assetShareValueMultiplier) {
|
|
73673
|
+
let remaining = computeBankOutflowRateLimit(bank, assetShareValueMultiplier)?.remaining ?? new BigNumber3__default.default(Infinity);
|
|
73674
|
+
const groupRemainingUsd = computeGroupRateLimitRemainingUsd(groupRateLimiter);
|
|
73618
73675
|
if (groupRemainingUsd !== null) {
|
|
73619
73676
|
const price = getPrice(oraclePrice, 1 /* None */, false);
|
|
73620
73677
|
if (price.gt(0)) remaining = BigNumber3__default.default.min(remaining, groupRemainingUsd.div(price));
|
|
@@ -78235,7 +78292,9 @@ function generateDummyAccount(group, authority, accountKey) {
|
|
|
78235
78292
|
mrgnErr: 0
|
|
78236
78293
|
},
|
|
78237
78294
|
emissionsDestinationAccount: new web3_js.PublicKey("11111111111111111111111111111111"),
|
|
78238
|
-
accountFlags: new BN8__default.default([0, 0, 0])
|
|
78295
|
+
accountFlags: new BN8__default.default([0, 0, 0]),
|
|
78296
|
+
activeOrders: 0
|
|
78297
|
+
};
|
|
78239
78298
|
return parseMarginfiAccountRaw(accountKey, rawAccount);
|
|
78240
78299
|
}
|
|
78241
78300
|
|
|
@@ -78346,7 +78405,7 @@ var HealthCache = class _HealthCache {
|
|
|
78346
78405
|
|
|
78347
78406
|
// src/models/account.ts
|
|
78348
78407
|
var MarginfiAccount = class _MarginfiAccount {
|
|
78349
|
-
constructor(address, group, authority, balances, accountFlags, emissionsDestinationAccount, healthCache) {
|
|
78408
|
+
constructor(address, group, authority, balances, accountFlags, emissionsDestinationAccount, healthCache, activeOrders = 0) {
|
|
78350
78409
|
this.address = address;
|
|
78351
78410
|
this.group = group;
|
|
78352
78411
|
this.authority = authority;
|
|
@@ -78354,6 +78413,7 @@ var MarginfiAccount = class _MarginfiAccount {
|
|
|
78354
78413
|
this.accountFlags = accountFlags;
|
|
78355
78414
|
this.emissionsDestinationAccount = emissionsDestinationAccount;
|
|
78356
78415
|
this.healthCache = healthCache;
|
|
78416
|
+
this.activeOrders = activeOrders;
|
|
78357
78417
|
}
|
|
78358
78418
|
/**
|
|
78359
78419
|
* Fetches a marginfi account from on-chain data.
|
|
@@ -78378,7 +78438,8 @@ var MarginfiAccount = class _MarginfiAccount {
|
|
|
78378
78438
|
account.balances.map((b) => Balance.fromBalanceType(b)),
|
|
78379
78439
|
account.accountFlags,
|
|
78380
78440
|
account.emissionsDestinationAccount,
|
|
78381
|
-
account.healthCache
|
|
78441
|
+
account.healthCache,
|
|
78442
|
+
account.activeOrders
|
|
78382
78443
|
);
|
|
78383
78444
|
}
|
|
78384
78445
|
/**
|
|
@@ -78398,7 +78459,8 @@ var MarginfiAccount = class _MarginfiAccount {
|
|
|
78398
78459
|
props.balances.map((b) => Balance.fromBalanceType(b)),
|
|
78399
78460
|
props.accountFlags,
|
|
78400
78461
|
props.emissionsDestinationAccount,
|
|
78401
|
-
HealthCache.fromHealthCacheType(props.healthCache)
|
|
78462
|
+
HealthCache.fromHealthCacheType(props.healthCache),
|
|
78463
|
+
props.activeOrders
|
|
78402
78464
|
);
|
|
78403
78465
|
}
|
|
78404
78466
|
/**
|
|
@@ -79253,6 +79315,14 @@ var MarginfiAccount = class _MarginfiAccount {
|
|
|
79253
79315
|
async makePlaceOrderTx(params) {
|
|
79254
79316
|
return makePlaceOrderTx({ ...params, marginfiAccount: this });
|
|
79255
79317
|
}
|
|
79318
|
+
/**
|
|
79319
|
+
* Creates a close-order instruction for this marginfi account.
|
|
79320
|
+
*
|
|
79321
|
+
* @see {@link makeCloseOrderIx} for detailed implementation
|
|
79322
|
+
*/
|
|
79323
|
+
async makeCloseOrderIx(params) {
|
|
79324
|
+
return makeCloseOrderIx2({ ...params, marginfiAccount: this });
|
|
79325
|
+
}
|
|
79256
79326
|
/**
|
|
79257
79327
|
* Creates a transaction closing an existing order.
|
|
79258
79328
|
*
|
|
@@ -79426,7 +79496,8 @@ function projectAccountAfterFirstLeg(account, firstLegFlashloanTxs, program, ban
|
|
|
79426
79496
|
projectedBalances.map((b) => Balance.fromBalanceType(b)),
|
|
79427
79497
|
account.accountFlags,
|
|
79428
79498
|
account.emissionsDestinationAccount,
|
|
79429
|
-
account.healthCache
|
|
79499
|
+
account.healthCache,
|
|
79500
|
+
account.activeOrders
|
|
79430
79501
|
);
|
|
79431
79502
|
}
|
|
79432
79503
|
function composeBundle(firstLegTxs, secondLegTxs, payer, blockhash, maxBundleTxs) {
|
|
@@ -81832,10 +81903,21 @@ async function makeBulkRepayTx(params) {
|
|
|
81832
81903
|
function buildOrderTrigger(params) {
|
|
81833
81904
|
const { stopLossUsd, takeProfitUsd } = params;
|
|
81834
81905
|
const maxSlippage = percentToMaxSlippageU32(params.maxSlippagePercent);
|
|
81906
|
+
const invalidTrigger = (reason) => TransactionBuildingError.orderInvalidTrigger(
|
|
81907
|
+
reason,
|
|
81908
|
+
takeProfitUsd?.toString(),
|
|
81909
|
+
stopLossUsd?.toString()
|
|
81910
|
+
);
|
|
81911
|
+
if (stopLossUsd && !stopLossUsd.gt(0)) {
|
|
81912
|
+
throw invalidTrigger(`stop-loss threshold (${stopLossUsd}) must be above 0`);
|
|
81913
|
+
}
|
|
81914
|
+
if (takeProfitUsd && !takeProfitUsd.gt(0)) {
|
|
81915
|
+
throw invalidTrigger(`take-profit threshold (${takeProfitUsd}) must be above 0`);
|
|
81916
|
+
}
|
|
81835
81917
|
if (stopLossUsd && takeProfitUsd) {
|
|
81836
81918
|
if (takeProfitUsd.lte(stopLossUsd)) {
|
|
81837
|
-
throw
|
|
81838
|
-
`
|
|
81919
|
+
throw invalidTrigger(
|
|
81920
|
+
`take-profit threshold (${takeProfitUsd}) must be above stop-loss threshold (${stopLossUsd})`
|
|
81839
81921
|
);
|
|
81840
81922
|
}
|
|
81841
81923
|
return {
|
|
@@ -81852,7 +81934,7 @@ function buildOrderTrigger(params) {
|
|
|
81852
81934
|
if (takeProfitUsd) {
|
|
81853
81935
|
return { takeProfit: { threshold: bigNumberToWrappedI80F48(takeProfitUsd), maxSlippage } };
|
|
81854
81936
|
}
|
|
81855
|
-
throw
|
|
81937
|
+
throw invalidTrigger("an order needs a stop-loss threshold, a take-profit threshold, or both");
|
|
81856
81938
|
}
|
|
81857
81939
|
async function makePlaceOrderIx2(params) {
|
|
81858
81940
|
const { program, marginfiAccount, collateralBank, debtBank, trigger, feePayer } = params;
|
|
@@ -84786,6 +84868,29 @@ var MarginfiAccountWrapper = class {
|
|
|
84786
84868
|
// ----------------------------------------------------------------------------
|
|
84787
84869
|
// Orders (take-profit / stop-loss)
|
|
84788
84870
|
// ----------------------------------------------------------------------------
|
|
84871
|
+
/**
|
|
84872
|
+
* Creates a place-order instruction, for composing into a larger transaction.
|
|
84873
|
+
*
|
|
84874
|
+
* @param collateralBank - Bank of the asset-side balance
|
|
84875
|
+
* @param debtBank - Bank of the liability-side balance
|
|
84876
|
+
* @param trigger - USD pair-equity thresholds and max slippage
|
|
84877
|
+
*/
|
|
84878
|
+
async makePlaceOrderIx(collateralBank, debtBank, trigger) {
|
|
84879
|
+
return this.account.makePlaceOrderIx({
|
|
84880
|
+
program: this.client.program,
|
|
84881
|
+
collateralBank,
|
|
84882
|
+
debtBank,
|
|
84883
|
+
trigger
|
|
84884
|
+
});
|
|
84885
|
+
}
|
|
84886
|
+
/**
|
|
84887
|
+
* Creates a close-order instruction, for composing into a larger transaction.
|
|
84888
|
+
*
|
|
84889
|
+
* @param order - The order PDA (from `fetchOrdersForAccount` or `deriveOrderPda`)
|
|
84890
|
+
*/
|
|
84891
|
+
async makeCloseOrderIx(order) {
|
|
84892
|
+
return this.account.makeCloseOrderIx({ program: this.client.program, order });
|
|
84893
|
+
}
|
|
84789
84894
|
/**
|
|
84790
84895
|
* Creates a transaction placing a take-profit / stop-loss order on a collateral/debt pair.
|
|
84791
84896
|
*
|
|
@@ -85646,6 +85751,7 @@ exports.computeBankBorrowApy = computeBankBorrowApy;
|
|
|
85646
85751
|
exports.computeBankBorrowCapRemaining = computeBankBorrowCapRemaining;
|
|
85647
85752
|
exports.computeBankDepositCapRemaining = computeBankDepositCapRemaining;
|
|
85648
85753
|
exports.computeBankMetrics = computeBankMetrics;
|
|
85754
|
+
exports.computeBankOutflowRateLimit = computeBankOutflowRateLimit;
|
|
85649
85755
|
exports.computeBankPoolSize = computeBankPoolSize;
|
|
85650
85756
|
exports.computeBankProjectedAvailableLiquidity = computeBankProjectedAvailableLiquidity;
|
|
85651
85757
|
exports.computeBankRateLimitRemaining = computeBankRateLimitRemaining;
|
|
@@ -85682,6 +85788,7 @@ exports.computeMaxWithdrawForBank = computeMaxWithdrawForBank;
|
|
|
85682
85788
|
exports.computeNetApy = computeNetApy;
|
|
85683
85789
|
exports.computeOracleMultiplier = computeOracleMultiplier;
|
|
85684
85790
|
exports.computeOracleMultipliers = computeOracleMultipliers;
|
|
85791
|
+
exports.computeOrderPairNetValue = computeOrderPairNetValue;
|
|
85685
85792
|
exports.computeProjectedActiveBalancesNoCpi = computeProjectedActiveBalancesNoCpi;
|
|
85686
85793
|
exports.computeProjectedActiveBanksNoCpi = computeProjectedActiveBanksNoCpi;
|
|
85687
85794
|
exports.computePtMultiplier = computePtMultiplier;
|
|
@@ -85756,7 +85863,7 @@ exports.fetchOracleData = fetchOracleData;
|
|
|
85756
85863
|
exports.fetchOracleMultipliers = fetchOracleMultipliers;
|
|
85757
85864
|
exports.fetchOracleMultipliersFromAPI = fetchOracleMultipliersFromAPI;
|
|
85758
85865
|
exports.fetchOracleMultipliersFromChain = fetchOracleMultipliersFromChain;
|
|
85759
|
-
exports.
|
|
85866
|
+
exports.fetchOrderFees = fetchOrderFees;
|
|
85760
85867
|
exports.fetchOrdersForAccount = fetchOrdersForAccount;
|
|
85761
85868
|
exports.fetchProgramForMints = fetchProgramForMints;
|
|
85762
85869
|
exports.fetchPythOracleData = fetchPythOracleData;
|
|
@@ -85946,7 +86053,7 @@ exports.requireBank = requireBank;
|
|
|
85946
86053
|
exports.requireTokenProgram = requireTokenProgram;
|
|
85947
86054
|
exports.resolveAmount = resolveAmount;
|
|
85948
86055
|
exports.resolveBridgeCandidateBanks = resolveBridgeCandidateBanks;
|
|
85949
|
-
exports.
|
|
86056
|
+
exports.resolveOrderLegs = resolveOrderLegs;
|
|
85950
86057
|
exports.resolvePinnedSwapRoute = resolvePinnedSwapRoute;
|
|
85951
86058
|
exports.resolveTokenProgramForMint = resolveTokenProgramForMint;
|
|
85952
86059
|
exports.resolveVaultTokenProgram = resolveVaultTokenProgram;
|