Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes from auditor comments #30

Merged
merged 73 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
02c9ee0
use dynamic fee instead of base fee
bout3fiddy Sep 13, 2023
5207bd1
mixbytes auditor comment. fix: gulp while transfer out; but gulp into…
bout3fiddy Sep 14, 2023
f376632
fix: use correct dx_w_fee in stored_balances
bout3fiddy Sep 15, 2023
ef17510
fix paranthesis
bout3fiddy Sep 15, 2023
0c87415
add D_ma_time for D_oracle
bout3fiddy Sep 19, 2023
6b7dbdf
do not add liquidity to base pool and incr
bout3fiddy Sep 19, 2023
8992bea
fix: incorrect stored_balances update; fix: remove donation for non r…
bout3fiddy Sep 20, 2023
2c10cb3
fix: also restrict exchange_underlying_received
bout3fiddy Sep 20, 2023
79615f8
fix pipeline
amfet42 Sep 20, 2023
cc8cfb2
fix mock contract
amfet42 Sep 20, 2023
8646209
fix: dynamic fee; feat: introduce gauge manager; feat: add optional r…
bout3fiddy Sep 21, 2023
b2161c0
fix donation test
amfet42 Sep 21, 2023
e6699d1
fix: add admin slashing immunity comment to docstring
bout3fiddy Sep 22, 2023
7cde923
Merge branch 'fix/audit' of github.com:curvefi/stableswap-ng into fix…
amfet42 Sep 22, 2023
f946037
fix tests
amfet42 Sep 22, 2023
10db985
fix tests
amfet42 Sep 22, 2023
2bab627
Merge pull request #31 from curvefi/fix/workflow
bout3fiddy Sep 23, 2023
dcf88c7
fix: remove unneeded dynarray forming code
bout3fiddy Sep 25, 2023
be65254
fix remove liquidity test
amfet42 Sep 26, 2023
2d5f374
fix: audit comments #2
bout3fiddy Sep 27, 2023
8315d25
fix: do not multiple vprice if we need lp tokens for views method
bout3fiddy Sep 27, 2023
daff90b
fix: tests
bout3fiddy Sep 27, 2023
496901e
fix: disallow 0 transferFrom into the pool
bout3fiddy Sep 27, 2023
04d2fa4
remove unused vars and rename internal fn
bout3fiddy Sep 27, 2023
9fa42a1
check for zero token amt burning
bout3fiddy Sep 27, 2023
d5adba9
fix: use fraxusdc for add_base_pool test since that has coins(u: uint…
bout3fiddy Sep 27, 2023
b3565b2
do not disable _checkpoint_rewards entirely
bout3fiddy Sep 28, 2023
f9f7e0f
fix: remove double fees accounting in views contract; remove division…
bout3fiddy Sep 28, 2023
9fad8da
update inflation params if is_killed is set to True
bout3fiddy Sep 28, 2023
df4aae3
fix: expose rebasing impl boolean
bout3fiddy Oct 2, 2023
d9f1b2c
make stored_rates return dynarray; use that in views; fix tests
bout3fiddy Oct 2, 2023
7b408a5
fix: reduce bytecode and remove asset_type
bout3fiddy Oct 2, 2023
145b390
remove unneeded rate oracle view method to save bytecode
bout3fiddy Oct 2, 2023
f61003f
chainsec comment: upkeep D oracle on remove_liquidity
bout3fiddy Oct 3, 2023
72699ee
fix: use correct last times in view methods
bout3fiddy Oct 3, 2023
6e64610
fix: comment
bout3fiddy Oct 3, 2023
50c0d65
add D oracle upkeeping in remove_liquidity for metapools
bout3fiddy Oct 3, 2023
919f1d0
final auditor comments
bout3fiddy Oct 4, 2023
72aabcf
update to vypers 0.3.10rc6. final candidate: 0.3.10; all hail king ch…
bout3fiddy Oct 4, 2023
7a285fd
fix: version pragma
bout3fiddy Oct 4, 2023
7b766a3
rename to set because apply is commit->apply, whereas here we're sett…
bout3fiddy Oct 4, 2023
6d313ee
update vyper to 0.3.10 !
bout3fiddy Oct 5, 2023
bff1522
bump gauge version
bout3fiddy Oct 5, 2023
237828d
add erc4626 token support in asset_type = 3
bout3fiddy Oct 11, 2023
63b46dc
add asset types; fix: _stored_rates in plain pools not reading extern…
bout3fiddy Oct 12, 2023
fa9731a
use correct asset precisions for erc4626
bout3fiddy Oct 12, 2023
d23f6e0
add tests for erc4626 tokens
bout3fiddy Oct 12, 2023
3f0cd36
add helper method to donate amount to vault
bout3fiddy Oct 12, 2023
ffe12f0
fix: remove deprecated var
bout3fiddy Oct 12, 2023
b5a073c
add helper fn for minting tokens
bout3fiddy Oct 12, 2023
b4da1e9
add feedback from Ivan
bout3fiddy Oct 13, 2023
a13a8b8
separate base pool setup from deploying infra
bout3fiddy Oct 13, 2023
5fc9b09
add sepolia deployment and boa deployment scripts
bout3fiddy Oct 16, 2023
c3bd2c6
add gnosis deployment
bout3fiddy Oct 17, 2023
af7685d
fix: doubly adding asset types in add_base_pool
bout3fiddy Oct 17, 2023
c3a25b1
attempt contract verification
bout3fiddy Oct 17, 2023
c86f511
remove breakpoint()
bout3fiddy Oct 17, 2023
fb09ee3
finish gnosis deployment testing
bout3fiddy Oct 17, 2023
cda42d8
remove exchange_underlying_received since bytecode length cannot fit …
bout3fiddy Oct 19, 2023
4aa954c
add optimism deployment
bout3fiddy Oct 20, 2023
8b76e57
polygon deployment!
bout3fiddy Oct 20, 2023
7a9a26c
add deployment addresses for polygon
bout3fiddy Oct 20, 2023
d564a9f
base deployment
bout3fiddy Oct 20, 2023
5926e9b
another round of deployments
bout3fiddy Oct 23, 2023
4a52715
more deployments
bout3fiddy Oct 24, 2023
eb1b641
awaiting boa static fee integration
bout3fiddy Oct 24, 2023
01f5bbc
add kava deployment
bout3fiddy Oct 25, 2023
23bb583
deployed on aurora
bout3fiddy Oct 25, 2023
2eeb0d4
deployed: polygon zkevm, scroll, ethereum!
bout3fiddy Oct 25, 2023
fd22952
add base pools to factory
bout3fiddy Oct 26, 2023
61f497f
add boa scripts and remove ape script
bout3fiddy Nov 1, 2023
d82428f
park workflows
bout3fiddy Nov 1, 2023
183c16e
fix readme
bout3fiddy Nov 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
run: |
pip install poetry==1.5.1
poetry config virtualenvs.in-project true
poetry install --no-interaction
poetry install --no-interaction --without dev

- name: Run Tests Basic
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
run: |
pip install poetry==1.5.1
poetry config virtualenvs.in-project true
poetry install --no-interaction
poetry install --no-interaction --without dev

- name: Run Tests
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
run: |
pip install poetry==1.5.1
poetry config virtualenvs.in-project true
poetry install --no-interaction
poetry install --no-interaction --without dev

- name: Run All Token Tests 18,18
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
run: |
pip install poetry==1.5.1
poetry config virtualenvs.in-project true
poetry install --no-interaction
poetry install --no-interaction --without dev

- name: Run Tests
run: |
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,6 @@ node_modules
docs/
scripts/experiments/get_p.py
.python-version
todo.txt
AuditorComments.md
set_env.py
8 changes: 5 additions & 3 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Stableswap NG

Permissionless deployment of Curve metapools.
Permissionless deployment of Curve Stableswap plain and metapools. Supports up to 8 coins for plain pools and 2 coins for metapools. Supports: rate-oraclised tokens (e.g. wstETH), ERC4626 (sDAI), rebasing (stETH), and plain (WETH:stETH) pools. Does not support native tokens.

# Wen?
For integrators: check exchange_received. That should improve your pathing significantly. Be aware that if a pool contains rebasing tokens, this method is intentionally disabled.

![STOP THE WEN!](./you_shall_not_wen.jpeg)
# Deployments

For a full list of deployments, please check: [The deployment script](scripts/deploy_infra.py)

## Overview

Expand Down
4 changes: 1 addition & 3 deletions ape-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ plugins:
default_ecosystem: ethereum

# vyper:
# default_version: paris # enable for non PUSH0 evm networks
# ethereum:
# evm_version: shanghai
# evm_version: shanghai

hardhat:
port: auto
Expand Down
156 changes: 156 additions & 0 deletions contracts/ProxyAdmin.vy
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# pragma version 0.3.10
# pragma evm-version paris
"""
@title ProxyAdmin
@notice Thin proxy allowing shared ownership of contracts
@author Ben Hauser
@license MIT
"""


event TransactionExecuted:
admin: indexed(address)
target: indexed(address)
calldata: Bytes[100000]
value: uint256

event RequestAdminChange:
current_admin: address
future_admin: address

event RevokeAdminChange:
current_admin: address
future_admin: address
calling_admin: address

event ApproveAdminChange:
current_admin: address
future_admin: address
calling_admin: address

event AcceptAdminChange:
previous_admin: address
current_admin: address


admins: public(address[2])

pending_current_admin: uint256
pending_new_admin: address
change_approved: bool


@external
def __init__(_authorized: address[2]):
"""
@notice Contract constructor
@param _authorized Admin accounts for this contract
"""
self.admins = _authorized


@payable
@external
def execute(_target: address, _calldata: Bytes[100000]):
"""
@notice Execute a contract call
@dev Ether sent when calling this function is forwarded onward
@param _target Address of the contract to call
@param _calldata Calldata to use in the call
"""
assert msg.sender in self.admins # dev: only admin

raw_call(_target, _calldata, value=msg.value)
log TransactionExecuted(msg.sender, _target, _calldata, msg.value)


@view
@external
def get_admin_change_status() -> (address, address, bool):
"""
@notice Get information about a pending admin change
@return Admin address to be replaced,
admin address to be added,
has change been approved?
"""
idx: uint256 = self.pending_current_admin
if idx == 0:
return ZERO_ADDRESS, ZERO_ADDRESS, False
else:
return self.admins[idx - 1], self.pending_new_admin, self.change_approved


@external
def request_admin_change(_new_admin: address):
"""
@notice Initiate changing an admin address
@param _new_admin New admin address (replaces msg.sender)
"""
assert self.pending_current_admin == 0 # dev: already an active request

admin_list: address[2] = self.admins
assert _new_admin not in admin_list # dev: new admin is already admin

for i in range(2):
if admin_list[i] == msg.sender:
self.pending_current_admin = i + 1
self.pending_new_admin = _new_admin
log RequestAdminChange(msg.sender, _new_admin)
return

raise # dev: only admin


@external
def approve_admin_change():
"""
@notice Approve changing an admin address
@dev Only callable by the 2nd admin address (the one that will not change)
"""
idx: uint256 = self.pending_current_admin

assert idx > 0 # dev: no active request
assert msg.sender == self.admins[idx % 2] # dev: caller is not 2nd admin

self.change_approved = True
log ApproveAdminChange(self.admins[idx - 1], self.pending_new_admin, msg.sender)


@external
def revoke_admin_change():
"""
@notice Revoke changing an admin address
@dev May be called by either admin at any time to reset the process,
even if approval has previous been given
"""
assert msg.sender in self.admins # dev: only admin

idx: uint256 = self.pending_current_admin
pending_admin: address = ZERO_ADDRESS
if idx > 0:
pending_admin = self.admins[idx - 1]

log RevokeAdminChange(pending_admin, self.pending_new_admin, msg.sender)

self.pending_current_admin = 0
self.pending_new_admin = ZERO_ADDRESS
self.change_approved = False



@external
def accept_admin_change():
"""
@notice Accept a changed admin address
@dev Only callable by the new admin address, after approval has been given
"""
assert self.change_approved == True # dev: change not approved
assert msg.sender == self.pending_new_admin # dev: only new admin

idx: uint256 = self.pending_current_admin - 1
log AcceptAdminChange(self.admins[idx], msg.sender)
self.admins[idx] = msg.sender

self.pending_current_admin = 0
self.pending_new_admin = ZERO_ADDRESS
self.change_approved = False
Loading