Skip to content

Commit

Permalink
fix: Limit swap exits (DM) (#3946)
Browse files Browse the repository at this point in the history
* Fix ethereum pool links in auto allowlist PRs

* Add test for detecting duplicates in voting list

* Change test name

* chore: Add migration notices (#3934)

* 1.118.1

* hotfix: fix reward tokens apr breakdown (#3936)

* 1.118.2

* chore: Add farmDE pool to polygon allowlist

* add well and stg to whitelist (#3939)

* 1.118.3

* chore: Add 2BTC pool to mainnet allowlist

* Add reth pool to allowlist

* 1.118.4

* chore: Add 80TBTC-20WBTC pool to mainnet allowlist

* 1.118.5

* 1.118.6

* 1.118.7

* 1.118.8

* 1.118.9

* fix: Limit swap exits to deep pools

* chore: Add comment

---------

Co-authored-by: Alberto Gualis <[email protected]>
Co-authored-by: Tim Robinson <[email protected]>
Co-authored-by: Automated Version Bump <[email protected]>
Co-authored-by: Fábio Mendes <[email protected]>
Co-authored-by: balopco <[email protected]>
Co-authored-by: ZeKraken <[email protected]>
Co-authored-by: Tim Robinson <[email protected]>
  • Loading branch information
8 people authored Aug 11, 2023
1 parent 4bc4783 commit 9340c0b
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/allowlist-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ on:
- avalanche
- arbitrum
- base
- ethereum
- gnosis-chain
- goerli
- mainnet
- polygon
- optimism
- zkevm
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@balancer/frontend-v2",
"version": "1.118.1",
"version": "1.118.9",
"engines": {
"node": "=16",
"npm": ">=8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import useVeBal from '@/composables/useVeBAL';
import WithdrawPreviewModal from './components/WithdrawPreviewModal/WithdrawPreviewModal.vue';
import { useTokens } from '@/providers/tokens.provider';
import {
isPreMintedBptType,
tokensListExclBpt,
usePoolHelpers,
} from '@/composables/usePoolHelpers';
Expand Down Expand Up @@ -57,6 +56,7 @@ const {
validAmounts,
hasBpt,
shouldUseRecoveryExit,
canSwapExit,
} = useExitPool();
const { isWrappedNativeAssetPool } = usePoolHelpers(pool);
Expand All @@ -76,8 +76,8 @@ const tokensList = computed(() => tokensListExclBpt(pool.value));
// Limit token select modal to a subset.
const subsetTokens = computed((): string[] => {
if (!shouldUseRecoveryExit.value && isPreMintedBptType(pool.value.poolType))
return [];
// Returning an empty array means all tokens are presented in the modal.
if (!shouldUseRecoveryExit.value && canSwapExit.value) return [];
if (isWrappedNativeAssetPool.value)
return [nativeAsset.address, ...tokensList.value];
Expand Down
4 changes: 4 additions & 0 deletions src/lib/config/base/pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const pools: Pools = {
AllowList: [
'0x6fbfcf88db1aada31f34215b2a1df7fafb4883e900000000000000000000000c', // stabal3
'0xe58ca65f418d4121d6c70d4c133e60cf6fda363c000000000000000000000013', // usdc/axlusd
'0x8c2062ec8d477366c749982e3703371a7ae1e66500000000000000000000001f', // rETH/WETH
],
},
Investment: {
Expand All @@ -46,6 +47,8 @@ const pools: Pools = {
'0x52e281318fed4efffb8e46c0847a8f9b71a461a8000200000000000000000018', // 50BTC-50WETH
'0x036d68e4e0005da4ef1c9ebd53b948d2c083495e00020000000000000000001a', // 50BTC-50USD
'0xe40cbccba664c7b1a953827c062f5070b78de86800020000000000000000001b', // WETH-GOLD
'0xfab10dd71e11d0ad403cc31418b45d816f2f988200020000000000000000001d', // well-eth
'0xc69793563a8f0a2c5b25bcfb8661de50da8eae1000020000000000000000001c', // stg-usdc
],
},
Factories: {
Expand All @@ -62,6 +65,7 @@ const pools: Pools = {
'0x52e281318fed4efffb8e46c0847a8f9b71a461a8000200000000000000000018', // 50BTC-50WETH
'0x036d68e4e0005da4ef1c9ebd53b948d2c083495e00020000000000000000001a', // 50BTC-50USD
'0xe40cbccba664c7b1a953827c062f5070b78de86800020000000000000000001b', // WETH-GOLD
'0xc69793563a8f0a2c5b25bcfb8661de50da8eae1000020000000000000000001c', // stg-usdc
],
},
Metadata: {
Expand Down
3 changes: 2 additions & 1 deletion src/lib/config/mainnet/pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ const pools: Pools = {
'0x1bd2f176a812e312077bca87e37c08432bb09f3e0000000000000000000005a1', // qETH-bb-a-WETH
'0xae8535c23afedda9304b03c68a3563b75fc8f92b0000000000000000000005a0', // swETH-bb-a-WETH
'0xe8c56405bc405840154d9b572927f4197d110de10000000000000000000005a4', // rETH/bbaWETH
'0xe4e72f872c4048925a78e1e6fddac411c9ae348a0000000000000000000005bc', // 2BTC
],
},
Investment: {
Expand Down Expand Up @@ -173,6 +174,7 @@ const pools: Pools = {
'0xb841b062ea8ccf5c4cb78032e91de4ae875560420002000000000000000005b7', // 50bb-s-DAI-50bb-a-USD
'0x2e52c64fd319e380cdbcfc4577ea1fda558a32e40002000000000000000005ba', // 50bb-a-WETH-50YieldETH
'0xcebb73246fd3f0ba3e42a4ba6ff6b40d0cd02fb30001000000000000000005b8', // 20wstETH-50ETHx-20sfrxETH-10rETH
'0xa9dd57145ca13a2f05199d85e3f2739af64784270002000000000000000005be', // 80TBTC-20WBTC
],
},
Factories: {
Expand Down Expand Up @@ -267,7 +269,6 @@ const pools: Pools = {
'0x173063a30e095313eee39411f07e95a8a806014e0002000000000000000003ab',
'0x8167a1117691f39e05e9131cfa88f0e3a620e96700020000000000000000038c',
'0x798b112420ad6391a4129ac25ef59663a44c88bb0002000000000000000003f4',
'0x798b112420ad6391a4129ac25ef59663a44c88bb0002000000000000000003f4',
'0x5512a4bbe7b3051f92324bacf25c02b9000c4a500001000000000000000003d7',
'0x4edcb2b46377530bc18bb4d2c7fe46a992c73e100000000000000000000003ec',
'0xd1ec5e215e8148d76f4460e4097fd3d5ae0a35580002000000000000000003d3',
Expand Down
1 change: 1 addition & 0 deletions src/lib/config/polygon/pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ const pools: Pools = {
'0xa88e4fae334a2237e300592ae7d52705cade95a0000200000000000000000c17', // 50WBTC-50MaticX
'0xf7fd196c4606fb78178a85d1059f8224ddbccd2d000200000000000000000c18', // 50DAI-50miMATIC
'0xacb0bd6f7206174c64cef5e05c4d7871ea888d33000100000000000000000c19', // 33WBTC-33WETH-33NEX
'0x93a97f352c8be88d1468b8f7e0c24ce535be9eae000100000000000000000c1a', // farmDE
],
},
Factories: {
Expand Down
32 changes: 27 additions & 5 deletions src/lib/config/pools.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,51 @@ function detectDuplicates(
const duplicatedPoolAddresses = getDuplicatedAddresses(addresses);
if (duplicatedPoolAddresses.length > 0)
throw new Error(
`Network ${networkName}: found duplicated pool addresses in ${allowlistType} Allowlist: ${duplicatedPoolAddresses}.
`Network ${networkName}: found duplicated pool addresses in ${allowlistType} Allowlist: ${duplicatedPoolAddresses}
Review /src/lib/config/${networkName}/pools.ts to remove duplicates.
It could be that 2 similar allowlist PRs were created at the same time.
`
);
}

test('Detect duplicated pool addresses in allowlists', async () => {
function detectDuplicatesInVotingList(
networkName: string,
addresses: string[]
) {
const duplicatedPoolAddresses = getDuplicatedAddresses(addresses);
if (duplicatedPoolAddresses.length > 0)
throw new Error(
`Network ${networkName}: found duplicated pool addresses in Stakable.VotingListPools: ${duplicatedPoolAddresses}
Review /src/lib/config/${networkName}/pools.ts to remove duplicates.
`
);
}

test('Detect duplicated pool addresses in Staking.VotingGaugePools addresses', async () => {
Object.values(config).forEach(networkConfig => {
detectDuplicates(
networkConfig.network,
'Stable',
networkConfig.pools['Stable'].AllowList
networkConfig.pools.Stable.AllowList
);
detectDuplicates(
networkConfig.network,
'Weighted',
networkConfig.pools['Weighted'].AllowList
networkConfig.pools.Weighted.AllowList
);
detectDuplicates(
networkConfig.network,
'Investment',
networkConfig.pools['Investment'].AllowList
networkConfig.pools.Investment.AllowList
);
});
});

test('Detect duplicated pool addresses in voting list', async () => {
Object.values(config).forEach(networkConfig => {
detectDuplicatesInVotingList(
networkConfig.network,
networkConfig.pools.Stakable.VotingGaugePools
);
});
});
4 changes: 3 additions & 1 deletion src/lib/scripts/automatic-prs/allowlist-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 4. Writes new file content back to file.
*
* Example usage:
* npx vite-node ./src/lib/scripts/automatic-prs/allowlist-pool.ts --network mainnet --poolType=stable --poolId=\"0x...\" --poolDescription=foo/bar/baz
* npx vite-node ./src/lib/scripts/automatic-prs/allowlist-pool.ts --network ethereum --poolType=stable --poolId=\"0x...\" --poolDescription=foo/bar/baz
*/

import { cac } from 'cac';
Expand All @@ -25,6 +25,8 @@ const poolId = options.poolId.replace(/[^0-9a-fA-Fx]+/g, '') as string;
const poolType = capitalize(options.poolType);
let network = options.network as string;
network = network.toLowerCase();
// Allow ethereum alias to correctly generate pool link from allowlist-manual.yml
if (network === 'ethereum') network = 'mainnet';
const { poolDescription } = options;

validateInput({ poolType, network, poolId });
Expand Down
10 changes: 7 additions & 3 deletions src/providers/local/exit-pool.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,15 @@ export const exitPoolProvider = (
shouldSignRelayer.value ? [relayerApprovalAction.value] : []
);

const canSwapExit = computed(
(): boolean => isDeep(pool.value) && isPreMintedBptType(pool.value.poolType)
);

const shouldUseSwapExit = computed(
(): boolean =>
isSingleAssetExit.value &&
isDeep(pool.value) &&
isPreMintedBptType(pool.value.poolType) &&
!includesAddress(pool.value.tokensList, singleAmountOut.address)
!includesAddress(pool.value.tokensList, singleAmountOut.address) &&
canSwapExit.value
);

const shouldUseGeneralisedExit = computed(
Expand Down Expand Up @@ -604,6 +607,7 @@ export const exitPoolProvider = (
relayerSignature,
relayerApprovalTx,
shouldUseSwapExit,
canSwapExit,
shouldUseRecoveryExit,

// methods
Expand Down

1 comment on commit 9340c0b

@vercel
Copy link

@vercel vercel bot commented on 9340c0b Aug 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.