Skip to content

Commit

Permalink
mis math on setting value for activity and transactions for eth add l… (
Browse files Browse the repository at this point in the history
#10592)

* mis math on setting value for activity and transactions for eth add liquidity

* fix issue where using same property for two different values
  • Loading branch information
bthaile authored Feb 9, 2021
1 parent 7622655 commit d630106
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion packages/augur-simplified/src/modules/common/tables.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ const TransactionRow = ({ transaction }: TransactionProps) => {
<li>
<ReceiptLink hash={transaction.tx_hash} label={transaction.subheader} />
</li>
<li>{formatDai(transaction.value).full}</li>
<li>{formatDai(transaction.cashValueUsd).full}</li>
<li>{transaction.tokenAmount}</li>
<li>{transaction.shareAmount}</li>
<li>
Expand Down
1 change: 0 additions & 1 deletion packages/augur-simplified/src/modules/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export const MILLION = THOUSAND.times(THOUSAND);
export const BILLION = MILLION.times(THOUSAND);
export const TRILLION = BILLION.times(THOUSAND);
export const SEC_IN_YEAR = createBigNumber(86400).times(createBigNumber(365));
export const NUM_TICKS_Y_N = 1000;

// # Asset Types
export const ETH = 'ETH';
Expand Down
32 changes: 16 additions & 16 deletions packages/augur-simplified/src/utils/process-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ const shapeEnterTransactions = (
sender: e.sender?.id,
subheader,
...properties,
cashValueUsd: String(cashValueUsd),
value: cashValueUsd
};
});
Expand All @@ -451,6 +452,7 @@ const shapeExitTransactions = (
subheader,
...properties,
value: cashValueUsd,
cashValueUsd: String(cashValueUsd)
};
});
};
Expand All @@ -464,17 +466,13 @@ const shapeAddLiquidityTransactions = (
const subheader = `Add ${cash.name} Liquidity`;
// TODO: cashValue seems to be off on graph data, work around is to add up yes/no share cashValues
const totalCashValue = new BN(e.noShareCashValue).plus(e.yesShareCashValue);
// const cashValue = String(
// convertOnChainCashAmountToDisplayCashAmount(
// e.cashValue,
// new BN(cash.decimals)
// )
// );
const cashValueUsd = String(
const cashValue =
convertOnChainSharesToDisplayShareAmount(
totalCashValue,
new BN(cash.decimals)
).times(cash.usdPrice)
);
const cashValueUsd = String(
cashValue.times(cash.usdPrice)
);
const lpTokens = String(
convertOnChainSharesToDisplayShareAmount(
Expand All @@ -491,7 +489,7 @@ const shapeAddLiquidityTransactions = (
...properties,
price: null,
cashValueUsd,
value: cashValueUsd,
value: String(cashValue),
lpTokens,
netShares: e.netShares
};
Expand All @@ -505,11 +503,12 @@ const shapeRemoveLiquidityTransactions = (
return transactions.map((e) => {
const properties = formatTransaction(e, cash);
const subheader = `Remove ${cash.name} Liquidity`;
const cashValue = String(
convertOnChainSharesToDisplayShareAmount(
new BN(e.cashValue),
new BN(cash.decimals)
)
const cashValue = convertOnChainSharesToDisplayShareAmount(
new BN(e.cashValue),
new BN(cash.decimals)
)
const cashValueUsd = String(
cashValue.times(cash.usdPrice)
);
const shares = new BN(e.noShares).plus(new BN(e.yesShares));
const shareAmount = String(formatShares(
Expand All @@ -531,8 +530,9 @@ const shapeRemoveLiquidityTransactions = (
subheader,
...properties,
price: null,
cashValue,
value: cashValue,
cashValue: String(cashValue),
cashValueUsd,
value: String(cashValue),
tokenAmount,
shareAmount
};
Expand Down

0 comments on commit d630106

Please sign in to comment.