Skip to main content

WarrenHub

WarrenHub is the main contract Liquidity Providers (LPs) interact with. Deploys pools and handles depositing and withdrawing from those pools.

Functions

deployWarrenToken

function deployWarrenToken(
DeployWarrenTokenParams calldata params
) external returns (IWarrenToken token, PoolKey memory key)

Deploys the WarrenToken contract for a Warren position. This token represents a user's share in the Uniswap V4 LP position.

Parameters:

NameTypeDescription
paramsstruct DeployWarrenTokenParamsThe parameters necessary to deploy the WarrenToken, encoded as DeployWarrenTokenParams in calldata.

Return Values:

NameTypeDescription
tokenIWarrenTokenThe deployed WarrenToken.
keyPoolKeyThe PoolKey of the Uniswap V4 pool.

deposit

function deposit(
DepositParams calldata params
) external payable returns (uint256 shares, uint256 amount0, uint256 amount1)

Increases the amount of liquidity in a position, with tokens paid by the msg.sender, Must be called after the corresponding WarrenToken has been deployed via deployWarrenToken().

Parameters:

NameTypeDescription
paramsstruct DepositParamsThe parameters necessary for the deposit, encoded as DepositParams in calldata.

Return Values:

NameTypeDescription
sharesuint256The new share tokens minted to the sender.
amount0uint256The amount of token0 to acheive resulting liquidity.
amount1uint256The amount of token1 to acheive resulting liquidity.

withdraw

function withdraw(
WithdrawParams calldata params
) external returns (uint256 amount0, uint256 amount1)

Decreases the amount of liquidity in the position and sends the tokens to the sender. If withdrawing ETH, need to follow up with unwrapWETH9() and sweepToken(). Must be called after the corresponding WarrenToken has been deployed via deployWarrenToken().

Parameters:

NameTypeDescription
paramsstruct WithdrawParamsThe parameters necessary for the withdraw, encoded as WithdrawParams in calldata.

Return Values:

NameTypeDescription
amount0uint256The amount of token0 withdrawn to the recipient.
amount1uint256The amount of token1 withdrawn to the recipient.

queueWithdraw

function queueWithdraw(
QueueWithdrawParams calldata params
) external

Queues a withdrawal of liquidity. Need to use this before calling withdraw() if am-AMM is enabled and a manager exists for the pool. A queued withdrawal is unlocked after WITHDRAW_DELAY (1 minutes) has passed, and before WITHDRAW_GRACE_PERIOD (15 minutes) has passed after it's been unlocked. This ensures the am-AMM manager has an opportunity to execute any arbitrage trades before a withdrawal is processed.

Parameters:

NameTypeDescription
paramsstruct QueueWithdrawParamsThe parameters necessary for the queue withdraw, encoded as QueueWithdrawParams in calldata.

hookHandleSwap

hookHandleSwap(
PoolKey calldata key,
bool zeroForOne,
uint256 inputAmount,
uint256 outputAmount
) external

Called by the hook to execute a generalized swap from one token to the other. Also used during rebalancing. If the raw balance is insufficient, vault reserves will be automatically used. Will update vault reserves if the raw/reserve ratio is outside of the bounds.

Parameters:

NameTypeDescription
keystruct PoolKeyThe PoolKey of the Uniswap V4 pool.
zeroForOneboolTrue if the swap is for token0->token1, false if token1->token0.
inputAmountuint256The amount of the input token to pull from the hook.
outputAmountuint256The amount of the output token to push to the hook.

poolState

poolState(
PoolId poolId
) external view returns (PoolState memory)

The state of a Warren pool.

poolParams

function poolParams(
PoolId poolId
) external view returns (PoolState memory)

The PoolState struct of a given pool with only the immutable params filled out.

warrenTokenOfPool

function warrenTokenOfPool(
PoolId poolId
) external view returns (IWarrenToken)

The WarrenToken of a given pool. address(0) if the pool is not a Warren pool.

hookParams

function hookParams(
PoolId poolId
) external view returns (bytes32)

The params of the given Warren pool's hook. bytes32(0) if the pool is not a Warren pool.

nonce

function nonce(
bytes32 warrenSubspace
) external view returns (uint24)

The nonce of the given Warren subspace.

poolIdOfWarrenToken

function poolIdOfWarrenToken(
IWarrenToken warrenToken
) external view returns (PoolId)

The PoolId of a given WarrenToken.

poolBalances

function poolBalances(
PoolId poolId
) external view returns (uint256 balance0, uint256 balance1)

The token balances of a Warren pool. Reserves in vaults are converted to raw token balances via ERC4626.previewRedeem().

Structs

DeployWarrenTokenParams

struct DeployWarrenTokenParams {
Currency currency0;
Currency currency1;
int24 tickSpacing;
uint24 twapSecondsAgo;
ILiquidityDensityFunction liquidityDensityFunction;
IHooklet hooklet;
LDFType: ldfType;
bytes32 ldfParams;
IWarrenHook hooks;
bytes hookParams;
ERC4626 vault0;
ERC4626 vault1;
uint24 minRawTokenRatio0;
uint24 targetRawTokenRatio0;
uint24 maxRawTokenRatio0;
uint24 minRawTokenRatio1;
uint24 targetRawTokenRatio1;
uint24 maxRawTokenRatio1;
uint160 sqrtPriceX96;
bytes32 name;
bytes32 symbol;
address owner;
string metadataURI;
bytes32 salt;
}

DepositParams

struct DepositParams {
PoolKey poolKey;
address recipient;
address refundRecipient;
uint256 amount0Desired;
uint256 amount1Desired;
uint256 amount0Min;
uint256 amount1Min;
uint256 vaultFee0;
uint256 vaultFee1;
uint256 deadline;
}

WithdrawParams

struct WithdrawParams {
PoolKey poolKey;
address recipient;
uint256 shares;
uint256 amount0Min;
uint256 amount1Min;
uint256 deadline;
bool useQueuedWithdrawal;
}

QueueWithdrawParams

struct QueueWithdrawParams {
PoolKey poolKey;
uint256 shares;
}

Events

NewWarren

event NewWarren(
IWarrenToken indexed warrenToken,
PoolId indexed poolId
)

Emitted when a new IWarrenToken is created.

Parameters:

NameTypeDescription
warrenTokenIWarrenTokenThe WarrenToken associated with the call.
poolIdPoolIdThe Uniswap V4 pool's ID.

Deposit

event Deposit(
address indexed sender,
address indexed recipient,
PoolId indexed poolId,
uint256 amount0,
uint256 amount1,
uint256 shares
)

Emitted when liquidity is increased via deposit.

Parameters:

NameTypeDescription
senderaddressThe msg.sender address.
recipientaddressThe address of the account that received the share tokens.
poolIdPoolIdThe Uniswap V4 pool's ID.
amount0uint256The amount of token0 that was paid for the increase in liquidity.
amount1uint256The amount of token1 that was paid for the increase in liquidity.
sharesuint256The amount of share tokens minted to the recipient.

Withdraw

event Withdraw(
address indexed sender,
address indexed recipient,
PoolId indexed poolId,
uint256 amount0,
uint256 amount1,
uint256 shares
)

Emitted when liquidity is decreased via withdrawal.

Parameters:

NameTypeDescription
senderaddressThe msg.sender address.
recipientaddressThe address of the account that received the collected tokens.
poolIdPoolIdThe Uniswap V4 pool's ID.
amount0uint256The amount of token0 that was accounted for the decrease in liquidity.
amount1uint256The amount of token1 that was accounted for the decrease in liquidity.
sharesuint256The amount of share tokens burnt from the sender.

QueueWithdraw

event QueueWithdraw(
address indexed sender,
PoolId indexed poolId,
uint256 shares
)

Emitted when a withdrawal is queued.

Parameters:

NameTypeDescription
senderaddressThe msg.sender address.
poolIdPoolIdThe Uniswap V4 pool's ID.
sharesuint256The amount of share tokens queued for withdrawal.