diff --git a/packages/cli/src/commands/exchange/celo.ts b/packages/cli/src/commands/exchange/celo.ts index 98531e998..233a9820d 100644 --- a/packages/cli/src/commands/exchange/celo.ts +++ b/packages/cli/src/commands/exchange/celo.ts @@ -10,7 +10,7 @@ import { checkNotDangerousExchange } from '../../utils/exchange' import { enumEntriesDupWithLowercase } from '../../utils/helpers' import { getMentoBroker } from '../../utils/mento-broker-adaptor' -const depeggedPricePercentage = 20 +const MAX_DEPEG_PRICE_PERCENTAGE = 20 const stableTokenOptions = enumEntriesDupWithLowercase(Object.entries(StableToken)) export default class ExchangeCelo extends BaseCommand { @@ -75,7 +75,7 @@ export default class ExchangeCelo extends BaseCommand { kit, sellAmount, new BigNumber(expectedAmountToReceive.toString()), - depeggedPricePercentage, + MAX_DEPEG_PRICE_PERCENTAGE, stableTokenInfos[stableToken] ) if (!check) { diff --git a/packages/cli/src/exchange-stable-base.ts b/packages/cli/src/exchange-stable-base.ts index b236c0d67..10c72deea 100644 --- a/packages/cli/src/exchange-stable-base.ts +++ b/packages/cli/src/exchange-stable-base.ts @@ -8,7 +8,7 @@ import { binaryPrompt, displaySendEthersTxViaCK, displaySendTx } from './utils/c import { CustomFlags } from './utils/command' import { checkNotDangerousExchange } from './utils/exchange' import { getMentoBroker } from './utils/mento-broker-adaptor' -const depeggedPricePercentage = 20 +const MAX_DEPEG_PRICE_PERCENTAGE = 20 export default class ExchangeStableBase extends BaseCommand { static flags = { ...BaseCommand.flags, @@ -68,7 +68,7 @@ export default class ExchangeStableBase extends BaseCommand { kit, sellAmount, new BigNumber(expectedAmountToReceive.toString()), - depeggedPricePercentage, + MAX_DEPEG_PRICE_PERCENTAGE, stableTokenInfos[this._stableCurrency as StableToken], true ) diff --git a/packages/cli/src/utils/exchange.ts b/packages/cli/src/utils/exchange.ts index b7ffe5279..5a376ffde 100644 --- a/packages/cli/src/utils/exchange.ts +++ b/packages/cli/src/utils/exchange.ts @@ -23,7 +23,7 @@ export async function checkNotDangerousExchange( kit: ContractKit, sellAmount: BigNumber, quotedAmountToReceiveWithBuffer: BigNumber, - depeggedPricePercentage: number, + maxDepegPricePercentage: number, stableTokenInfo: StableTokenInfo = stableTokenInfos[StableToken.cUSD], flipOracle = false ): Promise { @@ -37,7 +37,7 @@ export async function checkNotDangerousExchange( quotedAmountToReceiveWithBuffer, oracleMedianRate ) - if (Math.abs(expectedSlippage) > depeggedPricePercentage) { + if (Math.abs(expectedSlippage) > Math.abs(maxDepegPricePercentage)) { const check = await binaryPrompt( `Warning ${ stableTokenInfo.symbol