@atomiqlabs/lp-lib 13.0.0-beta.6 → 13.0.0-beta.8
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.
|
@@ -126,8 +126,18 @@ class FromBtcAmountAssertions extends AmountAssertions_1.AmountAssertions {
|
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
else {
|
|
129
|
+
this.checkBtcAmountInBounds(requestedAmount.amount);
|
|
129
130
|
amountBD = requestedAmount.amount - amountBDgas;
|
|
130
|
-
|
|
131
|
+
if (amountBD < 0n) {
|
|
132
|
+
throw {
|
|
133
|
+
code: 20003,
|
|
134
|
+
msg: "Amount too low!",
|
|
135
|
+
data: {
|
|
136
|
+
min: this.config.min.toString(10),
|
|
137
|
+
max: this.config.max.toString(10)
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
}
|
|
131
141
|
}
|
|
132
142
|
const swapFee = fees.baseFee + (amountBD * fees.feePPM / 1000000n);
|
|
133
143
|
const swapFeeInToken = await this.swapPricing.getFromBtcSwapAmount(swapFee, requestedAmount.token, chainIdentifier, true, requestedAmount.pricePrefetch);
|
|
@@ -251,7 +251,12 @@ class SpvVaultSwapHandler extends SwapHandler_1.SwapHandler {
|
|
|
251
251
|
abortController.signal.throwIfAborted();
|
|
252
252
|
metadata.times.addressCreated = Date.now();
|
|
253
253
|
//Adjust the amounts based on passed fees
|
|
254
|
-
|
|
254
|
+
if (parsedBody.exactOut) {
|
|
255
|
+
totalInToken = parsedBody.amount;
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
totalInToken = (totalInToken * 100000n / (100000n + parsedBody.callerFeeRate + parsedBody.frontingFeeRate));
|
|
259
|
+
}
|
|
255
260
|
totalInGasToken = (totalInGasToken * 100000n / (100000n + parsedBody.callerFeeRate + parsedBody.frontingFeeRate));
|
|
256
261
|
//Calculate raw amounts
|
|
257
262
|
const [rawTokenAmount, rawGasTokenAmount] = vault.toRawAmounts([totalInToken, totalInGasToken]);
|
package/package.json
CHANGED
|
@@ -189,8 +189,18 @@ export class FromBtcAmountAssertions extends AmountAssertions {
|
|
|
189
189
|
};
|
|
190
190
|
}
|
|
191
191
|
} else {
|
|
192
|
+
this.checkBtcAmountInBounds(requestedAmount.amount);
|
|
192
193
|
amountBD = requestedAmount.amount - amountBDgas;
|
|
193
|
-
|
|
194
|
+
if(amountBD < 0n) {
|
|
195
|
+
throw {
|
|
196
|
+
code: 20003,
|
|
197
|
+
msg: "Amount too low!",
|
|
198
|
+
data: {
|
|
199
|
+
min: this.config.min.toString(10),
|
|
200
|
+
max: this.config.max.toString(10)
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
}
|
|
194
204
|
}
|
|
195
205
|
|
|
196
206
|
const swapFee = fees.baseFee + (amountBD * fees.feePPM / 1000000n);
|
|
@@ -350,7 +350,11 @@ export class SpvVaultSwapHandler extends SwapHandler<SpvVaultSwap, SpvVaultSwapS
|
|
|
350
350
|
metadata.times.addressCreated = Date.now();
|
|
351
351
|
|
|
352
352
|
//Adjust the amounts based on passed fees
|
|
353
|
-
|
|
353
|
+
if(parsedBody.exactOut) {
|
|
354
|
+
totalInToken = parsedBody.amount;
|
|
355
|
+
} else {
|
|
356
|
+
totalInToken = (totalInToken * 100_000n / (100_000n + parsedBody.callerFeeRate + parsedBody.frontingFeeRate));
|
|
357
|
+
}
|
|
354
358
|
totalInGasToken = (totalInGasToken * 100_000n / (100_000n + parsedBody.callerFeeRate + parsedBody.frontingFeeRate));
|
|
355
359
|
|
|
356
360
|
//Calculate raw amounts
|