Skip to content

Commit

Permalink
chore: update position manager vault test case (#8501)
Browse files Browse the repository at this point in the history
<!--
Before opening a pull request, please read the [contributing
guidelines](https://github.com/pancakeswap/pancake-frontend/blob/develop/CONTRIBUTING.md)
first
-->

<!--
copilot:all
-->
### <samp>🤖[[deprecated]](https://githubnext.com/copilot-for-prs-sunset)
Generated by Copilot at 4c97660</samp>

### Summary
🧪🚀🎁

<!--
1.  🧪 for testing
2.  🚀 for multicall
3.  🎁 for fetching more data
-->
Improved vaults config test and multicall function. The test now checks
more contract data, and the function uses the position manager contracts
to get token addresses.

> _To test the vaults config better_
> _They fetched more data from the setter_
> _Using `multicall`_
> _With wrappers and all_
> _To get the reward and the pair tokens' letter_

### Walkthrough
* Update test description and assertions for vault config values
([link](https://github.com/pancakeswap/pancake-frontend/pull/8501/files?diff=unified&w=0#diff-a4873ef8c9b426fec67f851d2715ff5e71540ce6cc56fdb9578c0ff36966645dL29-R33),
[link](https://github.com/pancakeswap/pancake-frontend/pull/8501/files?diff=unified&w=0#diff-a4873ef8c9b426fec67f851d2715ff5e71540ce6cc56fdb9578c0ff36966645dL64-R95))
* Update `multicall` function to fetch pool, token0, and token1
addresses from position manager adapter contract
([link](https://github.com/pancakeswap/pancake-frontend/pull/8501/files?diff=unified&w=0#diff-a4873ef8c9b426fec67f851d2715ff5e71540ce6cc56fdb9578c0ff36966645dL40-R48),
[link](https://github.com/pancakeswap/pancake-frontend/pull/8501/files?diff=unified&w=0#diff-a4873ef8c9b426fec67f851d2715ff5e71540ce6cc56fdb9578c0ff36966645dR55-R64))
  • Loading branch information
Chef-Yogi authored Dec 2, 2023
1 parent 32cc943 commit cd05c8e
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions apps/web/src/config/__tests__/vaults.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,42 @@ describe('Config position manger Vault', () => {
})

describe.concurrent(
'Config check adapter address & fee tier',
'Config check adapter address, fee tier, reward token, token0, token1',
() => {
it.each(mainnetVaults.flat())('Config check adapter address & fee tier', async (vault) => {
const client = publicClient({ chainId: vault.currencyA.chainId })
const [adapterAddress] = await client.multicall({
const [adapterAddress, rewardTokenAddress] = await client.multicall({
contracts: [
{
abi: positionManagerWrapperABI,
address: vault.address,
functionName: 'adapterAddr',
},
{
abi: positionManagerWrapperABI,
address: vault.address,
functionName: 'rewardToken',
},
],
allowFailure: false,
})
const [poolAddress] = await client.multicall({
const [poolAddress, token0Address, token1Address] = await client.multicall({
contracts: [
{
abi: positionManagerAdapterABI,
address: adapterAddress,
functionName: 'pool',
},
{
abi: positionManagerAdapterABI,
address: adapterAddress,
functionName: 'token0',
},
{
abi: positionManagerAdapterABI,
address: adapterAddress,
functionName: 'token1',
},
],
allowFailure: false,
})
Expand All @@ -61,8 +76,23 @@ describe('Config position manger Vault', () => {
allowFailure: false,
})

expect(vault.adapterAddress).toBe(adapterAddress)
expect(vault.feeTier).toBe(fee)
expect(
vault.adapterAddress,
"Expected 'adapterAddress' to be the same as the value from the smart contract",
).toBe(adapterAddress)
expect(vault.feeTier, "Expected 'feeTier' to be the same as the value from the smart contract").toBe(fee)
expect(
vault.earningToken.isToken ? vault.earningToken.address : '0x',
"Expected 'earningToken' to be the same as the value from the smart contract",
).toBe(rewardTokenAddress)
expect(
vault.currencyA.isToken ? vault.currencyA.address : '0x',
"Expected 'currencyA' address to be the same as the value from the smart contract",
).toBe(token0Address)
expect(
vault.currencyB.isToken ? vault.currencyB.address : '0x',
"Expected 'currencyB' address to be the same as the value from the smart contract",
).toBe(token1Address)
})
},
{
Expand Down

0 comments on commit cd05c8e

Please sign in to comment.