Skip to content
Merged
Show file tree
Hide file tree
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
26 changes: 19 additions & 7 deletions contracts/rewards-collector/osmosis/tests/tests/test_withdraw.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cosmwasm_std::{coin, testing::mock_env, to_binary, CosmosMsg, SubMsg, Uint128, WasmMsg};
use cosmwasm_std::{testing::mock_env, to_binary, CosmosMsg, Decimal, SubMsg, Uint128, WasmMsg};
use mars_red_bank_types::rewards_collector::{
credit_manager::{self, Action, ActionAmount, ActionCoin},
ExecuteMsg,
Expand Down Expand Up @@ -55,14 +55,17 @@ fn withdrawing_from_cm_if_action_not_allowed() {
ExecuteMsg::WithdrawFromCreditManager {
account_id: "random_id".to_string(),
actions: vec![
Action::Withdraw(coin(100u128, "uatom")),
Action::Withdraw(ActionCoin {
denom: "uatom".to_string(),
amount: ActionAmount::Exact(Uint128::new(100)),
}),
Action::Unknown {},
Action::WithdrawLiquidity {
lp_token: ActionCoin {
denom: "gamm/pool/1".to_string(),
amount: ActionAmount::AccountBalance,
},
minimum_receive: vec![],
slippage: Decimal::percent(5),
},
],
},
Expand All @@ -77,16 +80,25 @@ fn withdrawing_from_cm_successfully() {

let account_id = "random_id".to_string();
let actions = vec![
Action::Withdraw(coin(100u128, "uusdc")),
Action::Withdraw(ActionCoin {
denom: "uusdc".to_string(),
amount: ActionAmount::Exact(Uint128::new(100)),
}),
Action::WithdrawLiquidity {
lp_token: ActionCoin {
denom: "gamm/pool/1".to_string(),
amount: ActionAmount::AccountBalance,
},
minimum_receive: vec![],
slippage: Decimal::percent(5),
},
Action::Withdraw(coin(120u128, "uatom")),
Action::Withdraw(coin(140u128, "uosmo")),
Action::Withdraw(ActionCoin {
denom: "uatom".to_string(),
amount: ActionAmount::Exact(Uint128::new(120)),
}),
Action::Withdraw(ActionCoin {
denom: "uosmo".to_string(),
amount: ActionAmount::Exact(Uint128::new(140)),
}),
];

// anyone can execute a withdrawal
Expand Down
6 changes: 3 additions & 3 deletions packages/types/src/rewards_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ pub enum QueryMsg {
// TODO: rover is private repo for now so can't use it as a dependency. Use rover types once repo is public.
pub mod credit_manager {
use cosmwasm_schema::cw_serde;
use cosmwasm_std::{Coin, Uint128};
use cosmwasm_std::{Decimal, Uint128};

#[cw_serde]
pub enum ExecuteMsg {
Expand All @@ -215,10 +215,10 @@ pub mod credit_manager {

#[cw_serde]
pub enum Action {
Withdraw(Coin),
Withdraw(ActionCoin),
WithdrawLiquidity {
lp_token: ActionCoin,
minimum_receive: Vec<Coin>,
slippage: Decimal, // value validated in credit-manager
},
Unknown {}, // Used to simulate allowance only for: Withdraw and WithdrawLiquidity
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@
],
"properties": {
"withdraw": {
"$ref": "#/definitions/Coin"
"$ref": "#/definitions/ActionCoin"
}
},
"additionalProperties": false
Expand All @@ -353,17 +353,14 @@
"type": "object",
"required": [
"lp_token",
"minimum_receive"
"slippage"
],
"properties": {
"lp_token": {
"$ref": "#/definitions/ActionCoin"
},
"minimum_receive": {
"type": "array",
"items": {
"$ref": "#/definitions/Coin"
}
"slippage": {
"$ref": "#/definitions/Decimal"
}
},
"additionalProperties": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ export type OwnerUpdate =
| 'clear_emergency_owner'
export type Action =
| {
withdraw: Coin
withdraw: ActionCoin
}
| {
withdraw_liquidity: {
lp_token: ActionCoin
minimum_receive: Coin[]
slippage: Decimal
}
}
| {
Expand Down