Skip to content

Commit 00099b3

Browse files
authored
Merge pull request #79 from compolabs/fix/816
[816] Correct error logic
2 parents 1f9bd0f + 71b6952 commit 00099b3

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

spark-frontend/src/screens/TradeScreen/LeftBlock/CreateOrderSpot/CreateOrderSpot.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ const CreateOrderSpot: React.FC<IProps> = observer(({ ...rest }) => {
141141
amount={vm.inputAmount}
142142
assetId={baseToken.assetId}
143143
decimals={baseToken.decimals}
144-
error={vm.isSell ? vm.inputTotalError : undefined}
144+
error={vm.isSell ? vm.isInputError : undefined}
145145
label="Order size"
146146
setAmount={(v) => vm.setInputAmount(v, true)}
147147
onBlur={vm.setActiveInput}
@@ -157,7 +157,7 @@ const CreateOrderSpot: React.FC<IProps> = observer(({ ...rest }) => {
157157
amount={vm.inputTotal}
158158
assetId={quoteToken.assetId}
159159
decimals={quoteToken.decimals}
160-
error={vm.isSell ? undefined : vm.inputTotalError}
160+
error={vm.isSell ? undefined : vm.isInputError}
161161
setAmount={(v) => vm.setInputTotal(v, true)}
162162
onBlur={vm.setActiveInput}
163163
onFocus={() => vm.setActiveInput(ACTIVE_INPUT.Total)}

spark-frontend/src/screens/TradeScreen/LeftBlock/CreateOrderSpot/CreateOrderSpotVM.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ class CreateOrderSpotVM {
8484
this.inputPrice.eq(BN.ZERO) &&
8585
this.activeInput !== ACTIVE_INPUT.Price
8686
) {
87-
console.log(orderType === ORDER_TYPE.Limit, this.inputPrice.eq(BN.ZERO), this.activeInput);
8887
this.setInputPriceDebounce(price);
8988
}
9089
},
@@ -96,13 +95,15 @@ class CreateOrderSpotVM {
9695
}
9796

9897
get canProceed() {
99-
return this.inputAmount.gt(0) && this.inputPrice.gt(0) && this.inputTotal.gt(0) && !this.inputTotalError;
98+
return this.inputAmount.gt(0) && this.inputPrice.gt(0) && this.inputTotal.gt(0) && !this.isInputError;
10099
}
101100

102-
get inputTotalError(): boolean {
101+
get isInputError(): boolean {
103102
const { tradeStore, balanceStore } = this.rootStore;
103+
const { market } = tradeStore;
104104
const amount = this.isSell ? this.inputAmount : this.inputTotal;
105-
const balance = balanceStore.getBalance(tradeStore.market!.quoteToken.assetId);
105+
const token = this.isSell ? market!.baseToken.assetId : market!.quoteToken.assetId;
106+
const balance = balanceStore.getBalance(token);
106107
return balance ? amount.gt(balance) : false;
107108
}
108109

@@ -151,7 +152,6 @@ class CreateOrderSpotVM {
151152
const formattedAmount = BN.formatUnits(this.inputAmount, tradeStore.market!.baseToken.decimals);
152153
const formattedTotal = BN.formatUnits(this.inputTotal, tradeStore.market!.quoteToken.decimals);
153154

154-
console.log(this.activeInput === ACTIVE_INPUT.Price);
155155
if (this.activeInput === ACTIVE_INPUT.Amount || this.activeInput === ACTIVE_INPUT.Price) {
156156
const total = BN.parseUnits(formattedAmount.times(formattedPrice), tradeStore.market!.quoteToken.decimals);
157157
this.setInputTotal(total);

0 commit comments

Comments
 (0)