Skip to content

Feat: Issuance/Blacklist Token Changes#724

Merged
Zitzak merged 10 commits intofeature/FM_PC_Oracle_Redeeming_v1from
issuance-token-blacklist-changes
Mar 18, 2025
Merged

Feat: Issuance/Blacklist Token Changes#724
Zitzak merged 10 commits intofeature/FM_PC_Oracle_Redeeming_v1from
issuance-token-blacklist-changes

Conversation

@marvinkruse
Copy link
Member

This PR will contain changes to the ERC20Issuance_Blacklist contract:

  • adding an upgradeable version
  • remove the blacklist manager from the init (due to indexing issues)

Zitzak and others added 3 commits March 7, 2025 09:42
- Add ERC20Issuance token version that is upgradeable
- Add tests
- Add ERC20Issuance_Blacklist token version that is upgradeable
- Add tests
@Zitzak Zitzak marked this pull request as ready for review March 7, 2025 08:44
@Zitzak Zitzak requested a review from fabianschu March 7, 2025 08:44
@Zitzak Zitzak assigned Zitzak and unassigned Zitzak Mar 7, 2025
Zitzak added 2 commits March 7, 2025 10:28
- The initial admin set in the constructor/init can't be picked up from
the indexer, as it only starts indexing once the token is set into
the workflow. For that reason, we removed the initial admin from the
initialization.
- Updated tests for this change
- Refactored contract natspec
…klist-changes' into issuance-token-blacklist-changes
@Zitzak
Copy link
Collaborator

Zitzak commented Mar 7, 2025

Can't assign you as reviewer, so tagging you here @marvinkruse

@Zitzak Zitzak requested a review from FHieser March 7, 2025 09:57
@Zitzak Zitzak changed the title Feat: Blacklist Issuance Token Changes Feat: Issuance/Blacklist Token Changes Mar 7, 2025
Copy link
Member Author

@marvinkruse marvinkruse left a comment

Choose a reason for hiding this comment

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

In general looks good upon first pass, just some minor natspec stuff that saw between checking the logic.

Just one missing constructor that disables the init for the upgradeable basic issuance token contract.

Copy link
Contributor

@FHieser FHieser left a comment

Choose a reason for hiding this comment

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

Left some comments

@Zitzak Zitzak force-pushed the issuance-token-blacklist-changes branch from 4d5ec83 to ef51609 Compare March 13, 2025 13:26
@Zitzak Zitzak force-pushed the issuance-token-blacklist-changes branch from ef51609 to 4af57cd Compare March 13, 2025 13:36
@Zitzak Zitzak force-pushed the issuance-token-blacklist-changes branch from c83fcbf to 513df8e Compare March 18, 2025 09:42
@Zitzak Zitzak merged commit 3a15da1 into feature/FM_PC_Oracle_Redeeming_v1 Mar 18, 2025
5 checks passed
@Zitzak Zitzak deleted the issuance-token-blacklist-changes branch March 18, 2025 10:50
Zitzak added a commit that referenced this pull request Apr 23, 2025
…v1, PP_Queue_ManualExecution_v1

* Fix array orderring mismatch bug

* address _setFlags() comment

* address PaymentRouter comment

* Feat: FM_PC_ExternalPriceRedeeming, ManualExternalPriceSetter and ERC20Issuance_Blacklist

* Contract structure defined

* removed IFundingManager extension

* IFundingManager_v1 needed

* extended IRedeemingBondingCurveBase_v1 as well

* ExternalPriceSetter, blacklist, Oracle and interfaces added

* formatting files and adapting to the code of conduct

* ManualExternalPriceSetter_v1 modified as LM

* added fees checks, paymentOrder to the process and defined role for blacklist

* managing roles, renaming, and removing unneeded things

* whitelist logic removed, blacklist fixes

* missing logic implemented

* blacklist fixes and custom error added

* switched from role to mapping for blacklist manager

* moved blacklist files to external, modified sell, and more context added

* PAYMENT_QUEUE_ROLE added, _sellOrder overriden

* emit_timestamp(IssuancePriceSet,RedemptionPriceSet),NatSpec

* fix: remove collateral transfer & collateral check

- The function `handleCollateralTokensAfterSell` was still expecting to
transfer collateral, which would revert in the current implementation.
- The _sellOrder` function had a conditional check which would let
the contract revert given there will not be any collateral in the
contract

* style: run make fmt for formating

* small fixes and documentation added

* docs added for issuance and redemption setters

* Rename ERC20Issuance_blacklist_v1.sol to ERC20Issuance_Blacklist_v1.sol

* Rename IERC20Issuance_blacklist_v1.sol to IERC20Issuance_Blacklist_v1.sol

* fixed executeRedemptionQueue, docs and renaming

* formatting natspec

* feat: add treasury collateral withdraw

* Fix fmt

* fix: typo

* fix: fmt

* fix: remove oracle from init

* fixed natspec

* modifier moved

* feat: update openRedemptionAmount

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* applied suggestions

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* formatting

* Update src/modules/fundingManager/oracle/interfaces/IFM_PC_ExternalPrice_Redeeming_v1.sol

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

* formatting

* Update src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

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

* formatting

* Modifier buyingIsEnabled and sellingIsEnabled added

* formatting, updating code from parent and adding interface check

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* Update src/modules/fundingManager/oracle/interfaces/ILM_ManualExternalPriceSetter_v1.sol

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

* Update src/modules/fundingManager/oracle/interfaces/ILM_ManualExternalPriceSetter_v1.sol

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

* Update src/modules/fundingManager/oracle/interfaces/IOraclePrice_v1.sol

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

* Update src/modules/fundingManager/oracle/interfaces/IOraclePrice_v1.sol

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

* Update src/external/token/interfaces/IERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/interfaces/IERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/interfaces/IERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/interfaces/IERC20Issuance_Blacklist_v1.sol

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

* Update src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

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

* Update src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

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

* Update src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

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

* Update src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

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

* Update src/modules/fundingManager/oracle/LM_ManualExternalPriceSetter_v1.sol

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

* Update src/modules/fundingManager/oracle/LM_ManualExternalPriceSetter_v1.sol

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

* formatting

* formatting

* moved constants

* changed notice to dev

* adding named returned variable

* modifier renamed and buyingIsEnabled added to buy

* return named variables to interface

* formatting

* fix: revert during deployment

* fix issue with authorization

* fix: interface check

* interface natspec same as contract

* line too long fixed

* removed dot from title

* _ensureTokenBalance overriden

* remove function

* fix fmt

* Update src/modules/fundingManager/oracle/interfaces/IOraclePrice_v1.sol

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

* fix: Move LM_ManualPriceSetter into LM folder

---------

Co-authored-by: scab24 <git.seco@protonmail.com>
Co-authored-by: Zitzak <marvin88gr@gmail.com>
Co-authored-by: Marvin <43185740+Zitzak@users.noreply.github.com>
Co-authored-by: Marvin Kruse <marvinkruse@users.noreply.github.com>
Co-authored-by: Sergio <94926493+scab24@users.noreply.github.com>

* Fix: Remove redeemed amount from balance check

* Remove unnecessary safety check

* Abstract projectFeeCollected

* Create tests

* Fmt

* Update src/modules/fundingManager/bondingCurve/interfaces/IRedeemingBondingCurveBase_v1.sol

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

* Add check to _handleCollateralTokensAfterSell

* Revert "Add check to _handleCollateralTokensAfterSell"

This reverts commit 32f9bb3.

* Readd the check but only for projectCollateralFeeCollected

* Update IFM_BC_Bancor_Redeeming_VirtualSupply_v1.sol

* fmt

* Apply comment suggestions from code review

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

* Rename Error

* Apply suggestions from code review

* Fix: Resolve version mismatches

* Chore: Resolve formatting issue

---------

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

* fix: decimal conversion error

* fix: decimal conversion error

* fix: add 10^tokenDecimal

* Feat: Add deduction of openRedemptionAmount

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

* address _setFlags() comment

* feat(FM_PC_ExternalPrice_Redeeming): add new paymennt order struct

* fix review comments

* Fix: Revert to integer-based order ID (#707)

* Fix: Resolve typos

* gas optimization in "_setFlags"

* improve flag setting UX

* bugfix

* Add Valid Payment Order check to ProcessPayments

* FIx: Move to stable version of Foundry

* contract renaming to V2

* fix: ERC20PaymentClientBaseV2 merge issues

* Fix: Add temporary fix for failing RPCs in tests

* Feat/Fix: Fixes for audit + Queue based PP Contracts

* switched from role to mapping for blacklist manager

* moved blacklist files to external, modified sell, and more context added

* PAYMENT_QUEUE_ROLE added, _sellOrder overriden

* emit_timestamp(IssuancePriceSet,RedemptionPriceSet),NatSpec

* fix: remove collateral transfer & collateral check

- The function `handleCollateralTokensAfterSell` was still expecting to
transfer collateral, which would revert in the current implementation.
- The _sellOrder` function had a conditional check which would let
the contract revert given there will not be any collateral in the
contract

* style: run make fmt for formating

* small fixes and documentation added

* docs added for issuance and redemption setters

* Rename ERC20Issuance_blacklist_v1.sol to ERC20Issuance_Blacklist_v1.sol

* Rename IERC20Issuance_blacklist_v1.sol to IERC20Issuance_Blacklist_v1.sol

* fixed executeRedemptionQueue, docs and renaming

* formatting natspec

* feat: add treasury collateral withdraw

* Fix fmt

* fix: typo

* fix: fmt

* fix: remove oracle from init

* fixed natspec

* modifier moved

* feat: update openRedemptionAmount

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* applied suggestions

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* formatting

* Update src/modules/fundingManager/oracle/interfaces/IFM_PC_ExternalPrice_Redeeming_v1.sol

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

* formatting

* Update src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

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

* formatting

* Modifier buyingIsEnabled and sellingIsEnabled added

* formatting, updating code from parent and adding interface check

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* Update src/modules/fundingManager/oracle/interfaces/ILM_ManualExternalPriceSetter_v1.sol

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

* Update src/modules/fundingManager/oracle/interfaces/ILM_ManualExternalPriceSetter_v1.sol

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

* Update src/modules/fundingManager/oracle/interfaces/IOraclePrice_v1.sol

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

* Update src/modules/fundingManager/oracle/interfaces/IOraclePrice_v1.sol

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

* Update src/external/token/interfaces/IERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/interfaces/IERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/interfaces/IERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/interfaces/IERC20Issuance_Blacklist_v1.sol

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

* Update src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

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

* Update src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

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

* Update src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

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

* Update src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

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

* Update src/modules/fundingManager/oracle/LM_ManualExternalPriceSetter_v1.sol

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

* Update src/modules/fundingManager/oracle/LM_ManualExternalPriceSetter_v1.sol

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

* formatting

* formatting

* moved constants

* changed notice to dev

* adding named returned variable

* modifier renamed and buyingIsEnabled added to buy

* return named variables to interface

* formatting

* initial setup

* fix: revert during deployment

* fix issue with authorization

* fix: interface check

* interface natspec same as contract

* line too long fixed

* removed dot from title

* _ensureTokenBalance overriden

* remove function

* fix fmt

* work started with PP_Queue_v1

* Update src/modules/fundingManager/oracle/interfaces/IOraclePrice_v1.sol

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

* fix: Move LM_ManualPriceSetter into LM folder

* Feat: FM_PC_ExternalPriceRedeeming, ManualExternalPriceSetter and ERC20Issuance_Blacklist

* Contract structure defined

* removed IFundingManager extension

* IFundingManager_v1 needed

* extended IRedeemingBondingCurveBase_v1 as well

* ExternalPriceSetter, blacklist, Oracle and interfaces added

* formatting files and adapting to the code of conduct

* ManualExternalPriceSetter_v1 modified as LM

* added fees checks, paymentOrder to the process and defined role for blacklist

* managing roles, renaming, and removing unneeded things

* whitelist logic removed, blacklist fixes

* missing logic implemented

* blacklist fixes and custom error added

* switched from role to mapping for blacklist manager

* moved blacklist files to external, modified sell, and more context added

* PAYMENT_QUEUE_ROLE added, _sellOrder overriden

* emit_timestamp(IssuancePriceSet,RedemptionPriceSet),NatSpec

* fix: remove collateral transfer & collateral check

- The function `handleCollateralTokensAfterSell` was still expecting to
transfer collateral, which would revert in the current implementation.
- The _sellOrder` function had a conditional check which would let
the contract revert given there will not be any collateral in the
contract

* style: run make fmt for formating

* small fixes and documentation added

* docs added for issuance and redemption setters

* Rename ERC20Issuance_blacklist_v1.sol to ERC20Issuance_Blacklist_v1.sol

* Rename IERC20Issuance_blacklist_v1.sol to IERC20Issuance_Blacklist_v1.sol

* fixed executeRedemptionQueue, docs and renaming

* formatting natspec

* feat: add treasury collateral withdraw

* Fix fmt

* fix: typo

* fix: fmt

* fix: remove oracle from init

* fixed natspec

* modifier moved

* feat: update openRedemptionAmount

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* applied suggestions

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* formatting

* Update src/modules/fundingManager/oracle/interfaces/IFM_PC_ExternalPrice_Redeeming_v1.sol

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

* formatting

* Update src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

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

* formatting

* Modifier buyingIsEnabled and sellingIsEnabled added

* formatting, updating code from parent and adding interface check

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* Update src/modules/fundingManager/oracle/interfaces/ILM_ManualExternalPriceSetter_v1.sol

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

* Update src/modules/fundingManager/oracle/interfaces/ILM_ManualExternalPriceSetter_v1.sol

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

* Update src/modules/fundingManager/oracle/interfaces/IOraclePrice_v1.sol

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

* Update src/modules/fundingManager/oracle/interfaces/IOraclePrice_v1.sol

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

* Update src/external/token/interfaces/IERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/interfaces/IERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/interfaces/IERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/interfaces/IERC20Issuance_Blacklist_v1.sol

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

* Update src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

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

* Update src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

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

* Update src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

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

* Update src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

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

* Update src/modules/fundingManager/oracle/LM_ManualExternalPriceSetter_v1.sol

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

* Update src/modules/fundingManager/oracle/LM_ManualExternalPriceSetter_v1.sol

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

* formatting

* formatting

* moved constants

* changed notice to dev

* adding named returned variable

* modifier renamed and buyingIsEnabled added to buy

* return named variables to interface

* formatting

* fix: revert during deployment

* fix issue with authorization

* fix: interface check

* interface natspec same as contract

* line too long fixed

* removed dot from title

* _ensureTokenBalance overriden

* remove function

* fix fmt

* Update src/modules/fundingManager/oracle/interfaces/IOraclePrice_v1.sol

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

* fix: Move LM_ManualPriceSetter into LM folder

---------

Co-authored-by: scab24 <git.seco@protonmail.com>
Co-authored-by: Zitzak <marvin88gr@gmail.com>
Co-authored-by: Marvin <43185740+Zitzak@users.noreply.github.com>
Co-authored-by: Marvin Kruse <marvinkruse@users.noreply.github.com>
Co-authored-by: Sergio <94926493+scab24@users.noreply.github.com>

* Adapt to new PaymentOrder Structuring

* PP_Queue_v1 implemented

* Fix: Remove redeemed amount from balance check

* Remove unnecessary safety check

* Abstract projectFeeCollected

* Create tests

* Fmt

* Update src/modules/fundingManager/bondingCurve/interfaces/IRedeemingBondingCurveBase_v1.sol

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

* Add check to _handleCollateralTokensAfterSell

* Revert "Add check to _handleCollateralTokensAfterSell"

This reverts commit 32f9bb3.

* Readd the check but only for projectCollateralFeeCollected

* Update IFM_BC_Bancor_Redeeming_VirtualSupply_v1.sol

* fmt

* Apply comment suggestions from code review

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

* Rename Error

* Apply suggestions from code review

* Fix: Resolve version mismatches

* Chore: Resolve formatting issue

---------

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

* fix: decimal conversion error

* fix: decimal conversion error

* fix: add 10^tokenDecimal

* store unclaimable amounts after transfer failure

* changed to queue per client system

* Feat: Add deduction of openRedemptionAmount

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

* FM_PC_ExternalPrice_Redeeming_v1_Test

* removing unnecessary things and adding quick fixes

* fixing compilation error

* Update src/modules/paymentProcessor/PP_Queue_ManualExecution_v1.sol

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

* Update src/modules/paymentProcessor/PP_Queue_ManualExecution_v1.sol

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

* vesting constants removed

* reused _validPaymentOrder

* formatting and reverting call to _validPaymentOrder

* setup

* fix: update paymentOrder orderId to uint type

* renaming and formatting

* Update src/modules/paymentProcessor/PP_Queue_v1.sol

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

* Update src/modules/paymentProcessor/PP_Queue_v1.sol

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

* Update src/modules/paymentProcessor/PP_Queue_v1.sol

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

* Update src/modules/paymentProcessor/interfaces/IPP_Queue_ManualExecution_v1.sol

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

* Update src/modules/paymentProcessor/PP_Queue_v1.sol

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

* formatting and dots

* underscores

* handling unhappy paths to get queue id

* make fmt

* new_test_PP_Queue

* new_test_PP_Queue

* fixing nextOrderId and so on

* Update with FM_PC

* Update PP_Queue_v1.sol

* Update IPP_Queue_v1.sol

* new_test

* new_tests

* new tests added

* more tests for exposed functions added

* audit fixes

* Tests_PP_Queue

* Fix_Audit + Tests

* refactor: remove duplicate ERC20Mock, extend existing with decimals

* refactor: initial cleanup LM_ManualExternalPriceSetter_v1

- removed unused imports
- moved files to right directory
- renamed files
- cleaned up setup by removing unnecessary initialization, instead
reuse existing setup from ModuleTest
- format code (make fmt)

* refactor: initial setup ERC20Issuance_Blacklist_v1
- Moved file
- Removed unnecessary imports
- Use only exposed mock for testing

* refactor: FM_PC_ExternalPrice_Redeeming_v1_Test

- Remove imports
- Refactor most of the setup
- Add exposed mock
- Removed OraclePriceMock and InvalidMock
- Added simpler oracle mockf
- fmt

* refactor: remove import and fmt of LM_ManualExternalPriceSetter test

* fix: compile error

* Fix=> testExternalBuy_revertsGivenNonWhitelistedUser, testExternalBuy_succeedsGivenMaxAmount and comment testExternalQueue_succeedsGivenSingleRedemptionOrder

* Add format (Inverter Standard) PP_Queue, make pre-commit

* refactor:changed file structure

* fix:fee amount bug

* refactor:add internal func for redeem and issue

* fix:projectfeeAmount variable

* audit fix:remove normalize prices

* fix:failing test for issuance decimals

* more audit fixes

* refactor(ERC20Issuance_Blacklist): Update event, internal function

What has been done:
- Add msg.sender to events
- Move logic of modifier to internal function (Inverter Standard)

* refactor(ERC20Issuance_Blacklist_v1_Test):

- Cleaned setup
- Moved imports and functions to correct place (Inverter Standard)
- Added extensive gherkin
- Add some missing tests

* fix:add missing events to interface

* fix:inherit doc issue, code compiling, tests pass

* fix:remove unused exposed contracts

* refactor: refactor set issuance and redemption price

* refacotr: use internal functions and remove redundant function

* add:deductFromRedemption function

* fix:add msg.sender to price setter,move events to ioracle

* docs(IOraclePrice_v1): add missing param natspec

* feat: Add roles for the role admin

* event with contract address and add amountPaid added

* emit event that updates state with msgSender

* merging events and fixing compilation error

* Add PP_Queue.sol and IPP_Queue.sol

* visibility changed

* Add FundingManagerPaymentProcessorE2E, add configuration in E2EModuleRegistry, tests(2)

* improve setup, add _setupOrchestratorFundingManagerPaymentProcessor

* refactor: LM_ManualExternalPriceSetter_v1

- Add function to get collateral decimals value
- Updated natspec of price getters to work with new setup
which removed the normalization
- Moved function natpsec to interface for 2 functions

* refactor(LM_ManualExternalPriceSetter_v1_Test): refactor unit tests

What has been done:
- Cleanup the setup
- Removed unused imports
- Added missing tests for functions
- Rewrote tests to only test one function per test
- Added/rewrote gherkin
- Added exposed mock for internal function testing
- Apply Inverter Standard to formatting and file layout

* format - 1st round

* compilation errors fixed

* fix: test address collition

* fixed 2 tests out of 16

* formatting - 2nd stage

* format: update imports and rearrange public functions

* format:change content structure

* fix decimals in _redeemTokensFormulaWrapper

* client order ID fix

* deposit funds, Execute Queue

* Fix tests, delete console.log, Deposit funds in preparation for executing Queue, Execute Queue

* cherry pick from other branch

* fix: decimal convertion

* fix (;)

* refactor(FM_PC_ExternalPrice_Redeeming_v1):

What has been done:
- Add missing events for the following setter functions
  - project treasury
  - oracle
  - direct operations only
- Renamed maxBuyFee variable and function so they are mirroring
  the max sell fee, i.e maxProjectBuyFee
- Cleaned up RedemptionOrderCreated event by:
  - Add clarity to some natspec
  - Removed block.timestamp
  - Removed duplicate final redemption amount
  - Renamed variables for clarity
- Removed duplicate modifiers from sell and buy functions, as they
  redirect to the base contract functions, which have them as well
- Used similar patterns with `sell()` and `sellTo()` function as
  with buy, i.e. redirecting them to base contracts
- Add usage of internal function to add open redemption amount
- Moved event in `_createAndEmitOrder()` to `_sellOrder()` to be in
  line with how the base contract does it
- Update `_issueTokensFormulaWrapper()` & `_redeemTokensFormulaWrapper()`
  function:
  - Use stored decimals instead of calling the token
  - Fix logic
- Add function to execute the redemption queue manually
- Add roles (general & admin) to restrict queue execution
- Removed unused decimals parameters
- Make roles private and add public getters

* bringing back queue verification and compilation error fixes

* fixed: testClaimPreviouslyUnclaimable_GivenMultipleAmounts

* fixed testCancelPaymentOrder_RevertGivenZeroId:

- _orderExists would return true as it was even if the order didn't exist (which had orderId = 0)

- Now we verify:
   1. The order belongs to the specified client (order.client_ == address(client_))
   2. The order has been initialized (order.timestamp_ != 0)

* fixed `testGetQueueHead_RevertGivenUninitializedQueue` by:

- Checking if the queue is initialized by looking at the sentinel position in the queue's list mapping
- If the sentinel position is 0, it means the queue is uninitialized, so we revert with our own error
- Only if the queue is initialized, we proceed to get the head of the queue

* refactor(PP_Queue):

What has been done:
- Add Queue operator, queue operator admin role and getters
- refactor internal _validPaymentOrder() and call the function
  in different funcitons to replace individual validation statements
- Remove timestamp from event emit
- Update natspec across different functions
- Refactor _validateFlagsAndData() to return boolean instead of revert
- Remove unused imports

* refactor(PP_Queue): Fix open questions around todos

What has been done:
- Remove duplicate check for 0 order ID
- Change revert in _validPaymentToken() to return boolean instead

* format

* test: fix (some) PP_queue tests

* merge up to date FM and adjecent contracts into PP_Queue branch

* fix comment

* WIP

* fix state

* FIX test_PP_Queue

* test(e2e): fix setup and role assignments

- Fix main configuration and role assignments in E2E tests
- Reorganize preconditions for better test structure
- Fix and enable 8 test cases in QueueBaseFundingManagerAndPaymentProcessorE2E
- Improve role assignment logic with correct module addresses
- Clean up test initialization and setup process
- Ensure proper role hierarchy in _setadminroles function
- Format code

* fix: Wrapper function decimal conversion

* remove canceled order state

* refactor(PP_Queue_v1): add features

What has been done?
- Add addresses, getters and setters for cancelled and failed order
  treasuries
- fix _orders mapping to work with multiple clients
- Add function to claim unclaimableAmount from blacklisted address
  to the right treasury
- Refactor cancelPaymentOrderThroughQueueId
- Refactor _executePaymentTransfer such that transfers are handled
  seperately, as transfers are needed across the module

* merge FM

* test: update tests

* WIP

* fix: execute redemption queue in FM

* test: lifecycle e2e test

* Fix PP_Queue_v1_Test and rename PP_Queue_v1_Exposed

* refactor: FM_PC_External_Redeeming

* test: Refactor tests for FM_PC_External_Redeeming

* Cleanup

* Internal State Management functions implemented

* - Finished testing `testInternalRedeemTokensFormulaWrapper_worksGivenValidAmount()`
- Added `testInternalIssueTokensFormulaWrapper_worksGivenValidAmount()`
- Added `testInternalProjectFeeCollected_worksGivenValidAmount()`
- Removed MaxFee checks

* Added tests for PP_Queue_ManualExecution_v1_Test

- Tests PP_Queue_ManualExecution_v1_Test
- Removed module constant from PP_Queue_v1_Test
- Creation of PP_Queue_ManualExecution_v1_Exposed

* fix:add function to contract body

* refactor: help function for create test order

* fix test testQueueOperations_GivenValidRecipientAndAmount

* refactor: refactor more tests, add setupToken helper

* refactor:createtestOrder

* refactor:add assertOrder helper

* fix:broken test

* test: Added tests for contract PP_Queue_v1

Test Changes:
- cancelRunningPayments
- claimPreviouslyUnclaimableToTreasury
- clientIsValid
- getCanceledOrdersTreasury
- getFailedOrdersTreasury
- getQueueOperatorRoleAdmin
- onlyModule
- processPayments
- setCanceledOrdersTreasury
- setFailedOrdersTreasury
- validPaymentOrder

* fix:fix two failing tests on PP_Queue

* Implemented External Tests (public + external)

* added testPublicGetQueueOperatorRoleAdmin_succeedsGivenCorrectAdmin

* refactor:orderMatch

* implemented _createAndEmitOrder

* Covered `executePaymentQueue()` with `testExecuteRedemptionQueue_worksGivenCallerHasQueueExecutorRole`

* Added tests for:
- getOrderId()
- getOpenRedemptionAmount()

* Implemented testAmountPaid_worksGivenPaymentMade

* fix: fix issuance and redemption price calculation and update natspec

* fmt

* refactor: add create payment order

* refactor(FM_PC_ExternalPrice_Redeeming): Add fee setter checks and cleaned up

- Add check for max fee to be <= BPS
- Cleaned up the _sellOrder function by rewriting variable names
  as they were quite misleading

* refactor: Add explicit PP_Queue_ManualExecution Mock

- Removed the non required PP function from the
  PaymentProcessorV1Mock
- Extended PaymentProcessorV1Mock with additional function
  specific to PP_Queue_ManualExecution

* test(InvalidOraclePrice_Mock): Add mock to test interface check

* test(FM_PC_ExternalPrice_Redeeming_v1): 100% test coverage

- Fixed failing test
- Add tests to complete all function tested and all branching tested
- Refactored tests
- Cleaned up imports

* refactor: Update ERC20PaymentClientBase version

* refactor: make all functions virtual, as per inverter standard

* refactor: Resolve compiler warnings in PP_Queue and its test

* refactor: Update naming and contract natspec

---------

Co-authored-by: Carlos <vendrell_46@hotmail.com>
Co-authored-by: scab24 <git.seco@protonmail.com>
Co-authored-by: Marvin Kruse <marvinkruse@users.noreply.github.com>
Co-authored-by: Sergio <94926493+scab24@users.noreply.github.com>
Co-authored-by: FHieser <felix_hieser@web.de>
Co-authored-by: Felix Hieser <47272854+FHieser@users.noreply.github.com>
Co-authored-by: Leandro Faria <lee.lara1219@gmail.com>

* Feat:  Issuance/Blacklist Token Changes (#724)

* Fix: Remove blacklist manager from init

* feat: ERC20IssuanceUpgradeable token

- Add ERC20Issuance token version that is upgradeable
- Add tests

* feat: ERC20IssuanceUpgradeable_Blacklist token

- Add ERC20Issuance_Blacklist token version that is upgradeable
- Add tests

* refactor: remove initial admin from ERC20Issuance, update natspec

- The initial admin set in the constructor/init can't be picked up from
the indexer, as it only starts indexing once the token is set into
the workflow. For that reason, we removed the initial admin from the
initialization.
- Updated tests for this change
- Refactored contract natspec

* refactor: Address review comments

* Address review comments

* fix proxy admin issue

* fix address collision

---------

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

* Fixes for [Audit] FM_PC_ExternalPrice_Redeeming, LM_ManualExternalPriceSetter_v1, (#728)

* removed redundant check on `_executePaymentQueue`

* removed redundant client validation on `executePaymentQueue`

* moved `RedemptionOrderCreated` event emit before `_addPaymentOrder`

* added the bytes data from the low level call in `executeRedemptionQueue` to the custom error

* fixed format

* fixed expecRevert error from test `testExecuteRedemptionQueue_revertGivenPaymentProcessorDoesNotHaveCorrectInterface`

* formatting fixes

* refactor: remove unnecessary address validation

* refactor: remove unnecessary function overrides

* Fix: address open PR comments and adapt tests

* fix: resolve failing test in PP_Simple_v2

---------

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

* fix: compile error

* Feat: Add fee collection to Queue based FM/PP (#731)

* refactor: Address review comments

* fix: PP_Queue_v1

What has been done?

- Implement protocol fee collection on transfer
- Update contract natspec
- Adapt tests

* fix: FM_PC_Oracle_Redeeming

What has been done?
- Override `calculateSaleReturn()` to add fee calculations
- Add protocol fee calculation to `_sellOrder()` which is used
  to emit correct amounts
- Add function to retrieve fee percentages
- Update contract natspec
- Adapt tests

* docs: update natspec

* refactor: removed duplicate file, update imports

* docs: max 80 char line and full stop to contract natspec

* adddress review comments

* Add event

* Fix vm.assume to much cases error

* refactor: add internal function to ERC20Issuance_Blacklist for gas optimization

What has been done?
- Add modifier to batch function
- move adding and removing of blacklist addresses to internal functions
- Call internal functions from batched functions
- Update tests accordingly

* fix: remove revert when feeAmount == 0 in PP_Queue

What has been done?
- Remove revert when feeAmount == 0 in PP_Queue. This could block the
  queue as when canceling an order, the same revert would happen
- Add flag to disable fee collection when an orcder is canceled
- Update tests accordinly

* refactor: remove unnecessary check

* Test: Refactor test branch (#734)

* test: add files to branch

* resolve conflict

* refactor: add revert given canceldOrderTreasury is blacklist

When an order is canceled, the token amount is sent to the treasury.
In case this fails, then the treasury is blacklisted which shouldn't happen. A revert is added to catch this instance

* refactor: add revert given order state is not PENDING

In the function _processOrder, the state has to be PENDING.
If this was not the case it would return false which now has been adapted
to return a revert instead

* refactor: testing files

* refactor: delete settings.json

* refactor: move storage slot gap to end of state in contracts

* refactor(LM_Oracle_Permissioned_v1): sort public function into getter/setter

* refactor: address comments for PP_Queue and PP_Queue_ManualExecution

What has been done?
- add msg.sender check to claimPreviouslyUnclaimable
- rename headers
- move view function to correct section in contract
- updated code to make use of internal function `_addToUnclaimableAmount`
  to update the state

* refactor: FM_PC_Oracle_Redeeming

What has been done?
- add library header and section to contract
- update header names
- move view functions to correct section in contract

* refactor: FM_PC_Oracle_Redeeming

What has been done?
- add library header and section to contract
- update header names
- move view functions to correct section in contract

* refactor: LM_Oracle_Permissioned: update header

* fix: address collition in testing

* fix: test failing

---------

Co-authored-by: 0xNuggan <82726722+0xNuggan@users.noreply.github.com>
Co-authored-by: vendrell46 <vendrell_46@hotmail.com>
Co-authored-by: scab24 <git.seco@protonmail.com>
Co-authored-by: Marvin Kruse <marvinkruse@users.noreply.github.com>
Co-authored-by: Sergio <94926493+scab24@users.noreply.github.com>
Co-authored-by: Felix Hieser <47272854+FHieser@users.noreply.github.com>
Co-authored-by: FHieser <felix_hieser@web.de>
Co-authored-by: Leandro Faria <lee.lara1219@gmail.com>
Zitzak added a commit that referenced this pull request Apr 24, 2025
* Fix array orderring mismatch bug

* address _setFlags() comment

* address PaymentRouter comment

* Feat: FM_PC_ExternalPriceRedeeming, ManualExternalPriceSetter and ERC20Issuance_Blacklist

* Contract structure defined

* removed IFundingManager extension

* IFundingManager_v1 needed

* extended IRedeemingBondingCurveBase_v1 as well

* ExternalPriceSetter, blacklist, Oracle and interfaces added

* formatting files and adapting to the code of conduct

* ManualExternalPriceSetter_v1 modified as LM

* added fees checks, paymentOrder to the process and defined role for blacklist

* managing roles, renaming, and removing unneeded things

* whitelist logic removed, blacklist fixes

* missing logic implemented

* blacklist fixes and custom error added

* switched from role to mapping for blacklist manager

* moved blacklist files to external, modified sell, and more context added

* PAYMENT_QUEUE_ROLE added, _sellOrder overriden

* emit_timestamp(IssuancePriceSet,RedemptionPriceSet),NatSpec

* fix: remove collateral transfer & collateral check

- The function `handleCollateralTokensAfterSell` was still expecting to
transfer collateral, which would revert in the current implementation.
- The _sellOrder` function had a conditional check which would let
the contract revert given there will not be any collateral in the
contract

* style: run make fmt for formating

* small fixes and documentation added

* docs added for issuance and redemption setters

* Rename ERC20Issuance_blacklist_v1.sol to ERC20Issuance_Blacklist_v1.sol

* Rename IERC20Issuance_blacklist_v1.sol to IERC20Issuance_Blacklist_v1.sol

* fixed executeRedemptionQueue, docs and renaming

* formatting natspec

* feat: add treasury collateral withdraw

* Fix fmt

* fix: typo

* fix: fmt

* fix: remove oracle from init

* fixed natspec

* modifier moved

* feat: update openRedemptionAmount

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* applied suggestions

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* formatting

* Update src/modules/fundingManager/oracle/interfaces/IFM_PC_ExternalPrice_Redeeming_v1.sol

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

* formatting

* Update src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

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

* formatting

* Modifier buyingIsEnabled and sellingIsEnabled added

* formatting, updating code from parent and adding interface check

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* Update src/modules/fundingManager/oracle/interfaces/ILM_ManualExternalPriceSetter_v1.sol

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

* Update src/modules/fundingManager/oracle/interfaces/ILM_ManualExternalPriceSetter_v1.sol

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

* Update src/modules/fundingManager/oracle/interfaces/IOraclePrice_v1.sol

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

* Update src/modules/fundingManager/oracle/interfaces/IOraclePrice_v1.sol

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

* Update src/external/token/interfaces/IERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/interfaces/IERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/interfaces/IERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/interfaces/IERC20Issuance_Blacklist_v1.sol

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

* Update src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

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

* Update src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

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

* Update src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

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

* Update src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

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

* Update src/modules/fundingManager/oracle/LM_ManualExternalPriceSetter_v1.sol

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

* Update src/modules/fundingManager/oracle/LM_ManualExternalPriceSetter_v1.sol

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

* formatting

* formatting

* moved constants

* changed notice to dev

* adding named returned variable

* modifier renamed and buyingIsEnabled added to buy

* return named variables to interface

* formatting

* fix: revert during deployment

* fix issue with authorization

* fix: interface check

* interface natspec same as contract

* line too long fixed

* removed dot from title

* _ensureTokenBalance overriden

* remove function

* fix fmt

* Update src/modules/fundingManager/oracle/interfaces/IOraclePrice_v1.sol

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

* fix: Move LM_ManualPriceSetter into LM folder

---------

Co-authored-by: scab24 <git.seco@protonmail.com>
Co-authored-by: Zitzak <marvin88gr@gmail.com>
Co-authored-by: Marvin <43185740+Zitzak@users.noreply.github.com>
Co-authored-by: Marvin Kruse <marvinkruse@users.noreply.github.com>
Co-authored-by: Sergio <94926493+scab24@users.noreply.github.com>

* Fix: Remove redeemed amount from balance check

* Remove unnecessary safety check

* Abstract projectFeeCollected

* Create tests

* Fmt

* Update src/modules/fundingManager/bondingCurve/interfaces/IRedeemingBondingCurveBase_v1.sol

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

* Add check to _handleCollateralTokensAfterSell

* Revert "Add check to _handleCollateralTokensAfterSell"

This reverts commit 32f9bb3.

* Readd the check but only for projectCollateralFeeCollected

* Update IFM_BC_Bancor_Redeeming_VirtualSupply_v1.sol

* fmt

* Apply comment suggestions from code review

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

* Rename Error

* Apply suggestions from code review

* Fix: Resolve version mismatches

* Chore: Resolve formatting issue

---------

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

* fix: decimal conversion error

* fix: decimal conversion error

* fix: add 10^tokenDecimal

* Feat: Add deduction of openRedemptionAmount

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

* address _setFlags() comment

* feat(FM_PC_ExternalPrice_Redeeming): add new paymennt order struct

* fix review comments

* Fix: Revert to integer-based order ID (#707)

* Fix: Resolve typos

* gas optimization in "_setFlags"

* improve flag setting UX

* bugfix

* Add Valid Payment Order check to ProcessPayments

* FIx: Move to stable version of Foundry

* contract renaming to V2

* fix: ERC20PaymentClientBaseV2 merge issues

* Fix: Add temporary fix for failing RPCs in tests

* Feat/Fix: Fixes for audit + Queue based PP Contracts

* switched from role to mapping for blacklist manager

* moved blacklist files to external, modified sell, and more context added

* PAYMENT_QUEUE_ROLE added, _sellOrder overriden

* emit_timestamp(IssuancePriceSet,RedemptionPriceSet),NatSpec

* fix: remove collateral transfer & collateral check

- The function `handleCollateralTokensAfterSell` was still expecting to
transfer collateral, which would revert in the current implementation.
- The _sellOrder` function had a conditional check which would let
the contract revert given there will not be any collateral in the
contract

* style: run make fmt for formating

* small fixes and documentation added

* docs added for issuance and redemption setters

* Rename ERC20Issuance_blacklist_v1.sol to ERC20Issuance_Blacklist_v1.sol

* Rename IERC20Issuance_blacklist_v1.sol to IERC20Issuance_Blacklist_v1.sol

* fixed executeRedemptionQueue, docs and renaming

* formatting natspec

* feat: add treasury collateral withdraw

* Fix fmt

* fix: typo

* fix: fmt

* fix: remove oracle from init

* fixed natspec

* modifier moved

* feat: update openRedemptionAmount

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* applied suggestions

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* formatting

* Update src/modules/fundingManager/oracle/interfaces/IFM_PC_ExternalPrice_Redeeming_v1.sol

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

* formatting

* Update src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

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

* formatting

* Modifier buyingIsEnabled and sellingIsEnabled added

* formatting, updating code from parent and adding interface check

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* Update src/modules/fundingManager/oracle/interfaces/ILM_ManualExternalPriceSetter_v1.sol

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

* Update src/modules/fundingManager/oracle/interfaces/ILM_ManualExternalPriceSetter_v1.sol

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

* Update src/modules/fundingManager/oracle/interfaces/IOraclePrice_v1.sol

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

* Update src/modules/fundingManager/oracle/interfaces/IOraclePrice_v1.sol

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

* Update src/external/token/interfaces/IERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/interfaces/IERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/interfaces/IERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/interfaces/IERC20Issuance_Blacklist_v1.sol

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

* Update src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

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

* Update src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

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

* Update src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

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

* Update src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

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

* Update src/modules/fundingManager/oracle/LM_ManualExternalPriceSetter_v1.sol

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

* Update src/modules/fundingManager/oracle/LM_ManualExternalPriceSetter_v1.sol

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

* formatting

* formatting

* moved constants

* changed notice to dev

* adding named returned variable

* modifier renamed and buyingIsEnabled added to buy

* return named variables to interface

* formatting

* initial setup

* fix: revert during deployment

* fix issue with authorization

* fix: interface check

* interface natspec same as contract

* line too long fixed

* removed dot from title

* _ensureTokenBalance overriden

* remove function

* fix fmt

* work started with PP_Queue_v1

* Update src/modules/fundingManager/oracle/interfaces/IOraclePrice_v1.sol

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

* fix: Move LM_ManualPriceSetter into LM folder

* Feat: FM_PC_ExternalPriceRedeeming, ManualExternalPriceSetter and ERC20Issuance_Blacklist

* Contract structure defined

* removed IFundingManager extension

* IFundingManager_v1 needed

* extended IRedeemingBondingCurveBase_v1 as well

* ExternalPriceSetter, blacklist, Oracle and interfaces added

* formatting files and adapting to the code of conduct

* ManualExternalPriceSetter_v1 modified as LM

* added fees checks, paymentOrder to the process and defined role for blacklist

* managing roles, renaming, and removing unneeded things

* whitelist logic removed, blacklist fixes

* missing logic implemented

* blacklist fixes and custom error added

* switched from role to mapping for blacklist manager

* moved blacklist files to external, modified sell, and more context added

* PAYMENT_QUEUE_ROLE added, _sellOrder overriden

* emit_timestamp(IssuancePriceSet,RedemptionPriceSet),NatSpec

* fix: remove collateral transfer & collateral check

- The function `handleCollateralTokensAfterSell` was still expecting to
transfer collateral, which would revert in the current implementation.
- The _sellOrder` function had a conditional check which would let
the contract revert given there will not be any collateral in the
contract

* style: run make fmt for formating

* small fixes and documentation added

* docs added for issuance and redemption setters

* Rename ERC20Issuance_blacklist_v1.sol to ERC20Issuance_Blacklist_v1.sol

* Rename IERC20Issuance_blacklist_v1.sol to IERC20Issuance_Blacklist_v1.sol

* fixed executeRedemptionQueue, docs and renaming

* formatting natspec

* feat: add treasury collateral withdraw

* Fix fmt

* fix: typo

* fix: fmt

* fix: remove oracle from init

* fixed natspec

* modifier moved

* feat: update openRedemptionAmount

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* applied suggestions

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* formatting

* Update src/modules/fundingManager/oracle/interfaces/IFM_PC_ExternalPrice_Redeeming_v1.sol

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

* formatting

* Update src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

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

* formatting

* Modifier buyingIsEnabled and sellingIsEnabled added

* formatting, updating code from parent and adding interface check

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/ERC20Issuance_Blacklist_v1.sol

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

* Update src/modules/fundingManager/oracle/interfaces/ILM_ManualExternalPriceSetter_v1.sol

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

* Update src/modules/fundingManager/oracle/interfaces/ILM_ManualExternalPriceSetter_v1.sol

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

* Update src/modules/fundingManager/oracle/interfaces/IOraclePrice_v1.sol

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

* Update src/modules/fundingManager/oracle/interfaces/IOraclePrice_v1.sol

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

* Update src/external/token/interfaces/IERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/interfaces/IERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/interfaces/IERC20Issuance_Blacklist_v1.sol

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

* Update src/external/token/interfaces/IERC20Issuance_Blacklist_v1.sol

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

* Update src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

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

* Update src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

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

* Update src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

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

* Update src/modules/fundingManager/oracle/FM_PC_ExternalPrice_Redeeming_v1.sol

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

* Update src/modules/fundingManager/oracle/LM_ManualExternalPriceSetter_v1.sol

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

* Update src/modules/fundingManager/oracle/LM_ManualExternalPriceSetter_v1.sol

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

* formatting

* formatting

* moved constants

* changed notice to dev

* adding named returned variable

* modifier renamed and buyingIsEnabled added to buy

* return named variables to interface

* formatting

* fix: revert during deployment

* fix issue with authorization

* fix: interface check

* interface natspec same as contract

* line too long fixed

* removed dot from title

* _ensureTokenBalance overriden

* remove function

* fix fmt

* Update src/modules/fundingManager/oracle/interfaces/IOraclePrice_v1.sol

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

* fix: Move LM_ManualPriceSetter into LM folder

---------

Co-authored-by: scab24 <git.seco@protonmail.com>
Co-authored-by: Zitzak <marvin88gr@gmail.com>
Co-authored-by: Marvin <43185740+Zitzak@users.noreply.github.com>
Co-authored-by: Marvin Kruse <marvinkruse@users.noreply.github.com>
Co-authored-by: Sergio <94926493+scab24@users.noreply.github.com>

* Adapt to new PaymentOrder Structuring

* PP_Queue_v1 implemented

* Fix: Remove redeemed amount from balance check

* Remove unnecessary safety check

* Abstract projectFeeCollected

* Create tests

* Fmt

* Update src/modules/fundingManager/bondingCurve/interfaces/IRedeemingBondingCurveBase_v1.sol

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

* Add check to _handleCollateralTokensAfterSell

* Revert "Add check to _handleCollateralTokensAfterSell"

This reverts commit 32f9bb3.

* Readd the check but only for projectCollateralFeeCollected

* Update IFM_BC_Bancor_Redeeming_VirtualSupply_v1.sol

* fmt

* Apply comment suggestions from code review

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

* Rename Error

* Apply suggestions from code review

* Fix: Resolve version mismatches

* Chore: Resolve formatting issue

---------

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

* fix: decimal conversion error

* fix: decimal conversion error

* fix: add 10^tokenDecimal

* store unclaimable amounts after transfer failure

* changed to queue per client system

* Feat: Add deduction of openRedemptionAmount

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

* FM_PC_ExternalPrice_Redeeming_v1_Test

* removing unnecessary things and adding quick fixes

* fixing compilation error

* Update src/modules/paymentProcessor/PP_Queue_ManualExecution_v1.sol

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

* Update src/modules/paymentProcessor/PP_Queue_ManualExecution_v1.sol

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

* vesting constants removed

* reused _validPaymentOrder

* formatting and reverting call to _validPaymentOrder

* setup

* fix: update paymentOrder orderId to uint type

* renaming and formatting

* Update src/modules/paymentProcessor/PP_Queue_v1.sol

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

* Update src/modules/paymentProcessor/PP_Queue_v1.sol

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

* Update src/modules/paymentProcessor/PP_Queue_v1.sol

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

* Update src/modules/paymentProcessor/interfaces/IPP_Queue_ManualExecution_v1.sol

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

* Update src/modules/paymentProcessor/PP_Queue_v1.sol

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

* formatting and dots

* underscores

* handling unhappy paths to get queue id

* make fmt

* new_test_PP_Queue

* new_test_PP_Queue

* fixing nextOrderId and so on

* Update with FM_PC

* Update PP_Queue_v1.sol

* Update IPP_Queue_v1.sol

* new_test

* new_tests

* new tests added

* more tests for exposed functions added

* audit fixes

* Tests_PP_Queue

* Fix_Audit + Tests

* refactor: remove duplicate ERC20Mock, extend existing with decimals

* refactor: initial cleanup LM_ManualExternalPriceSetter_v1

- removed unused imports
- moved files to right directory
- renamed files
- cleaned up setup by removing unnecessary initialization, instead
reuse existing setup from ModuleTest
- format code (make fmt)

* refactor: initial setup ERC20Issuance_Blacklist_v1
- Moved file
- Removed unnecessary imports
- Use only exposed mock for testing

* refactor: FM_PC_ExternalPrice_Redeeming_v1_Test

- Remove imports
- Refactor most of the setup
- Add exposed mock
- Removed OraclePriceMock and InvalidMock
- Added simpler oracle mockf
- fmt

* refactor: remove import and fmt of LM_ManualExternalPriceSetter test

* fix: compile error

* Fix=> testExternalBuy_revertsGivenNonWhitelistedUser, testExternalBuy_succeedsGivenMaxAmount and comment testExternalQueue_succeedsGivenSingleRedemptionOrder

* Add format (Inverter Standard) PP_Queue, make pre-commit

* refactor:changed file structure

* fix:fee amount bug

* refactor:add internal func for redeem and issue

* fix:projectfeeAmount variable

* audit fix:remove normalize prices

* fix:failing test for issuance decimals

* more audit fixes

* refactor(ERC20Issuance_Blacklist): Update event, internal function

What has been done:
- Add msg.sender to events
- Move logic of modifier to internal function (Inverter Standard)

* refactor(ERC20Issuance_Blacklist_v1_Test):

- Cleaned setup
- Moved imports and functions to correct place (Inverter Standard)
- Added extensive gherkin
- Add some missing tests

* fix:add missing events to interface

* fix:inherit doc issue, code compiling, tests pass

* fix:remove unused exposed contracts

* refactor: refactor set issuance and redemption price

* refacotr: use internal functions and remove redundant function

* add:deductFromRedemption function

* fix:add msg.sender to price setter,move events to ioracle

* docs(IOraclePrice_v1): add missing param natspec

* feat: Add roles for the role admin

* event with contract address and add amountPaid added

* emit event that updates state with msgSender

* merging events and fixing compilation error

* Add PP_Queue.sol and IPP_Queue.sol

* visibility changed

* Add FundingManagerPaymentProcessorE2E, add configuration in E2EModuleRegistry, tests(2)

* improve setup, add _setupOrchestratorFundingManagerPaymentProcessor

* refactor: LM_ManualExternalPriceSetter_v1

- Add function to get collateral decimals value
- Updated natspec of price getters to work with new setup
which removed the normalization
- Moved function natpsec to interface for 2 functions

* refactor(LM_ManualExternalPriceSetter_v1_Test): refactor unit tests

What has been done:
- Cleanup the setup
- Removed unused imports
- Added missing tests for functions
- Rewrote tests to only test one function per test
- Added/rewrote gherkin
- Added exposed mock for internal function testing
- Apply Inverter Standard to formatting and file layout

* format - 1st round

* compilation errors fixed

* fix: test address collition

* fixed 2 tests out of 16

* formatting - 2nd stage

* format: update imports and rearrange public functions

* format:change content structure

* fix decimals in _redeemTokensFormulaWrapper

* client order ID fix

* deposit funds, Execute Queue

* Fix tests, delete console.log, Deposit funds in preparation for executing Queue, Execute Queue

* cherry pick from other branch

* fix: decimal convertion

* fix (;)

* refactor(FM_PC_ExternalPrice_Redeeming_v1):

What has been done:
- Add missing events for the following setter functions
  - project treasury
  - oracle
  - direct operations only
- Renamed maxBuyFee variable and function so they are mirroring
  the max sell fee, i.e maxProjectBuyFee
- Cleaned up RedemptionOrderCreated event by:
  - Add clarity to some natspec
  - Removed block.timestamp
  - Removed duplicate final redemption amount
  - Renamed variables for clarity
- Removed duplicate modifiers from sell and buy functions, as they
  redirect to the base contract functions, which have them as well
- Used similar patterns with `sell()` and `sellTo()` function as
  with buy, i.e. redirecting them to base contracts
- Add usage of internal function to add open redemption amount
- Moved event in `_createAndEmitOrder()` to `_sellOrder()` to be in
  line with how the base contract does it
- Update `_issueTokensFormulaWrapper()` & `_redeemTokensFormulaWrapper()`
  function:
  - Use stored decimals instead of calling the token
  - Fix logic
- Add function to execute the redemption queue manually
- Add roles (general & admin) to restrict queue execution
- Removed unused decimals parameters
- Make roles private and add public getters

* bringing back queue verification and compilation error fixes

* fixed: testClaimPreviouslyUnclaimable_GivenMultipleAmounts

* fixed testCancelPaymentOrder_RevertGivenZeroId:

- _orderExists would return true as it was even if the order didn't exist (which had orderId = 0)

- Now we verify:
   1. The order belongs to the specified client (order.client_ == address(client_))
   2. The order has been initialized (order.timestamp_ != 0)

* fixed `testGetQueueHead_RevertGivenUninitializedQueue` by:

- Checking if the queue is initialized by looking at the sentinel position in the queue's list mapping
- If the sentinel position is 0, it means the queue is uninitialized, so we revert with our own error
- Only if the queue is initialized, we proceed to get the head of the queue

* refactor(PP_Queue):

What has been done:
- Add Queue operator, queue operator admin role and getters
- refactor internal _validPaymentOrder() and call the function
  in different funcitons to replace individual validation statements
- Remove timestamp from event emit
- Update natspec across different functions
- Refactor _validateFlagsAndData() to return boolean instead of revert
- Remove unused imports

* refactor(PP_Queue): Fix open questions around todos

What has been done:
- Remove duplicate check for 0 order ID
- Change revert in _validPaymentToken() to return boolean instead

* format

* test: fix (some) PP_queue tests

* merge up to date FM and adjecent contracts into PP_Queue branch

* fix comment

* WIP

* fix state

* FIX test_PP_Queue

* test(e2e): fix setup and role assignments

- Fix main configuration and role assignments in E2E tests
- Reorganize preconditions for better test structure
- Fix and enable 8 test cases in QueueBaseFundingManagerAndPaymentProcessorE2E
- Improve role assignment logic with correct module addresses
- Clean up test initialization and setup process
- Ensure proper role hierarchy in _setadminroles function
- Format code

* fix: Wrapper function decimal conversion

* remove canceled order state

* refactor(PP_Queue_v1): add features

What has been done?
- Add addresses, getters and setters for cancelled and failed order
  treasuries
- fix _orders mapping to work with multiple clients
- Add function to claim unclaimableAmount from blacklisted address
  to the right treasury
- Refactor cancelPaymentOrderThroughQueueId
- Refactor _executePaymentTransfer such that transfers are handled
  seperately, as transfers are needed across the module

* merge FM

* test: update tests

* WIP

* fix: execute redemption queue in FM

* test: lifecycle e2e test

* Fix PP_Queue_v1_Test and rename PP_Queue_v1_Exposed

* refactor: FM_PC_External_Redeeming

* test: Refactor tests for FM_PC_External_Redeeming

* Cleanup

* Internal State Management functions implemented

* - Finished testing `testInternalRedeemTokensFormulaWrapper_worksGivenValidAmount()`
- Added `testInternalIssueTokensFormulaWrapper_worksGivenValidAmount()`
- Added `testInternalProjectFeeCollected_worksGivenValidAmount()`
- Removed MaxFee checks

* Added tests for PP_Queue_ManualExecution_v1_Test

- Tests PP_Queue_ManualExecution_v1_Test
- Removed module constant from PP_Queue_v1_Test
- Creation of PP_Queue_ManualExecution_v1_Exposed

* fix:add function to contract body

* refactor: help function for create test order

* fix test testQueueOperations_GivenValidRecipientAndAmount

* refactor: refactor more tests, add setupToken helper

* refactor:createtestOrder

* refactor:add assertOrder helper

* fix:broken test

* test: Added tests for contract PP_Queue_v1

Test Changes:
- cancelRunningPayments
- claimPreviouslyUnclaimableToTreasury
- clientIsValid
- getCanceledOrdersTreasury
- getFailedOrdersTreasury
- getQueueOperatorRoleAdmin
- onlyModule
- processPayments
- setCanceledOrdersTreasury
- setFailedOrdersTreasury
- validPaymentOrder

* fix:fix two failing tests on PP_Queue

* Implemented External Tests (public + external)

* added testPublicGetQueueOperatorRoleAdmin_succeedsGivenCorrectAdmin

* refactor:orderMatch

* implemented _createAndEmitOrder

* Covered `executePaymentQueue()` with `testExecuteRedemptionQueue_worksGivenCallerHasQueueExecutorRole`

* Added tests for:
- getOrderId()
- getOpenRedemptionAmount()

* Implemented testAmountPaid_worksGivenPaymentMade

* fix: fix issuance and redemption price calculation and update natspec

* fmt

* refactor: add create payment order

* refactor(FM_PC_ExternalPrice_Redeeming): Add fee setter checks and cleaned up

- Add check for max fee to be <= BPS
- Cleaned up the _sellOrder function by rewriting variable names
  as they were quite misleading

* refactor: Add explicit PP_Queue_ManualExecution Mock

- Removed the non required PP function from the
  PaymentProcessorV1Mock
- Extended PaymentProcessorV1Mock with additional function
  specific to PP_Queue_ManualExecution

* test(InvalidOraclePrice_Mock): Add mock to test interface check

* test(FM_PC_ExternalPrice_Redeeming_v1): 100% test coverage

- Fixed failing test
- Add tests to complete all function tested and all branching tested
- Refactored tests
- Cleaned up imports

* refactor: Update ERC20PaymentClientBase version

* refactor: make all functions virtual, as per inverter standard

* refactor: Resolve compiler warnings in PP_Queue and its test

* refactor: Update naming and contract natspec

---------

Co-authored-by: Carlos <vendrell_46@hotmail.com>
Co-authored-by: scab24 <git.seco@protonmail.com>
Co-authored-by: Marvin Kruse <marvinkruse@users.noreply.github.com>
Co-authored-by: Sergio <94926493+scab24@users.noreply.github.com>
Co-authored-by: FHieser <felix_hieser@web.de>
Co-authored-by: Felix Hieser <47272854+FHieser@users.noreply.github.com>
Co-authored-by: Leandro Faria <lee.lara1219@gmail.com>

* Feat:  Issuance/Blacklist Token Changes (#724)

* Fix: Remove blacklist manager from init

* feat: ERC20IssuanceUpgradeable token

- Add ERC20Issuance token version that is upgradeable
- Add tests

* feat: ERC20IssuanceUpgradeable_Blacklist token

- Add ERC20Issuance_Blacklist token version that is upgradeable
- Add tests

* refactor: remove initial admin from ERC20Issuance, update natspec

- The initial admin set in the constructor/init can't be picked up from
the indexer, as it only starts indexing once the token is set into
the workflow. For that reason, we removed the initial admin from the
initialization.
- Updated tests for this change
- Refactored contract natspec

* refactor: Address review comments

* Address review comments

* fix proxy admin issue

* fix address collision

---------

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

* Fixes for [Audit] FM_PC_ExternalPrice_Redeeming, LM_ManualExternalPriceSetter_v1, (#728)

* removed redundant check on `_executePaymentQueue`

* removed redundant client validation on `executePaymentQueue`

* moved `RedemptionOrderCreated` event emit before `_addPaymentOrder`

* added the bytes data from the low level call in `executeRedemptionQueue` to the custom error

* fixed format

* fixed expecRevert error from test `testExecuteRedemptionQueue_revertGivenPaymentProcessorDoesNotHaveCorrectInterface`

* formatting fixes

* refactor: remove unnecessary address validation

* refactor: remove unnecessary function overrides

* Fix: address open PR comments and adapt tests

* fix: resolve failing test in PP_Simple_v2

---------

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

* fix: compile error

* Feat: Add fee collection to Queue based FM/PP (#731)

* refactor: Address review comments

* fix: PP_Queue_v1

What has been done?

- Implement protocol fee collection on transfer
- Update contract natspec
- Adapt tests

* fix: FM_PC_Oracle_Redeeming

What has been done?
- Override `calculateSaleReturn()` to add fee calculations
- Add protocol fee calculation to `_sellOrder()` which is used
  to emit correct amounts
- Add function to retrieve fee percentages
- Update contract natspec
- Adapt tests

* docs: update natspec

* refactor: removed duplicate file, update imports

* docs: max 80 char line and full stop to contract natspec

* adddress review comments

* Add event

* Fix vm.assume to much cases error

* refactor: add internal function to ERC20Issuance_Blacklist for gas optimization

What has been done?
- Add modifier to batch function
- move adding and removing of blacklist addresses to internal functions
- Call internal functions from batched functions
- Update tests accordingly

* fix: remove revert when feeAmount == 0 in PP_Queue

What has been done?
- Remove revert when feeAmount == 0 in PP_Queue. This could block the
  queue as when canceling an order, the same revert would happen
- Add flag to disable fee collection when an orcder is canceled
- Update tests accordinly

* refactor: remove unnecessary check

* Test: Refactor test branch (#734)

* test: add files to branch

* resolve conflict

* refactor: add revert given canceldOrderTreasury is blacklist

When an order is canceled, the token amount is sent to the treasury.
In case this fails, then the treasury is blacklisted which shouldn't happen. A revert is added to catch this instance

* refactor: add revert given order state is not PENDING

In the function _processOrder, the state has to be PENDING.
If this was not the case it would return false which now has been adapted
to return a revert instead

* refactor: testing files

* feature: deployment script

Deployment script which deploys and setup a queue based PIM. The script
validates all the deployment and setup at each step

* refactor: address collition

* refactor: removed unnecessary imports

* refactor: add visibility modifier to state

* fix: grant & revoke workflow admin

* test: check if admin roles have been set correctly

* fix: add quotations to string in env

* refactor: add input validation for fee

* refactor: rename deployemnt log

* fix: enable option to have independed update without admin

* delete unnecessary cherry picked scripts

* refactor: delete settings.json

* refactor: move storage slot gap to end of state in contracts

* refactor(LM_Oracle_Permissioned_v1): sort public function into getter/setter

* refactor: address comments for PP_Queue and PP_Queue_ManualExecution

What has been done?
- add msg.sender check to claimPreviouslyUnclaimable
- rename headers
- move view function to correct section in contract
- updated code to make use of internal function `_addToUnclaimableAmount`
  to update the state

* refactor: FM_PC_Oracle_Redeeming

What has been done?
- add library header and section to contract
- update header names
- move view functions to correct section in contract

* refactor: FM_PC_Oracle_Redeeming

What has been done?
- add library header and section to contract
- update header names
- move view functions to correct section in contract

* refactor: LM_Oracle_Permissioned: update header

* fix: address collition in testing

* fix: test failing

* refactor: add readme and dedicated env file for workflow deployment

* refactor: rename file, update console logs

* address review comment

* refactor: rename files

---------

Co-authored-by: 0xNuggan <82726722+0xNuggan@users.noreply.github.com>
Co-authored-by: vendrell46 <vendrell_46@hotmail.com>
Co-authored-by: scab24 <git.seco@protonmail.com>
Co-authored-by: Marvin Kruse <marvinkruse@users.noreply.github.com>
Co-authored-by: Sergio <94926493+scab24@users.noreply.github.com>
Co-authored-by: Felix Hieser <47272854+FHieser@users.noreply.github.com>
Co-authored-by: FHieser <felix_hieser@web.de>
Co-authored-by: Leandro Faria <lee.lara1219@gmail.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.

3 participants