diff --git a/src/chains/ton.ts b/src/chains/ton.ts index 5029e40..0eb8e50 100644 --- a/src/chains/ton.ts +++ b/src/chains/ton.ts @@ -39,6 +39,7 @@ import { type GetLpFeeGrowthGlobal, type GetLpProviderRewards, type IsTransferFromLp, + type GetProtocolFeeInUSD, type GetSwapResultAmount, type GetCrossChainStrategy, type SwapTokens, @@ -88,6 +89,7 @@ export type TonHelper = GetBalance & GetLpFeeDecimals & IsTransferFromLp & GetSwapResultAmount & + GetProtocolFeeInUSD & // GetIncomingStrategy & GetCrossChainStrategy & SwapTokens; @@ -569,7 +571,7 @@ export async function tonHandler({ ); return address.toString(); }, - estimateTime: () => Promise.resolve(undefined), + estimateTime: () => Promise.resolve(2n * 60n * 1000n), // 2 minutes isTransferFromLp: () => Promise.resolve(false), // TODO: update it async emmetHashFromtx(hash) { const b64 = Buffer.from(hash, "hex").toString("base64"); @@ -657,6 +659,9 @@ export async function tonHandler({ const jw = fetchClient().open(JettonWallet.create(jwa)); return jw.getBalance(); }, + protocolFeeInUSD: () => { + return 50n; + }, sendInstallment: async ( signer, amt, diff --git a/src/chains/web3.ts b/src/chains/web3.ts index 1cb80e6..0fabbc9 100644 --- a/src/chains/web3.ts +++ b/src/chains/web3.ts @@ -219,31 +219,38 @@ export async function web3Helper({ return amount; }, async crossChainStrategy(targetChain, fromSymbol, targetSymbol) { - const ccts = await data.getStrategy( - targetChain, - fromSymbol, - targetSymbol, - ); - + const outgoing: TStrategy[] = []; const incoming: TStrategy[] = []; const foreign: TStrategy[] = []; - const map = [ - { strategies: ccts.outgoing, targetArray: outgoing }, - { strategies: ccts.incoming, targetArray: incoming }, - { strategies: ccts.foreign, targetArray: foreign } - ] + try { + + const ccts = await data.getStrategy( + targetChain, + fromSymbol, + targetSymbol, + ); + + const map = [ + { strategies: ccts.outgoing, targetArray: outgoing }, + { strategies: ccts.incoming, targetArray: incoming }, + { strategies: ccts.foreign, targetArray: foreign } + ]; - for (const { strategies, targetArray } of map) { - for (const strat of strategies) { - const strategyName: TStrategy = strategyMap[BigInt(strat).toString()] as TStrategy; - if (strategyName) { - targetArray.push(strategyName); + for (const { strategies, targetArray } of map) { + for (const strat of strategies) { + const strategyName: TStrategy = strategyMap[BigInt(strat).toString()] as TStrategy; + if (strategyName) { + targetArray.push(strategyName); + } } } + + } catch (error) { + } - + return { outgoing, incoming, @@ -418,35 +425,42 @@ export async function web3Helper({ balance: async (addr) => (await fetchProvider()).getBalance(addr), provider: async () => await fetchProvider(), async estimateTime(targetChain, fromToken, targetToken) { + // Default time + let estimation: bigint = 2n * 60n * 1000n; - const ts = await data.getStrategy( - targetChain, - fromToken, - targetToken, - ); - - const outgoing = ts[0]; - const foreign = ts[1]; - - const cctpBurn: bigint = BigInt(EStrategy.CCTPClaim); - const cctpClaim: bigint = BigInt(EStrategy.CCTPClaim); - - const isCCTP = - foreign.includes(cctpBurn) || - foreign.includes(cctpClaim) || - outgoing.includes(cctpBurn) || - outgoing.includes(cctpClaim); + try { - if (isCCTP) { - // 2 minutes - const timeInMs = (2n * 60n) * 1000n; - return timeInMs; - } else { - // 1 minute - const timeInMs = (1n * 60n) * 1000n; - return timeInMs; + const ts = await data.getStrategy( + targetChain, + fromToken, + targetToken, + ); + + const outgoing = ts[0]; + const foreign = ts[1]; + + const cctpBurn: bigint = BigInt(EStrategy.CCTPClaim); + const cctpClaim: bigint = BigInt(EStrategy.CCTPClaim); + + const isCCTP = + foreign.includes(cctpBurn) || + foreign.includes(cctpClaim) || + outgoing.includes(cctpBurn) || + outgoing.includes(cctpClaim); + + if (isCCTP) { + // 3 minutes + estimation = (3n * 60n) * 1000n; + } else { + // 1 minute + estimation = (1n * 60n) * 1000n; + } + + } catch (error) { + console.warn(error) } - return undefined; + + return estimation; }, async isTransferFromLp(targetChain, fromToken, targetToken) { diff --git a/src/factory/rpcs.ts b/src/factory/rpcs.ts index f9ef5e6..a278fe6 100644 --- a/src/factory/rpcs.ts +++ b/src/factory/rpcs.ts @@ -12,7 +12,7 @@ export const MainnetRPCUri = { "https://polygon-bor-rpc.publicnode.com", "https://polygon-bor-rpc.publicnode.com", "https://1rpc.io/matic", - "https://polygon.blockpi.network/v1/rpc/public", + // "https://polygon.blockpi.network/v1/rpc/public", ] } as const;