@gearbox-protocol/airdrop
Advanced tools
Comparing version 1.4.7 to 1.5.0
/// <reference types="node" /> | ||
import { BigNumber } from "ethers"; | ||
export default class BalanceTree { | ||
@@ -7,8 +6,8 @@ private readonly tree; | ||
account: string; | ||
amount: BigNumber; | ||
amount: bigint; | ||
}[]); | ||
static verifyProof(index: number | BigNumber, account: string, amount: BigNumber, proof: Buffer[], root: Buffer): boolean; | ||
static toNode(index: number | BigNumber, account: string, amount: BigNumber): Buffer; | ||
static verifyProof(index: number | bigint, account: string, amount: bigint, proof: Buffer[], root: Buffer): boolean; | ||
static toNode(index: number | bigint, account: string, amount: bigint): Buffer; | ||
getHexRoot(): string; | ||
getProof(index: number | BigNumber, account: string, amount: BigNumber): string[]; | ||
getProof(index: number | bigint, account: string, amount: bigint): string[]; | ||
} |
@@ -14,3 +14,3 @@ import { BigNumberish } from "ethers"; | ||
} | ||
export declare type ClaimableBalance = { | ||
export type ClaimableBalance = { | ||
address: string; | ||
@@ -17,0 +17,0 @@ amount: BigNumberish; |
@@ -9,2 +9,3 @@ "use strict"; | ||
const balance_tree_1 = __importDefault(require("./balance-tree")); | ||
const sdk_1 = require("@gearbox-protocol/sdk"); | ||
const { isAddress, getAddress } = ethers_1.utils; | ||
@@ -19,4 +20,4 @@ function parseBalanceMap(balances) { | ||
throw new Error(`Duplicate address: ${parsed}`); | ||
const parsedNum = ethers_1.BigNumber.from(earnings); | ||
if (parsedNum.lte(0)) | ||
const parsedNum = (0, sdk_1.toBigInt)(earnings); | ||
if (parsedNum <= 0) | ||
throw new Error(`Invalid amount for account: ${account}`); | ||
@@ -28,3 +29,3 @@ memo[parsed] = { amount: parsedNum }; | ||
// construct a tree | ||
const tree = new balance_tree_1.default(sortedAddresses.map((address) => ({ | ||
const tree = new balance_tree_1.default(sortedAddresses.map(address => ({ | ||
account: address, | ||
@@ -38,3 +39,3 @@ amount: dataByAddress[address].amount, | ||
index, | ||
amount: amount.toHexString(), | ||
amount: sdk_1.BigIntMath.toHexString(amount), | ||
proof: tree.getProof(index, address, amount), | ||
@@ -44,7 +45,7 @@ }; | ||
}, {}); | ||
const tokenTotal = sortedAddresses.reduce((memo, key) => memo.add(dataByAddress[key].amount), ethers_1.BigNumber.from(0)); | ||
const tokenTotal = sortedAddresses.reduce((memo, key) => memo + dataByAddress[key].amount, 0n); | ||
return { | ||
merkleRoot: tree.getHexRoot(), | ||
toBlock: 0, | ||
tokenTotal: tokenTotal.toHexString(), | ||
tokenTotal: sdk_1.BigIntMath.toHexString(tokenTotal), | ||
claims, | ||
@@ -51,0 +52,0 @@ }; |
@@ -5,3 +5,2 @@ "use strict"; | ||
const sdk_1 = require("@gearbox-protocol/sdk"); | ||
const ethers_1 = require("ethers"); | ||
const range_1 = require("./range"); | ||
@@ -23,22 +22,22 @@ exports.creditRewardsPerBlock = { | ||
const GEAR_PER_BLOCK = { | ||
dDAI: 166, | ||
dUSDC: 166, | ||
dWETH: 230, | ||
dWBTC: 0, | ||
dwstETH: 0, | ||
dFRAX: 0, | ||
dDAI: 166n, | ||
dUSDC: 166n, | ||
dWETH: 230n, | ||
dWBTC: 0n, | ||
dwstETH: 0n, | ||
dFRAX: 0n, | ||
}; | ||
const GOERLI_BLOCK = 7694030; | ||
exports.creditRewardsPerBlock[sdk_1.CREDIT_MANAGER_DAI_V2_GOERLI].addValue(GOERLI_BLOCK, ethers_1.BigNumber.from(10).pow(18).mul(GEAR_PER_BLOCK.dDAI).div(100)); | ||
exports.creditRewardsPerBlock[sdk_1.CREDIT_MANAGER_USDC_V2_GOERLI].addValue(GOERLI_BLOCK, ethers_1.BigNumber.from(10).pow(18).mul(GEAR_PER_BLOCK.dUSDC).div(100)); | ||
exports.creditRewardsPerBlock[sdk_1.CREDIT_MANAGER_WETH_V2_GOERLI].addValue(GOERLI_BLOCK, ethers_1.BigNumber.from(10).pow(18).mul(GEAR_PER_BLOCK.dWETH).div(100)); | ||
exports.creditRewardsPerBlock[sdk_1.CREDIT_MANAGER_WSTETH_V2_GOERLI].addValue(GOERLI_BLOCK, ethers_1.BigNumber.from(10).pow(18).mul(GEAR_PER_BLOCK.dwstETH).div(100)); | ||
exports.creditRewardsPerBlock[sdk_1.CREDIT_MANAGER_WBTC_V2_GOERLI].addValue(GOERLI_BLOCK, ethers_1.BigNumber.from(10).pow(18).mul(GEAR_PER_BLOCK.dWBTC).div(100)); | ||
exports.creditRewardsPerBlock[sdk_1.CREDIT_MANAGER_DAI_V2_GOERLI].addValue(GOERLI_BLOCK, (10n ** 18n * GEAR_PER_BLOCK.dDAI) / 100n); | ||
exports.creditRewardsPerBlock[sdk_1.CREDIT_MANAGER_USDC_V2_GOERLI].addValue(GOERLI_BLOCK, (10n ** 18n * GEAR_PER_BLOCK.dUSDC) / 100n); | ||
exports.creditRewardsPerBlock[sdk_1.CREDIT_MANAGER_WETH_V2_GOERLI].addValue(GOERLI_BLOCK, (10n ** 18n * GEAR_PER_BLOCK.dWETH) / 100n); | ||
exports.creditRewardsPerBlock[sdk_1.CREDIT_MANAGER_WSTETH_V2_GOERLI].addValue(GOERLI_BLOCK, (10n ** 18n * GEAR_PER_BLOCK.dwstETH) / 100n); | ||
exports.creditRewardsPerBlock[sdk_1.CREDIT_MANAGER_WBTC_V2_GOERLI].addValue(GOERLI_BLOCK, (10n ** 18n * GEAR_PER_BLOCK.dWBTC) / 100n); | ||
const MAINNET_BLOCK = 16033000; | ||
exports.creditRewardsPerBlock[sdk_1.CREDIT_MANAGER_DAI_V2_MAINNET].addValue(MAINNET_BLOCK, ethers_1.BigNumber.from(10).pow(18).mul(GEAR_PER_BLOCK.dDAI).div(100)); | ||
exports.creditRewardsPerBlock[sdk_1.CREDIT_MANAGER_USDC_V2_MAINNET].addValue(MAINNET_BLOCK, ethers_1.BigNumber.from(10).pow(18).mul(GEAR_PER_BLOCK.dUSDC).div(100)); | ||
exports.creditRewardsPerBlock[sdk_1.CREDIT_MANAGER_WETH_V2_MAINNET].addValue(MAINNET_BLOCK, ethers_1.BigNumber.from(10).pow(18).mul(GEAR_PER_BLOCK.dWETH).div(100)); | ||
exports.creditRewardsPerBlock[sdk_1.CREDIT_MANAGER_WSTETH_V2_MAINNET].addValue(MAINNET_BLOCK, ethers_1.BigNumber.from(10).pow(18).mul(GEAR_PER_BLOCK.dwstETH).div(100)); | ||
exports.creditRewardsPerBlock[sdk_1.CREDIT_MANAGER_WBTC_V2_MAINNET].addValue(MAINNET_BLOCK, ethers_1.BigNumber.from(10).pow(18).mul(GEAR_PER_BLOCK.dWBTC).div(100)); | ||
exports.creditRewardsPerBlock[sdk_1.CREDIT_MANAGER_DAI_V2_MAINNET].addValue(MAINNET_BLOCK, (10n ** 18n * GEAR_PER_BLOCK.dDAI) / 100n); | ||
exports.creditRewardsPerBlock[sdk_1.CREDIT_MANAGER_USDC_V2_MAINNET].addValue(MAINNET_BLOCK, (10n ** 18n * GEAR_PER_BLOCK.dUSDC) / 100n); | ||
exports.creditRewardsPerBlock[sdk_1.CREDIT_MANAGER_WETH_V2_MAINNET].addValue(MAINNET_BLOCK, (10n ** 18n * GEAR_PER_BLOCK.dWETH) / 100n); | ||
exports.creditRewardsPerBlock[sdk_1.CREDIT_MANAGER_WSTETH_V2_MAINNET].addValue(MAINNET_BLOCK, (10n ** 18n * GEAR_PER_BLOCK.dwstETH) / 100n); | ||
exports.creditRewardsPerBlock[sdk_1.CREDIT_MANAGER_WBTC_V2_MAINNET].addValue(MAINNET_BLOCK, (10n ** 18n * GEAR_PER_BLOCK.dWBTC) / 100n); | ||
const FRAX_MAINNET_BLOCK = 16033000; | ||
exports.creditRewardsPerBlock[sdk_1.CREDIT_MANAGER_FRAX_V2_MAINNET].addValue(FRAX_MAINNET_BLOCK, ethers_1.BigNumber.from(10).pow(18).mul(GEAR_PER_BLOCK.dFRAX).div(100)); | ||
exports.creditRewardsPerBlock[sdk_1.CREDIT_MANAGER_FRAX_V2_MAINNET].addValue(FRAX_MAINNET_BLOCK, (10n ** 18n * GEAR_PER_BLOCK.dFRAX) / 100n); |
import { TypedEvent } from "@gearbox-protocol/sdk/lib/types/common"; | ||
import { BigNumber, providers } from "ethers"; | ||
import { providers } from "ethers"; | ||
import { Reward } from "./poolRewards"; | ||
import { RangedValue } from "./range"; | ||
export declare class CreditRewards { | ||
static computeReward(creditManager: string, address: string, provider: providers.Provider, toBlock?: number): Promise<BigNumber>; | ||
static computeReward(creditManager: string, address: string, provider: providers.Provider, toBlock?: number): Promise<bigint>; | ||
static computeAllRewards(creditManager: string, provider: providers.Provider, toBlock?: number): Promise<Array<Reward>>; | ||
@@ -11,4 +11,4 @@ static formatEvents(parsed: { | ||
totalBorrowedRange: RangedValue; | ||
borrowed: Record<string, BigNumber>; | ||
totalBorrowed: BigNumber; | ||
borrowed: Record<string, bigint>; | ||
totalBorrowed: bigint; | ||
}, rewardPerBlock: RangedValue, toBlock: number): Array<Reward>; | ||
@@ -18,4 +18,4 @@ static parseCMEvents(events: Array<TypedEvent>): { | ||
totalBorrowedRange: RangedValue; | ||
borrowed: Record<string, BigNumber>; | ||
totalBorrowed: BigNumber; | ||
borrowed: Record<string, bigint>; | ||
totalBorrowed: bigint; | ||
}; | ||
@@ -25,6 +25,6 @@ static computeCMStats(creditManager: string, provider: providers.Provider, toBlock?: number): Promise<{ | ||
totalBorrowedRange: RangedValue; | ||
borrowed: Record<string, BigNumber>; | ||
totalBorrowed: BigNumber; | ||
borrowed: Record<string, bigint>; | ||
totalBorrowed: bigint; | ||
}>; | ||
static computeRewardInt(toBlock: number, balance: RangedValue, totalSupply: RangedValue, rewardPerBlock: RangedValue): BigNumber; | ||
static computeRewardInt(toBlock: number, balance: RangedValue, totalSupply: RangedValue, rewardPerBlock: RangedValue): bigint; | ||
protected static getCMEvents(creditManager: string, provider: providers.Provider, toBlock: number): Promise<TypedEvent<any, any>[]>; | ||
@@ -31,0 +31,0 @@ protected static query(creditFacade: string, provider: providers.Provider, toBlock: number): Promise<Array<TypedEvent>>; |
@@ -5,3 +5,2 @@ "use strict"; | ||
const sdk_1 = require("@gearbox-protocol/sdk"); | ||
const ethers_1 = require("ethers"); | ||
const creditRewardParams_1 = require("./creditRewardParams"); | ||
@@ -15,3 +14,3 @@ const range_1 = require("./range"); | ||
const rewardFound = rewards.find(r => r.address === addressLC); | ||
const reward = !rewardFound ? ethers_1.BigNumber.from(0) : rewardFound.amount; | ||
const reward = !rewardFound ? 0n : rewardFound.amount; | ||
return reward; | ||
@@ -37,3 +36,3 @@ } | ||
const borrowed = {}; | ||
let totalBorrowed = ethers_1.BigNumber.from(0); | ||
let totalBorrowed = 0n; | ||
const cfi = sdk_1.ICreditFacade__factory.createInterface(); | ||
@@ -44,4 +43,5 @@ events.forEach(e => { | ||
case cfi.getEventTopic("OpenCreditAccount"): { | ||
const { onBehalfOf, borrowAmount } = event.args; | ||
totalBorrowed = totalBorrowed.add(borrowAmount); | ||
const { onBehalfOf, borrowAmount: ba } = event.args; | ||
const borrowAmount = (0, sdk_1.toBigInt)(ba); | ||
totalBorrowed = totalBorrowed + borrowAmount; | ||
totalBorrowedRange.addValue(e.blockNumber, totalBorrowed); | ||
@@ -61,13 +61,14 @@ borrowed[onBehalfOf] = borrowAmount; | ||
.args; | ||
totalBorrowed = totalBorrowed.sub(borrowed[borrower]); | ||
totalBorrowed = totalBorrowed - borrowed[borrower]; | ||
totalBorrowedRange.addValue(e.blockNumber, totalBorrowed); | ||
borrowed[borrower] = ethers_1.BigNumber.from(0); | ||
borrowedRange[borrower].addValue(e.blockNumber, ethers_1.BigNumber.from(0)); | ||
borrowed[borrower] = 0n; | ||
borrowedRange[borrower].addValue(e.blockNumber, 0n); | ||
break; | ||
} | ||
case cfi.getEventTopic("IncreaseBorrowedAmount"): { | ||
const { borrower, amount } = event.args; | ||
totalBorrowed = totalBorrowed.add(amount); | ||
const { borrower, amount: a } = event.args; | ||
const amount = (0, sdk_1.toBigInt)(a); | ||
totalBorrowed = totalBorrowed + amount; | ||
totalBorrowedRange.addValue(e.blockNumber, totalBorrowed); | ||
borrowed[borrower] = borrowed[borrower].add(amount); | ||
borrowed[borrower] = borrowed[borrower] + amount; | ||
borrowedRange[borrower].addValue(e.blockNumber, borrowed[borrower]); | ||
@@ -77,6 +78,7 @@ break; | ||
case cfi.getEventTopic("DecreaseBorrowedAmount"): { | ||
const { borrower, amount } = event.args; | ||
totalBorrowed = totalBorrowed.sub(amount); | ||
const { borrower, amount: a } = event.args; | ||
const amount = (0, sdk_1.toBigInt)(a); | ||
totalBorrowed = totalBorrowed - amount; | ||
totalBorrowedRange.addValue(e.blockNumber, totalBorrowed); | ||
borrowed[borrower] = borrowed[borrower].sub(amount); | ||
borrowed[borrower] = borrowed[borrower] - amount; | ||
borrowedRange[borrower].addValue(e.blockNumber, borrowed[borrower]); | ||
@@ -91,5 +93,5 @@ break; | ||
} | ||
borrowed[oldOwner] = ethers_1.BigNumber.from(0); | ||
borrowed[oldOwner] = 0n; | ||
borrowedRange[newOwner].addValue(e.blockNumber, borrowed[newOwner]); | ||
borrowedRange[oldOwner].addValue(e.blockNumber, ethers_1.BigNumber.from(0)); | ||
borrowedRange[oldOwner].addValue(e.blockNumber, 0n); | ||
break; | ||
@@ -119,3 +121,3 @@ } | ||
])).sort((a, b) => (a > b ? 1 : -1)); | ||
let total = ethers_1.BigNumber.from(0); | ||
let total = 0n; | ||
const balancesArr = balance.getValues(keys); | ||
@@ -127,7 +129,7 @@ const totalSupplyArr = totalSupply.getValues(keys); | ||
const nextBlock = i === keys.length - 1 ? toBlock : keys[i + 1]; | ||
if (!totalSupplyArr[i].isZero() && curBlock <= nextBlock) { | ||
total = total.add(balancesArr[i] | ||
.mul(nextBlock - curBlock) | ||
.mul(rewardsArr[i]) | ||
.div(totalSupplyArr[i])); | ||
if (totalSupplyArr[i] !== 0n && curBlock <= nextBlock) { | ||
total = | ||
total + | ||
(balancesArr[i] * BigInt(nextBlock - curBlock) * rewardsArr[i]) / | ||
totalSupplyArr[i]; | ||
} | ||
@@ -134,0 +136,0 @@ } |
import { DieselTokenTypes, NetworkType } from "@gearbox-protocol/sdk"; | ||
import { RangedValue } from "./range"; | ||
export declare const poolRewardsPerBlock: Record<NetworkType, Record<DieselTokenTypes, RangedValue>>; | ||
export declare const GEAR_PER_BLOCK: Record<DieselTokenTypes, number>; | ||
export declare const GEAR_PER_BLOCK_GIP30: Record<DieselTokenTypes, number>; | ||
export declare const GEAR_PER_BLOCK: Record<DieselTokenTypes, bigint>; | ||
export declare const GEAR_PER_BLOCK_GIP30: Record<DieselTokenTypes, bigint>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.GEAR_PER_BLOCK_GIP30 = exports.GEAR_PER_BLOCK = exports.poolRewardsPerBlock = void 0; | ||
const ethers_1 = require("ethers"); | ||
const range_1 = require("./range"); | ||
@@ -25,39 +24,38 @@ exports.poolRewardsPerBlock = { | ||
exports.GEAR_PER_BLOCK = { | ||
dDAI: 2283, | ||
dUSDC: 2283, | ||
dWETH: 3196, | ||
dWBTC: 913, | ||
dwstETH: 1636, | ||
dFRAX: 0, | ||
dDAI: 2283n, | ||
dUSDC: 2283n, | ||
dWETH: 3196n, | ||
dWBTC: 913n, | ||
dwstETH: 1636n, | ||
dFRAX: 0n, | ||
}; | ||
exports.GEAR_PER_BLOCK_GIP30 = { | ||
dDAI: 2283, | ||
dUSDC: 3101, | ||
dWETH: 4014, | ||
dWBTC: 457, | ||
dwstETH: 0, | ||
dFRAX: 641, | ||
dDAI: 2283n, | ||
dUSDC: 3101n, | ||
dWETH: 4014n, | ||
dWBTC: 457n, | ||
dwstETH: 0n, | ||
dFRAX: 641n, | ||
}; | ||
const GOERLI_BLOCK = 7694030; | ||
exports.poolRewardsPerBlock.Goerli.dDAI.addValue(GOERLI_BLOCK, ethers_1.BigNumber.from(10).pow(18).mul(exports.GEAR_PER_BLOCK.dDAI).div(100)); | ||
exports.poolRewardsPerBlock.Goerli.dUSDC.addValue(GOERLI_BLOCK, ethers_1.BigNumber.from(10).pow(18).mul(exports.GEAR_PER_BLOCK.dUSDC).div(100)); | ||
exports.poolRewardsPerBlock.Goerli.dWETH.addValue(GOERLI_BLOCK, ethers_1.BigNumber.from(10).pow(18).mul(exports.GEAR_PER_BLOCK.dWETH).div(100)); | ||
exports.poolRewardsPerBlock.Goerli.dWBTC.addValue(GOERLI_BLOCK, ethers_1.BigNumber.from(10).pow(18).mul(exports.GEAR_PER_BLOCK.dWBTC).div(100)); | ||
exports.poolRewardsPerBlock.Goerli.dwstETH.addValue(GOERLI_BLOCK, ethers_1.BigNumber.from(10).pow(18).mul(exports.GEAR_PER_BLOCK.dwstETH).div(100)); | ||
exports.poolRewardsPerBlock.Goerli.dDAI.addValue(GOERLI_BLOCK, (10n ** 18n * exports.GEAR_PER_BLOCK.dDAI) / 100n); | ||
exports.poolRewardsPerBlock.Goerli.dUSDC.addValue(GOERLI_BLOCK, (10n ** 18n * exports.GEAR_PER_BLOCK.dUSDC) / 100n); | ||
exports.poolRewardsPerBlock.Goerli.dWETH.addValue(GOERLI_BLOCK, (10n ** 18n * exports.GEAR_PER_BLOCK.dWETH) / 100n); | ||
exports.poolRewardsPerBlock.Goerli.dWBTC.addValue(GOERLI_BLOCK, (10n ** 18n * exports.GEAR_PER_BLOCK.dWBTC) / 100n); | ||
exports.poolRewardsPerBlock.Goerli.dwstETH.addValue(GOERLI_BLOCK, (10n ** 18n * exports.GEAR_PER_BLOCK.dwstETH) / 100n); | ||
const GOERLI_BLOCK_FRAX = 7694030; | ||
exports.poolRewardsPerBlock.Goerli.dFRAX.addValue(GOERLI_BLOCK_FRAX, ethers_1.BigNumber.from(10).pow(18).mul(exports.GEAR_PER_BLOCK.dFRAX).div(100)); | ||
exports.poolRewardsPerBlock.Goerli.dFRAX.addValue(GOERLI_BLOCK_FRAX, (10n ** 18n * exports.GEAR_PER_BLOCK.dFRAX) / 100n); | ||
const MAINNET_BLOCK = 15820000; | ||
exports.poolRewardsPerBlock.Mainnet.dDAI.addValue(MAINNET_BLOCK, ethers_1.BigNumber.from(10).pow(18).mul(exports.GEAR_PER_BLOCK.dDAI).div(100)); | ||
exports.poolRewardsPerBlock.Mainnet.dUSDC.addValue(MAINNET_BLOCK, ethers_1.BigNumber.from(10).pow(18).mul(exports.GEAR_PER_BLOCK.dUSDC).div(100)); | ||
exports.poolRewardsPerBlock.Mainnet.dWETH.addValue(MAINNET_BLOCK, ethers_1.BigNumber.from(10).pow(18).mul(exports.GEAR_PER_BLOCK.dWETH).div(100)); | ||
exports.poolRewardsPerBlock.Mainnet.dWBTC.addValue(MAINNET_BLOCK, ethers_1.BigNumber.from(10).pow(18).mul(exports.GEAR_PER_BLOCK.dWBTC).div(100)); | ||
exports.poolRewardsPerBlock.Mainnet.dwstETH.addValue(MAINNET_BLOCK, ethers_1.BigNumber.from(10).pow(18).mul(exports.GEAR_PER_BLOCK.dwstETH).div(100)); | ||
// poolRewardsPerBlock.Goerli.dDAI.addValue(90000, BigNumber.from(0)); | ||
exports.poolRewardsPerBlock.Mainnet.dDAI.addValue(MAINNET_BLOCK, (10n ** 18n * exports.GEAR_PER_BLOCK.dDAI) / 100n); | ||
exports.poolRewardsPerBlock.Mainnet.dUSDC.addValue(MAINNET_BLOCK, (10n ** 18n * exports.GEAR_PER_BLOCK.dUSDC) / 100n); | ||
exports.poolRewardsPerBlock.Mainnet.dWETH.addValue(MAINNET_BLOCK, (10n ** 18n * exports.GEAR_PER_BLOCK.dWETH) / 100n); | ||
exports.poolRewardsPerBlock.Mainnet.dWBTC.addValue(MAINNET_BLOCK, (10n ** 18n * exports.GEAR_PER_BLOCK.dWBTC) / 100n); | ||
exports.poolRewardsPerBlock.Mainnet.dwstETH.addValue(MAINNET_BLOCK, (10n ** 18n * exports.GEAR_PER_BLOCK.dwstETH) / 100n); | ||
const MAINNET_BLOCK_GIP30 = 15977000; | ||
exports.poolRewardsPerBlock.Mainnet.dDAI.addValue(MAINNET_BLOCK_GIP30, ethers_1.BigNumber.from(10).pow(18).mul(exports.GEAR_PER_BLOCK_GIP30.dDAI).div(100)); | ||
exports.poolRewardsPerBlock.Mainnet.dUSDC.addValue(MAINNET_BLOCK_GIP30, ethers_1.BigNumber.from(10).pow(18).mul(exports.GEAR_PER_BLOCK_GIP30.dUSDC).div(100)); | ||
exports.poolRewardsPerBlock.Mainnet.dWETH.addValue(MAINNET_BLOCK_GIP30, ethers_1.BigNumber.from(10).pow(18).mul(exports.GEAR_PER_BLOCK_GIP30.dWETH).div(100)); | ||
exports.poolRewardsPerBlock.Mainnet.dWBTC.addValue(MAINNET_BLOCK_GIP30, ethers_1.BigNumber.from(10).pow(18).mul(exports.GEAR_PER_BLOCK_GIP30.dWBTC).div(100)); | ||
exports.poolRewardsPerBlock.Mainnet.dwstETH.addValue(MAINNET_BLOCK_GIP30, ethers_1.BigNumber.from(10).pow(18).mul(exports.GEAR_PER_BLOCK_GIP30.dwstETH).div(100)); | ||
exports.poolRewardsPerBlock.Mainnet.dDAI.addValue(MAINNET_BLOCK_GIP30, (10n ** 18n * exports.GEAR_PER_BLOCK_GIP30.dDAI) / 100n); | ||
exports.poolRewardsPerBlock.Mainnet.dUSDC.addValue(MAINNET_BLOCK_GIP30, (10n ** 18n * exports.GEAR_PER_BLOCK_GIP30.dUSDC) / 100n); | ||
exports.poolRewardsPerBlock.Mainnet.dWETH.addValue(MAINNET_BLOCK_GIP30, (10n ** 18n * exports.GEAR_PER_BLOCK_GIP30.dWETH) / 100n); | ||
exports.poolRewardsPerBlock.Mainnet.dWBTC.addValue(MAINNET_BLOCK_GIP30, (10n ** 18n * exports.GEAR_PER_BLOCK_GIP30.dWBTC) / 100n); | ||
exports.poolRewardsPerBlock.Mainnet.dwstETH.addValue(MAINNET_BLOCK_GIP30, (10n ** 18n * exports.GEAR_PER_BLOCK_GIP30.dwstETH) / 100n); | ||
const MAINNET_BLOCK_FRAX = 16720000; | ||
exports.poolRewardsPerBlock.Mainnet.dFRAX.addValue(MAINNET_BLOCK_FRAX, ethers_1.BigNumber.from(10).pow(18).mul(exports.GEAR_PER_BLOCK_GIP30.dFRAX).div(100)); | ||
exports.poolRewardsPerBlock.Mainnet.dFRAX.addValue(MAINNET_BLOCK_FRAX, (10n ** 18n * exports.GEAR_PER_BLOCK_GIP30.dFRAX) / 100n); |
import { NetworkType, SupportedToken } from "@gearbox-protocol/sdk"; | ||
import { TransferEvent } from "@gearbox-protocol/sdk/lib/types/@openzeppelin/contracts/token/ERC20/IERC20"; | ||
import { BigNumber, providers } from "ethers"; | ||
import { providers } from "ethers"; | ||
import { RangedValue } from "./range"; | ||
@@ -8,13 +8,13 @@ export declare const POOL_REWARDS_DIESEL_TOKENS: Array<SupportedToken>; | ||
address: string; | ||
amount: BigNumber; | ||
amount: bigint; | ||
} | ||
export declare class PoolRewards { | ||
static computeReward(dieselToken: string, address: string, provider: providers.Provider, networkType: NetworkType, toBlock?: number): Promise<BigNumber>; | ||
static computeReward(dieselToken: string, address: string, provider: providers.Provider, networkType: NetworkType, toBlock?: number): Promise<bigint>; | ||
static computeAllRewards(dieselToken: string, provider: providers.Provider, networkType: NetworkType, toBlock?: number): Promise<Array<Reward>>; | ||
static computeRewardInt(toBlock: number, balance: RangedValue, totalSupply: RangedValue, rewardPerBlock: RangedValue): BigNumber; | ||
static computeRewardInt(toBlock: number, balance: RangedValue, totalSupply: RangedValue, rewardPerBlock: RangedValue): bigint; | ||
static computeAllRanges(dieselToken: string, provider: providers.Provider, toBlock: number): Promise<{ | ||
totalSupplyRange: RangedValue; | ||
balancesRange: Record<string, RangedValue>; | ||
totalSupply: BigNumber; | ||
balances: Record<string, BigNumber>; | ||
totalSupply: bigint; | ||
balances: Record<string, bigint>; | ||
}>; | ||
@@ -21,0 +21,0 @@ protected static query(dieselToken: string, provider: providers.Provider, toBlock: number): Promise<Array<TransferEvent>>; |
@@ -5,3 +5,2 @@ "use strict"; | ||
const sdk_1 = require("@gearbox-protocol/sdk"); | ||
const ethers_1 = require("ethers"); | ||
const poolRewardParams_1 = require("./poolRewardParams"); | ||
@@ -26,12 +25,13 @@ const range_1 = require("./range"); | ||
const totalSupplyRange = new range_1.RangedValue(); | ||
let totalSupply = ethers_1.BigNumber.from(0); | ||
let balance = ethers_1.BigNumber.from(0); | ||
let totalSupply = 0n; | ||
let balance = 0n; | ||
events.forEach(e => { | ||
const from = e.args.from.toLowerCase(); | ||
const eventValue = (0, sdk_1.toBigInt)(e.args.value); | ||
if (from === sdk_1.ADDRESS_0X0) { | ||
totalSupply = totalSupply.add(e.args.value); | ||
totalSupply = totalSupply + (0, sdk_1.toBigInt)(e.args.value); | ||
totalSupplyRange.addValue(e.blockNumber, totalSupply); | ||
} | ||
else if (from === addrLC) { | ||
balance = balance.sub(e.args.value); | ||
balance = balance - (0, sdk_1.toBigInt)(e.args.value); | ||
balanceRange.addValue(e.blockNumber, balance); | ||
@@ -41,7 +41,7 @@ } | ||
if (to === sdk_1.ADDRESS_0X0) { | ||
totalSupply = totalSupply.sub(e.args.value); | ||
totalSupply = totalSupply - (0, sdk_1.toBigInt)(e.args.value); | ||
totalSupplyRange.addValue(e.blockNumber, totalSupply); | ||
} | ||
else if (to === addrLC) { | ||
balance = balance.add(e.args.value); | ||
balance = balance + (0, sdk_1.toBigInt)(e.args.value); | ||
balanceRange.addValue(e.blockNumber, balance); | ||
@@ -69,3 +69,3 @@ } | ||
])).sort((a, b) => (a > b ? 1 : -1)); | ||
let total = ethers_1.BigNumber.from(0); | ||
let total = 0n; | ||
const balancesArr = balance.getValues(keys); | ||
@@ -77,7 +77,7 @@ const totalSupplyArr = totalSupply.getValues(keys); | ||
const nextBlock = i === keys.length - 1 ? toBlock : keys[i + 1]; | ||
if (!totalSupplyArr[i].isZero() && curBlock <= nextBlock) { | ||
total = total.add(balancesArr[i] | ||
.mul(nextBlock - curBlock) | ||
.mul(rewardsArr[i]) | ||
.div(totalSupplyArr[i])); | ||
if (totalSupplyArr[i] !== 0n && curBlock <= nextBlock) { | ||
total = | ||
total + | ||
(balancesArr[i] * BigInt(nextBlock - curBlock) * rewardsArr[i]) / | ||
totalSupplyArr[i]; | ||
} | ||
@@ -91,3 +91,3 @@ } | ||
const balancesRange = {}; | ||
let totalSupply = ethers_1.BigNumber.from(0); | ||
let totalSupply = 0n; | ||
let balances = {}; | ||
@@ -98,8 +98,9 @@ query | ||
const from = e.args.from.toLowerCase(); | ||
const eventValue = (0, sdk_1.toBigInt)(e.args.value); | ||
if (from === sdk_1.ADDRESS_0X0) { | ||
totalSupply = totalSupply.add(e.args.value); | ||
totalSupply = totalSupply + (0, sdk_1.toBigInt)(e.args.value); | ||
totalSupplyRange.addValue(e.blockNumber, totalSupply); | ||
} | ||
else { | ||
balances[from] = balances[from].sub(e.args.value); | ||
balances[from] = balances[from] - (0, sdk_1.toBigInt)(e.args.value); | ||
balancesRange[from].addValue(e.blockNumber, balances[from]); | ||
@@ -109,11 +110,11 @@ } | ||
if (to === sdk_1.ADDRESS_0X0) { | ||
totalSupply = totalSupply.sub(e.args.value); | ||
totalSupply = totalSupply - (0, sdk_1.toBigInt)(e.args.value); | ||
totalSupplyRange.addValue(e.blockNumber, totalSupply); | ||
} | ||
else { | ||
if (!balances[to]) { | ||
balances[to] = ethers_1.BigNumber.from(0); | ||
if (balances[to] === undefined) { | ||
balances[to] = 0n; | ||
balancesRange[to] = new range_1.RangedValue(); | ||
} | ||
balances[to] = balances[to].add(e.args.value); | ||
balances[to] = balances[to] + (0, sdk_1.toBigInt)(e.args.value); | ||
balancesRange[to].addValue(e.blockNumber, balances[to]); | ||
@@ -120,0 +121,0 @@ } |
@@ -1,16 +0,15 @@ | ||
import { BigNumber } from "ethers"; | ||
interface RangedValuesProps { | ||
keys: Array<number>; | ||
data: Array<[number, BigNumber]>; | ||
initialValue: BigNumber; | ||
data: Array<[number, bigint]>; | ||
initialValue: bigint; | ||
} | ||
export declare class RangedValue { | ||
protected initialValue: BigNumber; | ||
protected data: Map<number, BigNumber>; | ||
protected initialValue: bigint; | ||
protected data: Map<number, bigint>; | ||
protected _keys: Array<number>; | ||
constructor(props?: Partial<RangedValuesProps>); | ||
addValue(from: number, value: BigNumber): void; | ||
getValue(at: number): BigNumber; | ||
getValues(sortedKeys: Array<number>): Array<BigNumber>; | ||
protected getMapValue(index: number): BigNumber; | ||
addValue(from: number, value: bigint): void; | ||
getValue(at: number): bigint; | ||
getValues(sortedKeys: Array<number>): Array<bigint>; | ||
protected getMapValue(index: number): bigint; | ||
get keys(): Array<number>; | ||
@@ -17,0 +16,0 @@ static fromString(jsonString?: string | null): RangedValue; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RangedValue = void 0; | ||
const ethers_1 = require("ethers"); | ||
class RangedValue { | ||
@@ -10,3 +9,3 @@ initialValue; | ||
constructor(props) { | ||
const { initialValue = ethers_1.BigNumber.from(0), data = [], keys = [], } = props || {}; | ||
const { initialValue = 0n, data = [], keys = [] } = props || {}; | ||
this.initialValue = initialValue; | ||
@@ -24,3 +23,3 @@ this.data = new Map(data); | ||
const value = this.data.get(index); | ||
if (!value) | ||
if (value === undefined) | ||
throw new Error(`Unexpectedly cant find a value with index ${index}`); | ||
@@ -57,3 +56,3 @@ return value; | ||
const value = this.data.get(index); | ||
if (!value) { | ||
if (value === undefined) { | ||
if (this.data.size > 0) { | ||
@@ -77,7 +76,4 @@ throw new Error(`Can get value for ${index}`); | ||
...parsedObject, | ||
initialValue: ethers_1.BigNumber.from(parsedObject.initialValue), | ||
data: parsedObject.data.map(([key, value]) => [ | ||
key, | ||
ethers_1.BigNumber.from(value), | ||
]), | ||
initialValue: BigInt(parsedObject.initialValue), | ||
data: parsedObject.data.map(([key, value]) => [key, BigInt(value)]), | ||
}; | ||
@@ -84,0 +80,0 @@ return new RangedValue(transformed); |
@@ -1,2 +0,2 @@ | ||
declare type Action<T> = (start: number, end: number) => Promise<Array<T>>; | ||
type Action<T> = (start: number, end: number) => Promise<Array<T>>; | ||
interface ParseEventsProps<T> { | ||
@@ -3,0 +3,0 @@ action: Action<T>; |
@@ -1,2 +0,1 @@ | ||
import { BigNumber } from "ethers"; | ||
export declare const formatGear: (amount: BigNumber) => string; | ||
export declare const formatGear: (amount: bigint) => string; |
{ | ||
"name": "@gearbox-protocol/airdrop", | ||
"description": "Airdrop center for Gearbox protocol", | ||
"version": "1.4.7", | ||
"version": "1.5.0", | ||
"homepage": "https://gearbox.fi", | ||
@@ -47,3 +47,3 @@ "keywords": [ | ||
"@gearbox-protocol/prettier-config": "^1.5.0", | ||
"@gearbox-protocol/sdk": "^1.20.6", | ||
"@gearbox-protocol/sdk": "^1.23.0", | ||
"@nomiclabs/hardhat-ethers": "^2.0.5", | ||
@@ -73,3 +73,3 @@ "@nomiclabs/hardhat-etherscan": "^3.1.0", | ||
"typechain": "^8.0.0", | ||
"typescript": "^4.8.2" | ||
"typescript": "5.0.4" | ||
}, | ||
@@ -76,0 +76,0 @@ "prettier": "@gearbox-protocol/prettier-config", |
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
52521
1121