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

feat(Cellar): add support for multiple positions and multiple assets #38

Merged
merged 73 commits into from
Jul 7, 2022
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
673aa92
feat(Cellar): add support for multiple positions and multiple assets
0xble Jun 17, 2022
a666f3f
Merge branch 'feat/cellar-architecture' of https://github.com/PeggyJV…
0xble Jun 17, 2022
65e0708
feat(Cellar): add ability for enterPosition to handle converting betw…
0xble Jun 17, 2022
ab1ebcd
perf(Cellar): add an internal getter function to fetch data efficiently
0xble Jun 17, 2022
e67a354
refactor(Cellar): initialize cellar with positions
0xble Jun 17, 2022
f7683f3
tests(Cellar): update test
0xble Jun 17, 2022
a584281
feat(Cellar): add ability to handle assets of different decimals
0xble Jun 17, 2022
ab301e3
build: add chainlink dependency
0xble Jun 20, 2022
8e3d393
feat(PriceRouter): add price router
0xble Jun 20, 2022
b923f42
fix(Cellar): fix stack errors, fix decimal conversions, optimize data…
0xble Jun 20, 2022
4bbb67d
refactor(PriceRouter): change getExchangeRate to return data in decim…
0xble Jun 20, 2022
f1792c6
refactor(Cellar): fix pullFromPositions logic
0xble Jun 20, 2022
f01ee46
feat(Mocks): add mock price router
0xble Jun 20, 2022
e098b84
tests(Cellar): add test for withdrawFromPositions
0xble Jun 22, 2022
2d5e083
Merge branch 'main' of https://github.com/PeggyJV/cellar-contracts in…
crispymangoes Jun 23, 2022
519e7a9
Merge branch 'main' of https://github.com/PeggyJV/cellar-contracts in…
crispymangoes Jun 23, 2022
3e1dcb0
build: change remaining 0.8.13 to 0.8.15
crispymangoes Jun 23, 2022
6b80a03
fix(CellarRouter): withdrawFromPositionsIntoSingleAsset failed compil…
crispymangoes Jun 23, 2022
8be75ad
test(CellarRouter): add tests to Cellar.t.sol to check that withdrawi…
crispymangoes Jun 24, 2022
c46168f
Merge branch 'feat/cellar-architecture' of https://github.com/PeggyJV…
crispymangoes Jun 24, 2022
70a02d2
style(SwapRouter): removed unused code
crispymangoes Jun 24, 2022
d6b2e4b
Merge branch 'feat/cellar-architecture' of https://github.com/PeggyJV…
crispymangoes Jun 24, 2022
8847727
Merge branch 'feat/cellar-architecture' of https://github.com/PeggyJV…
0xble Jun 26, 2022
de4272a
feat(SwapRouter): add `multiSwap` function to allow for swaps at mult…
crispymangoes Jun 27, 2022
c83e52b
docs(CellarRouter): updated natspec for `withdrawFromPositionsIntoSin…
crispymangoes Jun 27, 2022
955af79
style(SwapRouter): remove unused console and test import
crispymangoes Jun 27, 2022
efef140
refactor(Cellar): merge enterPosition and exitPosition into rebalance…
0xble Jun 27, 2022
7270309
tests(Cellar): add test for accrue
0xble Jun 27, 2022
7a68af2
build: add remapping for ds-test
0xble Jun 27, 2022
5aed477
Merge branch 'feat/multiposition-multiasset' of https://github.com/Pe…
crispymangoes Jun 27, 2022
feafada
Merge branch 'feat/cellar-architecture' of https://github.com/PeggyJV…
0xble Jun 27, 2022
7061ec9
Merge branch 'feat/multiposition-multiasset' of https://github.com/Pe…
crispymangoes Jun 27, 2022
ce8cbf7
feat(PositionLib): add PositionLib to handle differing function calls…
crispymangoes Jun 27, 2022
2aff300
Merge branch 'feat/multiposition-multiasset' of https://github.com/Pe…
crispymangoes Jun 27, 2022
21fca78
tests(Cellar): add test for rebalance
0xble Jun 27, 2022
88cc81a
test(CellarRouter): move withdrawIntoSingleAsset tests from Cellar.t.…
crispymangoes Jun 27, 2022
c189ea0
tests(Cellar): add test for high watermark
0xble Jun 27, 2022
c7705a6
feat(Cellar): add ability to withdraw from all positions in proportion
0xble Jun 27, 2022
81e74c2
Merge branch 'feat/multiposition-multiasset' of https://github.com/Pe…
0xble Jun 27, 2022
a1d7c25
feat(Cellar): use PositionLib to allow for positions in ERC20, ERC462…
crispymangoes Jun 27, 2022
6e1c851
Merge branch 'feat/multiposition-multiasset' of https://github.com/Pe…
0xble Jun 28, 2022
7b5466e
refactor(Cellar): rewrite withdraw logic, reimplement holding pool as…
0xble Jun 28, 2022
fc3f957
refactor(PositionLib): revise library functions
0xble Jun 28, 2022
c71a9c5
fix(SwapRouter): from address is now checked to ensure attackers can'…
crispymangoes Jun 28, 2022
0bd9e0a
Merge branch 'feat/support-erc20-positions' of https://github.com/Peg…
0xble Jun 29, 2022
5f53365
refactor(CellarRouter): refactor cellar router to use the swap router
crispymangoes Jun 29, 2022
95c9558
refactor(CellarRouter): allow withdrawing and swapping into multiple …
0xble Jun 30, 2022
ba900d2
Merge branch 'feat/withdraw-into-single-asset' of https://github.com/…
0xble Jun 30, 2022
528a37d
fix(CellarRouter): missed approve calls before swaps, so tests were f…
crispymangoes Jun 30, 2022
6cf519b
Merge branch 'feat/withdraw-into-single-asset' of https://github.com/…
crispymangoes Jun 30, 2022
442b12e
Merge branch 'feat/multiposition-multiasset' of https://github.com/Pe…
crispymangoes Jun 30, 2022
cc62459
refactory(CellarRouter): use swap router in cellar router
crispymangoes Jun 30, 2022
a5fc988
Merge branch 'feat/cellar-architecture' of https://github.com/PeggyJV…
crispymangoes Jul 1, 2022
d64a11a
refactor(Cellar): change cellar swap function to work with new swap r…
crispymangoes Jul 1, 2022
ea8e5dc
Merge branch 'feat/cellar-architecture' of https://github.com/PeggyJV…
crispymangoes Jul 5, 2022
9af9be6
Merge branch 'feat/cellar-architecture' of https://github.com/PeggyJV…
0xble Jul 5, 2022
c310993
Merge branch 'feat/multiposition-multiasset' of https://github.com/Pe…
0xble Jul 5, 2022
efb0ce0
chore: remove old TODOs
0xble Jul 5, 2022
53a549a
refactor(Cellar): remove withdrawFromPositions function
0xble Jul 5, 2022
db0aba2
Merge branch 'feat/multiposition-multiasset' of https://github.com/Pe…
0xble Jul 6, 2022
9d414a9
Merge branch 'feat/multiposition-multiasset' of https://github.com/Pe…
0xble Jul 6, 2022
d276d46
style(Swap/PriceRouter): add in natspec comments and titles
crispymangoes Jul 6, 2022
6777b67
refactor(CellarRouter): combine withdrawAndSwap with withdrawFromAndSwap
0xble Jul 6, 2022
a4ea100
Merge branch 'feat/multiposition-multiasset' of https://github.com/Pe…
0xble Jul 6, 2022
ce243bb
docs: fix typos in contract natspec
0xble Jul 6, 2022
2b1940e
docs: fix natspec in PriceRouter and SwapRouter
0xble Jul 6, 2022
b2b2c5f
docs: fix natspec title of PriceRouter and SwapRouter
0xble Jul 6, 2022
b37cf19
docs(Cellar): add natspec
0xble Jul 6, 2022
bcb8f9f
tests(Cellar): fix build errors
0xble Jul 6, 2022
87aa5e3
docs(CellarRouter): fix natspec, and add natspec to cellar router
crispymangoes Jul 6, 2022
2b49b0a
Merge branch 'style/clean-up-swap-and-price-router' of https://github…
crispymangoes Jul 6, 2022
057d0f1
docs(CellarRouter): fix natspec in cellar router
crispymangoes Jul 6, 2022
2dcd6d0
docs(CellarRouter): revise contract natspec
0xble Jul 7, 2022
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
1 change: 1 addition & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@solmate/=lib/solmate/src/
@forge-std/=lib/forge-std/src/
@ds-test/=lib/forge-std/lib/ds-test/src/
ds-test/=lib/forge-std/lib/ds-test/src/
@openzeppelin/=lib/openzeppelin-contracts/
@uniswap/v3-periphery/=lib/v3-periphery/
@uniswap/v3-core/=lib/v3-core/
Expand Down
337 changes: 142 additions & 195 deletions src/CellarRouter.sol

Large diffs are not rendered by default.

28 changes: 21 additions & 7 deletions src/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -144,19 +144,26 @@ error USR_ZeroRewardsPerEpoch();
*/
error USR_InvalidLockValue(uint256 lock);

/**
* @notice Attempted to trust a position that had an incompatible underlying asset.
* @param incompatibleAsset address of the asset is incompatible with the asset of this cellar
* @param expectedAsset address of the cellar's underlying asset
*/
error USR_IncompatiblePosition(address incompatibleAsset, address expectedAsset);

/**
* @notice Attempted to add a position that is already being used.
* @param position address of the position
*/
error USR_PositionAlreadyUsed(address position);

/**
* @notice Attempted an action on a position that is not being used by the cellar but must be for
* the operation to succeed.
* @param position address of the invalid position
*/
error USR_InvalidPosition(address position);

/**
* @notice Attempted an action on a position that is required to be empty before the action can be performed.
* @param position address of the non-empty position
* @param sharesRemaining amount of shares remaining in the position
*/
error USR_PositionNotEmpty(address position, uint256 sharesRemaining);

/**
* @notice Attempted an operation with arrays of unequal lengths that were expected to be equal length.
*/
Expand All @@ -169,6 +176,13 @@ error USR_LengthMismatch();
*/
error USR_InvalidSignature(uint256 signatureLength, uint256 expectedSignatureLength);

/**
* @notice Attempted an operation with an asset that was different then the one expected.
* @param asset address of the asset
* @param expectedAsset address of the expected asset
*/
error USR_AssetMismatch(address asset, address expectedAsset);

/**
* @notice Attempted to reassign the address of a contract with an ID that has not been registered.
* @param unregisteredId value of the ID that has not been registered
Expand Down
Loading