mirror of
https://github.com/stronk-dev/LivepeerEvents.git
synced 2025-07-05 10:45:10 +02:00
delegator fee claiming added
This commit is contained in:
parent
3b4990865c
commit
6fad60f8c9
2990
dumps/events.json
2990
dumps/events.json
File diff suppressed because it is too large
Load Diff
@ -11,6 +11,7 @@ const rewardColour = "rgba(20, 99, 29, 0.3)";
|
|||||||
const updateColour = "rgba(122, 63, 23, 0.3)";
|
const updateColour = "rgba(122, 63, 23, 0.3)";
|
||||||
const withdrawStakeColour = "rgba(102, 3, 10, 0.3)";
|
const withdrawStakeColour = "rgba(102, 3, 10, 0.3)";
|
||||||
const stakeColour = "rgba(71, 23, 122, 0.3)";
|
const stakeColour = "rgba(71, 23, 122, 0.3)";
|
||||||
|
const claimColour = "rgba(77, 91, 42, 0.3)";
|
||||||
|
|
||||||
const EventButton = (obj) => {
|
const EventButton = (obj) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
@ -28,13 +29,17 @@ const EventButton = (obj) => {
|
|||||||
let transactionAdditionalAmount = 0;
|
let transactionAdditionalAmount = 0;
|
||||||
let transactionWhen = 0;
|
let transactionWhen = 0;
|
||||||
let hasBondTransaction = false;
|
let hasBondTransaction = false;
|
||||||
let isOnlyBond = true;
|
let hasRebondTransaction = false;
|
||||||
|
let hasUnbondTransaction = false;
|
||||||
|
let hasTransferbondTransaction = false;
|
||||||
|
let hasEarningsClaimed = false;
|
||||||
|
let isOnlyBondRelated = true;
|
||||||
let thisColour = "";
|
let thisColour = "";
|
||||||
|
|
||||||
// Which we will fill in by going over all of the events once
|
// Which we will fill in by going over all of the events once
|
||||||
thisData.map(eventObj => {
|
thisData.map(eventObj => {
|
||||||
// Bond: contains amount the transaction is about and who is participating
|
// Bond: contains amount the transaction is about and who is participating
|
||||||
if (eventObj.name === "Bond") {
|
if (eventObj.name === "Bond" && !hasEarningsClaimed) {
|
||||||
transactionCaller = eventObj.data.delegator.toLowerCase();
|
transactionCaller = eventObj.data.delegator.toLowerCase();
|
||||||
transactionFrom = eventObj.data.oldDelegate.toLowerCase();
|
transactionFrom = eventObj.data.oldDelegate.toLowerCase();
|
||||||
transactionTo = eventObj.data.newDelegate.toLowerCase();
|
transactionTo = eventObj.data.newDelegate.toLowerCase();
|
||||||
@ -42,6 +47,49 @@ const EventButton = (obj) => {
|
|||||||
transactionAdditionalAmount = parseFloat(eventObj.data.additionalAmount);
|
transactionAdditionalAmount = parseFloat(eventObj.data.additionalAmount);
|
||||||
hasBondTransaction = true;
|
hasBondTransaction = true;
|
||||||
}
|
}
|
||||||
|
// Unbond: defines transactionWhen. Defines transactionAmount as X / 1000000000000000000 LPT
|
||||||
|
if (eventObj.name === "Unbond") {
|
||||||
|
// Caller and from will get overwritten by TranserBond or Rebond, but might as well set them
|
||||||
|
if (isOnlyBondRelated) {
|
||||||
|
transactionCaller = eventObj.data.delegate.toLowerCase();
|
||||||
|
transactionFrom = eventObj.data.delegator.toLowerCase();
|
||||||
|
transactionAmount = parseFloat(eventObj.data.amount) / 1000000000000000000;
|
||||||
|
}
|
||||||
|
hasUnbondTransaction = true;
|
||||||
|
}
|
||||||
|
// TransferBond: defines to transactionFrom and transactionTo. Defines transactionAmount as X / 1000000000000000000 LPT
|
||||||
|
if (eventObj.name === "TransferBond") {
|
||||||
|
// transactionFrommight get overwritten by Rebond, but might as well set them
|
||||||
|
if (isOnlyBondRelated) {
|
||||||
|
transactionFrom = eventObj.data.oldDelegator.toLowerCase();
|
||||||
|
transactionTo = eventObj.data.newDelegator.toLowerCase();
|
||||||
|
transactionAmount = parseFloat(eventObj.data.amount) / 1000000000000000000;
|
||||||
|
}
|
||||||
|
hasTransferbondTransaction = true;
|
||||||
|
}
|
||||||
|
// TransferBond: defines to transactionFrom and transactionTo. Defines transactionAmount as X / 1000000000000000000 LPT
|
||||||
|
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();
|
||||||
|
transactionAmount = parseFloat(eventObj.data.amount) / 1000000000000000000;
|
||||||
|
}
|
||||||
|
hasRebondTransaction = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TranscoderActivated: defines transactionName as a stake claim. Defines transactionWhen
|
||||||
|
if (eventObj.name === "EarningsClaimed") {
|
||||||
|
transactionName = "Claim";
|
||||||
|
transactionWhen = eventObj.data.endRound;
|
||||||
|
transactionFrom = eventObj.data.delegate;
|
||||||
|
transactionCaller = eventObj.data.delegator;
|
||||||
|
transactionAmount = parseFloat(eventObj.data.rewards) / 1000000000000000000;
|
||||||
|
transactionAdditionalAmount = parseFloat(eventObj.data.fees) / 1000000000000000000;
|
||||||
|
thisColour = claimColour;
|
||||||
|
isOnlyBondRelated = false;
|
||||||
|
hasEarningsClaimed = true;
|
||||||
|
}
|
||||||
// TranscoderActivated: defines transactionName. Defines transactionAmount as X * 7e-18 LPT
|
// TranscoderActivated: defines transactionName. Defines transactionAmount as X * 7e-18 LPT
|
||||||
if (eventObj.name === "TranscoderActivated") {
|
if (eventObj.name === "TranscoderActivated") {
|
||||||
transactionName = "Activated";
|
transactionName = "Activated";
|
||||||
@ -50,15 +98,15 @@ const EventButton = (obj) => {
|
|||||||
transactionCaller = eventObj.data.transcoder.toLowerCase();
|
transactionCaller = eventObj.data.transcoder.toLowerCase();
|
||||||
}
|
}
|
||||||
thisColour = activationColour;
|
thisColour = activationColour;
|
||||||
isOnlyBond = false;
|
isOnlyBondRelated = false;
|
||||||
}
|
}
|
||||||
// TranscoderActivated: defines transactionName. Defines transactionAmount as X / 1000000000000000000 LPT
|
// TranscoderActivated: defines transactionName. Defines transactionAmount as X / 1000000000000000000 LPT
|
||||||
if (eventObj.name === "Reward") {
|
if (eventObj.name === "Reward") {
|
||||||
transactionName = "Reward";
|
transactionName = "Reward";
|
||||||
transactionCaller = eventObj.data.transcoder.toLowerCase();
|
transactionCaller = eventObj.data.transcoder.toLowerCase();
|
||||||
transactionAmount = eventObj.data.amount / 1000000000000000000;
|
transactionAmount = parseFloat(eventObj.data.amount) / 1000000000000000000;
|
||||||
thisColour = rewardColour;
|
thisColour = rewardColour;
|
||||||
isOnlyBond = false;
|
isOnlyBondRelated = false;
|
||||||
}
|
}
|
||||||
// TranscoderUpdate: defines transactionName. Defines transactionAmount as rewardCut and transactionAdditionalAmount as feeCut
|
// TranscoderUpdate: defines transactionName. Defines transactionAmount as rewardCut and transactionAdditionalAmount as feeCut
|
||||||
if (eventObj.name === "TranscoderUpdate") {
|
if (eventObj.name === "TranscoderUpdate") {
|
||||||
@ -67,23 +115,28 @@ const EventButton = (obj) => {
|
|||||||
transactionAmount = eventObj.data.rewardCut / 10000;
|
transactionAmount = eventObj.data.rewardCut / 10000;
|
||||||
transactionAdditionalAmount = 100 - (eventObj.data.feeShare / 10000);
|
transactionAdditionalAmount = 100 - (eventObj.data.feeShare / 10000);
|
||||||
thisColour = updateColour;
|
thisColour = updateColour;
|
||||||
isOnlyBond = false;
|
isOnlyBondRelated = false;
|
||||||
}
|
}
|
||||||
// WithdrawStake: defines transactionName. Defines transactionAmount as rewardCut and transactionAdditionalAmount as feeCut
|
// WithdrawStake: defines transactionName. Defines transactionAmount as rewardCut and transactionAdditionalAmount as feeCut
|
||||||
if (eventObj.name === "WithdrawStake") {
|
if (eventObj.name === "WithdrawStake") {
|
||||||
transactionName = "Withdraw";
|
transactionName = "Withdraw";
|
||||||
transactionCaller = eventObj.data.delegator.toLowerCase();
|
transactionCaller = eventObj.data.delegator.toLowerCase();
|
||||||
transactionAmount = eventObj.data.amount / 1000000000000000000;
|
transactionAmount = parseFloat(eventObj.data.amount) / 1000000000000000000;
|
||||||
transactionWhen = eventObj.data.withdrawRound;
|
transactionWhen = eventObj.data.withdrawRound;
|
||||||
thisColour = withdrawStakeColour;
|
thisColour = withdrawStakeColour;
|
||||||
isOnlyBond = false;
|
isOnlyBondRelated = false;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// If we only had a bond transaction and nothing else, this is a stake
|
// If we only had a bond transaction and nothing else, this is a stake
|
||||||
if (hasBondTransaction && isOnlyBond) {
|
if (isOnlyBondRelated) {
|
||||||
transactionName = "Stake";
|
if (hasBondTransaction) {
|
||||||
thisColour = stakeColour;
|
transactionName = "Stake";
|
||||||
|
thisColour = stakeColour;
|
||||||
|
} else if (hasRebondTransaction) {
|
||||||
|
console.log("Filtering out lone Rebond");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check name filter on transactionCaller, transactionFrom, transactionTo
|
// Check name filter on transactionCaller, transactionFrom, transactionTo
|
||||||
@ -129,6 +182,12 @@ const EventButton = (obj) => {
|
|||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
if (obj.delegatorRewardActivated) {
|
||||||
|
if (transactionName === "Claim") {
|
||||||
|
isFiltered = false;
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
}
|
||||||
if (isFiltered && count) {
|
if (isFiltered && count) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -147,6 +206,25 @@ const EventButton = (obj) => {
|
|||||||
<p>called reward worth {transactionAmount.toFixed(2)} LPT</p>
|
<p>called reward worth {transactionAmount.toFixed(2)} LPT</p>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
} else if (transactionName === "Claim") {
|
||||||
|
if (transactionFrom == "0x0000000000000000000000000000000000000000") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
let claimString = "claimed ";
|
||||||
|
if (transactionAmount > 0.001){
|
||||||
|
claimString += transactionAmount.toFixed(2) + " LPT staking rewards";
|
||||||
|
if (transactionAdditionalAmount > 0.00009){
|
||||||
|
claimString += " and "
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (transactionAdditionalAmount > 0.00009){
|
||||||
|
claimString += transactionAdditionalAmount.toFixed(4) + " Eth fee rewards";
|
||||||
|
}
|
||||||
|
eventSpecificInfo =
|
||||||
|
<div className="rowAlignLeft">
|
||||||
|
<p>{claimString} at </p>
|
||||||
|
<button className="selectOrch" onClick={() => { dispatch(getOrchestratorInfo(transactionFrom)) }} >{transactionFrom}</button>
|
||||||
|
</div>
|
||||||
} else if (transactionName === "Update") {
|
} else if (transactionName === "Update") {
|
||||||
eventSpecificInfo =
|
eventSpecificInfo =
|
||||||
<div className="rowAlignLeft">
|
<div className="rowAlignLeft">
|
||||||
|
@ -9,6 +9,7 @@ const rewardColour = "rgba(20, 99, 29, 0.3)";
|
|||||||
const updateColour = "rgba(122, 63, 23, 0.3)";
|
const updateColour = "rgba(122, 63, 23, 0.3)";
|
||||||
const withdrawStakeColour = "rgba(102, 3, 10, 0.3)";
|
const withdrawStakeColour = "rgba(102, 3, 10, 0.3)";
|
||||||
const stakeColour = "rgba(71, 23, 122, 0.3)";
|
const stakeColour = "rgba(71, 23, 122, 0.3)";
|
||||||
|
const claimColour = "rgba(77, 91, 42, 0.3)";
|
||||||
|
|
||||||
const EventViewer = (obj) => {
|
const EventViewer = (obj) => {
|
||||||
const [searchTerm, setSearchTerm] = useState(obj.prefill || "");
|
const [searchTerm, setSearchTerm] = useState(obj.prefill || "");
|
||||||
@ -17,6 +18,7 @@ const EventViewer = (obj) => {
|
|||||||
const [updateActivated, setUpdateActivated] = useState(false);
|
const [updateActivated, setUpdateActivated] = useState(false);
|
||||||
const [withdrawActivated, setWithdrawActivated] = useState(false);
|
const [withdrawActivated, setWithdrawActivated] = useState(false);
|
||||||
const [stakeActivated, setStakeActivated] = useState(false);
|
const [stakeActivated, setStakeActivated] = useState(false);
|
||||||
|
const [delegatorRewardActivated, setDelegatorRewardActivated] = useState(false);
|
||||||
console.log("Rendering EventViewer");
|
console.log("Rendering EventViewer");
|
||||||
|
|
||||||
let txCounter = 0;
|
let txCounter = 0;
|
||||||
@ -43,12 +45,6 @@ const EventViewer = (obj) => {
|
|||||||
<ScrollContainer className="overflow-container" hideScrollbars={false}>
|
<ScrollContainer className="overflow-container" hideScrollbars={false}>
|
||||||
<div className="overflow-content" style={{ cursor: 'grab', paddingTop: 0 }}>
|
<div className="overflow-content" style={{ cursor: 'grab', paddingTop: 0 }}>
|
||||||
{obj.events.slice(0).reverse().map((eventObj, idx) => {
|
{obj.events.slice(0).reverse().map((eventObj, idx) => {
|
||||||
// Filter
|
|
||||||
if (eventObj.name === "WithdrawFees" || eventObj.name === "TransferBond"
|
|
||||||
|| eventObj.name === "Rebond" || eventObj.name === "Unbond" || eventObj.name === "EarningsClaimed") {
|
|
||||||
console.log("Skipping event" + eventObj);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// New transaction found
|
// New transaction found
|
||||||
if (currentTx != eventObj.transactionHash) {
|
if (currentTx != eventObj.transactionHash) {
|
||||||
// Save old event data
|
// Save old event data
|
||||||
@ -81,6 +77,7 @@ const EventViewer = (obj) => {
|
|||||||
updateActivated={updateActivated}
|
updateActivated={updateActivated}
|
||||||
withdrawActivated={withdrawActivated}
|
withdrawActivated={withdrawActivated}
|
||||||
stakeActivated={stakeActivated}
|
stakeActivated={stakeActivated}
|
||||||
|
delegatorRewardActivated={delegatorRewardActivated}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
})}
|
})}
|
||||||
@ -112,6 +109,11 @@ const EventViewer = (obj) => {
|
|||||||
}}>
|
}}>
|
||||||
<h3>Stake</h3>
|
<h3>Stake</h3>
|
||||||
</button>
|
</button>
|
||||||
|
<button className={delegatorRewardActivated ? "row homeButton active" : "row homeButton"} style={{ backgroundColor: claimColour }} onClick={() => {
|
||||||
|
setDelegatorRewardActivated(!delegatorRewardActivated);
|
||||||
|
}}>
|
||||||
|
<h3>Claim</h3>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user