@0dotxyz/p0-ts-sdk 2.2.0-beta.2 → 2.2.0-beta.3
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 +13 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -5
- package/dist/index.d.ts +1 -5
- package/dist/index.js +14 -32
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -386,7 +386,6 @@ var MAX_U64 = BigInt("18446744073709551615").toString();
|
|
|
386
386
|
|
|
387
387
|
// src/constants/transaction.consts.ts
|
|
388
388
|
var MAX_TX_SIZE = 1232;
|
|
389
|
-
var MAX_WRITABLE_ACCOUNTS = 64;
|
|
390
389
|
var MAX_ACCOUNT_LOCKS = 64;
|
|
391
390
|
var BUNDLE_TX_SIZE = 81;
|
|
392
391
|
var PRIORITY_TX_SIZE = 44;
|
|
@@ -46952,7 +46951,6 @@ async function buildRepayWithCollatFlashloanTx({
|
|
|
46952
46951
|
destinationTokenAccount,
|
|
46953
46952
|
swapOpts,
|
|
46954
46953
|
sizeConstraint: swapConstraints.sizeConstraint,
|
|
46955
|
-
maxSwapAccounts: swapConstraints.maxSwapWritableAccounts,
|
|
46956
46954
|
maxSwapTotalAccounts: swapConstraints.maxSwapTotalAccounts
|
|
46957
46955
|
});
|
|
46958
46956
|
sizeConstraintUsed = swapConstraints.sizeConstraint;
|
|
@@ -47151,12 +47149,11 @@ async function buildRepayWithCollatFlashloanTx({
|
|
|
47151
47149
|
isSync: true
|
|
47152
47150
|
});
|
|
47153
47151
|
const txSize = getTxSize(flashloanTx);
|
|
47154
|
-
const writableKeys = getWritableAccountKeys(flashloanTx);
|
|
47155
47152
|
const totalKeys = getTotalAccountKeys(flashloanTx);
|
|
47156
|
-
if (txSize > MAX_TX_SIZE ||
|
|
47153
|
+
if (txSize > MAX_TX_SIZE || totalKeys > MAX_ACCOUNT_LOCKS) {
|
|
47157
47154
|
throw TransactionBuildingError.swapSizeExceededRepay(
|
|
47158
47155
|
txSize,
|
|
47159
|
-
|
|
47156
|
+
totalKeys,
|
|
47160
47157
|
swapOpts.swapConfig?.provider
|
|
47161
47158
|
);
|
|
47162
47159
|
}
|
|
@@ -47301,26 +47298,20 @@ function computeFlashLoanNonSwapBudget({
|
|
|
47301
47298
|
}).compileToV0Message(addressLookupTableAccounts);
|
|
47302
47299
|
const nonSwapSize = new web3_js.VersionedTransaction(nonSwapMsg).serialize().length;
|
|
47303
47300
|
const { header, staticAccountKeys, addressTableLookups } = nonSwapMsg;
|
|
47304
|
-
const writableStatic = staticAccountKeys.length - header.numReadonlySignedAccounts - header.numReadonlyUnsignedAccounts;
|
|
47305
|
-
const writableLut = addressTableLookups.reduce((s, l) => s + l.writableIndexes.length, 0);
|
|
47306
|
-
const nonSwapWritable = writableStatic + writableLut;
|
|
47307
47301
|
const nonSwapTotal = staticAccountKeys.length + addressTableLookups.reduce(
|
|
47308
47302
|
(s, l) => s + l.writableIndexes.length + l.readonlyIndexes.length,
|
|
47309
47303
|
0
|
|
47310
47304
|
);
|
|
47311
47305
|
const sizeConstraint = MAX_TX_SIZE - nonSwapSize - SWAP_MERGE_OVERHEAD;
|
|
47312
|
-
const maxSwapWritableAccounts = MAX_WRITABLE_ACCOUNTS - nonSwapWritable;
|
|
47313
47306
|
const maxSwapTotalAccounts = MAX_ACCOUNT_LOCKS - nonSwapTotal;
|
|
47314
47307
|
console.log("[flashloan-budget]", {
|
|
47315
47308
|
method: "compiled",
|
|
47316
47309
|
nonSwapSize,
|
|
47317
|
-
nonSwapWritable,
|
|
47318
47310
|
nonSwapTotal,
|
|
47319
47311
|
sizeConstraint,
|
|
47320
|
-
maxSwapWritableAccounts,
|
|
47321
47312
|
maxSwapTotalAccounts
|
|
47322
47313
|
});
|
|
47323
|
-
return { sizeConstraint,
|
|
47314
|
+
return { sizeConstraint, maxSwapTotalAccounts };
|
|
47324
47315
|
}
|
|
47325
47316
|
function compileFlashloanPrecheck({
|
|
47326
47317
|
allIxs,
|
|
@@ -47892,7 +47883,6 @@ async function buildLoopFlashloanTx({
|
|
|
47892
47883
|
destinationTokenAccount,
|
|
47893
47884
|
swapOpts,
|
|
47894
47885
|
sizeConstraint: swapConstraints.sizeConstraint,
|
|
47895
|
-
maxSwapAccounts: swapConstraints.maxSwapWritableAccounts,
|
|
47896
47886
|
maxSwapTotalAccounts: swapConstraints.maxSwapTotalAccounts
|
|
47897
47887
|
});
|
|
47898
47888
|
sizeConstraintUsed = swapConstraints.sizeConstraint;
|
|
@@ -48035,12 +48025,11 @@ async function buildLoopFlashloanTx({
|
|
|
48035
48025
|
ixs: allNonFlIxs
|
|
48036
48026
|
});
|
|
48037
48027
|
const txSize = getTxSize(flashloanTx);
|
|
48038
|
-
const writableKeys = getWritableAccountKeys(flashloanTx);
|
|
48039
48028
|
const totalKeys = getTotalAccountKeys(flashloanTx);
|
|
48040
|
-
if (txSize > MAX_TX_SIZE ||
|
|
48029
|
+
if (txSize > MAX_TX_SIZE || totalKeys > MAX_ACCOUNT_LOCKS) {
|
|
48041
48030
|
throw TransactionBuildingError.swapSizeExceededLoop(
|
|
48042
48031
|
txSize,
|
|
48043
|
-
|
|
48032
|
+
totalKeys,
|
|
48044
48033
|
swapOpts.swapConfig?.provider
|
|
48045
48034
|
);
|
|
48046
48035
|
}
|
|
@@ -48352,7 +48341,6 @@ async function buildSwapCollateralFlashloanTx({
|
|
|
48352
48341
|
destinationTokenAccount,
|
|
48353
48342
|
swapOpts,
|
|
48354
48343
|
sizeConstraint: swapConstraints.sizeConstraint,
|
|
48355
|
-
maxSwapAccounts: swapConstraints.maxSwapWritableAccounts,
|
|
48356
48344
|
maxSwapTotalAccounts: swapConstraints.maxSwapTotalAccounts
|
|
48357
48345
|
});
|
|
48358
48346
|
sizeConstraintUsed = swapConstraints.sizeConstraint;
|
|
@@ -48480,12 +48468,11 @@ async function buildSwapCollateralFlashloanTx({
|
|
|
48480
48468
|
isSync: true
|
|
48481
48469
|
});
|
|
48482
48470
|
const txSize = getTxSize(flashloanTx);
|
|
48483
|
-
const writableKeys = getWritableAccountKeys(flashloanTx);
|
|
48484
48471
|
const totalKeys = getTotalAccountKeys(flashloanTx);
|
|
48485
|
-
if (txSize > MAX_TX_SIZE ||
|
|
48472
|
+
if (txSize > MAX_TX_SIZE || totalKeys > MAX_ACCOUNT_LOCKS) {
|
|
48486
48473
|
throw TransactionBuildingError.swapSizeExceededLoop(
|
|
48487
48474
|
txSize,
|
|
48488
|
-
|
|
48475
|
+
totalKeys,
|
|
48489
48476
|
swapOpts.swapConfig?.provider
|
|
48490
48477
|
);
|
|
48491
48478
|
}
|
|
@@ -48671,7 +48658,6 @@ async function buildSwapDebtFlashloanTx({
|
|
|
48671
48658
|
destinationTokenAccount,
|
|
48672
48659
|
swapOpts,
|
|
48673
48660
|
sizeConstraint: swapConstraints.sizeConstraint,
|
|
48674
|
-
maxSwapAccounts: swapConstraints.maxSwapWritableAccounts,
|
|
48675
48661
|
maxSwapTotalAccounts: swapConstraints.maxSwapTotalAccounts
|
|
48676
48662
|
});
|
|
48677
48663
|
const { quoteResponse } = swapResponses;
|
|
@@ -48743,12 +48729,11 @@ async function buildSwapDebtFlashloanTx({
|
|
|
48743
48729
|
isSync: true
|
|
48744
48730
|
});
|
|
48745
48731
|
const txSize = getTxSize(flashloanTx);
|
|
48746
|
-
const writableKeys = getWritableAccountKeys(flashloanTx);
|
|
48747
48732
|
const totalKeys = getTotalAccountKeys(flashloanTx);
|
|
48748
|
-
if (txSize > MAX_TX_SIZE ||
|
|
48733
|
+
if (txSize > MAX_TX_SIZE || totalKeys > MAX_ACCOUNT_LOCKS) {
|
|
48749
48734
|
throw TransactionBuildingError.swapSizeExceededLoop(
|
|
48750
48735
|
txSize,
|
|
48751
|
-
|
|
48736
|
+
totalKeys,
|
|
48752
48737
|
swapOpts.swapConfig?.provider
|
|
48753
48738
|
);
|
|
48754
48739
|
}
|
|
@@ -49695,8 +49680,7 @@ function getSwapProviderFn({
|
|
|
49695
49680
|
connection,
|
|
49696
49681
|
destinationTokenAccount,
|
|
49697
49682
|
swapOpts,
|
|
49698
|
-
sizeConstraint
|
|
49699
|
-
maxSwapAccounts
|
|
49683
|
+
sizeConstraint
|
|
49700
49684
|
}) {
|
|
49701
49685
|
switch (attemptProvider) {
|
|
49702
49686
|
case "TITAN" /* TITAN */:
|
|
@@ -49710,7 +49694,6 @@ function getSwapProviderFn({
|
|
|
49710
49694
|
platformFeeBps: swapOpts.swapConfig?.platformFeeBps,
|
|
49711
49695
|
directRoutesOnly: swapOpts.swapConfig?.directRoutesOnly,
|
|
49712
49696
|
sizeConstraint,
|
|
49713
|
-
maxSwapAccounts,
|
|
49714
49697
|
maxSwapTotalAccounts
|
|
49715
49698
|
},
|
|
49716
49699
|
authority,
|
|
@@ -49734,7 +49717,7 @@ function getSwapProviderFn({
|
|
|
49734
49717
|
connection,
|
|
49735
49718
|
destinationTokenAccount,
|
|
49736
49719
|
apiConfig,
|
|
49737
|
-
maxSwapAccounts
|
|
49720
|
+
maxSwapAccounts: maxSwapTotalAccounts
|
|
49738
49721
|
});
|
|
49739
49722
|
default:
|
|
49740
49723
|
return void 0;
|
|
@@ -49787,7 +49770,7 @@ var getSwapIxsForFlashloan = async (params) => {
|
|
|
49787
49770
|
destinationTokenAccount,
|
|
49788
49771
|
swapOpts,
|
|
49789
49772
|
sizeConstraint,
|
|
49790
|
-
|
|
49773
|
+
maxSwapTotalAccounts
|
|
49791
49774
|
} = params;
|
|
49792
49775
|
if (swapOpts.swapIxs) {
|
|
49793
49776
|
return {
|
|
@@ -49820,8 +49803,7 @@ var getSwapIxsForFlashloan = async (params) => {
|
|
|
49820
49803
|
connection,
|
|
49821
49804
|
destinationTokenAccount,
|
|
49822
49805
|
swapOpts,
|
|
49823
|
-
sizeConstraint
|
|
49824
|
-
maxSwapAccounts
|
|
49806
|
+
sizeConstraint
|
|
49825
49807
|
});
|
|
49826
49808
|
if (!fn) continue;
|
|
49827
49809
|
try {
|
|
@@ -54670,7 +54652,6 @@ exports.MAX_ACCOUNT_LOCKS = MAX_ACCOUNT_LOCKS;
|
|
|
54670
54652
|
exports.MAX_CONFIDENCE_INTERVAL_RATIO = MAX_CONFIDENCE_INTERVAL_RATIO;
|
|
54671
54653
|
exports.MAX_TX_SIZE = MAX_TX_SIZE;
|
|
54672
54654
|
exports.MAX_U64 = MAX_U64;
|
|
54673
|
-
exports.MAX_WRITABLE_ACCOUNTS = MAX_WRITABLE_ACCOUNTS;
|
|
54674
54655
|
exports.MPL_METADATA_PROGRAM_ID = MPL_METADATA_PROGRAM_ID;
|
|
54675
54656
|
exports.MarginRequirementType = MarginRequirementType;
|
|
54676
54657
|
exports.MarginfiAccount = MarginfiAccount;
|