Skip to content

Commit

Permalink
Fix lifi on-chain calcs
Browse files Browse the repository at this point in the history
  • Loading branch information
axtezy committed Jul 26, 2024
1 parent 4a64a86 commit f029980
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 26 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rubic-sdk",
"version": "5.32.5",
"version": "5.32.6",
"description": "Simplify dApp creation",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
51 changes: 26 additions & 25 deletions src/features/on-chain/calculation-manager/on-chain-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { OnChainTradeError } from 'src/features/on-chain/calculation-manager/mod
import { OnChainTypedTradeProviders } from 'src/features/on-chain/calculation-manager/models/on-chain-typed-trade-provider';
import { RequiredOnChainManagerCalculationOptions } from 'src/features/on-chain/calculation-manager/models/required-on-chain-manager-calculation-options';
import { WrappedOnChainTradeOrNull } from 'src/features/on-chain/calculation-manager/models/wrapped-on-chain-trade-or-null';
import { LifiCalculationOptions } from 'src/features/on-chain/calculation-manager/providers/aggregators/lifi/models/lifi-calculation-options';
import { EvmWrapTrade } from 'src/features/on-chain/calculation-manager/providers/common/evm-wrap-trade/evm-wrap-trade';
import {
OnChainCalculationOptions,
Expand Down Expand Up @@ -278,33 +279,33 @@ export class OnChainManager {
}

private async calculateLifiTrade(
_from: PriceTokenAmount,
_to: PriceToken,
_options: RequiredOnChainManagerCalculationOptions
from: PriceTokenAmount,
to: PriceToken,
options: RequiredOnChainManagerCalculationOptions
): Promise<OnChainTrade | OnChainTradeError> {
try {
throw Error('Lifi has been compromised');
// const disabledProviders = [
// ...this.LIFI_DISABLED_PROVIDERS,
// ...options.disabledProviders
// ];
//
// const calculationOptions: LifiCalculationOptions = {
// ...options,
// slippageTolerance: options?.slippageTolerance!,
// gasCalculation: options.gasCalculation === 'disabled' ? 'disabled' : 'calculate',
// disabledProviders
// };
//
// const lifiAggregator = new this.AGGREGATORS.LIFI();
//
// const lifiCalculationCall = lifiAggregator.calculate(
// from as PriceTokenAmount<EvmBlockchainName>,
// to as PriceTokenAmount<EvmBlockchainName>,
// calculationOptions
// );
//
// return pTimeout(lifiCalculationCall, options.timeout);
// throw Error('Lifi has been compromised');
const disabledProviders = [
...this.LIFI_DISABLED_PROVIDERS,
...options.disabledProviders
];

const calculationOptions: LifiCalculationOptions = {
...options,
slippageTolerance: options?.slippageTolerance!,
gasCalculation: options.gasCalculation === 'disabled' ? 'disabled' : 'calculate',
disabledProviders
};

const lifiAggregator = new this.AGGREGATORS.LIFI();

const lifiCalculationCall = lifiAggregator.calculate(
from as PriceTokenAmount<EvmBlockchainName>,
to as PriceTokenAmount<EvmBlockchainName>,
calculationOptions
);

return pTimeout(lifiCalculationCall, options.timeout);
} catch (err) {
console.debug('[RUBIC_SDK] Trade calculation error occurred for lifi.', err);
return { type: ON_CHAIN_TRADE_TYPE.LIFI, error: err };
Expand Down

0 comments on commit f029980

Please sign in to comment.