mirror of
https://github.com/stronk-dev/LivepeerEvents.git
synced 2025-07-05 10:45:10 +02:00
Now with commission in ticket viewer and some prework for storing round numbers
This commit is contained in:
parent
673ec3265e
commit
6fba12ec1f
@ -24,6 +24,10 @@ const ActivateEventSchema = new mongoose.Schema({
|
||||
blockTime: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
blockRound: {
|
||||
type: Number,
|
||||
required: false
|
||||
}
|
||||
}, { timestamps: false });
|
||||
|
||||
|
@ -32,6 +32,10 @@ const ClaimEventSchema = new mongoose.Schema({
|
||||
blockTime: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
blockRound: {
|
||||
type: Number,
|
||||
required: false
|
||||
}
|
||||
}, { timestamps: false });
|
||||
|
||||
|
@ -20,6 +20,10 @@ const RedeemEventSchema = new mongoose.Schema({
|
||||
blockTime: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
blockRound: {
|
||||
type: Number,
|
||||
required: false
|
||||
}
|
||||
}, { timestamps: false });
|
||||
|
||||
|
@ -20,6 +20,10 @@ const RewardEventSchema = new mongoose.Schema({
|
||||
blockTime: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
blockRound: {
|
||||
type: Number,
|
||||
required: false
|
||||
}
|
||||
}, { timestamps: false });
|
||||
|
||||
|
@ -28,6 +28,10 @@ const StakeEventSchema = new mongoose.Schema({
|
||||
blockTime: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
blockRound: {
|
||||
type: Number,
|
||||
required: false
|
||||
}
|
||||
}, { timestamps: false });
|
||||
|
||||
|
@ -24,6 +24,10 @@ const TransferEventSchema = new mongoose.Schema({
|
||||
blockTime: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
blockRound: {
|
||||
type: Number,
|
||||
required: false
|
||||
}
|
||||
}, { timestamps: false });
|
||||
|
||||
|
@ -28,6 +28,10 @@ const UnbondEventSchema = new mongoose.Schema({
|
||||
blockTime: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
blockRound: {
|
||||
type: Number,
|
||||
required: false
|
||||
}
|
||||
}, { timestamps: false });
|
||||
|
||||
|
@ -24,6 +24,10 @@ const UpdateEventSchema = new mongoose.Schema({
|
||||
blockTime: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
blockRound: {
|
||||
type: Number,
|
||||
required: false
|
||||
}
|
||||
}, { timestamps: false });
|
||||
|
||||
|
@ -20,6 +20,10 @@ const WithdrawFeesEventSchema = new mongoose.Schema({
|
||||
blockTime: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
blockRound: {
|
||||
type: Number,
|
||||
required: false
|
||||
}
|
||||
}, { timestamps: false });
|
||||
|
||||
|
@ -24,6 +24,10 @@ const WithdrawStakeEventSchema = new mongoose.Schema({
|
||||
blockTime: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
blockRound: {
|
||||
type: Number,
|
||||
required: false
|
||||
}
|
||||
}, { timestamps: false });
|
||||
|
||||
|
@ -8,6 +8,10 @@ const BlockSchema = new mongoose.Schema({
|
||||
blockTime: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
blockRound: {
|
||||
type: Number,
|
||||
required: false
|
||||
}
|
||||
}, { timestamps: false });
|
||||
|
||||
|
@ -31,9 +31,28 @@ const EventButton = (obj) => {
|
||||
]} />
|
||||
eventColour = updateColour;
|
||||
} else if (obj.type == "reward") {
|
||||
// Determine reward cut
|
||||
let appendix = "";
|
||||
if (obj.monthlyStats) {
|
||||
var dateObj = new Date(0);
|
||||
dateObj.setUTCSeconds(obj.time);
|
||||
const thisYear = dateObj.getFullYear();
|
||||
const thisMonth = dateObj.getMonth();
|
||||
for (const timeObj of obj.monthlyStats) {
|
||||
if (thisYear == timeObj.year && thisMonth == timeObj.month) {
|
||||
if (timeObj.latestCommission) {
|
||||
for (const commissionObj of timeObj.latestCommission) {
|
||||
if (commissionObj.address == obj.eventObj.address) {
|
||||
appendix += ", keeping " + (obj.eventObj.amount * (commissionObj.rewardCommission / 100)).toFixed(4) + " LPT as commission";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
eventCaller = obj.eventObj.address;
|
||||
eventDescription = <Ticket seed={obj.seed + "-desc-"} icon={"🏦"} subtext={"called reward"} descriptions={[
|
||||
"+" + obj.eventObj.amount.toFixed(2) + " LPT" + (Math.floor(obj.eventObj.amount) == 69 ? "... Nice!" : "")
|
||||
"+" + obj.eventObj.amount.toFixed(2) + " LPT" + appendix
|
||||
]} />
|
||||
eventColour = rewardColour;
|
||||
} else if (obj.type == "claim") {
|
||||
@ -86,9 +105,28 @@ const EventButton = (obj) => {
|
||||
]} />
|
||||
eventColour = ticketTransferColour;
|
||||
} else if (obj.type == "redeemTicket") {
|
||||
// Determine fee cut
|
||||
let appendix = "";
|
||||
if (obj.monthlyStats) {
|
||||
var dateObj = new Date(0);
|
||||
dateObj.setUTCSeconds(obj.time);
|
||||
const thisYear = dateObj.getFullYear();
|
||||
const thisMonth = dateObj.getMonth();
|
||||
for (const timeObj of obj.monthlyStats) {
|
||||
if (thisYear == timeObj.year && thisMonth == timeObj.month) {
|
||||
if (timeObj.latestCommission) {
|
||||
for (const commissionObj of timeObj.latestCommission) {
|
||||
if (commissionObj.address == obj.eventObj.address) {
|
||||
appendix += ", keeping " + (obj.eventObj.amount * (commissionObj.feeCommission / 100)).toFixed(4) + " Eth as commission";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
eventCaller = obj.eventObj.address;
|
||||
eventDescription = <Ticket seed={obj.seed + "-desc-"} icon={"🎟️"} subtext={"redeemed winning ticket"} descriptions={[
|
||||
"+" + obj.eventObj.amount.toFixed(4) + " Eth"
|
||||
"+" + obj.eventObj.amount.toFixed(4) + " Eth" + appendix
|
||||
]} />
|
||||
eventColour = ticketRedeemColour;
|
||||
} else if (obj.type == "stake") {
|
||||
|
@ -98,10 +98,6 @@ const EventViewer = (obj) => {
|
||||
unbondEventsIdx = -1;
|
||||
}
|
||||
if (!delegatorRewardActivated) {
|
||||
filtered += rewardEventsIdx + 1;
|
||||
rewardEventsIdx = -1;
|
||||
}
|
||||
if (!rewardActivated) {
|
||||
filtered += claimEventsIdx + 1;
|
||||
claimEventsIdx = -1;
|
||||
}
|
||||
@ -426,7 +422,9 @@ const EventViewer = (obj) => {
|
||||
seed={thisEvent.transactionHash + unfiltered}
|
||||
eventObj={thisEvent}
|
||||
type={latestType}
|
||||
time={thisEvent.blockTime}
|
||||
setSearchTerm={obj.setSearchTerm}
|
||||
monthlyStats={obj.monthlyStats}
|
||||
/>);
|
||||
} else {
|
||||
prevBlock = thisEvent.blockNumber;
|
||||
@ -438,6 +436,7 @@ const EventViewer = (obj) => {
|
||||
isFirstOfBlock={prevBlock}
|
||||
time={thisEvent.blockTime}
|
||||
setSearchTerm={obj.setSearchTerm}
|
||||
monthlyStats={obj.monthlyStats}
|
||||
/>);
|
||||
}
|
||||
}
|
||||
|
@ -112,6 +112,7 @@ const Livepeer = (obj) => {
|
||||
activateEvents={livepeer.activateEvents}
|
||||
unbondEvents={livepeer.unbondEvents}
|
||||
stakeEvents={livepeer.stakeEvents}
|
||||
monthlyStats={livepeer.monthlyStats}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user