tranche tweaks

This commit is contained in:
Tim Olson
2023-12-09 00:59:49 -04:00
parent 7e33ffba76
commit f5fe0a45b7
2 changed files with 13 additions and 11 deletions

View File

@@ -37,6 +37,7 @@
</template> </template>
<template v-slot:expanded-row="{item}"> <template v-slot:expanded-row="{item}">
<tr> <tr>
<td>&nbsp;</td>
<td colspan="100"> <td colspan="100">
<v-table> <v-table>
<!-- <!--
@@ -50,8 +51,8 @@
--> -->
<tbody> <tbody>
<tr v-for="(t, i) in item.order.tranches"> <tr v-for="(t, i) in item.order.tranches">
<td>Tranche {{ i + 1 }}</td> <td class="text-right">Tranche {{ i + 1 }}</td>
<td> <td class="text-center w-33">
<suspense> <suspense>
<span> <span>
<token-amount :addr="item.amountToken" :amount="item.trancheFilled[i]" :raw="true"/> <token-amount :addr="item.amountToken" :amount="item.trancheFilled[i]" :raw="true"/>
@@ -60,10 +61,11 @@
</span> </span>
</suspense> </suspense>
</td> </td>
<td> <td class="text-left">
{{describeTrancheTime(item,t)}} <span class="mx-3">{{ describeTrancheTime(item, true, t) }}</span>
{{describeTrancheLine(item,true,t.minIntercept,t.minSlope)}} <span class="mx-3">{{ describeTrancheTime(item, false, t) }}</span>
{{describeTrancheLine(item,false,t.maxIntercept,t.maxSlope)}} <span class="mx-3">{{ describeTrancheLine(item, true, t.minIntercept, t.minSlope) }}</span>
<span class="mx-3">{{ describeTrancheLine(item, false, t.maxIntercept, t.maxSlope) }}</span>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@@ -225,22 +227,20 @@ const orders = computed(()=>{
return result return result
}) })
function describeTrancheTime(st, t) { function describeTrancheTime(st, isStart, t) {
let result = '' let result = ''
if( t.minIsBarrier || t.maxIsBarrier ) if( t.minIsBarrier || t.maxIsBarrier )
return 'barrier' return 'barrier'
if( t.startTime > 0 ) { if( isStart && t.startTime > 0 ) {
const started = t.startTimeIsRelative ? st.start + t.startTime : t.startTime const started = t.startTimeIsRelative ? st.start + t.startTime : t.startTime
console.log('started', started, st.start, t.startTime)
result += started*1000 < Date.now() ? 'Activated ' : 'Activates ' result += started*1000 < Date.now() ? 'Activated ' : 'Activates '
result += dateString(started) + ' ' result += dateString(started) + ' '
} }
if( t.endTime < 4294967295 ) { if( !isStart && t.endTime < 4294967295 ) {
const ended = t.endTimeIsRelative ? st.start + t.endTime : t.endTime const ended = t.endTimeIsRelative ? st.start + t.endTime : t.endTime
result += ended*1000 < Date.now() ? 'Expired ' : 'Expires ' result += ended*1000 < Date.now() ? 'Expired ' : 'Expires '
result += dateString(ended) result += dateString(ended)
} }
console.log('tt', st, t)
return result return result
} }

View File

@@ -45,6 +45,8 @@ export function timesliceTranches() {
} else { } else {
window = Math.round(duration / n) window = Math.round(duration / n)
} }
if( window < 60 )
window = 60
const amtPerTranche = Math.ceil(MAX_FRACTION / n) const amtPerTranche = Math.ceil(MAX_FRACTION / n)
duration -= 15 // subtract 15 seconds so the last tranche completes before the deadline duration -= 15 // subtract 15 seconds so the last tranche completes before the deadline
for (let i = 0; i < n; i++) { for (let i = 0; i < n; i++) {