Skip to content
This repository has been archived by the owner on Feb 9, 2025. It is now read-only.

fix conf filter + liqudity impact on edit token mango #2046

Merged
Merged
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
19 changes: 12 additions & 7 deletions components/instructions/programs/mangoV4.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -807,10 +807,11 @@ const instructions = () => ({
const parsedArgs: Partial<EditTokenArgsFormatted> = {
tokenIndex: args.tokenIndex,
tokenName: args.nameOpt,
oracleConfidenceFilter:
args['oracleConfigOpt.confFilter'] >= 100
oracleConfidenceFilter: args['oracleConfigOpt.confFilter']
? args['oracleConfigOpt.confFilter'] >= 100
? args['oracleConfigOpt.confFilter'].toString()
: (args['oracleConfigOpt.confFilter'] * 100).toFixed(2),
: (args['oracleConfigOpt.confFilter'] * 100).toFixed(2)
: undefined,
oracleMaxStalenessSlots: args['oracleConfigOpt.maxStalenessSlots'],
interestRateUtilizationPoint0:
args['interestRateParamsOpt.util0'] !== undefined
Expand Down Expand Up @@ -906,7 +907,9 @@ const instructions = () => ({
const midPriceImpacts = getMidPriceImpacts(mangoGroup.pis)

const tokenToPriceImpact = midPriceImpacts
.filter((x) => x.avg_price_impact_percent < 1)
.filter(
(x) => x.avg_price_impact_percent < 1 || x.target_amount <= 1000
)
.reduce(
(acc: { [key: string]: MidPriceImpact }, val: MidPriceImpact) => {
if (
Expand All @@ -923,7 +926,9 @@ const instructions = () => ({
const priceImpact = tokenToPriceImpact[getApiTokenName(bank.name)]

const suggestedPresetKey = getProposedKey(
priceImpact?.target_amount,
priceImpact.avg_price_impact_percent < 1
? priceImpact?.target_amount
: undefined,
bank.oracleProvider === OracleProvider.Pyth
)

Expand Down Expand Up @@ -1005,8 +1010,8 @@ const instructions = () => ({
{liqudityTier.priceImpact && (
<h3 className="text-orange flex">
Very low liquidity Price impact of{' '}
{liqudityTier?.priceImpact}% on $1000 swap. Check params
carefully
{Number(liqudityTier.priceImpact).toFixed(2)}% on $1000
swap. Check params carefully
</h3>
)}
</>
Expand Down
Loading