Skip to content

Commit

Permalink
outline process for creating and interacting with pool
Browse files Browse the repository at this point in the history
  • Loading branch information
MattPereira committed Mar 18, 2024
1 parent 90c8a79 commit ee5ddc0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
29 changes: 20 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

A series of guides and a prototyping tools for creating custom pools that integrate with Balancer v3

## Decision Records

- Using SE-2 hardhat with added `hardhat-foundry` plugin
- devs can choose preference of deploying / testing with hardhat or foundry
- balancer will release npm packages for their v3 contracts

## Requirements

Before you begin, you need to install the following tools:
Expand All @@ -18,7 +12,7 @@ Before you begin, you need to install the following tools:

## Quickstart

1. Clone the repo (with SSH since private for now)
1. Clone the repo

```
git clone git@github.com:MattPereira/scaffold-balancer-v3.git
Expand All @@ -38,10 +32,27 @@ yarn start

## Deploying Contracts

1. Set a `DEPLOYER_PRIVATE_KEY` in a `.env` at path `packagages/hardhat/.env`. Only do this with a develpment specific wallet that has only testnet funds. **NEVER PUT REAL FUNDS AT RISK WITH A PLAIN TEXT PRIVATE KEY**
1. Set a `DEPLOYER_PRIVATE_KEY` in a `.env` at path `packagages/hardhat/.env`

2. Run the deploy script. Note that whenever you deploy new contract the frontend will automatically be updated to point at the newly deployed contract
2. Run the deploy script\*

```
yarn deploy --network sepolia
```

\*Whenever you deploy new contract the frontend will automatically update to point at the newly deployed contract

## How To Create Custom Pool

1. Deploy a contract that inherits from `IBasePool` and `BalancerPoolToken` and impliments the three required functions: `onSwap`, `computeInvariant`, and `computeBalance`
- [See docs on creating custom pool](https://docs-v3.balancer.fi/concepts/guides/create-custom-amm-with-novel-invariant.html#build-your-custom-amm)
2. Register the pool with the `Vault` by calling `VaultExtension.registerPool` with the necessary arguments
3. Initialize the pool with the `Vault` by calling `Router.initialize` with the necessary arguments
- [See docs on`Router.initialize`](https://docs-v3.balancer.fi/concepts/router/overview.html#initialize)

## How To Interact With A Custom Pool

- The `Router` is the recommended entrypoint for all user operations
- [See Router Technical Description](https://docs-v3.balancer.fi/concepts/router/technical.html)
- The `Router` provides functions for querying and executing `swap`, `add`, and `remove`
- [See Router API](https://docs-v3.balancer.fi/concepts/router/overview.html)
8 changes: 3 additions & 5 deletions packages/nextjs/app/pools/_components/PoolActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@ export const PoolActions = () => {
<h5 className="text-2xl font-bold mb-3">Actions</h5>

<div className="w-full bg-base-200 rounded-xl">
<div className="flex border-b border-accent">
<div className="flex border-b-2 border-base-300">
{Object.keys(tabs).map(tab => (
<button
key={tab}
onClick={() => setActiveTab(tab as Action)}
className={`py-3 flex-1 ${
activeTab === tab
? "bg-base-100 rounded-tl-lg rounded-tr-lg font-bold"
: "border-b-4 border-transparent"
className={`py-3 flex-1 hover:font-bold ${
activeTab === tab ? "bg-base-100 rounded-tl-lg rounded-tr-lg" : ""
} focus:outline-none`}
>
{tab}
Expand Down

0 comments on commit ee5ddc0

Please sign in to comment.