From 17efa40c23d00e770c12476f519a80a8ddee8e42 Mon Sep 17 00:00:00 2001 From: pseudoelement Date: Mon, 20 Jan 2025 14:02:42 +0300 Subject: [PATCH 1/4] Centralization --- .../provider-element.component.html | 24 +++++++++++++++--- .../provider-element.component.scss | 18 ++++++++++++- .../provider-element.component.ts | 12 +++++++++ .../trade/constants/centralization-status.ts | 21 +++++++++++++++ src/assets/images/icons/decentralized.png | Bin 0 -> 552 bytes src/assets/images/icons/semi-centralized.png | Bin 0 -> 491 bytes 6 files changed, 70 insertions(+), 5 deletions(-) create mode 100644 src/app/features/trade/constants/centralization-status.ts create mode 100644 src/assets/images/icons/decentralized.png create mode 100644 src/assets/images/icons/semi-centralized.png diff --git a/src/app/features/trade/components/provider-element/provider-element.component.html b/src/app/features/trade/components/provider-element/provider-element.component.html index 7cc26f31b3..d1f67a7b85 100644 --- a/src/app/features/trade/components/provider-element/provider-element.component.html +++ b/src/app/features/trade/components/provider-element/provider-element.component.html @@ -78,10 +78,26 @@ - +
+
+ centralization +

{{ centralization }}

+
+ + +
diff --git a/src/app/features/trade/components/provider-element/provider-element.component.scss b/src/app/features/trade/components/provider-element/provider-element.component.scss index 1cdf1bbe2a..5e15012e17 100644 --- a/src/app/features/trade/components/provider-element/provider-element.component.scss +++ b/src/app/features/trade/components/provider-element/provider-element.component.scss @@ -166,11 +166,27 @@ gap: var(--tui-padding-xs); align-items: flex-end; } + + &__expandable { + @include flex(column, normal, normal); + margin-top: var(--tui-padding-s); + + &-status { + @include flex(row, center, normal); + gap: 7px; + + + &-text { + color: var(--tui-text-03); + line-height: 10px; + } + } + } } app-route-element { display: block; - margin-top: var(--tui-padding-l); + // margin-top: var(--tui-padding-s); } @include b($mobile-md) { diff --git a/src/app/features/trade/components/provider-element/provider-element.component.ts b/src/app/features/trade/components/provider-element/provider-element.component.ts index 234136b595..e137b83749 100644 --- a/src/app/features/trade/components/provider-element/provider-element.component.ts +++ b/src/app/features/trade/components/provider-element/provider-element.component.ts @@ -5,6 +5,11 @@ import { AppFeeInfo, AppGasData, ProviderInfo } from '@features/trade/models/pro import { TradeInfoManager } from '../../services/trade-info-manager/trade-info-manager.service'; import { isArbitrumBridgeRbcTrade } from '../../utils/is-arbitrum-bridge-rbc-trade'; import { Observable } from 'rxjs'; +import { + CENTRALIZATION_CONFIG, + CentralizationStatus, + hasCentralizationStatus +} from '../../constants/centralization-status'; @Component({ selector: 'app-provider-element', @@ -43,6 +48,13 @@ export class ProviderElementComponent { return time; } + public getCentralizationStatus(): CentralizationStatus | null { + if (hasCentralizationStatus(this.tradeState.tradeType)) { + return CENTRALIZATION_CONFIG[this.tradeState.tradeType]; + } + return null; + } + public getProviderInfo(tradeProvider: TradeProvider): ProviderInfo { return this.tradeInfoManager.getProviderInfo(tradeProvider); } diff --git a/src/app/features/trade/constants/centralization-status.ts b/src/app/features/trade/constants/centralization-status.ts new file mode 100644 index 0000000000..a29c6b4fbb --- /dev/null +++ b/src/app/features/trade/constants/centralization-status.ts @@ -0,0 +1,21 @@ +import { CROSS_CHAIN_TRADE_TYPE, CrossChainTradeType, OnChainTradeType } from 'rubic-sdk'; + +export const CENTRALIZATION_STATUS = { + CENTRALIZED: 'centralized', + DECENTRALIZED: 'decentralized', + SEMI_CENTRALIZED: 'semi-centralized' +} as const; + +export type CentralizationStatus = + (typeof CENTRALIZATION_STATUS)[keyof typeof CENTRALIZATION_STATUS]; + +export const CENTRALIZATION_CONFIG: Partial> = { + [CROSS_CHAIN_TRADE_TYPE.SIMPLE_SWAP]: CENTRALIZATION_STATUS.SEMI_CENTRALIZED, + [CROSS_CHAIN_TRADE_TYPE.CHANGENOW]: CENTRALIZATION_STATUS.SEMI_CENTRALIZED +}; + +export function hasCentralizationStatus( + tradeType: CrossChainTradeType | OnChainTradeType +): tradeType is keyof typeof CENTRALIZATION_CONFIG { + return Object.keys(CENTRALIZATION_CONFIG).some(type => type === tradeType); +} diff --git a/src/assets/images/icons/decentralized.png b/src/assets/images/icons/decentralized.png new file mode 100644 index 0000000000000000000000000000000000000000..16f5f3c06f13a075c6c685a808590802473b9b9a GIT binary patch literal 552 zcmV+@0@wYCP)C4YA8fQh3n+1@K-p%^&7ck z>GVYb$Cta8dv688D*|%h`{ge0CzS&3EitjzE8wNQ#5%_o6Q)a5TiWksok|@aR{=z? zk{k^FM$=ydrh6o9G6^e5kcpfYMUv;q3fsq9U$VPAFrvgdOXemLtDE5JO_GrKbxcxyCCSeF=p{8*GO{b) q`ZLKv!R9O#&iJ)|@UJ|(#k7CXXa-;%G1O!L0000-fh2 literal 0 HcmV?d00001 diff --git a/src/assets/images/icons/semi-centralized.png b/src/assets/images/icons/semi-centralized.png new file mode 100644 index 0000000000000000000000000000000000000000..ace2eaf2aea88fee3dc7a7108161479e40ab7640 GIT binary patch literal 491 zcmVdXU7!>tt2sSwbnB%trJy5!u5BwHm>C`K5^4S;}tDY36UC^CI Date: Wed, 22 Jan 2025 12:03:33 +0300 Subject: [PATCH 2/4] semi-centralized, replace centralization status to tradeState --- .../tokens-list-element.component.ts | 2 +- .../constants/go-plus-available-networks.ts | 3 ++- .../provider-element.component.html | 9 +++------ .../provider-element.component.ts | 12 ----------- src/app/features/trade/models/trade-state.ts | 2 ++ .../constants/default-trade-state.ts | 4 +++- .../swaps-state/swaps-state.service.ts | 20 +++++++++++++++++-- 7 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/app/features/trade/components/assets-selector/components/tokens-list/components/tokens-list-element/tokens-list-element.component.ts b/src/app/features/trade/components/assets-selector/components/tokens-list/components/tokens-list-element/tokens-list-element.component.ts index 53ec3238b3..c8e4da8f71 100644 --- a/src/app/features/trade/components/assets-selector/components/tokens-list/components/tokens-list-element/tokens-list-element.component.ts +++ b/src/app/features/trade/components/assets-selector/components/tokens-list/components/tokens-list-element/tokens-list-element.component.ts @@ -51,7 +51,7 @@ export class TokensListElementComponent { } public get securityStatus(): TokenSecurityStatus { - if (GO_PLUS_AVAILABLE_NETWORKS.includes(this.token.blockchain) === false) { + if (!GO_PLUS_AVAILABLE_NETWORKS.includes(this.token.blockchain)) { return TokenSecurityStatus.UNSUPPORTED_BLOCKCHAIN; } diff --git a/src/app/features/trade/components/assets-selector/constants/go-plus-available-networks.ts b/src/app/features/trade/components/assets-selector/constants/go-plus-available-networks.ts index a33acb6c4a..b94637cf50 100644 --- a/src/app/features/trade/components/assets-selector/constants/go-plus-available-networks.ts +++ b/src/app/features/trade/components/assets-selector/constants/go-plus-available-networks.ts @@ -12,5 +12,6 @@ export const GO_PLUS_AVAILABLE_NETWORKS: BlockchainName[] = [ BLOCKCHAIN_NAME.CRONOS, BLOCKCHAIN_NAME.GNOSIS, BLOCKCHAIN_NAME.TRON, - BLOCKCHAIN_NAME.ZK_FAIR + BLOCKCHAIN_NAME.ZK_FAIR, + BLOCKCHAIN_NAME.BASE ]; diff --git a/src/app/features/trade/components/provider-element/provider-element.component.html b/src/app/features/trade/components/provider-element/provider-element.component.html index d1f67a7b85..7ec7f70957 100644 --- a/src/app/features/trade/components/provider-element/provider-element.component.html +++ b/src/app/features/trade/components/provider-element/provider-element.component.html @@ -79,18 +79,15 @@
-
+
centralization -

{{ centralization }}

+

{{ tradeState.centralizationStatus }}

Date: Wed, 22 Jan 2025 12:53:19 +0300 Subject: [PATCH 3/4] fix xy/retro-bridge estimated gas --- package.json | 2 +- .../trade-info-manager.service.ts | 13 ++++++++++++- yarn.lock | 8 ++++---- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 29ebef5c1e..1b416e25d6 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "ngx-cookie-service": "^16.0.0", "querystring-es3": "^0.2.1", "rpc-websockets": "7.9.0", - "rubic-sdk": "5.50.4", + "rubic-sdk": "5.50.4-alpha-xy-retro-bridge-fix.0", "rxjs": "7.8.1", "ts-cacheable": "^1.0.5", "viem": "^1.21.1", diff --git a/src/app/features/trade/services/trade-info-manager/trade-info-manager.service.ts b/src/app/features/trade/services/trade-info-manager/trade-info-manager.service.ts index a2536bdebb..b84a2b4f59 100644 --- a/src/app/features/trade/services/trade-info-manager/trade-info-manager.service.ts +++ b/src/app/features/trade/services/trade-info-manager/trade-info-manager.service.ts @@ -44,7 +44,9 @@ export class TradeInfoManager { } public getGasData(trade: CrossChainTrade | OnChainTrade): AppGasData | null { - if (!('gasData' in trade) && !('gasFeeInfo' in trade)) return null; + const estimatedGasInWei = trade.getTradeInfo().estimatedGas; + + if ((!('gasData' in trade) && !('gasFeeInfo' in trade)) || !estimatedGasInWei) return null; const blockchain = trade.from.blockchain; const nativeToken = nativeTokensList[blockchain]; @@ -52,6 +54,15 @@ export class TradeInfoManager { compareTokens(token, { blockchain, address: nativeToken.address }) ).price; + if (estimatedGasInWei) { + const estimatedGas = Web3Pure.fromWei(estimatedGasInWei, nativeToken.decimals); + return { + amount: estimatedGas, + amountInUsd: estimatedGas.multipliedBy(nativeTokenPrice), + symbol: nativeToken.symbol + }; + } + let gasFeeNonWei = null; if (trade instanceof EvmCrossChainTrade) { gasFeeNonWei = this.getCcrGasFee(trade, nativeToken); diff --git a/yarn.lock b/yarn.lock index 9880a1077c..3120651c0c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17559,10 +17559,10 @@ rpc-websockets@^9.0.2: bufferutil "^4.0.1" utf-8-validate "^5.0.2" -rubic-sdk@5.50.4: - version "5.50.4" - resolved "https://registry.yarnpkg.com/rubic-sdk/-/rubic-sdk-5.50.4.tgz#ee1ae4228293719567e7ab7c14b7c6710d5dc556" - integrity sha512-F8HJ543RN+YRj6HblLKeeWg0db+VB3e/LK8QTYQ5MVsi2H1i9/qfquYQtKaU5V9QsJ7ekxV2VTxGFfxHBeEgrA== +rubic-sdk@5.50.4-alpha-xy-retro-bridge-fix.0: + version "5.50.4-alpha-xy-retro-bridge-fix.0" + resolved "https://registry.yarnpkg.com/rubic-sdk/-/rubic-sdk-5.50.4-alpha-xy-retro-bridge-fix.0.tgz#63b8556cc6b5b94ff5342395f82f51a58ee3a7f2" + integrity sha512-qqFqYSbCZTDumHcaMGMJ439NK05zunm4ZybPg2VLZjWB89te0DgF8kW6zYln7of74i/wKQbyGbOKbCRt/XVQTA== dependencies: "@1inch/limit-order-protocol-utils" "3.0.1" "@arbitrum/sdk" "^3.1.3" From 8036eda8e2a61cd274348b91a944d3f2e7a9b1a8 Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 23 Jan 2025 11:51:30 +0300 Subject: [PATCH 4/4] set sdk release version --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 1b416e25d6..c997ea850a 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "ngx-cookie-service": "^16.0.0", "querystring-es3": "^0.2.1", "rpc-websockets": "7.9.0", - "rubic-sdk": "5.50.4-alpha-xy-retro-bridge-fix.0", + "rubic-sdk": "5.50.5", "rxjs": "7.8.1", "ts-cacheable": "^1.0.5", "viem": "^1.21.1", diff --git a/yarn.lock b/yarn.lock index 3120651c0c..ecec3a9481 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17559,10 +17559,10 @@ rpc-websockets@^9.0.2: bufferutil "^4.0.1" utf-8-validate "^5.0.2" -rubic-sdk@5.50.4-alpha-xy-retro-bridge-fix.0: - version "5.50.4-alpha-xy-retro-bridge-fix.0" - resolved "https://registry.yarnpkg.com/rubic-sdk/-/rubic-sdk-5.50.4-alpha-xy-retro-bridge-fix.0.tgz#63b8556cc6b5b94ff5342395f82f51a58ee3a7f2" - integrity sha512-qqFqYSbCZTDumHcaMGMJ439NK05zunm4ZybPg2VLZjWB89te0DgF8kW6zYln7of74i/wKQbyGbOKbCRt/XVQTA== +rubic-sdk@5.50.5: + version "5.50.5" + resolved "https://registry.yarnpkg.com/rubic-sdk/-/rubic-sdk-5.50.5.tgz#293051f42d931129e16118928e3a34bc4f0a8873" + integrity sha512-MmSABhp5lnUJje5tooxKuEmQ2Lc5zpU/tz91U/ZZbfRUgxZAdOFBrpgnyI2mP28TsG5xaxcS6cmMUfE08YiipA== dependencies: "@1inch/limit-order-protocol-utils" "3.0.1" "@arbitrum/sdk" "^3.1.3"