price handling fixes affecting orderbuild, pairprice, ordershapes, etc
This commit is contained in:
@@ -38,13 +38,13 @@ const pair = computed(() => {
|
||||
function pairPrice(chainId, baseToken, quoteToken, price) {
|
||||
if (price === null || price === undefined)
|
||||
return null
|
||||
const decimals = baseToken.d - quoteToken.d
|
||||
const decimals = quoteToken.d - baseToken.d
|
||||
// console.log('pairPrice', chainId, baseToken, quoteToken, price, decimals)
|
||||
// console.log('adjusted pairPrice', price)
|
||||
if (decimals >= 0)
|
||||
price /= 10 ** decimals
|
||||
else
|
||||
price *= 10 ** -decimals
|
||||
// console.log('adjusted pairPrice', price)
|
||||
if (inversionPreference(chainId, baseToken, quoteToken))
|
||||
price = 1 / price
|
||||
// console.log('inverted?', price)
|
||||
|
||||
@@ -97,11 +97,11 @@
|
||||
<line-price class="mx-3" v-if="!t.marketOrder"
|
||||
:base="item.order.tokenIn" :quote="item.order.tokenOut"
|
||||
:b="t.minLine.intercept" :m="t.minLine.slope" :is-min="true"
|
||||
:show-btn="false"/>
|
||||
:show-btn="true"/>
|
||||
<line-price class="mx-3" v-if="!t.marketOrder"
|
||||
:base="item.order.tokenIn" :quote="item.order.tokenOut"
|
||||
:b="t.maxLine.intercept" :m="t.maxLine.slope" :is-min="false"
|
||||
:show-btn="false"/>
|
||||
:show-btn="true"/>
|
||||
</div>
|
||||
|
||||
</td>
|
||||
|
||||
@@ -156,7 +156,7 @@ const maxAmount = computed(()=>{
|
||||
return null
|
||||
const balance = s.balances[token.a]
|
||||
if( !balance )
|
||||
return 0
|
||||
return null
|
||||
const divisor = os.amountIsTotal ? 1 : os.tranches
|
||||
return balance / 10**token.d / divisor
|
||||
})
|
||||
@@ -165,7 +165,7 @@ const available = computed(()=>{
|
||||
return max === null ? '' : `Available: ${maxAmount.value} ${tokenIn.value.s}`
|
||||
})
|
||||
|
||||
const lastMaxValue = ref(null)
|
||||
const lastMaxValue = ref(-1)
|
||||
|
||||
function setMax() {
|
||||
let amount = maxAmount.value
|
||||
|
||||
Reference in New Issue
Block a user