-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from osmosis-labs/sumtree/tick-state
[Sumtree]: Tick State
- Loading branch information
Showing
5 changed files
with
48 additions
and
36 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
mod order; | ||
mod orderbook; | ||
mod reply_id; | ||
mod tick; | ||
|
||
pub use self::order::*; | ||
pub use self::orderbook::*; | ||
pub use self::reply_id::*; | ||
pub use self::tick::*; |
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,32 @@ | ||
use cosmwasm_schema::cw_serde; | ||
use cosmwasm_std::Decimal256; | ||
|
||
/// Represents the state of a specific price tick in a liquidity pool. | ||
#[cw_serde] | ||
pub struct TickState { | ||
/// Total Amount of Liquidity at tick (TAL) | ||
/// - Every limit order placement increments this value. | ||
/// - Every swap at this tick decrements this value. | ||
/// - Every cancellation decrements this value. | ||
pub total_amount_of_liquidity: Decimal256, | ||
|
||
/// Cumulative Total Limits at tick (CTT) | ||
/// - Every limit order placement increments this value. | ||
/// - There might be an edge-case optimization to lower this value. | ||
pub cumulative_total_limits: Decimal256, | ||
|
||
/// Effective Total Amount Swapped at tick (ETAS) | ||
/// - Every swap increments ETAS by the swap amount. | ||
/// - There will be other ways to update ETAS as described below. | ||
pub effective_total_amount_swapped: Decimal256, | ||
} | ||
|
||
impl Default for TickState { | ||
fn default() -> Self { | ||
TickState { | ||
total_amount_of_liquidity: Decimal256::zero(), | ||
cumulative_total_limits: Decimal256::zero(), | ||
effective_total_amount_swapped: Decimal256::zero(), | ||
} | ||
} | ||
} |