@meteora-ag/zap-sdk 1.2.0-rc.5 → 1.2.0-rc.7
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.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +121 -8
- package/dist/index.mjs +121 -8
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1716,6 +1716,7 @@ type GetZapInDammV2IndirectPoolParams = {
|
|
|
1716
1716
|
slippageBps: number;
|
|
1717
1717
|
jupiterQuoteToA: JupiterQuoteResponse | null;
|
|
1718
1718
|
jupiterQuoteToB: JupiterQuoteResponse | null;
|
|
1719
|
+
forceTwoSidedWhenBothQuotes?: boolean;
|
|
1719
1720
|
};
|
|
1720
1721
|
declare enum ZapInDammV2PoolSwapRoute {
|
|
1721
1722
|
Jupiter = "jupiter",
|
|
@@ -2020,6 +2021,7 @@ declare class Zap {
|
|
|
2020
2021
|
private zapInDammV2;
|
|
2021
2022
|
private resetOrInitializeLedgerAccount;
|
|
2022
2023
|
private isJupiterQuoteableAmount;
|
|
2024
|
+
private getJupiterQuoteForAmount;
|
|
2023
2025
|
private findMinimumJupiterQuoteableAmount;
|
|
2024
2026
|
private zapInDlmmForInitializedPosition;
|
|
2025
2027
|
private zapInDlmmForUninitializedPosition;
|
package/dist/index.d.ts
CHANGED
|
@@ -1716,6 +1716,7 @@ type GetZapInDammV2IndirectPoolParams = {
|
|
|
1716
1716
|
slippageBps: number;
|
|
1717
1717
|
jupiterQuoteToA: JupiterQuoteResponse | null;
|
|
1718
1718
|
jupiterQuoteToB: JupiterQuoteResponse | null;
|
|
1719
|
+
forceTwoSidedWhenBothQuotes?: boolean;
|
|
1719
1720
|
};
|
|
1720
1721
|
declare enum ZapInDammV2PoolSwapRoute {
|
|
1721
1722
|
Jupiter = "jupiter",
|
|
@@ -2020,6 +2021,7 @@ declare class Zap {
|
|
|
2020
2021
|
private zapInDammV2;
|
|
2021
2022
|
private resetOrInitializeLedgerAccount;
|
|
2022
2023
|
private isJupiterQuoteableAmount;
|
|
2024
|
+
private getJupiterQuoteForAmount;
|
|
2023
2025
|
private findMinimumJupiterQuoteableAmount;
|
|
2024
2026
|
private zapInDlmmForInitializedPosition;
|
|
2025
2027
|
private zapInDlmmForUninitializedPosition;
|
package/dist/index.js
CHANGED
|
@@ -3354,6 +3354,27 @@ var Zap = class {
|
|
|
3354
3354
|
return quote !== null;
|
|
3355
3355
|
});
|
|
3356
3356
|
}
|
|
3357
|
+
getJupiterQuoteForAmount(inputMint, outputMint, amount, maxAccounts, slippageBps) {
|
|
3358
|
+
return __async(this, null, function* () {
|
|
3359
|
+
if (amount.isZero()) {
|
|
3360
|
+
return null;
|
|
3361
|
+
}
|
|
3362
|
+
return yield getJupiterQuote(
|
|
3363
|
+
inputMint,
|
|
3364
|
+
outputMint,
|
|
3365
|
+
amount,
|
|
3366
|
+
maxAccounts,
|
|
3367
|
+
slippageBps,
|
|
3368
|
+
false,
|
|
3369
|
+
true,
|
|
3370
|
+
true,
|
|
3371
|
+
{
|
|
3372
|
+
jupiterApiUrl: this.jupiterApiUrl,
|
|
3373
|
+
jupiterApiKey: this.jupiterApiKey
|
|
3374
|
+
}
|
|
3375
|
+
);
|
|
3376
|
+
});
|
|
3377
|
+
}
|
|
3357
3378
|
findMinimumJupiterQuoteableAmount(inputMint, outputMint, maxAmount, maxAccounts, slippageBps) {
|
|
3358
3379
|
return __async(this, null, function* () {
|
|
3359
3380
|
if (maxAmount.isZero()) {
|
|
@@ -3369,9 +3390,45 @@ var Zap = class {
|
|
|
3369
3390
|
if (!maxAmountQuoteable) {
|
|
3370
3391
|
return null;
|
|
3371
3392
|
}
|
|
3372
|
-
|
|
3393
|
+
const defaultLowerBound = inputMint.equals(import_spl_token6.NATIVE_MINT) ? new import_anchor.BN(100) : new import_anchor.BN(1);
|
|
3394
|
+
let left = defaultLowerBound.gt(maxAmount) ? maxAmount : defaultLowerBound;
|
|
3373
3395
|
let right = maxAmount;
|
|
3374
3396
|
let best = maxAmount;
|
|
3397
|
+
const leftIsQuoteable = yield this.isJupiterQuoteableAmount(
|
|
3398
|
+
inputMint,
|
|
3399
|
+
outputMint,
|
|
3400
|
+
left,
|
|
3401
|
+
maxAccounts,
|
|
3402
|
+
slippageBps
|
|
3403
|
+
);
|
|
3404
|
+
if (!leftIsQuoteable) {
|
|
3405
|
+
let probe = left;
|
|
3406
|
+
let found = false;
|
|
3407
|
+
while (probe.lt(maxAmount)) {
|
|
3408
|
+
const nextProbe = import_anchor.BN.min(probe.mul(new import_anchor.BN(2)), maxAmount);
|
|
3409
|
+
const nextIsQuoteable = yield this.isJupiterQuoteableAmount(
|
|
3410
|
+
inputMint,
|
|
3411
|
+
outputMint,
|
|
3412
|
+
nextProbe,
|
|
3413
|
+
maxAccounts,
|
|
3414
|
+
slippageBps
|
|
3415
|
+
);
|
|
3416
|
+
if (nextIsQuoteable) {
|
|
3417
|
+
left = probe.add(new import_anchor.BN(1));
|
|
3418
|
+
right = nextProbe;
|
|
3419
|
+
best = nextProbe;
|
|
3420
|
+
found = true;
|
|
3421
|
+
break;
|
|
3422
|
+
}
|
|
3423
|
+
probe = nextProbe;
|
|
3424
|
+
}
|
|
3425
|
+
if (!found) {
|
|
3426
|
+
return null;
|
|
3427
|
+
}
|
|
3428
|
+
} else {
|
|
3429
|
+
best = left;
|
|
3430
|
+
right = left;
|
|
3431
|
+
}
|
|
3375
3432
|
while (left.lte(right)) {
|
|
3376
3433
|
const mid = left.add(right).div(new import_anchor.BN(2));
|
|
3377
3434
|
const isQuoteable = yield this.isJupiterQuoteableAmount(
|
|
@@ -3757,7 +3814,8 @@ var Zap = class {
|
|
|
3757
3814
|
maxTransferAmountExtendPercentage,
|
|
3758
3815
|
slippageBps,
|
|
3759
3816
|
jupiterQuoteToA,
|
|
3760
|
-
jupiterQuoteToB
|
|
3817
|
+
jupiterQuoteToB,
|
|
3818
|
+
forceTwoSidedWhenBothQuotes = false
|
|
3761
3819
|
} = params;
|
|
3762
3820
|
const poolState = yield getDammV2Pool(this.connection, pool);
|
|
3763
3821
|
const {
|
|
@@ -3942,6 +4000,32 @@ var Zap = class {
|
|
|
3942
4000
|
)
|
|
3943
4001
|
);
|
|
3944
4002
|
let { swapAmountToA: adjustedSwapAmountToA, swapAmountToB } = splitIndirectSwapAmounts(amountIn, swapAmountToA);
|
|
4003
|
+
if (forceTwoSidedWhenBothQuotes && adjustedSwapAmountToA.isZero()) {
|
|
4004
|
+
const minQuoteableToA = yield this.findMinimumJupiterQuoteableAmount(
|
|
4005
|
+
inputTokenMint,
|
|
4006
|
+
tokenAMint,
|
|
4007
|
+
amountIn,
|
|
4008
|
+
maxAccounts,
|
|
4009
|
+
slippageBps
|
|
4010
|
+
);
|
|
4011
|
+
if (minQuoteableToA !== null && minQuoteableToA.gt(new import_anchor.BN(0)) && minQuoteableToA.lt(amountIn)) {
|
|
4012
|
+
adjustedSwapAmountToA = minQuoteableToA;
|
|
4013
|
+
swapAmountToB = amountIn.sub(adjustedSwapAmountToA);
|
|
4014
|
+
}
|
|
4015
|
+
}
|
|
4016
|
+
if (forceTwoSidedWhenBothQuotes && swapAmountToB.isZero()) {
|
|
4017
|
+
const minQuoteableToB = yield this.findMinimumJupiterQuoteableAmount(
|
|
4018
|
+
inputTokenMint,
|
|
4019
|
+
tokenBMint,
|
|
4020
|
+
amountIn,
|
|
4021
|
+
maxAccounts,
|
|
4022
|
+
slippageBps
|
|
4023
|
+
);
|
|
4024
|
+
if (minQuoteableToB !== null && minQuoteableToB.gt(new import_anchor.BN(0)) && minQuoteableToB.lt(amountIn)) {
|
|
4025
|
+
swapAmountToB = minQuoteableToB;
|
|
4026
|
+
adjustedSwapAmountToA = amountIn.sub(swapAmountToB);
|
|
4027
|
+
}
|
|
4028
|
+
}
|
|
3945
4029
|
const quoteableA = yield this.isJupiterQuoteableAmount(
|
|
3946
4030
|
inputTokenMint,
|
|
3947
4031
|
tokenAMint,
|
|
@@ -3997,7 +4081,26 @@ var Zap = class {
|
|
|
3997
4081
|
"Calculated zero swap amount for both token routes, unable to proceed"
|
|
3998
4082
|
);
|
|
3999
4083
|
}
|
|
4000
|
-
|
|
4084
|
+
const quoteToAForSwap = yield this.getJupiterQuoteForAmount(
|
|
4085
|
+
inputTokenMint,
|
|
4086
|
+
tokenAMint,
|
|
4087
|
+
adjustedSwapAmountToA,
|
|
4088
|
+
maxAccounts,
|
|
4089
|
+
slippageBps
|
|
4090
|
+
);
|
|
4091
|
+
const quoteToBForSwap = yield this.getJupiterQuoteForAmount(
|
|
4092
|
+
inputTokenMint,
|
|
4093
|
+
tokenBMint,
|
|
4094
|
+
swapAmountToB,
|
|
4095
|
+
maxAccounts,
|
|
4096
|
+
slippageBps
|
|
4097
|
+
);
|
|
4098
|
+
if (!hasSwapToA || quoteToAForSwap === null) {
|
|
4099
|
+
if (quoteToBForSwap === null) {
|
|
4100
|
+
throw new Error(
|
|
4101
|
+
`Failed to get Jupiter quote for swap from ${inputTokenMint.toBase58()} to ${tokenBMint.toBase58()}`
|
|
4102
|
+
);
|
|
4103
|
+
}
|
|
4001
4104
|
const { transaction: swapToBTransaction2, quoteResponse: swapToBQuote2 } = yield buildJupiterSwapTransaction(
|
|
4002
4105
|
user,
|
|
4003
4106
|
inputTokenMint,
|
|
@@ -4005,7 +4108,7 @@ var Zap = class {
|
|
|
4005
4108
|
swapAmountToB,
|
|
4006
4109
|
maxAccounts,
|
|
4007
4110
|
slippageBps,
|
|
4008
|
-
|
|
4111
|
+
quoteToBForSwap,
|
|
4009
4112
|
{
|
|
4010
4113
|
jupiterApiUrl: this.jupiterApiUrl,
|
|
4011
4114
|
jupiterApiKey: this.jupiterApiKey
|
|
@@ -4043,7 +4146,12 @@ var Zap = class {
|
|
|
4043
4146
|
}
|
|
4044
4147
|
};
|
|
4045
4148
|
}
|
|
4046
|
-
if (!hasSwapToB) {
|
|
4149
|
+
if (!hasSwapToB || quoteToBForSwap === null) {
|
|
4150
|
+
if (quoteToAForSwap === null) {
|
|
4151
|
+
throw new Error(
|
|
4152
|
+
`Failed to get Jupiter quote for swap from ${inputTokenMint.toBase58()} to ${tokenAMint.toBase58()}`
|
|
4153
|
+
);
|
|
4154
|
+
}
|
|
4047
4155
|
const { transaction: swapToATransaction2, quoteResponse: swapToAQuote2 } = yield buildJupiterSwapTransaction(
|
|
4048
4156
|
user,
|
|
4049
4157
|
inputTokenMint,
|
|
@@ -4051,7 +4159,7 @@ var Zap = class {
|
|
|
4051
4159
|
adjustedSwapAmountToA,
|
|
4052
4160
|
maxAccounts,
|
|
4053
4161
|
slippageBps,
|
|
4054
|
-
|
|
4162
|
+
quoteToAForSwap,
|
|
4055
4163
|
{
|
|
4056
4164
|
jupiterApiUrl: this.jupiterApiUrl,
|
|
4057
4165
|
jupiterApiKey: this.jupiterApiKey
|
|
@@ -4089,6 +4197,11 @@ var Zap = class {
|
|
|
4089
4197
|
}
|
|
4090
4198
|
};
|
|
4091
4199
|
}
|
|
4200
|
+
if (quoteToAForSwap === null || quoteToBForSwap === null) {
|
|
4201
|
+
throw new Error(
|
|
4202
|
+
"Failed to get Jupiter quote for both token routes, unable to proceed"
|
|
4203
|
+
);
|
|
4204
|
+
}
|
|
4092
4205
|
const { transaction: swapToATransaction, quoteResponse: swapToAQuote } = yield buildJupiterSwapTransaction(
|
|
4093
4206
|
user,
|
|
4094
4207
|
inputTokenMint,
|
|
@@ -4096,7 +4209,7 @@ var Zap = class {
|
|
|
4096
4209
|
adjustedSwapAmountToA,
|
|
4097
4210
|
maxAccounts,
|
|
4098
4211
|
slippageBps,
|
|
4099
|
-
|
|
4212
|
+
quoteToAForSwap,
|
|
4100
4213
|
{
|
|
4101
4214
|
jupiterApiUrl: this.jupiterApiUrl,
|
|
4102
4215
|
jupiterApiKey: this.jupiterApiKey
|
|
@@ -4109,7 +4222,7 @@ var Zap = class {
|
|
|
4109
4222
|
swapAmountToB,
|
|
4110
4223
|
maxAccounts,
|
|
4111
4224
|
slippageBps,
|
|
4112
|
-
|
|
4225
|
+
quoteToBForSwap,
|
|
4113
4226
|
{
|
|
4114
4227
|
jupiterApiUrl: this.jupiterApiUrl,
|
|
4115
4228
|
jupiterApiKey: this.jupiterApiKey
|
package/dist/index.mjs
CHANGED
|
@@ -3333,6 +3333,27 @@ var Zap = class {
|
|
|
3333
3333
|
return quote !== null;
|
|
3334
3334
|
});
|
|
3335
3335
|
}
|
|
3336
|
+
getJupiterQuoteForAmount(inputMint, outputMint, amount, maxAccounts, slippageBps) {
|
|
3337
|
+
return __async(this, null, function* () {
|
|
3338
|
+
if (amount.isZero()) {
|
|
3339
|
+
return null;
|
|
3340
|
+
}
|
|
3341
|
+
return yield getJupiterQuote(
|
|
3342
|
+
inputMint,
|
|
3343
|
+
outputMint,
|
|
3344
|
+
amount,
|
|
3345
|
+
maxAccounts,
|
|
3346
|
+
slippageBps,
|
|
3347
|
+
false,
|
|
3348
|
+
true,
|
|
3349
|
+
true,
|
|
3350
|
+
{
|
|
3351
|
+
jupiterApiUrl: this.jupiterApiUrl,
|
|
3352
|
+
jupiterApiKey: this.jupiterApiKey
|
|
3353
|
+
}
|
|
3354
|
+
);
|
|
3355
|
+
});
|
|
3356
|
+
}
|
|
3336
3357
|
findMinimumJupiterQuoteableAmount(inputMint, outputMint, maxAmount, maxAccounts, slippageBps) {
|
|
3337
3358
|
return __async(this, null, function* () {
|
|
3338
3359
|
if (maxAmount.isZero()) {
|
|
@@ -3348,9 +3369,45 @@ var Zap = class {
|
|
|
3348
3369
|
if (!maxAmountQuoteable) {
|
|
3349
3370
|
return null;
|
|
3350
3371
|
}
|
|
3351
|
-
|
|
3372
|
+
const defaultLowerBound = inputMint.equals(NATIVE_MINT3) ? new BN5(100) : new BN5(1);
|
|
3373
|
+
let left = defaultLowerBound.gt(maxAmount) ? maxAmount : defaultLowerBound;
|
|
3352
3374
|
let right = maxAmount;
|
|
3353
3375
|
let best = maxAmount;
|
|
3376
|
+
const leftIsQuoteable = yield this.isJupiterQuoteableAmount(
|
|
3377
|
+
inputMint,
|
|
3378
|
+
outputMint,
|
|
3379
|
+
left,
|
|
3380
|
+
maxAccounts,
|
|
3381
|
+
slippageBps
|
|
3382
|
+
);
|
|
3383
|
+
if (!leftIsQuoteable) {
|
|
3384
|
+
let probe = left;
|
|
3385
|
+
let found = false;
|
|
3386
|
+
while (probe.lt(maxAmount)) {
|
|
3387
|
+
const nextProbe = BN5.min(probe.mul(new BN5(2)), maxAmount);
|
|
3388
|
+
const nextIsQuoteable = yield this.isJupiterQuoteableAmount(
|
|
3389
|
+
inputMint,
|
|
3390
|
+
outputMint,
|
|
3391
|
+
nextProbe,
|
|
3392
|
+
maxAccounts,
|
|
3393
|
+
slippageBps
|
|
3394
|
+
);
|
|
3395
|
+
if (nextIsQuoteable) {
|
|
3396
|
+
left = probe.add(new BN5(1));
|
|
3397
|
+
right = nextProbe;
|
|
3398
|
+
best = nextProbe;
|
|
3399
|
+
found = true;
|
|
3400
|
+
break;
|
|
3401
|
+
}
|
|
3402
|
+
probe = nextProbe;
|
|
3403
|
+
}
|
|
3404
|
+
if (!found) {
|
|
3405
|
+
return null;
|
|
3406
|
+
}
|
|
3407
|
+
} else {
|
|
3408
|
+
best = left;
|
|
3409
|
+
right = left;
|
|
3410
|
+
}
|
|
3354
3411
|
while (left.lte(right)) {
|
|
3355
3412
|
const mid = left.add(right).div(new BN5(2));
|
|
3356
3413
|
const isQuoteable = yield this.isJupiterQuoteableAmount(
|
|
@@ -3736,7 +3793,8 @@ var Zap = class {
|
|
|
3736
3793
|
maxTransferAmountExtendPercentage,
|
|
3737
3794
|
slippageBps,
|
|
3738
3795
|
jupiterQuoteToA,
|
|
3739
|
-
jupiterQuoteToB
|
|
3796
|
+
jupiterQuoteToB,
|
|
3797
|
+
forceTwoSidedWhenBothQuotes = false
|
|
3740
3798
|
} = params;
|
|
3741
3799
|
const poolState = yield getDammV2Pool(this.connection, pool);
|
|
3742
3800
|
const {
|
|
@@ -3921,6 +3979,32 @@ var Zap = class {
|
|
|
3921
3979
|
)
|
|
3922
3980
|
);
|
|
3923
3981
|
let { swapAmountToA: adjustedSwapAmountToA, swapAmountToB } = splitIndirectSwapAmounts(amountIn, swapAmountToA);
|
|
3982
|
+
if (forceTwoSidedWhenBothQuotes && adjustedSwapAmountToA.isZero()) {
|
|
3983
|
+
const minQuoteableToA = yield this.findMinimumJupiterQuoteableAmount(
|
|
3984
|
+
inputTokenMint,
|
|
3985
|
+
tokenAMint,
|
|
3986
|
+
amountIn,
|
|
3987
|
+
maxAccounts,
|
|
3988
|
+
slippageBps
|
|
3989
|
+
);
|
|
3990
|
+
if (minQuoteableToA !== null && minQuoteableToA.gt(new BN5(0)) && minQuoteableToA.lt(amountIn)) {
|
|
3991
|
+
adjustedSwapAmountToA = minQuoteableToA;
|
|
3992
|
+
swapAmountToB = amountIn.sub(adjustedSwapAmountToA);
|
|
3993
|
+
}
|
|
3994
|
+
}
|
|
3995
|
+
if (forceTwoSidedWhenBothQuotes && swapAmountToB.isZero()) {
|
|
3996
|
+
const minQuoteableToB = yield this.findMinimumJupiterQuoteableAmount(
|
|
3997
|
+
inputTokenMint,
|
|
3998
|
+
tokenBMint,
|
|
3999
|
+
amountIn,
|
|
4000
|
+
maxAccounts,
|
|
4001
|
+
slippageBps
|
|
4002
|
+
);
|
|
4003
|
+
if (minQuoteableToB !== null && minQuoteableToB.gt(new BN5(0)) && minQuoteableToB.lt(amountIn)) {
|
|
4004
|
+
swapAmountToB = minQuoteableToB;
|
|
4005
|
+
adjustedSwapAmountToA = amountIn.sub(swapAmountToB);
|
|
4006
|
+
}
|
|
4007
|
+
}
|
|
3924
4008
|
const quoteableA = yield this.isJupiterQuoteableAmount(
|
|
3925
4009
|
inputTokenMint,
|
|
3926
4010
|
tokenAMint,
|
|
@@ -3976,7 +4060,26 @@ var Zap = class {
|
|
|
3976
4060
|
"Calculated zero swap amount for both token routes, unable to proceed"
|
|
3977
4061
|
);
|
|
3978
4062
|
}
|
|
3979
|
-
|
|
4063
|
+
const quoteToAForSwap = yield this.getJupiterQuoteForAmount(
|
|
4064
|
+
inputTokenMint,
|
|
4065
|
+
tokenAMint,
|
|
4066
|
+
adjustedSwapAmountToA,
|
|
4067
|
+
maxAccounts,
|
|
4068
|
+
slippageBps
|
|
4069
|
+
);
|
|
4070
|
+
const quoteToBForSwap = yield this.getJupiterQuoteForAmount(
|
|
4071
|
+
inputTokenMint,
|
|
4072
|
+
tokenBMint,
|
|
4073
|
+
swapAmountToB,
|
|
4074
|
+
maxAccounts,
|
|
4075
|
+
slippageBps
|
|
4076
|
+
);
|
|
4077
|
+
if (!hasSwapToA || quoteToAForSwap === null) {
|
|
4078
|
+
if (quoteToBForSwap === null) {
|
|
4079
|
+
throw new Error(
|
|
4080
|
+
`Failed to get Jupiter quote for swap from ${inputTokenMint.toBase58()} to ${tokenBMint.toBase58()}`
|
|
4081
|
+
);
|
|
4082
|
+
}
|
|
3980
4083
|
const { transaction: swapToBTransaction2, quoteResponse: swapToBQuote2 } = yield buildJupiterSwapTransaction(
|
|
3981
4084
|
user,
|
|
3982
4085
|
inputTokenMint,
|
|
@@ -3984,7 +4087,7 @@ var Zap = class {
|
|
|
3984
4087
|
swapAmountToB,
|
|
3985
4088
|
maxAccounts,
|
|
3986
4089
|
slippageBps,
|
|
3987
|
-
|
|
4090
|
+
quoteToBForSwap,
|
|
3988
4091
|
{
|
|
3989
4092
|
jupiterApiUrl: this.jupiterApiUrl,
|
|
3990
4093
|
jupiterApiKey: this.jupiterApiKey
|
|
@@ -4022,7 +4125,12 @@ var Zap = class {
|
|
|
4022
4125
|
}
|
|
4023
4126
|
};
|
|
4024
4127
|
}
|
|
4025
|
-
if (!hasSwapToB) {
|
|
4128
|
+
if (!hasSwapToB || quoteToBForSwap === null) {
|
|
4129
|
+
if (quoteToAForSwap === null) {
|
|
4130
|
+
throw new Error(
|
|
4131
|
+
`Failed to get Jupiter quote for swap from ${inputTokenMint.toBase58()} to ${tokenAMint.toBase58()}`
|
|
4132
|
+
);
|
|
4133
|
+
}
|
|
4026
4134
|
const { transaction: swapToATransaction2, quoteResponse: swapToAQuote2 } = yield buildJupiterSwapTransaction(
|
|
4027
4135
|
user,
|
|
4028
4136
|
inputTokenMint,
|
|
@@ -4030,7 +4138,7 @@ var Zap = class {
|
|
|
4030
4138
|
adjustedSwapAmountToA,
|
|
4031
4139
|
maxAccounts,
|
|
4032
4140
|
slippageBps,
|
|
4033
|
-
|
|
4141
|
+
quoteToAForSwap,
|
|
4034
4142
|
{
|
|
4035
4143
|
jupiterApiUrl: this.jupiterApiUrl,
|
|
4036
4144
|
jupiterApiKey: this.jupiterApiKey
|
|
@@ -4068,6 +4176,11 @@ var Zap = class {
|
|
|
4068
4176
|
}
|
|
4069
4177
|
};
|
|
4070
4178
|
}
|
|
4179
|
+
if (quoteToAForSwap === null || quoteToBForSwap === null) {
|
|
4180
|
+
throw new Error(
|
|
4181
|
+
"Failed to get Jupiter quote for both token routes, unable to proceed"
|
|
4182
|
+
);
|
|
4183
|
+
}
|
|
4071
4184
|
const { transaction: swapToATransaction, quoteResponse: swapToAQuote } = yield buildJupiterSwapTransaction(
|
|
4072
4185
|
user,
|
|
4073
4186
|
inputTokenMint,
|
|
@@ -4075,7 +4188,7 @@ var Zap = class {
|
|
|
4075
4188
|
adjustedSwapAmountToA,
|
|
4076
4189
|
maxAccounts,
|
|
4077
4190
|
slippageBps,
|
|
4078
|
-
|
|
4191
|
+
quoteToAForSwap,
|
|
4079
4192
|
{
|
|
4080
4193
|
jupiterApiUrl: this.jupiterApiUrl,
|
|
4081
4194
|
jupiterApiKey: this.jupiterApiKey
|
|
@@ -4088,7 +4201,7 @@ var Zap = class {
|
|
|
4088
4201
|
swapAmountToB,
|
|
4089
4202
|
maxAccounts,
|
|
4090
4203
|
slippageBps,
|
|
4091
|
-
|
|
4204
|
+
quoteToBForSwap,
|
|
4092
4205
|
{
|
|
4093
4206
|
jupiterApiUrl: this.jupiterApiUrl,
|
|
4094
4207
|
jupiterApiKey: this.jupiterApiKey
|