Skip to content

Commit

Permalink
Merge pull request #21 from balancer/add-base-for-cow
Browse files Browse the repository at this point in the history
Add support for base network
  • Loading branch information
MattPereira authored Jan 8, 2025
2 parents 716d986 + 8cb9d2e commit 3c22248
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
SEPOLIA_RPC_URL=
MAINNET_RPC_URL=
GNOSIS_RPC_URL=
ARBITRUM_RPC_URL=
ARBITRUM_RPC_URL=
BASE_RPC_URL=
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-include .env

fork: fork-sepolia fork-mainnet fork-gnosis fork-arbitrum
fork: fork-sepolia fork-mainnet fork-gnosis fork-arbitrum fork-base

fork-%:
@echo "Forking the $* network..."
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ SEPOLIA_RPC_URL=
MAINNET_RPC_URL=
GNOSIS_RPC_URL=
ARBITRUM_RPC_URL=
BASE_RPC_URL=
```

2. Add `chains.foundry` as the first item of `targetNetworks` in the `scaffold.config.ts` file
Expand All @@ -56,6 +57,7 @@ make fork-sepolia
make fork-mainnet
make fork-gnosis
make fork-arbitrum
make fork-base
```

5. Start the frontend
Expand Down
18 changes: 13 additions & 5 deletions packages/nextjs/contracts/externalContracts.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { abis } from "./abis";
import { arbitrum, gnosis, mainnet, sepolia } from "viem/chains";
import { arbitrum, base, gnosis, mainnet, sepolia } from "viem/chains";
import scaffoldConfig from "~~/scaffold.config";
import { GenericContractsDeclaration } from "~~/utils/scaffold-eth/contract";

const FACTORY_ADDRESSES = {
11155111: "0x1E3D76AC2BB67a2D7e8395d3A624b30AA9056DF9",
1: "0xf76c421bAb7df8548604E60deCCcE50477C10462",
100: "0x703Bd8115E6F21a37BB5Df97f78614ca72Ad7624",
42161: "0xE0e2Ba143EE5268DA87D529949a2521115987302",
11155111: "0x1E3D76AC2BB67a2D7e8395d3A624b30AA9056DF9", // Sepolia
1: "0xf76c421bAb7df8548604E60deCCcE50477C10462", // Mainnet
100: "0x703Bd8115E6F21a37BB5Df97f78614ca72Ad7624", // Gnosis
42161: "0xE0e2Ba143EE5268DA87D529949a2521115987302", // Arbitrum
8453: "0x03362f847B4fAbC12e1Ce98b6b59F94401E4588e", // Base -> https://basescan.org/address/0x03362f847b4fabc12e1ce98b6b59f94401e4588e#code
} as const;

const externalContracts = {
Expand Down Expand Up @@ -46,6 +47,13 @@ const externalContracts = {
fromBlock: 248291297n,
},
},
8453: {
BCoWFactory: {
address: FACTORY_ADDRESSES[base.id],
abi: abis.CoW.BCoWFactory,
fromBlock: 23650200n,
},
},
} as const;

export default externalContracts satisfies GenericContractsDeclaration;
1 change: 1 addition & 0 deletions packages/nextjs/hooks/balancer/useApiConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ export const CHAIN_NAMES: { [key: number]: string } = {
100: "GNOSIS",
11155111: "SEPOLIA",
42161: "ARBITRUM",
8453: "BASE",
};
2 changes: 2 additions & 0 deletions packages/nextjs/hooks/cow/getPoolUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export function getPoolUrl(chainId: number, poolAddress: string) {
return `https://test.balancer.fi/pools/sepolia/cow/${poolAddress}`;
case 42161:
return `https://balancer.fi/pools/arbitrum/cow/${poolAddress}`;
case 8453:
return `https://balancer.fi/pools/base/cow/${poolAddress}`;
default:
return "unknown";
}
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/scaffold.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type ScaffoldConfig = {

const scaffoldConfig = {
// The networks on which your DApp is live
targetNetworks: [chains.sepolia, chains.mainnet, chains.gnosis, chains.arbitrum],
targetNetworks: [chains.sepolia, chains.mainnet, chains.gnosis, chains.arbitrum, chains.base],

// If using chains.foundry as your targetNetwork, you must specify a network to fork
targetFork: chains.sepolia,
Expand Down

0 comments on commit 3c22248

Please sign in to comment.