Skip to content

Commit

Permalink
init repo
Browse files Browse the repository at this point in the history
  • Loading branch information
0xLightt committed Sep 4, 2024
1 parent 47c0b2f commit d08d82d
Show file tree
Hide file tree
Showing 310 changed files with 37,951 additions and 54 deletions.
9 changes: 9 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#DO NOT SHARE THIS FILE WITH ANYONE - MAKE SURE TO ADD IT TO YOUR .GITIGNORE FILE

# FORK_TEST_ADDRESSES

UNISWAP_V3_FACTORY_ADDRESS = 0x1F98431c8aD98523631AE4a59f267346ea31F984
UNISWAP_V3_SWAP_ROUTER_ADDRESS = 0xE592427A0AEce92De3Edee1F18E0157C05861564
UNISWAP_V3_NFT_POSITION_MANAGER_ADDRESS = 0xC36442b4a4522E871399CD717aBDD847Ab11FE88

UNISWAP_FORK_RPC_URL = https://rpc.ankr.com/arbitrum
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "lib/solady"]
path = lib/solady
url = https://github.com/vectorized/solady
[submodule "lib/hermes-v2"]
path = lib/hermes-v2
url = https://github.com/Maia-DAO/hermes-v2
81 changes: 69 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Foundry Template
# TALOS

<!--
Badges provide a quick visual way to convey various information about your project. Below are several common types of badges. Feel free to uncomment, remove, or add new badges as needed for your project. Make sure to update the links so they point to the correct sources relevant to your project.
Expand Down Expand Up @@ -27,7 +27,7 @@ Remember to replace 'Maia-DAO/foundry-template' with your repository's path and
<!-- [![Discussions][discussions-badge]][discussions-link] -->
<!-- [![JS Library][js-library-badge]][js-library-link] -->

Add a short description of the repository here.
Transparent Automated Liquidity Omnichain Strategies (TALOS) is a peer-to-peer system that was built to reduce the current huge barrier of entry for adoption of concentrated liquidity and elevate the current user experience, specifically for Uniswap V3.

## Contributing

Expand All @@ -39,7 +39,16 @@ A more detailed description of the project can be found in the [documentation](h

## Architecture

Add a short description of the architecture here.
Talos positions are split into two main *Types*:

- **Vanilla**: Represent a share of one or more UNI V3 NFT positions.
- **Staked**: Represent a share of one or more UNI V3 NFT positions that are all staked in our Uniswap V3 Staker.

*Strategy Templates* encompass rebalancing and reranging strategies that work with both *Types* of positions without requiring any modifications.

New *Strategy Templates* can easily be created by solidity developers. There are multiple audited examples with guides of some possible operations.

The first *Strategy Template* holds a single UNI V3 NFT that anyone can create for any pool. When the price deviates a predefined number of ticks from the center of the position, anyone can call rebalance for the pool to set it at 50/50 again. There is an associated fee to these tasks – if the cost of constantly balancing the position is too large, it either won't happen or the pool or gas depositors may incur losses.

## Repository Structure

Expand All @@ -49,23 +58,71 @@ Note that helper contracts used by tests are held in the `./test/utils` subfolde

```ml
src
└── Counter - "Contract desciption"
├── base
│ └── TalosBaseStrategy.sol
├── boost-aggregator
│ └── BoostAggregator.sol
├── factories
│ ├── BoostAggregatorFactory.sol
│ ├── OptimizerFactory.sol
│ ├── TalosBaseStrategyFactory.sol
│ ├── TalosManagerFactory.sol
│ ├── TalosStrategyStakedFactory.sol
│ └── TalosStrategyVanillaFactory.sol
├── interfaces
│ ├── AutomationCompatibleInterface.sol
│ ├── IBoostAggregatorFactory.sol
│ ├── IBoostAggregator.sol
│ ├── IOptimizerFactory.sol
│ ├── ITalosBaseStrategyFactory.sol
│ ├── ITalosBaseStrategy.sol
│ ├── ITalosManagerFactory.sol
│ ├── ITalosManager.sol
│ ├── ITalosOptimizer.sol
│ ├── ITalosStrategyStakedFactory.sol
│ ├── ITalosStrategyStaked.sol
│ └── ITalosStrategyVanillaFactory.sol
├── libraries
│ ├── PoolActions.sol
│ └── PoolVariables.sol
├── strategies
│ └── TalosStrategySimple.sol
├── TalosManager.sol
├── TalosOptimizer.sol
├── TalosStrategyStaked.sol
└── TalosStrategyVanilla.sol
test
└── Counter.t.sol
├── BoostAggregatorTest.t.sol
├── factories
│ ├── BoostAggregatorFactoryTest.t.sol
│ ├── ComputeBoostAggregator.t.sol
│ └── OptimizerFactoryTest.t.sol
├── mocks
│ ├── MockBoostAggregatorFactory.sol
│ └── MockOptimizerFactory.sol
├── TalosOptimizerTest.t.sol
├── TalosStrategyStakedTest.t.sol
├── TalosStrategyVanillaTest.t.sol
├── TalosTestor.t.sol
└── utils
├── libraries
│ ├── PoolActions.sol
│ └── PoolVariables.sol
└── UniswapV3Assistant.t.sol
```

## Local deployment and Usage
## Local deployment and testing

To utilize the contracts and deploy to a local testnet, you can install the code in your repo with forge:
To utilize the contracts in you can install the code in your repo with forge:

```markdown
forge install https://github.com/Maia-DAO/foundry-template
```bash
forge install https://github.com/Maia-DAO/talos
```

To integrate with the contracts, the interfaces are available to use:

```solidity
To run tests, first clone the repository, then setup .env following the .env.example file. After that, run the following command to install dependencies, compile and run tests:

```bash
forge test
```

## License
Expand Down
28 changes: 24 additions & 4 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,35 @@ out = "out"
libs = ["lib"]
solc = "0.8.19"
via_ir = true
optimizer = true
optimizer_runs = 1000000
# optimizer_runs = 200 # default

# Allow forge to write gas snapshots
ffi = true
fs_permissions = [{ access = "read-write", path = ".forge-snapshots/"}]

memory_limit = 43554432
# memory_limit = 33554432 # default limit
[profile.default.fuzz]
# Number of Fuzzing runs to perform
runs = 1000
# runs = 256 # default

# Necessary for testing
gas_price = 10000
[profile.ci.fuzz]
# Number of Fuzzing runs to perform
runs = 100000
# runs = 256 # default

[profile.ci.invariant]
# If true, the Invariant will fail if a revert is detected
# fail_on_revert = true
# fail_on_revert = false # default

# Number of Invariant runs to perform
runs = 512
# runs = 256 # default

# Number of runs to perform per Invariant run
depth = 30
# depth = 15 # default

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
1 change: 1 addition & 0 deletions lib/hermes-v2
Submodule hermes-v2 added at 108563
1 change: 1 addition & 0 deletions lib/v3-core/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sol linguist-language=Solidity
60 changes: 60 additions & 0 deletions lib/v3-core/.github/workflows/fuzz-testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Fuzz Testing

on:
push:
branches:
- main
- 0.8
pull_request:

jobs:
echidna:
name: Echidna
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
testName:
- TickBitmapEchidnaTest
- TickMathEchidnaTest
- SqrtPriceMathEchidnaTest
- SwapMathEchidnaTest
- TickEchidnaTest
- TickOverflowSafetyEchidnaTest
- OracleEchidnaTest
- BitMathEchidnaTest
- UnsafeMathEchidnaTest
- FullMathEchidnaTest

steps:
- uses: actions/checkout@v2

- name: Set up node
uses: actions/setup-node@v1
with:
node-version: 12

- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install node dependencies
run: yarn install --frozen-lockfile

- name: Install pip3
run: |
python -m pip install --upgrade pip
- name: Install slither
run: |
pip3 install slither-analyzer
- name: Install echidna
run: |
sudo wget -O /tmp/echidna-test.tar.gz https://github.com/crytic/echidna/releases/download/v1.7.2/echidna-test-1.7.2-Ubuntu-18.04.tar.gz
sudo tar -xf /tmp/echidna-test.tar.gz -C /usr/bin
sudo chmod +x /usr/bin/echidna-test
- name: Run ${{ matrix.testName }}
run: echidna-test . --contract ${{ matrix.testName }} --config echidna.config.yml
33 changes: 33 additions & 0 deletions lib/v3-core/.github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Lint

on:
push:
branches:
- main
- 0.8
pull_request:

jobs:
run-linters:
name: Run linters
runs-on: ubuntu-latest

steps:
- name: Check out Git repository
uses: actions/checkout@v2

- name: Set up node
uses: actions/setup-node@v1
with:
node-version: 12

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Run linters
uses: wearerequired/lint-action@a8497ddb33fb1205941fd40452ca9fff07e0770d
with:
github_token: ${{ secrets.github_token }}
prettier: true
auto_fix: true
prettier_extensions: 'css,html,js,json,jsx,md,sass,scss,ts,tsx,vue,yaml,yml,sol'
64 changes: 64 additions & 0 deletions lib/v3-core/.github/workflows/mythx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Mythx

on:
workflow_dispatch:

jobs:
mythx:
name: Submit to Mythx
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up node
uses: actions/setup-node@v1
with:
node-version: 12

- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install node dependencies
run: yarn install --frozen-lockfile

- name: Install pip3
run: |
python -m pip install --upgrade pip
- name: Install mythx CLI
run: |
pip3 install mythx-cli
- name: Install solc-select
run: |
pip3 install solc-select
- name: Install solc 0.8.12
run: |
solc-select install 0.8.12
solc-select use 0.8.12
- name: Submit code to Mythx
run: |
mythx --api-key ${{ secrets.MYTHX_API_KEY }} \
--yes \
analyze \
--mode deep \
--async \
--create-group \
--group-name "@uniswap/v3-core@${{ github.sha }}" \
--solc-version 0.8.12 \
--check-properties \
contracts/test/TickBitmapEchidnaTest.sol --include TickBitmapEchidnaTest \
contracts/test/TickMathEchidnaTest.sol --include TickMathEchidnaTest \
contracts/test/SqrtPriceMathEchidnaTest.sol --include SqrtPriceMathEchidnaTest \
contracts/test/SwapMathEchidnaTest.sol --include SwapMathEchidnaTest \
contracts/test/TickEchidnaTest.sol --include TickEchidnaTest \
contracts/test/TickOverflowSafetyEchidnaTest.sol --include TickOverflowSafetyEchidnaTest \
contracts/test/OracleEchidnaTest.sol --include OracleEchidnaTest \
contracts/test/BitMathEchidnaTest.sol --include BitMathEchidnaTest \
contracts/test/UnsafeMathEchidnaTest.sol --include UnsafeMathEchidnaTest \
contracts/test/FullMathEchidnaTest.sol --include FullMathEchidnaTest
39 changes: 39 additions & 0 deletions lib/v3-core/.github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Tests

on:
push:
branches:
- main
- 0.8
pull_request:

jobs:
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12.x

- id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v1
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
yarn-
- name: Install dependencies
run: yarn install --frozen-lockfile

# This is required separately from yarn test because it generates the typechain definitions
- name: Compile
run: yarn compile

- name: Run unit tests
run: yarn test
5 changes: 5 additions & 0 deletions lib/v3-core/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
artifacts/
cache/
crytic-export/
node_modules/
typechain/
5 changes: 5 additions & 0 deletions lib/v3-core/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"semi": false,
"singleQuote": true,
"printWidth": 120
}
6 changes: 6 additions & 0 deletions lib/v3-core/.solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error"
}
}
1 change: 1 addition & 0 deletions lib/v3-core/.yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ignore-scripts true
Loading

0 comments on commit d08d82d

Please sign in to comment.