Skip to content
This repository has been archived by the owner on Nov 15, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop' into tier
Browse files Browse the repository at this point in the history
  • Loading branch information
amityadav0 authored Jun 20, 2024
2 parents 7034bb1 + 29d25a6 commit 5187eec
Show file tree
Hide file tree
Showing 16 changed files with 834 additions and 87 deletions.
397 changes: 397 additions & 0 deletions .github/workflows/pipeline.yml

Large diffs are not rendered by default.

48 changes: 0 additions & 48 deletions .github/workflows/release.yml

This file was deleted.

24 changes: 0 additions & 24 deletions .github/workflows/test.yml

This file was deleted.

1 change: 1 addition & 0 deletions .version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.2.6
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,34 @@ This guide provides instructions on how to spin up a new localnet using the Elys

This command will install the `elysd` daemon.

3. **Download the Latest Snapshot**
3. **Download the Latest TestNet Snapshot**

Get the latest snapshot available for the Elys network by using the following command:
Get the latest TestNet snapshot available for the Elys network.

**Main branch**

Use the following command to download the latest TestNet snapshot that uses the changes from the `main` branch:

```bash
rm -rf ~/.elys && curl -o - -L https://snapshots.elys.network/elys-snapshot-main.tar.lz4 | lz4 -c -d - | tar -x -C ~/
```

**Devnet branch**

Use the following command to download the latest TestNet snapshot that uses the changes from the `devnet` branch:

```bash
rm -rf ~/.elys && curl -o - -L https://snapshots.elys.network/elys-snapshot-devnet.tar.lz4 | lz4 -c -d - | tar -x -C ~/
```

**Develop branch**

Use the following command to download the latest TestNet snapshot that uses the changes from the `develop` branch:

```bash
rm -rf ~/.elys && curl -o - -L https://snapshots.elys.network/elys-snapshot-develop.tar.lz4 | lz4 -c -d - | tar -x -C ~/
```

4. **Spin Up the Localnet**

Use the command below to start the localnet:
Expand Down
3 changes: 3 additions & 0 deletions bindings-test/src/multitest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ impl Module for ElysModule {
request: Self::QueryT,
) -> AnyResult<cosmwasm_std::Binary> {
match request {
ElysQuery::ParameterParams {} => todo!("ParameterParams"),
ElysQuery::LeveragelpParams { .. } => {
let resp = LeveragelpParamsResponse {
params: Some(LeveragelpParams {
Expand Down Expand Up @@ -662,6 +663,7 @@ impl Module for ElysModule {
})?)
}
ElysQuery::CommitmentNumberOfCommitments {} => todo!("CommitmentNumberOfCommitments"),
ElysQuery::LeveragelpRewards { .. } => todo!(),
}
}

Expand Down Expand Up @@ -1065,6 +1067,7 @@ impl Module for ElysModule {
data: Some(data),
})
}
ElysMsg::LeveragelpClaimRewards { .. } => todo!(),
}
}

Expand Down
8 changes: 8 additions & 0 deletions bindings/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ pub enum ElysMsg {
amount: Int128,
owner: String,
},

LeveragelpClaimRewards {
sender: String,
id: Vec<u64>,
},
}

impl ElysMsg {
Expand Down Expand Up @@ -371,6 +376,9 @@ impl ElysMsg {
pub fn tier_set_portfolio(creator: String, user: String) -> Self {
Self::TierSetPortfolio { creator, user }
}
pub fn leveragelp_withdraw_reward(sender: String, id: Vec<u64>) -> Self {
Self::LeveragelpClaimRewards { sender, id }
}

pub fn estaking_withdraw_reward(delegator_address: String, validator_address: String) -> Self {
Self::EstakingWithdrawReward {
Expand Down
134 changes: 126 additions & 8 deletions bindings/src/querier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,12 +748,65 @@ impl<'a> ElysQuerier<'a> {

pub fn masterchef_params(&self) -> StdResult<MasterchefParamsResponse> {
let request = QueryRequest::Custom(ElysQuery::masterchef_params());
self.querier.query(&request)
let MasterchefParamsResponseRaw { params: raw_params } = self.querier.query(&request)?;
let lp_incentives = raw_params.lp_incentives.map_or(
IncentiveInfo {
eden_amount_per_year: Int128::zero(),
distribution_start_block: Int128::zero(),
total_blocks_per_year: Int128::zero(),
blocks_distributed: Int128::zero(),
},
|raw_lp_incentives| IncentiveInfo {
eden_amount_per_year: raw_lp_incentives.eden_amount_per_year.unwrap_or_default(),
distribution_start_block: raw_lp_incentives
.distribution_start_block
.unwrap_or_default(),
total_blocks_per_year: raw_lp_incentives.total_blocks_per_year.unwrap_or_default(),
blocks_distributed: raw_lp_incentives.blocks_distributed.unwrap_or_default(),
},
);

let supported_reward_denoms: Vec<SupportedRewardDenom> = raw_params
.supported_reward_denoms
.map_or(vec![], |raw_supported_reward_denoms| {
raw_supported_reward_denoms
.iter()
.map(|reward_denom| SupportedRewardDenom {
denom: reward_denom.denom.clone().unwrap_or_default(),
min_amount: reward_denom.min_amount.unwrap_or_default(),
})
.collect()
});

let params = MasterchefParams {
lp_incentives,
reward_portion_for_lps: raw_params.reward_portion_for_lps.unwrap_or_default(),
reward_portion_for_stakers: raw_params.reward_portion_for_stakers.unwrap_or_default(),
max_eden_reward_apr_lps: raw_params.max_eden_reward_apr_lps.unwrap_or_default(),
supported_reward_denoms,
protocol_revenue_address: "".to_string(),
};

Ok(MasterchefParamsResponse { params })
}

pub fn masterchef_pool_info(&self, pool_id: u64) -> StdResult<MasterchefPoolInfoResponse> {
let request = QueryRequest::Custom(ElysQuery::masterchef_pool_info(pool_id));
self.querier.query(&request)
let MasterchefPoolInfoResponseRaw {
pool_info: pool_info_raw,
} = self.querier.query(&request)?;
let pool_info = MasterchefPoolInfo {
pool_id: pool_info_raw.pool_id.unwrap_or_default(),
reward_wallet: pool_info_raw.reward_wallet.unwrap_or_default(),
multiplier: pool_info_raw.multiplier.unwrap_or_default(),
eden_apr: pool_info_raw.eden_apr.unwrap_or_default(),
dex_apr: pool_info_raw.dex_apr.unwrap_or_default(),
gas_apr: pool_info_raw.gas_apr.unwrap_or_default(),
external_incentive_apr: pool_info_raw.external_incentive_apr.unwrap_or_default(),
external_reward_denoms: pool_info_raw.external_reward_denoms.unwrap_or_default(),
};

Ok(MasterchefPoolInfoResponse { pool_info })
}

/// This function retrieves pending rewards for a user from the Masterchef contract.
Expand All @@ -777,6 +830,17 @@ impl<'a> ElysQuerier<'a> {
))
}

pub fn query_leverage_lp_rewards(
&self,
address: String,
ids: Vec<u64>,
) -> StdResult<GetLeverageLpRewardsResp> {
self.querier
.query(&QueryRequest::Custom(ElysQuery::query_leverage_lp_rewards(
address, ids,
)))
}

pub fn get_masterchef_pool_apr(&self, pool_ids: Vec<u64>) -> StdResult<QueryPoolAprsResponse> {
let query = ElysQuery::get_masterchef_pool_apr(pool_ids);
let request = QueryRequest::Custom(query);
Expand Down Expand Up @@ -867,22 +931,57 @@ impl<'a> ElysQuerier<'a> {
};
Ok(resp)
}
pub fn leveragelp_query_positions_for_address(

fn leveragelp_query_positions_for_address(
&self,
address: impl Into<String>,
pagination: Option<PageRequest>,
) -> StdResult<LeveragelpPositionsResponse> {
) -> StdResult<LeveragelpPositionsResponseRaw> {
let req = QueryRequest::Custom(ElysQuery::leveragelp_query_positions_for_address(
address.into(),
pagination,
));
let raw_resp: LeveragelpPositionsResponseRaw = self.querier.query(&req)?;
let positions = raw_resp.positions.unwrap_or(vec![]);
Ok(LeveragelpPositionsResponse {
positions,
self.querier.query(&req)
}

pub fn get_leveragelp_query_positions_for_address(
&self,
address: impl Into<String>,
prev_pagination: Option<PageRequest>,
) -> StdResult<LeveragelpPositionsAndRewardsResponse> {
let address: String = address.into();
let raw_resp: LeveragelpPositionsResponseRaw =
self.leveragelp_query_positions_for_address(address.to_string(), prev_pagination)?;

if raw_resp.positions.is_none() {
return Ok(LeveragelpPositionsAndRewardsResponse {
positions: LeveragelpPositionWithReward::default(),
pagination: raw_resp.pagination,
});
}

let leverage_reward_data =
self.query_leverage_lp_rewards(address.to_string(), raw_resp.get_pools())?;

let leveragelp_fiat_rewards = LeveragelpFiatRewards {
rewards: leverage_reward_data.to_coin_value(self)?,
total_rewards: leverage_reward_data.total_rewards_to_coin_value(self)?,
};

Ok(LeveragelpPositionsAndRewardsResponse {
positions: LeveragelpPositionWithReward {
positions: raw_resp.positions.unwrap(),
rewards: leveragelp_fiat_rewards,
},
pagination: raw_resp.pagination,
})
}
pub fn leveragelp_pool_ids_for_address(&self, address: String) -> StdResult<Vec<u64>> {
let pagination = PageRequest::total();
let raw_resp =
self.leveragelp_query_positions_for_address(address.clone(), Some(pagination.clone()))?;
Ok(raw_resp.get_pools())
}
pub fn leveragelp_get_whitelist(
&self,
pagination: Option<PageRequest>,
Expand Down Expand Up @@ -1012,6 +1111,25 @@ impl<'a> ElysQuerier<'a> {
};
Ok(resp)
}
pub fn parameter_params(&self) -> StdResult<ParameterParamsResponse> {
let query = ElysQuery::parameter_params();
let request = QueryRequest::Custom(query);
let ParameterParamsResponseRaw { params: raw_params } = self.querier.query(&request)?;
let params = ParameterParams {
min_commission_rate: raw_params.min_commission_rate.unwrap_or(Decimal::zero()),
max_voting_power: raw_params.max_voting_power.unwrap_or(Decimal::zero()),
min_self_delegation: raw_params.min_self_delegation.unwrap_or(Int128::zero()),
broker_address: raw_params.broker_address.unwrap_or("".to_string()),
total_blocks_per_year: raw_params.total_blocks_per_year.unwrap_or(0),
rewards_data_lifetime: raw_params.rewards_data_lifetime.unwrap_or(0),
wasm_max_label_size: raw_params.wasm_max_label_size.unwrap_or(Int128::zero()),
wasm_max_size: raw_params.wasm_max_size.unwrap_or(Int128::zero()),
wasm_max_proposal_wasm_size: raw_params
.wasm_max_proposal_wasm_size
.unwrap_or(Int128::zero()),
};
Ok(ParameterParamsResponse { params })
}

#[allow(dead_code)]
#[cfg(feature = "debug")]
Expand Down
11 changes: 11 additions & 0 deletions bindings/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ use cosmwasm_std::{Coin, CustomQuery, Decimal, Int128, SignedDecimal, SignedDeci
#[cw_serde]
#[derive(QueryResponses)]
pub enum ElysQuery {
// Define Parameter
#[returns(ParameterParamsResponse)]
ParameterParams {},
// Define AmmQuery
#[returns(AmmSwapEstimationResponse)]
AmmSwapEstimation {
Expand Down Expand Up @@ -80,6 +83,8 @@ pub enum ElysQuery {
CommitmentVestingInfo { address: String },
#[returns(CommitmentNumberOfCommitmentsResponse)]
CommitmentNumberOfCommitments {},
#[returns(GetLeverageLpRewardsResp)]
LeveragelpRewards { address: String, ids: Vec<u64> },

// Define Incentive
#[returns(QueryAprResponse)]
Expand Down Expand Up @@ -189,6 +194,9 @@ pub enum ElysQuery {
impl CustomQuery for ElysQuery {}

impl ElysQuery {
pub fn parameter_params() -> Self {
Self::ParameterParams {}
}
pub fn amm_swap_estimation(
routes: Vec<SwapAmountInRoute>,
token_in: Coin,
Expand Down Expand Up @@ -458,4 +466,7 @@ impl ElysQuery {
pub fn tier_calculate_discount(user: String) -> Self {
Self::TierCalculateDiscount { user }
}
pub fn query_leverage_lp_rewards(address: String, ids: Vec<u64>) -> Self {
Self::LeveragelpRewards { address, ids }
}
}
Loading

0 comments on commit 5187eec

Please sign in to comment.