Skip to content

Commit

Permalink
Merge pull request #83 from neutron-org/fix/remove-dust-threshold
Browse files Browse the repository at this point in the history
fix: remove dust threshold #ntrn-239
  • Loading branch information
sotnikov-s authored Mar 29, 2024
2 parents e86b087 + 8e88409 commit e623c48
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
12 changes: 8 additions & 4 deletions contracts/vesting-lp/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::msg::{CallbackMsg, ExecuteMsg, InstantiateMsg, MigrateMsg};
use crate::state::{XykToClMigrationConfig, XYK_TO_CL_MIGRATION_CONFIG};
use astroport::asset::{native_asset, PairInfo};
use astroport::asset::{native_asset, Asset, PairInfo};
use astroport::pair::QueryMsg::Share;
use astroport::pair::{
Cw20HookMsg as PairCw20HookMsg, ExecuteMsg as PairExecuteMsg, QueryMsg as PairQueryMsg,
};
Expand Down Expand Up @@ -81,7 +82,6 @@ pub fn migrate(deps: DepsMut, _env: Env, msg: MigrateMsg) -> Result<Response, Co
cl_pair: deps.api.addr_validate(msg.cl_pair.as_str())?,
new_lp_token: deps.api.addr_validate(msg.new_lp_token.as_str())?,
pcl_vesting: deps.api.addr_validate(msg.pcl_vesting.as_str())?,
dust_threshold: msg.dust_threshold,
},
)?;

Expand Down Expand Up @@ -112,10 +112,14 @@ fn execute_migrate_liquidity(
.query_wasm_smart(migration_config.xyk_pair.clone(), &PairQueryMsg::Pair {})?;

let user_share = compute_share(&user.info)?;
let user_share_assets: Vec<Asset> = deps.querier.query_wasm_smart(
migration_config.xyk_pair.clone(),
&Share { amount: user_share },
)?;

// if there is nothing to migrate just update vi and quit.
// if there is only dust, than send it back to user, update vi and quit
if user_share < migration_config.dust_threshold {
// if there is only dust, then send it back to user, update vi and quit
if user_share_assets.iter().any(|a| a.amount.is_zero()) {
if !user_share.is_zero() {
resp = resp.add_message(CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: pair_info.liquidity_token.to_string(),
Expand Down
1 change: 0 additions & 1 deletion contracts/vesting-lp/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ pub struct MigrateMsg {
pub cl_pair: String,
pub new_lp_token: String,
pub pcl_vesting: String,
pub dust_threshold: Uint128,
}

impl From<ExecuteMsg> for BaseExecute {
Expand Down
3 changes: 1 addition & 2 deletions contracts/vesting-lp/src/state.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cosmwasm_schema::cw_serde;
use cosmwasm_std::{Addr, Decimal, Uint128};
use cosmwasm_std::{Addr, Decimal};
use cw_storage_plus::Item;

/// Config for xyk->CL liquidity migration.
Expand All @@ -13,7 +13,6 @@ pub struct XykToClMigrationConfig {
pub cl_pair: Addr,
pub new_lp_token: Addr,
pub pcl_vesting: Addr,
pub dust_threshold: Uint128,
}

pub const XYK_TO_CL_MIGRATION_CONFIG: Item<XykToClMigrationConfig> =
Expand Down

0 comments on commit e623c48

Please sign in to comment.