Skip to content

Commit

Permalink
hide-ton-keys, release
Browse files Browse the repository at this point in the history
  • Loading branch information
PseudoElement committed Oct 18, 2024
1 parent 8837807 commit a11729b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 41 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<TypedWeb3Pure>()
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 {
Expand Down Expand Up @@ -51,10 +51,10 @@ export class TonWeb3Pure {
walletAddress: string
): Promise<TonApiParseAddressResp> {
const res = await Injector.httpClient.get<TonApiResp<TonApiParseAddressResp>>(
`${TONAPI_API_URL}/address/${walletAddress}/parse`,
`${this.xApiUrl}/v2/address/${walletAddress}/parse`,
{
headers: {
Authorization: TONAPI_API_KEY
apikey: this.xApiKey
}
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<TonEncodedConfig> {
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);

Check warning on line 68 in src/features/on-chain/calculation-manager/providers/aggregators/stonfi/services/stonfi-swap-service-v2.ts

View workflow job for this annotation

GitHub Actions / Check code base before merge to master

Unexpected console statement
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);
}
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2887,10 +2887,10 @@
decamelize-keys "2.0.1"
ofetch "1.3.4"

"@ston-fi/[email protected].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/[email protected].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"
Expand Down

0 comments on commit a11729b

Please sign in to comment.