ICurveStableSwapPool
Title: ICurveStableSwapPool
Author: Vendored minimal subset of Curve StableSwap (https://github.com/curvefi/curve-contract/blob/master/contracts/pool-templates/base/SwapTemplateBase.vy).
Upstream license: none granted ("Copyright (c) Curve.Fi, 2020 - all rights reserved").
Minimal vendored subset of a Curve StableSwap pool, specialized to a 2-coin pool.
Curve pools are generated per-N (the coins array is fixed-size in the Vyper source), so a
single Solidity signature must pin N. The Lattice Curve adapter targets the dominant
2-coin StableSwap shape (e.g. stETH/ETH, FRAX/USDC, USDe/USDC); the adapter supplies one
side via a configured coinIndex (0 or 1) and leaves the other at zero. Only the selectors
the adapter calls are declared. Methods that move funds are non-view; valuation reads are
view. NOTE: get_virtual_price() is read-only-reentrancy-exposed on real pools — see
CurveStableSwapAdapterLib.totalAssetsManaged for how the adapter avoids reading it mid
external interaction.
Functions
add_liquidity
Deposits amounts (indexed by coin) and mints at least minMint LP tokens to caller.
function add_liquidity(uint256[2] calldata amounts, uint256 minMint) external returns (uint256 minted);Parameters
| Name | Type | Description |
|---|---|---|
| amounts | uint256[2] | Per-coin deposit amounts (the adapter sets only its coinIndex slot). |
| minMint | uint256 | Minimum LP to mint (slippage floor); reverts if the pool would mint less. |
Returns
| Name | Type | Description |
|---|---|---|
| minted | uint256 | The amount of LP tokens minted to the caller. |
remove_liquidity_one_coin
Burns lp LP tokens and withdraws a single coin i, sending at least minOut.
function remove_liquidity_one_coin(uint256 lp, int128 i, uint256 minOut) external returns (uint256 out);Parameters
| Name | Type | Description |
|---|---|---|
| lp | uint256 | LP token amount to burn. |
| i | int128 | Coin index to receive (int128 per Curve ABI). |
| minOut | uint256 | Minimum coin out (slippage floor); reverts if the pool would return less. |
Returns
| Name | Type | Description |
|---|---|---|
| out | uint256 | The amount of coin i returned to the caller. |
get_virtual_price
The price of one LP token in the pool's invariant units (WAD, 1e18 == 1.0). Monotonically
non-decreasing as the pool earns fees, so lp * virtualPrice / 1e18 lower-bounds the
redeemable single-coin value (a safe NAV for an over-collateralized stable pool).
Read-only-reentrancy hazard: this can be manipulated mid-callback on real pools. Never call it during the adapter's own external interaction. See the adapter NatSpec.
function get_virtual_price() external view returns (uint256);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
coins
Returns the token address at coin index i.
function coins(uint256 i) external view returns (address);Parameters
| Name | Type | Description |
|---|---|---|
| i | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
calc_token_amount
Estimates LP minted (deposit==true) or burned (deposit==false) for amounts.
Used to size the slippage floor for add_liquidity / single-coin withdrawals. Does not
account for fees on most pools, so callers apply an extra slippageBps haircut.
function calc_token_amount(uint256[2] calldata amounts, bool deposit) external view returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
| amounts | uint256[2] | |
| deposit | bool |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
calc_withdraw_one_coin
Estimates the single-coin output of burning lp LP for coin i.
Used to size the minOut slippage floor on withdrawals.
function calc_withdraw_one_coin(uint256 lp, int128 i) external view returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
| lp | uint256 | |
| i | int128 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |