@bootnodedev/intents-framework-core v0.1.0
ERC7683 Reference Implementation
Overview
This project is centered around the Base7683 contract, which serves as the foundational component
for implementing the interfaces defined in the
ERC7683 specification. The contract is designed
to be highly flexible, supporting any orderDataType and orderData. The logic for handling specific orderData types
within the process of resolving and filling orders is intentionally left unimplemented, allowing inheriting contracts to
define this behavior.
While adhering to the ERC7683 standard, Base7683 introduces additional functionality for settling and refunding
orders. These functions are not part of the ERC7683 specification but are included to provide a unified interface for
solvers and users across all implementations built on this framework.
Inheriting contracts must implement several key internal functions to define their specific logic for order resolution, filling, settlement, and refunds. These include:
_resolveOrder(GaslessCrossChainOrder memory _order)and_resolveOrder(OnchainCrossChainOrder memory _order)for resolving orders into a hydrated format._fillOrder(bytes32 _orderId, bytes calldata _originData, bytes calldata _fillerData)for processing and filling orders._settleOrders(bytes32[] calldata _orderIds, bytes[] memory _ordersOriginData, bytes[] memory _ordersFillerData)for settling batches of orders._refundOrdersfor bothOnchainCrossChainOrderandGaslessCrossChainOrdertypes, enabling the implementation of specific refund logic._localDomain()to retrieve the local domain identifier._getOrderIdfor computing unique identifiers for bothGaslessCrossChainOrderandOnchainCrossChainOrdertypes.
These functions ensure that each inheriting contract provides its specific behavior while maintaining a consistent interface across the framework. You'll find more details of this function interfaces documented on the Base7683.
As reference, the following contracts build upon Base7683:
BasicSwap7683 The
BasicSwap7683contract extendsBase7683by implementing logic for a specificorderDatatype as defined in the OrderEncoder. This implementation facilitates token swaps, enabling the exchange of aninputTokenon the origin chain for anoutputTokenon the destination chain.Hyperlane7683 The
Hyperlane7683contract builds onBasicSwap7683by integratingHyperlaneas the interchain messaging layer. This layer ensures seamless communication between chains during order execution.
Extensibility
Both BasicSwap7683 and Hyperlane7683 are designed to be modular and extensible. Developers can use them as reference
implementations to create custom solutions. For example:
- To implement a different
orderDatatype, you could replaceBasicSwap7683with a new contract that inherits fromBase7683. TheHyperlane7683contract can remain unchanged and continue to provide messaging functionality. - Alternatively, you could replace the Hyperlane-based messaging layer in
Hyperlane7683with another interchain messaging protocol while retaining theBasicSwap7683logic.
This modular approach enables a high degree of flexibility, allowing developers to adapt the framework to various use cases and requirements.
Scripts
Deploy
- Run
npm installfrom the root of the monorepo to install all the dependencies - Create a
.envfile base on the .env.example file file, and set the required variables depending which script you are going to run.
Set the following environment variables required for running all the scripts, on each network.
NETWORK: the name of the network you want to run the scriptETHERSCAN_API_KEY: your Etherscan API keyAPI_KEY_ALCHEMY: your Alchemy API key
If the network is not listed under the rpc_endpoints section of the foundry.toml file you'll have to
add a new entry for it.
For deploying the router you have to run the npm run run:deployHyperlane7683. Make sure the following environment
variable are set:
DEPLOYER_PK: deployer private keyMAILBOX: address of Hyperlane Mailbox contract on the chainPERMIT2: Permit2 address onNETWORK_NAMEROUTER_OWNER: address of the router ownerPROXY_ADMIN_OWNER: address of the ProxyAdmin owner,ROUTER_OWNERwould be used if this is not set. The router is deployed using aTransparentUpgradeableProxy, so a ProxyAdmin contract is deployed and set as the admin of the proxy.HYPERLANE7683_SALT: a single use by chain salt for deploying the the router. Make sure you use the same on all chains so the routers are deployed all under the same address.DOMAINS: the domains list of the routers to enroll, separated by commas
Open an Order
For opening an onchain order you can run npm run run:openOrder. Make sure the following environment variable are set:
ROUTER_OWNER_PK: the router's owner private key. Only the owner can enroll routersORDER_SENDER: address of order senderORDER_RECIPIENT: address of order recipientITT_INPUT: token input addressITT_OUTPUT: token output addressAMOUNT_IN: amount inAMOUNT_OUT: amount outDESTINATION_DOMAIN: destination domain id
Usage
This is a list of the most frequently needed commands.
Build
Build the contracts:
$ yarn buildClean
Delete the build artifacts and cache directories:
$ yarn cleanCoverage
Get a test coverage report:
$ yarn coverageFormat
Format the contracts:
$ yarn sol:fmtGas Usage
Lint
Lint the contracts:
$ yarn lintTest
Run the tests:
$ yarn testGenerate test coverage and output result to the terminal:
$ yarn test:coverageGenerate test coverage with lcov report (you'll have to open the ./coverage/index.html file in your browser, to do so
simply copy paste the path):
$ yarn test:coverage:report9 months ago