Skip to content

Commit

Permalink
Merge branch 'master' into shah/base-strategist-update
Browse files Browse the repository at this point in the history
  • Loading branch information
shahthepro committed Jan 10, 2025
2 parents b8f7fa8 + 79f2ae3 commit c75f2cb
Show file tree
Hide file tree
Showing 64 changed files with 4,044 additions and 1,274 deletions.
98 changes: 73 additions & 25 deletions .github/workflows/defi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ jobs:
- run: yarn prettier:check
working-directory: ./contracts

contracts-test:
name: "Contracts Unit Tests"
contracts-unit-coverage:
name: "Mainnet Unit Coverage"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -58,15 +58,20 @@ jobs:
- run: yarn install --frozen-lockfile
working-directory: ./contracts

# this will run the unit tests and report the gas usage
- name: Run Unit Tests
env:
REPORT_GAS: true
run: yarn run test
- name: Run Mainnet Unit Coverage
run: yarn run test:coverage
working-directory: ./contracts

contracts-unit-coverage:
name: "Contracts Unit Coverage"
- uses: actions/upload-artifact@v4
with:
name: unit-test-coverage-${{ github.sha }}
path: |
./contracts/coverage.json
./contracts/coverage/**/*
retention-days: 1

contracts-base-test:
name: "Base Unit Coverage"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -81,20 +86,22 @@ jobs:
- run: yarn install --frozen-lockfile
working-directory: ./contracts

- name: Run Unit Coverage
run: yarn run test:coverage
- name: Run Base Unit Coverage
env:
UNIT_TESTS_NETWORK: base
run: yarn run test:coverage:base
working-directory: ./contracts

- uses: actions/upload-artifact@v4
with:
name: unit-test-coverage-${{ github.sha }}
name: base-unit-test-coverage-${{ github.sha }}
path: |
./contracts/coverage.json
./contracts/coverage/**/*
retention-days: 1

contracts-base-test:
name: "Contracts Unit Tests (Base)"
contracts-sonic-test:
name: "Sonic Unit Coverage"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -109,24 +116,22 @@ jobs:
- run: yarn install --frozen-lockfile
working-directory: ./contracts

# this will run the unit tests and report the gas usage
- name: Run Unit Tests
- name: Run Sonic Unit Coverage
env:
REPORT_GAS: true
UNIT_TESTS_NETWORK: base
run: yarn run test:coverage:base
UNIT_TESTS_NETWORK: sonic
run: yarn run test:coverage:sonic
working-directory: ./contracts

- uses: actions/upload-artifact@v4
with:
name: base-unit-test-coverage-${{ github.sha }}
name: sonic-unit-test-coverage-${{ github.sha }}
path: |
./contracts/coverage.json
./contracts/coverage/**/*
retention-days: 1

contracts-forktest:
name: "Contracts Fork Tests ${{ matrix.chunk_id }}"
name: "Mainnet Fork Tests ${{ matrix.chunk_id }}"
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down Expand Up @@ -268,7 +273,7 @@ jobs:
cache: "yarn"
cache-dependency-path: contracts/yarn.lock

- uses: actions/cache@v3
- uses: actions/cache@v4
id: hardhat-cache
with:
path: contracts/cache
Expand All @@ -282,23 +287,66 @@ jobs:
- run: yarn run test:coverage:base-fork
working-directory: ./contracts

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: fork-test-base-coverage-${{ github.sha }}
path: |
./contracts/coverage.json
./contracts/coverage/**/*
retention-days: 1


contracts-sonic-forktest:
name: "Sonic Fork Tests"
runs-on: ubuntu-latest
continue-on-error: true
env:
HARDHAT_CACHE_DIR: ./cache
PROVIDER_URL: ${{ secrets.PROVIDER_URL }}
SONIC_PROVIDER_URL: ${{ secrets.SONIC_PROVIDER_URL }}
steps:
- uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: "yarn"
cache-dependency-path: contracts/yarn.lock

- uses: actions/cache@v4
id: hardhat-cache
with:
path: contracts/cache
key: ${{ runner.os }}-hardhat-${{ hashFiles('contracts/cache/*.json') }}
restore-keys: |
${{ runner.os }}-hardhat-cache
- run: yarn install --frozen-lockfile
working-directory: ./contracts

- run: yarn run test:coverage:sonic-fork
working-directory: ./contracts

- uses: actions/upload-artifact@v4
with:
name: fork-test-sonic-coverage-${{ github.sha }}
path: |
./contracts/coverage.json
./contracts/coverage/**/*
retention-days: 1

coverage-uploader:
name: "Upload Coverage Reports"
runs-on: ubuntu-latest
needs:
- contracts-unit-coverage
- contracts-base-test
- contracts-sonic-test
- contracts-forktest
- contracts-arb-forktest
- contracts-hol-forktest
- contracts-base-test
- contracts-base-forktest
- contracts-sonic-forktest
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,6 @@ fork-coverage
unit-coverage

.VSCodeCounter

# Certora #
.certora_internal
85 changes: 85 additions & 0 deletions brownie/runlogs/2025_01_strategist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# -------------------------------------
# Jan 6, 2025 - Withdraw 1k from new OUSD Morpho Gauntlet Strategies
# -------------------------------------
from world import *

def main():
with TemporaryForkForReallocations() as txs:
# Before
txs.append(vault_core.rebase(std))
txs.append(vault_value_checker.takeSnapshot(std))

# Remove 1k USDC from Morpho Gauntlet Strategy
txs.append(
vault_admin.withdrawFromStrategy(
MORPHO_GAUNTLET_PRIME_USDC_STRAT,
[usdc],
[1000 * 10**6],
{'from': STRATEGIST}
)
)

# Remove 1k USDT from Morpho Gauntlet Strategy
txs.append(
vault_admin.withdrawFromStrategy(
MORPHO_GAUNTLET_PRIME_USDT_STRAT,
[usdt],
[1000 * 10**6],
{'from': STRATEGIST}
)
)

# After
vault_change = vault_core.totalValue() - vault_value_checker.snapshots(STRATEGIST)[0]
supply_change = ousd.totalSupply() - vault_value_checker.snapshots(STRATEGIST)[1]
profit = vault_change - supply_change
txs.append(vault_value_checker.checkDelta(profit, (1 * 10**18), vault_change, (1 * 10**18), std))
print("-----")
print("Profit", "{:.6f}".format(profit / 10**18), profit)
print("OUSD supply change", "{:.6f}".format(supply_change / 10**18), supply_change)
print("Vault Change", "{:.6f}".format(vault_change / 10**18), vault_change)
print("-----")

# -------------------------------------
# Jan 7, 2025 - Withdraw 100k USDC from Morpho Steakhouse and deposit in Morpho Gauntlet Prime
# -------------------------------------
from world import *

def main():
with TemporaryForkForReallocations() as txs:
# Before
txs.append(vault_core.rebase(std))
txs.append(vault_value_checker.takeSnapshot(std))

# Remove 100k USDC from Morpho Steakhouse Strategy
txs.append(
vault_admin.withdrawFromStrategy(
MORPHO_META_USDC_STRAT,
[usdc],
[1000000 * 10**6],
{'from': STRATEGIST}
)
)

# Deposit 100k USDC tin Morpho Gauntlet Prime Strategy
txs.append(
vault_admin.depositToStrategy(
MORPHO_GAUNTLET_PRIME_USDC_STRAT,
[usdc],
[1000000 * 10**6],
{'from': STRATEGIST}
)
)

# After
vault_change = vault_core.totalValue() - vault_value_checker.snapshots(STRATEGIST)[0]
supply_change = ousd.totalSupply() - vault_value_checker.snapshots(STRATEGIST)[1]
profit = vault_change - supply_change
txs.append(vault_value_checker.checkDelta(profit, (1 * 10**18), vault_change, (1 * 10**18), std))
print("-----")
print("Profit", "{:.6f}".format(profit / 10**18), profit)
print("OUSD supply change", "{:.6f}".format(supply_change / 10**18), supply_change)
print("Vault Change", "{:.6f}".format(vault_change / 10**18), vault_change)
print("-----")


16 changes: 16 additions & 0 deletions certora/confs/OUSD_accounting.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"files": [
"contracts/contracts/token/OUSD.sol"
],
"msg": "OUSD Accounting invariants",
"packages": [
"@openzeppelin/contracts=contracts/lib/openzeppelin/contracts",
],
"process": "emv",
"prover_args": [

],
"solc": "solc8.28",
"verify": "OUSD:certora/specs/OUSD/AccountInvariants.spec",
"server": "production",
}
18 changes: 18 additions & 0 deletions certora/confs/OUSD_balances.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"files": [
"contracts/contracts/token/OUSD.sol"
],
"msg": "OUSD Balances invariants",
"packages": [
"@openzeppelin/contracts=contracts/lib/openzeppelin/contracts",
],
"process": "emv",
"prover_args": [
"-mediumTimeout 40",
],
"multi_assert_check":true,
"smt_timeout":"1000",
"solc": "solc8.28",
"verify": "OUSD:certora/specs/OUSD/BalanceInvariants.spec",
"server": "production"
}
17 changes: 17 additions & 0 deletions certora/confs/OUSD_other.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"files": [
"contracts/contracts/token/OUSD.sol"
],
"msg": "OUSD other invariants",
"packages": [
"@openzeppelin/contracts=contracts/lib/openzeppelin/contracts",
],
"process": "emv",
"prover_args": [
"-mediumTimeout 40",
],
"smt_timeout":"1000",
"solc": "solc8.28",
"verify": "OUSD:certora/specs/OUSD/OtherInvariants.spec",
"server": "production"
}
19 changes: 19 additions & 0 deletions certora/confs/OUSD_sumOfBalances.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"files": [
"contracts/contracts/token/OUSD.sol"
],
"msg": "OUSD Sum of balances rules",
"packages": [
"@openzeppelin/contracts=contracts/lib/openzeppelin/contracts",
],
"process": "emv",
"prover_args": [
"-mediumTimeout 40",
"-s [z3:lia2,z3:arith1,yices:def]",
],
"multi_assert_check":true,
"smt_timeout":"1000",
"solc": "solc8.28",
"verify": "OUSD:certora/specs/OUSD/SumOfBalances.spec",
"server": "production"
}
4 changes: 4 additions & 0 deletions certora/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
certoraRun certora/confs/OUSD_accounting.conf
certoraRun certora/confs/OUSD_balances.conf
certoraRun certora/confs/OUSD_other.conf
certoraRun certora/confs/OUSD_sumOfBalances.conf
Loading

0 comments on commit c75f2cb

Please sign in to comment.