-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
110 additions
and
74 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,38 @@ | ||
export function calculateBonusAndAPR(roundBonusPayReports, roundBonusPayProposed, reportsProposedAdjustPwr,numOraclesAdjustBase,collateralPctPay, reportedOrMerged, proposed, investedAmount, periodsPerYear,activeOracles) { | ||
// Calculate the bonus payment | ||
let bonusPay = roundBonusPayReports * Math.pow(reportedOrMerged, reportsProposedAdjustPwr) + roundBonusPayProposed * Math.pow(proposed, reportsProposedAdjustPwr); | ||
bonusPay = bonusPay / Math.pow(numOraclesAdjustBase, activeOracles); | ||
// bonusPay = bonusPay / activeOracles | ||
const configPayment = { | ||
collateral_pct_pay_per_round_mult: 0.000075, // 5% APR approximation | ||
round_bonus_pay_reports: 10, | ||
round_bonus_pay_proposed: 2, | ||
reports_proposed_adjust_pwr: 0.42, | ||
num_oracles_adjust_base: 1.015 | ||
}; | ||
|
||
// Calculate APR based on the bonus and invested amount | ||
let basePay = collateralPctPay * investedAmount; | ||
// let apr = (basePay / investedAmount) * periodsPerYear * 100; // Multiply by 100 to convert to percentage | ||
let apr = ((basePay+bonusPay) / investedAmount) * periodsPerYear * 100; // Multiply by 100 to convert to percentage | ||
return { bonusPay, apr, basePay }; | ||
} | ||
function calculateOracleEarnings(numReports, proposed, collateral) { | ||
const roundsPerYear = 675; | ||
|
||
// Configuration | ||
const configPayment = { | ||
collateral_pct_pay_per_round_mult: 0.000037075, // 2.5% APR | ||
round_bonus_pay_reports: 10, | ||
round_bonus_pay_proposed: 2, | ||
reports_proposed_adjust_pwr: .42, | ||
num_oracles_adjust_base:1.015 | ||
} | ||
// Additional Parameters | ||
const activeOracles = 20 | ||
const oracleCollateral = 5000000 | ||
const periodsPerYear = 674.31 // for calculating oracle collateral APR | ||
// Base pay | ||
const basePay = collateral * configPayment.collateral_pct_pay_per_round_mult | ||
// const basePay = u32(f32(oracleRow.trueCollateral) * config.payment.collateral_pct_pay_per_round_mult) | ||
console.log(basePay) | ||
|
||
// Scenarios | ||
const scenarios = [100,500, 1000, 2050, 5000, 10000, 100000]; | ||
const proposedReports = 200; // Assuming constant for simplicity | ||
const bonusPay = configPayment.round_bonus_pay_reports * Math.pow(proposed, configPayment.reports_proposed_adjust_pwr) + configPayment.round_bonus_pay_proposed * Math.pow(numReports, configPayment.reports_proposed_adjust_pwr) | ||
console.log(bonusPay) | ||
// Total paid per round | ||
const totalPaidPerRound = basePay + bonusPay; | ||
|
||
// Calculate and print the bonus and APR for each scenario | ||
scenarios.forEach(reportedOrMerged => { | ||
const {bonusPay, apr,basePay} = calculateBonusAndAPR( | ||
configPayment.round_bonus_pay_reports, | ||
configPayment.round_bonus_pay_proposed, | ||
configPayment.reports_proposed_adjust_pwr, | ||
configPayment.num_oracles_adjust_base, | ||
configPayment.collateral_pct_pay_per_round_mult, | ||
reportedOrMerged, | ||
proposedReports, | ||
oracleCollateral, | ||
periodsPerYear, | ||
activeOracles | ||
); | ||
// APR calculation | ||
const totalPaidPerYear = totalPaidPerRound * roundsPerYear; | ||
const apr = (totalPaidPerYear / collateral) * 100; | ||
|
||
return { | ||
bonusPay: bonusPay.toFixed(2), | ||
basePay: basePay.toFixed(2), | ||
totalPaid: totalPaidPerRound.toFixed(2), | ||
apr: apr.toFixed(2) + '%' | ||
}; | ||
} | ||
|
||
console.log(`Reported/Merged: ${reportedOrMerged}, Bonus: ${bonusPay.toLocaleString(undefined, {maximumFractionDigits: 2})}, Base: ${ basePay } APR: ${apr.toFixed(2)}%, total paid: ${(bonusPay*activeOracles).toLocaleString()}`); | ||
}); | ||
// Example usage | ||
const numReports = 50; // Number of reports made by the oracle | ||
const collateral = 5000000; // Collateral of the oracle | ||
const numProposals = 10 | ||
console.log(calculateOracleEarnings(numReports, numProposals, collateral)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
module.exports = { | ||
chains: ['eos', 'kylin', 'wax', 'jungle', 'telosTest', 'waxTest'], | ||
chains: ['eos', 'kylin', 'wax', 'jungle', 'telosTest', 'waxTest','telos'], | ||
endpoints: { | ||
eos: ['https://eos.eosn.io','https://eos.api.animus.is', 'https://eos.dfuse.eosnation.io/'], | ||
kylin: ['https://kylin.eosn.io', 'https://kylin.eossweden.org'], | ||
jungle: ['https://jungle3.cryptolions.io', 'https://jungle3.greymass.com'], | ||
telosTest: ['https://testnet.telos.caleos.io'], | ||
telos: ['https://mainnet.telos.net'], | ||
waxTest: ['https://testnet.waxsweden.org'] | ||
}, | ||
accountName: { | ||
telosTest: "power.boid", | ||
telos: "power.boid", | ||
}, | ||
explorer: { | ||
waxTest: "https://wax-test.bloks.io", | ||
telosTest: "https://explorer-test.telos.net" | ||
telosTest: "https://explorer-test.telos.net", | ||
telos: "https://explorer.telos.net" | ||
}, | ||
contractName: 'boid.contract' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters