Skip to content

Commit

Permalink
Merge master into transmission branch (#1162)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brean0 authored Oct 26, 2024
2 parents 0aa27e6 + b7562a2 commit a83210c
Show file tree
Hide file tree
Showing 1,194 changed files with 594,643 additions and 211,617 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/ci.protocol.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: Protocol

on:
pull_request:
types: [opened, synchronize]
Expand Down Expand Up @@ -31,22 +30,38 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Protocol Tests
uses: actions/setup-node@v3
with:
node-version: "18"

- name: Cache Node Modules
id: node-modules-cache
uses: actions/cache@v3
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: Install Dependencies
if: steps.node-modules-cache.outputs.cache-hit != 'true'
run: yarn install --immutable
- run: yarn generate
working-directory: protocol
- run: yarn test

- name: Clear cache and reinstall on generate failure
if: steps.generate-with-cache.outcome == 'failure' && steps.node-modules-cache.outputs.cache-hit == 'true'
run: |
rm -rf **/node_modules
yarn install --no-immutable
- name: Generate (after potential cache clear)
if: steps.generate-with-cache.outcome == 'failure'
run: yarn generate
working-directory: protocol

- name: Run tests
run: yarn test
env:
FORKING_RPC: ${{ secrets.ANVIL_FORK_URL }}
working-directory: protocol
2 changes: 1 addition & 1 deletion .github/workflows/ci.subgraph-basin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
run: echo "There are uncommitted changes - execute 'yarn codegen' locally and commit the generated files!"

- name: Build Subgraph
run: yarn build
run: yarn build -- ethereum
working-directory: projects/subgraph-basin
test:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.subgraph-bean.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
run: echo "There are uncommitted changes - execute 'yarn codegen' locally and commit the generated files!"

- name: Build Subgraph
run: yarn build
run: yarn build -- ethereum
working-directory: projects/subgraph-bean
test:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.subgraph-beanft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
run: echo "There are uncommitted changes - execute 'yarn codegen' locally and commit the generated files!"

- name: Build Subgraph
run: yarn build
run: yarn build -- ethereum
working-directory: projects/subgraph-beanft
test:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.subgraph-beanstalk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
run: echo "There are uncommitted changes - execute 'yarn codegen' locally and commit the generated files!"

- name: Build Subgraph
run: yarn build
run: yarn build -- ethereum
working-directory: projects/subgraph-beanstalk
test:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
exit 1
fi
# Check if the subgraph is a valid selection
if [[ "${{ github.event.inputs.subgraph }}" != "beanstalk" && "${{ github.event.inputs.subgraph }}" != "bean" && "${{ github.event.inputs.subgraph }}" != "basin" && "${{ github.event.inputs.subgraph }}" != "beanft" ]]; then
if [[ ! "${{ github.event.inputs.subgraph }}" =~ ^(beanstalk|bean|basin|beanft) ]]; then
echo "Error: Subgraph must be one of 'beanstalk', 'bean', 'basin', 'beanft'."
exit 1
fi
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,18 @@
"sdk:prettier": "yarn prettier projects/sdk -w",
"sdk:publish": "yarn workspace @beanstalk/sdk publish",
"sdk:version": "yarn workspace @beanstalk/sdk version",
"dex-ui:dev": "yarn workspace dex-ui dev",
"dex-ui:build": "yarn workspace dex-ui build",
"dex-ui:generate": "yarn workspace dex-ui generate",
"ui:generate": "yarn workspace ui generate",
"ui:dev": "yarn workspace ui dev",
"ui:start": "yarn workspace ui start",
"ui:build": "yarn workspace ui build",
"ui:test": "yarn workspace ui test",
"test:browser": "yarn workspace tests test:browser",
"ex": "yarn workspace @beanstalk/examples x",
"anvil-arbitrum": "yarn cli:anvil-arbitrum",
"anvil-eth-mainnet": "yarn cli:anvil-eth-mainnet",
"anvil": "anvil --fork-url https://eth-mainnet.g.alchemy.com/v2/5ubn94zT7v7DnB5bNW1VOnoIbX5-AG2N --chain-id 1337",
"anvil4tests": "anvil --fork-url https://eth-mainnet.g.alchemy.com/v2/Kk7ktCQL5wz4v4AG8bR2Gun8TAASQ-qi --chain-id 1337 --fork-block-number 18629000"
},
Expand Down
5 changes: 5 additions & 0 deletions projects/cli/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# DEV API key
DEV_ALCHEMY_API_KEY=""

# Test API key
DEV_TEST_ALCHEMY_API_KEY=""
2 changes: 2 additions & 0 deletions projects/cli/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules
build

.env
48 changes: 48 additions & 0 deletions projects/cli/anvil.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

source .env

# Set variables based on arguments
keyType="$1"
chainIdType="$2"

# Set chain IDs
mainnet_local_chain_id=1338

arbitrum_local_chain_id=1337

# Determine which API key to use
if [ "$keyType" = "test" ]; then
apiKey="$DEV_TEST_ALCHEMY_API_KEY"
else
apiKey="$DEV_ALCHEMY_API_KEY"
fi

# Determine which chain ID to use. Defaults to arbitrum local host
if [ "$chainIdType" = "eth-mainnet" ]; then
chainId=$mainnet_local_chain_id
prefix="eth"
port=9545
else
chainId=$arbitrum_local_chain_id
prefix="arb"
port=8545
fi

# Check if required variables are set
if [ -z "$prefix" ] || [ -z "$apiKey" ] || [ -z "$chainId" ]; then
echo "Error: Missing required variables. Please set keyType and chainIdType."
exit 1
fi

anvil \
--fork-url "https://$prefix-mainnet.g.alchemy.com/v2/$apiKey" \
--chain-id "$chainId" \
--port "$port" \
"${@:3}"

# Check if Anvil exited with an error
if [ $? -ne 0 ]; then
echo "Error: Anvil exited with a non-zero status."
exit 1
fi
8 changes: 6 additions & 2 deletions projects/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@beanstalk/cli",
"version": "0.0.10",
"version": "0.0.20",
"description": "Beanstalk protocol development cli tool",
"license": "MIT",
"repository": {
Expand All @@ -16,7 +16,11 @@
"scripts": {
"cli:publish": "yarn cli:build && yarn npm publish --access public",
"cli:build": "rimraf build && tsc && chmod u+x build/cli.js",
"g:bean": "yarn ts-node-esm src/cli.ts"
"g:bean": "yarn ts-node-esm src/cli.ts",
"cli:anvil-eth-mainnet": "bash anvil.sh dev eth-mainnet",
"cli:anvil-arbitrum": "bash anvil.sh dev arbitrum-mainnet",
"cli:anvil4tests-mainnet": "bash anvil.sh test eth-mainnet --fork-block-number 18629000",
"cli:anvil4tests-arbitrum": "bash anvil.sh test arbitrum-mainnet --fork-block-number 18629000"
},
"devDependencies": {
"@types/command-line-args": "^5.2.3",
Expand Down
37 changes: 27 additions & 10 deletions projects/cli/src/commands/balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { table } from "table";

export const balance = async (sdk, { account, symbol }) => {
console.log(`${chalk.bold.whiteBright("Account:")} ${chalk.greenBright(account)}`);
let res = [[chalk.bold("Token"), chalk.bold("Internal"), chalk.bold("External"), chalk.bold("Total")]];
let res = [
[chalk.bold("Token"), chalk.bold("Internal"), chalk.bold("External"), chalk.bold("Total")]
];

if (symbol) {
res.push(await getBal(sdk, symbol, account));
Expand All @@ -12,16 +14,21 @@ export const balance = async (sdk, { account, symbol }) => {
[
"ETH",
"WETH",
"WSTETH",
"WEETH",
"WBTC",
"BEAN",
"USDT",
"USDC",
"DAI",
"CRV3",
"UNRIPE_BEAN",
"UNRIPE_BEAN_WETH",
"BEAN_CRV3_LP",
"BEAN_ETH_WELL_LP",
"ROOT"
"USDC",
"USDT",
"urBEAN",
"urBEANWSTETH",
"BEANWETH",
"BEANWEETH",
"BEANWEETH",
"BEANWBTC",
"BEANUSDC",
"BEANUSDT"
].map((s) => getBal(sdk, s, account))
);
res.push(...bals);
Expand All @@ -30,7 +37,17 @@ export const balance = async (sdk, { account, symbol }) => {
};

async function getBal(sdk, symbol: string, account: string) {
const token = sdk.tokens[symbol];
let token = sdk.tokens[symbol];
if (!token) {
if (symbol === "urBEAN") token = sdk.tokens.UNRIPE_BEAN;
if (symbol === "urBEANWSTETH") token = sdk.tokens.UNRIPE_BEAN_WSTETH;
if (symbol === "BEANWETH") token = sdk.tokens.BEAN_ETH_WELL_LP;
if (symbol === "BEANWEETH") token = sdk.tokens.BEAN_WEETH_WELL_LP;
if (symbol === "BEANWSTETH") token = sdk.tokens.BEAN_WSTETH_WELL_LP;
if (symbol === "BEANWBTC") token = sdk.tokens.BEAN_WBTC_WELL_LP;
if (symbol === "BEANUSDC") token = sdk.tokens.BEAN_USDC_WELL_LP;
if (symbol === "BEANUSDT") token = sdk.tokens.BEAN_USDT_WELL_LP;
}
if (!token) throw new Error(`No token found: ${symbol}`);

try {
Expand Down
38 changes: 32 additions & 6 deletions projects/cli/src/commands/setbalance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,43 @@ export const setbalance = async (sdk, chain, { account, symbol, amount }) => {
if (!symbol) {
await chain.setAllBalances(account, amount);
} else {
const symbols = ["ETH", "WETH", "BEAN", "USDT", "USDC", "DAI", "CRV3", "BEAN3CRV", "BEANWETH", "urBEAN", "urBEANWETH", "ROOT"];
const symbols = [
"ETH",
"WETH",
"WSTETH",
"WEETH",
"WBTC",
"BEAN",
"DAI",
"USDC",
"USDT",
"urBEAN",
"urBEANWSTETH",
"BEANWETH",
"BEANWSTETH",
"BEANWEETH",
"BEANWBTC",
"BEANUSDC",
"BEANUSDT"
];
if (!symbols.includes(symbol)) {
console.log(`${chalk.bold.red("Error")} - ${chalk.bold.white(symbol)} is not a valid token. Valid options are: `);
console.log(
`${chalk.bold.red("Error")} - ${chalk.bold.white(symbol)} is not a valid token. Valid options are: `
);
console.log(symbols.map((s) => chalk.green(s)).join(", "));
process.exit(-1);
}
let t = sdk.tokens[symbol] as Token;
if (symbol === "urBEAN") t = sdk.tokens.UNRIPE_BEAN;
if (symbol === "urBEANWETH") t = sdk.tokens.UNRIPE_BEAN_WETH;
if (symbol === "BEAN3CRV") t = sdk.tokens.BEAN_CRV3_LP;
if (symbol === "BEANWETH") t = sdk.tokens.BEAN_ETH_WELL_LP;
if (!t) {
if (symbol === "urBEAN") t = sdk.tokens.UNRIPE_BEAN;
if (symbol === "urBEANWSTETH") t = sdk.tokens.UNRIPE_BEAN_WSTETH;
if (symbol === "BEANWETH") t = sdk.tokens.BEAN_ETH_WELL_LP;
if (symbol === "BEANWEETH") t = sdk.tokens.BEAN_WEETH_WELL_LP;
if (symbol === "BEANWSTETH") t = sdk.tokens.BEAN_WSTETH_WELL_LP;
if (symbol === "BEANWBTC") t = sdk.tokens.BEAN_WBTC_WELL_LP;
if (symbol === "BEANUSDC") t = sdk.tokens.BEAN_USDC_WELL_LP;
if (symbol === "BEANUSDT") t = sdk.tokens.BEAN_USDT_WELL_LP;
}
if (typeof chain[`set${symbol}Balance`] !== "function")
throw new Error(`${symbol} is not a valid token or the method ${chalk.bold.whiteBright("")}`);

Expand Down
14 changes: 7 additions & 7 deletions projects/cli/src/commands/setprice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ export const setPrice = async (sdk: BeanstalkSDK, chain: TestUtils.BlockchainUti
console.log(beanInput, crv3Input);

const newBeanAmount = (beanInput ? beanInput : 20) * 1_000_000;
const newCrv3Amount = (crv3Input ? crv3Input : beanInput ? beanInput : 20) * 1_000_000;
// const newCrv3Amount = (crv3Input ? crv3Input : beanInput ? beanInput : 20) * 1_000_000;

const newBean = sdk.tokens.BEAN.amount(newBeanAmount);
const newCrv3 = sdk.tokens.CRV3.amount(newCrv3Amount);
// const newBean = sdk.tokens.BEAN.amount(newBeanAmount);
// const newCrv3 = sdk.tokens.CRV3.amount(newCrv3Amount);

////// Set the new balance
console.log(`New Balances: ${newBean.toHuman()} ${newCrv3.toHuman()}`);
// console.log(`New Balances: ${newBean.toHuman()} ${newCrv3.toHuman()}`);
// update the array tracking balances
await setBalance(sdk, POOL_ADDRESS, BALANCE_SLOT, newBean, newCrv3);
// await setBalance(sdk, POOL_ADDRESS, BALANCE_SLOT, newBean, newCrv3);
// actually give the pool the ERC20's
await chain.setBEANBalance(POOL_ADDRESS, newBean);
await chain.setCRV3Balance(POOL_ADDRESS, newCrv3);
// await chain.setBEANBalance(POOL_ADDRESS, newBean);
// await chain.setCRV3Balance(POOL_ADDRESS, newCrv3);

// Curve also keeps track of the previous balance, so we just copy the existing current to old.
await setBalance(sdk, POOL_ADDRESS, PREV_BALANCE_SLOT, currentBean, currentCrv3);
Expand Down
5 changes: 4 additions & 1 deletion projects/cli/src/commands/sunrise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const sunrise = async (sdk, chain, { force }) => {
}

await callSunrise(sdk);
await sdk.provider.send("evm_mine", []);

if (diff > 1) {
console.log(`You are still behind by ${diff - 1} seasons. May need to call it again.`);
Expand All @@ -27,7 +28,9 @@ async function callSunrise(sdk: BeanstalkSDK) {
const res = await sdk.contracts.beanstalk.sunrise();
await res.wait();
const season = await sdk.contracts.beanstalk.season();
console.log(`${chalk.bold.greenBright("sunrise()")} called. New season is ${chalk.bold.yellowBright(season)}`);
console.log(
`${chalk.bold.greenBright("sunrise()")} called. New season is ${chalk.bold.yellowBright(season)}`
);
} catch (err: any) {
console.log(`sunrise() call failed: ${err.reason}`);
}
Expand Down
8 changes: 5 additions & 3 deletions projects/dex-ui/.env.local.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
VITE_AQUIFER_ADDRESS=local/fork deployed address
VITE_AQUIFER_ADDRESS_ETH="deployed address here"
VITE_AQUIFER_ADDRESS_ARBITRUM="deployed address here"
VITE_ALCHEMY_API_KEY="your key here"
VITE_THEGRAPH_API_KEY="your key here"
VITE_WALLETCONNECT_PROJECT_ID="project key here"
VITE_WELLS_ORIGIN_BLOCK=17138465
VITE_LOAD_HISTORY_FROM_GRAPH=0
VITE_WALLET_CONNECT_PROJECT_ID="project key here"
VITE_LOAD_HISTORY_FROM_GRAPH=0
7 changes: 6 additions & 1 deletion projects/dex-ui/.env.production
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
// DO NOT ACTUALLY SAVE THINGS HERE
// ONLY USE THIS FILE TO TRACK WHAT ENV VARS NEED TO
// BE ADDED TO NETLIFY CONFIG
VITE_AQUIFER_ADDRESS_ETH=""
VITE_AQUIFER_ADDRESS_ARBITRUM=""
VITE_ALCHEMY_API_KEY=""
VITE_WALLET_CONNECT_PROJECT_ID=""
VITE_THEGRAPH_API_KEY=""
VITE_WALLETCONNECT_PROJECT_ID=""
VITE_WELLS_ORIGIN_BLOCK=""
VITE_LOAD_HISTORY_FROM_GRAPH=""
Loading

0 comments on commit a83210c

Please sign in to comment.