LadderOrder submission works
This commit is contained in:
@@ -29,8 +29,9 @@ import {useOrderStore} from "@/store/store";
|
||||
import LimitPrice from "@/components/LimitPrice.vue";
|
||||
import Order from "@/components/Order.vue";
|
||||
import {computed, ref} from "vue";
|
||||
import {applyLimit, maxFraction} from "@/orderbuild.js";
|
||||
import {applyLimit} from "@/orderbuild.js";
|
||||
import {validateRequired, validateTranches} from "@/validate.js";
|
||||
import {MAX_FRACTION, newTranche} from "@/blockchain/orderlib.js";
|
||||
|
||||
const os = useOrderStore()
|
||||
|
||||
@@ -79,12 +80,12 @@ const amounts = computed( ()=>fractions.value.map((f)=>f*os.totalAmount) )
|
||||
function buildTranches() {
|
||||
const ts = []
|
||||
const n = os.tranches
|
||||
const mf = Number(maxFraction)
|
||||
for( let i=0; i<n; i++ ) {
|
||||
// todo optional deadline
|
||||
const cs = [applyLimit(rungs.value[i])]
|
||||
const fraction = Math.min(mf, Math.ceil(mf * fractions.value[i]) )
|
||||
ts.push([fraction, cs])
|
||||
const fraction = Math.min(MAX_FRACTION, Math.ceil(MAX_FRACTION * fractions.value[i]) )
|
||||
const tranche = newTranche({fraction})
|
||||
applyLimit(tranche, rungs.value[i])
|
||||
ts.push(tranche)
|
||||
}
|
||||
return ts
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {routeInverted} from "@/misc.js";
|
||||
import {MAX_FRACTION, newTranche} from "@/blockchain/orderlib.js";
|
||||
import {useOrderStore} from "@/store/store.js";
|
||||
import {encodeIEE754} from "@/blockchain/common.js";
|
||||
|
||||
|
||||
export function applyLimit(tranche, price=null) {
|
||||
@@ -15,7 +16,7 @@ export function applyLimit(tranche, price=null) {
|
||||
const isAbove = os.limitIsMinimum ^ inverted
|
||||
const isRatio = false // todo ratios
|
||||
const decimals = 10 ** (os.tokenA.decimals - os.tokenB.decimals)
|
||||
const limit = inverted ? decimals / price : price / decimals
|
||||
const limit = encodeIEE754(inverted ? decimals / price : price / decimals)
|
||||
tranche.marketOrder = false;
|
||||
if( isAbove ) {
|
||||
tranche.minIntercept = limit;
|
||||
|
||||
Reference in New Issue
Block a user