Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Limit swap exits (DM) #3946

Merged
merged 29 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a564fc9
Fix ethereum pool links in auto allowlist PRs
agualis Aug 10, 2023
456b02e
Merge pull request #3931 from balancer/release/1.118.0
timjrobinson Aug 10, 2023
5701444
Add test for detecting duplicates in voting list
agualis Aug 10, 2023
fdb3196
Change test name
agualis Aug 10, 2023
71c9cfd
chore: Add migration notices (#3934)
garethfuller Aug 10, 2023
01232c9
1.118.1
gh-action-bump-version Aug 10, 2023
cd3637d
hotfix: fix reward tokens apr breakdown (#3936)
mendesfabio Aug 10, 2023
5c5ea04
1.118.2
gh-action-bump-version Aug 10, 2023
845230f
chore: Add farmDE pool to polygon allowlist
balopco Aug 10, 2023
89af719
add well and stg to whitelist (#3939)
zekraken-bot Aug 10, 2023
0acfcf3
1.118.3
gh-action-bump-version Aug 10, 2023
e3763de
chore: Add 2BTC pool to mainnet allowlist
balopco Aug 11, 2023
78e27e4
Add reth pool to allowlist
timjrobinson Aug 11, 2023
902c90c
Merge pull request #3942 from balancer/allowlist-base-reth
timjrobinson Aug 11, 2023
b16339a
1.118.4
gh-action-bump-version Aug 11, 2023
5954b85
chore: Add 80TBTC-20WBTC pool to mainnet allowlist
balopco Aug 11, 2023
940bfd0
Merge pull request #3933 from balancer/test/voting-duplicates
timjrobinson Aug 11, 2023
655e473
1.118.5
gh-action-bump-version Aug 11, 2023
aafaa61
Merge pull request #3938 from balancer/update-allowlist-polygon-0x93a…
timjrobinson Aug 11, 2023
2c5ef8d
1.118.6
gh-action-bump-version Aug 11, 2023
b757705
Merge pull request #3940 from balancer/update-allowlist-mainnet-0xe4e…
timjrobinson Aug 11, 2023
a37199a
1.118.7
gh-action-bump-version Aug 11, 2023
dc2dd25
Merge pull request #3943 from balancer/update-allowlist-mainnet-0xa9d…
timjrobinson Aug 11, 2023
dc1e73d
1.118.8
gh-action-bump-version Aug 11, 2023
75ea499
Merge pull request #3930 from balancer/fix/eth-pool-link-PR
timjrobinson Aug 11, 2023
67a38b9
1.118.9
gh-action-bump-version Aug 11, 2023
29a57ea
fix: Limit swap exits to deep pools
garethfuller Aug 11, 2023
ea32e6e
chore: Add comment
garethfuller Aug 11, 2023
cc39498
Merge branch 'develop' into fix/limit-swap-exits
garethfuller Aug 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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