Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple stake targets for cw-staking adapter #70

Merged
Binary file modified app-template/artifacts/app.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion app-template/artifacts/checksums.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4e4b097907a9eb0a31d4757f73ba741ca4452e1b9f632a4500cc1dfbeba01f4d app-aarch64.wasm
3849868a9cbe2fb82bc7375148784233506ac2e70ed424b33d20061c65ca8c6e app.wasm
2 changes: 1 addition & 1 deletion app-template/artifacts/checksums_intermediate.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6a3347162d4e89d6aebafd8c7cbd40c686d8161e4b68797b39e1ca49bb4cfb49 ./target/wasm32-unknown-unknown/release/app.wasm
2a2a39252752ccfff03ad02dca930b6f1831afefb001590fe980867658571b17 /target/wasm32-unknown-unknown/release/app.wasm
Binary file removed app-template/artifacts/template_app-aarch64.wasm
Binary file not shown.
1 change: 1 addition & 0 deletions framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Install modules replaced install module method on module factory to reduce gas consumption for multi-install cases.
- Modified the account id structure. Each account is now identified with a unique ID and a trace. This is a requirement for Abstract IBC.
- Register Module(and Add Module) will now accept list of items, which reduces gas for multi-module install
- Stake methods on cw-staking adapter now accept list, allowing users to do multi-stake/unstake/etc.

### Fixed

Expand Down
17 changes: 9 additions & 8 deletions framework/packages/staking/src/command.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::msg::{RewardTokensResponse, StakeResponse, StakingInfoResponse, UnbondingResponse};
use crate::{CwStakingError, Identify};
use abstract_core::objects::AnsAsset;
use abstract_sdk::core::objects::{AssetEntry, ContractEntry};
use abstract_sdk::feature_objects::{AnsHost, VersionControlContract};
use abstract_sdk::AbstractSdkResult;
use cosmwasm_std::{Addr, CosmosMsg, Deps, Env, QuerierWrapper, Uint128};
use cw_utils::Duration;
use cosmwasm_std::{Addr, CosmosMsg, Deps, Env, QuerierWrapper};
use std::error::Error;

/// Trait that defines the staking commands for providers
Expand Down Expand Up @@ -39,23 +39,23 @@ pub trait CwStakingCommand<E: Error = CwStakingError>: Identify {
info: Option<cosmwasm_std::MessageInfo>,
ans_host: &AnsHost,
version_control_contract: &VersionControlContract,
staking_asset: AssetEntry,
staking_assets: Vec<AssetEntry>,
) -> AbstractSdkResult<()>;

/// Stake the provided asset into the staking contract
fn stake(
&self,
deps: Deps,
amount: Uint128,
unbonding_period: Option<Duration>,
stake_request: Vec<AnsAsset>,
unbonding_period: Option<cw_utils::Duration>,
) -> Result<Vec<CosmosMsg>, E>;

/// Stake the provided asset into the staking contract
fn unstake(
&self,
deps: Deps,
amount: Uint128,
unbonding_period: Option<Duration>,
unstake_request: Vec<AnsAsset>,
unbonding_period: Option<cw_utils::Duration>,
) -> Result<Vec<CosmosMsg>, E>;

/// Claim rewards on the staking contract
Expand All @@ -74,7 +74,8 @@ pub trait CwStakingCommand<E: Error = CwStakingError>: Identify {
&self,
querier: &QuerierWrapper,
staker: Addr,
unbonding_period: Option<Duration>,
stakes: Vec<AssetEntry>,
unbonding_period: Option<cw_utils::Duration>,
) -> Result<StakeResponse, E>;

/// Query information on unbonding positions for a given staker.
Expand Down
27 changes: 16 additions & 11 deletions framework/packages/staking/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,21 @@ pub struct StakingExecuteMsg {
pub enum StakingAction {
/// Stakes/bonds a given token
Stake {
asset: AnsAsset,
assets: Vec<AnsAsset>,
unbonding_period: Option<Duration>,
},

/// Unstake/unbond a given token
Unstake {
asset: AnsAsset,
assets: Vec<AnsAsset>,
unbonding_period: Option<Duration>,
},

/// Claim rewards for a given token
ClaimRewards { asset: AssetEntry },
ClaimRewards { assets: Vec<AssetEntry> },

/// Claim matured unbonding tokens
Claim { asset: AssetEntry },
Claim { assets: Vec<AssetEntry> },
}

#[cosmwasm_schema::cw_serde]
Expand All @@ -66,25 +66,25 @@ pub enum StakingQueryMsg {
#[returns(StakingInfoResponse)]
Info {
provider: ProviderName,
staking_token: AssetEntry,
staking_tokens: Vec<AssetEntry>,
},
#[returns(StakeResponse)]
Staked {
provider: ProviderName,
staking_token: AssetEntry,
staker_address: String,
unbonding_period: Option<Duration>,
stakes: Vec<AssetEntry>,
},
#[returns(UnbondingResponse)]
Unbonding {
provider: ProviderName,
staking_token: AssetEntry,
staker_address: String,
staking_tokens: Vec<AssetEntry>,
},
#[returns(RewardTokensResponse)]
RewardTokens {
provider: ProviderName,
staking_token: AssetEntry,
staking_tokens: Vec<AssetEntry>,
},
}

Expand Down Expand Up @@ -132,6 +132,11 @@ impl From<Addr> for StakingTarget {

#[cosmwasm_schema::cw_serde]
pub struct StakingInfoResponse {
pub infos: Vec<StakingInfo>,
}

#[cosmwasm_schema::cw_serde]
pub struct StakingInfo {
pub staking_target: StakingTarget,
pub staking_token: AssetInfo,
pub unbonding_periods: Option<Vec<Duration>>,
Expand All @@ -140,17 +145,17 @@ pub struct StakingInfoResponse {

#[cosmwasm_schema::cw_serde]
pub struct StakeResponse {
pub amount: Uint128,
pub amounts: Vec<Uint128>,
}

#[cosmwasm_schema::cw_serde]
pub struct RewardTokensResponse {
pub tokens: Vec<AssetInfo>,
pub tokens: Vec<Vec<AssetInfo>>,
}

#[cosmwasm_schema::cw_serde]
pub struct UnbondingResponse {
pub claims: Vec<Claim>,
pub claims: Vec<Vec<Claim>>,
}

#[cosmwasm_schema::cw_serde]
Expand Down
Loading