order amount bugfix
This commit is contained in:
@@ -2,8 +2,10 @@
|
||||
<order title="Ladder" subtitle="Multiple price levels" :tranches="buildTranches" :valid="validOrder">
|
||||
<limit-price :required="true" label="start price" :show-price="false"/>
|
||||
<limit-price store-var="limitPrice2" :required="true" label="end price"/>
|
||||
<v-text-field label='Parts' type="number" step="1" aria-valuemin="0" min="1" variant="outlined"
|
||||
v-model="num" />
|
||||
<v-text-field label="Tranches" type="number" variant="outlined" aria-valuemin="1" min="1" max="255"
|
||||
v-model="os.tranches" :rules="[validateRequired,validateTranches]">
|
||||
<template v-slot:append-inner>tranches</template>
|
||||
</v-text-field>
|
||||
<v-text-field label='Skew' type="number" step="10" aria-valuemin="0" min="-100" max="100" variant="outlined"
|
||||
v-model="skew" clearable @click:clear="skew=0" suffix="%"/>
|
||||
<!-- todo deadline -->
|
||||
@@ -27,16 +29,16 @@ import {useOrderStore} from "@/store/store";
|
||||
import LimitPrice from "@/components/LimitPrice.vue";
|
||||
import Order from "@/components/Order.vue";
|
||||
import {computed, ref} from "vue";
|
||||
import {newTimeConstraint, TimeMode} from "@/blockchain/orderlib.js";
|
||||
import {limitConstraint, maxFraction} from "@/orderbuild.js";
|
||||
import {validateMax} from "@/validate.js";
|
||||
import {validateRequired, validateTranches} from "@/validate.js";
|
||||
|
||||
const os = useOrderStore()
|
||||
|
||||
const num = ref(3)
|
||||
const skew = ref(0)
|
||||
const rungs = computed(()=>{
|
||||
const n = num.value;
|
||||
if( !os.limitPrice || !os.limitPrice2 )
|
||||
return []
|
||||
const n = os.tranches;
|
||||
const a = parseFloat(os.limitPrice);
|
||||
const b = parseFloat(os.limitPrice2);
|
||||
if( n < 1 || !a || !b ) return []
|
||||
@@ -52,7 +54,7 @@ const rungsFmt = computed(()=>{
|
||||
return rungs.value.map((r)=>r.toPrecision(5)) // todo precisions
|
||||
})
|
||||
const fractions = computed(()=>{
|
||||
const n = num.value
|
||||
const n = os.tranches
|
||||
const s = skew.value / 100
|
||||
const result = []
|
||||
if( s === 1 ) {
|
||||
@@ -72,11 +74,11 @@ const fractions = computed(()=>{
|
||||
}
|
||||
return result
|
||||
})
|
||||
const amounts = computed( ()=>fractions.value.map((f)=>f*os.amount) )
|
||||
const amounts = computed( ()=>fractions.value.map((f)=>f*os.totalAmount) )
|
||||
|
||||
function buildTranches() {
|
||||
const ts = []
|
||||
const n = num.value
|
||||
const n = os.tranches
|
||||
const mf = Number(maxFraction)
|
||||
for( let i=0; i<n; i++ ) {
|
||||
// todo optional deadline
|
||||
|
||||
@@ -20,19 +20,16 @@
|
||||
|
||||
<script setup>
|
||||
import {useOrderStore, useStore} from "@/store/store";
|
||||
import {computed, ref} from "vue";
|
||||
import PhoneCard from "@/components/PhoneCard.vue";
|
||||
import Amount from "@/components/Amount.vue"
|
||||
// noinspection ES6UnusedImports
|
||||
import {routeInverted, SingletonCoroutine, vAutoSelect} from "@/misc.js";
|
||||
import {newLimitConstraint, newOrder, newTimeConstraint, TimeMode} from "@/blockchain/orderlib.js";
|
||||
import {newOrder} from "@/blockchain/orderlib.js";
|
||||
import {FixedNumber} from "ethers";
|
||||
import {pendOrder} from "@/blockchain/wallet.js";
|
||||
import NeedsProvider from "@/components/NeedsProvider.vue";
|
||||
import RoutePrice from "@/components/RoutePrice.vue";
|
||||
import router from "@/router/index.js";
|
||||
import PairChoice from "@/components/PairChoice.vue";
|
||||
import {isEmpty, validateAmount, validateRequired} from "@/validate.js";
|
||||
|
||||
const s = useStore()
|
||||
const os = useOrderStore()
|
||||
@@ -44,7 +41,7 @@ function placeOrder() {
|
||||
const tokenIn = os.buy ? tb.address : ta.address
|
||||
const tokenOut = os.buy ? ta.address : tb.address
|
||||
const route = os.route
|
||||
const amt = FixedNumber.fromString(os.amount.toString(), {decimals: os.amountToken.decimals}).value
|
||||
const amt = FixedNumber.fromString(os.totalAmount.toString(), {decimals: os.amountToken.decimals}).value
|
||||
const ts = props.tranches()
|
||||
const order = newOrder(tokenIn, tokenOut, route.exchange, route.fee, amt, os.amountIsInput, ts)
|
||||
pendOrder(order)
|
||||
|
||||
Reference in New Issue
Block a user