Skip to content

Commit

Permalink
Merge branch 'master' into chore/add-networks-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
garethfuller committed Jun 6, 2024
2 parents dcd63d8 + 22b6d8c commit 168fb92
Show file tree
Hide file tree
Showing 24 changed files with 170 additions and 187 deletions.
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.144.0",
"version": "1.144.94",
"engines": {
"node": "=16",
"npm": ">=8"
Expand Down
24 changes: 18 additions & 6 deletions src/components/contextual/pages/vebal/LMVoting/GaugesTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,14 @@ function getPickedTokens(tokens: VotingPool['tokens']) {
)
.map(item => item.address);
}
function voteDisabledFor(pool: VotingPool): boolean {
return (
hasUserVotes(pool) ||
isVotingTimeLocked(pool.lastUserVoteTime) ||
props.selectVotesDisabled
);
}
</script>

<template>
Expand All @@ -210,7 +218,9 @@ function getPickedTokens(tokens: VotingPool['tokens']) {
:square="upToLargeBreakpoint"
:isPaginated="isPaginated"
:href="{ getHref: gauge => getPoolExternalUrl(gauge) }"
:onRowClick="redirectToPool"
:onRowClick="
(pool, inNewTab) => !voteDisabledFor(pool) && toggleSelection(pool)
"
:getTableRowClass="getTableRowClass"
:initialState="{
sortColumn: 'nextPeriodVotes',
Expand Down Expand Up @@ -279,6 +289,12 @@ function getPickedTokens(tokens: VotingPool['tokens']) {
v-if="getIsGaugeExpired(pool.gauge.address)"
class="ml-2"
/>
<BalIcon
name="arrow-up-right"
size="sm"
class="ml-2 text-gray-500 hover:text-blue-500 transition-colors"
@click="redirectToPool(pool, true)"
/>
</div>
</template>
<template #nextPeriodVotesCell="pool: VotingPool">
Expand Down Expand Up @@ -327,11 +343,7 @@ function getPickedTokens(tokens: VotingPool['tokens']) {
name="expiredGaugesFilter"
noMargin
:modelValue="isSelected(pool)"
:disabled="
hasUserVotes(pool) ||
isVotingTimeLocked(pool.lastUserVoteTime) ||
selectVotesDisabled
"
:disabled="voteDisabledFor(pool)"
@click.stop
@input="toggleSelection(pool)"
/>
Expand Down
20 changes: 4 additions & 16 deletions src/components/pool/PoolPageHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -310,24 +310,12 @@ function symbolFor(titleTokenIndex: number): string {
</BalAlert>
<BalAlert
v-if="
disableJoinsReason.requiresAllowListing ||
disableJoinsReason.nonAllowedWeightedPoolAfterTimestamp
"
type="warning"
:title="$t('requiresAllowListing1')"
v-if="disableJoinsReason.isBlocked"
type="error"
:title="$t('blockedPool')"
class="mt-2"
block
>
{{ $t('Click') }}
<a
href="https://github.com/balancer/frontend-v2/wiki/How-tos#add-a-new-pool"
target="_blank"
class="underline"
>{{ $t('here') }}</a
>
{{ $t('requiresAllowListing2') }}
</BalAlert>
/>
</template>
<style scoped>
.pool-title {
Expand Down
2 changes: 1 addition & 1 deletion src/components/web3/SanctionedWalletModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function onClose() {
>
<p class="pb-3 text-sm">
Your wallet address cannot use this site because it has been flagged as
high risk by our compliance partner, TRM Labs.
high risk by our compliance partner, Hypernative.
</p>
<p class="pb-3 text-sm">
This website is open source and permissionless. Anyone can fork and run
Expand Down
2 changes: 1 addition & 1 deletion src/components/web3/ThirdPartyServicesModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const services = [
'the-graph',
'fathom-analytics',
'appzi',
'TRM-labs',
'hypernative',
'sentry',
'amazon-web-services',
];
Expand Down
99 changes: 3 additions & 96 deletions src/composables/useDisabledJoinPool.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import { initDependenciesWithDefaultMocks } from '@/dependencies/default-mocks';
import { Pool, PoolType } from '@/services/pool/types';
import { aBoostedPool } from '@/__mocks__/boosted-pool';
import { aPoolToken } from '@/__mocks__/weighted-pool';
import { initDependenciesWithDefaultMocks } from '@/dependencies/default-mocks';
import { Pool } from '@/services/pool/types';
import { mountComposableWithFakeTokensProvider as mountComposable } from '@tests/mount-helpers';
import {
balAddress,
daiAddress,
randomAddress,
} from '@tests/unit/builders/address';
import { aPool } from '@tests/unit/builders/pool.builders';
import { randomAddress } from '@tests/unit/builders/address';
import { useDisabledJoinPool } from './useDisabledJoinPool';
import useNetwork from './useNetwork';
import { dateToUnixTimestamp } from './useTime';
Expand All @@ -30,24 +24,6 @@ it('disables joins for pools with no initial liquidity', async () => {
expect(disableJoinsReason.value.notInitialLiquidity).toBeTrue();
});

it('disables joins for pools created after timestamp (2023-03-29) with non vetted tokens', async () => {
const { networkId } = useNetwork();
networkId.value = 1;

const pool = aBoostedPool();
pool.createTime = dateToUnixTimestamp('2023-03-30'); //Created after 29 March
const { disableJoinsReason, shouldDisableJoins, nonAllowedSymbols } =
await mountVettedTokensInPool(pool);

pool.tokens[0].address = randomAddress();

expect(shouldDisableJoins.value).toBeTrue();
expect(disableJoinsReason.value.nonVettedTokensAfterTimestamp).toBeTrue();
expect(nonAllowedSymbols.value).toMatchInlineSnapshot(
'"bb-a-USDT,USDT,bb-a-USDC,USDC,bb-a-DAI,DAI"'
);
});

it('allows joins for pools on test networks with non vetted tokens', async () => {
const { networkId } = useNetwork();
networkId.value = 5;
Expand All @@ -62,72 +38,3 @@ it('allows joins for pools on test networks with non vetted tokens', async () =>
console.log('Reason: ', disableJoinsReason.value);
expect(shouldDisableJoins.value).toBeFalse();
});

it('disables joins for weighted pools created after timestamp (2023-03-29) that are not in the weighted allow list', async () => {
const { networkId } = useNetwork();
networkId.value = 1;

const pool = aBoostedPool();
pool.createTime = dateToUnixTimestamp('2023-03-30'); //Created after 29 March
pool.poolType = PoolType.Weighted;
const { disableJoinsReason, shouldDisableJoins } =
await mountVettedTokensInPool(pool);

pool.tokens[0].address = randomAddress();

expect(shouldDisableJoins.value).toBeTrue();
expect(
disableJoinsReason.value.nonAllowedWeightedPoolAfterTimestamp
).toBeTrue();
});

it('allows joins for weighted pools on test networks created after timestamp (2023-03-29) that are not in the weighted allow list', async () => {
const { networkId } = useNetwork();
networkId.value = 5;

const pool = aBoostedPool();
pool.createTime = dateToUnixTimestamp('2023-03-30'); //Created after 29 March
pool.poolType = PoolType.Weighted;
const { disableJoinsReason } = await mountVettedTokensInPool(pool);

pool.tokens[0].address = randomAddress();

expect(
disableJoinsReason.value.nonAllowedWeightedPoolAfterTimestamp
).toBeFalse();
});

it('does not disables joins for pools created before 29 march', async () => {
const pool = aBoostedPool();
pool.createTime = dateToUnixTimestamp('2023-03-28'); //Created before 29 March
pool.totalShares = '100';
const { shouldDisableJoins, disableJoinsReason } =
await mountVettedTokensInPool(pool);

expect(disableJoinsReason.value.nonVettedTokensAfterTimestamp).toBeFalse();
expect(shouldDisableJoins.value).toBeFalse();
});

it('disabled joins for pools FX pool', async () => {
const pool = aPool({
totalShares: '100',
createTime: dateToUnixTimestamp('2023-03-28'),
owner: randomAddress(),
poolType: PoolType.Investment, // Requires Allow listing
tokens: [
aPoolToken({ address: daiAddress, symbol: 'DAI' }),
aPoolToken({ address: balAddress, symbol: 'BAL' }),
],
});

const { networkId } = useNetwork();
networkId.value = 1;

const { shouldDisableJoins, disableJoinsReason } =
await mountVettedTokensInPool(pool);

expect(disableJoinsReason.value.requiresAllowListing).toBeTrue();
expect(shouldDisableJoins.value).toBeTrue();
expect(disableJoinsReason.value.nonVettedTokensAfterTimestamp).toBeFalse();
expect(disableJoinsReason.value.notInitialLiquidity).toBeFalse();
});
40 changes: 3 additions & 37 deletions src/composables/useDisabledJoinPool.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,23 @@
import {
createdAfterTimestamp,
filterTokensInList,
isFx,
isJoinsDisabled,
isManaged,
isStableLike,
isWeighted,
noInitLiquidity,
usePoolHelpers,
} from '@/composables/usePoolHelpers';
import { computed } from 'vue';

import { isSameAddress } from '@/lib/utils';
import { useTokenLists } from '@/providers/token-lists.provider';
import { configService } from '@/services/config/config.service';
import { Pool } from '@/services/pool/types';
import useWeb3 from '@/services/web3/useWeb3';
import { isAddress } from '@ethersproject/address';
import { isTestnet } from './useNetwork';

const POOLS = configService.network.pools;

function doesRequireAllowListing(pool: Pool, account: string): boolean {
const requiresAllowlisting =
(isStableLike(pool.poolType) && !isFx(pool.poolType)) ||
isManaged(pool.poolType);
const isOwnedByUser =
pool.owner && isAddress(account) && isSameAddress(pool.owner, account);
const isAllowlisted =
POOLS.Stable.AllowList.includes(pool.id) ||
POOLS.Investment.AllowList.includes(pool.id);
return (
!isTestnet.value && requiresAllowlisting && !isAllowlisted && !isOwnedByUser
);
function isBlocked(poolId: string): boolean {
return POOLS.BlockList.includes(poolId);
}

export function useDisabledJoinPool(pool: Pool) {
const { account } = useWeb3();
const { balancerTokenList } = useTokenLists();
const { hasNonApprovedRateProviders } = usePoolHelpers(toRef(pool));

Expand All @@ -57,15 +38,6 @@ export function useDisabledJoinPool(pool: Pool) {
);
});

const nonAllowedWeightedPoolAfterTimestamp = computed(() => {
return (
!isTestnet.value &&
isWeighted(pool.poolType) &&
createdAfterTimestamp(pool) &&
!POOLS.Weighted.AllowList.includes(pool.id)
);
});

const nonAllowedSymbols = computed(() => {
return notVettedTokens.value.map(token => token.symbol).join(',');
});
Expand All @@ -74,10 +46,6 @@ export function useDisabledJoinPool(pool: Pool) {
return noInitLiquidity(pool);
});

const requiresAllowListing = computed(() => {
return doesRequireAllowListing(pool, account.value);
});

const unapprovedRateProvider = computed(() => {
const nonApprovedRateProviderExceptions = [
// wjAURA-WETH - https://github.com/balancer/frontend-v2/issues/4417
Expand All @@ -91,12 +59,10 @@ export function useDisabledJoinPool(pool: Pool) {

const disableJoinsReason = computed(() => ({
notInitialLiquidity: notInitialLiquidity.value,
requiresAllowListing: requiresAllowListing.value,
nonVettedTokensAfterTimestamp: nonVettedTokensAfterTimestamp.value,
nonAllowedWeightedPoolAfterTimestamp:
nonAllowedWeightedPoolAfterTimestamp.value,
hardcoded: isJoinsDisabled(pool.id),
unapprovedRateProvider: unapprovedRateProvider.value,
isBlocked: isBlocked(pool.id),
}));

const shouldDisableJoins = computed(() => {
Expand Down
1 change: 1 addition & 0 deletions src/composables/useVotingPools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export function isVe8020Pool(pool: VotingPool): boolean {
POOLS.IdsMap.veUSH,
POOLS.IdsMap.veQi,
POOLS.IdsMap.veGEM,
POOLS.IdsMap.veTHX,
].includes(pool.id.toLowerCase());
}

Expand Down
10 changes: 7 additions & 3 deletions src/lib/config/arbitrum/pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ const pools: Pools = {
'0x2f0cdf8596be980ef24924ca7bf54e630ca526b2000000000000000000000529', // sUSDe/USDC
'0x537d8ef9e6e0adfb099cb14aeaf04ebeffaf444c000000000000000000000528', // USDe/USDC
'0xfb2f7ed572589940e24c5711c002adc59d5e79ef000000000000000000000535', // jitoSOL/wSOL
'0x7b54c44fbe6db6d97fd22b8756f89c0af16202cc00000000000000000000053c', // ETHx/wstETH
],
},
Investment: {
AllowList: [''],
},
Weighted: {
// Only effective after given timestamp here: usePool.ts#createdAfterTimestamp
// see useDisabledJoinPool.ts#nonAllowedWeightedPoolAfterTimestamp for logic.
// Deprecated list, no longer in use
AllowList: [
'0xd449efa0a587f2cb6be3ae577bc167a7745258100001000000000000000003f4',
'0xce34c867d7053befb3421d6adabcb5ce55ff777b00010000000000000000041b', // crv/wbtc/wsteth/gdai/uni/link
Expand Down Expand Up @@ -209,6 +209,7 @@ const pools: Pools = {
'0x260dbd54d87a10a0fc9d08622ebc969a3bf4e6bb000200000000000000000536', // jitoSOL/wstETH
'0xf2658f994c882237d3612099cae541d50348fcf9000200000000000000000537', // PUPPET-WETH
'0xbc450dcb3a135a57448f8054badaec5c9f2af571000200000000000000000538', // 50SOL-50wstETH
'0x19da41a2ccd0792b9b674777e72447903fe29074000200000000000000000539', // PUPPET-WETH
],
},
Factories: {
Expand Down Expand Up @@ -313,6 +314,9 @@ const pools: Pools = {
'0x125bc5a031b2db6733bfa35d914ffa428095978b000200000000000000000514',
'0xca8ecd05a289b1fbc2e0eaec07360c4bfec07b6100020000000000000000051d',
'0x14abd18d1fa335e9f630a658a2799b33208763fa00020000000000000000051f',
'0x260dbd54d87a10a0fc9d08622ebc969a3bf4e6bb000200000000000000000536',
'0xfb2f7ed572589940e24c5711c002adc59d5e79ef000000000000000000000535',
'0x7b54c44fbe6db6d97fd22b8756f89c0af16202cc00000000000000000000053c',
],
AllowList: [
'0x88e2c969e2a1c69c16d1dcd9f8acde4c6ab3838a0002000000000000000004c1',
Expand All @@ -331,7 +335,7 @@ const pools: Pools = {
protocol: Protocol.Renzo,
multiple: '3',
description:
'LPs in this pool earn 2x ezPoints on the TVL of the pool (wstETH + ezETH)',
'LPs in this pool earn 3x ezPoints on the TVL of the pool (wstETH + ezETH)',
},
{
protocol: Protocol.Eigenlayer,
Expand Down
Loading

0 comments on commit 168fb92

Please sign in to comment.