add ultra premium listing (#280)

* add ultra premium tier

* fix
This commit is contained in:
Adrian Brzeziński 2023-09-29 00:48:59 +02:00 committed by GitHub
parent b89c3b3fca
commit 2de1946cd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 19 deletions

View File

@ -120,14 +120,17 @@ const ListToken = ({ goBack }: { goBack: () => void }) => {
) )
const [isPyth, setIsPyth] = useState(false) const [isPyth, setIsPyth] = useState(false)
const tierLowerThenCurrent = const tierLowerThenCurrent =
liqudityTier === 'PREMIUM' liqudityTier === 'ULTRA_PREMIUM' || liqudityTier === 'PREMIUM'
? 'MID' ? 'MID'
: liqudityTier === 'MID' : liqudityTier === 'MID'
? 'MEME' ? 'MEME'
: liqudityTier : liqudityTier
const isMidOrPremium = liqudityTier === 'MID' || liqudityTier === 'PREMIUM' const isPythRecommended =
liqudityTier === 'MID' ||
liqudityTier === 'PREMIUM' ||
liqudityTier === 'ULTRA_PREMIUM'
const listingTier = const listingTier =
isMidOrPremium && !isPyth ? tierLowerThenCurrent : liqudityTier isPythRecommended && !isPyth ? tierLowerThenCurrent : liqudityTier
const quoteBank = group?.getFirstBankByMint(new PublicKey(USDC_MINT)) const quoteBank = group?.getFirstBankByMint(new PublicKey(USDC_MINT))
const minVoterWeight = useMemo( const minVoterWeight = useMemo(
@ -257,12 +260,20 @@ const ListToken = ({ goBack }: { goBack: () => void }) => {
const handleLiqudityCheck = useCallback( const handleLiqudityCheck = useCallback(
async (tokenMint: PublicKey) => { async (tokenMint: PublicKey) => {
try { try {
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([ const swaps = await Promise.all([
handleGetRoutesWithFixedArgs(250000, tokenMint, 'ExactIn'),
handleGetRoutesWithFixedArgs(100000, tokenMint, 'ExactIn'), handleGetRoutesWithFixedArgs(100000, tokenMint, 'ExactIn'),
handleGetRoutesWithFixedArgs(20000, tokenMint, 'ExactIn'), handleGetRoutesWithFixedArgs(20000, tokenMint, 'ExactIn'),
handleGetRoutesWithFixedArgs(5000, tokenMint, 'ExactIn'), handleGetRoutesWithFixedArgs(5000, tokenMint, 'ExactIn'),
handleGetRoutesWithFixedArgs(1000, tokenMint, 'ExactIn'), handleGetRoutesWithFixedArgs(1000, tokenMint, 'ExactIn'),
handleGetRoutesWithFixedArgs(250000, tokenMint, 'ExactOut'),
handleGetRoutesWithFixedArgs(100000, tokenMint, 'ExactOut'), handleGetRoutesWithFixedArgs(100000, tokenMint, 'ExactOut'),
handleGetRoutesWithFixedArgs(20000, tokenMint, 'ExactOut'), handleGetRoutesWithFixedArgs(20000, tokenMint, 'ExactOut'),
handleGetRoutesWithFixedArgs(5000, tokenMint, 'ExactOut'), handleGetRoutesWithFixedArgs(5000, tokenMint, 'ExactOut'),
@ -320,6 +331,7 @@ const ListToken = ({ goBack }: { goBack: () => void }) => {
tokenMint: PublicKey, tokenMint: PublicKey,
) => { ) => {
const tierToSwapValue: { [key: string]: number } = { const tierToSwapValue: { [key: string]: number } = {
ULTRA_PREMIUM: 250000,
PREMIUM: 100000, PREMIUM: 100000,
MID: 20000, MID: 20000,
MEME: 5000, MEME: 5000,
@ -699,7 +711,7 @@ const ListToken = ({ goBack }: { goBack: () => void }) => {
{listingTier && coinTiersToNames[listingTier]} {listingTier && coinTiersToNames[listingTier]}
</p> </p>
</div> </div>
{isMidOrPremium && !isPyth && ( {isPythRecommended && !isPyth && (
<div className="mb-2 flex items-center justify-end"> <div className="mb-2 flex items-center justify-end">
<p className="text-th-warning"> <p className="text-th-warning">
Pyth oracle needed for higher tier Pyth oracle needed for higher tier

View File

@ -107,20 +107,22 @@ const DashboardSuggestedValues = ({
{}, {},
) )
const priceImapct = filteredResp[getApiTokenName(bank.name)] const priceImapct = filteredResp[getApiTokenName(bank.name)]
const liqudityTier = const liqudityTier = (Object.values(PRESETS).find(
Object.values(PRESETS).find( (x) => x.preset_target_amount === priceImapct?.target_amount,
(x) => x.preset_target_amount === priceImapct?.target_amount, )?.preset_key || 'SHIT') as LISTING_PRESETS_KEYS
)?.preset_key || 'SHIT' const detieredTierWithoutPyth =
const tierLowerThenCurrent = liqudityTier === 'ULTRA_PREMIUM' || liqudityTier === 'PREMIUM'
liqudityTier === 'PREMIUM'
? 'MID' ? 'MID'
: liqudityTier === 'MID' : liqudityTier === 'MID'
? 'MEME' ? 'MEME'
: liqudityTier : liqudityTier
const isMidOrPremium = liqudityTier === 'MID' || liqudityTier === 'PREMIUM' const isPythRecommended =
liqudityTier === 'MID' ||
liqudityTier === 'PREMIUM' ||
liqudityTier === 'ULTRA_PREMIUM'
const listingTier = const listingTier =
isMidOrPremium && bank?.oracleProvider !== OracleProvider.Pyth isPythRecommended && bank?.oracleProvider !== OracleProvider.Pyth
? tierLowerThenCurrent ? detieredTierWithoutPyth
: liqudityTier : liqudityTier
setSuggstedTier(listingTier as LISTING_PRESETS_KEYS) setSuggstedTier(listingTier as LISTING_PRESETS_KEYS)

View File

@ -24,7 +24,7 @@
"@blockworks-foundation/mango-feeds": "0.1.7", "@blockworks-foundation/mango-feeds": "0.1.7",
"@blockworks-foundation/mango-mints-redemption": "^0.0.8", "@blockworks-foundation/mango-mints-redemption": "^0.0.8",
"@blockworks-foundation/mango-v4": "^0.19.33", "@blockworks-foundation/mango-v4": "^0.19.33",
"@blockworks-foundation/mango-v4-settings": "0.2.10", "@blockworks-foundation/mango-v4-settings": "0.2.11",
"@blockworks-foundation/mangolana": "0.0.1-beta.15", "@blockworks-foundation/mangolana": "0.0.1-beta.15",
"@headlessui/react": "1.6.6", "@headlessui/react": "1.6.6",
"@heroicons/react": "2.0.10", "@heroicons/react": "2.0.10",

View File

@ -42,10 +42,10 @@
keccak256 "^1.0.6" keccak256 "^1.0.6"
merkletreejs "^0.3.10" merkletreejs "^0.3.10"
"@blockworks-foundation/mango-v4-settings@0.2.10": "@blockworks-foundation/mango-v4-settings@0.2.11":
version "0.2.10" version "0.2.11"
resolved "https://registry.yarnpkg.com/@blockworks-foundation/mango-v4-settings/-/mango-v4-settings-0.2.10.tgz#d09a74b743b1eb44bcad46b09680035fb8ec5a85" resolved "https://registry.yarnpkg.com/@blockworks-foundation/mango-v4-settings/-/mango-v4-settings-0.2.11.tgz#f573cf3c61c6b31d9097940160f18897219cac80"
integrity sha512-pQ7TfAxBdoF0fNVQ7PsT4TW5cpGibTjZadXcYlbyfetxQbTQS9mgghfGaq/TDFz/rHa6FS2FJ0xCJBoy7FNDbg== integrity sha512-F4cR8gOTcstdrMtbtEDgXb40Jm+7j6HE1PNiu+9UgJ04hsoQFbxbtSIWRh4ZpmiW3Kd4LIOZLNSjzRnAJU8zcg==
dependencies: dependencies:
bn.js "^5.2.1" bn.js "^5.2.1"
eslint-config-prettier "^9.0.0" eslint-config-prettier "^9.0.0"