Merge branch 'main' of github.com:blockworks-foundation/mango-ui-v3 into kierangillen/wallet-updates

This commit is contained in:
Kieran Gillen 2022-03-28 18:22:13 +02:00
commit 6da4d5f76f
10 changed files with 37 additions and 29 deletions

View File

@ -24,7 +24,6 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: yarn install --frozen-lockfile
- run: yarn type-check
- run: yarn lint

View File

@ -109,10 +109,7 @@ export const FiveOhFive = ({ error }) => {
</div>
</main>
<footer className="mx-auto w-full max-w-7xl px-4 sm:px-6 lg:px-8">
<div className="border-t border-gray-200 py-12 text-center md:flex md:justify-between">
<p className="text-base text-gray-400">
&copy; Workflow, Inc. All rights reserved.
</p>
<div className="border-t border-gray-200 py-10 text-center md:flex md:justify-between">
<div className="mt-6 flex justify-center space-x-8 md:mt-0">
{social.map((item, itemIdx) => (
<a

View File

@ -106,11 +106,11 @@ const MarketDetails = () => {
{t('average-funding')}
</div>
<div className="text-th-fgd-1 md:text-xs">
{`${market?.funding1h.toLocaleString(undefined, {
maximumSignificantDigits: 3,
})}% (${(market?.funding1h * 24 * 365).toFixed(
2
)}% APR)`}
{`${market?.funding1h.toFixed(4)}% (${(
market?.funding1h *
24 *
365
).toFixed(2)}% APR)`}
</div>
</div>
</Tooltip>

View File

@ -53,7 +53,6 @@ const TVChartContainer = () => {
const selectedMarketConfig = useMangoStore((s) => s.selectedMarket.config)
const openOrders = useMangoStore((s) => s.selectedMangoAccount.openOrders)
const actions = useMangoStore((s) => s.actions)
const selectedMarketPrice = useMangoStore((s) => s.selectedMarket.markPrice)
const isMobile = width ? width < breakpoints.sm : false
const mangoClient = useMangoStore.getState().connection.client
@ -353,12 +352,15 @@ const TVChartContainer = () => {
function drawLine(order, market) {
const orderSizeUi = roundPerpSize(order.size, market.config.baseSymbol)
if (!tvWidgetRef.current.chart()) return
return tvWidgetRef.current
.chart()
.createOrderLine({ disableUndo: false })
.onMove(function () {
const currentOrderPrice = order.price
const updatedOrderPrice = this.getPrice()
const selectedMarketPrice =
useMangoStore.getState().selectedMarket.markPrice
if (!order.perpTrigger?.clientOrderId) {
if (
(order.side === 'buy' &&

View File

@ -4,8 +4,10 @@ import Input from 'components/Input'
import { useRouter } from 'next/router'
import React, { useState } from 'react'
import { ExclamationCircleIcon } from '@heroicons/react/outline'
import { useTranslation } from 'next-i18next'
export const MangoAccountSearch = () => {
export const MangoAccountLookup = () => {
const { t } = useTranslation('common')
const router = useRouter()
const [value, setValue] = useState('')
const [isInvalid, setIsInvalid] = useState(false)
@ -33,10 +35,8 @@ export const MangoAccountSearch = () => {
return (
<div className="flex flex-col items-center rounded-lg px-4 text-th-fgd-1">
<h2 className="mb-1 text-base">Search by Mango Account</h2>
<p className="mb-2 text-center">
Enter a Mango account address to show account details
</p>
<h2 className="mb-1 text-base">{t('mango-account-lookup-title')}</h2>
<p className="mb-2 text-center">{t('mango-account-lookup-desc')}</p>
<div className="w-[350px] p-1 md:w-[400px]">
<Input
type="text"
@ -49,11 +49,11 @@ export const MangoAccountSearch = () => {
{isInvalid && (
<div className="flex items-center pt-1.5 text-th-red">
<ExclamationCircleIcon className="mr-1.5 h-4 w-4" />
The address is invalid
{t('invalid-address')}
</div>
)}
<div className="pt-3 pb-2">
<Button onClick={onClickSearch}>Search</Button>
<Button onClick={onClickSearch}>{t('view')}</Button>
</div>
</div>
)

View File

@ -39,19 +39,23 @@ export const collectPerpPosition = (
let avgEntryPrice = 0,
breakEvenPrice = 0
const perpTradeHistory = tradeHistory.filter(
(t) => t.marketName === marketConfig.name
)
try {
const perpTradeHistory = tradeHistory.filter(
(t) => t.marketName === marketConfig.name
)
avgEntryPrice = perpAccount
.getAverageOpenPrice(mangoAccount, perpMarket, perpTradeHistory)
.toNumber()
} catch (e) {
console.error(marketConfig.name, e)
}
try {
breakEvenPrice = perpAccount
.getBreakEvenPrice(mangoAccount, perpMarket, perpTradeHistory)
.toNumber()
} catch (e) {
// console.error(e)
console.error(marketConfig.name, e)
}
const basePosition = perpMarket?.baseLotsToNumber(perpAccount.basePosition)
@ -92,6 +96,7 @@ const usePerpPositions = () => {
const mangoCache = useMangoStore(mangoCacheSelector)
const allMarkets = useMangoStore(marketsSelector)
const tradeHistory = useMangoStore((s) => s.tradeHistory.parsed)
useEffect(() => {
if (
mangoAccount &&

View File

@ -16,7 +16,7 @@
"lint-all": "yarn lint && yarn type-check"
},
"dependencies": {
"@blockworks-foundation/mango-client": "git+https://github.com/blockworks-foundation/mango-client-v3.git#update-wallet-type",
"@blockworks-foundation/mango-client": "^3.3.27",
"@headlessui/react": "^0.0.0-insiders.2dbc38c",
"@heroicons/react": "^1.0.0",
"@jup-ag/react-hook": "^1.0.0-beta.16",

View File

@ -53,7 +53,7 @@ import DelegateModal from 'components/DelegateModal'
import { Menu, Transition } from '@headlessui/react'
import { useWallet } from '@solana/wallet-adapter-react'
import { handleWalletConnect } from 'components/ConnectWalletButton'
import { MangoAccountSearch } from 'components/account_page/MangoAccountSearch'
import { MangoAccountLookup } from 'components/account_page/MangoAccountLookup'
export async function getStaticProps({ locale }) {
return {
@ -449,7 +449,7 @@ export default function Account() {
</div>
{!connected && (
<div className="mt-6 md:mt-3 md:rounded-lg md:bg-th-bkg-2 md:p-6">
<MangoAccountSearch />
<MangoAccountLookup />
</div>
)}
</PageBodyContainer>

View File

@ -178,6 +178,7 @@
"intro-feature-2": "All assets count as collateral to trade or borrow",
"intro-feature-3": "Deposit any asset and earn interest automatically",
"intro-feature-4": "Borrow against your assets for other DeFi activities",
"invalid-address": "The address is invalid",
"ioc": "IOC",
"languages-tip-desc": "Choose another language here. More coming soon...",
"languages-tip-title": "Multilingual?",
@ -206,6 +207,8 @@
"maker-fee": "Maker Fee",
"mango": "Mango",
"mango-accounts": "Mango Accounts",
"mango-account-lookup-desc": "Enter a Mango account address to show account details",
"mango-account-lookup-title": "View a Mango Account",
"margin": "Margin",
"margin-available": "Margin Available",
"market": "Market",
@ -420,6 +423,7 @@
"v3-unaudited": "The V3 protocol is in public beta. This is unaudited software, use it at your own risk.",
"v3-welcome": "Welcome to Mango",
"value": "Value",
"view": "View",
"view-all-trades": "View all trades in the Account page",
"view-counterparty": "View Counterparty",
"view-transaction": "View Transaction",

View File

@ -1001,9 +1001,10 @@
"@babel/helper-validator-identifier" "^7.16.7"
to-fast-properties "^2.0.0"
"@blockworks-foundation/mango-client@git+https://github.com/blockworks-foundation/mango-client-v3.git#update-wallet-type":
version "3.3.25"
resolved "git+https://github.com/blockworks-foundation/mango-client-v3.git#bada6221280b35dcdb8bf64225091bebb3e68f60"
"@blockworks-foundation/mango-client@^3.3.27":
version "3.3.27"
resolved "https://registry.yarnpkg.com/@blockworks-foundation/mango-client/-/mango-client-3.3.27.tgz#a3133bf2073e0b211b5133290deed2f9d18ee1cf"
integrity sha512-P3StybDO57Tg288BxxEfIs2SEC//55eHogwoJ9hAcX0gmHOxzrW3uTodSMRFV1h6S5dgxCqMRCqWPF946401vQ==
dependencies:
"@project-serum/anchor" "^0.21.0"
"@project-serum/serum" "0.13.55"