This commit is contained in:
Finn 2024-05-12 14:11:13 +02:00
parent 6e7005296e
commit 872d014efe
1 changed files with 10 additions and 2 deletions

View File

@ -2,7 +2,10 @@ import type { NextApiRequest, NextApiResponse } from 'next'
import { MangoClient } from '@blockworks-foundation/mango-v4'
import { AnchorProvider, Wallet } from '@coral-xyz/anchor'
import { Connection, PublicKey, Keypair } from '@solana/web3.js'
import { LISTING_PRESETS } from '@blockworks-foundation/mango-v4-settings/lib/helpers/listingTools'
import {
LISTING_PRESETS,
getMidPriceImpacts,
} from '@blockworks-foundation/mango-v4-settings/lib/helpers/listingTools'
interface TokenDetails {
reduceOnly?: number
@ -73,11 +76,16 @@ export default async function handler(
.sort((a, b) => a.name.localeCompare(b.name))
const priceImpacts = group?.pis || []
const midPriceImpacts = getMidPriceImpacts(
priceImpacts.length ? priceImpacts : [],
)
console.log(midPriceImpacts)
const tokenThresholds: {
[symbol: string]: { below1Percent: number; below2Percent: number }
} = {}
for (const impact of priceImpacts) {
for (const impact of midPriceImpacts) {
if (!tokenThresholds[impact.symbol]) {
tokenThresholds[impact.symbol] = { below1Percent: 0, below2Percent: 0 }
}