Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick fix: Switch estimated profitability time #537

Merged
merged 1 commit into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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