Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lifi on-chain calcs #688

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading