Skip to content

Conversation

@oldchili
Copy link
Collaborator

@oldchili oldchili commented Aug 5, 2023

Creating this PR so comments can be made on the content of dev.

sunbreak1211 and others added 29 commits May 24, 2023 18:31
* Rename Buffer back to Vault

* Add Escrow called Buffer

* Wipe from another address

* Complete buffer, add tests and minor changes
* Add AllocatorRoles

* First check roles

* Fix for error messaging + add test for roles in the buffer + some renaming and order

* Fix test

* Add constructor, events and fix parameter of one function

* Update README

* Add tests + some renaming

* Minor changes

* Fix indentation

* Simplify casting

* More casting simplification
* Add AllocatorConduit example

* feat: Add conduit interface (#5)

* feat: add initial interface

* feat: add natspec, finalize interface

* fix: update title

* Interface rename + allocator => domain

---------

Co-authored-by: sunbreak <sunbreak1211@proton.me>

* Add conduit interface and changes to conduit example (WIP)

* fix: update natspec

* More interface and example changes

* Fix indentation

* Simplest maxDeposit and maxWithdraw implementations

* Fix spacing

* Implement singleton roles and make it immutable where using it (#7)

* Implement singleton roles and make it immutable where using it

* Renaming

* Split request funds portion into a separate, optional interface (#8)

* split request funds portion into a separate, optional interface

* Fix example to work with new version of interfaces

---------

Co-authored-by: sunbreak <sunbreak1211@proton.me>

* Remove FundsRequestable part

* domain => ilk

* Minor change in authed mock

* Roles: admins to ilkAdmins

---------

Co-authored-by: Lucas Manuel <lucasmanuel.tech@gmail.com>
Co-authored-by: Sam MacPherson <xylom44@gmail.com>
* Add Router

* Fix event

* Clean ConduitMock

* Update latest version WhitelistedRouter

* Update files structure + Make test fully unit without RPC reliance

* Add changes to Router and Buffer

* Use also deposit in Router.move and remove last param of Buffer.deposit

* Use IAllocatorConduit for AllocatorBuffer

* Add immutable ilk in Buffer

* Test Buffer getters

---------

Co-authored-by: telome <>
* Remove Router + Add Registry + Modify Buffer, IConduit and example

* Remove deposit and withdraw from Buffer + extending conduit example
* Add AllocatorRoles

* First check roles

* Fix for error messaging + add test for roles in the buffer + some renaming and order

* Add tests + some renaming

* More casting simplification

* Add draft swapper

* Separate facilitators from keepers

* Account for ES

* Fix nits

* Move to subfolders

* Move tests

* Use storage weights

* Remove pip

* Add box authorisation sanity check

* Update src/funnels/Swapper.sol

Co-authored-by: oldchili <130549691+oldchili@users.noreply.github.com>

* Address first batch of review comments

* Rename vars

* Use fixed lots

* Add countdowns

* Allow other gem decimals

* Remove wipe call

* Removing deposit call

* Add README for latest design

* Update README re whitelist

* Update README to laster design iteration

* Clarify README

* Add updated Swapper

* Add Router

* Fix event

* Clean ConduitMock

* Update to approve+deposit architecture

* Rename WhitelistedRouter.move

* Move gem from buffer

* Make Swapper generic

* Add roles to Swapper

* Add SwapperRunner

* Update Swapper tests

* Update router tests

* Fix rebase

* Use AllocatorBuffer instead of mock

* Use fork

* Rename swap role

* Add Depositor

* Fix rebase

* Add Depositor rate limit

* Add SwapDepositor

* Fix cap check

* Fix comment

* Simplify usage of StableSwapper + fix tests

* Add swap threshold

* Remove this version of Router

* Prepare structure for easier merge of dev

* Rename GemLikes

* Add _ prefix to internal functions

* Move dust transfer to outer call

* Allow for fee collection without liquidity removal

* Using deposit cap per gem

* Remove SwapDepositor

* Add collect function to Depositor

* Reorg directories

* Rename maxSrcAmts -> caps + split Swapper tests

* Add auth tests

* Set StableSwapper config in one go

* Apply suggestions from code review

Co-authored-by: oldchili <130549691+oldchili@users.noreply.github.com>

* Use immutable for buffer & swapper

* Use reqOut instead of minPrice

* Pre-calculate optimal deposit amounts

* Add comments + fix events

* Add fee collectFees flag + comment warning about minOut/reqOut mismatch

* Add liquidity move test

* Clean up StableSwapper access control

* Split depositor tests

* Add event tests

* Remove buffer_ refs

* Add revert tests

* Add src checks

* More tests for before and after hop operations

* Remove redundant blank lines

* More tests for StableSwapper

* Remove redundant blank line in Depositor.t.sol

* Remove unused TestUtils

* Depositor interacts with pool directly

* Add stable depositor

* Align min/max/req var names

* Add StableDepositor tests, missing collect

* Now really add tests

* Revert Depositor.t.sol changes

* Apply suggestions from code review

Co-authored-by: sunbreak1211 <129470872+sunbreak1211@users.noreply.github.com>

* MintCallback revert message, tests

* Actually add test, minor changes

* Move automation's collect to keeper

* Remove setApprovalForAll from buffer

* Remove setApprovalForAll interface

* Make facilitator warded, bots=>buds

* Standarize short functions to multi-line, spaces

* Remove more spaces in front of events

* Reorder immutables according to ctr params

* Fix spaces before immutable comments

* Move PairConfig comments to the struct definition

* Set swapper as SwapperLike directly

* Add new lines at end of files

* Fix some license identifiers

* Pack hop,zzz,cap in swapper

* Pack hop,zzz in depositor

* Use buffer explicitly in MintCallbackData

* Add UniV3 callee tests

* Fix whitespaces

* Increase slippage tolerance for testSwapLongPath

* Use USDT instead of WETH in callee tests

* Update test/funnels/callees/UniV3SwapperCallee.t.sol

Co-authored-by: sunbreak1211 <129470872+sunbreak1211@users.noreply.github.com>

* Use single struct for configuration

* Minor fix

* Use math libs from dss-kiln

* Apply suggestions from code review

Co-authored-by: sunbreak1211 <129470872+sunbreak1211@users.noreply.github.com>

* Update test/funnels/Swapper.t.sol

Co-authored-by: sunbreak1211 <129470872+sunbreak1211@users.noreply.github.com>

* Update test/funnels/Swapper.t.sol

Co-authored-by: sunbreak1211 <129470872+sunbreak1211@users.noreply.github.com>

* Make sure zzz does not change in setLimits test

* Align amt=>collect, test events with snapshot (except withdraw)

* Test zzz also for Depositor's setLimits

* Apply suggestions from code review

Co-authored-by: sunbreak1211 <129470872+sunbreak1211@users.noreply.github.com>
Co-authored-by: telome <130504305+telome@users.noreply.github.com>

* Update src/funnels/Depositor.sol

Co-authored-by: sunbreak1211 <129470872+sunbreak1211@users.noreply.github.com>

* Move constant ot after immutable

* Use named params in collect's burn call

* Address Depositor.t.sol review comments

* Apply suggestions from code review

Co-authored-by: sunbreak1211 <129470872+sunbreak1211@users.noreply.github.com>

* Return fees from Depositor.withdraw + misc (#22)

* Return fees in Depositor

* Fully check Depositor.Withdraw events

* Withdraw to return fees0 and fees1, rename to those in collect

* Test also withdraw events data

* gem0, gem1 => src, dst in Swapper

* Minor neats

* Align vars and structs documentation, Capitalize comments

* Clean up merge duplication

* Remove spacing

---------

Co-authored-by: telome <>
Co-authored-by: oldchili <130549691+oldchili@users.noreply.github.com>
Co-authored-by: sunbreak1211 <129470872+sunbreak1211@users.noreply.github.com>

* Update test/funnels/automation/StableDepositor.t.sol

Co-authored-by: sunbreak1211 <129470872+sunbreak1211@users.noreply.github.com>

* Read position (#25)

* Add getPosition

* Return fees in Depositor

* Fully check Depositor.Withdraw events

* Withdraw to return fees0 and fees1, rename to those in collect

* Test also withdraw events data

* gem0, gem1 => src, dst in Swapper

* Minor neats

* Align vars and structs documentation, Capitalize comments

* Clean up merge duplication

---------

Co-authored-by: oldchili <130549691+oldchili@users.noreply.github.com>
Co-authored-by: telome <>

* Minor modifications to funnels tests + change default verbosity (#24)

* Modify funnel test + change default verbosity

* More changes to tests

* Remove check that is semantically doesn't say much

* Remove unused variables

* Remove unused variables

* Remove TestUtils (#27)

* Smarter rate limiter using partial amounts (#26)

* Swapper: Rate limit using partial amount

* StableSwapper: add hop

* Swapper reorder fields in limits structure

* Partial amounts for Depositor and StableDepositor

* Use same order

* Change amts if greater than new cap in setLimits

* amt => due

* Add some missing variable documentation

* Add missing zzz update

* Fix name test contract

* Improve storage packing + make deposit mapping keys more specific

* Set due and zzz to 0 on SetLimits

* Fix missing update of zzz

* Add missing check + fix error message

* Improve test coverage

* Fix some comments

* Set zzz to 0 in setConfig

* Fix comments

* Remove some unchecked blocks for better theoretical code correctness

* Easier comparison to reason about

* Fix for using just two slots in StableDepositor

* Fix spacing

* Fix comment

* Minor change in test

* nits

* Minor

* Minor

* Avoid swapping directly to buffer (#28)

* Avoid swapping directly to buffer

* No need to get prev balance

* Minor change in test

* Revert "Minor change in test"

This reverts commit 08e8cee.

---------

Co-authored-by: sunbreak <sunbreak1211@proton.me>

* min => req

* Minors

Co-authored-by: oldchili <130549691+oldchili@users.noreply.github.com>

* hop => era, zzz => end

* More hop => era

* Match order struct values Depositor with Swapper as it is also more logical packing

* Fix aligment

* StableDepositor: Make num signed int for separating deposit from withdraw (#29)

* Changes in comments

Co-authored-by: telome <130504305+telome@users.noreply.github.com>

---------

Co-authored-by: oldchili <130549691+oldchili@users.noreply.github.com>
Co-authored-by: telome <130504305+telome@users.noreply.github.com>

* Rename Depositor to DepositorUniV3 + Callee renaming + Minor comment fix in Swapper (#30)

* Rename Depositor to DepositorUniV3 + Minor comment fix in Swapper

* UniV3SwapperCallee => SwapperCalleeUniV3

* Swapper Depositor Neats (#32)

* Remove TODO of cheaper SLOAD

* LiquidityAmounts - standard header, remove unused functions

* Change licenses

* Conduits Automated Mover (#33)

* Conduit mover - initial version

* Reordering and neats

* Turn AllocatorConduitExample to a mock

* Update test/funnels/automation/ConduitMover.t.sol

Co-authored-by: telome <130504305+telome@users.noreply.github.com>

---------

Co-authored-by: telome <130504305+telome@users.noreply.github.com>

---------

Co-authored-by: sunbreak <sunbreak1211@proton.me>
Co-authored-by: telome <>
Co-authored-by: oldchili <130549691+oldchili@users.noreply.github.com>
Co-authored-by: sunbreak1211 <129470872+sunbreak1211@users.noreply.github.com>

function file(bytes32 ilk, bytes32 what, address data) external auth {
if (what == "buffer") {
buffers[ilk] = data;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: multiple ilks can map to the same buffer; I'm assuming this isn't an issue and is maybe even an intended feature, but wanted to flag it just in case

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this isn't an issue as the pause proxy is not expected to do that (map multiple ilks to the same buffer).

sunbreak1211 and others added 26 commits August 29, 2023 08:46
Co-authored-by: telome <>
* Readme Additions

* Update README.md

Co-authored-by: telome <130504305+telome@users.noreply.github.com>

---------

Co-authored-by: telome <130504305+telome@users.noreply.github.com>
* Deployment scripts - wip

* Minimize functions, init all from PP

* Add ConduitMover, solve compilation issues

* Add changelog values

* Update src/deploy/AllocatorInit.sol

Co-authored-by: telome <130504305+telome@users.noreply.github.com>

* put in ilk registry, sanity checks

* WIP

* test cleaups

* Move deploy out of src

* Remove init function and use grab in spell set up

* vat.grab in init script instead of vault's removed init()

* Update alignment in deploy/AllocatorInit.sol

Co-authored-by: telome <130504305+telome@users.noreply.github.com>

* Gems => Tokens

* Apply suggestions from code review

Co-authored-by: sunbreak1211 <129470872+sunbreak1211@users.noreply.github.com>
Co-authored-by: telome <130504305+telome@users.noreply.github.com>

* deployNetwork => deployIlk

* initAllocator => initIlk

* More network => ilk renamings

* Alignment after renaming

* Add comment to verify nstJoin once in dss-test

* Set duty

* Switch to use class 5 in the registry

* Use contracts as interfaces in Deployment.t.sol

* Add missing check for collect

* Support multiple facilitators and keepers

* AllocatorConfig=>AllocatorIlkConfig

* Pass ilk explicitly to initIlk

* Creak the ilk's chainlog keys automaticaly

* Use ilk string as ilk resitry name and symbol

* Use bytes32ToStr to conserve dash in ilk registy names

* Update deploy/AllocatorDeploy.sol

Co-authored-by: sunbreak1211 <129470872+sunbreak1211@users.noreply.github.com>

* Fix return values

* Correct checking that PP is denied

* Use ScriptTools.switchOwner in AllocatorInit.sol

* better bytes32ToStr

* Do not use bytes32ToStr in test

* Add PIP chainlog entry per ilk

* Remove Allocator from CL keys

* Fetch vat from NstJoin (#59)

* Fetch vat from nst join

* nstJoin.vat() to return VatLike

---------

Co-authored-by: telome <130504305+telome@users.noreply.github.com>
Co-authored-by: sunbreak <sunbreak1211@proton.me>
Co-authored-by: sunbreak1211 <129470872+sunbreak1211@users.noreply.github.com>
* Use expected amounts in tests

* Apply suggestions from code review

Co-authored-by: sunbreak1211 <129470872+sunbreak1211@users.noreply.github.com>

* Update test/funnels/UniV3Utils.sol

Co-authored-by: sunbreak1211 <129470872+sunbreak1211@users.noreply.github.com>

* Revert changes to REF_TICK notation

* Align getExpectedAmounts with UniswapV3Pool code

* Remove unnecessary configs() read

* Update test/funnels/UniV3Utils.sol

Co-authored-by: sunbreak1211 <129470872+sunbreak1211@users.noreply.github.com>

* Use SafeCast to calculate liqDelta

* Test that amtMin can be > req

---------

Co-authored-by: telome <>
Co-authored-by: sunbreak1211 <129470872+sunbreak1211@users.noreply.github.com>
* Remove unused interface functions

* Roles: Use inbuilt bit negator

* Roles: more optimized way to shift bit

* StableSwapper: fix typo

* Fix SwapperCalleeUniV3 approve interface

* Add USDT swap test

* Rename ApproveLike -> GemLike

* Update test/funnels/callees/SwapperCalleeUniV3.t.sol

* Add fee to depositor events

* Enforce src == path[0] in callee

* Fix typos and clarify keeper's assumptions

* Audit fix additions (#64)

* Force ConduitMover to withdraw only lot

* Add clarification on Buffer-Conduits movement rate limiting responsibilities

* Minor changes

* Add comment on 0/0 division of divup (#65)

---------

Co-authored-by: telome <>
Co-authored-by: telome <130504305+telome@users.noreply.github.com>
Co-authored-by: oldchili <130549691+oldchili@users.noreply.github.com>
* Add SwapperCalleePsm

* Remove USDT swap tests

* Add tests for USDT PSM

* Add missing empty line

* Rename keg -> pocket

* Remove separate Pocket contract for PsmMock

* Update src/funnels/callees/SwapperCalleePsm.sol

Co-authored-by: sunbreak1211 <129470872+sunbreak1211@users.noreply.github.com>

* Update test/mocks/PsmMock.sol

Co-authored-by: sunbreak1211 <129470872+sunbreak1211@users.noreply.github.com>

---------

Co-authored-by: telome <>
Co-authored-by: sunbreak1211 <129470872+sunbreak1211@users.noreply.github.com>
* AllocatorOracle: 1 WAD price

* Add extra check

* Clear way to show number

* Add clarification in README

* Change constant name

* Fix aligment

* Add comment

* Update test/AllocatorOracle.t.sol

Co-authored-by: telome <130504305+telome@users.noreply.github.com>

---------

Co-authored-by: telome <130504305+telome@users.noreply.github.com>
* Test for Rely events in constructors + minor test re-arranging

* Fix SwapperCalleeUniV3Test

---------

Co-authored-by: telome <>
* Add VaultMinter automation contract

* Minor changes to tests

* Add VaultMinter to deployment scripts + other minor changes

* Fix some wording

* Fix events

* Update test/integration/Deployment.t.sol

Co-authored-by: oldchili <130549691+oldchili@users.noreply.github.com>

---------

Co-authored-by: oldchili <130549691+oldchili@users.noreply.github.com>
* Add initial set of Certora specs (WIP)

* Add pull_request for CI

* Fix Certora CI

* Fix syntax error

* Add new rules to Roles

* Apply modifications in spec for vault changes

* Swapper specs (WIP)

* Fix typo

* Swapper spec fixes

* Make some mock contracts more general

* More renaming of mocks

* Fix + more renaming

* More renaming

* Initial set of rules for DepositorUniV3

* Remove comment

* Swapper spec fixes

* Fix Swapper spec + Move some mocks + Add CI for Swapper and Depositor

* DepositorUniV3: deposit rule

* DepositorUniV3: deposit_revert rule

* DepositorUniV3: withdraw and withdraw_revert rules

* Fix mock

* DepositorUniV3: Check return values for deposit and withdraw (WIP)

* DepositorUniV3: add collect and collect_revert rules

* DepositorUniV3: add uniswapV3MintCallback and uniswapV3MintCallback_revert rules

* DepositorUniV3: add getPosition rule

* Add StableSwapper specs

* Use certora-cli beta for now due to a bug in production tool

* Add initial set of rules for StableDepositorUniV3 (WIP) + Missing CI for StableSwapper

* Vault: Remove init specs

* StableSwapper: Fix error messages

* StableDepositorUniV3: deposit, withdraw and collect rules

* StableDepositorUniV3: deposit_revert, withdraw_revert and collect_revert rules

* Solve timeout issue on Vault draw_revert rule + simplify run commands for other spec files

* CI: Use multi_assert_check to avoid timeout on draw_revert

* CI: Run only vault with multi_assert_check

* Vault: Minor change to draw_revert + add wipe and wipe_revert (wip as it is timing out)

* Fix error messages

Co-authored-by: telome <130504305+telome@users.noreply.github.com>

* Remove unnecessary assert

* Move some asserts to require as they are third party logic

* Check src balance for Swapper

* Variables renaming

* Add external call check for automation contracts

* Automation contracts: check all params are passed correctly

* Rename other variables

* Check address receiving call is correct

* Add ConduitMover spec (pending to finish move_revert)

* Finish ConduitMover

* Add counters

* Fix message

* Add --wait_for_results

* Update move_revert to latest changes

* Use config files (#68)

* Change AllocatorOracle spec due to code change

* Add rule for checking non corresponding storage keeps unchanged (#67)

* Add rule for checking non corresponding storage keeps unchanged

* Remove unused variables

* Test for Rely events in constructors + minor test re-arranging (#71)

* Test for Rely events in constructors + minor test re-arranging

* Fix SwapperCalleeUniV3Test

---------

Co-authored-by: telome <>

* Add VaultMinter automation contract (#70)

* Add VaultMinter automation contract

* Minor changes to tests

* Add VaultMinter to deployment scripts + other minor changes

* Fix some wording

* Fix events

* Update test/integration/Deployment.t.sol

Co-authored-by: oldchili <130549691+oldchili@users.noreply.github.com>

---------

Co-authored-by: oldchili <130549691+oldchili@users.noreply.github.com>

* Add VaultMinter specs

* Make reverts rules shorter using double implication

* Remove unnecessary lines

* Improve comment

* Remove other unnecessary line

---------

Co-authored-by: telome <130504305+telome@users.noreply.github.com>
Co-authored-by: oldchili <130549691+oldchili@users.noreply.github.com>
* SwapperCalleePsm: Prevent swap amts not multiple of to18ConversionFactor

* Remove requirement on SwapperCalleePsm amt

---------

Co-authored-by: telome <>
* split deploy/init scripts into core components and default funnels

* review fixes
@DaiFoundation-DevOps
Copy link

DaiFoundation-DevOps commented Aug 22, 2024

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants