mirror of
https://github.com/hanzoai/papers.git
synced 2026-10-29 07:34:31 +00:00
54 lines
1.4 KiB
TeX
54 lines
1.4 KiB
TeX
\section{Solidity Interface}
|
|
|
|
\label{app:solidity}
|
|
|
|
\begin{verbatim}
|
|
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.8.20;
|
|
|
|
interface IHMM {
|
|
struct Pool {
|
|
uint256[] q; // Resource reserves
|
|
uint256[] p; // Credit reserves
|
|
uint256 kappa; // Hamiltonian invariant
|
|
uint256 lambda; // Curvature parameter
|
|
uint256[] weights; // Resource weights (sum = 1e18)
|
|
uint256[] qBar; // Target reserves
|
|
uint256[] mu; // Inertia parameters
|
|
}
|
|
|
|
struct Quote {
|
|
uint256[] deltaQ; // Resources to receive
|
|
uint256 totalFee; // Total fee in credits
|
|
uint256 slippage; // Price impact (basis points)
|
|
uint256 expiry; // Quote expiration block
|
|
}
|
|
|
|
function getQuote(
|
|
uint256 poolId,
|
|
uint256[] calldata deltaP
|
|
) external view returns (Quote memory);
|
|
|
|
function swap(
|
|
uint256 poolId,
|
|
uint256[] calldata deltaP,
|
|
uint256[] calldata minQ
|
|
) external payable returns (uint256[] memory deltaQ);
|
|
|
|
function addLiquidity(
|
|
uint256 poolId,
|
|
uint256[] calldata deltaQ,
|
|
uint256[] calldata deltaP
|
|
) external returns (uint256 shares);
|
|
|
|
function removeLiquidity(
|
|
uint256 poolId,
|
|
uint256 shares
|
|
) external returns (
|
|
uint256[] memory deltaQ,
|
|
uint256[] memory deltaP
|
|
);
|
|
}
|
|
\end{verbatim}
|
|
|