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