Skip to content

[SC-213] Feat: Reserve Vault#665

Merged
Zitzak merged 12 commits intofeature/ToposFundingManagerfrom
sc-213-reserve-vault
Oct 8, 2024
Merged

[SC-213] Feat: Reserve Vault#665
Zitzak merged 12 commits intofeature/ToposFundingManagerfrom
sc-213-reserve-vault

Conversation

@FHieser
Copy link
Contributor

@FHieser FHieser commented Oct 1, 2024

Renamed to Token Vault

@FHieser FHieser requested a review from Zitzak October 1, 2024 08:43
@linear
Copy link

linear bot commented Oct 1, 2024

SC-213 Reserve Vault

@FHieser FHieser marked this pull request as draft October 1, 2024 08:43
@FHieser FHieser marked this pull request as ready for review October 1, 2024 09:26
@Zitzak Zitzak changed the title Sc 213 reserve vault [SC-213] Feat: Reserve Vault Oct 1, 2024
// Errors
import {OZErrors} from "test/utils/errors/OZErrors.sol";

contract FM_EXT_TokenVault_v1Test is ModuleTest {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't have any Gherkin in the file.

I've just checked if ChatGPT could help with that and it's pretty good, which could safe you some time. Example:

/* Test validAmount() modifier
    ├── Given the vault contains a specific amount of tokens
    │   └── And the amount is equal to 0
    │       └── When the withdraw() function is called
    │           └── Then the transaction should revert with Module__FM_EXT_TokenVault__InvalidAmount error
    └── Given the amount is greater than 0
        └── When the withdraw() function is called
            └── Then the transaction should succeed
*/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I test both conditions here
The first one in the test itself
The second in the modifier in position / the modifier test itself

Copy link
Collaborator

Choose a reason for hiding this comment

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

I will be adding some gherkin to your tests. Will prob do that somewhere later today/tomorrow

FHieser and others added 2 commits October 2, 2024 10:11
- Internal function to modifier
- Trailing underscore to parameters
- Gherkin to test
- Cleaned up tests
@Zitzak
Copy link
Collaborator

Zitzak commented Oct 3, 2024

@FHieser Added Gherkin to the test files and changed a few other things based on our dev guidelines.

However somehow I don't get 2 tests to work, but no clue why and have already spent to long on it. Could you take a look at it please 🙏

Copy link
Collaborator

@Zitzak Zitzak left a comment

Choose a reason for hiding this comment

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

LGTM

@FHieser FHieser changed the base branch from feature/ToposFundingManager to dev October 4, 2024 13:33
@FHieser FHieser changed the base branch from dev to sc-98-create-topos-funding-manager October 4, 2024 13:35
@FHieser FHieser changed the base branch from sc-98-create-topos-funding-manager to feature/ToposFundingManager October 4, 2024 13:36
@marvinkruse marvinkruse changed the base branch from feature/ToposFundingManager to dev October 4, 2024 13:40
@marvinkruse marvinkruse changed the base branch from dev to feature/ToposFundingManager October 4, 2024 13:42
@marvinkruse marvinkruse force-pushed the sc-213-reserve-vault branch 2 times, most recently from 9ebcf30 to 1e06f23 Compare October 4, 2024 13:47
@Zitzak Zitzak merged commit 5b4da1a into feature/ToposFundingManager Oct 8, 2024
@Zitzak Zitzak deleted the sc-213-reserve-vault branch October 8, 2024 15:25
Zitzak added a commit that referenced this pull request Feb 24, 2025
* [SC-213] Feat: Reserve Vault (#665)

* Create Reservepool Contract

* Rename and adapt

* Create FM_EXT_ReservePool_v1.t.sol

* Rename to TokenVault

* Adapt to not send native token

* Address comments

* Add:
- Internal function to modifier
- Trailing underscore to parameters
- Gherkin to test
- Cleaned up tests

* Update FM_EXT_TokenVault_v1.t.sol

---------

Co-authored-by: Zitzak <marvin88gr@gmail.com>
Co-authored-by: Marvin <43185740+Zitzak@users.noreply.github.com>

* Chore: Clean up TokenVault

* Feat: Add FM_BC_BondingSurface_Redeemable_Repayer_Seizable_v1 (#666)

* Create Reservepool Contract

* Rename and adapt

* Create FM_EXT_ReservePool_v1.t.sol

* Topos FM

* remove liquidity vault controller contracts

* Rename to TokenVault

* Adapt to not send native token

* Rename to Token Vault

* Address comments

* Outcomment Burn tests for now

* Create setTokenVault

* Fix most Burn functions

* AddSpentAllowance to ERC20Issuance

* Add _spendAllowance to BondingCurveBase

* Add _spendAllowance to BurnIssuanceFor

* Fix Dependency Issue

* Rename Redeemable to Redeeming

* Create FM_BC_BondingSurface_Redeeming_v1.sol

* WIP

* Add:
- Internal function to modifier
- Trailing underscore to parameters
- Gherkin to test
- Cleaned up tests

* restructure contracts

* Add tag for testing file split

* Setup seperate Tests

* Update Base BondingSurface test

* Rename Mock

* Remove Tests that are included in the base contract

* Remove parameters from BondingSurface Struct

* Go over comments

* Address comments

* Address Comments

* Adapt Naming of events

* Adding Restricted to the name

* Update comments

* resolve comments in implementations

* Fix: Finalize moving of error into funding manager base

* Fix: Typos in ERC20Issuance

* Chore: Start cleanup of FM_BC's

* Fix: Resolve failing test

Was mismatched with implementation, didn't cover the address(this) case.

---------

Co-authored-by: FHieser <felix_hieser@web.de>
Co-authored-by: Felix Hieser <47272854+FHieser@users.noreply.github.com>
Co-authored-by: Marvin Kruse <marvinkruse@users.noreply.github.com>

* Sc 720 expand unit tests for topos related modules (#676)

* Add empty BondingSurface test file

* Remove tokenVault from init

The tokenvault cant be set during init because is created simultaneously to the BondingCurve contract.
It has to be added via Dependency Injection

* Remove unnecessary overrides

* Add and adapt tests

* Adapt inheritance of functions

* Update Comments

* Update Tests

* Update fmt

* Add event to projectFeeCollected

* Address comments of PR

---------

Co-authored-by: Zitzak <marvin88gr@gmail.com>

* Sc 828 address omega review comments (#680)

* Add empty BondingSurface test file

* Remove tokenVault from init

The tokenvault cant be set during init because is created simultaneously to the BondingCurve contract.
It has to be added via Dependency Injection

* Remove unnecessary overrides

* Add and adapt tests

* Adapt inheritance of functions

* Update Comments

* Update Tests

* Update fmt

* Add event to projectFeeCollected

* Address comments of PR

* Revert if redeemamount reaches Min Reserve

* Check for Min Reserve in TransferOrchestrator Token

* Add MinReserveCheck to transferRepayment

* Rename Modifier

* Remove time casting

* Enable BuyFee

* Use function that can be overriden

* Add gap

* Make Min_Reserves variable based on Token Decimals

* Use SpotPrice to get StaticPrice

* adapt based on comments

* Update FM_BC_BondingSurface_Redeeming_v1.t.sol

---------

Co-authored-by: Zitzak <marvin88gr@gmail.com>

* Refactor Update the BondingSurface implementation to represent the code of conduct

* Add empty BondingSurface test file

* Remove tokenVault from init

The tokenvault cant be set during init because is created simultaneously to the BondingCurve contract.
It has to be added via Dependency Injection

* Remove unnecessary overrides

* Add and adapt tests

* Adapt inheritance of functions

* Update Comments

* Update Tests

* Update fmt

* Add event to projectFeeCollected

* Address comments of PR

* Revert if redeemamount reaches Min Reserve

* Check for Min Reserve in TransferOrchestrator Token

* Add MinReserveCheck to transferRepayment

* Rename Modifier

* Remove time casting

* Enable BuyFee

* Use function that can be overriden

* Add gap

* Make Min_Reserves variable based on Token Decimals

* Use SpotPrice to get StaticPrice

* adapt based on comments

* Update FM_BC_BondingSurface_Redeeming_v1.t.sol

* WIP push

* Rename seizable

* Make state internal

* Rename Parameters and Return Values

* Rename Contracts

* Adapt to code of conduct

* Adapting Interfaces to have Contract Overview Documentation

* Adapt Sectioning

* Adapt Mocks and Tests to parameter conventions

* Remove Todos/notes

* Adapt merge aftermath

* Update BondingSurface.sol

* Rename to prevent shadow

* Adapt remapping

* Address comments

* Adapt init

* Update inverter standard versioning

* Delete FM_BC_BondingSurface_RedeemingV1_exposed.sol

* Adapt Contract Naming Standards

* Fix naming references

* Fix test

* Update naming reference

* Adapt modifier to call internal function

* Adapt naming of internal function

* update modifier Naming

* Adapt tests

* Adapt naming internal functions

* Adapt Parameters

* Adapt naming of function state

* Adapt sections

* Update Interface Inheritance

* Update versioning

* Update natspec to be rule compliant

* Fix naming

* Delete ILiquidityVaultProviderWhitelist_v1.sol

* Remove Liquidity Vault Controller Interface

* Rename Modifier

* Add solmate as lib

* Revert "Add solmate as lib"

This reverts commit 050b9d2.

* Remove comment

* Adapt natspec

* Apply comment suggestions from code review

Co-authored-by: Marvin Kruse <marvinkruse@users.noreply.github.com>

* Adapt internal function state

* Add . to comments

* Adapt spacing in natspec comments

* Adapt spacing

* Replace @dev with @notice

* Adapt comment length

* Adapt naming

* Address Comments

* Adapt Version

* Reposition MIN_RESERVE

* Adapt sectioning

* Update more sectioning

* Add title section and increment version

---------

Co-authored-by: Zitzak <marvin88gr@gmail.com>
Co-authored-by: Marvin Kruse <marvinkruse@users.noreply.github.com>

* Add before and afterSell functionalities

* Add new contracts to scripts

* Rename Files to contain .t

* Add BondingSurface E2E

* Use ModuleRole

* Finish e2e tests

* Add Documentation

* Adapt the Deployment Parameters

* Create Contract Template.md

* 4/5 tests passing

* Create BondingSurface.md

* Fix missing tests

* update comment about eror tolerance

* refactor: resolve renaming mismatch in contracts

* fix: resolve RPC issue on tests

---------

Co-authored-by: Felix Hieser <47272854+FHieser@users.noreply.github.com>
Co-authored-by: Zitzak <marvin88gr@gmail.com>
Co-authored-by: Marvin <43185740+Zitzak@users.noreply.github.com>
Co-authored-by: FHieser <felix_hieser@web.de>
Co-authored-by: 0xNuggan <82726722+0xNuggan@users.noreply.github.com>
0xNuggan added a commit that referenced this pull request Apr 8, 2025
* [SC-213] Feat: Reserve Vault (#665)

* Create Reservepool Contract

* Rename and adapt

* Create FM_EXT_ReservePool_v1.t.sol

* Rename to TokenVault

* Adapt to not send native token

* Address comments

* Add:
- Internal function to modifier
- Trailing underscore to parameters
- Gherkin to test
- Cleaned up tests

* Update FM_EXT_TokenVault_v1.t.sol

---------

Co-authored-by: Zitzak <marvin88gr@gmail.com>
Co-authored-by: Marvin <43185740+Zitzak@users.noreply.github.com>

* Chore: Clean up TokenVault

* Feat: Add FM_BC_BondingSurface_Redeemable_Repayer_Seizable_v1 (#666)

* Create Reservepool Contract

* Rename and adapt

* Create FM_EXT_ReservePool_v1.t.sol

* Topos FM

* remove liquidity vault controller contracts

* Rename to TokenVault

* Adapt to not send native token

* Rename to Token Vault

* Address comments

* Outcomment Burn tests for now

* Create setTokenVault

* Fix most Burn functions

* AddSpentAllowance to ERC20Issuance

* Add _spendAllowance to BondingCurveBase

* Add _spendAllowance to BurnIssuanceFor

* Fix Dependency Issue

* Rename Redeemable to Redeeming

* Create FM_BC_BondingSurface_Redeeming_v1.sol

* WIP

* Add:
- Internal function to modifier
- Trailing underscore to parameters
- Gherkin to test
- Cleaned up tests

* restructure contracts

* Add tag for testing file split

* Setup seperate Tests

* Update Base BondingSurface test

* Rename Mock

* Remove Tests that are included in the base contract

* Remove parameters from BondingSurface Struct

* Go over comments

* Address comments

* Address Comments

* Adapt Naming of events

* Adding Restricted to the name

* Update comments

* resolve comments in implementations

* Fix: Finalize moving of error into funding manager base

* Fix: Typos in ERC20Issuance

* Chore: Start cleanup of FM_BC's

* Fix: Resolve failing test

Was mismatched with implementation, didn't cover the address(this) case.

---------

Co-authored-by: FHieser <felix_hieser@web.de>
Co-authored-by: Felix Hieser <47272854+FHieser@users.noreply.github.com>
Co-authored-by: Marvin Kruse <marvinkruse@users.noreply.github.com>

* Sc 720 expand unit tests for topos related modules (#676)

* Add empty BondingSurface test file

* Remove tokenVault from init

The tokenvault cant be set during init because is created simultaneously to the BondingCurve contract.
It has to be added via Dependency Injection

* Remove unnecessary overrides

* Add and adapt tests

* Adapt inheritance of functions

* Update Comments

* Update Tests

* Update fmt

* Add event to projectFeeCollected

* Address comments of PR

---------

Co-authored-by: Zitzak <marvin88gr@gmail.com>

* Sc 828 address omega review comments (#680)

* Add empty BondingSurface test file

* Remove tokenVault from init

The tokenvault cant be set during init because is created simultaneously to the BondingCurve contract.
It has to be added via Dependency Injection

* Remove unnecessary overrides

* Add and adapt tests

* Adapt inheritance of functions

* Update Comments

* Update Tests

* Update fmt

* Add event to projectFeeCollected

* Address comments of PR

* Revert if redeemamount reaches Min Reserve

* Check for Min Reserve in TransferOrchestrator Token

* Add MinReserveCheck to transferRepayment

* Rename Modifier

* Remove time casting

* Enable BuyFee

* Use function that can be overriden

* Add gap

* Make Min_Reserves variable based on Token Decimals

* Use SpotPrice to get StaticPrice

* adapt based on comments

* Update FM_BC_BondingSurface_Redeeming_v1.t.sol

---------

Co-authored-by: Zitzak <marvin88gr@gmail.com>

* Refactor Update the BondingSurface implementation to represent the code of conduct

* Add empty BondingSurface test file

* Remove tokenVault from init

The tokenvault cant be set during init because is created simultaneously to the BondingCurve contract.
It has to be added via Dependency Injection

* Remove unnecessary overrides

* Add and adapt tests

* Adapt inheritance of functions

* Update Comments

* Update Tests

* Update fmt

* Add event to projectFeeCollected

* Address comments of PR

* Revert if redeemamount reaches Min Reserve

* Check for Min Reserve in TransferOrchestrator Token

* Add MinReserveCheck to transferRepayment

* Rename Modifier

* Remove time casting

* Enable BuyFee

* Use function that can be overriden

* Add gap

* Make Min_Reserves variable based on Token Decimals

* Use SpotPrice to get StaticPrice

* adapt based on comments

* Update FM_BC_BondingSurface_Redeeming_v1.t.sol

* WIP push

* Rename seizable

* Make state internal

* Rename Parameters and Return Values

* Rename Contracts

* Adapt to code of conduct

* Adapting Interfaces to have Contract Overview Documentation

* Adapt Sectioning

* Adapt Mocks and Tests to parameter conventions

* Remove Todos/notes

* Adapt merge aftermath

* Update BondingSurface.sol

* Rename to prevent shadow

* Adapt remapping

* Address comments

* Adapt init

* Update inverter standard versioning

* Delete FM_BC_BondingSurface_RedeemingV1_exposed.sol

* Adapt Contract Naming Standards

* Fix naming references

* Fix test

* Update naming reference

* Adapt modifier to call internal function

* Adapt naming of internal function

* update modifier Naming

* Adapt tests

* Adapt naming internal functions

* Adapt Parameters

* Adapt naming of function state

* Adapt sections

* Update Interface Inheritance

* Update versioning

* Update natspec to be rule compliant

* Fix naming

* Delete ILiquidityVaultProviderWhitelist_v1.sol

* Remove Liquidity Vault Controller Interface

* Rename Modifier

* Add solmate as lib

* Revert "Add solmate as lib"

This reverts commit 050b9d2.

* Remove comment

* Adapt natspec

* Apply comment suggestions from code review

Co-authored-by: Marvin Kruse <marvinkruse@users.noreply.github.com>

* Adapt internal function state

* Add . to comments

* Adapt spacing in natspec comments

* Adapt spacing

* Replace @dev with @notice

* Adapt comment length

* Adapt naming

* Address Comments

* Adapt Version

* Reposition MIN_RESERVE

* Adapt sectioning

* Update more sectioning

* Add title section and increment version

---------

Co-authored-by: Zitzak <marvin88gr@gmail.com>
Co-authored-by: Marvin Kruse <marvinkruse@users.noreply.github.com>

* Add before and afterSell functionalities

* Add new contracts to scripts

* Rename Files to contain .t

* Add BondingSurface E2E

* Use ModuleRole

* Finish e2e tests

* Add Documentation

* Adapt the Deployment Parameters

* Create Contract Template.md

* 4/5 tests passing

* Create BondingSurface.md

* Fix missing tests

* update comment about eror tolerance

* refactor: resolve renaming mismatch in contracts

* fix: resolve RPC issue on tests

---------

Co-authored-by: Felix Hieser <47272854+FHieser@users.noreply.github.com>
Co-authored-by: Zitzak <marvin88gr@gmail.com>
Co-authored-by: Marvin <43185740+Zitzak@users.noreply.github.com>
Co-authored-by: FHieser <felix_hieser@web.de>
Co-authored-by: 0xNuggan <82726722+0xNuggan@users.noreply.github.com>
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.

2 participants