Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update mango settings lib #1847

Merged
Show file tree
Hide file tree
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
11 changes: 2 additions & 9 deletions VoteStakeRegistry/components/Account/LockTokensModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import {
Period,
VestingPeriod,
vestingPeriods,
DAILY,
} from 'VoteStakeRegistry/tools/types'
import BigNumber from 'bignumber.js'
import useVotePluginsClientStore from 'stores/useVotePluginsClientStore'
Expand Down Expand Up @@ -376,16 +375,10 @@ const LockTokensModal = ({
onChange={(type) =>
setLockupType(
//@ts-ignore
lockupTypes
.filter(
(x) => x.value !== MONTHLY && x.value !== DAILY
)
.find((t) => t.displayName === type)
lockupTypes.find((t) => t.displayName === type)
)
}
values={lockupTypes
.filter((x) => x.value !== MONTHLY && x.value !== DAILY)
.map((type) => type.displayName)}
values={lockupTypes.map((type) => type.displayName)}
/>
</div>
</>
Expand Down
12 changes: 7 additions & 5 deletions components/instructions/programs/mangoV4.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import EmptyWallet, {
getBestMarket,
EditTokenArgsFormatted,
isPythOracle,
getFormattedListingPresets,
FlatEditArgs,
getFormattedListingPresets,
} from '@utils/Mango/listingTools'
import { secondsToHours } from 'date-fns'
import WarningFilledIcon from '@carbon/icons-react/lib/WarningFilled'
Expand Down Expand Up @@ -795,6 +795,7 @@ const instructions = () => ({
}

if (mint) {
const bank = mangoGroup.getFirstBankByMint(mint)
mintData = tokenPriceService.getTokenInfo(mint.toBase58())
const oracle =
args.oracleOpt ||
Expand All @@ -807,11 +808,12 @@ const instructions = () => ({
priceImpact: '0',
}

const suggestedPreset = getFormattedListingPresets(!!isPyth)[
liqudityTier.tier!
]
const suggestedPreset = getFormattedListingPresets(
!!isPyth,
bank.nativeDeposits().mul(bank.price).toNumber()
)[liqudityTier.tier!]
suggestedUntrusted = liqudityTier.tier === 'UNTRUSTED'

console.log(suggestedPreset)
const suggestedFormattedPreset:
| EditTokenArgsFormatted
| Record<string, never> = Object.keys(suggestedPreset).length
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.11",
"@blockworks-foundation/mango-v4-settings": "0.2.13",
"@blockworks-foundation/mangolana": "0.0.1-beta.15",
"@bonfida/spl-name-service": "0.1.47",
"@bundlr-network/client": "0.7.15",
Expand Down
16 changes: 14 additions & 2 deletions utils/Mango/listingTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
LISTING_PRESETS_KEYS,
LISTING_PRESETS_PYTH,
ListingPreset,
getTierWithAdjustedNetBorrows,
} from '@blockworks-foundation/mango-v4-settings/lib/helpers/listingTools'
import { AnchorProvider, Program, Wallet } from '@coral-xyz/anchor'
import { MAINNET_USDC_MINT } from '@foresight-tmp/foresight-sdk/dist/consts'
Expand Down Expand Up @@ -157,12 +158,23 @@ type ProposedListingPresets = {
[key in LISTING_PRESETS_KEYS]: FormattedListingPreset
}

export const getFormattedListingPresets = (isPythOracle: boolean) => {
export const getFormattedListingPresets = (
isPythOracle: boolean,
currentTotalDepositsInUsdc?: number
) => {
const PRESETS = isPythOracle ? LISTING_PRESETS_PYTH : LISTING_PRESETS

const PROPOSED_LISTING_PRESETS: ProposedListingPresets = Object.keys(
PRESETS
).reduce((accumulator, key) => {
accumulator[key] = transformPresetToProposed(PRESETS[key])
accumulator[key] = transformPresetToProposed(
!currentTotalDepositsInUsdc
? PRESETS[key]
: getTierWithAdjustedNetBorrows(
PRESETS[key],
currentTotalDepositsInUsdc
)
)
return accumulator
}, {} as ProposedListingPresets)
return PROPOSED_LISTING_PRESETS
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].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==
"@blockworks-foundation/[email protected].13":
version "0.2.13"
resolved "https://registry.yarnpkg.com/@blockworks-foundation/mango-v4-settings/-/mango-v4-settings-0.2.13.tgz#c75c1ea2e8e4c7888e45e979d75d18a2342142bf"
integrity sha512-C5djeBkeM1u2IuFTu9qu9B78iCdq2Fu/M2VEXUlZWDBmU3eMUMtQ60qc+nBL+HedrBriApM4WaRSu/RwBs3IBQ==
dependencies:
bn.js "^5.2.1"
eslint-config-prettier "^9.0.0"
Expand Down
Loading