allow to select tier other the suggested (#367)
This commit is contained in:
parent
e9f9496fea
commit
eb25e7c1e8
|
@ -1,7 +1,7 @@
|
|||
import Input from '@components/forms/Input'
|
||||
import Label from '@components/forms/Label'
|
||||
import Button, { IconButton } from '@components/shared/Button'
|
||||
import { ChangeEvent, useCallback, useMemo, useState } from 'react'
|
||||
import { ChangeEvent, useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import mangoStore, { CLUSTER } from '@store/mangoStore'
|
||||
import { Token } from 'types/jupiter'
|
||||
import { handleGetRoutes } from '@components/swap/useQuoteRoutes'
|
||||
|
@ -53,10 +53,12 @@ import {
|
|||
getPythPresets,
|
||||
LISTING_PRESET,
|
||||
getPresetWithAdjustedDepositLimit,
|
||||
LISTING_PRESETS_KEY,
|
||||
} from '@blockworks-foundation/mango-v4-settings/lib/helpers/listingTools'
|
||||
import Checkbox from '@components/forms/Checkbox'
|
||||
import { ReferralProvider } from '@jup-ag/referral-sdk'
|
||||
import { BN } from '@coral-xyz/anchor'
|
||||
import Select from '@components/forms/Select'
|
||||
|
||||
type FormErrors = Partial<Record<keyof TokenListForm, string>>
|
||||
|
||||
|
@ -137,16 +139,20 @@ const ListToken = ({ goBack }: { goBack: () => void }) => {
|
|||
}, [isPyth])
|
||||
const [proposedPresetTargetAmount, setProposedProposedTargetAmount] =
|
||||
useState(0)
|
||||
const [preset, setPreset] = useState<LISTING_PRESET>(presets.UNTRUSTED)
|
||||
|
||||
const preset: LISTING_PRESET =
|
||||
Object.values(presets).find(
|
||||
(x) => x.preset_target_amount === proposedPresetTargetAmount,
|
||||
) || presets.UNTRUSTED
|
||||
const proposedPreset = getPresetWithAdjustedDepositLimit(
|
||||
preset,
|
||||
baseTokenPrice,
|
||||
currentTokenInfo?.decimals || 0,
|
||||
)
|
||||
useEffect(() => {
|
||||
setPreset(
|
||||
Object.values(presets).find(
|
||||
(x) => x.preset_target_amount === proposedPresetTargetAmount,
|
||||
) || presets.UNTRUSTED,
|
||||
)
|
||||
}, [presets, proposedPresetTargetAmount])
|
||||
|
||||
const quoteBank = group?.getFirstBankByMint(new PublicKey(USDC_MINT))
|
||||
const minVoterWeight = useMemo(
|
||||
|
@ -462,7 +468,7 @@ const ListToken = ({ goBack }: { goBack: () => void }) => {
|
|||
}
|
||||
const mint = new PublicKey(advForm.mintPk)
|
||||
const proposalTx = []
|
||||
|
||||
console.log(proposedPreset)
|
||||
if (Object.keys(proposedPreset).length) {
|
||||
const registerTokenIx = await client!.program.methods
|
||||
.tokenRegister(
|
||||
|
@ -696,7 +702,32 @@ const ListToken = ({ goBack }: { goBack: () => void }) => {
|
|||
</div>
|
||||
<div className="mb-2 flex items-center justify-between">
|
||||
<p>{t('tier')}</p>
|
||||
<p className="text-th-fgd-2">{proposedPreset.preset_name}</p>
|
||||
<Select
|
||||
value={proposedPreset.preset_name}
|
||||
onChange={(val) => {
|
||||
setPreset(LISTING_PRESETS[val as LISTING_PRESETS_KEY]!)
|
||||
}}
|
||||
className="w-[200px]"
|
||||
>
|
||||
{Object.keys(LISTING_PRESETS).map((name) => (
|
||||
<Select.Option key={name} value={name}>
|
||||
<div className="flex w-full items-center justify-between">
|
||||
{
|
||||
LISTING_PRESETS[name as LISTING_PRESETS_KEY]
|
||||
.preset_name
|
||||
}{' '}
|
||||
{`{${
|
||||
LISTING_PRESETS[name as LISTING_PRESETS_KEY]
|
||||
.preset_key
|
||||
}}`}
|
||||
{LISTING_PRESETS[name as LISTING_PRESETS_KEY]
|
||||
.preset_target_amount === proposedPresetTargetAmount
|
||||
? '- suggested'
|
||||
: ''}
|
||||
</div>
|
||||
</Select.Option>
|
||||
))}
|
||||
</Select>
|
||||
</div>
|
||||
<div className="flex items-center justify-between">
|
||||
<p>{t('mint')}</p>
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
"dependencies": {
|
||||
"@blockworks-foundation/mango-feeds": "0.1.7",
|
||||
"@blockworks-foundation/mango-mints-redemption": "^0.0.10",
|
||||
"@blockworks-foundation/mango-v4": "0.21.13",
|
||||
"@blockworks-foundation/mango-v4": "0.21.17",
|
||||
"@blockworks-foundation/mango-v4-settings": "0.4.7",
|
||||
"@blockworks-foundation/mangolana": "0.0.1-beta.15",
|
||||
"@headlessui/react": "1.6.6",
|
||||
|
|
14
yarn.lock
14
yarn.lock
|
@ -358,10 +358,10 @@
|
|||
bn.js "^5.2.1"
|
||||
eslint-config-prettier "^9.0.0"
|
||||
|
||||
"@blockworks-foundation/mango-v4@0.21.13":
|
||||
version "0.21.13"
|
||||
resolved "https://registry.yarnpkg.com/@blockworks-foundation/mango-v4/-/mango-v4-0.21.13.tgz#297b21f26810f59b29b3a05e0609fe6f493ac98c"
|
||||
integrity sha512-mpU6CnhJHOuIkXQj2VOqznDBETmg8GSV5K6UBII61K9skh3g8avwvtOMSxJ7V6bZaTf1IMlh0t5Fe7WnWtoTlQ==
|
||||
"@blockworks-foundation/mango-v4@0.21.17":
|
||||
version "0.21.17"
|
||||
resolved "https://registry.yarnpkg.com/@blockworks-foundation/mango-v4/-/mango-v4-0.21.17.tgz#8c3d1f3c8ffc4e0a01c0872d07a345fabba85e1c"
|
||||
integrity sha512-BSAqU2iGBDq4Z7WNd4EJoBkH/iUdTpBcuzM03mnufNRDkTM1sSlhrXsl3C7hrF/IIsbNWoHRonIelslEIU4OhA==
|
||||
dependencies:
|
||||
"@blockworks-foundation/mango-v4-settings" "^0.2.16"
|
||||
"@coral-xyz/anchor" "^0.28.1-beta.2"
|
||||
|
@ -375,6 +375,7 @@
|
|||
bs58 "^5.0.0"
|
||||
cross-fetch "^3.1.5"
|
||||
dotenv "^16.0.3"
|
||||
fast-copy "^3.0.1"
|
||||
lodash "^4.17.21"
|
||||
node-kraken-api "^2.2.2"
|
||||
|
||||
|
@ -6459,6 +6460,11 @@ eyes@^0.1.8:
|
|||
resolved "https://registry.yarnpkg.com/eyes/-/eyes-0.1.8.tgz#62cf120234c683785d902348a800ef3e0cc20bc0"
|
||||
integrity sha512-GipyPsXO1anza0AOZdy69Im7hGFCNB7Y/NGjDlZGJ3GJJLtwNSb2vrzYrTYJRrRloVx7pl+bhUaTB8yiccPvFQ==
|
||||
|
||||
fast-copy@^3.0.1:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/fast-copy/-/fast-copy-3.0.1.tgz#9e89ef498b8c04c1cd76b33b8e14271658a732aa"
|
||||
integrity sha512-Knr7NOtK3HWRYGtHoJrjkaWepqT8thIVGAwt0p0aUs1zqkAzXZV4vo9fFNwyb5fcqK1GKYFYxldQdIDVKhUAfA==
|
||||
|
||||
fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
|
||||
version "3.1.3"
|
||||
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
|
||||
|
|
Loading…
Reference in New Issue