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

fix: remove dust threshold #ntrn-239 #83

Merged
merged 2 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading