Skip to content

Commit

Permalink
Merge pull request #86 from neutron-org/fix/proper-handling-of-vestin…
Browse files Browse the repository at this point in the history
…g-lp-migration

Fix: proper handling of vesting lp migration
  • Loading branch information
sotnikov-s authored Mar 29, 2024
2 parents 1028cd2 + 44d72e7 commit afad579
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion contracts/lockdrop/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "neutron-lockdrop"
version = "1.2.1"
version = "1.3.0"
authors = ["_astromartian"]
edition = "2021"

Expand Down
6 changes: 4 additions & 2 deletions contracts/lockdrop/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use astroport::generator::{
};
use astroport::restricted_vector::RestrictedVector;
use astroport::DecimalCheckedOps;
use astroport_periphery::utils::Decimal256CheckedOps;
use cosmwasm_std::{
attr, coins, entry_point, from_json, to_json_binary, Addr, BankMsg, Binary, Coin, CosmosMsg,
Decimal, Decimal256, Deps, DepsMut, Env, MessageInfo, Order, Response, StdError, StdResult,
Expand All @@ -20,14 +19,15 @@ use cosmwasm_std::{
use cw2::set_contract_version;
use cw20::{BalanceResponse, Cw20ExecuteMsg, Cw20QueryMsg, Cw20ReceiveMsg, MinterResponse};

use crate::raw_queries::{raw_balance, raw_generator_deposit};
use astroport_periphery::lockdrop::{
CallbackMsg, Config, Cw20HookMsg, ExecuteMsg, InstantiateMsg, LockUpInfoResponse,
LockUpInfoSummary, LockupInfoV2, MigrateMsg, PoolInfo, PoolType, QueryMsg, State,
StateResponse, UpdateConfigMsg, UserInfoResponse, UserInfoWithListResponse,
};
use astroport_periphery::lockdrop_pcl::ExecuteMsg as LockdropPCLExecuteMsg;
use astroport_periphery::utils::Decimal256CheckedOps;

use crate::raw_queries::{raw_balance, raw_generator_deposit};
use crate::state::{
CompatibleLoader, ASSET_POOLS, CONFIG, LOCKUP_INFO, OWNERSHIP_PROPOSAL, PCL_LOCKDROP_CONTRACT,
STATE, TOTAL_USER_LOCKUP_AMOUNT, USER_INFO,
Expand Down Expand Up @@ -450,6 +450,8 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
/// * **_msg** is an object of type [`MigrateMsg`].
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn migrate(deps: DepsMut, _env: Env, msg: MigrateMsg) -> StdResult<Response> {
set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;

PCL_LOCKDROP_CONTRACT.save(
deps.storage,
&deps.api.addr_validate(&msg.pcl_lockdrop_contract)?,
Expand Down
10 changes: 5 additions & 5 deletions contracts/vesting-lp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "vesting-lp"
version = "1.1.0"
version = "1.2.0"
authors = ["Neutron"]
edition = "2021"
description = "Vesting contract with a voting capabilities. Provides queries to get the amount of tokens are being held by user at certain height."
Expand All @@ -14,16 +14,16 @@ library = []

[dependencies]
cw2 = { version = "0.15" }
vesting-base = {path = "../../packages/vesting-base"}
vesting-lp-pcl = {path = "../vesting-lp-pcl"}
vesting-base = { path = "../../packages/vesting-base" }
vesting-lp-pcl = { path = "../vesting-lp-pcl" }
astroport = { path = "../../packages/astroport" }
cosmwasm-schema = { version = "1.1", default-features = false }
cosmwasm-schema = { version = "1.1", default-features = false }
cosmwasm-std = { version = "1.1" }
cw-storage-plus = "0.15"
cw20 = { version = "0.15" }

[dev-dependencies]
cw-multi-test = "0.15"
astroport-token = {git = "https://github.com/astroport-fi/astroport-core.git", rev = "65ce7d1879cc5d95b09fa14202f0423bba52ae0e" }
astroport-token = { git = "https://github.com/astroport-fi/astroport-core.git", rev = "65ce7d1879cc5d95b09fa14202f0423bba52ae0e" }
cw20 = { version = "0.15" }
cw-utils = "0.15"
27 changes: 17 additions & 10 deletions contracts/vesting-lp/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
/// Manages contract migration.
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn migrate(deps: DepsMut, _env: Env, msg: MigrateMsg) -> Result<Response, ContractError> {
set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;

XYK_TO_CL_MIGRATION_CONFIG.save(
deps.storage,
&XykToClMigrationConfig {
Expand Down Expand Up @@ -104,7 +106,10 @@ fn execute_migrate_liquidity(
let vesting_info = vesting_info(config.extensions.historical);
let info = vesting_info.load(deps.storage, address.clone())?;
let mut resp = Response::default();
let user = VestingAccountFullInfo { address, info };
let user = VestingAccountFullInfo {
address,
info: info.clone(),
};

// get pairs LP token addresses
let pair_info: PairInfo = deps
Expand All @@ -131,15 +136,17 @@ fn execute_migrate_liquidity(
}));
}

vesting_info.save(
deps.storage,
user.address.clone(),
&VestingInfo {
schedules: vec![],
released_amount: Uint128::zero(),
},
env.block.height,
)?;
if !info.schedules.is_empty() {
vesting_info.save(
deps.storage,
user.address.clone(),
&VestingInfo {
schedules: vec![],
released_amount: Uint128::zero(),
},
env.block.height,
)?;
}
return Ok(resp);
};

Expand Down

0 comments on commit afad579

Please sign in to comment.