-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!-- Before opening a pull request, please read the [contributing guidelines](https://github.com/pancakeswap/pancake-frontend/blob/develop/CONTRIBUTING.md) first --> <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on updating dependencies and making changes related to gauges in the codebase. ### Detailed summary - Updated dependencies for `@pancakeswap/sdk` and `@types/lodash`. - Modified token addresses and types in `packages/gauges/src/constants/config/prod.ts`. - Added a new function `filterKilledGauges` in `packages/gauges/src/fetchAllKilledGauges.ts`. - Added new tests in `packages/gauges/src/tests/config.test.ts`. - Updated the ABI definition in `packages/gauges/src/abis/gaugesVoting.ts`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
- Loading branch information
Showing
7 changed files
with
233 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { ContractFunctionConfig, ContractFunctionResult, Hex, MulticallContracts, PublicClient } from 'viem' | ||
import { gaugesVotingABI } from './abis' | ||
import { getContract } from './contract' | ||
import { GaugeInfo } from './types' | ||
|
||
export const filterKilledGauges = async (client: PublicClient, gauges: GaugeInfo[]): Promise<GaugeInfo[]> => { | ||
const contract = getContract(client) | ||
|
||
const multicalls: MulticallContracts<ContractFunctionConfig<typeof gaugesVotingABI, 'gaugeIsKilled_'>[]> = [] | ||
|
||
for (let i = 0; i < gauges.length; i++) { | ||
multicalls.push({ | ||
...contract, | ||
functionName: 'gaugeIsKilled_', | ||
args: [gauges[i].hash as Hex], | ||
} as const) | ||
} | ||
|
||
const response = (await client.multicall({ | ||
contracts: multicalls, | ||
allowFailure: false, | ||
})) as ContractFunctionResult<typeof gaugesVotingABI, 'gaugeIsKilled_'>[] | ||
|
||
return gauges.filter((_, index) => { | ||
return !response[index] | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { chainNames } from '@pancakeswap/chains' | ||
import { FACTORY_ADDRESS_MAP, Token, computePairAddress } from '@pancakeswap/sdk' | ||
import { DEPLOYER_ADDRESSES, computePoolAddress } from '@pancakeswap/v3-sdk' | ||
import groupBy from 'lodash/groupBy' | ||
import { describe, expect, it } from 'vitest' | ||
import { CONFIG_PROD } from '../constants/config/prod' | ||
import { GaugeType } from '../types' | ||
|
||
describe('Gauges Config', async () => { | ||
const chainName = chainNames[1] | ||
|
||
const gidGroups = groupBy(CONFIG_PROD, 'gid') | ||
Object.entries(gidGroups).forEach(([gid, gauge]) => { | ||
it(`${chainName} gauges with gid #${gid} should be unique`, () => { | ||
expect(gauge.length).toBe(1) | ||
}) | ||
}) | ||
|
||
CONFIG_PROD.forEach((gauge) => { | ||
it(`${chainName} gid #${gauge.gid} tokens chainId-lpAddress-feeTier should be matched`, () => { | ||
if (gauge.type === GaugeType.V3) { | ||
const tokenA = new Token(gauge.chainId, gauge.token0Address, 18, '') | ||
const tokenB = new Token(gauge.chainId, gauge.token1Address, 18, '') | ||
const computedAddress = computePoolAddress({ | ||
deployerAddress: DEPLOYER_ADDRESSES[gauge.chainId], | ||
tokenA, | ||
tokenB, | ||
fee: gauge.feeTier, | ||
}) | ||
expect(computedAddress).toBe(gauge.address) | ||
} | ||
|
||
if (gauge.type === GaugeType.V2) { | ||
const tokenA = new Token(gauge.chainId, gauge.token0Address, 18, '') | ||
const tokenB = new Token(gauge.chainId, gauge.token1Address, 18, '') | ||
const computedAddress = computePairAddress({ | ||
factoryAddress: FACTORY_ADDRESS_MAP[gauge.chainId], | ||
tokenA, | ||
tokenB, | ||
}) | ||
expect(gauge.address).toBe(computedAddress) | ||
} | ||
}) | ||
}) | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
533887e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
web – ./apps/web
web.pancake.run
web2.pancake.run
pancake-prod.vercel.app
www.pancakeswap.finance
pancakeswap.finance
web-git-develop.pancake.run