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

Support Optimism, Base, Metis and Avalanche #25

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/fair-olives-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@protocolink/logics': patch
---

support Optimism, Base, Metis and Avalanche
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
},
"dependencies": {
"@paraswap/sdk": "^6.2.2",
"@protocolink/common": "^0.3.0",
"@protocolink/core": "^0.4.1",
"@protocolink/common": "^0.3.3",
"@protocolink/core": "^0.4.2",
"@types/lodash": "^4.14.195",
"@uniswap/sdk-core": "^3.2.6",
"@uniswap/token-lists": "^1.0.0-beta.31",
Expand Down
7 changes: 7 additions & 0 deletions src/logics/aave-v2/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ export const configs: Config[] = [
AaveV2FlashLoanCallback: '0x27BfAC5fb25C3853C2F48cF0e5B2F89Ea03C0104',
},
},
{
chainId: common.ChainId.avalanche,
contract: {
ProtocolDataProvider: '0x65285E9dfab318f57051ab2b139ccCf232945451',
AaveV2FlashLoanCallback: '0x27BfAC5fb25C3853C2F48cF0e5B2F89Ea03C0104',
},
},
];

export const [supportedChainIds, configMap] = configs.reduce(
Expand Down
28 changes: 28 additions & 0 deletions src/logics/aave-v3/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,48 @@ export const configs: Config[] = [
AaveV3FlashLoanCallback: '0x6ea614B4C520c8abC9B0F50803Bef964D4DA81EB',
},
},
{
chainId: common.ChainId.optimism,
contract: {
PoolDataProvider: '0xd9Ca4878dd38B021583c1B669905592EAe76E044',
AaveV3FlashLoanCallback: '0x6ea614B4C520c8abC9B0F50803Bef964D4DA81EB',
Jeff-CCH marked this conversation as resolved.
Show resolved Hide resolved
},
},
{
chainId: common.ChainId.polygon,
contract: {
PoolDataProvider: '0x9441B65EE553F70df9C77d45d3283B6BC24F222d',
AaveV3FlashLoanCallback: '0x6ea614B4C520c8abC9B0F50803Bef964D4DA81EB',
},
},
{
chainId: common.ChainId.metis,
contract: {
PoolDataProvider: '0x99411FC17Ad1B56f49719E3850B2CDcc0f9bBFd8',
AaveV3FlashLoanCallback: '0x6ea614B4C520c8abC9B0F50803Bef964D4DA81EB',
},
},
{
chainId: common.ChainId.base,
contract: {
PoolDataProvider: '0x2d8A3C5677189723C4cB8873CfC9C8976FDF38Ac',
AaveV3FlashLoanCallback: '0x6ea614B4C520c8abC9B0F50803Bef964D4DA81EB',
},
},
{
chainId: common.ChainId.arbitrum,
contract: {
PoolDataProvider: '0x6b4E260b765B3cA1514e618C0215A6B7839fF93e',
AaveV3FlashLoanCallback: '0x6ea614B4C520c8abC9B0F50803Bef964D4DA81EB',
},
},
{
chainId: common.ChainId.avalanche,
contract: {
PoolDataProvider: '0x50ddd0Cd4266299527d25De9CBb55fE0EB8dAc30',
AaveV3FlashLoanCallback: '0x6ea614B4C520c8abC9B0F50803Bef964D4DA81EB',
},
},
];

export const [supportedChainIds, configMap] = configs.reduce(
Expand Down
24 changes: 24 additions & 0 deletions src/logics/balancer-v2/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ export const configs: Config[] = [
ProtocolFeesCollector: '0xce88686553686DA562CE7Cea497CE749DA109f9F',
},
},
{
chainId: common.ChainId.optimism,
contract: {
Vault: '0xBA12222222228d8Ba445958a75a0704d566BF2C8',
BalancerV2FlashLoanCallback: '0x08b3d2c773C08CF21746Cf16268d2E092881c208',
ProtocolFeesCollector: '0xce88686553686DA562CE7Cea497CE749DA109f9F',
},
},
{
chainId: common.ChainId.polygon,
contract: {
Expand All @@ -24,6 +32,14 @@ export const configs: Config[] = [
ProtocolFeesCollector: '0xce88686553686DA562CE7Cea497CE749DA109f9F',
},
},
{
chainId: common.ChainId.base,
contract: {
Vault: '0xBA12222222228d8Ba445958a75a0704d566BF2C8',
BalancerV2FlashLoanCallback: '0x08b3d2c773C08CF21746Cf16268d2E092881c208',
ProtocolFeesCollector: '0xce88686553686DA562CE7Cea497CE749DA109f9F',
},
},
{
chainId: common.ChainId.arbitrum,
contract: {
Expand All @@ -32,6 +48,14 @@ export const configs: Config[] = [
ProtocolFeesCollector: '0xce88686553686DA562CE7Cea497CE749DA109f9F',
},
},
{
chainId: common.ChainId.avalanche,
contract: {
Vault: '0xBA12222222228d8Ba445958a75a0704d566BF2C8',
BalancerV2FlashLoanCallback: '0x08b3d2c773C08CF21746Cf16268d2E092881c208',
ProtocolFeesCollector: '0xce88686553686DA562CE7Cea497CE749DA109f9F',
},
},
];

export const [supportedChainIds, configMap] = configs.reduce(
Expand Down
20 changes: 20 additions & 0 deletions src/logics/compound-v3/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type ContractNames = 'CometRewards';
export enum MarketId {
USDC = 'USDC',
USDCe = 'USDC.e',
USDbC = 'USDbC',
ETH = 'ETH',
}

Expand Down Expand Up @@ -67,6 +68,25 @@ export const configs: Config[] = [
'(PoS) Compound'
),
},
{
chainId: common.ChainId.base,
contract: {
CometRewards: '0x123964802e6ABabBE1Bc9547D72Ef1B69B00A6b1',
},
markets: [
{
id: MarketId.USDbC,
cometAddress: '0x9c4ec768c28520B50860ea7a15bd7213a9fF58bf',
baseTokenAddress: '0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA',
},
{
id: MarketId.ETH,
cometAddress: '0x46e6b214b524310239732D51387075E0e70970bf',
baseTokenAddress: '0x4200000000000000000000000000000000000006',
},
],
COMP: new common.Token(common.ChainId.base, '0x9e1028F5F1D5eDE59748FFceE5532509976840E0', 18, 'COMP', 'Compound'),
hihiben marked this conversation as resolved.
Show resolved Hide resolved
},
{
chainId: common.ChainId.arbitrum,
contract: {
Expand Down
19 changes: 19 additions & 0 deletions src/logics/paraswap-v5/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ export const configs: Config[] = [
'https://gateway.ipfs.io/ipns/tokens.uniswap.org',
],
},
{
chainId: common.ChainId.optimism,
tokenListUrls: [
'https://static.optimism.io/optimism.tokenlist.json',
'https://tokens.coingecko.com/optimistic-ethereum/all.json',
],
},
{
chainId: common.ChainId.polygon,
tokenListUrls: [
Expand All @@ -24,6 +31,10 @@ export const configs: Config[] = [
'https://tokens.coingecko.com/polygon-pos/all.json',
],
},
{
chainId: common.ChainId.base,
tokenListUrls: ['https://static.optimism.io/optimism.tokenlist.json'],
hihiben marked this conversation as resolved.
Show resolved Hide resolved
},
{
chainId: common.ChainId.arbitrum,
tokenListUrls: [
Expand All @@ -32,6 +43,14 @@ export const configs: Config[] = [
'https://tokens.coingecko.com/arbitrum-one/all.json',
],
},
{
chainId: common.ChainId.avalanche,
tokenListUrls: [
'https://raw.githubusercontent.com/pangolindex/tokenlists/main/pangolin.tokenlist.json',
'https://raw.githubusercontent.com/traderjoe-xyz/joe-tokenlists/main/mc.tokenlist.json',
'https://tokens.coingecko.com/avalanche/all.json',
],
},
];

export const [supportedChainIds, configMap] = configs.reduce(
Expand Down
45 changes: 31 additions & 14 deletions src/logics/uniswap-v3/configs.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { FeeAmount } from '@uniswap/v3-sdk';
import { arbitrumTokens, mainnetTokens, polygonTokens } from './tokens';
import { arbitrumTokens, avalancheTokens, baseTokens, mainnetTokens, optimismTokens, polygonTokens } from './tokens';
import * as common from '@protocolink/common';
import * as univ3 from 'src/modules/univ3';

// https://github.com/Uniswap/interface/blob/v4.204.5/src/constants/routing.ts#L61
// https://github.com/Uniswap/interface/blob/v4.265.0/src/constants/routing.ts#L65
hihiben marked this conversation as resolved.
Show resolved Hide resolved
// https://github.com/Uniswap/interface/blob/v4.204.5/src/constants/routing.ts#L91
// https://github.com/Uniswap/interface/blob/v4.204.5/src/constants/routing.ts#L108
export const configs: univ3.Config[] = [
Expand All @@ -13,7 +13,7 @@ export const configs: univ3.Config[] = [
quoter: { address: '0x61fFE014bA17989E743c5F6cB21bF9697530B21e', isV2: true },
swapRouterAddress: '0xE592427A0AEce92De3Edee1F18E0157C05861564',
feeAmounts: [FeeAmount.LOWEST, FeeAmount.LOW, FeeAmount.MEDIUM, FeeAmount.HIGH],
bases: [mainnetTokens.WETH, mainnetTokens.DAI, mainnetTokens.USDC, mainnetTokens.USDT, mainnetTokens.WBTC],
bases: [mainnetTokens.DAI, mainnetTokens.USDC, mainnetTokens.USDT, mainnetTokens.WBTC, mainnetTokens.WETH],
additionalBases: {
'0xF16E4d813f4DcfDe4c5b44f305c908742De84eF0': [mainnetTokens.ETH2X_FLI],
[mainnetTokens.rETH2.address]: [mainnetTokens.sETH2],
Expand All @@ -26,20 +26,29 @@ export const configs: univ3.Config[] = [
[mainnetTokens.renBTC.address]: [mainnetTokens.WBTC],
},
},
{
chainId: common.ChainId.optimism,
factoryAddress: '0x1F98431c8aD98523631AE4a59f267346ea31F984',
quoter: { address: '0x61fFE014bA17989E743c5F6cB21bF9697530B21e', isV2: true },
swapRouterAddress: '0xE592427A0AEce92De3Edee1F18E0157C05861564',
feeAmounts: [FeeAmount.LOWEST, FeeAmount.LOW, FeeAmount.MEDIUM, FeeAmount.HIGH],
bases: [optimismTokens.OP, optimismTokens.DAI, optimismTokens['USDC.e'], optimismTokens.USDT, optimismTokens.WBTC],
hihiben marked this conversation as resolved.
Show resolved Hide resolved
},
{
chainId: common.ChainId.polygon,
factoryAddress: '0x1F98431c8aD98523631AE4a59f267346ea31F984',
quoter: { address: '0x61fFE014bA17989E743c5F6cB21bF9697530B21e', isV2: true },
swapRouterAddress: '0xE592427A0AEce92De3Edee1F18E0157C05861564',
feeAmounts: [FeeAmount.LOWEST, FeeAmount.LOW, FeeAmount.MEDIUM, FeeAmount.HIGH],
bases: [
polygonTokens.WMATIC,
polygonTokens.DAI,
polygonTokens.USDC,
polygonTokens.USDT,
polygonTokens.WETH,
polygonTokens.WBTC,
],
bases: [polygonTokens.WETH, polygonTokens.USDC, polygonTokens.DAI, polygonTokens.USDT, polygonTokens.WBTC],
},
{
chainId: common.ChainId.base,
factoryAddress: '0x33128a8fC17869897dcE68Ed026d694621f6FDfD',
quoter: { address: '0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a', isV2: true },
swapRouterAddress: '',
feeAmounts: [FeeAmount.LOWEST, FeeAmount.LOW, FeeAmount.MEDIUM, FeeAmount.HIGH],
bases: [baseTokens.WETH, baseTokens.USDbC],
},
{
chainId: common.ChainId.arbitrum,
Expand All @@ -48,14 +57,22 @@ export const configs: univ3.Config[] = [
swapRouterAddress: '0xE592427A0AEce92De3Edee1F18E0157C05861564',
feeAmounts: [FeeAmount.LOWEST, FeeAmount.LOW, FeeAmount.MEDIUM, FeeAmount.HIGH],
bases: [
arbitrumTokens.WETH,
arbitrumTokens.ARB,
arbitrumTokens.DAI,
arbitrumTokens.USDC,
arbitrumTokens.USDT,
arbitrumTokens.WBTC,
arbitrumTokens.USDC,
arbitrumTokens['USDC.e'],
arbitrumTokens.WETH,
],
},
{
chainId: common.ChainId.avalanche,
factoryAddress: '0x740b1c1de25031C31FF4fC9A62f554A55cdC1baD',
quoter: { address: '0xbe0F5544EC67e9B3b2D979aaA43f18Fd87E6257F', isV2: true },
swapRouterAddress: '',
feeAmounts: [FeeAmount.LOWEST, FeeAmount.LOW, FeeAmount.MEDIUM, FeeAmount.HIGH],
bases: [avalancheTokens.DAI, avalancheTokens.USDC, avalancheTokens.USDT, avalancheTokens.WETH],
},
];

export const [supportedChainIds, configMap] = configs.reduce(
Expand Down
7 changes: 7 additions & 0 deletions src/logics/uniswap-v3/tokens/data/arbitrum.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
{
"ARB": {
"chainId": 42161,
"address": "0x912CE59144191C1204E64559FE8253a0e49E6548",
"decimals": 18,
"symbol": "ARB",
"name": "Arbitrum"
},
"WETH": {
"chainId": 42161,
"address": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
Expand Down
37 changes: 37 additions & 0 deletions src/logics/uniswap-v3/tokens/data/avalanche.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"DAI": {
"chainId": 43114,
"address": "0xd586E7F844cEa2F87f50152665BCbc2C279D8d70",
"decimals": 18,
"symbol": "DAI.e",
"name": "Dai Stablecoin"
},
"USDC": {
"chainId": 43114,
"address": "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
"decimals": 6,
"symbol": "USDC",
"name": "USD Coin"
},
"USDC.e": {
"chainId": 43114,
"address": "0xA7D7079b0FEaD91F3e65f86E8915Cb59c1a4C664",
"decimals": 6,
"symbol": "USDC.e",
"name": "USD Coin - Bridged"
},
"USDT": {
"chainId": 43114,
"address": "0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",
"decimals": 6,
"symbol": "USDT",
"name": "Tether Token"
},
"WETH": {
"chainId": 43114,
"address": "0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB",
"decimals": 18,
"symbol": "WETH.e",
"name": "Wrapped Ether"
}
}
16 changes: 16 additions & 0 deletions src/logics/uniswap-v3/tokens/data/base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"WETH": {
"chainId": 8453,
"address": "0x4200000000000000000000000000000000000006",
"decimals": 18,
"symbol": "WETH",
"name": "Wrapped Ether"
},
"USDbC": {
"chainId": 8453,
"address": "0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA",
"decimals": 6,
"symbol": "USDbC",
"name": "USD Base Coin"
}
}
44 changes: 44 additions & 0 deletions src/logics/uniswap-v3/tokens/data/optimism.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"OP": {
"chainId": 10,
"address": "0x4200000000000000000000000000000000000042",
"decimals": 18,
"symbol": "OP",
"name": "Optimism"
},
"DAI": {
"chainId": 10,
"address": "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1",
"decimals": 18,
"symbol": "DAI",
"name": "Dai Stablecoin"
},
"USDC": {
"chainId": 10,
"address": "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
"decimals": 6,
"symbol": "USDC",
"name": "USD Coin"
},
"USDC.e": {
"chainId": 10,
"address": "0x7F5c764cBc14f9669B88837ca1490cCa17c31607",
"decimals": 6,
"symbol": "USDC.e",
"name": "USD Coin (Bridged from Ethereum)"
},
"USDT": {
"chainId": 10,
"address": "0x94b008aA00579c1307B0EF2c499aD98a8ce58e58",
"decimals": 6,
"symbol": "USDT",
"name": "Tether USD"
},
"WBTC": {
"chainId": 10,
"address": "0x68f180fcCe6836688e9084f035309E29Bf0A2095",
"decimals": 8,
"symbol": "WBTC",
"name": "Wrapped BTC"
}
}
Loading