Skip to content

Commit f55cfb5

Browse files
authored
Use latest credit-manager schema for withdraw. (#324)
1 parent 06308d5 commit f55cfb5

File tree

4 files changed

+28
-19
lines changed

4 files changed

+28
-19
lines changed

contracts/rewards-collector/osmosis/tests/tests/test_withdraw.rs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use cosmwasm_std::{coin, testing::mock_env, to_binary, CosmosMsg, SubMsg, Uint128, WasmMsg};
1+
use cosmwasm_std::{testing::mock_env, to_binary, CosmosMsg, Decimal, SubMsg, Uint128, WasmMsg};
22
use mars_red_bank_types::rewards_collector::{
33
credit_manager::{self, Action, ActionAmount, ActionCoin},
44
ExecuteMsg,
@@ -55,14 +55,17 @@ fn withdrawing_from_cm_if_action_not_allowed() {
5555
ExecuteMsg::WithdrawFromCreditManager {
5656
account_id: "random_id".to_string(),
5757
actions: vec![
58-
Action::Withdraw(coin(100u128, "uatom")),
58+
Action::Withdraw(ActionCoin {
59+
denom: "uatom".to_string(),
60+
amount: ActionAmount::Exact(Uint128::new(100)),
61+
}),
5962
Action::Unknown {},
6063
Action::WithdrawLiquidity {
6164
lp_token: ActionCoin {
6265
denom: "gamm/pool/1".to_string(),
6366
amount: ActionAmount::AccountBalance,
6467
},
65-
minimum_receive: vec![],
68+
slippage: Decimal::percent(5),
6669
},
6770
],
6871
},
@@ -77,16 +80,25 @@ fn withdrawing_from_cm_successfully() {
7780

7881
let account_id = "random_id".to_string();
7982
let actions = vec![
80-
Action::Withdraw(coin(100u128, "uusdc")),
83+
Action::Withdraw(ActionCoin {
84+
denom: "uusdc".to_string(),
85+
amount: ActionAmount::Exact(Uint128::new(100)),
86+
}),
8187
Action::WithdrawLiquidity {
8288
lp_token: ActionCoin {
8389
denom: "gamm/pool/1".to_string(),
8490
amount: ActionAmount::AccountBalance,
8591
},
86-
minimum_receive: vec![],
92+
slippage: Decimal::percent(5),
8793
},
88-
Action::Withdraw(coin(120u128, "uatom")),
89-
Action::Withdraw(coin(140u128, "uosmo")),
94+
Action::Withdraw(ActionCoin {
95+
denom: "uatom".to_string(),
96+
amount: ActionAmount::Exact(Uint128::new(120)),
97+
}),
98+
Action::Withdraw(ActionCoin {
99+
denom: "uosmo".to_string(),
100+
amount: ActionAmount::Exact(Uint128::new(140)),
101+
}),
90102
];
91103

92104
// anyone can execute a withdrawal

packages/types/src/rewards_collector.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ pub enum QueryMsg {
203203
// TODO: rover is private repo for now so can't use it as a dependency. Use rover types once repo is public.
204204
pub mod credit_manager {
205205
use cosmwasm_schema::cw_serde;
206-
use cosmwasm_std::{Coin, Uint128};
206+
use cosmwasm_std::{Decimal, Uint128};
207207

208208
#[cw_serde]
209209
pub enum ExecuteMsg {
@@ -215,10 +215,10 @@ pub mod credit_manager {
215215

216216
#[cw_serde]
217217
pub enum Action {
218-
Withdraw(Coin),
218+
Withdraw(ActionCoin),
219219
WithdrawLiquidity {
220220
lp_token: ActionCoin,
221-
minimum_receive: Vec<Coin>,
221+
slippage: Decimal, // value validated in credit-manager
222222
},
223223
Unknown {}, // Used to simulate allowance only for: Withdraw and WithdrawLiquidity
224224
}

schemas/mars-rewards-collector-base/mars-rewards-collector-base.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@
338338
],
339339
"properties": {
340340
"withdraw": {
341-
"$ref": "#/definitions/Coin"
341+
"$ref": "#/definitions/ActionCoin"
342342
}
343343
},
344344
"additionalProperties": false
@@ -353,17 +353,14 @@
353353
"type": "object",
354354
"required": [
355355
"lp_token",
356-
"minimum_receive"
356+
"slippage"
357357
],
358358
"properties": {
359359
"lp_token": {
360360
"$ref": "#/definitions/ActionCoin"
361361
},
362-
"minimum_receive": {
363-
"type": "array",
364-
"items": {
365-
"$ref": "#/definitions/Coin"
366-
}
362+
"slippage": {
363+
"$ref": "#/definitions/Decimal"
367364
}
368365
},
369366
"additionalProperties": false

scripts/types/generated/mars-rewards-collector-base/MarsRewardsCollectorBase.types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ export type OwnerUpdate =
8585
| 'clear_emergency_owner'
8686
export type Action =
8787
| {
88-
withdraw: Coin
88+
withdraw: ActionCoin
8989
}
9090
| {
9191
withdraw_liquidity: {
9292
lp_token: ActionCoin
93-
minimum_receive: Coin[]
93+
slippage: Decimal
9494
}
9595
}
9696
| {

0 commit comments

Comments
 (0)