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

Refactor price logic #192

Merged
merged 2 commits into from
Oct 24, 2023
Merged

Refactor price logic #192

merged 2 commits into from
Oct 24, 2023

Conversation

hieronx
Copy link
Contributor

@hieronx hieronx commented Oct 23, 2023

No description provided.

@hieronx hieronx requested review from ilinzweilin and AStox October 23, 2023 19:11
Copy link
Contributor

@NunoAlexandre NunoAlexandre left a comment

Choose a reason for hiding this comment

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

LGMT 👌

test/PoolManager.t.sol Outdated Show resolved Hide resolved
mapping(address liquidityPool => TrancheTokenPrice) prices;
}

struct TrancheTokenPrice {
Copy link
Contributor

Choose a reason for hiding this comment

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

👌

@hieronx hieronx changed the base branch from review to review2 October 24, 2023 09:55
@github-actions
Copy link

Coverage after merging price-changes into review2 will be

81.59%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   Escrow.sol100%100%100%100%
   InvestmentManager.sol90.94%68.33%97.22%98.10%165, 169, 174, 203, 207, 245, 271, 321, 352, 428, 434–435, 463, 473, 499–500, 543, 545, 588–589, 648–649
   LiquidityPool.sol95.08%80%97.30%98.46%175, 187, 204, 208, 267
   PoolManager.sol94.09%82.86%100%99.22%177, 193, 219, 230, 248, 308, 316, 328, 333, 348, 359, 464, 466
   Root.sol100%100%100%100%
   UserEscrow.sol100%100%100%100%
src/admins
   DelayedAdmin.sol100%100%100%100%
   PauseAdmin.sol100%100%100%100%
src/gateway
   Gateway.sol94.59%83.33%100%98.88%329, 341, 353, 366, 379, 382, 398, 405
   Messages.sol62.77%16.67%60.47%65.38%105, 124, 153, 194, 202, 237, 282–285, 381, 389–393, 417, 425, 449, 457, 481, 489, 509, 517–520, 540, 548–551, 562, 605, 649, 696, 735, 747, 773, 810–813, 829–832, 843, 86, 869, 892, 922, 953–954, 956–957, 957, 957–958, 960, 964, 968, 985–986, 986, 986–987, 991
src/gateway/routers/axelar
   Router.sol100%100%100%100%
src/gateway/routers/xcm
   Router.sol0%0%0%0%103, 103, 103–104, 106, 109, 114, 119, 121, 123, 142, 157, 157, 157–159, 159, 159, 161–162, 162, 162–164, 164, 164–166, 166, 166–168, 168, 168–170, 170, 170–172, 172, 172–173, 175, 182–183, 185, 189–191, 193, 197, 90, 90, 90–91, 93, 96
src/token
   ERC20.sol95.42%92.86%92.86%97.33%199, 228, 67, 85–86
   RestrictionManager.sol97.30%91.67%100%100%86
   Tranche.sol91.18%100%75%100%
src/util
   Auth.sol100%100%100%100%
   BytesLib.sol0%0%0%0%10, 10, 10, 102, 102, 102–103, 106, 109, 11, 11, 11, 113, 113, 113–114, 117, 120, 124, 124, 124–125, 128, 13, 131, 65, 69, 69, 69–70, 73, 76, 80, 80, 80–81, 84, 87, 91, 91, 91–92, 95, 98
   Factory.sol100%100%100%100%
   MathLib.sol0%0%0%0%105–106, 106, 106–107, 109, 114, 114, 114–115, 117, 24–25, 28–29, 33, 33, 33, 37, 41, 41, 41, 48, 51, 54–55, 63, 66, 69, 72, 76, 81, 86–91, 97–98
   SafeTransferLib.sol87.50%66.67%100%100%28, 38

Copy link
Contributor

@NunoAlexandre NunoAlexandre left a comment

Choose a reason for hiding this comment

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

@hieronx hieronx merged commit 296bdf6 into review2 Oct 24, 2023
@hieronx hieronx deleted the price-changes branch October 24, 2023 13:46
hieronx added a commit that referenced this pull request Oct 26, 2023
* fix: add tranche (#180)

* Align approval flow and interface with EIP draft (#178)

* Explore new approval flow

* Fix permit logic

* Allowance checks

* Remove fee-on-transfer support

* Fix revert message

* Fix tests

* Remove unused function from interface

* Fix comment

* Naming

* Remove console

* Remove duplicate transfer from function

* Fix balance check

* Add operator param

* Align naming of view functions

* Address pr comments

* disallow freezing the zero address (#181)

* Fix permit fr with lower asset amounts (#183)

* fix frontrunning with smaller asset amounts with permits

* add test condition

Signed-off-by: ilin <[email protected]>

---------

Signed-off-by: ilin <[email protected]>

* Make restrictionManagerFactory mutable on PoolManager (#182)

* Make restrictionManagerFactory mutable on PoolManager

* group RestrictionManagerFactory with other public vars

* Preview methods should revert (#186)

* Remove preview methods from investment mgr

* Add comment

* Format

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

---------

Co-authored-by: Adam Stox <[email protected]>

* Add IERC7540 (#190)

* Add IERC7540

* Update interface

* Update ERC-20 interfaces

* Fix comment

* Skip slither step

* Fix price calculation issue on decrease executions (#184)

* Add test for failing price conversion on decrease

* Attempt to fix conversions

* Automatically claim deposits on trigger request redeem (#187)

* Automatically claim deposits on trigger request redeem

* trigger redemptions when user still has tokens in escrow (#189)

* trigger redemptions when user still has tokens in escrow

Signed-off-by: ilin <[email protected]>

* fix comments

Signed-off-by: ilin <[email protected]>

* add fixes from review

* add fixes from review

* add fixes from review

---------

Signed-off-by: ilin <[email protected]>

---------

Signed-off-by: ilin <[email protected]>
Co-authored-by: Alina Sinelnikova <[email protected]>

* fix permit (#195)

* fix permit

* consolidate code

* fmt

* remove redundant require from permitted deposit request

* Refactor price logic (#192)

* Refactor price logic

* Remove redundant comments

* Check transfer restriction on request redeem (#193)

* Check transfer restriction on request redeem

* Fix

* Format

* Freeze check both directions

* Fix test

* Change member checks

* Update checks again

* Revert cancel rely if no target is scheduled (#197)

* Check price is newer (#198)

---------

Signed-off-by: ilin <[email protected]>
Co-authored-by: Alina Sinelnikova <[email protected]>
Co-authored-by: Adam Stox <[email protected]>
hieronx added a commit that referenced this pull request Oct 26, 2023
* fix: add tranche (#180)

* Align approval flow and interface with EIP draft (#178)

* Explore new approval flow

* Fix permit logic

* Allowance checks

* Remove fee-on-transfer support

* Fix revert message

* Fix tests

* Remove unused function from interface

* Fix comment

* Naming

* Remove console

* Remove duplicate transfer from function

* Fix balance check

* Add operator param

* Align naming of view functions

* Address pr comments

* disallow freezing the zero address (#181)

* Fix permit fr with lower asset amounts (#183)

* fix frontrunning with smaller asset amounts with permits

* add test condition

Signed-off-by: ilin <[email protected]>

---------

Signed-off-by: ilin <[email protected]>

* Make restrictionManagerFactory mutable on PoolManager (#182)

* Make restrictionManagerFactory mutable on PoolManager

* group RestrictionManagerFactory with other public vars

* Preview methods should revert (#186)

* Remove preview methods from investment mgr

* Add comment

* Format

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

---------

Co-authored-by: Adam Stox <[email protected]>

* Add IERC7540 (#190)

* Add IERC7540

* Update interface

* Update ERC-20 interfaces

* Fix comment

* Skip slither step

* Fix price calculation issue on decrease executions (#184)

* Add test for failing price conversion on decrease

* Attempt to fix conversions

* Automatically claim deposits on trigger request redeem (#187)

* Automatically claim deposits on trigger request redeem

* trigger redemptions when user still has tokens in escrow (#189)

* trigger redemptions when user still has tokens in escrow

Signed-off-by: ilin <[email protected]>

* fix comments

Signed-off-by: ilin <[email protected]>

* add fixes from review

* add fixes from review

* add fixes from review

---------

Signed-off-by: ilin <[email protected]>

---------

Signed-off-by: ilin <[email protected]>
Co-authored-by: Alina Sinelnikova <[email protected]>

* Add ERC165 support

* fix permit (#195)

* fix permit

* consolidate code

* fmt

* remove redundant require from permitted deposit request

* Refactor price logic (#192)

* Refactor price logic

* Remove redundant comments

* Fix comments

* Check transfer restriction on request redeem (#193)

* Check transfer restriction on request redeem

* Fix

* Format

* Freeze check both directions

* Fix test

* Change member checks

* Update checks again

* Change interfaces

* Revert cancel rely if no target is scheduled (#197)

* Check price is newer (#198)

* Fix approve in test setup

* Fix redundant investment mgr deployment

* Update interface style

* Format

* Fix pool manager typo

* Undo

---------

Signed-off-by: ilin <[email protected]>
Co-authored-by: Alina Sinelnikova <[email protected]>
Co-authored-by: Adam Stox <[email protected]>
hieronx added a commit that referenced this pull request Oct 30, 2023
* fix: add tranche (#180)

* Align approval flow and interface with EIP draft (#178)

* Explore new approval flow

* Fix permit logic

* Allowance checks

* Remove fee-on-transfer support

* Fix revert message

* Fix tests

* Remove unused function from interface

* Fix comment

* Naming

* Remove console

* Remove duplicate transfer from function

* Fix balance check

* Add operator param

* Align naming of view functions

* Address pr comments

* disallow freezing the zero address (#181)

* Fix permit fr with lower asset amounts (#183)

* fix frontrunning with smaller asset amounts with permits

* add test condition

Signed-off-by: ilin <[email protected]>

---------

Signed-off-by: ilin <[email protected]>

* Make restrictionManagerFactory mutable on PoolManager (#182)

* Make restrictionManagerFactory mutable on PoolManager

* group RestrictionManagerFactory with other public vars

* Preview methods should revert (#186)

* Remove preview methods from investment mgr

* Add comment

* Format

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

---------

Co-authored-by: Adam Stox <[email protected]>

* Add IERC7540 (#190)

* Add IERC7540

* Update interface

* Update ERC-20 interfaces

* Fix comment

* Skip slither step

* Fix price calculation issue on decrease executions (#184)

* Add test for failing price conversion on decrease

* Attempt to fix conversions

* Automatically claim deposits on trigger request redeem (#187)

* Automatically claim deposits on trigger request redeem

* trigger redemptions when user still has tokens in escrow (#189)

* trigger redemptions when user still has tokens in escrow

Signed-off-by: ilin <[email protected]>

* fix comments

Signed-off-by: ilin <[email protected]>

* add fixes from review

* add fixes from review

* add fixes from review

---------

Signed-off-by: ilin <[email protected]>

---------

Signed-off-by: ilin <[email protected]>
Co-authored-by: Alina Sinelnikova <[email protected]>

* Fix event callers (#191)

* fix permit (#195)

* fix permit

* consolidate code

* fmt

* remove redundant require from permitted deposit request

* Refactor price logic (#192)

* Refactor price logic

* Remove redundant comments

* Check transfer restriction on request redeem (#193)

* Check transfer restriction on request redeem

* Fix

* Format

* Freeze check both directions

* Fix test

* Change member checks

* Update checks again

* Revert cancel rely if no target is scheduled (#197)

* Check price is newer (#198)

* PoolManager events

* Add 7540 reference to readme

* Update image

* Reorganize methods in liquidity pool

* Reorder more

* Use inheritdoc to extend comments in liquidity pool contract

* Public => external

* Reordering

---------

Signed-off-by: ilin <[email protected]>
Co-authored-by: Alina Sinelnikova <[email protected]>
Co-authored-by: Adam Stox <[email protected]>
hieronx added a commit that referenced this pull request Jan 4, 2024
* Start adding convert invariant

* Remove collect functions, remove sanity checks for incoming calls, fix price conversion

* Remove deposit/redeem price calculations

* Add redeem request internal method

* Simplify convert methods

* Remove some comments

* Fix tests

* More simplfications

* Fix tests

* Fix typo

* Fixes

* Simplify math

* Simplify LP lookups

* Remove internal touint128 in test

* Consistent naming

* Rename lp values / orderbook to investment state

* Fix price type

* Fix convert invariants, add maxdeposit/redeem invariants

* Start adapting investor handler to support multiple investors

* Set 2 investors

* Set up base handler

* fix: add tranche (#180)

* Align approval flow and interface with EIP draft (#178)

* Explore new approval flow

* Fix permit logic

* Allowance checks

* Remove fee-on-transfer support

* Fix revert message

* Fix tests

* Remove unused function from interface

* Fix comment

* Naming

* Remove console

* Remove duplicate transfer from function

* Fix balance check

* Add operator param

* Align naming of view functions

* Address pr comments

* disallow freezing the zero address (#181)

* Fix permit fr with lower asset amounts (#183)

* fix frontrunning with smaller asset amounts with permits

* add test condition

Signed-off-by: ilin <[email protected]>

---------

Signed-off-by: ilin <[email protected]>

* Make restrictionManagerFactory mutable on PoolManager (#182)

* Make restrictionManagerFactory mutable on PoolManager

* group RestrictionManagerFactory with other public vars

* Preview methods should revert (#186)

* Remove preview methods from investment mgr

* Add comment

* Format

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

---------

Co-authored-by: Adam Stox <[email protected]>

* Add IERC7540 (#190)

* Add IERC7540

* Update interface

* Update ERC-20 interfaces

* Fix comment

* Skip slither step

* Fix price calculation issue on decrease executions (#184)

* Add test for failing price conversion on decrease

* Attempt to fix conversions

* Automatically claim deposits on trigger request redeem (#187)

* Automatically claim deposits on trigger request redeem

* trigger redemptions when user still has tokens in escrow (#189)

* trigger redemptions when user still has tokens in escrow

Signed-off-by: ilin <[email protected]>

* fix comments

Signed-off-by: ilin <[email protected]>

* add fixes from review

* add fixes from review

* add fixes from review

---------

Signed-off-by: ilin <[email protected]>

---------

Signed-off-by: ilin <[email protected]>
Co-authored-by: Alina Sinelnikova <[email protected]>

* Work on multiple pools

* Fix multiple pool setup

* Fix investor handler

* Start working on decrease

* Work on executing decrease invest orders

* Work on kv store in handler base

* fix permit (#195)

* fix permit

* consolidate code

* fmt

* remove redundant require from permitted deposit request

* Refactor price logic (#192)

* Refactor price logic

* Remove redundant comments

* Check transfer restriction on request redeem (#193)

* Check transfer restriction on request redeem

* Fix

* Format

* Freeze check both directions

* Fix test

* Change member checks

* Update checks again

* Revert cancel rely if no target is scheduled (#197)

* Check price is newer (#198)

* Fix key type

* Clean up

* Reorganize unit tests

* More renames

* Rename invariant test folder

* Fix imports

* Add price invariants

* Disable fork tests for now

* Fix old imports, typo

* Clean up

* Currency setup

* Remove handler

* Fix build

* Move tests

* Env var for fork tests

* Clean up fork & integration tests

* Rename

* Set up cross-chain fork tests

* Add admin signer setup

* Remove foundry rpc urls

* Clean up

* Move around

* Add CI for fork tests

* Update celo messages

* Add deployment info

* Move spells

* Determinism check

* Set up testnet support

* Format

* Remove redundant rpc urls

* Cron job for fork tests

* Remove duplicated code

* Add mathlib and safetransferlib tests

* Fix typo

* Reorganize

* Format

* Clean up folder structure

* More renames

* Delete duplicate files

* Remove xcm router

* Remove old import

* Remove unused param

* Add forwarder test

* Add BytesLib test

* Typo

* Revert

* Add investment manager tests

* Add more tests

* Re-enable

* Ad some more unit tests

* 2 more

* Add more sanity check tests

* Rename

* Add more

* Add allowed currency for requestRedeem check

* Fix compilation

* Reduce params

* Fix ci path

* Fix another ci path

* Remove unused ci code

* Refactor shadow var handling

* Format

* Fix slow builds

* Exclude invariant tests from code cov

* Remove more merge conflict issues

* Add old metadata check

* Fix typo

* Disable some invariants for now

* Include invariant tests in coverage again

---------

Signed-off-by: ilin <[email protected]>
Co-authored-by: Alina Sinelnikova <[email protected]>
Co-authored-by: Adam Stox <[email protected]>
hieronx added a commit that referenced this pull request Jan 4, 2024
* Start adding convert invariant

* Remove collect functions, remove sanity checks for incoming calls, fix price conversion

* Remove deposit/redeem price calculations

* Add redeem request internal method

* Simplify convert methods

* Remove some comments

* Fix tests

* More simplfications

* Fix tests

* Fix typo

* Fixes

* Simplify math

* Simplify LP lookups

* Remove internal touint128 in test

* Consistent naming

* Rename lp values / orderbook to investment state

* Fix price type

* Fix convert invariants, add maxdeposit/redeem invariants

* Start adapting investor handler to support multiple investors

* Set 2 investors

* Set up base handler

* fix: add tranche (#180)

* Align approval flow and interface with EIP draft (#178)

* Explore new approval flow

* Fix permit logic

* Allowance checks

* Remove fee-on-transfer support

* Fix revert message

* Fix tests

* Remove unused function from interface

* Fix comment

* Naming

* Remove console

* Remove duplicate transfer from function

* Fix balance check

* Add operator param

* Align naming of view functions

* Address pr comments

* disallow freezing the zero address (#181)

* Fix permit fr with lower asset amounts (#183)

* fix frontrunning with smaller asset amounts with permits

* add test condition

Signed-off-by: ilin <[email protected]>

---------

Signed-off-by: ilin <[email protected]>

* Make restrictionManagerFactory mutable on PoolManager (#182)

* Make restrictionManagerFactory mutable on PoolManager

* group RestrictionManagerFactory with other public vars

* Preview methods should revert (#186)

* Remove preview methods from investment mgr

* Add comment

* Format

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

---------

Co-authored-by: Adam Stox <[email protected]>

* Add IERC7540 (#190)

* Add IERC7540

* Update interface

* Update ERC-20 interfaces

* Fix comment

* Skip slither step

* Fix price calculation issue on decrease executions (#184)

* Add test for failing price conversion on decrease

* Attempt to fix conversions

* Automatically claim deposits on trigger request redeem (#187)

* Automatically claim deposits on trigger request redeem

* trigger redemptions when user still has tokens in escrow (#189)

* trigger redemptions when user still has tokens in escrow

Signed-off-by: ilin <[email protected]>

* fix comments

Signed-off-by: ilin <[email protected]>

* add fixes from review

* add fixes from review

* add fixes from review

---------

Signed-off-by: ilin <[email protected]>

---------

Signed-off-by: ilin <[email protected]>
Co-authored-by: Alina Sinelnikova <[email protected]>

* Work on multiple pools

* Fix multiple pool setup

* Fix investor handler

* Start working on decrease

* Work on executing decrease invest orders

* Work on kv store in handler base

* fix permit (#195)

* fix permit

* consolidate code

* fmt

* remove redundant require from permitted deposit request

* Refactor price logic (#192)

* Refactor price logic

* Remove redundant comments

* Check transfer restriction on request redeem (#193)

* Check transfer restriction on request redeem

* Fix

* Format

* Freeze check both directions

* Fix test

* Change member checks

* Update checks again

* Revert cancel rely if no target is scheduled (#197)

* Check price is newer (#198)

* Fix key type

* Clean up

* Reorganize unit tests

* More renames

* Rename invariant test folder

* Fix imports

* Add price invariants

* Disable fork tests for now

* Fix old imports, typo

* Clean up

* Currency setup

* Remove handler

* Fix build

* Move tests

* Env var for fork tests

* Clean up fork & integration tests

* Rename

* Set up cross-chain fork tests

* Add admin signer setup

* Remove foundry rpc urls

* Clean up

* Move around

* Add CI for fork tests

* Update celo messages

* Add deployment info

* Move spells

* Determinism check

* Set up testnet support

* Format

* Remove redundant rpc urls

* Cron job for fork tests

* Remove duplicated code

* Add mathlib and safetransferlib tests

* Fix typo

* Reorganize

* Format

* Clean up folder structure

* More renames

* Delete duplicate files

* Remove xcm router

* Remove old import

* Remove unused param

* Add forwarder test

* Add BytesLib test

* Typo

* Revert

* Add investment manager tests

* Add more tests

* Re-enable

* Ad some more unit tests

* 2 more

* Add more sanity check tests

* Rename

* Add more

* Add allowed currency for requestRedeem check

* Fix compilation

* Reduce params

* Fix ci path

* Fix another ci path

* Remove unused ci code

* Refactor shadow var handling

* Format

* Fix slow builds

* Exclude invariant tests from code cov

* Remove more merge conflict issues

* Add old metadata check

* Fix typo

* Simplify Axelar router

* Disable some invariants for now

* Include invariant tests in coverage again

---------

Signed-off-by: ilin <[email protected]>
Co-authored-by: Alina Sinelnikova <[email protected]>
Co-authored-by: Adam Stox <[email protected]>
hieronx added a commit that referenced this pull request Jan 5, 2024
* Start adding convert invariant

* Remove collect functions, remove sanity checks for incoming calls, fix price conversion

* Remove deposit/redeem price calculations

* Add redeem request internal method

* Simplify convert methods

* Remove some comments

* Fix tests

* More simplfications

* Fix tests

* Fix typo

* Fixes

* Simplify math

* Simplify LP lookups

* Remove internal touint128 in test

* Consistent naming

* Rename lp values / orderbook to investment state

* Fix price type

* Fix convert invariants, add maxdeposit/redeem invariants

* Start adapting investor handler to support multiple investors

* Set 2 investors

* Set up base handler

* fix: add tranche (#180)

* Align approval flow and interface with EIP draft (#178)

* Explore new approval flow

* Fix permit logic

* Allowance checks

* Remove fee-on-transfer support

* Fix revert message

* Fix tests

* Remove unused function from interface

* Fix comment

* Naming

* Remove console

* Remove duplicate transfer from function

* Fix balance check

* Add operator param

* Align naming of view functions

* Address pr comments

* disallow freezing the zero address (#181)

* Fix permit fr with lower asset amounts (#183)

* fix frontrunning with smaller asset amounts with permits

* add test condition

Signed-off-by: ilin <[email protected]>

---------

Signed-off-by: ilin <[email protected]>

* Make restrictionManagerFactory mutable on PoolManager (#182)

* Make restrictionManagerFactory mutable on PoolManager

* group RestrictionManagerFactory with other public vars

* Preview methods should revert (#186)

* Remove preview methods from investment mgr

* Add comment

* Format

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

---------

Co-authored-by: Adam Stox <[email protected]>

* Add IERC7540 (#190)

* Add IERC7540

* Update interface

* Update ERC-20 interfaces

* Fix comment

* Skip slither step

* Fix price calculation issue on decrease executions (#184)

* Add test for failing price conversion on decrease

* Attempt to fix conversions

* Automatically claim deposits on trigger request redeem (#187)

* Automatically claim deposits on trigger request redeem

* trigger redemptions when user still has tokens in escrow (#189)

* trigger redemptions when user still has tokens in escrow

Signed-off-by: ilin <[email protected]>

* fix comments

Signed-off-by: ilin <[email protected]>

* add fixes from review

* add fixes from review

* add fixes from review

---------

Signed-off-by: ilin <[email protected]>

---------

Signed-off-by: ilin <[email protected]>
Co-authored-by: Alina Sinelnikova <[email protected]>

* Work on multiple pools

* Fix multiple pool setup

* Fix investor handler

* Start working on decrease

* Work on executing decrease invest orders

* Work on kv store in handler base

* fix permit (#195)

* fix permit

* consolidate code

* fmt

* remove redundant require from permitted deposit request

* Refactor price logic (#192)

* Refactor price logic

* Remove redundant comments

* Check transfer restriction on request redeem (#193)

* Check transfer restriction on request redeem

* Fix

* Format

* Freeze check both directions

* Fix test

* Change member checks

* Update checks again

* Revert cancel rely if no target is scheduled (#197)

* Check price is newer (#198)

* Fix key type

* Clean up

* Reorganize unit tests

* More renames

* Rename invariant test folder

* Fix imports

* Add price invariants

* Disable fork tests for now

* Fix old imports, typo

* Clean up

* Currency setup

* Remove handler

* Fix build

* Move tests

* Env var for fork tests

* Clean up fork & integration tests

* Rename

* Set up cross-chain fork tests

* Add admin signer setup

* Remove foundry rpc urls

* Clean up

* Move around

* Add CI for fork tests

* Update celo messages

* Add deployment info

* Move spells

* Determinism check

* Set up testnet support

* Format

* Remove redundant rpc urls

* Cron job for fork tests

* Remove duplicated code

* Add mathlib and safetransferlib tests

* Fix typo

* Reorganize

* Format

* Clean up folder structure

* More renames

* Delete duplicate files

* Remove xcm router

* Remove old import

* Remove unused param

* Add forwarder test

* Add BytesLib test

* Typo

* Revert

* Add investment manager tests

* Add more tests

* Re-enable

* Ad some more unit tests

* 2 more

* Add more sanity check tests

* Rename

* Add more

* Add allowed currency for requestRedeem check

* Fix compilation

* Reduce params

* Fix ci path

* Fix another ci path

* Remove unused ci code

* Refactor shadow var handling

* Format

* Fix slow builds

* Exclude invariant tests from code cov

* Remove more merge conflict issues

* Add old metadata check

* Fix typo

* Simplify Axelar router

* Disable some invariants for now

* Include invariant tests in coverage again

* Remove LP.transferFrom and LP.decimals methods

---------

Signed-off-by: ilin <[email protected]>
Co-authored-by: Alina Sinelnikova <[email protected]>
Co-authored-by: Adam Stox <[email protected]>
hieronx added a commit that referenced this pull request Feb 15, 2024
* Start adding convert invariant

* Remove collect functions, remove sanity checks for incoming calls, fix price conversion

* Remove deposit/redeem price calculations

* Add redeem request internal method

* Simplify convert methods

* Remove some comments

* Fix tests

* More simplfications

* Fix tests

* Fix typo

* Fixes

* Simplify math

* Simplify LP lookups

* Remove internal touint128 in test

* Consistent naming

* Rename lp values / orderbook to investment state

* Fix price type

* Fix convert invariants, add maxdeposit/redeem invariants

* Start adapting investor handler to support multiple investors

* Set 2 investors

* Set up base handler

* fix: add tranche (#180)

* Align approval flow and interface with EIP draft (#178)

* Explore new approval flow

* Fix permit logic

* Allowance checks

* Remove fee-on-transfer support

* Fix revert message

* Fix tests

* Remove unused function from interface

* Fix comment

* Naming

* Remove console

* Remove duplicate transfer from function

* Fix balance check

* Add operator param

* Align naming of view functions

* Address pr comments

* disallow freezing the zero address (#181)

* Fix permit fr with lower asset amounts (#183)

* fix frontrunning with smaller asset amounts with permits

* add test condition

Signed-off-by: ilin <[email protected]>

---------

Signed-off-by: ilin <[email protected]>

* Make restrictionManagerFactory mutable on PoolManager (#182)

* Make restrictionManagerFactory mutable on PoolManager

* group RestrictionManagerFactory with other public vars

* Preview methods should revert (#186)

* Remove preview methods from investment mgr

* Add comment

* Format

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

---------

Co-authored-by: Adam Stox <[email protected]>

* Add IERC7540 (#190)

* Add IERC7540

* Update interface

* Update ERC-20 interfaces

* Fix comment

* Skip slither step

* Fix price calculation issue on decrease executions (#184)

* Add test for failing price conversion on decrease

* Attempt to fix conversions

* Automatically claim deposits on trigger request redeem (#187)

* Automatically claim deposits on trigger request redeem

* trigger redemptions when user still has tokens in escrow (#189)

* trigger redemptions when user still has tokens in escrow

Signed-off-by: ilin <[email protected]>

* fix comments

Signed-off-by: ilin <[email protected]>

* add fixes from review

* add fixes from review

* add fixes from review

---------

Signed-off-by: ilin <[email protected]>

---------

Signed-off-by: ilin <[email protected]>
Co-authored-by: Alina Sinelnikova <[email protected]>

* Work on multiple pools

* Fix multiple pool setup

* Fix investor handler

* Start working on decrease

* Work on executing decrease invest orders

* Work on kv store in handler base

* fix permit (#195)

* fix permit

* consolidate code

* fmt

* remove redundant require from permitted deposit request

* Refactor price logic (#192)

* Refactor price logic

* Remove redundant comments

* Check transfer restriction on request redeem (#193)

* Check transfer restriction on request redeem

* Fix

* Format

* Freeze check both directions

* Fix test

* Change member checks

* Update checks again

* Revert cancel rely if no target is scheduled (#197)

* Check price is newer (#198)

* Fix key type

* Clean up

* Reorganize unit tests

* More renames

* Rename invariant test folder

* Fix imports

* Add price invariants

* Disable fork tests for now

* Fix old imports, typo

* Clean up

* Currency setup

* Remove handler

* Fix build

* Move tests

* Env var for fork tests

* Clean up fork & integration tests

* Rename

* Set up cross-chain fork tests

* Add admin signer setup

* Remove foundry rpc urls

* Clean up

* Move around

* Add CI for fork tests

* Update celo messages

* Add deployment info

* Move spells

* Determinism check

* Set up testnet support

* Format

* Remove redundant rpc urls

* Cron job for fork tests

* Remove duplicated code

* Add mathlib and safetransferlib tests

* Fix typo

* Reorganize

* Format

* Clean up folder structure

* More renames

* Delete duplicate files

* Remove xcm router

* Remove old import

* Remove unused param

* Add forwarder test

* Add BytesLib test

* Typo

* Revert

* Add investment manager tests

* Add more tests

* Re-enable

* Ad some more unit tests

* 2 more

* Add more sanity check tests

* Rename

* Add more

* Add allowed currency for requestRedeem check

* Fix compilation

* Reduce params

* Fix ci path

* Fix another ci path

* Remove unused ci code

* Refactor shadow var handling

* Format

* Fix slow builds

* Exclude invariant tests from code cov

* Remove more merge conflict issues

* Add old metadata check

* Fix typo

* Simplify Axelar router

* Disable some invariants for now

* Include invariant tests in coverage again

* First draft

* WIP

* Make it kind of work

* Clean up

* Format

* Extend tests

* File tess

* Message proof test

* Resend method

* Comment

* Add delayed admin method

* Comment

* Integrate in deployment

* Comment

* Update coments

* Refactor storage

* Label deployed contracts

* Upgrade forge-std

* Improve gas usage

* Fix tests

* Nicer

* Add aggregation fuzz test

* Update bounds

* Add events and more

* Rename

* Clean up events

* Wire delayed admin to aggregator

* Add recovery tests

* Use aggregation in integration tests

* Format

* Simplify axelar router

* Missing event

* Small cleanup

* Improve storage and retrieval of confirmations

* Uncomment

* Comment

* Remove unused code

* Dont allow send before init

* Clean up imports

* Remove loop inits

* Add router to execute msg event

* Remove first router check

* Remove quorum param

* Adapt recover methods

* Naming

* Clean up and test filing routers

* Create ARrayLib

* Message recovery draft

* Simplify

* Clean up

* Clean up

* Remove wrong ward

* Set up ArrayLib tests

* Fix huge loophole :)

* Simplify

* Add recovery tests

* Clean up

* Decrease n value test

* More tests

* Allow disputing message recovery by admin

* Remove double line

* Clean up file

* Fix missing root ward

* Update src/gateway/routers/RouterAggregator.sol

Co-authored-by: Adam Stox <[email protected]>

---------

Signed-off-by: ilin <[email protected]>
Co-authored-by: Alina Sinelnikova <[email protected]>
Co-authored-by: Adam Stox <[email protected]>
hieronx added a commit that referenced this pull request Feb 20, 2024
* Start cleaning up message parsing

* Remove more code

* Remove collect* mesages

* Disallow recovering using invalid router

* Set up CastLib

* Extend cast lib, clean up

* Rewrite many format methods

* Remove more format methods

* Fix tests

* Remove another helper

* More cleanup

* Fix missing

* Multi-router Message Aggregation (#235)

* Start adding convert invariant

* Remove collect functions, remove sanity checks for incoming calls, fix price conversion

* Remove deposit/redeem price calculations

* Add redeem request internal method

* Simplify convert methods

* Remove some comments

* Fix tests

* More simplfications

* Fix tests

* Fix typo

* Fixes

* Simplify math

* Simplify LP lookups

* Remove internal touint128 in test

* Consistent naming

* Rename lp values / orderbook to investment state

* Fix price type

* Fix convert invariants, add maxdeposit/redeem invariants

* Start adapting investor handler to support multiple investors

* Set 2 investors

* Set up base handler

* fix: add tranche (#180)

* Align approval flow and interface with EIP draft (#178)

* Explore new approval flow

* Fix permit logic

* Allowance checks

* Remove fee-on-transfer support

* Fix revert message

* Fix tests

* Remove unused function from interface

* Fix comment

* Naming

* Remove console

* Remove duplicate transfer from function

* Fix balance check

* Add operator param

* Align naming of view functions

* Address pr comments

* disallow freezing the zero address (#181)

* Fix permit fr with lower asset amounts (#183)

* fix frontrunning with smaller asset amounts with permits

* add test condition

Signed-off-by: ilin <[email protected]>

---------

Signed-off-by: ilin <[email protected]>

* Make restrictionManagerFactory mutable on PoolManager (#182)

* Make restrictionManagerFactory mutable on PoolManager

* group RestrictionManagerFactory with other public vars

* Preview methods should revert (#186)

* Remove preview methods from investment mgr

* Add comment

* Format

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

---------

Co-authored-by: Adam Stox <[email protected]>

* Add IERC7540 (#190)

* Add IERC7540

* Update interface

* Update ERC-20 interfaces

* Fix comment

* Skip slither step

* Fix price calculation issue on decrease executions (#184)

* Add test for failing price conversion on decrease

* Attempt to fix conversions

* Automatically claim deposits on trigger request redeem (#187)

* Automatically claim deposits on trigger request redeem

* trigger redemptions when user still has tokens in escrow (#189)

* trigger redemptions when user still has tokens in escrow

Signed-off-by: ilin <[email protected]>

* fix comments

Signed-off-by: ilin <[email protected]>

* add fixes from review

* add fixes from review

* add fixes from review

---------

Signed-off-by: ilin <[email protected]>

---------

Signed-off-by: ilin <[email protected]>
Co-authored-by: Alina Sinelnikova <[email protected]>

* Work on multiple pools

* Fix multiple pool setup

* Fix investor handler

* Start working on decrease

* Work on executing decrease invest orders

* Work on kv store in handler base

* fix permit (#195)

* fix permit

* consolidate code

* fmt

* remove redundant require from permitted deposit request

* Refactor price logic (#192)

* Refactor price logic

* Remove redundant comments

* Check transfer restriction on request redeem (#193)

* Check transfer restriction on request redeem

* Fix

* Format

* Freeze check both directions

* Fix test

* Change member checks

* Update checks again

* Revert cancel rely if no target is scheduled (#197)

* Check price is newer (#198)

* Fix key type

* Clean up

* Reorganize unit tests

* More renames

* Rename invariant test folder

* Fix imports

* Add price invariants

* Disable fork tests for now

* Fix old imports, typo

* Clean up

* Currency setup

* Remove handler

* Fix build

* Move tests

* Env var for fork tests

* Clean up fork & integration tests

* Rename

* Set up cross-chain fork tests

* Add admin signer setup

* Remove foundry rpc urls

* Clean up

* Move around

* Add CI for fork tests

* Update celo messages

* Add deployment info

* Move spells

* Determinism check

* Set up testnet support

* Format

* Remove redundant rpc urls

* Cron job for fork tests

* Remove duplicated code

* Add mathlib and safetransferlib tests

* Fix typo

* Reorganize

* Format

* Clean up folder structure

* More renames

* Delete duplicate files

* Remove xcm router

* Remove old import

* Remove unused param

* Add forwarder test

* Add BytesLib test

* Typo

* Revert

* Add investment manager tests

* Add more tests

* Re-enable

* Ad some more unit tests

* 2 more

* Add more sanity check tests

* Rename

* Add more

* Add allowed currency for requestRedeem check

* Fix compilation

* Reduce params

* Fix ci path

* Fix another ci path

* Remove unused ci code

* Refactor shadow var handling

* Format

* Fix slow builds

* Exclude invariant tests from code cov

* Remove more merge conflict issues

* Add old metadata check

* Fix typo

* Simplify Axelar router

* Disable some invariants for now

* Include invariant tests in coverage again

* First draft

* WIP

* Make it kind of work

* Clean up

* Format

* Extend tests

* File tess

* Message proof test

* Resend method

* Comment

* Add delayed admin method

* Comment

* Integrate in deployment

* Comment

* Update coments

* Refactor storage

* Label deployed contracts

* Upgrade forge-std

* Improve gas usage

* Fix tests

* Nicer

* Add aggregation fuzz test

* Update bounds

* Add events and more

* Rename

* Clean up events

* Wire delayed admin to aggregator

* Add recovery tests

* Use aggregation in integration tests

* Format

* Simplify axelar router

* Missing event

* Small cleanup

* Improve storage and retrieval of confirmations

* Uncomment

* Comment

* Remove unused code

* Dont allow send before init

* Clean up imports

* Remove loop inits

* Add router to execute msg event

* Remove first router check

* Remove quorum param

* Adapt recover methods

* Naming

* Clean up and test filing routers

* Create ARrayLib

* Message recovery draft

* Simplify

* Clean up

* Clean up

* Remove wrong ward

* Set up ArrayLib tests

* Fix huge loophole :)

* Simplify

* Add recovery tests

* Clean up

* Decrease n value test

* More tests

* Allow disputing message recovery by admin

* Remove double line

* Clean up file

* Fix missing root ward

* Update src/gateway/routers/RouterAggregator.sol

Co-authored-by: Adam Stox <[email protected]>

---------

Signed-off-by: ilin <[email protected]>
Co-authored-by: Alina Sinelnikova <[email protected]>
Co-authored-by: Adam Stox <[email protected]>

* Fix most message parsing tests

* Fix transfer test

* Fix gateway test

---------

Signed-off-by: ilin <[email protected]>
Co-authored-by: Alina Sinelnikova <[email protected]>
Co-authored-by: Adam Stox <[email protected]>
hieronx added a commit that referenced this pull request Feb 20, 2024
* Start adding convert invariant

* Remove collect functions, remove sanity checks for incoming calls, fix price conversion

* Remove deposit/redeem price calculations

* Add redeem request internal method

* Simplify convert methods

* Remove some comments

* Fix tests

* More simplfications

* Fix tests

* Fix typo

* Fixes

* Simplify math

* Simplify LP lookups

* Remove internal touint128 in test

* Consistent naming

* Rename lp values / orderbook to investment state

* Fix price type

* Fix convert invariants, add maxdeposit/redeem invariants

* Start adapting investor handler to support multiple investors

* Set 2 investors

* Set up base handler

* fix: add tranche (#180)

* Align approval flow and interface with EIP draft (#178)

* Explore new approval flow

* Fix permit logic

* Allowance checks

* Remove fee-on-transfer support

* Fix revert message

* Fix tests

* Remove unused function from interface

* Fix comment

* Naming

* Remove console

* Remove duplicate transfer from function

* Fix balance check

* Add operator param

* Align naming of view functions

* Address pr comments

* disallow freezing the zero address (#181)

* Fix permit fr with lower asset amounts (#183)

* fix frontrunning with smaller asset amounts with permits

* add test condition

Signed-off-by: ilin <[email protected]>

---------

Signed-off-by: ilin <[email protected]>

* Make restrictionManagerFactory mutable on PoolManager (#182)

* Make restrictionManagerFactory mutable on PoolManager

* group RestrictionManagerFactory with other public vars

* Preview methods should revert (#186)

* Remove preview methods from investment mgr

* Add comment

* Format

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

* Update src/InvestmentManager.sol

Co-authored-by: Adam Stox <[email protected]>

---------

Co-authored-by: Adam Stox <[email protected]>

* Add IERC7540 (#190)

* Add IERC7540

* Update interface

* Update ERC-20 interfaces

* Fix comment

* Skip slither step

* Fix price calculation issue on decrease executions (#184)

* Add test for failing price conversion on decrease

* Attempt to fix conversions

* Automatically claim deposits on trigger request redeem (#187)

* Automatically claim deposits on trigger request redeem

* trigger redemptions when user still has tokens in escrow (#189)

* trigger redemptions when user still has tokens in escrow

Signed-off-by: ilin <[email protected]>

* fix comments

Signed-off-by: ilin <[email protected]>

* add fixes from review

* add fixes from review

* add fixes from review

---------

Signed-off-by: ilin <[email protected]>

---------

Signed-off-by: ilin <[email protected]>
Co-authored-by: Alina Sinelnikova <[email protected]>

* Work on multiple pools

* Fix multiple pool setup

* Fix investor handler

* Start working on decrease

* Work on executing decrease invest orders

* Work on kv store in handler base

* fix permit (#195)

* fix permit

* consolidate code

* fmt

* remove redundant require from permitted deposit request

* Refactor price logic (#192)

* Refactor price logic

* Remove redundant comments

* Check transfer restriction on request redeem (#193)

* Check transfer restriction on request redeem

* Fix

* Format

* Freeze check both directions

* Fix test

* Change member checks

* Update checks again

* Revert cancel rely if no target is scheduled (#197)

* Check price is newer (#198)

* Fix key type

* Clean up

* Reorganize unit tests

* More renames

* Rename invariant test folder

* Fix imports

* Add price invariants

* Disable fork tests for now

* Fix old imports, typo

* Clean up

* Currency setup

* Remove handler

* Fix build

* Move tests

* Env var for fork tests

* Clean up fork & integration tests

* Rename

* Set up cross-chain fork tests

* Add admin signer setup

* Remove foundry rpc urls

* Clean up

* Move around

* Add CI for fork tests

* Update celo messages

* Add deployment info

* Move spells

* Determinism check

* Set up testnet support

* Format

* Remove redundant rpc urls

* Cron job for fork tests

* Remove duplicated code

* Add mathlib and safetransferlib tests

* Fix typo

* Reorganize

* Format

* Clean up folder structure

* More renames

* Delete duplicate files

* Remove xcm router

* Remove old import

* Remove unused param

* Add forwarder test

* Add BytesLib test

* Typo

* Revert

* Add investment manager tests

* Add more tests

* Re-enable

* Ad some more unit tests

* 2 more

* Add more sanity check tests

* Rename

* Add more

* Add allowed currency for requestRedeem check

* Fix compilation

* Reduce params

* Fix ci path

* Fix another ci path

* Remove unused ci code

* Refactor shadow var handling

* Format

* Fix slow builds

* Exclude invariant tests from code cov

* Remove more merge conflict issues

* Add old metadata check

* Fix typo

* Simplify Axelar router

* Disable some invariants for now

* Include invariant tests in coverage again

* First draft

* WIP

* Make it kind of work

* Clean up

* Format

* Extend tests

* File tess

* Message proof test

* Resend method

* Comment

* Add delayed admin method

* Comment

* Integrate in deployment

* Comment

* Update coments

* Refactor storage

* Label deployed contracts

* Upgrade forge-std

* Improve gas usage

* Fix tests

* Nicer

* Add aggregation fuzz test

* Update bounds

* Add events and more

* Rename

* Clean up events

* Wire delayed admin to aggregator

* Add recovery tests

* Use aggregation in integration tests

* Format

* Start cleaning up message parsing

* Remove more code

* Simplify axelar router

* Missing event

* Small cleanup

* Remove collect* mesages

* Improve storage and retrieval of confirmations

* Uncomment

* Comment

* Remove unused code

* Dont allow send before init

* Clean up imports

* Remove loop inits

* Add router to execute msg event

* Remove first router check

* Remove quorum param

* Adapt recover methods

* Naming

* Clean up and test filing routers

* Create ARrayLib

* Message recovery draft

* Simplify

* Clean up

* Clean up

* Remove wrong ward

* Disallow recovering using invalid router

* Set up CastLib

* Extend cast lib, clean up

* Rewrite many format methods

* Remove more format methods

* Fix tests

* Remove another helper

* More cleanup

* Set up ArrayLib tests

* Fix huge loophole :)

* Simplify

* Add recovery tests

* Clean up

* Decrease n value test

* More tests

* Allow disputing message recovery by admin

* Remove double line

* Clean up file

* Fix missing root ward

* Fix missing

* Fix most message parsing tests

* Fix transfer test

* Fix gateway test

---------

Signed-off-by: ilin <[email protected]>
Co-authored-by: Alina Sinelnikova <[email protected]>
Co-authored-by: Adam Stox <[email protected]>
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.

3 participants