• Stars
    star
    138
  • Rank 264,508 (Top 6 %)
  • Language
    TypeScript
  • License
    GNU General Publi...
  • Created over 2 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Token List Bridge Utils

Description

This package contains utility functions used for converting an L1 token list into a cross-chain tokenlist by adding cross-chain mapping information for Arbitrum, Optimism, and Polygon to a given L1 list.

Mappings get added in the form of an extensions field, following this schema. (Currently does not fill information for origin and destination bridge addresses)

ex:

  "name": "Uniswap",
  "address": "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984",
  "symbol": "UNI",
  "decimals": 18,
  "chainId": 1,
  "logoURI": "ipfs://QmXttGpZrECX5qCyXbBQiqgQNytVGeZW5Anewvh2jc4psg",
  "extensions": {
    "bridgeInfo": {
      "10": {
        "tokenAddress": "0x6fd9d7AD17242c41f7131d257212c54A0e816691"
      },
      "137": {
        "tokenAddress": "0xb33EaAd8d922B1083446DC23f610c2567fB5180f"
      },
      "42161": {
        "tokenAddress": "0xFa7F8980b0f1E64A2062791cc3b0871572f1F7f0"
      }
    }
  }}

Also adds a "root-level" token entry for each of the L2's that a token maps to.

ex. for Optimism:

{
  "name": "Uniswap",
  "address": "0x6fd9d7AD17242c41f7131d257212c54A0e816691",
  "symbol": "UNI",
  "decimals": 18,
  "chainId": 10,
  "logoURI": "ipfs://QmXttGpZrECX5qCyXbBQiqgQNytVGeZW5Anewvh2jc4psg",
  "extensions": {
    "bridgeInfo": {
      "1": {
        "tokenAddress": "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984"
      }
    }
  }
}

Functions Overview

chainify

  • Adds bridgeInfo to the given token list for Optimism, Polygon and Arbitrum.
  • @param l1TokenListOrPathOrUrl
  • @returns TokenList with l2 bridgeInfo filled

chainifyTokenList

  • Given a chain ID (Optimism, Polygon, or Arbitrum) and a TokenList, returns the TokenList with extensions filled.
  • @param chainId chainId to operate on
  • @param l1TokenListOrPathOrUrl either an L1 TokenList object or a path/url to a TokenList
  • @returns L1 TokenList with extensions filled for the given network

mergeTokenLists

  • Merges two token lists, resolving conflicts to primary list.
  • @param primary primary token list to resolve conflicts to
  • @param secondary secondary token list
  • @returns merged token list

Usage (from external package):

Install Package

yarn add @uniswap/token-list-bridge-utils

or

npm i @uniswap/token-list-bridge-utils

Create .env file (Optional)

  • By default, the library uses https://rpc.ankr.com/eth as the MAINNET_RPC env variable value required by arbitrum-sdk. You can override this value by creating a .env file in your root directory and setting a value for MAINNET_RPC.

    • Sample .env file contents:

      MAINNET_RPC="https://mainnet.infura.io/v3/<infura key>"

  • Note: If this is not set correctly, the library will throw a NETWORK_ERROR error code.

Call Function

CommonJS

const bridge_utils = require('@uniswap/token-list-bridge-utils');

let chainifiedList = await bridge_utils.chainify(tokenList);

ESM

import { chainify } from '@uniswap/token-list-bridge-utils';

let chainifiedList = await chainify(tokenList);

Run Tests

yarn install

yarn test

DTS User Guide

DTS scaffolds your new library inside /src.

To run DTS, use:

npm start # or yarn start

This builds to /dist and runs the project in watch mode so any edits you save inside src causes a rebuild to /dist.

To do a one-off build, use npm run build or yarn build.

More Repositories

1

web3-react

A simple, maximally extensible, dependency minimized framework for building modern Ethereum dApps
TypeScript
5,373
star
2

interface

🦄 Open source interfaces for the Uniswap protocol
TypeScript
4,923
star
3

v3-core

🦄 🦄 🦄 Core smart contracts of Uniswap v3
TypeScript
4,386
star
4

v2-core

🦄 🦄 Core smart contracts of Uniswap V2
TypeScript
2,964
star
5

v4-core

🦄 🦄 🦄 🦄 Core smart contracts of Uniswap v4
Solidity
1,810
star
6

v3-periphery

🦄 🦄 🦄 Peripheral smart contracts for interacting with Uniswap v3
TypeScript
1,194
star
7

token-lists

📚 The Token Lists specification
TypeScript
926
star
8

v2-periphery

🎚 Peripheral smart contracts for interacting with Uniswap V2
Solidity
916
star
9

permit2

🔑🔑🔑 next generation token approvals mechanism
Solidity
745
star
10

v4-periphery

🦄 🦄 🦄 🦄 Peripheral smart contracts for interacting with Uniswap v4
Solidity
640
star
11

wallet

Uniswap Wallet is the simplest, safest, and most powerful self-custodial crypto wallet. It is developed by the Uniswap Labs team, inventors of the Uniswap Protocol.
TypeScript
530
star
12

merkle-distributor

📦 A smart contract that distributes a balance of tokens according to a merkle root
TypeScript
497
star
13

v3-sdk

🛠 An SDK for building applications on top of Uniswap V3
TypeScript
453
star
14

v1-contracts

🐍Uniswap V1 smart contracts
Python
438
star
15

v2-sdk

🛠 An SDK for building applications on top of Uniswap V2
TypeScript
427
star
16

universal-router

Uniswap's Universal Router for NFT and ERC20 swapping
TypeScript
408
star
17

v2-subgraph

Uniswap V2 subgraph 📊
TypeScript
399
star
18

smart-order-router

TypeScript
398
star
19

UniswapX

🦄 Gasless ERC20 swap settlement protocol 🦄
Solidity
380
star
20

v3-info

Interface for Uniswap V3 analytics. 📊
TypeScript
378
star
21

v3-subgraph

Subgraph for Uniswap V3
TypeScript
341
star
22

v3-staker

Canonical liquidity mining contract for Uniswap V3
TypeScript
330
star
23

docs

📓 Uniswap V3 docs website
TypeScript
310
star
24

default-token-list

◦ The Uniswap default token list
JavaScript
298
star
25

info

ℹ️ Uniswap v1+v2 analytics
JavaScript
283
star
26

tokenlists-org

A site for browsing featured token lists
JavaScript
175
star
27

sybil-list

List of verified mappings from Ethereum addresses to social profiles
162
star
28

routing-api

TypeScript
147
star
29

org-v1

🌐 Uniswap protocol homepage
JavaScript
144
star
30

solidity-lib

📖 Solidity libraries that are shared across Uniswap contracts
TypeScript
131
star
31

widgets

TypeScript
124
star
32

examples

TypeScript
124
star
33

governance-seatbelt

Make governance safer
TypeScript
116
star
34

retroactive-query

👀⬅️ Queries for surfacing information about past users of Uniswap
109
star
35

v3-market-depth-study

Market depth calculation for Uniswap v3
Python
107
star
36

swap-router-contracts

Smart contracts for swapping on Uniswap V2 and V3. Superseded by https://github.com/Uniswap/universal-router
TypeScript
102
star
37

unisocks

🧦
JavaScript
101
star
38

v3-polars

Jupyter Notebook
96
star
39

redux-multicall

A React + Redux library for fetching, batching, and caching chain state via the MultiCall contract.
TypeScript
93
star
40

api-deprecated

🔮 Uniswap market data
TypeScript
86
star
41

governance

🏛 Governance contracts for the Uniswap protocol
Solidity
78
star
42

sdk-core

⚙️ Code shared across TypeScript Uniswap SDK versions
TypeScript
77
star
43

universal-router-sdk

TypeScript
77
star
44

hardhat-v3-deploy

Hardhat plugin for Uniswap V3 deployment
TypeScript
75
star
45

sybil-interface

Interface that incorporates Sybil, a governance tool for discovering delegates.
TypeScript
69
star
46

deploy-v3

CLI to deploy Uniswap V3 to any Ethereum compatible network
TypeScript
62
star
47

liquidity-staker

Initial UNI liquidity staking contracts
TypeScript
60
star
48

unisocks-erc721

🧦
Python
52
star
49

sdks

prototype SDK monorepo
TypeScript
44
star
50

v1-docs

42
star
51

uniswapx-sdk

SDK bindings for the UniswapX protocol
TypeScript
40
star
52

uniswapx-parameterization-api

TypeScript
40
star
53

widgets-demo

@uniswap/widgets demo
40
star
54

uniswapx-service

UniswapX Order Service
TypeScript
39
star
55

marketdepth-v3

Uniswap v3 onchain market depth calculator
Solidity
39
star
56

unipig

🦄🐷
JavaScript
38
star
57

v3-new-chain-deployments

Instructions for deploying the Uniswap V3 protocol to new chains after receiving approval from governance.
34
star
58

unified-routing-api

TypeScript
34
star
59

uniswap-first-contract-example

Example code for the smart contract getting started example.
JavaScript
29
star
60

permit2-sdk

TypeScript
29
star
61

old-solidity-contracts

⚠️ DEPRECATED
Python
29
star
62

unisocks-erc20

🧦
Python
26
star
63

v3-core-optimism

Optimism fork of the V3 core contracts
TypeScript
25
star
64

lp-action-contracts

Solidity
25
star
65

sybil-verifier-worker

Cloudlfare worker to verify mappings for Sybil, a governance tool for delegates.
JavaScript
25
star
66

router-sdk

TypeScript
23
star
67

advanced-weth

A smart contract that wraps WETH that adds functionality for transparently dealing in WETH
JavaScript
20
star
68

ethers-rs-mobile

Rust
17
star
69

v3-periphery-optimism

Optimism fork of the V3 periphery contracts
TypeScript
17
star
70

ds-tools

Python
15
star
71

jest-environment-hardhat

TypeScript
15
star
72

conedison

Utilities for Uniswap repositories
TypeScript
13
star
73

extended-token-list

JavaScript
12
star
74

v1-interface

💀 Legacy interface for the Uniswap V1 protocol
JavaScript
12
star
75

returns-comparison-study

Python
11
star
76

mask-app

TypeScript
10
star
77

convert-cidv0-cidv1

GitHub action that converts CIDv0 for IPFS to CIDv1
JavaScript
9
star
78

polygon-bridge

Bridge contract for Polygon
TypeScript
9
star
79

mrkl-drop-data-chunks

The Merkle drop data broken up into chunks of 101 addresses and including a mapping file
TypeScript
8
star
80

fx-comparison-study

R
7
star
81

snapshot-gas-cost

Tiny utility package for snapshotting gas costs
TypeScript
7
star
82

eslint-config

Uniswap ESLint config
JavaScript
7
star
83

analytics

Uniswap analytics
TypeScript
7
star
84

interface-redirects

↪️ Redirects for alternative app.uniswap.org domains
6
star
85

analytics-events

Uniswap analytics events
TypeScript
6
star
86

permit2-dashboard

a dashboard for managing permit2 permissions
TypeScript
6
star
87

replace-vercel-dns-records

GitHub action for replacing Vercel DNS records, particularly useful for IPFS DNSLink TXT records
JavaScript
5
star
88

view-quoter-v3

Solidity
5
star
89

ticketblaster

a whimsical ticketing thing
TypeScript
4
star
90

relayer

Contracts supporting relayed UniversalRouter swaps
Solidity
4
star
91

v1-sdk

🛠 An SDK for building applications on top of Uniswap V1
TypeScript
3
star
92

signer

TypeScript
3
star
93

contracts

Collection of all Uniswap smart contracts
Solidity
2
star
94

interfaces

Solidity
2
star
95

info-redirects

↪️ Redirects for the uniswap.info domain
1
star