fix trustless registers + prettier fix (#215)

This commit is contained in:
Adrian Brzeziński 2023-07-22 14:36:22 +02:00 committed by GitHub
parent 9b1c111270
commit 2ee8b708ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 42 additions and 52 deletions

View File

@ -1,4 +1,5 @@
{
"semi": false,
"singleQuote": true
"singleQuote": true,
"trailingComma": "all"
}

View File

@ -102,7 +102,7 @@ let marketType: 'spot' | 'perp'
export const queryPerpBars = async (
tokenAddress: string,
resolution: (typeof SUPPORTED_RESOLUTIONS)[number],
resolution: typeof SUPPORTED_RESOLUTIONS[number],
periodParams: {
firstDataRequest: boolean
from: number
@ -150,7 +150,7 @@ export const queryPerpBars = async (
export const queryBirdeyeBars = async (
tokenAddress: string,
resolution: (typeof SUPPORTED_RESOLUTIONS)[number],
resolution: typeof SUPPORTED_RESOLUTIONS[number],
periodParams: {
firstDataRequest: boolean
from: number

View File

@ -66,7 +66,7 @@ const configurationData = {
export const queryBars = async (
tokenAddress: string,
resolution: (typeof SUPPORTED_RESOLUTIONS)[number],
resolution: typeof SUPPORTED_RESOLUTIONS[number],
periodParams: {
firstDataRequest: boolean
from: number

View File

@ -52,12 +52,9 @@ const Layout = ({ children }: { children: ReactNode }) => {
const animationFrames = 15
for (let x = 1; x <= animationFrames; x++) {
setTimeout(
() => {
setTimeout(() => {
window.dispatchEvent(new Event('resize'))
},
(sideBarAnimationDuration / animationFrames) * x,
)
}, (sideBarAnimationDuration / animationFrames) * x)
}
}, [isCollapsed])

View File

@ -38,23 +38,17 @@ const HydrateStore = () => {
actions.fetchGroup()
}, [marketName])
useInterval(
() => {
useInterval(() => {
actions.fetchGroup()
},
(slowNetwork ? 40 : 20) * SECONDS,
)
}, (slowNetwork ? 40 : 20) * SECONDS)
// refetches open orders every 30 seconds
// only the selected market's open orders are updated via websocket
useInterval(
() => {
useInterval(() => {
if (mangoAccountAddress) {
actions.fetchOpenOrders()
}
},
(slowNetwork ? 60 : 30) * SECONDS,
)
}, (slowNetwork ? 60 : 30) * SECONDS)
// refetch trade history and activity feed when switching accounts
useEffect(() => {
@ -65,13 +59,10 @@ const HydrateStore = () => {
}, [mangoAccountAddress])
// reload and parse market fills from the event queue
useInterval(
async () => {
useInterval(async () => {
const actions = mangoStore.getState().actions
actions.loadMarketFills()
},
(slowNetwork ? 60 : 20) * SECONDS,
)
}, (slowNetwork ? 60 : 20) * SECONDS)
// The websocket library solana/web3.js uses closes its websocket connection when the subscription list
// is empty after opening its first time, preventing subsequent subscriptions from receiving responses.

View File

@ -492,7 +492,7 @@ const ListToken = ({ goBack }: { goBack: () => void }) => {
.instruction()
proposalTx.push(editIx)
} else {
await client!.program.methods
const trustlessIx = await client!.program.methods
.tokenRegisterTrustless(Number(advForm.tokenIndex), advForm.name)
.accounts({
mint: new PublicKey(advForm.mintPk),
@ -503,6 +503,8 @@ const ListToken = ({ goBack }: { goBack: () => void }) => {
group: group!.publicKey,
})
.instruction()
proposalTx.push(trustlessIx)
}
const registerMarketix = await client!.program.methods

View File

@ -63,8 +63,8 @@ export default function useSelectedMarket() {
mangoTokens.find(
(t) => t.symbol.toLowerCase() === lowerCaseBaseSymbol,
) ||
mangoTokens.find(
(t) => t.symbol.toLowerCase()?.includes(lowerCaseBaseSymbol),
mangoTokens.find((t) =>
t.symbol.toLowerCase()?.includes(lowerCaseBaseSymbol),
)
if (token) {
return token.logoURI

View File

@ -840,10 +840,12 @@ const Dashboard: NextPage = () => {
4,
)} (maint leverage: ${(
1 /
(perpMarket.maintBaseLiabWeight.toNumber() - 1)
(perpMarket.maintBaseLiabWeight.toNumber() -
1)
).toFixed(2)}x, init leverage: ${(
1 /
(perpMarket.initBaseLiabWeight.toNumber() - 1)
(perpMarket.initBaseLiabWeight.toNumber() -
1)
).toFixed(2)}x)`}
/>
<KeyValuePair

View File

@ -85,7 +85,7 @@ export const getDeposits = async ({
...x,
mint: mints[mintCfgs![x.votingMintConfigIdx].mint.toBase58()],
index: idx,
}) as unknown as DepositWithMintAccount,
} as unknown as DepositWithMintAccount),
)
.filter((x) => typeof isUsed === 'undefined' || x.isUsed === isUsed)
const usedDeposits = deposits.filter((x) => x.isUsed)

View File

@ -7,10 +7,7 @@ export const DEFAULT_VSR_ID = new web3.PublicKey(
)
export class VsrClient {
constructor(
public program: Program<Idl>,
public devnet?: boolean,
) {}
constructor(public program: Program<Idl>, public devnet?: boolean) {}
static async connect(
provider: Provider,

View File

@ -6,7 +6,7 @@ export const ONE_HOUR_SECONDS = ONE_HOUR_MINS * ONE_MINUTE_SECONDS
export const ONE_DAY_SECONDS = ONE_HOUR_SECONDS * 24
export type BASE_CHART_QUERY = {
address: string
type: (typeof SUPPORTED_SPOT_RESOLUTIONS)[number]
type: typeof SUPPORTED_SPOT_RESOLUTIONS[number]
time_to: number
}
export type CHART_QUERY = BASE_CHART_QUERY & {
@ -16,7 +16,7 @@ export type CHART_QUERY = BASE_CHART_QUERY & {
//Translate values that api accepts to chart seconds
export const RES_NAME_TO_RES_VAL: {
[key: string]: {
val: (typeof SUPPORTED_SPOT_RESOLUTIONS)[number]
val: typeof SUPPORTED_SPOT_RESOLUTIONS[number]
seconds: number
}
} = {