Skip to content

Commit e4fe4f7

Browse files
committed
initial commit
1 parent ae72dbc commit e4fe4f7

24 files changed

+659
-105
lines changed

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ out/
77
/broadcast/*/31337/
88
/broadcast/**/dry-run/
99

10-
# Docs
11-
docs/
12-
1310
# Dotenv file
1411
.env
12+
13+
/dev-ctx/
14+
/broadcast/

.gitmodules

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
11
[submodule "lib/forge-std"]
22
path = lib/forge-std
33
url = https://github.com/foundry-rs/forge-std
4+
[submodule "libflat/euler-swap"]
5+
path = libflat/euler-swap
6+
url = git@github.com:euler-xyz/euler-swap
7+
[submodule "libflat/euler-vault-kit"]
8+
path = libflat/euler-vault-kit
9+
url = https://github.com/euler-xyz/euler-vault-kit
10+
[submodule "libflat/ethereum-vault-connector"]
11+
path = libflat/ethereum-vault-connector
12+
url = https://github.com/euler-xyz/ethereum-vault-connector
13+
[submodule "libflat/openzeppelin-contracts"]
14+
path = libflat/openzeppelin-contracts
15+
url = https://github.com/OpenZeppelin/openzeppelin-contracts
16+
[submodule "libflat/permit2"]
17+
path = libflat/permit2
18+
url = https://github.com/Uniswap/permit2
19+
[submodule "libflat/v4-periphery"]
20+
path = libflat/v4-periphery
21+
url = https://github.com/uniswap/v4-periphery
22+
[submodule "libflat/v4-core"]
23+
path = libflat/v4-core
24+
url = https://github.com/uniswap/v4-core
25+
[submodule "libflat/solmate"]
26+
path = libflat/solmate
27+
url = https://github.com/rari-capital/solmate
28+
[submodule "libflat/euler-interfaces"]
29+
path = libflat/euler-interfaces
30+
url = https://github.com/euler-xyz/euler-interfaces

README.md

Lines changed: 25 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,47 @@
1-
## Foundry
1+
# Euler Devland
22

3-
**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**
3+
Devland is a framework for running a simple testing blockchain (anvil) and installing a basic instance of the Euler contracts for development and testing purposes.
44

5-
Foundry consists of:
5+
* Fast and deterministic: The entire environment can be created and installed in a second or two. This lets you setup testing/dev scenarios and instantly reset them to the starting conditions, which is helpful for development. By editing the file `script/DeployDev.sol` you can create self-contained scenarios and send them to other devs, who can get started instantly.
6+
* Lightweight: It does not use forge-style nested submodules. Instead, each project is checked out exactly once in a `libflat` directory, and then remappings are used to map depenencies for each project. This means that each repo is only checked out once, saving time and diskspace. However, it also means that only a single version of a dependency can be installed, globally.
67

7-
- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
8-
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
9-
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
10-
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.
8+
## Usage
119

12-
## Documentation
10+
### Installation
1311

14-
https://book.getfoundry.sh/
12+
First [install foundry](https://getfoundry.sh/) then run:
1513

16-
## Usage
14+
./install.sh
1715

18-
### Build
16+
### Run anvil
1917

20-
```shell
21-
$ forge build
22-
```
18+
./run.sh
2319

24-
### Test
20+
If all goes well, your RPC will be available on the standard `http://127.0.0.1:8545` endpoint.
2521

26-
```shell
27-
$ forge test
28-
```
22+
### Private keys
2923

30-
### Format
24+
The default is just to use the standard anvil mnemonic. For example this is user 0:
3125

32-
```shell
33-
$ forge fmt
34-
```
26+
* Private key: `0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80`
27+
* Address: `0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266`
3528

36-
### Gas Snapshots
29+
Import the above private key into metamask, and then change network to Foundry (chain id 31337).
3730

38-
```shell
39-
$ forge snapshot
40-
```
4131

42-
### Anvil
32+
## Extras
4333

44-
```shell
45-
$ anvil
46-
```
34+
Devland also sets up some configuration files for the dev network. They are in the same format as production for ease of integration:
4735

48-
### Deploy
36+
* `dev-ctx/EulerChains.json` - A chain manifest in the same format as [EulerChains.json](https://github.com/euler-xyz/euler-interfaces/blob/master/EulerChains.json)
37+
* `dev-ctx/labels/31337/products.json` - A `products.json` in the same format as [euler-labels](https://github.com/euler-xyz/euler-labels/blob/master/1/products.json)
38+
* `dev-ctx/addresses/31337/CoreAddresses.json` - Address files in the same format as [euler-interfaces](https://github.com/euler-xyz/euler-interfaces/blob/master/addresses/1/CoreAddresses.json)
39+
* `dev-ctx/priceapi/31337/prices.json` - A sample output from the [prices API](https://app.euler.finance/api/v1/price?chainId=1).
4940

50-
```shell
51-
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
52-
```
5341

54-
### Cast
5542

56-
```shell
57-
$ cast <subcommand>
58-
```
43+
## Deploy MaglevLens:
5944

60-
### Help
45+
For now, this repo also contains some lens code, until it can find a better home. To deploy, put a `WALLET_PRIVATE_KEY` into `.env` and then run:
6146

62-
```shell
63-
$ forge --help
64-
$ anvil --help
65-
$ cast --help
66-
```
47+
forge script ./script/DeployMaglevLens.s.sol --rpc-url $RPC_URL --broadcast --slow

chains.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
let chains = [
2+
//// PRODUCTION
3+
4+
{
5+
chainId: 31337,
6+
name: 'dev',
7+
safeBaseUrl: 'https://app.safe.global',
8+
safeAddressPrefix: 'dev',
9+
status: 'beta',
10+
},
11+
];
12+
13+
14+
15+
const fs = require("node:fs");
16+
17+
for (let c of chains) {
18+
let addrsDir = `./dev-ctx/addresses/${c.chainId}/`;
19+
20+
c.addresses = {};
21+
22+
for (const file of fs.readdirSync(addrsDir)) {
23+
if (!file.endsWith('Addresses.json')) continue;
24+
let section = file.replace(/Addresses[.]json$/, 'Addrs');
25+
section = (section[0] + '').toLowerCase() + section.substr(1);
26+
c.addresses[section] = JSON.parse(fs.readFileSync(`${addrsDir}/${file}`).toString());
27+
}
28+
}
29+
30+
fs.writeFileSync('./dev-ctx/EulerChains.json', JSON.stringify(chains));

dev-setup.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
rm -rf dev-ctx/
6+
mkdir -p dev-ctx/{addresses,labels,priceapi}/31337
7+
8+
forge script --rpc-url http://127.0.0.1:8545 script/DeployDev.sol --broadcast
9+
cast rpc evm_increaseTime 86400
10+
cast rpc evm_mine
11+
12+
node chains.js

foundry.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ src = "src"
33
out = "out"
44
libs = ["lib"]
55

6-
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
6+
auto_detect_remappings = false
7+
solc = "0.8.27"
8+
fs_permissions = [{ access = "read-write", path = "./dev-ctx/"}]

install.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
forge install
6+
git submodule update --init

libflat/ethereum-vault-connector

libflat/euler-interfaces

Submodule euler-interfaces added at 0d73b98

libflat/euler-swap

Submodule euler-swap added at bcbe14f

0 commit comments

Comments
 (0)