Skip to content

Commit

Permalink
Merge pull request #137 from apollodao/dev/fix-force-unlock-id
Browse files Browse the repository at this point in the history
Dev/fix-force-unlock-id
  • Loading branch information
pacmanifold authored Feb 14, 2023
2 parents 5fc880c + 0d32fa1 commit 350d92f
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

3 changes: 2 additions & 1 deletion cw-dex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ edition = "2021"
license = "MPL-2.0"
name = "cw-dex"
repository = "https://github.com/apollodao/cw-dex"
version = "0.1.0"
version = "0.1.1"
readme = "README.md"

[features]
default = []
Expand Down
10 changes: 10 additions & 0 deletions cw-dex/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# cw-dex
CosmWasm abstractions for decentralized exchanges.

This crate defines a set of
traits to abstract out the common behavior of various decentralized exchanges so
that the same contract code can be used to interact with any of them.

The currently supported decentralized exchanges are:
- [Osmosis](src/implementations/osmosis/)
- [Astroport](src/implementations/astroport/)
9 changes: 8 additions & 1 deletion cw-dex/src/implementations/osmosis/staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,16 @@ impl ForceUnlock for OsmosisStaking {
&self,
_deps: Deps,
env: &Env,
lockup_id: u64,
lockup_id: Option<u64>,
amount: Uint128,
) -> Result<Response, CwDexError> {
let lockup_id = match lockup_id {
Some(id) => Ok(id),
None => self
.lock_id
.ok_or_else(|| StdError::generic_err("osmosis error: lock id not set")),
}?;

let coin_to_unlock = Coin::new(amount.u128(), self.lp_token_denom.clone());

let force_unlock_msg = MsgForceUnlock {
Expand Down
2 changes: 1 addition & 1 deletion cw-dex/src/traits/staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub trait ForceUnlock: LockedStaking {
&self,
deps: Deps,
env: &Env,
lockup_id: u64,
lockup_id: Option<u64>,
amount: Uint128,
) -> Result<Response, CwDexError>;
}
2 changes: 1 addition & 1 deletion cw-dex/tests/osmosis_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ mod tests {
// Force unlock LP tokens
let force_unlock_msg = ExecuteMsg::ForceUnlock {
amount: unlock_amount,
lockup_id: 1,
lockup_id: Some(1),
};
runner.execute_cosmos_msgs::<MsgExecuteContractResponse>(
&[force_unlock_msg.into_cosmos_msg(contract_addr.clone(), vec![])],
Expand Down
2 changes: 1 addition & 1 deletion test-contracts/osmosis-test-contract/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ pub fn execute_force_unlock(
env: Env,
_info: MessageInfo,
amount: Uint128,
lockup_id: u64,
lockup_id: Option<u64>,
) -> Result<Response, ContractError> {
let staking = STAKING.load(deps.storage)?;

Expand Down
2 changes: 1 addition & 1 deletion test-contracts/package/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub enum ExecuteMsg {
},
ForceUnlock {
amount: Uint128,
lockup_id: u64,
lockup_id: Option<u64>,
},
Swap {
offer: Asset,
Expand Down

0 comments on commit 350d92f

Please sign in to comment.