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

Big Swap Feedback #122

Merged
merged 3 commits into from
Feb 7, 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
4 changes: 2 additions & 2 deletions packages/cli/src/commands/exchange/celo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/exchange-stable-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
)
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/utils/exchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean> {
Expand All @@ -37,11 +37,11 @@ export async function checkNotDangerousExchange(
quotedAmountToReceiveWithBuffer,
oracleMedianRate
)
if (expectedSlippage > depeggedPricePercentage) {
if (Math.abs(expectedSlippage) > Math.abs(maxDepegPricePercentage)) {
const check = await binaryPrompt(
`Warning ${
stableTokenInfo.symbol
} price here (i.e. on-chain) is depegged by ${expectedSlippage}% which is >${depeggedPricePercentage}% from the oracle prices ${oracleMedianRate.toString()} (i.e. swap prices). Are you sure you want to continue?`,
} price here (i.e. on-chain) would be depegged by ${expectedSlippage}% from the oracle prices ${oracleMedianRate.toString()} (i.e. swap prices). Are you sure you want to continue?`,
true
)
return check
Expand Down
Loading