Skip to content

Commit

Permalink
(fix) revised uniswap-base support
Browse files Browse the repository at this point in the history
  • Loading branch information
fengtality committed Jun 2, 2024
1 parent 87a3d66 commit c8e092b
Show file tree
Hide file tree
Showing 6 changed files with 273 additions and 10 deletions.
5 changes: 5 additions & 0 deletions src/connectors/uniswap/uniswap.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export namespace UniswapConfig {
maximumHops: number;
uniswapV3SmartOrderRouterAddress: (network: string) => string;
uniswapV3NftManagerAddress: (network: string) => string;
uniswapV3FactoryAddress: (network: string) => string;
tradingTypes: (type: string) => Array<string>;
chainType: string;
availableNetworks: Array<AvailableNetworks>;
Expand All @@ -33,6 +34,10 @@ export namespace UniswapConfig {
ConfigManagerV2.getInstance().get(
`uniswap.contractAddresses.${network}.uniswapV3NftManagerAddress`
),
uniswapV3FactoryAddress: (network: string) =>
ConfigManagerV2.getInstance().get(
`uniswap.contractAddresses.${network}.uniswapV3FactoryAddress`
),
tradingTypes: (type: string) => {
return type === 'swap' ? ['AMM'] : ['AMM_LP'];
},
Expand Down
7 changes: 4 additions & 3 deletions src/connectors/uniswap/uniswap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import {
Pool,
SwapQuoter,
Trade as UniswapV3Trade,
Route,
FACTORY_ADDRESS,
Route
} from '@uniswap/v3-sdk';
import { abi as IUniswapV3PoolABI } from '@uniswap/v3-core/artifacts/contracts/interfaces/IUniswapV3Pool.sol/IUniswapV3Pool.json';
import { abi as IUniswapV3FactoryABI } from '@uniswap/v3-core/artifacts/contracts/interfaces/IUniswapV3Factory.sol/IUniswapV3Factory.json';
Expand Down Expand Up @@ -56,6 +55,7 @@ export class Uniswap implements Uniswapish {
private readonly _useRouter: boolean;
private readonly _feeTier: FeeAmount;
private readonly _quoterContractAddress: string;
private readonly _factoryAddress: string;

private constructor(chain: string, network: string) {
const config = UniswapConfig.config;
Expand Down Expand Up @@ -88,6 +88,7 @@ export class Uniswap implements Uniswapish {
? FeeAmount[config.feeTier as keyof typeof FeeAmount]
: FeeAmount.MEDIUM;
this._quoterContractAddress = config.quoterContractAddress(network);
this._factoryAddress = config.uniswapV3FactoryAddress(network);
}

public static getInstance(chain: string, network: string): Uniswap {
Expand Down Expand Up @@ -428,7 +429,7 @@ export class Uniswap implements Uniswapish {
poolId?: string
): Promise<Pool | null> {
const uniswapFactory = new Contract(
FACTORY_ADDRESS,
this._factoryAddress,
IUniswapV3FactoryABI,
this.chain.provider
);
Expand Down
7 changes: 5 additions & 2 deletions src/services/schema/uniswap-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
"properties": {
"uniswapV3SmartOrderRouterAddress": { "type": "string" },
"uniswapV3NftManagerAddress": { "type": "string" },
"uniswapV3QuoterV2ContractAddress": { "type": "string" }
"uniswapV3QuoterV2ContractAddress": { "type": "string" },
"uniswapV3FactoryAddress": { "type": "string" }
},
"required": [
"uniswapV3SmartOrderRouterAddress",
"uniswapV3NftManagerAddress"
"uniswapV3NftManagerAddress",
"uniswapV3QuoterV2ContractAddress",
"uniswapV3FactoryAddress"
],
"additionalProperties": false
}
Expand Down
10 changes: 9 additions & 1 deletion src/templates/ethereum.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ networks:
chainID: 324
nodeURL: https://mainnet.era.zksync.io
tokenListType: FILE
tokenListSource: conf/lists/zksync_quiknode_tokens.json
tokenListSource: /home/gateway/conf/lists/zksync_quiknode_tokens.json
nativeCurrencySymbol: ETH
gasPriceRefreshInterval: 60
optimism:
Expand All @@ -39,6 +39,14 @@ networks:
tokenListType: FILE
tokenListSource: /home/gateway/conf/lists/erc20_tokens_goerli.json
nativeCurrencySymbol: ETH
base:
chainID: 8453
nodeURL: https://rpc.ankr.com/base
tokenListType: FILE
tokenListSource: /home/gateway/conf/lists/base_uniswap_20240411.json
nativeCurrencySymbol: ETH
gasPriceRefreshInterval: 60


# if you use the gas assumptions below, your wallet needs >0.1 ETH balance for gas
gasLimitTransaction: 3000000
Expand Down
241 changes: 241 additions & 0 deletions src/templates/lists/base_uniswap_20240411.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
{
"name": "Uniswap Labs Default",
"timestamp": "2024-04-08T14:06:46.865Z",
"version": {
"major": 11,
"minor": 17,
"patch": 0
},
"tags": {},
"logoURI": "ipfs://QmNa8mQkrNKp1WEEeGjFezDmDeodkWRevGFN8JCV7b4Xir",
"keywords": [
"uniswap",
"default"
],
"tokens": [
{
"chainId": 8453,
"address": "0xc5fecC3a29Fb57B5024eEc8a2239d4621e111CBE",
"name": "1inch",
"symbol": "1INCH",
"decimals": 18,
"logoURI": "https://assets.coingecko.com/coins/images/13469/thumb/1inch-token.png?1608803028"
},
{
"chainId": 8453,
"address": "0x940181a94A35A4569E4529A3CDfB74e38FD98631",
"name": "Aerodrome Finance",
"symbol": "AERO",
"decimals": 18,
"logoURI": "https://basescan.org/token/images/aerodrome_32.png"
},
{
"chainId": 8453,
"address": "0x97c806e7665d3AFd84A8Fe1837921403D59F3Dcc",
"name": "Alethea Artificial Liquid Intelligence",
"symbol": "ALI",
"decimals": 18,
"logoURI": "https://assets.coingecko.com/coins/images/22062/thumb/alethea-logo-transparent-colored.png?1642748848"
},
{
"chainId": 8453,
"address": "0x1C9Fa01e87487712706Fb469a13bEb234262C867",
"name": "ARPA Chain",
"symbol": "ARPA",
"decimals": 18,
"logoURI": "https://assets.coingecko.com/coins/images/8506/thumb/9u0a23XY_400x400.jpg?1559027357"
},
{
"name": "Balancer",
"address": "0x4158734D47Fc9692176B5085E0F52ee0Da5d47F1",
"symbol": "BAL",
"decimals": 18,
"chainId": 8453,
"logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xba100000625a3754423978a60c9317c58a424e3D/logo.png"
},
{
"chainId": 8453,
"address": "0xA7d68d155d17cB30e311367c2Ef1E82aB6022b67",
"name": "Braintrust",
"symbol": "BTRST",
"decimals": 18,
"logoURI": "https://assets.coingecko.com/coins/images/18100/thumb/braintrust.PNG?1630475394"
},
{
"chainId": 8453,
"address": "0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22",
"name": "Coinbase Wrapped Staked ETH",
"symbol": "cbETH",
"decimals": 18,
"logoURI": "https://ethereum-optimism.github.io/data/cbETH/logo.svg"
},
{
"name": "Compound",
"address": "0x9e1028F5F1D5eDE59748FFceE5532509976840E0",
"symbol": "COMP",
"decimals": 18,
"chainId": 8453,
"logoURI": "https://ethereum-optimism.github.io/data/COMP/logo.svg"
},
{
"name": "Curve DAO Token",
"address": "0x8Ee73c484A26e0A5df2Ee2a4960B789967dd0415",
"symbol": "CRV",
"decimals": 18,
"chainId": 8453,
"logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xD533a949740bb3306d119CC777fa900bA034cd52/logo.png"
},
{
"name": "Dai Stablecoin",
"address": "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",
"symbol": "DAI",
"decimals": 18,
"chainId": 8453,
"logoURI": "https://ethereum-optimism.github.io/data/DAI/logo.svg"
},
{
"chainId": 8453,
"address": "0xD08a2917653d4E460893203471f0000826fb4034",
"name": "Harvest Finance",
"symbol": "FARM",
"decimals": 18,
"logoURI": "https://assets.coingecko.com/coins/images/12304/thumb/Harvest.png?1613016180"
},
{
"chainId": 8453,
"address": "0x968B2323d4b005C7D39c67D31774FE83c9943A60",
"name": "Ampleforth Governance Token",
"symbol": "FORTH",
"decimals": 18,
"logoURI": "https://assets.coingecko.com/coins/images/14917/thumb/photo_2021-04-22_00.00.03.jpeg?1619020835"
},
{
"chainId": 8453,
"address": "0x2dbe0d779c7A04F7a5de83326973effE23356930",
"name": "ShapeShift FOX Token",
"symbol": "FOX",
"decimals": 18,
"logoURI": "https://assets.coingecko.com/coins/images/9988/thumb/FOX.png?1574330622"
},
{
"chainId": 8453,
"name": "Liquity USD",
"symbol": "LUSD",
"logoURI": "https://assets.coingecko.com/coins/images/14666/thumb/Group_3.png?1617631327",
"address": "0x368181499736d0c0CC614DBB145E2EC1AC86b8c6",
"decimals": 18
},
{
"chainId": 8453,
"address": "0xB4fDe59a779991bfB6a52253B51947828b982be3",
"name": "Pepe",
"symbol": "PEPE",
"decimals": 18,
"logoURI": "https://assets.coingecko.com/coins/images/29850/large/pepe-token.jpeg?1682922725"
},
{
"chainId": 8453,
"address": "0xfA980cEd6895AC314E7dE34Ef1bFAE90a5AdD21b",
"name": "Prime",
"symbol": "PRIME",
"decimals": 18,
"logoURI": "https://assets.coingecko.com/coins/images/29053/large/PRIMELOGOOO.png?1676976222"
},
{
"chainId": 8453,
"address": "0x18dD5B087bCA9920562aFf7A0199b96B9230438b",
"name": "Propy",
"symbol": "PRO",
"decimals": 8,
"logoURI": "https://assets.coingecko.com/coins/images/869/thumb/propy.png?1548332100"
},
{
"chainId": 8453,
"address": "0x1C7a460413dD4e964f96D8dFC56E7223cE88CD85",
"name": "Seamlesss",
"symbol": "SEAM",
"decimals": 18,
"logoURI": "https://basescan.org/token/images/seamless_32.png"
},
{
"name": "Synthetix Network Token",
"address": "0x22e6966B799c4D5B13BE962E1D117b56327FDa66",
"symbol": "SNX",
"decimals": 18,
"chainId": 8453,
"logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F/logo.png"
},
{
"chainId": 8453,
"address": "0x7D49a065D17d6d4a55dc13649901fdBB98B2AFBA",
"name": "Sushi",
"symbol": "SUSHI",
"decimals": 18,
"logoURI": "https://assets.coingecko.com/coins/images/12271/thumb/512x512_Logo_no_chop.png?1606986688"
},
{
"chainId": 8453,
"address": "0x236aa50979D5f3De3Bd1Eeb40E81137F22ab794b",
"name": "tBTC",
"symbol": "tBTC",
"decimals": 18,
"logoURI": "https://raw.githubusercontent.com/uniswap/assets/master/blockchains/ethereum/assets/0x18084fbA666a33d37592fA2633fD49a74DD93a88/logo.png"
},
{
"chainId": 8453,
"address": "0xA81a52B4dda010896cDd386C7fBdc5CDc835ba23",
"name": "OriginTrail",
"symbol": "TRAC",
"decimals": 18,
"logoURI": "https://assets.coingecko.com/coins/images/1877/thumb/TRAC.jpg?1635134367"
},
{
"chainId": 8453,
"address": "0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA",
"name": "USD Base Coin",
"symbol": "USDbC",
"decimals": 6,
"logoURI": "https://ethereum-optimism.github.io/data/USDC/logo.png"
},
{
"name": "USD Coin",
"address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"symbol": "USDC",
"decimals": 6,
"chainId": 8453,
"logoURI": "https://ethereum-optimism.github.io/data/USDC/logo.png"
},
{
"chainId": 8453,
"name": "Wrapped Ampleforth",
"symbol": "WAMPL",
"logoURI": "https://assets.coingecko.com/coins/images/20825/thumb/photo_2021-11-25_02-05-11.jpg?1637811951",
"address": "0x489fe42C267fe0366B16b0c39e7AEEf977E841eF",
"decimals": 18
},
{
"name": "Wrapped Ether",
"address": "0x4200000000000000000000000000000000000006",
"symbol": "WETH",
"decimals": 18,
"chainId": 8453,
"logoURI": "https://ethereum-optimism.github.io/data/WETH/logo.png"
},
{
"chainId": 8453,
"address": "0x9EaF8C1E34F05a589EDa6BAfdF391Cf6Ad3CB239",
"name": "yearn finance",
"symbol": "YFI",
"decimals": 18,
"logoURI": "https://assets.coingecko.com/coins/images/11849/thumb/yfi-192x192.png?1598325330"
},
{
"name": "0x Protocol Token",
"address": "0x3bB4445D30AC020a84c1b5A8A2C6248ebC9779D0",
"symbol": "ZRX",
"decimals": 18,
"chainId": 8453,
"logoURI": "https://ethereum-optimism.github.io/data/ZRX/logo.png"
}
]
}
13 changes: 9 additions & 4 deletions src/templates/uniswap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,24 @@ contractAddresses:
uniswapV3SmartOrderRouterAddress: '0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45'
uniswapV3NftManagerAddress: '0xC36442b4a4522E871399CD717aBDD847Ab11FE88'
uniswapV3QuoterV2ContractAddress: '0x61fFE014bA17989E743c5F6cB21bF9697530B21e'
uniswapV3FactoryAddress: '0x1F98431c8aD98523631AE4a59f267346ea31F984'
goerli:
uniswapV3SmartOrderRouterAddress: '0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45'
uniswapV3NftManagerAddress: '0xC36442b4a4522E871399CD717aBDD847Ab11FE88'
uniswapV3QuoterV2ContractAddress: '0x61fFE014bA17989E743c5F6cB21bF9697530B21e'
uniswapV3FactoryAddress: '0x1F98431c8aD98523631AE4a59f267346ea31F984'
arbitrum:
uniswapV3SmartOrderRouterAddress: '0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45'
uniswapV3NftManagerAddress: '0xC36442b4a4522E871399CD717aBDD847Ab11FE88'
uniswapV3QuoterV2ContractAddress: '0x61fFE014bA17989E743c5F6cB21bF9697530B21e'
uniswapV3FactoryAddress: '0x1F98431c8aD98523631AE4a59f267346ea31F984'
optimism:
uniswapV3SmartOrderRouterAddress: '0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45'
uniswapV3NftManagerAddress: '0xC36442b4a4522E871399CD717aBDD847Ab11FE88'
uniswapV3QuoterV2ContractAddress: '0x61fFE014bA17989E743c5F6cB21bF9697530B21e'
mumbai:
uniswapV3SmartOrderRouterAddress: '0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45'
uniswapV3NftManagerAddress: '0xC36442b4a4522E871399CD717aBDD847Ab11FE88'
uniswapV3QuoterV2ContractAddress: '0x61fFE014bA17989E743c5F6cB21bF9697530B21e'
uniswapV3FactoryAddress: '0x1F98431c8aD98523631AE4a59f267346ea31F984'
base:
uniswapV3SmartOrderRouterAddress: '0x2626664c2603336E57B271c5C0b26F421741e481'
uniswapV3NftManagerAddress: '0x03a520b32C04BF3bEEf7BEb72E919cf822Ed34f1'
uniswapV3QuoterV2ContractAddress: '0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a'
uniswapV3FactoryAddress: '0x33128a8fC17869897dcE68Ed026d694621f6FDfD'

0 comments on commit c8e092b

Please sign in to comment.