forked from yearn/tokenized-strategy-foundry-mix
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into runtime-fv
- Loading branch information
Showing
9 changed files
with
316 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: CI | ||
|
||
on: [push] | ||
|
||
jobs: | ||
foundry-test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
submodules: recursive | ||
- uses: foundry-rs/foundry-toolchain@v1 | ||
with: | ||
version: nightly | ||
- name: Install forge-std | ||
run: | | ||
forge install foundry-rs/forge-std --no-commit | ||
forge remappings > remappings.txt | ||
- name: Run non-Kontrol tests | ||
run: | | ||
forge test --no-match-path "src/test/kontrol/*" -vvv | ||
- name: Run snapshot without Kontrol tests | ||
run: forge snapshot --no-match-path "src/test/kontrol/*" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: "[sepolia-deploy] deploy governance for strategy" | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
proposer: | ||
description: 'Proposer address' | ||
required: true | ||
default: '0x' | ||
strategy: | ||
description: 'Strategy Address' | ||
required: true | ||
default: '0x' | ||
governorRoleAddress: | ||
description: 'Governor role address' | ||
required: true | ||
default: '0x' | ||
governorVaults: | ||
description: 'Governor vaults as comma separated' | ||
required: false | ||
default: '' | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: sepolia | ||
url: https://term-finance.github.io/yearn-v3-term-vault/ | ||
steps: | ||
- uses: actions/checkout@master | ||
with: | ||
fetch-depth: 0 | ||
submodules: recursive | ||
- uses: foundry-rs/foundry-toolchain@v1 | ||
- run: forge install | ||
- run: forge build | ||
- run: forge tree | ||
- run: forge script script/DeployGovernance.s.sol:DeployGovernance --rpc-url $RPC_URL --broadcast --gas-price 500000000000 --verify --verbosity 4 | ||
env: | ||
RPC_URL: ${{ secrets.RPC_URL }} | ||
PRIVATE_KEY: ${{ secrets.GOVERNANCE_DEPLOYER_KEY }} | ||
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }} | ||
PROPOSER: ${{ github.event.inputs.proposer }} | ||
STRATEGY: ${{ github.event.inputs.strategy }} | ||
GOVERNOR: ${{ github.event.inputs.governorRoleAddress }} | ||
VAULT_GOVERNORS: ${{ github.event.inputs.governorVaults }} | ||
GOVERNANCE_FACTORY: ${{ vars.GOVERNANCE_FACTORY }} | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: stylebot | ||
on: | ||
push: | ||
branches: | ||
- master | ||
concurrency: | ||
group: "stylebot" | ||
cancel-in-progress: true | ||
permissions: | ||
id-token: write | ||
contents: write | ||
packages: write | ||
pull-requests: write | ||
jobs: | ||
fix: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/create-github-app-token@v1 | ||
id: app-token | ||
with: | ||
app-id: ${{ secrets.STYLEBOT_GITHUB_APP_ID }} | ||
private-key: ${{ secrets.STYLEBOT_GITHUB_APP_KEY }} | ||
- uses: actions/checkout@master | ||
- id: nodeversion | ||
run: echo "version=$(grep nodejs .tool-versions | sed -e 's/[^[:space:]]*[[:space:]]*//')" >> $GITHUB_OUTPUT | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ steps.nodeversion.outputs.version }} | ||
cache: yarn | ||
- run: yarn install --immutable | ||
# Run fixes, save stdout. | ||
- run: | | ||
echo 'ESLINT_RESULTS<<EOF' >> ${GITHUB_ENV} | ||
yarn fix:eslint >> ${GITHUB_ENV} || true | ||
echo 'EOF' >> ${GITHUB_ENV} | ||
- run: | | ||
echo 'PRETTIER_RESULTS<<EOF' >> ${GITHUB_ENV} | ||
yarn fix:prettier >> ${GITHUB_ENV} | ||
echo 'EOF' >> ${GITHUB_ENV} | ||
- run: git restore .yarn .yarnrc.yml | ||
# Make PR from local changes. | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v7 | ||
with: | ||
token: ${{ steps.app-token.outputs.token }} | ||
commit-message: "[stylebot] Fixes for code style" | ||
branch: stylebot/patch | ||
title: "[stylebot] Fixes for code style" | ||
body: | | ||
Stylebot detected automatically fix-able code style issues. | ||
<details><summary>`yarn fix:eslint`</summary> | ||
``` | ||
${{ env.ESLINT_RESULTS }} | ||
``` | ||
</details> | ||
<details><summary>`yarn fix:prettier`</summary> | ||
``` | ||
${{ env.PRETTIER_RESULTS }} | ||
``` | ||
</details> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
[profile.default] | ||
evm_version = 'shanghai' | ||
src = 'src' | ||
out = 'out' | ||
libs = ['lib'] | ||
|
Submodule forge-std
updated
44 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.18; | ||
import "forge-std/Script.sol"; | ||
import "../src/Strategy.sol"; | ||
|
||
interface TermVaultGovernanceFactory { | ||
function deploySafe( | ||
address proposer, | ||
address strategy, | ||
address governor, | ||
address[] calldata vaultGovernors | ||
) external; | ||
} | ||
|
||
contract DeployGovernance is Script { | ||
/** | ||
* @dev Converts a comma-separated string of addresses to an array of addresses. | ||
* @param _input A string containing comma-separated addresses. | ||
* @return addressArray An array of addresses parsed from the input string. | ||
*/ | ||
function stringToAddressArray(string memory _input) public pure returns (address[] memory) { | ||
// Check if the input string is empty | ||
if (bytes(_input).length == 0) { | ||
return new address[](0); | ||
} | ||
// Step 1: Split the input string by commas | ||
string[] memory parts = splitString(_input, ","); | ||
|
||
// Step 2: Convert each part to an address | ||
address[] memory addressArray = new address[](parts.length); | ||
for (uint256 i = 0; i < parts.length; i++) { | ||
addressArray[i] = parseAddress(parts[i]); | ||
} | ||
|
||
return addressArray; | ||
} | ||
|
||
|
||
/** | ||
* @dev Helper function to split a string by a delimiter | ||
* @param _str The input string | ||
* @param _delimiter The delimiter to split by | ||
* @return An array of substrings | ||
*/ | ||
function splitString(string memory _str, string memory _delimiter) internal pure returns (string[] memory) { | ||
bytes memory strBytes = bytes(_str); | ||
bytes memory delimiterBytes = bytes(_delimiter); | ||
uint256 partsCount = 1; | ||
|
||
// Count the parts to split the string | ||
for (uint256 i = 0; i < strBytes.length - 1; i++) { | ||
if (strBytes[i] == delimiterBytes[0]) { | ||
partsCount++; | ||
} | ||
} | ||
|
||
string[] memory parts = new string[](partsCount); | ||
uint256 partIndex = 0; | ||
bytes memory part; | ||
|
||
for (uint256 i = 0; i < strBytes.length; i++) { | ||
if (strBytes[i] == delimiterBytes[0]) { | ||
parts[partIndex] = string(part); | ||
part = ""; | ||
partIndex++; | ||
} else { | ||
part = abi.encodePacked(part, strBytes[i]); | ||
} | ||
} | ||
|
||
// Add the last part | ||
parts[partIndex] = string(part); | ||
|
||
return parts; | ||
} | ||
|
||
/** | ||
* @dev Helper function to parse a string and convert it to an address | ||
* @param _str The string representation of an address | ||
* @return The address parsed from the input string | ||
*/ | ||
function parseAddress(string memory _str) internal pure returns (address) { | ||
bytes memory tmp = bytes(_str); | ||
require(tmp.length == 42, "Invalid address length"); // Must be 42 characters long (0x + 40 hex chars) | ||
|
||
uint160 addr = 0; | ||
for (uint256 i = 2; i < 42; i++) { | ||
uint160 b = uint160(uint8(tmp[i])); | ||
|
||
if (b >= 48 && b <= 57) { // 0-9 | ||
addr = addr * 16 + (b - 48); | ||
} else if (b >= 65 && b <= 70) { // A-F | ||
addr = addr * 16 + (b - 55); | ||
} else if (b >= 97 && b <= 102) { // a-f | ||
addr = addr * 16 + (b - 87); | ||
} else { | ||
revert("Invalid address character"); | ||
} | ||
} | ||
|
||
return address(addr); | ||
} | ||
|
||
function run() external { | ||
uint256 deployerPK = vm.envUint("PRIVATE_KEY"); | ||
|
||
// Set up the RPC URL (optional if you're using the default foundry config) | ||
string memory rpcUrl = vm.envString("RPC_URL"); | ||
|
||
vm.startBroadcast(deployerPK); | ||
|
||
TermVaultGovernanceFactory factory = TermVaultGovernanceFactory(vm.envAddress("GOVERNANCE_FACTORY")); | ||
address proposer = vm.envAddress("PROPOSER"); | ||
address strategy = vm.envAddress("STRATEGY"); | ||
address governor = vm.envAddress("GOVERNOR"); | ||
address[] memory vaultGovernors = stringToAddressArray(vm.envString("VAULT_GOVERNORS")); | ||
|
||
factory.deploySafe(proposer, strategy, governor, vaultGovernors); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
|
||
} |
Oops, something went wrong.