@gearbox-protocol/airdrop
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -9,2 +9,14 @@ import { TypedEvent } from "@gearbox-protocol/sdk/lib/types/common"; | ||
static parseEvents(events: Array<TypedEvent>, rewardPerBlock: RangedValue, toBlock: number): Array<Reward>; | ||
static parseCMEvents(events: Array<TypedEvent>): { | ||
borrowedRange: Record<string, RangedValue>; | ||
totalBorrowedRange: RangedValue; | ||
borrowed: Record<string, BigNumber>; | ||
totalBorrowed: BigNumber; | ||
}; | ||
static computeCMStats(creditManager: string, provider: providers.Provider, toBlock?: number): Promise<{ | ||
borrowedRange: Record<string, RangedValue>; | ||
totalBorrowedRange: RangedValue; | ||
borrowed: Record<string, BigNumber>; | ||
totalBorrowed: BigNumber; | ||
}>; | ||
static computeRewardInt(toBlock: number, balance: RangedValue, totalSupply: RangedValue, rewardPerBlock: RangedValue): BigNumber; | ||
@@ -11,0 +23,0 @@ protected static query(creditFacade: string, provider: providers.Provider, toBlock: number): Promise<Array<TypedEvent>>; |
@@ -30,2 +30,9 @@ "use strict"; | ||
static parseEvents(events, rewardPerBlock, toBlock) { | ||
const { borrowedRange, totalBorrowedRange, borrowed } = CreditRewards.parseCMEvents(events); | ||
return Object.keys(borrowed).map(address => ({ | ||
address: address.toLowerCase(), | ||
amount: CreditRewards.computeRewardInt(toBlock, borrowedRange[address], totalBorrowedRange, rewardPerBlock), | ||
})); | ||
} | ||
static parseCMEvents(events) { | ||
const borrowedRange = {}; | ||
@@ -91,7 +98,21 @@ const totalBorrowedRange = new range_1.RangedValue(); | ||
}); | ||
return Object.keys(borrowed).map(address => ({ | ||
address: address.toLowerCase(), | ||
amount: CreditRewards.computeRewardInt(toBlock, borrowedRange[address], totalBorrowedRange, rewardPerBlock), | ||
})); | ||
return { | ||
borrowedRange, | ||
totalBorrowedRange, | ||
borrowed, | ||
totalBorrowed, | ||
}; | ||
} | ||
static async computeCMStats(creditManager, provider, toBlock) { | ||
const toBlockQuery = toBlock || (await provider.getBlockNumber()); | ||
const cm = sdk_1.ICreditManagerV2__factory.connect(creditManager, provider); | ||
const cc = sdk_1.ICreditConfigurator__factory.connect(await cm.creditConfigurator(), provider); | ||
const creditFacadesEvents = await cc.queryFilter(cc.filters.CreditFacadeUpgraded()); | ||
const events = []; | ||
for (const cfe of creditFacadesEvents) { | ||
const query = await CreditRewards.query(cfe.args.newCreditFacade, provider, toBlockQuery); | ||
events.push(...query); | ||
} | ||
return CreditRewards.parseCMEvents(events); | ||
} | ||
static computeRewardInt(toBlock, balance, totalSupply, rewardPerBlock) { | ||
@@ -98,0 +119,0 @@ const keys = Array.from(new Set([ |
{ | ||
"name": "@gearbox-protocol/airdrop", | ||
"description": "Airdrop center for Gearbox protocol", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"homepage": "https://gearbox.fi", | ||
@@ -32,4 +32,4 @@ "keywords": [ | ||
"test": "npx mocha --require ts-node/register core/**/*.spec.ts", | ||
"update": "npx hardhat run scripts/updateRewards.ts -- network mainnet", | ||
"update-goerli": "npx hardhat run scripts/updateRewards.ts -- network goerli" | ||
"update": "npx hardhat run scripts/updateRewards.ts --network mainnet", | ||
"update-goerli": "npx hardhat run scripts/updateRewards.ts --network goerli" | ||
}, | ||
@@ -36,0 +36,0 @@ "dependencies": {}, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37442
745