diff --git a/package.json b/package.json index 460e491dc2..18a05f1809 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rubic-sdk", - "version": "5.40.2", + "version": "5.40.3", "description": "Simplify dApp creation", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -84,7 +84,7 @@ "@solana/web3.js": "^1.89.1", "@solflare-wallet/utl-sdk": "^1.4.0", "@ston-fi/api": "^0.12.1", - "@ston-fi/sdk": "2.0.0-rc.7", + "@ston-fi/sdk": "2.0.0-rc.8", "@ton/core": "^0.52.0", "@ton/crypto": "^3.3.0", "@ton/ton": "^15.0.0", diff --git a/src/core/blockchain/web3-pure/typed-web3-pure/ton-web3-pure/ton-web3-pure.ts b/src/core/blockchain/web3-pure/typed-web3-pure/ton-web3-pure/ton-web3-pure.ts index 378af2da6f..32565d9824 100644 --- a/src/core/blockchain/web3-pure/typed-web3-pure/ton-web3-pure/ton-web3-pure.ts +++ b/src/core/blockchain/web3-pure/typed-web3-pure/ton-web3-pure/ton-web3-pure.ts @@ -3,15 +3,15 @@ import { RubicSdkError } from 'src/common/errors'; import { compareAddresses } from 'src/common/utils/blockchain'; import { staticImplements } from 'src/common/utils/decorators'; import { TonApiParseAddressResp, TonApiResp } from 'src/core/blockchain/models/ton/tonapi-types'; -import { - TONAPI_API_KEY, - TONAPI_API_URL -} from 'src/core/blockchain/services/constants/ton-constants'; import { TypedWeb3Pure } from 'src/core/blockchain/web3-pure/typed-web3-pure/typed-web3-pure'; import { Injector } from 'src/core/injector/injector'; @staticImplements() export class TonWeb3Pure { + private static readonly xApiUrl = 'https://x-api.rubic.exchange/tonapi'; + + private static readonly xApiKey = 'sndfje3u4b3fnNSDNFUSDNVSunw345842hrnfd3b4nt4'; + public static readonly EMPTY_ADDRESS = '0x0000000000000000000000000000000000000000'; public static get nativeTokenAddress(): string { @@ -51,10 +51,10 @@ export class TonWeb3Pure { walletAddress: string ): Promise { const res = await Injector.httpClient.get>( - `${TONAPI_API_URL}/address/${walletAddress}/parse`, + `${this.xApiUrl}/v2/address/${walletAddress}/parse`, { headers: { - Authorization: TONAPI_API_KEY + apikey: this.xApiKey } } ); diff --git a/src/features/on-chain/calculation-manager/providers/aggregators/stonfi/services/stonfi-swap-service-v2.ts b/src/features/on-chain/calculation-manager/providers/aggregators/stonfi/services/stonfi-swap-service-v2.ts index 46fab625e2..9ab261b1e9 100644 --- a/src/features/on-chain/calculation-manager/providers/aggregators/stonfi/services/stonfi-swap-service-v2.ts +++ b/src/features/on-chain/calculation-manager/providers/aggregators/stonfi/services/stonfi-swap-service-v2.ts @@ -13,53 +13,60 @@ export class StonfiSwapServiceV2 implements StonfiTxParamsProvider { return TonClientInstance.getInstance(); } - private readonly stonfiRouter = this.tonClient.open( - DEX.v2_1.Router.create('kQALh-JBBIKK7gr0o4AVf9JZnEsFndqO0qTCyT-D-yBsWk0v') - ); - public async getTxParams( from: PriceTokenAmount, to: PriceTokenAmount, walletAddress: string, minAmountOutWei: string ): Promise { + const stonfiRouter = this.tonClient.open( + DEX.v2_2.Router.create('kQALh-JBBIKK7gr0o4AVf9JZnEsFndqO0qTCyT-D-yBsWk0v') + ); const proxyTon = pTON.v2_1.create('kQACS30DNoUQ7NfApPvzh7eBmSZ9L4ygJ-lkNWtba8TQT-Px'); - if (from.isNative) { - const txParams = await this.stonfiRouter.getSwapTonToJettonTxParams({ - userWalletAddress: walletAddress, - proxyTon, - offerAmount: from.stringWeiAmount, - askJettonAddress: to.address, - minAskAmount: minAmountOutWei, - referralAddress: STONFI_REFERRAL_ADDRESS - }); + try { + if (from.isNative) { + const txParams = await stonfiRouter.getSwapTonToJettonTxParams({ + userWalletAddress: walletAddress, + proxyTon, + offerAmount: from.stringWeiAmount, + askJettonAddress: to.address, + minAskAmount: minAmountOutWei, + referralValue: 100, + referralAddress: STONFI_REFERRAL_ADDRESS + }); - return convertTxParamsToTonConfig(txParams); - } + return convertTxParamsToTonConfig(txParams); + } + + if (to.isNative) { + const txParams = await stonfiRouter.getSwapJettonToTonTxParams({ + userWalletAddress: walletAddress, + offerJettonAddress: from.address, + offerAmount: from.stringWeiAmount, + proxyTon, + minAskAmount: minAmountOutWei, + referralValue: 100, + referralAddress: STONFI_REFERRAL_ADDRESS + }); + + return convertTxParamsToTonConfig(txParams); + } - if (to.isNative) { - const txParams = await this.stonfiRouter.getSwapJettonToTonTxParams({ + const txParams = await stonfiRouter.getSwapJettonToJettonTxParams({ userWalletAddress: walletAddress, offerJettonAddress: from.address, offerAmount: from.stringWeiAmount, - proxyTon, + askJettonAddress: to.address, minAskAmount: minAmountOutWei, + referralValue: 100, referralAddress: STONFI_REFERRAL_ADDRESS }); return convertTxParamsToTonConfig(txParams); + } catch (err) { + console.log('getTxParams_ERROR ==> ', err); + throw err; } - - const txParams = await this.stonfiRouter.getSwapJettonToJettonTxParams({ - userWalletAddress: walletAddress, - offerJettonAddress: from.address, - offerAmount: from.stringWeiAmount, - askJettonAddress: to.address, - minAskAmount: minAmountOutWei, - referralAddress: STONFI_REFERRAL_ADDRESS - }); - - return convertTxParamsToTonConfig(txParams); } } diff --git a/yarn.lock b/yarn.lock index 2ebd22a1f1..f343204469 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2887,10 +2887,10 @@ decamelize-keys "2.0.1" ofetch "1.3.4" -"@ston-fi/sdk@2.0.0-rc.7": - version "2.0.0-rc.7" - resolved "https://registry.yarnpkg.com/@ston-fi/sdk/-/sdk-2.0.0-rc.7.tgz#479bfd6ebc00cb749d755c00b6c3c2d7199a784b" - integrity sha512-5a04aX7FWq9Sm2/Ox2WayOpeoJ5VQH6Fnn/hiL8rW4wn7obwzAJgllnodwOQQNWw/z/Vb5BJHo2Ur5o7tymfXg== +"@ston-fi/sdk@2.0.0-rc.8": + version "2.0.0-rc.8" + resolved "https://registry.yarnpkg.com/@ston-fi/sdk/-/sdk-2.0.0-rc.8.tgz#c6b7260dfe29c27ec5e63f88af84ac24a730accd" + integrity sha512-9+9qBhdGzTVsC3iDHVQnrEFU7N7mdlGKbn57pHJrVfZiGm/55X5IPl4DKclbdtl9Gtjf9Kf8bBLweMEwzHntGw== "@supercharge/promise-pool@^2.1.0": version "2.4.0"