Skip to content

Commit

Permalink
Remove default tokens list, change vetted to allowlisted (#3678)
Browse files Browse the repository at this point in the history
* Remove default tokens list, change vetted to allowlisted

- Removed the old default tokens list as it's no longer used in the UI.
  In the future we may add a special list.
- Renamed the vetted list to allowlisted to be consistent with
  tokenlists repo and other places that we allow tokens. As vetted was
ambiguous if it represents all allowlisted tokens or a hand picked
"vetted" set of them.

* Make Faucet table use allowlist

* Change name to balancerTokenList

* Fix type error

* Fix token list provider tests

* Fix Avalanche and Sepolia

* Fix fake tokenlist tests
  • Loading branch information
timjrobinson authored and joehquak committed Jul 30, 2023
1 parent 73a27eb commit 0e12f6d
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 116 deletions.
4 changes: 2 additions & 2 deletions src/components/tables/FaucetTable/FaucetTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import { useTokens } from '@/providers/tokens.provider';
const { t } = useI18n();
const { upToLargeBreakpoint } = useBreakpoints();
const { fNum } = useNumbers();
const { defaultTokenList } = useTokenLists();
const { balancerTokenList } = useTokenLists();
const { priceFor, balanceFor } = useTokens();
const tokens = computed(() => {
const tokensWithValues = Object.values(defaultTokenList.value.tokens)
const tokensWithValues = Object.values(balancerTokenList.value.tokens)
.map(token => {
const balance = balanceFor(token.address);
const price = priceFor(token.address);
Expand Down
4 changes: 2 additions & 2 deletions src/composables/useDisabledJoinPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ function doesRequireAllowListing(pool: Pool, account: string): boolean {

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

const notVettedTokens = computed(() => {
const vettedTokenAddresses = vettedTokenList.value.tokens.map(
const vettedTokenAddresses = balancerTokenList.value.tokens.map(
t => t.address
);

Expand Down
4 changes: 1 addition & 3 deletions src/lib/config/arbitrum/tokenlists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { TokenListURLMap } from '@/types/TokenList';

const tokenlists: TokenListURLMap = {
Balancer: {
Default:
'https://raw.githubusercontent.com/balancer/tokenlists/main/generated/listed-old.tokenlist.json',
Vetted:
Allowlisted:
'https://raw.githubusercontent.com/balancer/tokenlists/main/generated/balancer.tokenlist.json',
},
External: [],
Expand Down
4 changes: 1 addition & 3 deletions src/lib/config/gnosis-chain/tokenlists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { TokenListURLMap } from '@/types/TokenList';

const tokenlists: TokenListURLMap = {
Balancer: {
Default:
'https://raw.githubusercontent.com/balancer/tokenlists/main/generated/listed-old.tokenlist.json',
Vetted:
Allowlisted:
'https://raw.githubusercontent.com/balancer/tokenlists/main/generated/balancer.tokenlist.json',
},
External: [
Expand Down
4 changes: 1 addition & 3 deletions src/lib/config/goerli/tokenlists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { TokenListURLMap } from '@/types/TokenList';

const tokenlists: TokenListURLMap = {
Balancer: {
Default:
'https://raw.githubusercontent.com/balancer/tokenlists/main/generated/listed-old.tokenlist.json',
Vetted:
Allowlisted:
'https://raw.githubusercontent.com/balancer/tokenlists/main/generated/balancer.tokenlist.json',
},
External: [],
Expand Down
4 changes: 1 addition & 3 deletions src/lib/config/mainnet/tokenlists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { TokenListURLMap } from '@/types/TokenList';

const tokenlists: TokenListURLMap = {
Balancer: {
Default:
'https://raw.githubusercontent.com/balancer/tokenlists/main/generated/listed-old.tokenlist.json',
Vetted:
Allowlisted:
'https://raw.githubusercontent.com/balancer/tokenlists/main/generated/balancer.tokenlist.json',
},
External: [
Expand Down
4 changes: 1 addition & 3 deletions src/lib/config/neon-devnet/tokenlists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { TokenListURLMap } from '@/types/TokenList';

const tokenlists: TokenListURLMap = {
Balancer: {
Default:
'https://raw.githubusercontent.com/neonlabsorg/token-list/main/tokenlist.json',
Vetted:
Allowlisted:
'https://raw.githubusercontent.com/neonlabsorg/token-list/main/tokenlist.json',
},
External: [],
Expand Down
4 changes: 1 addition & 3 deletions src/lib/config/neon-mainnet/tokenlists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { TokenListURLMap } from '@/types/TokenList';

const tokenlists: TokenListURLMap = {
Balancer: {
Default:
'https://raw.githubusercontent.com/neonlabsorg/token-list/main/tokenlist.json',
Vetted:
Allowlisted:
'https://raw.githubusercontent.com/neonlabsorg/token-list/main/tokenlist.json',
},
External: [],
Expand Down
3 changes: 1 addition & 2 deletions src/lib/config/optimism/tokenlists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { TokenListURLMap } from '@/types/TokenList';

const tokenlists: TokenListURLMap = {
Balancer: {
Default: '',
Vetted: '',
Allowlisted: '',
},
External: [],
};
Expand Down
4 changes: 1 addition & 3 deletions src/lib/config/polygon/tokenlists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { TokenListURLMap } from '@/types/TokenList';

const tokenlists: TokenListURLMap = {
Balancer: {
Default:
'https://raw.githubusercontent.com/balancer/tokenlists/main/generated/listed-old.tokenlist.json',
Vetted:
Allowlisted:
'https://raw.githubusercontent.com/balancer/tokenlists/main/generated/balancer.tokenlist.json',
},
External: [
Expand Down
4 changes: 1 addition & 3 deletions src/lib/config/zkevm/tokenlists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { TokenListURLMap } from '@/types/TokenList';

const tokenlists: TokenListURLMap = {
Balancer: {
Default:
'https://raw.githubusercontent.com/balancer/tokenlists/main/generated/balancer.tokenlist.json',
Vetted:
Allowlisted:
'https://raw.githubusercontent.com/balancer/tokenlists/main/generated/balancer.tokenlist.json',
},
External: [],
Expand Down
4 changes: 2 additions & 2 deletions src/providers/__mocks__/tokens.provider.fake.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ test('Fakes provided state', async () => {

expect(wrappedNativeAsset.value.address).toBe(wethAddress);

expect(Object.keys(activeTokenListTokens.value)).toHaveLength(12);
expect(Object.keys(activeTokenListTokens.value)).toHaveLength(16);
expect(Object.keys(activeTokenListTokens.value)).toEqual(
expect.arrayContaining([])
);

expect(Object.keys(balancerTokenListTokens.value)).toHaveLength(21);
expect(Object.keys(balancerTokenListTokens.value)).toHaveLength(16);

expect(Object.keys(prices.value)).toHaveLength(2);
expect(Object.keys(balances.value)).toHaveLength(2);
Expand Down
70 changes: 8 additions & 62 deletions src/providers/token-lists.provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,81 +23,27 @@ describe('Token lists provider should', () => {

expect(firstTokenListSymbols(result.activeTokenLists.value)).toEqual([
'BAL',
'DAI',
'USDT',
'USDC',
'WETH',
'WBTC',
'miMATIC',
// Explicitly added to test tokens-5.json to simplify testing:
'bb-a-USD',
'bb-a-USDT',
'test-pool-symbol',
'bb-a-DAI',
'GRO',
]);
});

test('provide approved TokenList', async () => {
const { result } = mountComposableWithTokenLists();
expect(firstTokenListSymbols(result.approvedTokenLists.value)).toEqual([
'BAL',
'DAI',
'USDT',
'USDC',
'WETH',
'WBTC',
'miMATIC',
// Explicitly added to test tokens-5.json to simplify testing:
'bb-a-USD',
'bb-a-USDC',
'bb-a-USDT',
'test-pool-symbol',
'bb-a-DAI',
'GRO',
]);
});

test('provide balancer TokenList', async () => {
const { result } = mountComposableWithTokenLists();
expect(firstTokenListSymbols(result.balancerTokenLists.value)).toEqual([
'BAL',
'DAI',
'USDT',
'USDC',
'WETH',
'WBTC',
'miMATIC',
// Explicitly added to test tokens-5.json to simplify testing:
'bb-a-USD',
'bb-a-USDT',
'test-pool-symbol',
'bb-a-DAI',
'GRO',
]);
});

test('provide default TokenList', async () => {
const { result } = mountComposableWithTokenLists();
expect(tokenListSymbols(result.defaultTokenList.value)).toEqual([
'BAL',
'DAI',
'FEI',
'GNO',
'USDT',
'USDC',
'WETH',
'WBTC',
'miMATIC',
// Explicitly added to test tokens-5.json to simplify testing:
'bb-a-USD',
'bb-a-USDT',
'test-pool-symbol',
'bb-a-DAI',
'aDAI',
'aUSDC',
'aUSDT',
'GRO',
]);
});

test('provide vetted TokenList', async () => {
test('provide balancer TokenList', async () => {
const { result } = mountComposableWithTokenLists();
expect(tokenListSymbols(result.vettedTokenList.value)).toEqual([
expect(tokenListSymbols(result.balancerTokenList.value)).toEqual([
'BAL',
'bb-a-DAI',
'bb-a-USDC',
Expand Down
18 changes: 5 additions & 13 deletions src/providers/token-lists.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const { networkId } = useNetwork();
* STATE
*/
const state: TokenListsState = reactive({
activeListKeys: [uris.Balancer.Default],
activeListKeys: [uris.Balancer.Allowlisted],
});

const allTokenLists = ref({});
Expand All @@ -50,17 +50,10 @@ const activeTokenLists = computed(
);

/**
* The default Balancer token list.
* All allowlisted tokens from tokenlists repo
*/
const defaultTokenList = computed(
(): TokenList => allTokenLists.value[uris.Balancer.Default]
);

/**
* The Balancer vetted token list, contains LBP tokens.
*/
const vettedTokenList = computed(
(): TokenList => allTokenLists.value[uris.Balancer.Vetted]
const balancerTokenList = computed(
(): TokenList => allTokenLists.value[uris.Balancer.Allowlisted]
);

/**
Expand Down Expand Up @@ -128,10 +121,9 @@ export const tokenListsProvider = () => {
// computed
allTokenLists,
activeTokenLists,
defaultTokenList,
balancerTokenLists,
approvedTokenLists,
vettedTokenList,
balancerTokenList,
// methods
toggleTokenList,
isActiveList,
Expand Down
2 changes: 1 addition & 1 deletion src/providers/tokens.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ export const tokensProvider = (

const newTokens = await new TokenService().metadata.get(
injectable,
omit(allTokenLists.value, tokenListUris.Balancer.Default)
omit(allTokenLists.value, tokenListUris.Balancer.Allowlisted)
);

state.injectedTokens = { ...state.injectedTokens, ...newTokens };
Expand Down
10 changes: 4 additions & 6 deletions src/services/token-list/token-list.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ interface TokenListUris {
All: string[];
Balancer: {
All: string[];
// Compliant list for exchange
Default: string;
// Extended list to include LBP tokens
Vetted: string;
// Allowlisted tokens list from tokenslist repo
Allowlisted: string;
};
Approved: string[];
External: string[];
Expand All @@ -36,9 +34,9 @@ export default class TokenListService {
this.appNetwork
).tokenlists;

const balancerLists = [Balancer.Default, Balancer.Vetted];
const balancerLists = [Balancer.Allowlisted];
const All = [...balancerLists, ...External];
const Approved = [Balancer.Default, ...External];
const Approved = [Balancer.Allowlisted, ...External];

return {
All,
Expand Down
3 changes: 1 addition & 2 deletions src/types/TokenList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ export type TokenInfoMap = Record<string, TokenInfo>;

export interface TokenListURLMap {
Balancer: {
Default: string;
Vetted: string;
Allowlisted: string;
};
External: string[];
}

0 comments on commit 0e12f6d

Please sign in to comment.