mirror of
https://github.com/luxfi/uma.git
synced 2026-07-27 05:11:41 +00:00
Daily Reporter: Change class-level functions from "arrow" to traditional syntax (#1580)
Signed-off-by: Nick Pai <npai.nyc@gmail.com>
This commit is contained in:
@@ -77,7 +77,7 @@ When the function is named and declared at the file-level or class-level scope,
|
||||
|
||||
```js
|
||||
function name(arg1, arg2) {
|
||||
// Fuction body
|
||||
// Function body
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ class GlobalSummaryReporter {
|
||||
this.formatDecimalString = createFormatFunction(this.web3, 2, 4);
|
||||
}
|
||||
|
||||
update = async () => {
|
||||
async update() {
|
||||
await this.empClient.update();
|
||||
await this.empEventClient.update();
|
||||
await this.referencePriceFeed.update();
|
||||
@@ -57,7 +57,7 @@ class GlobalSummaryReporter {
|
||||
this.endBlockTimestamp
|
||||
)}`;
|
||||
|
||||
// Events accessible by all methods.
|
||||
// Query events not already queried by EMPEventClient
|
||||
this.collateralDepositEvents = await this.collateralContract.getPastEvents("Transfer", {
|
||||
fromBlock: 0,
|
||||
toBlock: this.currentBlockNumber,
|
||||
@@ -76,6 +76,7 @@ class GlobalSummaryReporter {
|
||||
event => event.returnValues.from === this.empContract.options.address && event.returnValues.to === ZERO_ADDRESS
|
||||
);
|
||||
|
||||
// Events loaded by EMPEventClient.update()
|
||||
this.newSponsorEvents = this.empEventClient.getAllNewSponsorEvents();
|
||||
this.createEvents = this.empEventClient.getAllCreateEvents();
|
||||
this.regularFeeEvents = this.empEventClient.getAllRegularFeeEvents();
|
||||
@@ -93,9 +94,9 @@ class GlobalSummaryReporter {
|
||||
|
||||
// Pricefeed stats.
|
||||
this.priceEstimate = this.referencePriceFeed.getCurrentPrice();
|
||||
};
|
||||
}
|
||||
|
||||
generateSummaryStatsTable = async () => {
|
||||
async generateSummaryStatsTable() {
|
||||
await this.update();
|
||||
|
||||
// 1. Sponsor stats table
|
||||
@@ -163,9 +164,9 @@ class GlobalSummaryReporter {
|
||||
console.log(bold("DVM summary stats"));
|
||||
await this._generateDvmStats();
|
||||
console.groupEnd();
|
||||
};
|
||||
}
|
||||
|
||||
_generateSponsorStats = async () => {
|
||||
async _generateSponsorStats() {
|
||||
let allSponsorStatsTable = {};
|
||||
|
||||
if (this.newSponsorEvents.length === 0) {
|
||||
@@ -282,9 +283,9 @@ class GlobalSummaryReporter {
|
||||
};
|
||||
|
||||
console.table(allSponsorStatsTable);
|
||||
};
|
||||
}
|
||||
|
||||
_generateTokenStats = async () => {
|
||||
async _generateTokenStats() {
|
||||
let allTokenStatsTable = {};
|
||||
|
||||
const currentTokenPrice = this.uniswapPriceFeed.getLastBlockPrice();
|
||||
@@ -311,9 +312,9 @@ class GlobalSummaryReporter {
|
||||
// - volume of trades in uniswap in # of tokens (24H) (cumulative)
|
||||
|
||||
console.table(allTokenStatsTable);
|
||||
};
|
||||
}
|
||||
|
||||
_generateLiquidationStats = async () => {
|
||||
async _generateLiquidationStats() {
|
||||
let allLiquidationStatsTable = {};
|
||||
|
||||
let uniqueLiquidations = {};
|
||||
@@ -356,9 +357,9 @@ class GlobalSummaryReporter {
|
||||
|
||||
console.table(allLiquidationStatsTable);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
_generateDisputeStats = async () => {
|
||||
async _generateDisputeStats() {
|
||||
let allDisputeStatsTable = {};
|
||||
|
||||
let uniqueDisputes = {};
|
||||
@@ -431,9 +432,9 @@ class GlobalSummaryReporter {
|
||||
console.table(disputesResolved);
|
||||
console.groupEnd();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
_generateDvmStats = async () => {
|
||||
async _generateDvmStats() {
|
||||
let allDvmStatsTable = {};
|
||||
|
||||
let regularFeesPaid = this.toBN("0");
|
||||
@@ -485,15 +486,15 @@ class GlobalSummaryReporter {
|
||||
|
||||
console.table(allDvmStatsTable);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
_getLookbackTimeInBlocks = async lookbackTimeInSeconds => {
|
||||
async _getLookbackTimeInBlocks(lookbackTimeInSeconds) {
|
||||
const blockTimeInSeconds = await averageBlockTimeSeconds();
|
||||
const blocksToLookBack = Math.ceil(lookbackTimeInSeconds / blockTimeInSeconds);
|
||||
return blocksToLookBack;
|
||||
};
|
||||
}
|
||||
|
||||
_constructTokenHolderList = async () => {
|
||||
async _constructTokenHolderList() {
|
||||
const cumulativeTokenHolders = {};
|
||||
const currentTokenHolders = {};
|
||||
|
||||
@@ -537,7 +538,7 @@ class GlobalSummaryReporter {
|
||||
cumulative: cumulativeTokenHolders,
|
||||
current: currentTokenHolders
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
module.exports = {
|
||||
GlobalSummaryReporter
|
||||
|
||||
@@ -21,13 +21,13 @@ class SponsorReporter {
|
||||
this.networkId = 1;
|
||||
}
|
||||
|
||||
update = async () => {
|
||||
async update() {
|
||||
await this.empClient.update();
|
||||
await this.priceFeed.update();
|
||||
};
|
||||
}
|
||||
|
||||
// Iterate over monitored wallets and generate key metrics.
|
||||
generateMonitoredWalletMetrics = async () => {
|
||||
async generateMonitoredWalletMetrics() {
|
||||
await this.update();
|
||||
console.log(
|
||||
italic("- Each monitored wallet within the configuration object has their position and token balances printed")
|
||||
@@ -49,9 +49,9 @@ class SponsorReporter {
|
||||
// end of main group
|
||||
console.groupEnd();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
generateSponsorsTable = async () => {
|
||||
async generateSponsorsTable() {
|
||||
await this.update();
|
||||
console.log(italic("- All current token sponsors within the spesified EMP are printed"));
|
||||
|
||||
@@ -70,7 +70,7 @@ class SponsorReporter {
|
||||
};
|
||||
}
|
||||
console.table(allSponsorTable);
|
||||
};
|
||||
}
|
||||
|
||||
_generatePositionTable(address) {
|
||||
const position = this.empClient.getAllPositions().filter(position => position.sponsor == address);
|
||||
@@ -102,7 +102,7 @@ class SponsorReporter {
|
||||
});
|
||||
}
|
||||
|
||||
_calculatePositionCRPercent = (collateral, tokensOutstanding, tokenPrice) => {
|
||||
_calculatePositionCRPercent(collateral, tokensOutstanding, tokenPrice) {
|
||||
if (collateral == 0) {
|
||||
return 0;
|
||||
}
|
||||
@@ -114,7 +114,7 @@ class SponsorReporter {
|
||||
.mul(this.web3.utils.toBN(this.web3.utils.toWei("1")))
|
||||
.mul(this.web3.utils.toBN(this.web3.utils.toWei("1")))
|
||||
.div(this.web3.utils.toBN(tokensOutstanding).mul(this.web3.utils.toBN(tokenPrice)));
|
||||
};
|
||||
}
|
||||
}
|
||||
module.exports = {
|
||||
SponsorReporter
|
||||
|
||||
+2
-3
@@ -122,7 +122,7 @@ async function run(
|
||||
await globalSummaryReporter.generateSummaryStatsTable();
|
||||
}
|
||||
|
||||
const Poll = async function(callback) {
|
||||
async function Poll(callback) {
|
||||
try {
|
||||
if (
|
||||
!process.env.EMP_ADDRESS ||
|
||||
@@ -169,9 +169,8 @@ const Poll = async function(callback) {
|
||||
} catch (err) {
|
||||
callback(err);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Poll.run = run;
|
||||
// Attach this function to the exported function
|
||||
// in order to allow the script to be executed through both truffle and a test runner.
|
||||
Poll.run = run;
|
||||
|
||||
Reference in New Issue
Block a user