feat(onramp): add settleIn function and onramp order settlement support#81
Open
onahprosper wants to merge 23 commits intomainfrom
Open
feat(onramp): add settleIn function and onramp order settlement support#81onahprosper wants to merge 23 commits intomainfrom
onahprosper wants to merge 23 commits intomainfrom
Conversation
…ate event names in IGateway interface
…stence check in Gateway contract
…Out and implement settleIn for order processing
…ependencies and add license information for several packages
…tocol fees - Changed the data structure in IGateway interface to replace senderFeeRecipient with aggregatorFee. - Updated Gateway contract logic to calculate and transfer aggregator fees instead of protocol fees. - Modified settleOrder tests to reflect changes in fee calculations and ensure correct amounts are transferred. - Removed unused event SenderFeeTransferred from Events.
…regator address retrieval - Renamed variables for clarity in fee calculations, changing `senderAmount` to `amountToSettle`. - Updated logic to correctly handle aggregator fees during order settlements. - Added a new function `getAggregator` in the IGateway interface to retrieve the aggregator address. - Adjusted event emissions to reflect changes in fee handling.
…nt after deducting all fees - Adjusted transfer logic to handle gross amount and subtract sender and protocol fees. - Updated variable names for clarity, changing `senderAmount` to `recipientAmount`. - Ensured that the correct amount is transferred to the recipient after all fees are deducted. - Emitted settlement event with the updated recipient amount.
- Updated index files to export MockUSDT and its factory. - Modified IGateway interface to include changes in event parameters for SettleIn. - Updated hardhat types to include new contract factories and deployment methods for ProxyAdmin and TransparentUpgradeableProxy. - Refactored existing index files to organize exports for better clarity and maintainability.
- Changed Mocha version from 11.7.5 to 11.3.0 in package.json and package-lock.json. - Updated hardhat.config.ts to move Mocha timeout settings under the new test configuration structure. - Adjusted TypeScript configuration to use ES2020 module syntax and bundler resolution.
…ening - Implemented a new task to print available accounts and their ETH balances. - Created a task to flatten specified contracts and their dependencies, with license handling.
- Changed RPC URLs for various networks in hardhat.config.ts to new endpoints. - Added chainId for Celo network in the configuration. - Updated package dependencies, including upgrading Hardhat to version 3.1.9 and adjusting related packages. - Added license information for several packages in package-lock.json and yarn.lock. - Removed autogenerated artifacts from the artifacts directory to clean up the project.
…ansfers - Integrated SafeERC20 library to ensure safe token transfers in the Gateway contract. - Replaced direct transfer calls with safeTransfer and safeTransferFrom methods to prevent potential issues with token transfers. - Updated deployment addresses in the Ignition configuration for the Gateway contract. - Adjusted README to reflect changes in deployment commands and network configurations.
|
Important Review skippedToo many files! This PR contains 182 files, which is 32 over the limit of 150. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (3)
📒 Files selected for processing (182)
You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
- Deleted package-lock.json to eliminate outdated dependency locks and ensure a fresh installation of packages. - This change may require reinstallation of dependencies to generate a new lock file.
- Upgraded Node.js version from 18.16.0 to 22.22.0 in the GitHub Actions workflow for Hardhat. - This change ensures compatibility with the latest features and improvements in Node.js.
- Updated buildInfoId for TransparentUpgradeableProxy and ProxyAdmin to reflect the latest Solidity compiler version. - Removed outdated build-info files to clean up the artifacts directory. - Adjusted bytecode and deployedBytecode in the respective JSON and TypeScript files to ensure consistency with the latest contract implementations.
- Commented out the hardhat-mocha plugin in hardhat.config.ts to streamline the configuration. - Adjusted the plugins array to exclude the commented-out Mocha plugin for clarity.
…i Matchers plugin - Commented out the hardhat-ethers-chai-matchers import in hardhat.config.ts to simplify the configuration. - Updated the plugins array to exclude the commented-out Ethers Chai Matchers plugin for better clarity.
- Introduced package-lock.json to lock down the project's dependencies for consistent installations. - Added @nomicfoundation/hardhat-ethers-chai-matchers as a new dependency in package.json. - Updated several dependencies in yarn.lock, including hardhat and its related packages, to their latest versions for improved stability and features.
- Introduced several new dependencies including hardhat-ignition, hardhat-ignition-ethers, hardhat-keystore, hardhat-mocha, and ignition-core to package.json. - These additions aim to improve the development experience and expand the capabilities of the Hardhat environment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds onramp support to the Gateway contract, enabling liquidity providers to settle inbound (crypto-to-fiat) orders directly on-chain. Previously the contract only supported offramp flows via
settleOut. The following changes are introduced:Gateway contract —
contracts/Gateway.solsettleInfunction: accepts an order ID, token, amount, sender fee details, recipient, and rate. It validates the order, transfers funds from the caller, computes and routes the aggregator fee (for FX transfers viaproviderToAggregatorFx) or triggers local fee splitting (for local transfers at rate 100), records order state, transfers the net amount to the recipient, and emitsSettleIn.settle→settleOutfor symmetry with the newsettleIn._handleLocalTransferFeeSplittingand_handleFxTransferFeeSplittingfor accurate fee distribution between the sender fee recipient, liquidity provider, and aggregator.SafeERC20(safeTransfer/safeTransferFrom) for secure ERC-20 handling.IGateway interface —
contracts/interfaces/IGateway.solSettleInevent withorderId,liquidityProvider,recipient,amount,token,aggregatorFee, andrateparameters.OrderSettled→SettleOut.settleInfunction signature with full NatSpec documentation.New contract —
contracts/ProviderBatchCallAndSponsor.solsettleIncalls in a single transaction, reducing gas overhead for high-volume onramp settlement.Tooling and infrastructure
accounts(list signers) andflatten(produce a flattened source).Gateway,GatewayDeployProxy,GatewayUpgrade, andProviderBatchCallAndSponsoracross all supported chains: Ethereum, Optimism, Polygon, Arbitrum, Celo, BNB Chain, Base, Scroll, and Manta.Tests
test/gateway/gateway.settleOrder.test.jsto coversettleInscenarios including correct fee deductions, recipient transfers, event emission, and revert conditions.References
closes #73
Testing
npm installoryarnnpx hardhat compilenpx hardhat testtest/gateway/gateway.settleOrder.test.jsManual end-to-end:
npx hardhat ignition deploy ignition/modules/GatewayDeployProxy.ts --network <network>settleInwith a valid token, amount, and recipient address.SettleInevent is emitted with correct fee values and the recipient receives the net amount.Environment: Hardhat · Solidity ^0.8.18 · Node.js 18+ · ethers v6
Checklist
mainBy submitting a PR, I agree to Paycrest's Contributor Code of Conduct and Contribution Guide.