Skip to content

Commit

Permalink
fix: distrib fetching (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
Picodes authored Nov 30, 2023
1 parent 5547d7b commit 1b4355a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const MULTICALL_ADDRESS = '0xcA11bde05977b3631167028862bE2a173976CA11';
export const NULL_ADDRESS = '0x0000000000000000000000000000000000000000';
export const GITHUB_URL = `https://raw.githubusercontent.com/AngleProtocol/merkl-rewards/main/`; // TODO switch to public gcloud buckets
export const ANGLE_API = `https://api.angle.money/`;
export const MAX_NUM_SUBCALLS = 50;
export const MAX_NUM_SUBCALLS = 20;
export const HOUR = 3600;
export const YEAR = 3600 * 24 * 365;

Expand Down
16 changes: 15 additions & 1 deletion src/providers/on-chain/RpcProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,21 @@ export default class RpcProvider extends OnChainProvider {
override activeDistributionsBetween = async (start: number, end: number) => {
const instance = DistributionCreator__factory.connect(this.distributorCreator, this.provider);

return instance['getDistributionsBetweenEpochs(uint32,uint32)'](start, end, { blockTag: this.blockNumber });
let lastIndex = 0;
let distributions = [];

while (true) {
const call = await instance['getDistributionsBetweenEpochs(uint32,uint32,uint32,uint32)'](start, end, lastIndex, 50);
const rewards = call[0];
if (!!rewards) {
distributions = distributions.concat(call[0]);
}

if (lastIndex === call[1].toNumber()) break;
lastIndex = call[1].toNumber();
}

return distributions;
};

override poolName = async (pool: string, amm: AMM) => {
Expand Down

0 comments on commit 1b4355a

Please sign in to comment.