Skip to content
Closed
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
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ module.exports = {
'no-empty': 'off',
'no-empty-function': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
},
}
14 changes: 10 additions & 4 deletions .github/workflows/forge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,23 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: '16'
- name: Install dev dependencies
run: npm install

- name: Install Foundry
uses: onbjerg/foundry-toolchain@v1
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Install Deps
run: forge install
- name: Run forge tests forking mainnet
run: forge test -f ${{ secrets.ETH_NODE_URI_MAINNET }} --fork-block-number 14518542
run: forge test -f ${{ secrets.ETH_NODE_URI_MAINNET }} --fork-block-number ${{ secrets.FORK_NUMBER }} --no-match-contract ".*(Polygon)"
- name: Run forge tests forking polygon
run: forge test -f ${{ secrets.ETH_NODE_URI_POLYGON }} --fork-block-number ${{ secrets.POLYGON_FORK_NUMBER }} --match-contract ".*(Polygon)"
7 changes: 4 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: '14'
node-version: '16'

- name: Get yarn cache directory path
id: yarn-cache-dir-path
Expand Down Expand Up @@ -40,6 +40,7 @@ jobs:
env:
MNEMONIC: ${{ secrets.MNEMONIC }}
ETH_NODE_URI: ${{ secrets.ETH_NODE_URI }}
ETH_NODE_URI_RINKEBY: ${{ secrets.ETH_NODE_URI_RINKEBY }}
ETH_NODE_URI_POLYGON: ${{ secrets.ETH_NODE_URI_POLYGON }}
ETH_NODE_URI_ARBITRUM: ${{ secrets.ETH_NODE_URI_ARBITRUM }}
ETH_NODE_URI_KOVAN_OPTIMISM: ${{ secrets.ETH_NODE_URI_KOVAN_OPTIMISM }}
ETH_NODE_URI_ARBITRUMONE: ${{ secrets.ETH_NODE_URI_ARBITRUMONE }}
ETH_NODE_URI_OPTIMISTICKOVAN: ${{ secrets.ETH_NODE_URI_OPTIMISTICKOVAN }}
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[submodule "lib/ds-test"]
path = lib/ds-test
url = https://github.com/dapphub/ds-test
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/brockelmore/forge-std
[submodule "lib/solmate"]
path = lib/solmate
url = https://github.com/rari-capital/solmate
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
15 changes: 9 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
update:; forge update

# Build & test
build :; forge build
test :; forge test --fork-url ${ETH_NODE_URI_MAINNET} --fork-block-number ${FORK_NUMBER} -vv
trace :; forge test --fork-url ${ETH_NODE_URI_MAINNET} --fork-block-number ${FORK_NUMBER} -vvv
watch :; forge test --watch src test --fork-url ${ETH_NODE_URI_MAINNET} --fork-block-number ${FORK_NUMBER} -vvvv
clean :; forge clean
snapshot :; forge snapshot
build :; forge build
test :; forge test --fork-url ${ETH_NODE_URI_MAINNET} --fork-block-number ${FORK_NUMBER} -vv --no-match-contract ".*(Polygon)"
coverage :; forge coverage --fork-url ${ETH_NODE_URI_MAINNET} --fork-block-number ${FORK_NUMBER} -vv --no-match-contract ".*(Polygon)"
test-polygon :; forge test --fork-url ${ETH_NODE_URI_POLYGON} --fork-block-number ${POLYGON_FORK_NUMBER} -vv --match-contract ".*(Polygon)"
coverage-polygon :; forge coverage --fork-url ${ETH_NODE_URI_POLYGON} --fork-block-number ${POLYGON_FORK_NUMBER} -vv --match-contract ".*(Polygon)"
trace :; forge test --fork-url ${ETH_NODE_URI_MAINNET} --fork-block-number ${FORK_NUMBER} -vvv
watch :; forge test --watch src test --fork-url ${ETH_NODE_URI_MAINNET} --fork-block-number ${FORK_NUMBER} -vvvv
clean :; forge clean
snapshot :; forge snapshot --fork-url ${ETH_NODE_URI_MAINNET} --fork-block-number ${FORK_NUMBER} --match-path "test/solidity/Gas/**/*"
26 changes: 21 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
2. [TEST](#test)
3. [TEST With Foundry/Forge](#foundry-forge)
7. [Contract Docs](#contract-docs)
8. [More Information](#more-information)
8. [DEPLOY](#deploy)
9. [More Information](#more-information)

## General<a name="general"></a>

Expand Down Expand Up @@ -82,7 +83,7 @@ No need for users to leave your dApps anymore.

## How It Works<a name="how-it-works"></a>

Our [API](https://apidocs.li.finance/) and [SDK](https://docs.li.finance/official-documentation/integrate-li.fi-natively/li.fi-sdk) allow dApps and dApp developers to request the best routes for a desired cross-chain swap.
Our [API](https://apidocs.li.fi/) and [SDK](https://docs.li.fi/products/integrate-li.fi-js-sdk/install-li.fi-sdk) allow dApps and dApp developers to request the best routes for a desired cross-chain swap.
Our backend will calculate the best possible routes based on the transaction fees, gas costs and execution duration.

The then returned routes contain already populated transactions which can directly be sent via the user's wallet to our contracts.
Expand Down Expand Up @@ -112,6 +113,7 @@ graph TD;
D{LiFiDiamond}-- DELEGATECALL -->AnyswapFacet;
D{LiFiDiamond}-- DELEGATECALL -->CBridgeFacet;
D{LiFiDiamond}-- DELEGATECALL -->HyphenFacet;
D{LiFiDiamond}-- DELEGATECALL -->StargateFacet;
```

---
Expand Down Expand Up @@ -211,10 +213,24 @@ OR
yarn test:forge
```

### DEPLOY<a name="deploy"></a>

You can deploy the entire project by running:

`yarn deploy <network> --tags DeployAllFacets`

You can deploy individual facets by running:

`yarn deploy <network> --tags Deploy<facet> // e.g. DeployNXTPFacet`

DEX Manager is a special facet that manages allowed DEXs and allowed function calls. You can update these allowed DEXs/functions by updating `/config/dex.ts` and then running:

`yarn deploy <network> --tags DeployDexManagerFacet`

## More Information<a name="more-information"></a>

- [Website](https://li.fi/)
- [General Documentation](https://docs.li.finance/)
- [API Documentation](https://apidocs.li.finance/)
- [SDK Documentation](https://docs.li.finance/official-documentation/integrate-li.fi-natively/li.fi-sdk)
- [General Documentation](https://docs.li.fi/)
- [API Documentation](https://apidocs.li.fi/)
- [SDK Documentation](https://docs.li.fi/products/integrate-li.fi-js-sdk/install-li.fi-sdk)
- [Transfer UI](https://transferto.xyz/)
57 changes: 57 additions & 0 deletions config/across.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
interface AcrossConfig {
[key: string]: {
acrossSpokePool: string
weth: string
}
}

const config: AcrossConfig = {
hardhat: {
acrossSpokePool: '0x4D9079Bb4165aeb4084c526a32695dCfd2F77381',
weth: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
},
boba: {
acrossSpokePool: '0xBbc6009fEfFc27ce705322832Cb2068F8C1e0A58',
weth: '0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000',
},
arbitrumOne: {
acrossSpokePool: '0xB88690461dDbaB6f04Dfad7df66B7725942FEb9C',
weth: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1',
},
optimisticEthereum: {
acrossSpokePool: '0xa420b2d1c0841415A695b81E5B867BCD07Dff8C9',
weth: '0x4200000000000000000000000000000000000006',
},
polygon: {
acrossSpokePool: '0x69B5c72837769eF1e7C164Abc6515DcFf217F920',
weth: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
},
mainnet: {
acrossSpokePool: '0x4D9079Bb4165aeb4084c526a32695dCfd2F77381',
weth: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
},

// Testnet
rinkeby: {
acrossSpokePool: '0x90743806D7A66b37F31FAfd7b3447210aB55640f',
weth: '0xDf032Bc4B9dC2782Bb09352007D4C57B75160B15',
},
kovan: {
acrossSpokePool: '0x73549B5639B04090033c1E77a22eE9Aa44C2eBa0',
weth: '0xF3A6679B266899042276804930B3bFBaf807F15b',
},
arbitrumTestnet: {
acrossSpokePool: '0x3BED21dAe767e4Df894B31b14aD32369cE4bad8b',
weth: '',
},
optimisticKovan: {
acrossSpokePool: '0x2b7b7bAE341089103dD22fa4e8D7E4FA63E11084',
weth: '0x4200000000000000000000000000000000000006',
},
polygonMumbai: {
acrossSpokePool: '0xFd9e2642a170aDD10F53Ee14a93FcF2F31924944',
weth: '0xA6FA4fB5f76172d178d61B04b0ecd319C5d1C0aa',
},
}

export default config
35 changes: 35 additions & 0 deletions config/amarok.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
interface AmarokConfig {
[key: string]: {
connextHandler: string
domain: number
}
}

const config: AmarokConfig = {
hardhat: {
connextHandler: '',
domain: 0,
},
mainnet: {
connextHandler: '',
domain: 0,
},
goerli: {
connextHandler: '0x6c9a905Ab3f4495E2b47f5cA131ab71281E0546e',
domain: 3331,
},
rinkeby: {
connextHandler: '0x4cAA6358a3d9d1906B5DABDE60A626AAfD80186F',
domain: 1111,
},
mumbai: {
connextHandler: '0x765cbd312ad84A791908000DF58d879e4eaf768b',
domain: 9991,
},
evmosTestnet: {
connextHandler: '0xd14d61FE8E1369957711C99a427d38A0d8Cc141C',
domain: 4441,
},
}

export default config
60 changes: 60 additions & 0 deletions config/arbitrum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
interface ArbitrumBridgeConfig {
[key: string]: {
gatewayRouter: string // GatewayRouter contract address,
inbox: string // Inbox contract address,
}
}

export const DEFAULT_SUBMISSION_PRICE_PERCENT_INCREASE = 340
// Temporary workaround for incorrect gas estimation from NodeInterface when there is gas refund
export const DEFAULT_MAX_GAS_PERCENT_INCREASE = 50

export const ARB_RETRYABLE_TX_ADDRESS =
'0x000000000000000000000000000000000000006E'
export const NODE_INTERFACE_ADDRESS =
'0x00000000000000000000000000000000000000C8'

export const GET_SUBMISSION_PRICE_ABI = [
`
function getSubmissionPrice(uint256 calldataSize)
external
view
returns (uint256, uint256)
`,
]
export const ESTIMATE_RETRYABLE_TICKET_ABI = [
`
function estimateRetryableTicket(
address sender,
uint256 deposit,
address destAddr,
uint256 l2CallValue,
uint256 maxSubmissionCost,
address excessFeeRefundAddress,
address callValueRefundAddress,
uint256 maxGas,
uint256 gasPriceBid,
bytes data
)
external
view
returns (uint256, uint256)
`,
]

const config: ArbitrumBridgeConfig = {
hardhat: {
gatewayRouter: '0x72Ce9c846789fdB6fC1f34aC4AD25Dd9ef7031ef',
inbox: '0x4Dbd4fc535Ac27206064B68FfCf827b0A60BAB3f',
},
mainnet: {
gatewayRouter: '0x72Ce9c846789fdB6fC1f34aC4AD25Dd9ef7031ef',
inbox: '0x4Dbd4fc535Ac27206064B68FfCf827b0A60BAB3f',
},
rinkeby: {
gatewayRouter: '0x70C143928eCfFaf9F5b406f7f4fC28Dc43d68380',
inbox: '0x578BAde599406A8fE3d24Fd7f7211c0911F5B29e',
},
}

export default config
49 changes: 49 additions & 0 deletions config/axelar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
interface AxelarConfig {
[key: string]: {
gateway: string // Gateway contract address,
gasService: string // Gas Service contract address,
}
}

const config: AxelarConfig = {
mainnet: {
gateway: '0x4F4495243837681061C4743b74B3eEdf548D56A5',
gasService: '0x4154CF6eea0633DD9c4933E76a077fD7E9260738',
},
polygon: {
gateway: '0x6f015F16De9fC8791b234eF68D486d2bF203FBA8',
gasService: '0xc8E0b617c388c7E800a7643adDD01218E14a727a',
},
opera: {
gateway: '0x304acf330bbE08d1e512eefaa92F6a57871fD895',
gasService: '0x2879da536D9d107D6b92D95D7c4CFaA5De7088f4',
},
moonbeam: {
gateway: '0x4F4495243837681061C4743b74B3eEdf548D56A5',
gasService: '0x27927CD55db998b720214205e598aA9AD614AEE3',
},
avalanche: {
gateway: '0x5029C0EFf6C34351a0CEc334542cDb22c7928f78',
gasService: '0xB53C693544363912D2A034f70D9d98808D5E192a',
},
bsc: {
gateway: '0x304acf330bbE08d1e512eefaa92F6a57871fD895',
gasService: '',
},

// Testnets
ropsten: {
gateway: '0xBC6fcce7c5487d43830a219CA6E7B83238B41e71',
gasService: '0xbE406F0189A0B4cf3A05C286473D23791Dd44Cc6',
},
bscTestnet: {
gateway: '0x4D147dCb984e6affEEC47e44293DA442580A3Ec0',
gasService: '0xbE406F0189A0B4cf3A05C286473D23791Dd44Cc6',
},
polygonMumbai: {
gateway: '0xBF62ef1486468a6bd26Dd669C06db43dEd5B849B',
gasService: '0xbE406F0189A0B4cf3A05C286473D23791Dd44Cc6',
},
}

export default config
Loading