-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
127 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use alloy_sol_types::sol; | ||
|
||
sol! { | ||
/// Struct representing modify liquidity operation parameters. | ||
struct ModifyLiquidityParams { | ||
/// The lower tick of the position. | ||
int24 tickLower; | ||
/// The upper tick of the position. | ||
int24 tickUpper; | ||
/// How to modify the liquidity. | ||
int256 liquidityDelta; | ||
/// A value to set if you want unique liquidity positions | ||
/// at the same range. | ||
bytes32 salt; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//! Module with data types for Uniswap V4 Hooks. | ||
use alloy_primitives::{Signed, Uint, B256, I256}; | ||
|
||
mod liquidity; | ||
mod pool_key; | ||
mod swap_params; | ||
|
||
pub use liquidity::ModifyLiquidityParams; | ||
pub use pool_key::{Currency, PoolKey}; | ||
pub use swap_params::SwapParams; | ||
|
||
/// Type representing Id of a Pool. | ||
pub type PoolId = B256; | ||
|
||
/// Type representing signed 24-bits integer. | ||
pub type I24 = Signed<24, 1>; | ||
|
||
/// Type representing unsigned 24-bits integer. | ||
pub type U24 = Uint<24, 1>; | ||
|
||
/// Type representing balance delta. | ||
pub type BalanceDelta = I256; | ||
|
||
/// Type representing before swap delta. | ||
pub type BeforeSwapDelta = I256; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use alloy_primitives::keccak256; | ||
use alloy_sol_types::{sol, SolValue}; | ||
|
||
use super::PoolId; | ||
|
||
sol! { | ||
/// The currency data type. | ||
type Currency is address; | ||
|
||
/// Returns the key for identifying a pool. | ||
struct PoolKey { | ||
/// The lower currency of the pool, sorted numerically. | ||
Currency currency0; | ||
/// The higher currency of the pool, sorted numerically. | ||
Currency currency1; | ||
/// The pool LP fee, capped at 1_000_000. | ||
/// If the highest bit is 1, the pool has a dynamic fee and | ||
/// must be exactly equal to 0x800000. | ||
uint24 fee; | ||
/// Ticks that involve positions must be a multiple of tick spacing. | ||
int24 tickSpacing; | ||
/* | ||
// TODO | ||
// The hooks of the pool | ||
// IHooks hooks; | ||
*/ | ||
} | ||
} | ||
|
||
impl From<PoolKey> for PoolId { | ||
fn from(value: PoolKey) -> Self { | ||
let encoded = PoolKey::abi_encode(&value); | ||
keccak256(encoded) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use alloy_sol_types::sol; | ||
|
||
sol! { | ||
/// Struct representing swap parameters. | ||
struct SwapParams { | ||
/// Whether to swap token0 for token1 or vice versa. | ||
bool zeroForOne; | ||
/// The desired input amount if negative (exactIn), | ||
/// or the desired output amount if positive (exactOut). | ||
int256 amountSpecified; | ||
/// The sqrt price at which, if reached, the swap will stop executing. | ||
uint160 sqrtPriceLimitX96; | ||
} | ||
} |