Skip to content
This repository has been archived by the owner on Dec 29, 2023. It is now read-only.

Commit

Permalink
chore: add 2 endpoints for join and exit
Browse files Browse the repository at this point in the history
  • Loading branch information
kenta-elys committed Dec 8, 2023
1 parent 16b7711 commit 19269c0
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 9 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ thiserror = "1"
schemars = "0.8.1"
cosmwasm-schema = "1.1.4"
cw-utils = "0.13"
elys-bindings = { version = "0.8.0", git = "https://github.com/elys-network/bindings", tag = "v0.8.0" }
elys-bindings = { version = "0.8.0", git = "https://github.com/elys-network/bindings", branch = "feat/pool" }

[dev-dependencies]

cw-multi-test = "0.13.4"
serde_json = "1.0.107"
elys-bindings = { version = "0.8.0", git = "https://github.com/elys-network/bindings", tag = "v0.8.0", features = [
elys-bindings = { version = "0.8.0", git = "https://github.com/elys-network/bindings", branch = "feat/pool", features = [
"testing",
] }
elys-bindings-test = { version = "0.8.0", git = "https://github.com/elys-network/bindings", tag = "v0.8.0" }
elys-bindings-test = { version = "0.8.0", git = "https://github.com/elys-network/bindings", branch = "feat/pool" }
23 changes: 23 additions & 0 deletions src/action/execute/exit_amm_pool_request.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use super::*;
use cosmwasm_std::{Uint128, Coin};

pub fn exit_amm_pool_request(
info: MessageInfo,
_deps: DepsMut<ElysQuery>,
pool_id: u64,
min_amounts_out: Vec<Coin>,
share_amount_in: Uint128,
token_out_denom: String,
) -> Result<Response<ElysMsg>, ContractError> {
let msg: ElysMsg = ElysMsg::amm_exit_pool(
info.sender.into_string(),
pool_id,
min_amounts_out,
share_amount_in,
token_out_denom,
);

let resp = Response::new().add_message(msg);

Ok(resp)
}
23 changes: 23 additions & 0 deletions src/action/execute/join_amm_pool_request.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use super::*;
use cosmwasm_std::{Uint128, Coin};

pub fn join_amm_pool_request(
info: MessageInfo,
_deps: DepsMut<ElysQuery>,
pool_id: u64,
max_amounts_in: Vec<Coin>,
share_amount_out: Uint128,
no_remaining: bool,
) -> Result<Response<ElysMsg>, ContractError> {
let msg: ElysMsg = ElysMsg::amm_join_pool(
info.sender.into_string(),
pool_id,
max_amounts_in,
share_amount_out,
no_remaining,
);

let resp = Response::new().add_message(msg);

Ok(resp)
}
4 changes: 4 additions & 0 deletions src/action/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ pub mod execute {
mod eden_vest_request;
mod elys_cancel_unstake_request;
mod elys_redelegation_request;
mod join_amm_pool_request;
mod exit_amm_pool_request;

use super::*;

Expand All @@ -68,6 +70,8 @@ pub mod execute {
pub use elys_redelegation_request::elys_redelegation_request;
pub use stake_request::stake_request;
pub use unstake_request::unstake_request;
pub use join_amm_pool_request::join_amm_pool_request;
pub use exit_amm_pool_request::exit_amm_pool_request;
}

pub mod reply {
Expand Down
14 changes: 13 additions & 1 deletion src/entry_point/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ pub fn execute(
ClaimRewardsRequest { withdraw_type } => claim_rewards_request(info, deps, withdraw_type),
ClaimValidatorCommissionRequest { validator_address } => {
claim_validator_commission_request(info, deps, validator_address)
}
},
AmmJoinPoolRequest {
pool_id,
max_amounts_in,
share_amount_out,
no_remaining,
} => join_amm_pool_request(info, deps, pool_id, max_amounts_in, share_amount_out, no_remaining),
AmmExitPoolRequest {
pool_id,
min_amounts_out,
share_amount_in,
token_out_denom,
}=> exit_amm_pool_request(info, deps, pool_id, min_amounts_out, share_amount_in, token_out_denom),
}
}
14 changes: 13 additions & 1 deletion src/msg/execute_msg.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::types::{MarginOrderType, MarginPosition, OrderPrice, SpotOrderType};
use cosmwasm_schema::cw_serde;
use cosmwasm_std::{Coin, Decimal, Int128};
use cosmwasm_std::{Coin, Decimal, Int128, Uint128};
use elys_bindings::types::EarnType;

#[cw_serde]
Expand Down Expand Up @@ -76,4 +76,16 @@ pub enum ExecuteMsg {
ClaimValidatorCommissionRequest {
validator_address: String,
},
AmmJoinPoolRequest {
pool_id: u64,
max_amounts_in: Vec<Coin>,
share_amount_out: Uint128,
no_remaining: bool,
},
AmmExitPoolRequest {
pool_id: u64,
min_amounts_out: Vec<Coin>,
share_amount_in: Uint128,
token_out_denom: String,
}
}

0 comments on commit 19269c0

Please sign in to comment.