Skip to content

Commit

Permalink
Initial Quark Scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
hayesgm committed Jun 1, 2024
0 parents commit 8740a16
Show file tree
Hide file tree
Showing 68 changed files with 7,136 additions and 0 deletions.
85 changes: 85 additions & 0 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
ApproveAndSwapTest:testSwap() (gas: 285500)
ApproveAndSwapTest:testSwapFailsIfWeExpectedTooMuch() (gas: 364666)
ApproveAndSwapTest:testSwapFailsWithNoApproval() (gas: 122231)
CometClaimRewardsTest:testClaimComp() (gas: 131265)
CometRepayAndWithdrawMultipleAssetsTest:testInvalidInput() (gas: 68171)
CometRepayAndWithdrawMultipleAssetsTest:testRepayAndWithdrawMultipleAssets() (gas: 153860)
CometSupplyMultipleAssetsAndBorrowTest:testInvalidInput() (gas: 68114)
CometSupplyMultipleAssetsAndBorrowTest:testSupplyMultipleAssetsAndBorrow() (gas: 295260)
ConditionalMulticallTest:testConditionalRunEmptyInputIsValid() (gas: 51386)
ConditionalMulticallTest:testConditionalRunInvalidInput() (gas: 68840)
ConditionalMulticallTest:testConditionalRunMulticallError() (gas: 316436)
ConditionalMulticallTest:testConditionalRunOnPeriodicRepay() (gas: 340313)
ConditionalMulticallTest:testConditionalRunPassed() (gas: 284615)
ConditionalMulticallTest:testConditionalRunUnmet() (gas: 103718)
EthcallTest:testEthcallCallReraiseError() (gas: 76316)
EthcallTest:testEthcallCounter() (gas: 69662)
EthcallTest:testEthcallShouldReturnCallResult() (gas: 52545)
EthcallTest:testEthcallSupplyUSDCToComet() (gas: 171965)
EthcallTest:testEthcallWithdrawUSDCFromComet() (gas: 296115)
GetDripTest:testDrip() (gas: 120591)
MulticallTest:testCallcodeToMulticallSucceedsWhenUninitialized() (gas: 83316)
MulticallTest:testCreateSubWalletAndExecute() (gas: 608534)
MulticallTest:testEmptyInputIsValid() (gas: 50892)
MulticallTest:testExecutorCanMulticallAcrossSubwallets() (gas: 303309)
MulticallTest:testInvalidInput() (gas: 68358)
MulticallTest:testInvokeCounterTwice() (gas: 83470)
MulticallTest:testMulticallError() (gas: 309667)
MulticallTest:testMulticallShouldReturnCallResults() (gas: 86409)
MulticallTest:testRevertsForInvalidCallContext() (gas: 11574)
MulticallTest:testSupplyWETHWithdrawUSDCOnComet() (gas: 259628)
PaycallTest:testInitializeProperlyFromConstructor() (gas: 6425)
PaycallTest:testPaycallForPayWithUSDT() (gas: 121389)
PaycallTest:testPaycallForPayWithWBTC() (gas: 115864)
PaycallTest:testReturnCallResult() (gas: 89981)
PaycallTest:testRevertsForInvalidCallContext() (gas: 16521)
PaycallTest:testRevertsWhenCostIsMoreThanMaxPaymentCost() (gas: 119258)
PaycallTest:testSimpleCounterAndPayWithUSDC() (gas: 143929)
PaycallTest:testSimpleTransferTokenAndPayWithUSDC() (gas: 139569)
PaycallTest:testSupplyWETHWithdrawUSDCOnCometAndPayWithUSDC() (gas: 300142)
ReplayableTransactionsTest:testCancelRecurringPurchase() (gas: 267995)
ReplayableTransactionsTest:testRecurringPurchaseHappyPath() (gas: 210285)
ReplayableTransactionsTest:testRecurringPurchaseMultiplePurchases() (gas: 365698)
ReplayableTransactionsTest:testRecurringPurchaseWithDifferentCalldata() (gas: 590229)
ReplayableTransactionsTest:testRevertsForExpiredQuarkOperation() (gas: 11893)
ReplayableTransactionsTest:testRevertsForExpiredUniswapParams() (gas: 118215)
ReplayableTransactionsTest:testRevertsForPurchaseBeforeNextPurchasePeriod() (gas: 283863)
ReplayableTransactionsTest:testRevertsForPurchasingOverTheLimit() (gas: 284305)
SupplyActionsTest:testInvalidInput() (gas: 67616)
SupplyActionsTest:testRepayBorrow() (gas: 89628)
SupplyActionsTest:testSupply() (gas: 131927)
SupplyActionsTest:testSupplyFrom() (gas: 111824)
SupplyActionsTest:testSupplyMultipleCollateral() (gas: 270579)
SupplyActionsTest:testSupplyTo() (gas: 131476)
TransferActionsTest:testRevertsForTransferERC777ReentrancyAttackWithReentrancyGuard() (gas: 148745)
TransferActionsTest:testRevertsForTransferReentrancyAttackWithReentrancyGuard() (gas: 130322)
TransferActionsTest:testRevertsForTransferReentrancyAttackWithoutCallbackEnabled() (gas: 99351)
TransferActionsTest:testRevertsForTransferReentrantAttackWithStolenSignature() (gas: 110234)
TransferActionsTest:testTransferERC20TokenToEOA() (gas: 70280)
TransferActionsTest:testTransferERC20TokenToQuarkWallet() (gas: 71600)
TransferActionsTest:testTransferERC777SuccessWithEvilReceiverWithoutAttackAttempt() (gas: 106630)
TransferActionsTest:testTransferERC777TokenReentrancyAttackSuccessWithCallbackEnabled() (gas: 144402)
TransferActionsTest:testTransferNativeTokenToEOA() (gas: 79394)
TransferActionsTest:testTransferNativeTokenToQuarkWallet() (gas: 54956)
TransferActionsTest:testTransferReentrancyAttackSuccessWithCallbackEnabled() (gas: 128482)
TransferActionsTest:testTransferSuccessWithEvilReceiverWithoutAttackAttempt() (gas: 87222)
UniswapFlashLoanTest:testFlashLoanForCollateralSwapOnCompound() (gas: 426291)
UniswapFlashLoanTest:testRevertsForInsufficientFundsToRepayFlashLoan() (gas: 192671)
UniswapFlashLoanTest:testRevertsForInvalidCaller() (gas: 70165)
UniswapFlashLoanTest:testRevertsIfCalledDirectly() (gas: 10598)
UniswapFlashLoanTest:testTokensOrderInvariant() (gas: 94563)
UniswapFlashSwapExactOutTest:testInvalidCallerFlashSwap() (gas: 70209)
UniswapFlashSwapExactOutTest:testNotEnoughToPayFlashSwap() (gas: 293339)
UniswapFlashSwapExactOutTest:testRevertsIfCalledDirectly() (gas: 10724)
UniswapFlashSwapExactOutTest:testUniswapFlashSwapExactOutLeverageComet() (gas: 353254)
UniswapSwapActionsTest:testApprovalRefund() (gas: 163571)
UniswapSwapActionsTest:testBuyAssetOneStop() (gas: 251129)
UniswapSwapActionsTest:testBuyAssetTwoStops() (gas: 357689)
UniswapSwapActionsTest:testSellAssetOneStop() (gas: 248467)
UniswapSwapActionsTest:testSellAssetTwoStops() (gas: 361614)
WithdrawActionsTest:testBorrow() (gas: 153735)
WithdrawActionsTest:testInvalidInput() (gas: 67488)
WithdrawActionsTest:testWithdraw() (gas: 83594)
WithdrawActionsTest:testWithdrawFrom() (gas: 83108)
WithdrawActionsTest:testWithdrawMultipleAssets() (gas: 159195)
WithdrawActionsTest:testWithdrawTo() (gas: 83573)
54 changes: 54 additions & 0 deletions .github/workflows/gas-snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: snapshot gas

on:
workflow_dispatch:
pull_request:

env:
FOUNDRY_PROFILE: ci

jobs:
snapshot-gas:
name: Diff against gas snapshot
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: "nightly-de33b6af53005037b463318d2628b5cfcaf39916"

- name: Install dependencies
run: forge install

- name: Diff gas snapshot against baseline
run: |
set -euo pipefail
# grep -E '^test' -- skip over test results, just get diffs
forge snapshot --via-ir --diff \
| grep -E '^test' \
| tee .gas-snapshot.new
env:
NODE_PROVIDER_BYPASS_KEY: ${{ secrets.NODE_PROVIDER_BYPASS_KEY }}

- name: Check diff tolerance
run: |
set -euo pipefail
# 1. skip over diffs of 0 gas (do not fail if no matches)
# 2. skip over negative diffs (do not fail if no matches)
# 3. remove ANSI color / style escape sequences
# 4. extract absolute (not percentage) gas diffs
# 5. pluck any diffs that exceed an absolute tolerance threshold
# and exit non-zero (failure) if any such diff is found
{ grep -Ev 'gas: 0' .gas-snapshot.new || true; } \
| { grep -Ev '\-[0-9]+' || true; } \
| sed -Ee 's/\x1b\[[0-9;]*m//g' \
-Ee 's/(.+)\(\) \(gas: ([0-9]+).+/\1 \2/' \
| awk '{ if ($2 > ENVIRON["GAS_DIFF_THRESHOLD"]) { print; failures++ } } END { if (failures > 0) { print $failures; exit 1 } else { print "ok." } }'
env:
# gas diff check should fail if any gas diff exceeds threshold
GAS_DIFF_THRESHOLD: 5000
39 changes: 39 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: lint

on:
workflow_dispatch:
pull_request:

env:
FOUNDRY_PROFILE: ci

jobs:
check:
strategy:
fail-fast: true

name: Foundry project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: "nightly-de33b6af53005037b463318d2628b5cfcaf39916"

- name: Install dependencies
run: forge install

- name: Run Forge build
run: |
forge --version
forge build --sizes
id: build

- name: Run Forge Format
run: |
forge fmt --check
id: format
41 changes: 41 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: test

on:
workflow_dispatch:
pull_request:

env:
FOUNDRY_PROFILE: ci

jobs:
check:
strategy:
fail-fast: true

name: Foundry project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: "nightly-de33b6af53005037b463318d2628b5cfcaf39916"

- name: Install dependencies
run: forge install

- name: Run Forge build
run: |
forge --version
forge build --via-ir --sizes
id: build

- name: Run Forge tests
run: |
forge test --via-ir
id: test
env:
NODE_PROVIDER_BYPASS_KEY: ${{ secrets.NODE_PROVIDER_BYPASS_KEY }}
31 changes: 31 additions & 0 deletions .github/workflows/vendoza.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: vendoza

on:
workflow_dispatch:
pull_request:

env:
FOUNDRY_PROFILE: ci

jobs:
check:
strategy:
fail-fast: true

name: Foundry project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Install node
uses: actions/setup-node@v2
with:
node-version: 19

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

- name: Vendoza Audit
run: yarn vendoza-audit
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Compiler files
cache/
out/

# Ignores development broadcast logs
!/broadcast
/broadcast/*/31337/
/broadcast/**/dry-run/

# Docs
docs/

# Dotenv file
.env

# VSCode files
.vscode/

# Node modules
node_modules/

# Quark releases
/quark-out.release-v*.zip
15 changes: 15 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/openzeppelin/openzeppelin-contracts
[submodule "lib/v3-periphery"]
path = lib/v3-periphery
url = https://github.com/Uniswap/v3-periphery
[submodule "lib/v3-core"]
path = lib/v3-core
url = https://github.com/uniswap/v3-core
[submodule "lib/quark"]
path = lib/quark
url = [email protected]:compound-finance/quark
11 changes: 11 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Copyright 2023 Compound Labs, Inc.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Loading

0 comments on commit 8740a16

Please sign in to comment.