rubic-sdk 4.29.2-alpha-xy-amount.0 → 4.29.2-alpha-xy-amount.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/rubic-sdk.min.js +7 -2
- package/dist/rubic-sdk.min.js.map +1 -1
- package/lib/core/blockchain/web3-public-service/web3-public/web3-public.js +2 -0
- package/lib/core/blockchain/web3-public-service/web3-public/web3-public.js.map +1 -1
- package/lib/features/cross-chain/calculation-manager/providers/xy-provider/xy-cross-chain-trade.js +5 -2
- package/lib/features/cross-chain/calculation-manager/providers/xy-provider/xy-cross-chain-trade.js.map +1 -1
- package/package.json +1 -1
package/dist/rubic-sdk.min.js
CHANGED
@@ -210442,7 +210442,9 @@ class Web3Public {
|
|
210442
210442
|
const balanceWei = await this.getBalance(userAddress, token.address);
|
210443
210443
|
const balance = web3_pure_1.Web3Pure.fromWei(balanceWei, token.decimals);
|
210444
210444
|
if (balance.lt(requiredAmount)) {
|
210445
|
+
console.log('==========================');
|
210445
210446
|
console.log('You have not enough tokens');
|
210447
|
+
console.log('==========================');
|
210446
210448
|
// throw new InsufficientFundsError(token, balance, requiredAmount);
|
210447
210449
|
}
|
210448
210450
|
}
|
@@ -225406,16 +225408,19 @@ class XyCrossChainTrade extends evm_cross_chain_trade_1.EvmCrossChainTrade {
|
|
225406
225408
|
async checkOrderAmount(toTokenAmount) {
|
225407
225409
|
const newAmount = web3_pure_1.Web3Pure.fromWei(toTokenAmount, this.to.decimals);
|
225408
225410
|
const acceptableExpensesChangePercent = 2;
|
225411
|
+
const acceptableReductionChangePercent = 0.3;
|
225409
225412
|
const amountPlusPercent = this.to.tokenAmount.plus(this.to.tokenAmount.multipliedBy(acceptableExpensesChangePercent).dividedBy(100));
|
225413
|
+
const amountMinusPercent = this.to.tokenAmount.minus(this.to.tokenAmount.multipliedBy(acceptableReductionChangePercent).dividedBy(100));
|
225410
225414
|
const infoObject = {
|
225411
225415
|
newAmount: newAmount.toFixed(),
|
225412
225416
|
oldAmount: this.to.tokenAmount.toFixed(),
|
225413
|
-
oldAmountPlusPercent: amountPlusPercent.toFixed()
|
225417
|
+
oldAmountPlusPercent: `plus 2% = ${amountPlusPercent.toFixed()}`,
|
225418
|
+
oldAmountMinusPercent: `minus 0.3% = ${amountMinusPercent.toFixed()}`,
|
225414
225419
|
newAmountLessThenOld: newAmount.lt(this.to.tokenAmount),
|
225415
225420
|
newAmountGreatThenOldMore2Percent: newAmount.gt(amountPlusPercent)
|
225416
225421
|
};
|
225417
225422
|
console.log(infoObject);
|
225418
|
-
if (newAmount.lt(
|
225423
|
+
if (newAmount.lt(amountMinusPercent) || newAmount.gt(amountPlusPercent)) {
|
225419
225424
|
const newTo = await tokens_1.PriceTokenAmount.createFromToken({
|
225420
225425
|
...this.to,
|
225421
225426
|
tokenAmount: newAmount
|