Skip to content

Commit 86d2608

Browse files
fix limit orders parsing (#182)
1 parent dca3285 commit 86d2608

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

components/instructions/programs/manifest.tsx

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { AccountMetaData } from '@solana/spl-governance'
1616
import { Connection, PublicKey } from '@solana/web3.js'
1717
import { abbreviateAddress } from '@utils/formatting'
1818
import tokenPriceService from '@utils/services/tokenPrice'
19+
import { tryGetTokenMint } from '@utils/tokens'
1920
import { UiOpenOrder } from '@utils/uiTypes/manifest'
2021

2122
export type CancelOrderInstructionArgs = {
@@ -102,12 +103,36 @@ export const MANIFEST_INSTRUCTIONS = {
102103
const amount = params.baseAtoms
103104

104105
const side = params.isBid ? 'Buy' : 'Sell'
105-
const quoteTokenInfo = tokenPriceService.getTokenInfo(
106+
let quoteTokenInfo = tokenPriceService.getTokenInfo(
106107
accounts[15].pubkey.toBase58(),
107108
)
108-
const baseTokenInfo = tokenPriceService.getTokenInfo(
109+
let baseTokenInfo = tokenPriceService.getTokenInfo(
110+
accounts[10].pubkey.toBase58(),
111+
)
112+
console.log(
113+
accounts[15].pubkey.toBase58(),
109114
accounts[10].pubkey.toBase58(),
110115
)
116+
if (!baseTokenInfo) {
117+
const resp = await connection.getParsedAccountInfo(
118+
accounts[10].pubkey,
119+
)
120+
baseTokenInfo = {
121+
//@ts-ignore
122+
decimals: resp.value?.data.parsed.info.decimals,
123+
symbol: accounts[10].pubkey.toBase58(),
124+
} as any
125+
}
126+
if (!quoteTokenInfo) {
127+
const resp = await connection.getParsedAccountInfo(
128+
accounts[15].pubkey,
129+
)
130+
quoteTokenInfo = {
131+
//@ts-ignore
132+
decimals: resp.value?.data.parsed.info.decimals,
133+
symbol: accounts[15].pubkey.toBase58(),
134+
} as any
135+
}
111136

112137
const market = accounts[3].pubkey
113138

pages/dao/[symbol]/treasury/orders/index.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,16 @@ export default function Orders() {
11671167
</div>
11681168
<div
11691169
onClick={() => {
1170-
setSellAmount(uiAmount.toString())
1170+
setSellAmount(
1171+
toUiDecimals(
1172+
toNative(
1173+
uiAmount,
1174+
sellToken?.extensions.mint?.account.decimals ||
1175+
6,
1176+
).toNumber() - 1,
1177+
sellToken?.extensions.mint?.account.decimals || 6,
1178+
).toString(),
1179+
)
11711180
}}
11721181
className="text-xs cursor-pointer hover:text-primary-light"
11731182
>

0 commit comments

Comments
 (0)