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

Commit

Permalink
v0.2.6 (#383)
Browse files Browse the repository at this point in the history
* Ci/cd (#370)

* new pipeline was added

* new pipeline was added

* update version

* Feat/leverage claim rewards (#367)

* add: leveragelp query and leveragelp get rewards

* feat: add claim rewards

* refactor: leveragelp querier funcs

* add: usdc and eden rewards

* update: test

* fix

---------

Co-authored-by: Warao <[email protected]>

* Ci/cd (#372)

* new pipeline was added

* new pipeline was added

* update version

* update version

* upgrade version (#374)

* upgrade version

* Update leverage LP rewards structure (#377)

* Update structure

* Update version

* docs: improved testnet snapshot intructions (#381)

* update: leveragelp reward response (#380)

* update: get_leveragelp_query_positions_for_address response

* Update version

---------

Co-authored-by: Warao Gil <[email protected]>

---------

Co-authored-by: Servio Zambrano <[email protected]>
Co-authored-by: cryptokage <[email protected]>
Co-authored-by: Cosmic Vagabond <[email protected]>
  • Loading branch information
4 people authored Jun 19, 2024
1 parent 9f203db commit 1116f98
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.5
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
29 changes: 16 additions & 13 deletions bindings/src/querier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -917,25 +917,28 @@ impl<'a> ElysQuerier<'a> {
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 mut usdc = Decimal::zero();
let mut eden = Uint128::zero();

for coin in leverage_reward_data.total_rewards {
if coin.denom == "uusdc".to_string() {
usdc = CoinValue::from_coin(&coin, self)?.amount_usd;
} else {
eden = coin.amount;
}
}
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: raw_resp.positions.unwrap_or(vec![]),
positions: LeveragelpPositionWithReward {
positions: raw_resp.positions.unwrap(),
rewards: leveragelp_fiat_rewards,
},
pagination: raw_resp.pagination,
usdc,
eden,
})
}
pub fn leveragelp_pool_ids_for_address(&self, address: String) -> StdResult<Vec<u64>> {
Expand Down
49 changes: 45 additions & 4 deletions bindings/src/query_resp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,10 +630,29 @@ pub struct LeveragelpPositionsResponse {

#[cw_serde]
pub struct LeveragelpPositionsAndRewardsResponse {
pub positions: Vec<LeveragelpPosition>,
pub positions: LeveragelpPositionWithReward,
pub pagination: Option<PageResponse>,
pub usdc: Decimal,
pub eden: Uint128,
}

#[cw_serde]
#[derive(Default)]
pub struct LeveragelpPositionWithReward {
pub positions: Vec<LeveragelpPosition>,
pub rewards: LeveragelpFiatRewards,
}

#[cw_serde]
#[derive(Default)]
pub struct LeveragelpFiatRewards {
pub rewards: Vec<RewardInfoMappedToCoinValue>,
pub total_rewards: Vec<CoinValue>,
}

#[cw_serde]
#[derive(Default)]
pub struct RewardInfoMappedToCoinValue {
pub position_id: u64,
pub reward: Vec<CoinValue>,
}

#[cw_serde]
Expand Down Expand Up @@ -988,11 +1007,33 @@ pub struct RewardInfo {
}

impl GetLeverageLpRewardsResp {
pub fn total_rewards_to_coin(&self, querier: &ElysQuerier<'_>) -> StdResult<Vec<CoinValue>> {
pub fn total_rewards_to_coin_value(
&self,
querier: &ElysQuerier<'_>,
) -> StdResult<Vec<CoinValue>> {
let mut coin_values = Vec::new();
for reward in &self.total_rewards {
coin_values.push(CoinValue::from_coin(reward, querier)?);
}
Ok(coin_values)
}

pub fn to_coin_value(
&self,
querier: &ElysQuerier<'_>,
) -> StdResult<Vec<RewardInfoMappedToCoinValue>> {
let mut reward_info = vec![RewardInfoMappedToCoinValue::default()];

for reward in &self.rewards {
let mut coin_values = vec![];
for coin in reward.reward.clone() {
coin_values.push(CoinValue::from_coin(&coin, querier)?);
}
reward_info.push(RewardInfoMappedToCoinValue {
position_id: reward.position_id,
reward: coin_values,
})
}
Ok(reward_info)
}
}

0 comments on commit 1116f98

Please sign in to comment.