Skip to content

Commit

Permalink
router deployment (#16)
Browse files Browse the repository at this point in the history
* router deployment

* adding readme and logo
  • Loading branch information
sogipec authored Nov 25, 2022
1 parent fcb7c7e commit a0251ba
Show file tree
Hide file tree
Showing 16 changed files with 4,735 additions and 8 deletions.
96 changes: 94 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,95 @@
# Router
# <img src="logo.svg" alt="Angle Router Contracts" height="40px"> Angle Router Contracts

Router to interact with all Angle modules
[![CI](https://github.com/AngleProtocol/angle-router/workflows/CI/badge.svg)](https://github.com/AngleProtocol/angle-router/actions?query=workflow%3ACI)

## Documentation

This repository contains router contracts for the Angle Protocol. These contracts are designed to facilitate the composition of actions on top of Angle and other protocols in a single transaction.

There is one router contract per chain on which the protocol is natively deployed with a very similar implementation each time.

Across all chains, router contracts implementations rely on a **mixer()** function that can be called with a set of instructions, including the different actions it can perform and their parameters.

Instructions can range from transferring funds to another address, performing a swap on 1Inch, opening a perpetual, depositing in an ERC4626 contract, wrapping the native token of a chain (e.g ETH to wETH), ...

Some actions are possible on some chains but not on others, and we recommend to look at the implementation of the contract to view what kind of actions are supported.

The list of all potentially available actions is defined in the `ActionType` enum.

## Setup

### Install packages

You can install all dependencies by running

```bash
yarn
forge i
```

### Create `.env` file

In order to interact with non local networks, you must create an `.env` that has:

- `MNEMONIC`
- network key
- `ETHERSCAN_API_KEY`

For additional keys, you can check the `.env.example` file.

Warning: always keep your confidential information safe.

### Tests

Contracts in this repo rely on Hardhat tests. You can run tests as follows:

```bash
yarn hardhat:test ./test/hardhat/router/baseRouter.test.ts
```

You can also check the coverage of the tests with:

```bash
yarn hardhat:coverage
```

### Coverage

```bash
yarn hardhat:coverage
```

### Deploying

```bash
yarn deploy mainnet
```

Make sure to change the tag corresponding to the file you're deploying, and to adapt the `CoreBorrow`, `Treasury` and `ProxyAdmin` to your use case.

## Foundry Installation

```bash
curl -L https://foundry.paradigm.xyz | bash

source /root/.zshrc
# or, if you're under bash: source /root/.bashrc

foundryup
```

To install the standard library:

```bash
forge install foundry-rs/forge-std
```

To update libraries:

```bash
forge update
```

## Media

Don't hesitate to reach out on [Twitter](https://twitter.com/AngleProtocol) 🐦
12 changes: 6 additions & 6 deletions deploy/routerSidechain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const func: DeployFunction = async ({ ethers, deployments, network }) => {
chainId = ChainId.POLYGON;
chainName = 'Polygon';
} else {
chainId = ChainId.POLYGON;
chainId = ChainId.ARBITRUM;
chainName = network.name.charAt(0).toUpperCase() + network.name.substring(1);
}
const proxyAdmin = registry(chainId)?.ProxyAdminGuardian;
Expand All @@ -28,28 +28,28 @@ const func: DeployFunction = async ({ ethers, deployments, network }) => {
const contractName = `AngleRouter${chainName}`;

console.log('Now deploying the implementation');
await deploy(`${contractName}_Implementation`, {
await deploy(`${contractName}V2_Implementation`, {
contract: contractName,
from: deployer.address,
log: !argv.ci,
});

const routerImplementation = (await ethers.getContract(`${contractName}_Implementation`)).address;
const routerImplementation = (await ethers.getContract(`${contractName}V2_Implementation`)).address;
console.log(`Successfully deployed the implementation for the router at ${routerImplementation}`);
console.log('Now deploying the proxy contract');
const dataRouter = new ethers.Contract(
routerImplementation,
AngleRouterPolygon__factory.createInterface(),
).interface.encodeFunctionData('initializeRouter', [coreBorrow, json.uniswapV3Router, json.oneInchRouter]);

await deploy(`${contractName}`, {
await deploy(`${contractName}V2`, {
contract: 'TransparentUpgradeableProxy',
from: deployer.address,
args: [routerImplementation, proxyAdmin, dataRouter],
log: !argv.ci,
});
const router = (await deployments.get(`${contractName}`)).address;
console.log(`Successfully deployed ${contractName} at the address ${router}`);
const router = (await deployments.get(`${contractName}V2`)).address;
console.log(`Successfully deployed ${contractName}V2 at the address ${router}`);

console.log(`${router} ${routerImplementation} ${proxyAdmin} ${dataRouter}`);
console.log('');
Expand Down
247 changes: 247 additions & 0 deletions deployments/arbitrum/AngleRouterArbitrumV2.json

Large diffs are not rendered by default.

Loading

0 comments on commit a0251ba

Please sign in to comment.