A vault for solvers to keep liquidity between HyperEvm and Hyper Core
This project requires Node.js version 22.10.0 or higher and yarn 4.6.0 or higher. Before building, install dependencies:
yarn installTo compile the contracts, run:
npx hardhat compileTo run tests, use:
npx hardhat testDeployment scripts are located in the deploy/ directory. You can deploy the contracts using Hardhat's deploy plugin.
Make sure to configure your network settings in hardhat.config.ts before deploying.
npx hardhat deploy --network <network-name>- The solver deposits liquidity into the vault by sending tokens to the vault contract. We don't track the balance of each token in the vault, the solver is responsible for ensuring there is enough liquidity for exchanges.
- There is only the
settlementcontract that can call theexchangefunction on the vault. This is enforced by theonlySettlementmodifier. - When the
settlementcontract calls theexchangefunction, it specifies the input token, output token, the amount to be exchanged, the expiration time, and thesignaturesfrom a group of trusted signers that were pre-designated by the solver. Note that thesignaturesare over the hash of the exchange parameters, ensuring authenticity and integrity. This is the data in the message that is signed:All parameters are concatenated usingbytes32 orderUid, // unique identifier for the order address tokenIn, // address of the input token uint256 amountIn, // amount of the input token address tokenOut, // address of the output token uint256 amountOut, // amount of the output token uint256 validTo, // expiration time of the order uint256 block.chainid, // enforce on current chainId to avoid replay attacks across chains uint256 nonce, // unique number to avoid replay attacks address contractAddress, // address of this Vault contract address sender // address of the settlement contractabi.encodebefore hashing. The signatures are signed using ECDSA on the resulting hash (https://ethereum.org/developers/docs/apis/json-rpc/#eth_sign). - The vault verifies the signatures against the pre-designated trusted signers for the solver. If all the signatures are valid and meet the required threshold, the vault proceeds with the exchange.
- The vault takes the specified amount of the input token from the
settlementcontract, transferring the corresponding amount of the output token to thesettlementcontract, completing the exchange.