Skip to content

Commit

Permalink
Merge branch 'main' of github.com:blockworks-foundation/mango-v4-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
abrzezinski94 committed Sep 4, 2024
2 parents 3761abe + 242cd39 commit 73d70df
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 20 deletions.
5 changes: 3 additions & 2 deletions components/trade/OraclePrice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Tooltip from '@components/shared/Tooltip'
import { useTranslation } from 'next-i18next'
import mangoStore from '@store/mangoStore'
import { useEffect, useState } from 'react'
import { PerpMarket, Bank } from '@blockworks-foundation/mango-v4'
import { PerpMarket, Bank, Group } from '@blockworks-foundation/mango-v4'
import { BorshAccountsCoder } from '@coral-xyz/anchor'
import {
floorToDecimal,
Expand Down Expand Up @@ -62,7 +62,8 @@ const OraclePrice = () => {
marketOrBank.oracle,
async (info, context) => {
const { price, uiPrice, lastUpdatedSlot } =
await group.decodePriceFromOracleAi(
await Group.decodePriceFromOracleAi(
group,
coder,
marketOrBank.oracle,
info,
Expand Down
8 changes: 5 additions & 3 deletions hooks/useStablePrice.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { I80F48, PerpMarket } from '@blockworks-foundation/mango-v4'
import { Group, I80F48, PerpMarket } from '@blockworks-foundation/mango-v4'
import { useMemo } from 'react'
import useMangoGroup from './useMangoGroup'
import useSelectedMarket from './useSelectedMarket'
Expand All @@ -22,11 +22,13 @@ const useStablePrice = () => {
(b) => b.tokenIndex === selectedMarket.quoteTokenIndex,
)

const baseStablePrice = group.toUiPrice(
const baseStablePrice = Group.toUiPrice(
group,
I80F48.fromNumber(baseBank!.stablePriceModel.stablePrice),
baseBank!.mintDecimals,
)
const quoteStablePrice = group.toUiPrice(
const quoteStablePrice = Group.toUiPrice(
group,
I80F48.fromNumber(quoteBank!.stablePriceModel.stablePrice),
quoteBank!.mintDecimals,
)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"dependencies": {
"@blockworks-foundation/mango-feeds": "0.1.7",
"@blockworks-foundation/mango-mints-redemption": "^0.0.10",
"@blockworks-foundation/mango-v4": "0.33.4",
"@blockworks-foundation/mango-v4": "0.33.5",
"@blockworks-foundation/mango-v4-settings": "0.14.24",
"@blockworks-foundation/mangolana": "0.1.1",
"@headlessui/react": "1.6.6",
Expand Down
11 changes: 9 additions & 2 deletions pages/dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
PriceImpact,
OracleProvider,
toUiDecimalsForQuote,
Group,
} from '@blockworks-foundation/mango-v4'
import ExplorerLink from '@components/shared/ExplorerLink'
import { BorshAccountsCoder } from '@coral-xyz/anchor'
Expand Down Expand Up @@ -387,7 +388,8 @@ const Dashboard: NextPage = () => {
/>
<KeyValuePair
label="Stable Price"
value={`$${group.toUiPrice(
value={`$${Group.toUiPrice(
group,
I80F48.fromNumber(
perpMarket.stablePriceModel.stablePrice,
),
Expand Down Expand Up @@ -639,6 +641,10 @@ const Dashboard: NextPage = () => {
/>
}
/>
<KeyValuePair
label="Token Index"
value={market.marketIndex}
/>
<KeyValuePair
label="Base Token Index"
value={market.baseTokenIndex}
Expand Down Expand Up @@ -811,7 +817,8 @@ const BankDisclosure = ({
const subId = connection.onAccountChange(
bank.oracle,
async (info, context) => {
const { lastUpdatedSlot } = await group.decodePriceFromOracleAi(
const { lastUpdatedSlot } = await Group.decodePriceFromOracleAi(
group,
coder,
bank.oracle,
info,
Expand Down
3 changes: 2 additions & 1 deletion utils/governance/listingTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ export const getFormattedBankValues = (group: Group, bank: Bank) => {
publicKey: bank.publicKey.toBase58(),
vault: bank.vault.toBase58(),
oracle: bank.oracle.toBase58(),
stablePrice: group.toUiPrice(
stablePrice: Group.toUiPrice(
group,
I80F48.fromNumber(bank.stablePriceModel.stablePrice),
bank.mintDecimals,
),
Expand Down
65 changes: 54 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,10 @@
bn.js "^5.2.1"
eslint-config-prettier "^9.0.0"

"@blockworks-foundation/[email protected].4":
version "0.33.4"
resolved "https://registry.yarnpkg.com/@blockworks-foundation/mango-v4/-/mango-v4-0.33.4.tgz#11f17eb066e1e3456f93b67e67b2920ee9a2872c"
integrity sha512-ASsxGYoXTFIYx2ougn9OseUi/y8Vd+KZJ4tFknhB8VtfV8RQ8iTcDVaaVhyZ6zfLJ2D0JBcwFS/DIfY7kzQKug==
"@blockworks-foundation/[email protected].5":
version "0.33.5"
resolved "https://registry.yarnpkg.com/@blockworks-foundation/mango-v4/-/mango-v4-0.33.5.tgz#56ff1c3d6120acfb1abc6af937017b2517ee2348"
integrity sha512-MNACUyUpWlLRDh4EAYdXaPlioQYaN2wBsn2gLfvJllTsmyWq4CDCUZv6gtvcTe9XFxxLQpzMBrgm7nADmzCEHQ==
dependencies:
"@blockworks-foundation/mango-v4-settings" "0.14.24"
"@blockworks-foundation/mangolana" "0.1.0"
Expand Down Expand Up @@ -491,7 +491,7 @@
resolved "https://registry.yarnpkg.com/@contentful/rich-text-types/-/rich-text-types-16.3.4.tgz#c5fc9c834dde03d4c4ee189900d304ce1888a74b"
integrity sha512-PyVSrQa5j1hO4grgA0Ivo/taiOvW0uFN79JB5JkTG8U7DnWGI7Ap2As6zN6/E6YvDqb7w2cYRMSGSQ3qfxu8HQ==

"@coral-xyz/anchor-30@npm:@coral-xyz/[email protected]", "switchboard-anchor@npm:@coral-xyz/[email protected]":
"@coral-xyz/anchor-30@npm:@coral-xyz/[email protected]":
version "0.30.1"
resolved "https://registry.yarnpkg.com/@coral-xyz/anchor/-/anchor-0.30.1.tgz#17f3e9134c28cd0ea83574c6bab4e410bcecec5d"
integrity sha512-gDXFoF5oHgpriXAaLpxyWBHdCs8Awgf/gLHIo6crv7Aqm937CNdY+x+6hoj7QR5vaJV7MxWSQ0NGFzL3kPbWEQ==
Expand Down Expand Up @@ -12763,8 +12763,7 @@ string-length@^4.0.1:
char-regex "^1.0.2"
strip-ansi "^6.0.0"

"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
name string-width-cjs
"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand All @@ -12782,6 +12781,15 @@ string-width@^1.0.1:
is-fullwidth-code-point "^1.0.0"
strip-ansi "^3.0.0"

"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^3.0.0, string-width@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961"
Expand Down Expand Up @@ -12884,8 +12892,7 @@ stringify-entities@^4.0.0:
character-entities-html4 "^2.0.0"
character-entities-legacy "^3.0.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
name strip-ansi-cjs
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand All @@ -12906,6 +12913,13 @@ strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0:
dependencies:
ansi-regex "^4.1.0"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^7.0.1:
version "7.1.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
Expand Down Expand Up @@ -13027,6 +13041,27 @@ supports-preserve-symlinks-flag@^1.0.0:
resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09"
integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==

"switchboard-anchor@npm:@coral-xyz/[email protected]":
version "0.30.1"
resolved "https://registry.yarnpkg.com/@coral-xyz/anchor/-/anchor-0.30.1.tgz#17f3e9134c28cd0ea83574c6bab4e410bcecec5d"
integrity sha512-gDXFoF5oHgpriXAaLpxyWBHdCs8Awgf/gLHIo6crv7Aqm937CNdY+x+6hoj7QR5vaJV7MxWSQ0NGFzL3kPbWEQ==
dependencies:
"@coral-xyz/anchor-errors" "^0.30.1"
"@coral-xyz/borsh" "^0.30.1"
"@noble/hashes" "^1.3.1"
"@solana/web3.js" "^1.68.0"
bn.js "^5.1.2"
bs58 "^4.0.1"
buffer-layout "^1.2.2"
camelcase "^6.3.0"
cross-fetch "^3.1.5"
crypto-hash "^1.3.0"
eventemitter3 "^4.0.7"
pako "^2.0.3"
snake-case "^3.0.4"
superstruct "^0.15.4"
toml "^3.0.0"

symbol-tree@^3.2.4:
version "3.2.4"
resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2"
Expand Down Expand Up @@ -14341,8 +14376,7 @@ word-wrap@^1.2.5:
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.5.tgz#d2c45c6dd4fbce621a66f136cbe328afd0410b34"
integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
name wrap-ansi-cjs
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand All @@ -14369,6 +14403,15 @@ wrap-ansi@^6.0.1:
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
Expand Down

0 comments on commit 73d70df

Please sign in to comment.