Skip to content

Commit

Permalink
fix: liquidity gauges don't need week param
Browse files Browse the repository at this point in the history
  • Loading branch information
gmbronco committed Aug 31, 2023
1 parent 0835ca2 commit 1df2430
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions modules/pool/lib/staking/gauge-staking.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class GaugeStakingService implements PoolStakingService {
let periodFinish: number;

if (gaugeVersion === 1) {
const gaugeV1 = await getContractAt(gauge.id, childChainGaugeV1Abi);
const gaugeV1 = getContractAt(gauge.id, childChainGaugeV1Abi);
const rewardData = await gaugeV1.reward_data(tokenAddress);

periodFinish = rewardData[2];
Expand All @@ -124,10 +124,10 @@ export class GaugeStakingService implements PoolStakingService {
}
} else {
// we can't get BAL rate from the reward data but got it from the inflation_rate call which set the rewardToken.rate
if (tokenAddress === this.balAddress) {
if (tokenAddress.toLowerCase() === this.balAddress.toLowerCase()) {
rewardRate = rewardToken.rate ? rewardToken.rate : '0.0';
} else {
const gaugeV2 = await getContractAt(gauge.id, childChainGaugeV2Abi);
const gaugeV2 = getContractAt(gauge.id, childChainGaugeV2Abi);
const rewardData = await gaugeV2.reward_data(tokenAddress);

periodFinish = parseFloat(formatUnits(rewardData[1], 0));
Expand Down Expand Up @@ -164,12 +164,20 @@ export class GaugeStakingService implements PoolStakingService {

async getChildChainGaugeInfo(gaugeAddresses: string[]): Promise<{ [gaugeAddress: string]: ChildChainInfo }> {
const currentWeek = Math.floor(Date.now() / 1000 / 604800);
const multicall = new Multicaller3(childChainGaugeV2Abi);
const childChainAbi = networkContext.chain === 'MAINNET'
? 'function inflation_rate() view returns (uint256)'
: 'function inflation_rate(uint256 week) view returns (uint256)';
const multicall = new Multicaller3([childChainAbi]);

let response: { [gaugeAddress: string]: ChildChainInfo } = {};

gaugeAddresses.forEach((address) => {
multicall.call(address, address, 'inflation_rate', [currentWeek], true);
// Only L2 gauges have the inflation_rate with a week parameter
if (networkContext.chain === 'MAINNET') {
multicall.call(address, address, 'inflation_rate', [], true);
} else {
multicall.call(address, address, 'inflation_rate', [currentWeek], true);
}
});

const childChainData = (await multicall.execute()) as Record<string, string | undefined>;
Expand Down

0 comments on commit 1df2430

Please sign in to comment.