Skip to content

Commit

Permalink
add ultra premium tier for mango listing (solana-labs#1842)
Browse files Browse the repository at this point in the history
  • Loading branch information
abrzezinski94 authored Sep 28, 2023
1 parent eab95b1 commit be21945
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 10 deletions.
2 changes: 1 addition & 1 deletion components/instructions/programs/mangoV4.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ const instructions = () => ({
liqudityTier = !mint.equals(USDC_MINT)
? await getSuggestedCoinTier(mint.toBase58(), !!isPyth)
: {
tier: 'PREMIUM',
tier: 'ULTRA_PREMIUM',
priceImpact: '0',
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"dependencies": {
"@blockworks-foundation/mango-v4": "0.19.29",
"@blockworks-foundation/mango-v4-settings": "0.2.10",
"@blockworks-foundation/mango-v4-settings": "0.2.11",
"@blockworks-foundation/mangolana": "0.0.1-beta.15",
"@bonfida/spl-name-service": "0.1.47",
"@bundlr-network/client": "0.7.15",
Expand Down
31 changes: 27 additions & 4 deletions utils/Mango/listingTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,20 @@ export const getSuggestedCoinTier = async (
outputMint: string,
hasPythOracle: boolean
) => {
const TIERS: LISTING_PRESETS_KEYS[] = ['PREMIUM', 'MID', 'MEME', 'SHIT']
const TIERS: LISTING_PRESETS_KEYS[] = [
'ULTRA_PREMIUM',
'PREMIUM',
'MID',
'MEME',
'SHIT',
]

const swaps = await Promise.all([
fetchJupiterRoutes(
MAINNET_USDC_MINT.toBase58(),
outputMint,
toNative(250000, 6).toNumber()
),
fetchJupiterRoutes(
MAINNET_USDC_MINT.toBase58(),
outputMint,
Expand All @@ -226,6 +238,12 @@ export const getSuggestedCoinTier = async (
outputMint,
toNative(1000, 6).toNumber()
),
fetchJupiterRoutes(
MAINNET_USDC_MINT.toBase58(),
outputMint,
toNative(250000, 6).toNumber(),
'ExactOut'
),
fetchJupiterRoutes(
MAINNET_USDC_MINT.toBase58(),
outputMint,
Expand Down Expand Up @@ -281,10 +299,15 @@ export const getSuggestedCoinTier = async (
indexForTierFromSwaps > -1 ? TIERS[indexForTierFromSwaps] : 'UNTRUSTED'

const tierLowerThenCurrent =
tier === 'PREMIUM' ? 'MID' : tier === 'MID' ? 'MEME' : tier
const isMidOrPremium = tier === 'MID' || tier === 'PREMIUM'
tier === 'ULTRA_PREMIUM' || tier === 'PREMIUM'
? 'MID'
: tier === 'MID'
? 'MEME'
: tier
const isPythRecommendedTier =
tier === 'MID' || tier === 'PREMIUM' || tier === 'ULTRA_PREMIUM'
const listingTier =
isMidOrPremium && !hasPythOracle ? tierLowerThenCurrent : tier
isPythRecommendedTier && !hasPythOracle ? tierLowerThenCurrent : tier

return {
tier: listingTier,
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,10 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==

"@blockworks-foundation/[email protected].10":
version "0.2.10"
resolved "https://registry.yarnpkg.com/@blockworks-foundation/mango-v4-settings/-/mango-v4-settings-0.2.10.tgz#d09a74b743b1eb44bcad46b09680035fb8ec5a85"
integrity sha512-pQ7TfAxBdoF0fNVQ7PsT4TW5cpGibTjZadXcYlbyfetxQbTQS9mgghfGaq/TDFz/rHa6FS2FJ0xCJBoy7FNDbg==
"@blockworks-foundation/[email protected].11":
version "0.2.11"
resolved "https://registry.yarnpkg.com/@blockworks-foundation/mango-v4-settings/-/mango-v4-settings-0.2.11.tgz#f573cf3c61c6b31d9097940160f18897219cac80"
integrity sha512-F4cR8gOTcstdrMtbtEDgXb40Jm+7j6HE1PNiu+9UgJ04hsoQFbxbtSIWRh4ZpmiW3Kd4LIOZLNSjzRnAJU8zcg==
dependencies:
bn.js "^5.2.1"
eslint-config-prettier "^9.0.0"
Expand Down

0 comments on commit be21945

Please sign in to comment.