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 all commits
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
82 changes: 2 additions & 80 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
#[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 @@ -27,7 +21,7 @@
NoGainSwap,
InvalidTickSpacing,
FeeTierAlreadyExist,
UnauthorizedFeeReceriver,
UnauthorizedFeeReceiver,
ZeroLiquidity,
TransferError,
TokensAreTheSame,
Expand Down Expand Up @@ -103,13 +97,6 @@
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 @@ -135,13 +122,6 @@
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 @@ -208,7 +188,7 @@
{
return Err(InvariantError::WrongLimit);
}
} else {

Check warning on line 191 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Run clippy and unit tests

this `else { if .. }` block can be collapsed
if pool.sqrt_price >= sqrt_price_limit
|| sqrt_price_limit < SqrtPrice::new(MIN_SQRT_PRICE)
{
Expand Down Expand Up @@ -312,16 +292,6 @@
self.ticks.remove(key, index);
}

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(key, index, &tick);
}

fn emit_swap_event(
&self,
address: AccountId,
Expand Down Expand Up @@ -414,25 +384,6 @@
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),
},
}
}
}

impl Invariant for Contract {
Expand All @@ -448,7 +399,7 @@
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 @@ -732,13 +683,6 @@
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)]
fn get_position(&mut self, index: u32) -> Result<Position, InvariantError> {
let caller = self.env().caller();
Expand Down Expand Up @@ -1238,28 +1182,6 @@
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!(Ok(tick), recieved_tick);
contract.remove_tick(pool_key, index);
let recieved_tick = contract.get_tick(pool_key, index);
assert_eq!(Err(InvariantError::TickNotFound), recieved_tick);
}
}

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