Skip to content

Commit

Permalink
chore: done zap out
Browse files Browse the repository at this point in the history
  • Loading branch information
trung2891 committed Nov 9, 2024
1 parent 6539637 commit f6c208b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 22 deletions.
11 changes: 0 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ exclude = [
[workspace.dependencies]
cosmwasm-std = { version = "1.5" }
cosmwasm-schema = { version = "1.5" }
cosmwasm-storage = { version = "1.5" }
cosmwasm-vm = { version = "1.5" }
cosmos-sdk-proto = { version = "0.19", default-features = false }
osmosis-std = "0.22.0"
Expand Down
1 change: 0 additions & 1 deletion contracts/osmosis-zapper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ test-tube = []
[dependencies]
cosmwasm-std = { workspace = true }
cosmwasm-schema = { workspace = true }
cosmwasm-storage = { workspace = true }
osmosis-std = { workspace = true }
zapper = { workspace = true }
thiserror = { workspace = true }
Expand Down
3 changes: 1 addition & 2 deletions contracts/osmosis-zapper/src/reply.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use cosmwasm_std::{
coin, to_json_binary, wasm_execute, CosmosMsg, Decimal, DepsMut, Env, Order, Reply, Response,
SubMsgResult,
coin, wasm_execute, CosmosMsg, Decimal, DepsMut, Env, Order, Reply, Response, SubMsgResult,
};
use osmosis_std::types::osmosis::concentratedliquidity::v1beta1::{
MsgCreatePositionResponse, MsgTransferPositions,
Expand Down
22 changes: 15 additions & 7 deletions contracts/osmosis-zapper/src/zap.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::str::FromStr;

use cosmwasm_std::{
coin, to_json_binary, wasm_execute, CosmosMsg, DepsMut, Env, MessageInfo, Response, SubMsg,
Uint128,
coin, wasm_execute, CosmosMsg, Decimal256, DepsMut, Env, MessageInfo, Response, SubMsg, Uint128,
};
use cw_utils::one_coin;
use osmosis_std::types::{
Expand Down Expand Up @@ -242,12 +243,19 @@ pub fn zap_out_liquidity(
},
)?;

// scale 1e18
let liquidity_amount = (Decimal256::from_str(&position.liquidity)?
* Decimal256::from_str("1000000000000000000")?)
.to_string();

let withdraw_position_msg = MsgWithdrawPosition {
position_id,
sender: env.contract.address.to_string(),
liquidity_amount,
};

Ok(Response::new().add_submessage(SubMsg::reply_on_success(
MsgWithdrawPosition {
position_id,
sender: env.contract.address.to_string(),
liquidity_amount: position.liquidity,
},
withdraw_position_msg,
WITHDRAW_POSITION_ID,
)))
}

0 comments on commit f6c208b

Please sign in to comment.