price handling fixes affecting orderbuild, pairprice, ordershapes, etc

This commit is contained in:
tim
2024-10-13 18:28:01 -04:00
parent 4b5626094a
commit fe8dd3ef6c
8 changed files with 16 additions and 17 deletions

View File

@@ -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)

View File

@@ -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>

View File

@@ -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