Skip to content

Conversation

@marvinkruse
Copy link
Member

No description provided.

@marvinkruse marvinkruse requested a review from Zitzak December 23, 2024 13:20
@marvinkruse marvinkruse self-assigned this Dec 23, 2024
@Zitzak
Copy link
Collaborator

Zitzak commented Jan 13, 2025

Going to merge it @marvinkruse as it has been approved for some time, fyi

@Zitzak Zitzak merged commit f3ca173 into dev Jan 13, 2025
6 checks passed
@Zitzak Zitzak deleted the fix-change-orderid-payment-order branch January 13, 2025 17:31
0xNuggan added a commit that referenced this pull request Feb 21, 2025
* Fix array orderring mismatch bug

* address _setFlags() comment

* address PaymentRouter comment

* 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: Resolve versioning issues

Known issues:
- Prior versions are currently missing
- Orchestrator in this current form only supports v2 of the payment processors

Both will be fixed in a follow-up PR soon.

* Fix: Resolve formatting issues

---------

Co-authored-by: Marvin Kruse <marvinkruse@users.noreply.github.com>
Co-authored-by: Marvin <43185740+Zitzak@users.noreply.github.com>
0xNuggan pushed a commit that referenced this pull request Apr 8, 2025
0xNuggan added a commit that referenced this pull request Apr 8, 2025
* Fix array orderring mismatch bug

* address _setFlags() comment

* address PaymentRouter comment

* 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: Resolve versioning issues

Known issues:
- Prior versions are currently missing
- Orchestrator in this current form only supports v2 of the payment processors

Both will be fixed in a follow-up PR soon.

* Fix: Resolve formatting issues

---------

Co-authored-by: Marvin Kruse <marvinkruse@users.noreply.github.com>
Co-authored-by: Marvin <43185740+Zitzak@users.noreply.github.com>
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>
0xNuggan added a commit that referenced this pull request Jun 13, 2025
* Crosschain PP Contract addition - DRAFT (#686)

* add cross-chain module, contracts compile

* refactor tempalte module

* fix compile issues

* add todo's for implementation contract

* added notes handoff

* add more notes

* fix compile issues before everclear impl

* add everclear poc impl

* add everclear logic impl

* remove old templates

* code compile issue solved

* code compile issue solved

* fix minor dependency

* remove file

* added contract for bridge testing

* comment our bridge test

* add tests for base contracts

* fix file structure

* uncomment bridge return value and run fmt

* change contract to abstract

* add logic to PP_Connext_Crosschain

* fix inheritance chain

* remove function impl

* restructure directories

* seperate interfaces

* remove unecessary state variables

* add templates

* contracts compile

* adjust issues from inheritance chain

* readd execute Bridge

* fix compile error

---------

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

* Fix array orderring mismatch bug

* address _setFlags() comment

* address PaymentRouter comment

* 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: merge conflict

* Feat: Everclear crosschain payment processor and base (#694)

* add cross-chain module, contracts compile

* refactor tempalte module

* fix compile issues

* add todo's for implementation contract

* added notes handoff

add more notes

* fix compile issues before everclear impl

* add everclear poc impl

* add everclear logic impl

* remove old templates

* code compile issue solved

code compile issue solved

* fix minor dependency

* remove file

* added contract for bridge testing

comment our bridge test

* add tests for base contracts

* fix file structure

* uncomment bridge return value and run fmt

* change contract to abstract

* add logic to PP_Connext_Crosschain

* fix inheritance chain

* remove function impl

* seperate interfaces

* remove unecessary state variables

* remove unecessary state variables

* add unit tests for Connext

* unit test processPayments & xcall

fix merge conflicts

fix file structure

fix merge conflicts

finish rebasing

* fix directory structure

* unit test chainid test

* unit test processpayments test

* unit test paymentId check and test

* unit test chainId and ProcessPayment

* unit test paymentId check and test

* resolve conflicts

rebasing

rebasing

* add unit test verify bridgeData

* add unit test process payments insufficient balance

* add feedback comment

fix paths after rebase

rebased and add init

* fixed unit tests after rebase

remove init functions

* add comments and fuzz tests

add notes

* refrator test file and add unit tests

* verify executionData & add unit tests

* add ttl validation

* refractor unit tests

* add unit tests CrosschainBase_v1

* singlePayment fuzz tests added

* move balance setup internal function

* multiplePayment fuzz tests added

* camelcase changes for CrossChainBase contract

* add gherking comments

* remove unecessary variables and add comments

* add more gherkin to each test

* add validation of ttl

* add getbridgedata and natspec

* chore: cleaned code changed event name

* add templates folder

* emit PaymentProcessed via Interface

* chore: use exposed payment processor

* update gherkin for tests

* add assertions to payment processor test

* update gherkin and remove vs code settings

* feat: add cancel payments

* feat:add cancel payment & test

* feat:add retry payments & test

* fix:retry payments test

* fix:format

* fix:fmt and standard updates

* chore:delete bridging folder

* fix:rebase onto feature

* chore:remove redundant files

* fix:add standard to test file

* chore:remove redundant files

* fix:update crosschain base format

* fix:delete console import

* fix:move files to proper directories

* fix:remove impl for functions

* fix: fix retry failed payments

* chore:add comments for clarity

* fix:remove files

* add tests for unhappy paths

* chore:change mapping name

* remove redundant file

* chore:rename file

* add base test file

* fix: remove chainid impl

* chore: add unit tests

* chore: add unit tests

* fix: make unit tests generic input

* fix: process payment if else

* chore: add unit tests for PP_Crosschain_v1

* fix: add auth checks and retrypayment issue and format unit tests

* fix: change test to fuzz tests, fix minor bugs

* fix: code format invertor standard

* fix: change the _validateTransferRequest msg.sender to client

* fix: refractor the unit tests

* chore: add unit tests for client.amountPaid functionality

* fix: track processedIntentId fix

* feat: add unclaimed amount impl

* fix: format code

* fix: follow invertor standard

* refactor: Rename ERC20PaymentClientBase_v1 to v2

* refactor: adapt implementation and tests to new Payment order struct

What has been done:
- Comment implementation where it didn't compile instead of updating it
- Copied and commented test that were failing because of the change. Changed the tests to work with empty data

* feat(IERC20PaymentClientBase_v2): add maxFee and TTL to payment order comment

* refactor: CrossChainBase_v1 & ICrossChainBase_v1

What has been done:
- Removed `processPayments()` as the base is no PP
- Remove `executionData` from `executeBridgeTransfer` because of move to new payment order
- Add __gap for upgrade
- Removed unnused events/errors/struct
- Inverter Standard
 - Cleaned up import
 - Update headers in files
 - Moved functions to the correct place in file
 - Append underscore in function parameters
 - Add explicit name to return variables

* refactor: PP_Crosschain_v1 & IPP_Crosschain_v1

What has been done?
- Remove `processPayments()` as it's not an implementation but abstract
- Moved `validPaymentOrder()` from this abstract to the connext implementation,
because what makes a payment order valid differs for each implementation given the
data/flags field send
- Moved the following functionalities from the connext implementation to this abstract,
as each crosschain PP will need them, so they can be in the base:
  - `unclaimable()`
  - `claimPreviouslyUnclaimable()`
  - the internal mapping to track the unclaimable amounts
- Removed internal functions `validTimes()` as the crosschain PP doesn't vest orders
- Removed unused events/errors/structs
- Inverter Standard
  - Made state variable internal and add getters
  - Cleaned up import
  - Update headers in files
  - Moved functions to the correct place in file
  - Append underscore in function parameters
  - Add explicit name to return variables

* refactor: PP_Connext_Crosschain_v1 & IPP_Connext_Crosschain_v1

What has been done:
- Update contract with the new payment order struct, which introduces the
following changed:
  - Add Flags constants that are used to validate and read the data field of the payment order
  - Add internal functions `_validateFlagsAndData()` & `_getEverclearMaxFeeAndTTL()` to validate
  and retrieve the `maxFee` and `ttl` from the data field of the payment order
  - Remove all parameters for `executionData` as the values needed are now retrieved from
  the data fields of the payment order struct
- Moved `unclaimableAmountsForRecipient` state variable from this implementation to the base
abstract contract
- Add internal functions `_validPaymentOrder()` which checks all the values of the new
payment order. Also add call to this function in `processPayments()`
- Add internal function `_transferTokenAndApproveToBridge()` which is called when we pull assets
from the payment client, but not when retrying bridging, removing the need to pass as boolean param
to internal function `_createCrossChainIntent()`
- Renamed `retryFailedTransfer()` to `retryFailedBridgeTransfer()` to be more explicit
- Removed unused events/errors/struct
- Inverter Standard
  - Cleaned up import
  - Update headers in files
  - Moved functions to the correct place in file
  - Make state variable internal and add getters
  - Append underscore in function parameters
  - Add explicit name to return variables

* test: WIP

* fix: code refactor & fix unit tests

* fix: code refactor & fix unit tests

* chore: add interface

* chore: inverter standard changes #1

* chore: inverter standard changes #2

* chore: standardize CrossChain naming convention across files and contracts, and remove unused imports in tests

* fix:retunr data from mapping

* fix:compliation error

* refactor: refactor natspec and state variable visibility

What has been done?
- Add `.` after comments
- Set constants back to public after mistake to make them private
- update author

* refactor: Update natspec

* refactor: clean up test file, remove duplicate file after renaming

* refactor: update version in mocks

* Fix camelcase naming issue

* Remove case-conflicting file from remote tracking

* Delete test/modules/paymentProcessor/abstracts/CrosschainBase_v1.t.sol

Delete duplicate file

* fix: resolve renaming issue

* fix: inverter standard and event emission

* fix:missing modifier

* fix:fix failing tests

* fix:fix gherkin in base test

* fix:fix tag spacing and inverter  standard comments

* fix:fix imports in tests

* fix:remove helper function

* fix:tag spacing

* fix:camel case contract names

* fix: fix tests add fuzzing

* fix: function params

* fix:init natsec

* fix: folder for mocks

* fix: camelcase file issue

* fix:camel casing and compliation

* fix: file thingy issue

* Remove camelCase

* fix:compliation erro

* fix:test names

* refactor: Delete CrossChainBase_v1 contract and interface

Why?
- The contract is supposed to function as base crossChain contract for
all modules. However it is leaning to much towards payment processing due
to the use of payment orders. Because of that, the decision is make to merge it with
the PP_CrossChain contract

* refactor: PP_CrossChain_v1

What has been done?
- Add deleted functionalities from CrossChainBase
- Update contract Natspec
- Update event that emits bridge intend
  - Add more members to make it easier for the indexer
  - rename event
- Add missing Inverter Standard changes

* refactor: PP_Connext_CrossChain_v1

What has been done?
- Update contract natspec
- Update event when bridging has been succesful
- Add missing changes for Inverter Standard

* refactor: Rename implementation contract to PP_Everclear_CrossChain_v1

Why?
The contract was named after the bridging infra we used initially,
i.e. Connext. This has been changed to Everclear

* refactor: rename PP_CrossChain into PP_CrossChainBase

Why?
As this is the base crosschain contract for all the payment processors

* test: add PP_CrossChainBase test file

* refactor: PP_Everclear_CrossChain test

* fix:fix compliation errors

* fix:tests and revert statements

* chore:format

* fix:add test cases for exposed function

* refactor: PP_CrossChainBase & PP_EverClear_CrossCahin

What has been done?
- Add TokenReleased event
- Removed unused parameters
- Removed unused WETH
- Inverter standard

* wip

* fix:add tests for execute bridge transfer

* fix:add test for transfer token function

* fix:add valid payment order test

* chore:fmt

* bugfix: resolve test failing in PP_Everclear_CrossChain

---------

Co-authored-by: Zuhaib Mohammed <zzzuhaibmohd@gmail.com>
Co-authored-by: Zitzak <marvin88gr@gmail.com>
Co-authored-by: JeffreyJoel <jowoloko@gmail.com>
Co-authored-by: Marvin <43185740+Zitzak@users.noreply.github.com>

* Refactor: update version

* fix: address review comment for PP_Everclear_CrossChain

What has been done?
- add safe transfer
- deleted retryFailedBridgeTransfer function
- moved storage slot gap

* fix: address review comment PP_CrossChainBase

What has been done?
- add safe transfer
- move gap

* fix: resolve merge conflict

* refactor: resolve repo wide compiler warnings

* Create Everclear Payment Router Mock

* Add E2E test setup

* fix _getEverclearMaxFeeAndTTL()

* passing E2E, no event checking

* Intermediate state

* add ai memory bank to gitignore

* move test EverclearE2E test file

* add event checks

* start ai context cleanup

* delete ai context

* end ai-context cleanup

* refactor: resolve merge errors of imports

* refactor: update flags for payment order in Everclear PP

---------

Co-authored-by: leeftk <40748420+leeftk@users.noreply.github.com>
Co-authored-by: Zuhaib Mohammed <zzzuhaibmohd@gmail.com>
Co-authored-by: 0xNuggan <82726722+0xNuggan@users.noreply.github.com>
Co-authored-by: Marvin Kruse <marvinkruse@users.noreply.github.com>
Co-authored-by: JeffreyJoel <jowoloko@gmail.com>
marvinkruse added a commit that referenced this pull request Jun 20, 2025
* Crosschain PP Contract addition - DRAFT (#686)

* add cross-chain module, contracts compile

* refactor tempalte module

* fix compile issues

* add todo's for implementation contract

* added notes handoff

* add more notes

* fix compile issues before everclear impl

* add everclear poc impl

* add everclear logic impl

* remove old templates

* code compile issue solved

* code compile issue solved

* fix minor dependency

* remove file

* added contract for bridge testing

* comment our bridge test

* add tests for base contracts

* fix file structure

* uncomment bridge return value and run fmt

* change contract to abstract

* add logic to PP_Connext_Crosschain

* fix inheritance chain

* remove function impl

* restructure directories

* seperate interfaces

* remove unecessary state variables

* add templates

* contracts compile

* adjust issues from inheritance chain

* readd execute Bridge

* fix compile error

---------

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

* Fix array orderring mismatch bug

* address _setFlags() comment

* address PaymentRouter comment

* 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: merge conflict

* Feat: Everclear crosschain payment processor and base (#694)

* add cross-chain module, contracts compile

* refactor tempalte module

* fix compile issues

* add todo's for implementation contract

* added notes handoff

add more notes

* fix compile issues before everclear impl

* add everclear poc impl

* add everclear logic impl

* remove old templates

* code compile issue solved

code compile issue solved

* fix minor dependency

* remove file

* added contract for bridge testing

comment our bridge test

* add tests for base contracts

* fix file structure

* uncomment bridge return value and run fmt

* change contract to abstract

* add logic to PP_Connext_Crosschain

* fix inheritance chain

* remove function impl

* seperate interfaces

* remove unecessary state variables

* remove unecessary state variables

* add unit tests for Connext

* unit test processPayments & xcall

fix merge conflicts

fix file structure

fix merge conflicts

finish rebasing

* fix directory structure

* unit test chainid test

* unit test processpayments test

* unit test paymentId check and test

* unit test chainId and ProcessPayment

* unit test paymentId check and test

* resolve conflicts

rebasing

rebasing

* add unit test verify bridgeData

* add unit test process payments insufficient balance

* add feedback comment

fix paths after rebase

rebased and add init

* fixed unit tests after rebase

remove init functions

* add comments and fuzz tests

add notes

* refrator test file and add unit tests

* verify executionData & add unit tests

* add ttl validation

* refractor unit tests

* add unit tests CrosschainBase_v1

* singlePayment fuzz tests added

* move balance setup internal function

* multiplePayment fuzz tests added

* camelcase changes for CrossChainBase contract

* add gherking comments

* remove unecessary variables and add comments

* add more gherkin to each test

* add validation of ttl

* add getbridgedata and natspec

* chore: cleaned code changed event name

* add templates folder

* emit PaymentProcessed via Interface

* chore: use exposed payment processor

* update gherkin for tests

* add assertions to payment processor test

* update gherkin and remove vs code settings

* feat: add cancel payments

* feat:add cancel payment & test

* feat:add retry payments & test

* fix:retry payments test

* fix:format

* fix:fmt and standard updates

* chore:delete bridging folder

* fix:rebase onto feature

* chore:remove redundant files

* fix:add standard to test file

* chore:remove redundant files

* fix:update crosschain base format

* fix:delete console import

* fix:move files to proper directories

* fix:remove impl for functions

* fix: fix retry failed payments

* chore:add comments for clarity

* fix:remove files

* add tests for unhappy paths

* chore:change mapping name

* remove redundant file

* chore:rename file

* add base test file

* fix: remove chainid impl

* chore: add unit tests

* chore: add unit tests

* fix: make unit tests generic input

* fix: process payment if else

* chore: add unit tests for PP_Crosschain_v1

* fix: add auth checks and retrypayment issue and format unit tests

* fix: change test to fuzz tests, fix minor bugs

* fix: code format invertor standard

* fix: change the _validateTransferRequest msg.sender to client

* fix: refractor the unit tests

* chore: add unit tests for client.amountPaid functionality

* fix: track processedIntentId fix

* feat: add unclaimed amount impl

* fix: format code

* fix: follow invertor standard

* refactor: Rename ERC20PaymentClientBase_v1 to v2

* refactor: adapt implementation and tests to new Payment order struct

What has been done:
- Comment implementation where it didn't compile instead of updating it
- Copied and commented test that were failing because of the change. Changed the tests to work with empty data

* feat(IERC20PaymentClientBase_v2): add maxFee and TTL to payment order comment

* refactor: CrossChainBase_v1 & ICrossChainBase_v1

What has been done:
- Removed `processPayments()` as the base is no PP
- Remove `executionData` from `executeBridgeTransfer` because of move to new payment order
- Add __gap for upgrade
- Removed unnused events/errors/struct
- Inverter Standard
 - Cleaned up import
 - Update headers in files
 - Moved functions to the correct place in file
 - Append underscore in function parameters
 - Add explicit name to return variables

* refactor: PP_Crosschain_v1 & IPP_Crosschain_v1

What has been done?
- Remove `processPayments()` as it's not an implementation but abstract
- Moved `validPaymentOrder()` from this abstract to the connext implementation,
because what makes a payment order valid differs for each implementation given the
data/flags field send
- Moved the following functionalities from the connext implementation to this abstract,
as each crosschain PP will need them, so they can be in the base:
  - `unclaimable()`
  - `claimPreviouslyUnclaimable()`
  - the internal mapping to track the unclaimable amounts
- Removed internal functions `validTimes()` as the crosschain PP doesn't vest orders
- Removed unused events/errors/structs
- Inverter Standard
  - Made state variable internal and add getters
  - Cleaned up import
  - Update headers in files
  - Moved functions to the correct place in file
  - Append underscore in function parameters
  - Add explicit name to return variables

* refactor: PP_Connext_Crosschain_v1 & IPP_Connext_Crosschain_v1

What has been done:
- Update contract with the new payment order struct, which introduces the
following changed:
  - Add Flags constants that are used to validate and read the data field of the payment order
  - Add internal functions `_validateFlagsAndData()` & `_getEverclearMaxFeeAndTTL()` to validate
  and retrieve the `maxFee` and `ttl` from the data field of the payment order
  - Remove all parameters for `executionData` as the values needed are now retrieved from
  the data fields of the payment order struct
- Moved `unclaimableAmountsForRecipient` state variable from this implementation to the base
abstract contract
- Add internal functions `_validPaymentOrder()` which checks all the values of the new
payment order. Also add call to this function in `processPayments()`
- Add internal function `_transferTokenAndApproveToBridge()` which is called when we pull assets
from the payment client, but not when retrying bridging, removing the need to pass as boolean param
to internal function `_createCrossChainIntent()`
- Renamed `retryFailedTransfer()` to `retryFailedBridgeTransfer()` to be more explicit
- Removed unused events/errors/struct
- Inverter Standard
  - Cleaned up import
  - Update headers in files
  - Moved functions to the correct place in file
  - Make state variable internal and add getters
  - Append underscore in function parameters
  - Add explicit name to return variables

* test: WIP

* fix: code refactor & fix unit tests

* fix: code refactor & fix unit tests

* chore: add interface

* chore: inverter standard changes #1

* chore: inverter standard changes #2

* chore: standardize CrossChain naming convention across files and contracts, and remove unused imports in tests

* fix:retunr data from mapping

* fix:compliation error

* refactor: refactor natspec and state variable visibility

What has been done?
- Add `.` after comments
- Set constants back to public after mistake to make them private
- update author

* refactor: Update natspec

* refactor: clean up test file, remove duplicate file after renaming

* refactor: update version in mocks

* Fix camelcase naming issue

* Remove case-conflicting file from remote tracking

* Delete test/modules/paymentProcessor/abstracts/CrosschainBase_v1.t.sol

Delete duplicate file

* fix: resolve renaming issue

* fix: inverter standard and event emission

* fix:missing modifier

* fix:fix failing tests

* fix:fix gherkin in base test

* fix:fix tag spacing and inverter  standard comments

* fix:fix imports in tests

* fix:remove helper function

* fix:tag spacing

* fix:camel case contract names

* fix: fix tests add fuzzing

* fix: function params

* fix:init natsec

* fix: folder for mocks

* fix: camelcase file issue

* fix:camel casing and compliation

* fix: file thingy issue

* Remove camelCase

* fix:compliation erro

* fix:test names

* refactor: Delete CrossChainBase_v1 contract and interface

Why?
- The contract is supposed to function as base crossChain contract for
all modules. However it is leaning to much towards payment processing due
to the use of payment orders. Because of that, the decision is make to merge it with
the PP_CrossChain contract

* refactor: PP_CrossChain_v1

What has been done?
- Add deleted functionalities from CrossChainBase
- Update contract Natspec
- Update event that emits bridge intend
  - Add more members to make it easier for the indexer
  - rename event
- Add missing Inverter Standard changes

* refactor: PP_Connext_CrossChain_v1

What has been done?
- Update contract natspec
- Update event when bridging has been succesful
- Add missing changes for Inverter Standard

* refactor: Rename implementation contract to PP_Everclear_CrossChain_v1

Why?
The contract was named after the bridging infra we used initially,
i.e. Connext. This has been changed to Everclear

* refactor: rename PP_CrossChain into PP_CrossChainBase

Why?
As this is the base crosschain contract for all the payment processors

* test: add PP_CrossChainBase test file

* refactor: PP_Everclear_CrossChain test

* fix:fix compliation errors

* fix:tests and revert statements

* chore:format

* fix:add test cases for exposed function

* refactor: PP_CrossChainBase & PP_EverClear_CrossCahin

What has been done?
- Add TokenReleased event
- Removed unused parameters
- Removed unused WETH
- Inverter standard

* wip

* fix:add tests for execute bridge transfer

* fix:add test for transfer token function

* fix:add valid payment order test

* chore:fmt

* bugfix: resolve test failing in PP_Everclear_CrossChain

---------

Co-authored-by: Zuhaib Mohammed <zzzuhaibmohd@gmail.com>
Co-authored-by: Zitzak <marvin88gr@gmail.com>
Co-authored-by: JeffreyJoel <jowoloko@gmail.com>
Co-authored-by: Marvin <43185740+Zitzak@users.noreply.github.com>

* Refactor: update version

* fix: address review comment for PP_Everclear_CrossChain

What has been done?
- add safe transfer
- deleted retryFailedBridgeTransfer function
- moved storage slot gap

* fix: address review comment PP_CrossChainBase

What has been done?
- add safe transfer
- move gap

* fix: resolve merge conflict

* refactor: resolve repo wide compiler warnings

* Create Everclear Payment Router Mock

* Add E2E test setup

* fix _getEverclearMaxFeeAndTTL()

* passing E2E, no event checking

* Intermediate state

* add ai memory bank to gitignore

* move test EverclearE2E test file

* add event checks

* start ai context cleanup

* delete ai context

* end ai-context cleanup

* refactor: resolve merge errors of imports

* refactor: update flags for payment order in Everclear PP

---------

Co-authored-by: leeftk <40748420+leeftk@users.noreply.github.com>
Co-authored-by: Zuhaib Mohammed <zzzuhaibmohd@gmail.com>
Co-authored-by: 0xNuggan <82726722+0xNuggan@users.noreply.github.com>
Co-authored-by: Marvin Kruse <marvinkruse@users.noreply.github.com>
Co-authored-by: JeffreyJoel <jowoloko@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