From 93e5af8881bc69616096de11dee822ab2dcb9f1f Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 8 Aug 2024 18:20:08 +0300 Subject: [PATCH 1/6] handle negative toAmount for dln provider --- .../debridge-cross-chain-provider.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/features/cross-chain/calculation-manager/providers/debridge-provider/debridge-cross-chain-provider.ts b/src/features/cross-chain/calculation-manager/providers/debridge-provider/debridge-cross-chain-provider.ts index 11f939d10a2..a0048810ba6 100644 --- a/src/features/cross-chain/calculation-manager/providers/debridge-provider/debridge-cross-chain-provider.ts +++ b/src/features/cross-chain/calculation-manager/providers/debridge-provider/debridge-cross-chain-provider.ts @@ -100,6 +100,18 @@ export class DebridgeCrossChainProvider extends CrossChainProvider { DlnEvmTransactionResponse | DlnSolanaTransactionResponse >(requestParams); + const toAmount = new BigNumber( + debridgeResponse.estimation.dstChainTokenOut.maxTheoreticalAmount + ); + + if (toAmount.lt(0) || toAmount.eq(0)) { + return { + error: new RubicSdkError('Received toAmount is less than 0'), + trade: null, + tradeType: this.type + }; + } + const to = new PriceTokenAmount({ ...toToken.asStruct, tokenAmount: Web3Pure.fromWei( From b76a5478da90f7735f5e6307bf895154c4b3d873 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 9 Aug 2024 09:35:41 +0300 Subject: [PATCH 2/6] fix comments --- .../debridge-provider/debridge-cross-chain-provider.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/features/cross-chain/calculation-manager/providers/debridge-provider/debridge-cross-chain-provider.ts b/src/features/cross-chain/calculation-manager/providers/debridge-provider/debridge-cross-chain-provider.ts index a0048810ba6..102028774aa 100644 --- a/src/features/cross-chain/calculation-manager/providers/debridge-provider/debridge-cross-chain-provider.ts +++ b/src/features/cross-chain/calculation-manager/providers/debridge-provider/debridge-cross-chain-provider.ts @@ -104,18 +104,10 @@ export class DebridgeCrossChainProvider extends CrossChainProvider { debridgeResponse.estimation.dstChainTokenOut.maxTheoreticalAmount ); - if (toAmount.lt(0) || toAmount.eq(0)) { - return { - error: new RubicSdkError('Received toAmount is less than 0'), - trade: null, - tradeType: this.type - }; - } - const to = new PriceTokenAmount({ ...toToken.asStruct, tokenAmount: Web3Pure.fromWei( - debridgeResponse.estimation.dstChainTokenOut.maxTheoreticalAmount, + toAmount.gt(0) ? toAmount : new BigNumber(0), debridgeResponse.estimation.dstChainTokenOut.decimals ) }); From 2a067ebf0aa484214717969132281f0bdf3454ff Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 9 Aug 2024 09:46:55 +0300 Subject: [PATCH 3/6] fix negative amount for rate update --- .../chains/debridge-evm-cross-chain-trade.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/features/cross-chain/calculation-manager/providers/debridge-provider/chains/debridge-evm-cross-chain-trade.ts b/src/features/cross-chain/calculation-manager/providers/debridge-provider/chains/debridge-evm-cross-chain-trade.ts index d9b5dc38370..269cf370966 100644 --- a/src/features/cross-chain/calculation-manager/providers/debridge-provider/chains/debridge-evm-cross-chain-trade.ts +++ b/src/features/cross-chain/calculation-manager/providers/debridge-provider/chains/debridge-evm-cross-chain-trade.ts @@ -269,8 +269,9 @@ export class DebridgeEvmCrossChainTrade extends EvmCrossChainTrade { const { tx, estimation } = await DlnApiService.fetchCrossChainSwapData(params); - - return { config: tx, amount: estimation.dstChainTokenOut.maxTheoreticalAmount }; + const toAmount = new BigNumber(estimation.dstChainTokenOut.maxTheoreticalAmount); + const receivedAmount = toAmount.gt(0) ? toAmount.toString() : '0'; + return { config: tx, amount: receivedAmount }; } public getTradeInfo(): TradeInfo { From 6c97a721bdb33b23c2f0512ae074f3e3ce018b61 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 9 Aug 2024 09:55:16 +0300 Subject: [PATCH 4/6] minor fix --- .../debridge-provider/chains/debridge-evm-cross-chain-trade.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/features/cross-chain/calculation-manager/providers/debridge-provider/chains/debridge-evm-cross-chain-trade.ts b/src/features/cross-chain/calculation-manager/providers/debridge-provider/chains/debridge-evm-cross-chain-trade.ts index 269cf370966..547ec3b41ca 100644 --- a/src/features/cross-chain/calculation-manager/providers/debridge-provider/chains/debridge-evm-cross-chain-trade.ts +++ b/src/features/cross-chain/calculation-manager/providers/debridge-provider/chains/debridge-evm-cross-chain-trade.ts @@ -270,7 +270,7 @@ export class DebridgeEvmCrossChainTrade extends EvmCrossChainTrade { const { tx, estimation } = await DlnApiService.fetchCrossChainSwapData(params); const toAmount = new BigNumber(estimation.dstChainTokenOut.maxTheoreticalAmount); - const receivedAmount = toAmount.gt(0) ? toAmount.toString() : '0'; + const receivedAmount = toAmount.gt(0) ? toAmount.toFixed() : '0'; return { config: tx, amount: receivedAmount }; } From c9f28e80c48f6e0a1b22b37e8c2fbd94b449e4fd Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 9 Aug 2024 15:02:13 +0300 Subject: [PATCH 5/6] fix price impact --- package.json | 2 +- src/common/tokens/price-token-amount.ts | 2 +- .../providers/eddy-bridge/eddy-bridge-trade.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index ab555c26cff..3082bd4ae91 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rubic-sdk", - "version": "5.33.0", + "version": "5.33.1-alpha-fix-dln.0", "description": "Simplify dApp creation", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/common/tokens/price-token-amount.ts b/src/common/tokens/price-token-amount.ts index 7a670455ef3..ec352081396 100644 --- a/src/common/tokens/price-token-amount.ts +++ b/src/common/tokens/price-token-amount.ts @@ -147,6 +147,6 @@ export class PriceTokenAmount extends .dp(2, BigNumber.ROUND_HALF_UP) .toNumber(); - return impact > 0 ? impact : 0; + return impact; } } diff --git a/src/features/cross-chain/calculation-manager/providers/eddy-bridge/eddy-bridge-trade.ts b/src/features/cross-chain/calculation-manager/providers/eddy-bridge/eddy-bridge-trade.ts index c76e5bb6831..90020f34a09 100644 --- a/src/features/cross-chain/calculation-manager/providers/eddy-bridge/eddy-bridge-trade.ts +++ b/src/features/cross-chain/calculation-manager/providers/eddy-bridge/eddy-bridge-trade.ts @@ -245,7 +245,7 @@ export class EddyBridgeTrade extends EvmCrossChainTrade { return { estimatedGas: this.estimatedGas, feeInfo: this.feeInfo, - priceImpact: this.priceImpact || null, + priceImpact: this.priceImpact ?? null, slippage: this.slippage * 100, routePath: this.routePath }; From abd400a941fe1e4e9e50f5cf7c784597c46f592e Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 13 Aug 2024 09:46:36 +0300 Subject: [PATCH 6/6] set sdk release version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3082bd4ae91..4836b3d5b60 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rubic-sdk", - "version": "5.33.1-alpha-fix-dln.0", + "version": "5.33.3", "description": "Simplify dApp creation", "main": "lib/index.js", "types": "lib/index.d.ts",