Skip to content

Commit

Permalink
Merge pull request #205 from DeXter-on-Radix/fix-market-auto-amount
Browse files Browse the repository at this point in the history
fix market order input auto amount update
  • Loading branch information
EvgeniiaVak authored Dec 11, 2023
2 parents 3c92fe0 + 3cdb8ea commit 27cb9d6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@types/node": "20.3.3",
"@types/react": "18.2.14",
"@types/react-dom": "18.2.6",
"alphadex-sdk-js": "^0.12.5",
"alphadex-sdk-js": "^0.12.7",
"autoprefixer": "10.4.14",
"eslint-config-next": "13.4.7",
"lightweight-charts": "^4.0.1",
Expand Down
16 changes: 10 additions & 6 deletions src/app/state/orderInputSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,17 +415,21 @@ export const orderInputSlice = createSlice({

if (state.tab === OrderTab.MARKET) {
// MARKET
if (state.side === OrderSide.SELL) {
state.token2.amount = quote.toAmount;
} else {
state.token1.amount = quote.fromAmount;
}

// https://www.npmjs.com/package/alphadex-sdk-js#quoteresultmessages
if (quote.resultCode === 5 || quote.resultCode === 6) {
if (state.side === OrderSide.SELL) {
state.token1.amount = quote.fromAmount;
state.validationToken1.valid = false;
state.validationToken1.message = quote.resultMessageLong;
} else {
state.validationToken2.valid = false;
state.validationToken2.message = quote.resultMessageLong;
}
} else {
if (state.side === OrderSide.SELL) {
state.token2.amount = quote.toAmount;
} else {
state.token1.amount = quote.fromAmount;
}
}
} else {
Expand Down

0 comments on commit 27cb9d6

Please sign in to comment.