diff --git a/.changeset/funny-lies-train.md b/.changeset/funny-lies-train.md new file mode 100644 index 00000000..a4bf6ff9 --- /dev/null +++ b/.changeset/funny-lies-train.md @@ -0,0 +1,5 @@ +--- +'@protocolink/logics': patch +--- + +fix init.ts rpc url diff --git a/.env.mainnet b/.env.mainnet index 5b6d929d..cf1097fb 100644 --- a/.env.mainnet +++ b/.env.mainnet @@ -1,2 +1 @@ CHAIN_ID=1 -HTTP_RPC_URL=https://mainnet.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161 diff --git a/.env.mainnet.pb b/.env.mainnet.pb index 080ea875..f2ed0862 100644 --- a/.env.mainnet.pb +++ b/.env.mainnet.pb @@ -1,3 +1,2 @@ CHAIN_ID=1 -HTTP_RPC_URL=https://mainnet.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161 BLOCK_NUMBER=18989101 diff --git a/.github/workflows/e2e-test-latest.yml b/.github/workflows/e2e-test-latest.yml index 42b45e57..99417398 100644 --- a/.github/workflows/e2e-test-latest.yml +++ b/.github/workflows/e2e-test-latest.yml @@ -4,6 +4,9 @@ on: push: pull_request: +env: + MAINNET_RPC_URL: ${{ secrets.MAINNET_RPC_URL }} + jobs: run-e2e-test: name: latest diff --git a/.github/workflows/e2e-test-mainnet-pb.yml b/.github/workflows/e2e-test-mainnet-pb.yml index 8c31370e..16ad1d4d 100644 --- a/.github/workflows/e2e-test-mainnet-pb.yml +++ b/.github/workflows/e2e-test-mainnet-pb.yml @@ -4,6 +4,9 @@ on: push: pull_request: +env: + MAINNET_RPC_URL: ${{ secrets.MAINNET_RPC_URL }} + jobs: run-e2e-test: name: mainnet pb diff --git a/hardhat.config.ts b/hardhat.config.ts index 4e8e8104..013054ac 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -17,7 +17,7 @@ const config: HardhatUserConfig = { initialIndex: 0, }, forking: { - url: process.env.HTTP_RPC_URL ?? 'https://eth.llamarpc.com', + url: process.env.HTTP_RPC_URL || process.env.MAINNET_RPC_URL || 'https://eth.llamarpc.com', blockNumber: process.env.BLOCK_NUMBER ? parseInt(process.env.BLOCK_NUMBER) : undefined, }, }, diff --git a/test/init.ts b/test/init.ts index e1c977a3..0a969284 100644 --- a/test/init.ts +++ b/test/init.ts @@ -1,3 +1,9 @@ import * as common from '@protocolink/common'; -common.setNetwork(common.ChainId.mainnet, { rpcUrl: 'https://mainnet.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161' }); +if (process.env.CHAIN_ID && process.env.HTTP_RPC_URL) { + common.setNetwork(parseInt(process.env.CHAIN_ID), { rpcUrl: process.env.HTTP_RPC_URL }); +} else if (process.env.MAINNET_RPC_URL) { + common.setNetwork(common.ChainId.mainnet, { rpcUrl: process.env.MAINNET_RPC_URL }); +} else { + common.setNetwork(common.ChainId.mainnet, { rpcUrl: 'https://eth.llamarpc.com' }); +} diff --git a/test/logics/uniswap-v3/swap-token.test.ts b/test/logics/uniswap-v3/swap-token.test.ts index 80bcaca4..d002776d 100644 --- a/test/logics/uniswap-v3/swap-token.test.ts +++ b/test/logics/uniswap-v3/swap-token.test.ts @@ -29,9 +29,9 @@ describe('mainnet-pb: Test UniswapV3 SwapToken Logic', function () { }, { params: { - input: new common.TokenAmount(mainnetTokens.USDC, '1000'), + input: new common.TokenAmount(mainnetTokens.USDC, '10'), tokenOut: mainnetTokens.ETH, - slippage: 500, + slippage: 1000, }, }, { @@ -51,9 +51,9 @@ describe('mainnet-pb: Test UniswapV3 SwapToken Logic', function () { }, { params: { - input: new common.TokenAmount(mainnetTokens.USDC, '1000'), + input: new common.TokenAmount(mainnetTokens.USDC, '10'), tokenOut: mainnetTokens.ETH, - slippage: 500, + slippage: 1000, }, balanceBps: 5000, }, @@ -76,7 +76,7 @@ describe('mainnet-pb: Test UniswapV3 SwapToken Logic', function () { params: { tokenIn: mainnetTokens.USDC, output: new common.TokenAmount(mainnetTokens.ETH, '1'), - slippage: 500, + slippage: 1000, }, }, {