Skip to content

Commit

Permalink
fix: Show correct gross profit date when the callee is switched (#537)
Browse files Browse the repository at this point in the history
  • Loading branch information
aomafarag authored Nov 15, 2022
1 parent ba4c763 commit 3dc430a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<div class="flex w-full justify-between">
<div>Estimated Profitability Time</div>
<div class="RightInfo">
<time-till-profitable :auction="auctionTransaction" />
<TimeTillProfitable :auction="auctionTransaction" :market-id="currentMarketId" />
</div>
</div>
<div class="flex w-full justify-between">
Expand Down
29 changes: 23 additions & 6 deletions frontend/components/auction/collateral/TimeTillProfitable.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div>
<div v-if="auction.transactionGrossProfitDate">
<time-till v-if="isProfitableBeforeEnding" :date="auction.transactionGrossProfitDate" />
<div v-if="transactionGrossProfitDate">
<time-till v-if="isProfitableBeforeEnding" :date="transactionGrossProfitDate" />
<div v-else>Likely will not be profitable</div>
</div>
<div v-else-if="isAlreadyProfitable">Auction is profitable</div>
Expand All @@ -11,6 +11,7 @@

<script lang="ts">
import Vue from 'vue';
import BigNumber from 'bignumber.js';
import { AuctionTransaction } from 'auctions-core/src/types';
import TimeTill from '~/components/common/formatters/TimeTill.vue';
Expand All @@ -23,19 +24,35 @@ export default Vue.extend({
type: Object as Vue.PropType<AuctionTransaction>,
required: true,
},
marketId: {
type: String,
default: '',
},
},
computed: {
transactionGrossProfitDate(): Date | undefined {
if (!this.marketId || !this.auction.marketDataRecords) {
return this.auction.transactionGrossProfitDate;
}
return this.auction.marketDataRecords[this.marketId].transactionGrossProfitDate;
},
marketUnitPrice(): BigNumber | undefined {
if (!this.marketId || !this.auction.marketDataRecords) {
return this.auction.marketUnitPrice;
}
return this.auction.marketDataRecords[this.marketId].marketUnitPrice;
},
isProfitableBeforeEnding(): boolean {
if (!this.auction.transactionGrossProfitDate) {
if (!this.transactionGrossProfitDate) {
return false;
}
return this.auction.endDate > this.auction.transactionGrossProfitDate;
return this.auction.endDate > this.transactionGrossProfitDate;
},
isAlreadyProfitable(): boolean {
if (!this.auction.marketUnitPrice) {
if (!this.marketUnitPrice) {
return false;
}
return this.auction.approximateUnitPrice.isLessThan(this.auction.marketUnitPrice);
return this.auction.approximateUnitPrice.isLessThan(this.marketUnitPrice);
},
},
});
Expand Down

0 comments on commit 3dc430a

Please sign in to comment.