Warning
This project is still in a very early and experimental phase. It has never been audited nor thoroughly reviewed for security vulnerabilities. Do not use in production.
- The example curve lib.rs demonstrates a constant-sum swap curve, in which tokens are traded exactly 1:1.
Tip
You can modify ICurve
trait based on your needs, or provide your custom algorithm
for a swap curve calculation.
Caution
If anything changes in the contract's interface, make sure to update your Solidity contract with Uniswap hooks to use the new Solidity ABI Interface of this contract.
Follow the instructions in the Stylus quickstart to configure your development environment.
You'll also need Foundry to interact with the contract.
You can use cargo stylus to check that your contract is compatible with Stylus by running
cargo stylus check
With the following command you can deploy it to an Arbitrum chain
cargo stylus deploy --endpoint $RPC_URL --private-key $PRIVATE_KEY
For unit testing, this example integrates the motsu library from OpenZeppelin. To run unit tests, you can simply use
cargo test --locked --features std --lib
Alternatively, you can use the bash script available test-unit.sh.
To export the Solidity ABI interface run the following command
cargo stylus export-abi
Instructions to setup a local dev node can be found here.
This is the current Solidity ABI Interface for the contract
interface IUniswapCurve {
function getAmountInForExactOutput(uint256 amount_out, address input, address output, bool zero_for_one) external returns (uint256);
function getAmountOutFromExactInput(uint256 amount_in, address input, address output, bool zero_for_one) external returns (uint256);
error CurveCustomError();
}