diff --git a/cli/sample.env b/cli/sample.env index 8b82066..acc23a1 100644 --- a/cli/sample.env +++ b/cli/sample.env @@ -1,4 +1,6 @@ INFURA_API_KEY= PINATA_JWT= PINATA_GATEWAY_URL= -PINATA_GATEWAY_API_KEY= \ No newline at end of file +PINATA_GATEWAY_API_KEY= +THORNODE_URL=https://daemon.thorchain.shapeshift.com +UNCHAINED_URL=https://api.thorchain.shapeshift.com \ No newline at end of file diff --git a/cli/src/client.ts b/cli/src/client.ts index 0ab9b24..edf0c91 100644 --- a/cli/src/client.ts +++ b/cli/src/client.ts @@ -10,12 +10,23 @@ import { error, info, warn } from './logging' import { CalculateRewardsArgs, RewardDistribution } from './types' const INFURA_API_KEY = process.env['INFURA_API_KEY'] - if (!INFURA_API_KEY) { error('INFURA_API_KEY not set. Please make sure you copied the sample.env and filled out your .env file.') process.exit(1) } +const THORNODE_URL = process.env['THORNODE_URL'] +if (!THORNODE_URL) { + error('THORNODE_URL not set. Please make sure you copied the sample.env and filled out your .env file.') + process.exit(1) +} + +const UNCHAINED_URL = process.env['UNCHAINED_URL'] +if (!UNCHAINED_URL) { + error('UNCHAINED_URL not set. Please make sure you copied the sample.env and filled out your .env file.') + process.exit(1) +} + const AVERAGE_BLOCK_TIME_BLOCKS = 1000 const THORCHAIN_PRECISION = 8 const TOKEN_PRECISION = 18 @@ -32,6 +43,7 @@ export const stakingContracts = [ type Revenue = { addresses: string[] amount: string + revenue: Record } type Pool = { @@ -145,7 +157,7 @@ export class Client { async getRevenue(startTimestamp: number, endTimestamp: number): Promise { try { const { data } = await axios.get( - `https://api.thorchain.shapeshift.com/api/v1/affiliate/revenue?start=${startTimestamp}&end=${endTimestamp}`, + `${UNCHAINED_URL}/api/v1/affiliate/revenue?start=${startTimestamp}&end=${endTimestamp}`, ) return data } catch (err) { @@ -163,12 +175,10 @@ export class Client { async getPrice(): Promise { try { - const { data: ethPool } = await axios.get( - 'https://daemon.thorchain.shapeshift.com/lcd/thorchain/pool/ETH.ETH', - ) + const { data: ethPool } = await axios.get(`${THORNODE_URL}/lcd/thorchain/pool/ETH.ETH`) const { data: foxPool } = await axios.get( - 'https://daemon.thorchain.shapeshift.com/lcd/thorchain/pool/ETH.FOX-0XC770EEFAD204B5180DF6A14EE197D99D808EE52D', + `${THORNODE_URL}/lcd/thorchain/pool/ETH.FOX-0XC770EEFAD204B5180DF6A14EE197D99D808EE52D`, ) const ethPriceUsd = toPrecision(ethPool.asset_tor_price, THORCHAIN_PRECISION).toFixed(THORCHAIN_PRECISION) diff --git a/cli/src/index.ts b/cli/src/index.ts index c1c6bf5..34e6351 100644 --- a/cli/src/index.ts +++ b/cli/src/index.ts @@ -44,9 +44,15 @@ const processEpoch = async () => { const revenue = await client.getRevenue(metadata.epochStartTimestamp, metadata.epochEndTimestamp) - info( - `Total ${month} revenue earned by ${revenue.addresses}: ${BigNumber(revenue.amount).div(100000000).toFixed(8)} RUNE`, - ) + info(`Affilate addresses:`) + revenue.addresses.forEach(address => info(`\t- ${address}`)) + + info(`Total revenue earned by denom:`) + Object.entries(revenue.revenue).forEach(([denom, amount]) => { + info(`\t- ${BigNumber(amount).div(100000000).toFixed(8)} ${denom}`) + }) + + info(`Total revenue in RUNE: ${BigNumber(revenue.amount).div(100000000).toFixed(8)}`) const totalDistributionRate = Object.entries(metadata.distributionRateByStakingContract).reduce( (prev, [stakingContract, distributionRate]) => { @@ -119,6 +125,7 @@ const processEpoch = async () => { endBlock: Number(endBlock), treasuryAddress: metadata.treasuryAddress, totalRevenue: revenue.amount, + revenue: revenue.revenue, burnRate: metadata.burnRate, runePriceUsd, distributionStatus: 'pending', diff --git a/cli/src/ipfs.ts b/cli/src/ipfs.ts index b1926fc..db84dab 100644 --- a/cli/src/ipfs.ts +++ b/cli/src/ipfs.ts @@ -1,6 +1,6 @@ import * as prompts from '@inquirer/prompts' import { PinataSDK } from 'pinata' -import axios, { isAxiosError } from 'axios' +import { isAxiosError } from 'axios' import BigNumber from 'bignumber.js' import { error, info } from './logging' import { Epoch, EpochDetails, RFOXMetadata, RewardDistribution } from './types' diff --git a/cli/src/types.ts b/cli/src/types.ts index 4380fda..06e7855 100644 --- a/cli/src/types.ts +++ b/cli/src/types.ts @@ -80,6 +80,8 @@ export type Epoch = { treasuryAddress: string /** The total revenue (RUNE) earned by the treasury for this epoch */ totalRevenue: string + /** The revenue earned (by denom) by the treasury for this epoch */ + revenue: Record /** The percentage of revenue (RUNE) accumulated by the treasury to be used to buy FOX from the open market and subsequently burned for this epoch */ burnRate: number /** The spot price of rune in USD */ diff --git a/cli/src/wallet.ts b/cli/src/wallet.ts index 2bd12ee..43b3432 100644 --- a/cli/src/wallet.ts +++ b/cli/src/wallet.ts @@ -11,9 +11,14 @@ import { error, info, success } from './logging' import { Epoch } from './types' import { RFOX_DIR } from '.' +const THORNODE_URL = process.env['THORNODE_URL'] +if (!THORNODE_URL) { + error('THORNODE_URL not set. Please make sure you copied the sample.env and filled out your .env file.') + process.exit(1) +} + const BIP32_PATH = `m/44'/931'/0'/0/0` const SHAPESHIFT_MULTISIG_ADDRESS = 'thor122h9hlrugzdny9ct95z6g7afvpzu34s73uklju' -const THORNODE_URL = 'https://daemon.thorchain.shapeshift.com' const addressNList = bip32ToAddressNList(BIP32_PATH)