Skip to content

Commit

Permalink
Merge pull request #33 from bancorprotocol/improve-store-rewards
Browse files Browse the repository at this point in the history
Optimize storePoolRewards script
  • Loading branch information
lbeder authored Jun 3, 2021
2 parents afe828a + 483ecac commit d1fecdf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
1 change: 0 additions & 1 deletion settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"owner": "0x9Ab934010E6f2D633FeEB5b6f1DdCeEdeD601BCF"
},
"LiquidityProtection": {
"address": "0x42743f4d9f139bfd04680df50bce2d7dd8816f90",
"owner": "0x7E3692A6D8c34a762079Fa9057AeD87be7e67cb8"
},
"TokenGovernance": {
Expand Down
17 changes: 16 additions & 1 deletion tasks/store-pool-rewards.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { trace, info, error, arg } = require('../utils/logger');
const BN = require('bn.js');
const DB = require('../utils/db');

const BATCH_SIZE = 15;
Expand All @@ -9,7 +10,21 @@ const storePoolRewardsTask = async (env, { poolToken }) => {

let totalGas = 0;

const providers = Object.keys(data.pendingRewards);
let providers = [];
for (const provider of Object.keys(data.pendingRewards)) {
const rewards = await web3Provider.call(
contracts.StakingRewards.methods.pendingPoolRewards(provider, poolToken)
);

if (new BN(rewards).eq(new BN(0))) {
trace('Skipping provider without any pending rewards', arg('provider', provider));

continue;
}

providers.push(provider);
}

for (let i = 0; i < providers.length; i += BATCH_SIZE) {
const providersBatch = providers.slice(i, i + BATCH_SIZE);

Expand Down

0 comments on commit d1fecdf

Please sign in to comment.