Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed never used structs #76

Merged
merged 3 commits into from
Nov 28, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 2 additions & 85 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ pub mod math;
#[derive(Debug, PartialEq, Eq, scale::Encode, scale::Decode)]
#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
pub enum InvariantError {
InsufficientSenderBalance,
InsufficientLPLocked,
PairNotFound,
MintFailed,
BurnFailed,
SwapFailed,
UnauthorizedAdmin,
PoolAlreadyExist,
PoolNotFound,
Expand All @@ -28,7 +22,7 @@ pub enum InvariantError {
NoGainSwap,
InvalidTickSpacing,
FeeTierAlreadyAdded,
UnauthorizedFeeReceriver,
UnauthorizedFeeReceiver,
ZeroLiquidity,
TransferError,
TokensAreTheSame,
Expand All @@ -37,7 +31,6 @@ pub enum InvariantError {
#[ink::contract]
pub mod contract {
use crate::InvariantError;
// use math::fee_growth::FeeGrowth;
use traceable_result::unwrap;

use crate::contracts::state::State;
Expand Down Expand Up @@ -104,13 +97,6 @@ pub mod contract {
x_to_y: bool,
}

#[ink(event)]
#[derive(Debug)]
pub struct OrderPair {
pub x: (AccountId, Balance),
pub y: (AccountId, Balance),
}

#[derive(scale::Decode, Default, scale::Encode, Clone, Debug)]
#[cfg_attr(
feature = "std",
Expand All @@ -136,13 +122,6 @@ pub mod contract {
x_to_y: bool,
}

#[derive(scale::Decode, Default, scale::Encode, Clone, Debug)]
#[cfg_attr(
feature = "std",
derive(scale_info::TypeInfo, ink::storage::traits::StorageLayout,)
)]
pub struct TokenPairs(pub Vec<(AccountId, AccountId)>);

#[ink(storage)]
#[derive(Default)]
pub struct Contract {
Expand Down Expand Up @@ -180,7 +159,7 @@ pub mod contract {
let mut pool = self.pools.get(pool_key)?;

if pool.fee_receiver != caller {
return Err(InvariantError::UnauthorizedFeeReceriver);
return Err(InvariantError::UnauthorizedFeeReceiver);
}

let (fee_protocol_token_x, fee_protocol_token_y) = pool.withdraw_protocol_fee(pool_key);
Expand Down Expand Up @@ -617,13 +596,6 @@ pub mod contract {
Ok(())
}

// positions list features
// #[ink(message)]
// pub fn add_position(&mut self) {
// let caller = self.env().caller();
// self.positions.add(caller, Position::default());
// }

#[ink(message)]
pub fn get_position(&mut self, index: u32) -> Option<Position> {
let caller = self.env().caller();
Expand Down Expand Up @@ -890,16 +862,6 @@ pub mod contract {
self.pools.get(key)
}

fn remove_pool(&mut self, key: PoolKey) {
self.pools.remove(key);
self.pool_keys.retain(|&x| x != key);
}

// Ticks
fn add_tick(&mut self, key: PoolKey, index: i32, tick: Tick) {
self.ticks.add_tick(key, index, tick);
}

#[ink(message)]
pub fn get_tick(&self, key: PoolKey, index: i32) -> Option<Tick> {
self.ticks.get_tick(key, index)
Expand All @@ -909,10 +871,6 @@ pub mod contract {
pub fn get_tickmap_bit(&self, key: PoolKey, index: i32) -> bool {
self.tickmap.get(index, key.fee_tier.tick_spacing, key)
}
fn remove_tick(&mut self, key: PoolKey, index: i32) {
self.ticks.remove_tick(key, index);
}

fn emit_swap_event(
&self,
address: AccountId,
Expand Down Expand Up @@ -1002,25 +960,6 @@ pub mod contract {
fn get_timestamp(&self) -> u64 {
self.env().block_timestamp()
}

fn _order_tokens(
&self,
token_0: AccountId,
token_1: AccountId,
balance_0: Balance,
balance_1: Balance,
) -> OrderPair {
match token_0.lt(&token_1) {
true => OrderPair {
x: (token_0, balance_0),
y: (token_1, balance_1),
},
false => OrderPair {
x: (token_1, balance_1),
y: (token_0, balance_0),
},
}
}
}

#[cfg(test)]
Expand Down Expand Up @@ -1143,28 +1082,6 @@ pub mod contract {
contract.remove_fee_tier(fee_tier_key);
assert_eq!(contract.fee_tier_keys.len(), 0);
}

#[ink::test]
fn test_ticks() {
let mut contract = Contract::new(Percentage::new(0));
let fee_tier = FeeTier {
fee: Percentage::new(1),
tick_spacing: 50u16,
};
let pool_key = PoolKey {
token_x: AccountId::from([0x0; 32]),
token_y: AccountId::from([0x0; 32]),
fee_tier,
};
let tick = Tick::default();
let index = 10i32;
contract.add_tick(pool_key, index, tick);
let recieved_tick = contract.get_tick(pool_key, index);
assert_eq!(Some(tick), recieved_tick);
contract.remove_tick(pool_key, index);
let recieved_tick = contract.get_tick(pool_key, index);
assert_eq!(None, recieved_tick);
}
}

#[cfg(all(test, feature = "e2e-tests"))]
Expand Down