Skip to content
This repository has been archived by the owner on Jul 9, 2023. It is now read-only.

Commit

Permalink
fix negative contract cost on failed contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Apr 3, 2020
1 parent 5f036fe commit 311b41b
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/sync/contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function mergeContract(chain, sia) {
earned_revenue: new BigNumber(0),
lost_revenue: new BigNumber(0),
potential_revenue: new BigNumber(0),
unused: sia.datasize === 0,
proof_required: !new BigNumber(chain.valid_proof_outputs[1].value).eq(chain.missed_proof_outputs[1].value),
tags: []
};

Expand All @@ -146,7 +146,7 @@ function mergeContract(chain, sia) {
break;
case 'obligationfailed':
c.payout = new BigNumber(c.missed_proof_outputs[1].value);
c.returned_collateral = new BigNumber(c.missed_proof_outputs[1].value);
c.returned_collateral = new BigNumber(c.missed_proof_outputs[1].value).minus(c.contract_cost);
c.lost_revenue = new BigNumber(c.valid_proof_outputs[1].value).minus(sia.lockedcollateral)
.minus(c.transaction_fees);
c.burnt_collateral = new BigNumber(sia.lockedcollateral).minus(c.returned_collateral);
Expand Down Expand Up @@ -231,13 +231,7 @@ export async function parseHostContracts() {

addContractStats(stats, c);

if (c.unused) {
c.tags.push({
text: 'Unused'
});
}

if (c.proof_deadline < currentBlock.height && !c.unused && !c.proof_confirmed) {
if (c.proof_deadline < currentBlock.height && c.proof_required && !c.proof_confirmed) {
c.tags.push({
severity: 'severe',
text: 'Proof Not Submitted'
Expand Down

0 comments on commit 311b41b

Please sign in to comment.