Skip to content

Commit

Permalink
fix: reflect review of #67 (#68)
Browse files Browse the repository at this point in the history
* apply review
#67 (comment)

* apply review
#67 (comment)

* error prefix for determinism

* redundant test
  • Loading branch information
byeongsu-hong authored Jan 25, 2024
1 parent 60791e1 commit b99fb29
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 36 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/tester.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,10 @@ jobs:
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Install Rust
run: rustup default 1.72.0

- name: Install Rust
run: rustup update nightly

- name: Install target
run: rustup target add wasm32-unknown-unknown
run: |
rustup default 1.72.0
rustup update nightly
rustup target add wasm32-unknown-unknown
- run: cargo fetch --verbose
- run: cargo build
Expand Down
4 changes: 2 additions & 2 deletions contracts/periphery/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ pub enum ContractError {
#[error("{0}")]
CheckedFromRatioError(#[from] cosmwasm_std::CheckedFromRatioError),

#[error("{0}")]
#[error("ibcx-math: {0}")]
IBCXMath(#[from] ibcx_math::MathError),

#[error("{0}")]
#[error("ibcx-pool: {0}")]
IBCXPool(#[from] ibcx_pool::PoolError),

#[error("Paused")]
Expand Down
13 changes: 0 additions & 13 deletions contracts/periphery/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,3 @@ pub fn simulate_burn_exact_amount_out(
swap_result_amount: coin(sim_res.max_token_out.u128(), output_asset.denom),
})
}

#[cfg(test)]
mod tests {
use cosmwasm_std::Decimal;

#[test]
fn test_sad() {
let invert = Decimal::one()
.checked_div(Decimal::from_ratio(5u64, 1000u64))
.unwrap();
assert_eq!(invert, Decimal::from_ratio(200u64, 1u64));
}
}
10 changes: 3 additions & 7 deletions packages/pool/src/sim/index_in.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,7 @@ impl<'a> Simulator<'a> {
}
};

let mut loop_count = 0;
loop {
if loop_count >= MAX_LOOP {
return Err(PoolError::MaxLoopExceeded);
}

for _ in 0..MAX_LOOP {
acc_res = self.search_efficient_amount_for_output_f(
desired_output.clone(),
acc_res.max_token_out,
Expand All @@ -175,7 +170,8 @@ impl<'a> Simulator<'a> {
{
return Ok(acc_res);
}
loop_count += 1;
}

Err(PoolError::MaxLoopExceeded)
}
}
10 changes: 3 additions & 7 deletions packages/pool/src/sim/index_out.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,7 @@ impl<'a> Simulator<'a> {
}
};

let mut loop_count = 0;
loop {
if loop_count >= MAX_LOOP {
return Err(PoolError::MaxLoopExceeded);
}

for _ in 0..MAX_LOOP {
acc_res = self.search_efficient_amount_for_input_f(
desired_input.clone(),
acc_res.est_min_token_out,
Expand All @@ -178,7 +173,8 @@ impl<'a> Simulator<'a> {
{
return Ok(acc_res);
}
loop_count += 1;
}

Err(PoolError::MaxLoopExceeded)
}
}

0 comments on commit b99fb29

Please sign in to comment.