Skip to content

Commit

Permalink
Audits and final optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
itsHaseebSaeed committed Feb 23, 2024
1 parent 442d26f commit 8eddf07
Show file tree
Hide file tree
Showing 30 changed files with 896 additions and 1,191 deletions.
70 changes: 0 additions & 70 deletions contracts/liquidity_book/lb_factory/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,76 +454,6 @@ fn try_create_lb_pair(
Ok(Response::new().add_submessages(messages))
}

// /// Sets whether the pair is ignored or not for routing, it will make the pair unusable by the router.
// ///
// /// # Arguments
// ///
// /// * `token_x` - The address of the first token of the pair.
// /// * `token_y` - The address of the second token of the pair.
// /// * `bin_step` - The bin step in basis point of the pair.
// /// * `ignored` - Whether to ignore (true) or not (false) the pair for routing.
// fn try_set_lb_pair_ignored(
// deps: DepsMut,
// env: Env,
// info: MessageInfo,
// token_a: TokenType,
// token_b: TokenType,
// bin_step: u16,
// ignored: bool,
// ) -> Result<Response> {
// let config = CONFIG.load(deps.storage)?;
// only_owner(&info.sender, &config.owner)?;

// let (token_a, token_b) = _sort_tokens(token_a, token_b);

// let mut pair_information = LB_PAIRS_INFO
// .load(
// deps.storage,
// (
// token_a.unique_key().clone(),
// token_b.unique_key().clone(),
// bin_step,
// ),
// )
// .unwrap();

// if pair_information
// .lb_pair
// .contract
// .address
// .as_str()
// .is_empty()
// {
// return Err(Error::LBPairDoesNotExist {
// token_x: token_a.unique_key().clone(),
// token_y: token_b.unique_key().clone(),
// bin_step,
// });
// }

// if pair_information.ignored_for_routing == ignored {
// return Err(Error::LBPairIgnoredIsAlreadyInTheSameState);
// }

// pair_information.ignored_for_routing = ignored;

// LB_PAIRS_INFO.save(
// deps.storage,
// (
// token_a.unique_key().clone(),
// token_b.unique_key().clone(),
// bin_step,
// ),
// &pair_information,
// )?;

// // emit LBPairIgnoredStateChanged(pairInformation.LBPair, ignored);

// // TODO: be more specific about which pair changed
// Ok(Response::default()
// .add_attribute_plaintext("LBPair ignored state changed", format!("{}", ignored)))
// }

/// Sets the preset parameters of a bin step
///
/// # Arguments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ impl ExampleData for ContractInfo {
}
}

// TODO - why are we using this instead of ContractInfo?
impl ExampleData for RawContract {
fn example() -> Self {
RawContract {
Expand Down Expand Up @@ -178,7 +177,6 @@ impl ExampleData for RemoveLiquidity {
amount_x_min: Uint128::from(10u128),
amount_y_min: Uint128::from(10u128),
ids: vec![ACTIVE_ID],
// TODO - understand what "amounts" means. Is that a packed_uint128?
amounts: vec![Uint256::from_u128(10u128)],
deadline: 1701283067,
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/liquidity_book/lb_pair/src/bin/secretcli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ fn main() -> io::Result<()> {
fee_info: FeeInfo {
shade_dao_address: Addr::recipient(),
lp_fee: Fee {
nom: 100_00000, //TODO: fix these
nom: 100_00000,
denom: 1000,
},
shade_dao_fee: Fee {
Expand Down
14 changes: 9 additions & 5 deletions contracts/liquidity_book/lb_pair/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,15 @@ pub fn instantiate(
CONTRACT_STATUS.save(deps.storage, &ContractStatus::Active)?;
BIN_TREE.save(deps.storage, &tree)?;
FEE_MAP_TREE.save(deps.storage, state.rewards_epoch_index, &tree)?;
REWARDS_STATS_STORE.save(deps.storage, state.rewards_epoch_index, &RewardStats {
cumm_value: Uint256::zero(),
cumm_value_mul_bin_id: Uint256::zero(),
rewards_distribution_algorithm: msg.rewards_distribution_algorithm,
})?;
REWARDS_STATS_STORE.save(
deps.storage,
state.rewards_epoch_index,
&RewardDistributionConfig {
cumulative_value: Uint256::zero(),
cumulative_value_mul_bin_id: Uint256::zero(),
rewards_distribution_algorithm: msg.rewards_distribution_algorithm,
},
)?;
EPHEMERAL_STORAGE.save(deps.storage, &EphemeralStruct {
lb_token_code_hash: msg.lb_token_implementation.code_hash,
staking_contract: msg.staking_contract_implementation,
Expand Down
2 changes: 2 additions & 0 deletions contracts/liquidity_book/lb_pair/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ pub enum LBPairError {
ZeroAmount { id: u32 },
#[error("Zero Shares for bin id: {id}")]
ZeroShares { id: u32 },
#[error("Distribution exceeded the max value")]
DistrubtionError,
#[error("Max total fee exceeded!")]
MaxTotalFeeExceeded,
#[error("Wrong Pair")]
Expand Down
Loading

0 comments on commit 8eddf07

Please sign in to comment.