diff --git a/src/eventButton.js b/src/eventButton.js index d3fc015..bc221cb 100644 --- a/src/eventButton.js +++ b/src/eventButton.js @@ -13,6 +13,9 @@ const withdrawStakeColour = "rgba(102, 3, 10, 0.3)"; const stakeColour = "rgba(71, 23, 122, 0.3)"; const claimColour = "rgba(77, 91, 42, 0.3)"; +const thresholdStaking = 0.001; +const thresholdFees = 0.00009; + const EventButton = (obj) => { const dispatch = useDispatch(); // Data shared among all events in this transaction @@ -44,8 +47,8 @@ const EventButton = (obj) => { transactionCaller = eventObj.data.delegator.toLowerCase(); transactionFrom = eventObj.data.oldDelegate.toLowerCase(); transactionTo = eventObj.data.newDelegate.toLowerCase(); - transactionAmount = parseFloat(eventObj.data.bondedAmount); - transactionAdditionalAmount = parseFloat(eventObj.data.additionalAmount); + transactionAmount = parseFloat(eventObj.data.bondedAmount) / 1000000000000000000; + transactionAdditionalAmount = parseFloat(eventObj.data.additionalAmount) / 1000000000000000000; hasBondTransaction = true; } // Unbond: defines transactionWhen. Defines transactionAmount as X / 1000000000000000000 LPT @@ -72,15 +75,15 @@ const EventButton = (obj) => { if (eventObj.name === "Rebond") { // transactionCaller might get overwritten by TranserBond, but might as well set them if (isOnlyBondRelated) { - transactionCaller = eventObj.data.delegate.toLowerCase(); - transactionFrom = eventObj.data.delegator.toLowerCase(); + transactionTo = eventObj.data.delegate.toLowerCase(); + transactionCaller = eventObj.data.delegator.toLowerCase(); transactionAmount = parseFloat(eventObj.data.amount) / 1000000000000000000; } hasRebondTransaction = true; } // TranscoderActivated: defines transactionName as a stake claim. Defines transactionWhen - if (eventObj.name === "EarningsClaimed" && !hasActivation) { + if (eventObj.name === "EarningsClaimed" && !hasActivation && !hasBondTransaction) { transactionName = "Claim"; transactionWhen = eventObj.data.endRound; transactionFrom = eventObj.data.delegate; @@ -131,14 +134,15 @@ const EventButton = (obj) => { }) // If we only had a bond transaction and nothing else, this is a stake - if (isOnlyBondRelated) { - if (hasBondTransaction) { - transactionName = "Stake"; - thisColour = stakeColour; - } else if (hasRebondTransaction) { - console.log("Filtering out lone Rebond"); - return null; - } + if (hasBondTransaction) { + transactionName = "Stake"; + thisColour = stakeColour; + } + + // Lone Rebond, treat as new stake + if (hasRebondTransaction && transactionName == "") { + transactionName = "Rebond"; + thisColour = stakeColour; } // Check name filter on transactionCaller, transactionFrom, transactionTo @@ -184,6 +188,12 @@ const EventButton = (obj) => { } count++; } + if (obj.stakeActivated) { + if (transactionName === "Rebond") { + isFiltered = false; + } + count++; + } if (obj.delegatorRewardActivated) { if (transactionName === "Claim") { isFiltered = false; @@ -213,13 +223,13 @@ const EventButton = (obj) => { return null; } let claimString = "claimed "; - if (transactionAmount > 0.001){ + if (transactionAmount > thresholdStaking) { claimString += transactionAmount.toFixed(2) + " LPT staking rewards"; - if (transactionAdditionalAmount > 0.00009){ + if (transactionAdditionalAmount > thresholdFees) { claimString += " and " } } - if (transactionAdditionalAmount > 0.00009){ + if (transactionAdditionalAmount > thresholdFees) { claimString += transactionAdditionalAmount.toFixed(4) + " Eth fee rewards"; } eventSpecificInfo = @@ -236,18 +246,24 @@ const EventButton = (obj) => { if (transactionFrom == "0x0000000000000000000000000000000000000000") { eventSpecificInfo =
staked {(transactionAmount / 1000000000000000000).toFixed(2)} LPT to
+staked {transactionAmount.toFixed(2)} LPT to
moved {(transactionAmount / 1000000000000000000).toFixed(2)} LPT stake:
+moved {transactionAmount.toFixed(2)} LPT stake:
to
increased their stake with {transactionAmount.toFixed(2)} LPT at
+ +activated with a self stake of {(transactionAmount / 1000000000000000000).toFixed(2)} LPT and will become active in round {transactionWhen}
+activated with a self stake of {transactionAmount.toFixed(2)} LPT and will become active in round {transactionWhen}
UNIMPLEMENTED
-