Skip to content

Commit

Permalink
Merge pull request #463 from morpho-org/chore/remove-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
MathisGD authored Nov 5, 2024
2 parents 17025b3 + c1597d9 commit 1361511
Show file tree
Hide file tree
Showing 48 changed files with 70 additions and 6,726 deletions.
15 changes: 0 additions & 15 deletions .github/actions/build-hardhat/action.yml

This file was deleted.

10 changes: 0 additions & 10 deletions .github/actions/install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,5 @@ runs:
using: composite

steps:
- name: Install node
uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Install dependencies
run: yarn install --frozen-lockfile
shell: bash
8 changes: 4 additions & 4 deletions .github/workflows/foundry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Build contracts via IR & check sizes
# don't use compilation cache
# skip import files, because we don't care if contracts are too big
run: yarn build:forge --force --sizes --skip Import
run: yarn build --force --sizes --skip Import


build-no-ir:
Expand All @@ -58,7 +58,7 @@ jobs:
- uses: ./.github/actions/install-cache

- name: Build contracts without IR
run: yarn build:forge
run: yarn build
env:
FOUNDRY_PROFILE: test

Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:
- uses: ./.github/actions/install-cache

- name: Run local tests on chain ${{ matrix.chain }} in ${{ matrix.type }} mode
run: yarn test:forge:local
run: yarn test:local
env:
FOUNDRY_FUZZ_RUNS: ${{ matrix.fuzz-runs }}
FOUNDRY_FUZZ_MAX_TEST_REJECTS: ${{ matrix.max-test-rejects }}
Expand Down Expand Up @@ -147,7 +147,7 @@ jobs:
- uses: ./.github/actions/install-cache

- name: Run fork tests on chain ${{ matrix.chain }} in ${{ matrix.type }} mode
run: yarn test:forge:fork --chain ${{ matrix.chain }}
run: yarn test:fork --chain ${{ matrix.chain }}
env:
ALCHEMY_KEY: ${{ secrets.ALCHEMY_KEY }}
FOUNDRY_FUZZ_RUNS: ${{ matrix.fuzz-runs }}
Expand Down
38 changes: 0 additions & 38 deletions .github/workflows/hardhat.yml

This file was deleted.

28 changes: 0 additions & 28 deletions .github/workflows/npm-release.yml

This file was deleted.

9 changes: 0 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Compiler files
cache/
out/
dist/

# Ignores development broadcast logs
!/broadcast
Expand All @@ -21,14 +20,6 @@ docs/
data/
broadcast/

# Node.js
node_modules/

# Hardhat
/types
/cache_hardhat
/artifacts

*.log

# Certora
Expand Down
5 changes: 0 additions & 5 deletions .husky/post-checkout

This file was deleted.

5 changes: 0 additions & 5 deletions .husky/post-merge

This file was deleted.

2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
yarn lint
4 changes: 0 additions & 4 deletions .husky/prepare-commit-msg

This file was deleted.

133 changes: 6 additions & 127 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,137 +12,11 @@ Some chain-specific domains are also scoped to the chain-specific folder, becaus

User-end bundlers are provided in each chain-specific folder, instantiating all the intermediary domain-specific bundlers and associated parameters (such as chain-specific protocol addresses, e.g. [`EthereumBundlerV2`](./src/ethereum/EthereumBundlerV2.sol)).

## Deployments

- [EthereumBundler](https://github.com/morpho-org/morpho-blue-bundlers/releases/tag/v1.0.0)
- [EthereumBundlerV2](https://github.com/morpho-org/morpho-blue-bundlers/releases/tag/v1.2.0)
- (TODO) AgnosticBundlerV2 on Base

## Getting Started

### Package installation

```bash
npm install @morpho-org/morpho-blue-bundlers
```

```bash
yarn add @morpho-org/morpho-blue-bundlers
```

### Usage

Bundle a collateral supply and a borrow:

```typescript
import { BundlerAction } from "@morpho-org/morpho-blue-bundlers";

const collateral = 1_000000000000000000n;
const borrowedAssets = 1000_000000n;

const borrower = "0x...";
const marketParams = {
collateralToken: "0x...",
loanToken: "0x...",
irm: "0x...",
oracle: "0x...",
lltv: 86_0000000000000000n,
};

await bundler
.connect(supplier)
.multicall([
BundlerAction.transferFrom(marketParams.collateralToken, collateral),
BundlerAction.morphoSupplyCollateral(marketParams, collateral, borrower, "0x"),
BundlerAction.morphoBorrow(marketParams, borrowedAssets, 0n, borrower, borrower),
]);
```

Bundle a permit2 signature approval and a ERC-4626 deposit:

```typescript
import { Signature } from "ethers";

import { BundlerAction } from "@morpho-org/morpho-blue-bundlers";

const permit2Address = "0x000000000022D473030F116dDEE9F6B43aC78BA3";

const permit2Config = {
domain: {
name: "Permit2",
chainId: "0x1",
verifyingContract: permit2Address,
},
types: {
PermitSingle: [
{
name: "details",
type: "PermitDetails",
},
{
name: "spender",
type: "address",
},
{
name: "sigDeadline",
type: "uint256",
},
],
PermitDetails: [
{
name: "token",
type: "address",
},
{
name: "amount",
type: "uint160",
},
{
name: "expiration",
type: "uint48",
},
{
name: "nonce",
type: "uint48",
},
],
},
};

const assetAddress = "0x...";
const assets = 1000_000000n;

const supplier = "0x...";
const bundlerAddress = "0x...";
const permitSingle = {
details: {
token: assetAddress,
amount: assets,
nonce: 0n,
expiration: 2n ** 48n - 1,
},
spender: bundlerAddress,
sigDeadline: 2n ** 48n - 1,
};

await bundler
.connect(supplier)
.multicall([
BundlerAction.approve2(
permitSingle,
Signature.from(await supplier.signTypedData(permit2Config.domain, permit2Config.types, permitSingle)),
false,
),
BundlerAction.transferFrom2(assetAddress, assets),
BundlerAction.erc4626Deposit(erc4626Address, assets, 0, supplier),
]);
```

## Development

Install dependencies with `yarn`.

Run tests with `yarn test:forge --chain <chainid>` (chainid can be 1 or 8453).
Run tests with `yarn test --chain <chainid>` (chainid can be 1 or 8453).

Note that the `EthereumBundlerV2` has been deployed with 80 000 optimizer runs.
To compile contracts with the same configuration, run `FOUNDRY_PROFILE=ethereumBundlerV2 forge b`.
Expand All @@ -154,3 +28,8 @@ All audits are stored in the [audits](./audits/)' folder.
## License

Bundlers are licensed under `GPL-2.0-or-later`, see [`LICENSE`](./LICENSE).

## Links

- [Deployments](https://docs.morpho.org/bundlers/addresses/#bundlers)
- [SDK](https://github.com/morpho-org/sdks/tree/main/packages/bundler-sdk-ethers)
2 changes: 0 additions & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
[profile.default]
names = true
sizes = true
src = "src"
test = "test/forge"
fs_permissions = [
{ access = "read", path = "./out/"},
{ access = "read", path = "./config/"}
Expand Down
Loading

0 comments on commit 1361511

Please sign in to comment.