Skip to content

Commit

Permalink
Merge pull request #67 from neutron-org/chore/small-improvements
Browse files Browse the repository at this point in the history
[NTRN-127] chore: small improvements
  • Loading branch information
pr0n00gler authored Oct 31, 2023
2 parents e673b63 + 44c32d3 commit 3264ab5
Show file tree
Hide file tree
Showing 14 changed files with 128 additions and 97 deletions.
18 changes: 13 additions & 5 deletions contracts/astroport/oracle/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,16 @@ pub fn instantiate(
Ok(Response::default())
}

/// ## Description
/// Exposes all the execute functions available in the contract.
/// ## Params
/// * **deps** is an object of type [`DepsMut`].
///
/// ## Variants
/// * **ExecuteMsg::Update {}** Updates the local TWAP values for the assets in the Astroport pool.
/// * **env** is an object of type [`Env`].
///
/// * **info** is an object of type [`MessageInfo`].
///
/// * **msg** is an object of type [`ExecuteMsg`].
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn execute(
deps: DepsMut,
Expand Down Expand Up @@ -174,10 +180,12 @@ pub fn update(deps: DepsMut, env: Env) -> Result<Response, ContractError> {
}

/// Exposes all the queries available in the contract.
/// ## Params
/// * **deps** is an object of type [`Deps`].
///
/// * **_env** is an object of type [`Env`].
///
/// ## Queries
/// * **QueryMsg::Consult { token, amount }** Validates assets and calculates a new average
/// amount with updated precision
/// * **msg** is an object of type [`QueryMsg`].
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> Result<Binary, ContractError> {
match msg {
Expand Down
12 changes: 0 additions & 12 deletions contracts/auction/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,6 @@ pub fn instantiate(
/// * **info** is an object of type [`MessageInfo`].
///
/// * **msg** is an object of type [`ExecuteMsg`].
///
/// ## Execute messages
///
/// * **ExecuteMsg::Receive(msg)** Parse incoming messages from the NTRN token.
///
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn execute(
deps: DepsMut,
Expand Down Expand Up @@ -229,13 +224,6 @@ pub fn execute_deposit(deps: DepsMut, env: Env, info: MessageInfo) -> Result<Res
/// * **_env** is an object of type [`Env`].
///
/// * **msg** is an object of type [`QueryMsg`].
///
/// ## Queries
/// * **QueryMsg::Config {}** Returns the config info.
///
/// * **QueryMsg::State {}** Returns state of the contract.
///
/// * **QueryMsg::UserInfo { address }** Returns user position details.
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
Expand Down
17 changes: 17 additions & 0 deletions contracts/credits/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ pub fn instantiate(
Ok(Response::new())
}

/// ## Description
/// Exposes all the execute functions available in the contract.
/// ## Params
/// * **deps** is an object of type [`DepsMut`].
///
/// * **env** is an object of type [`Env`].
///
/// * **info** is an object of type [`MessageInfo`].
///
/// * **msg** is an object of type [`ExecuteMsg`].
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn execute(
deps: DepsMut,
Expand Down Expand Up @@ -388,6 +398,13 @@ pub fn execute_mint(deps: DepsMut, env: Env, info: MessageInfo) -> Result<Respon
.map_err(Cw20Error)
}

/// Exposes all the queries available in the contract.
/// ## Params
/// * **deps** is an object of type [`Deps`].
///
/// * **_env** is an object of type [`Env`].
///
/// * **msg** is an object of type [`QueryMsg`].
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
Expand Down
17 changes: 17 additions & 0 deletions contracts/cw20-merkle-airdrop/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ pub fn instantiate(
]))
}

/// ## Description
/// Exposes all the execute functions available in the contract.
/// ## Params
/// * **deps** is an object of type [`DepsMut`].
///
/// * **env** is an object of type [`Env`].
///
/// * **info** is an object of type [`MessageInfo`].
///
/// * **msg** is an object of type [`ExecuteMsg`].
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn execute(
deps: DepsMut,
Expand Down Expand Up @@ -332,6 +342,13 @@ pub fn execute_resume(
Ok(Response::new().add_attributes(vec![attr("action", "resume"), attr("paused", "false")]))
}

/// Exposes all the queries available in the contract.
/// ## Params
/// * **deps** is an object of type [`Deps`].
///
/// * **_env** is an object of type [`Env`].
///
/// * **msg** is an object of type [`QueryMsg`].
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
Expand Down
64 changes: 4 additions & 60 deletions contracts/lockdrop/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,29 +129,6 @@ pub fn instantiate(
/// * **info** is an object of type [`MessageInfo`].
///
/// * **msg** is an object of type [`ExecuteMsg`].
///
/// ## Execute messages
///
/// * **ExecuteMsg::Receive(msg)** Parse incoming messages from the cNTRN token.
///
/// * **ExecuteMsg::UpdateConfig { new_config }** Admin function to update configuration parameters.
///
/// * **ExecuteMsg::InitializePool {
/// pool_type,
/// incentives_share,
/// }** Facilitates addition of new Pool (axlrUSDC/NTRN or ATOM/NTRN) whose LP tokens can then be locked in the lockdrop contract.
///
/// * **ExecuteMsg::ClaimRewardsAndOptionallyUnlock {
/// terraswap_lp_token,
/// duration,
/// withdraw_lp_stake,
/// }** Claims user Rewards for a particular Lockup position.
///
/// * **ExecuteMsg::ProposeNewOwner { owner, expires_in }** Creates a request to change contract ownership.
///
/// * **ExecuteMsg::DropOwnershipProposal {}** Removes a request to change contract ownership.
///
/// * **ExecuteMsg::ClaimOwnership {}** Claims contract ownership.
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn execute(deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg) -> StdResult<Response> {
let migration_state = MIGRATION_STATUS.may_load(deps.storage)?;
Expand Down Expand Up @@ -376,40 +353,6 @@ struct MigratePairStep2Data {
/// * **_env** is an object of type [`Env`].
///
/// * **msg** is an object of type [`QueryMsg`].
///
/// ## Queries
/// * **QueryMsg::Config {}** Returns the config info.
///
/// * **QueryMsg::State {}** Returns the contract's state info.
///
/// * **QueryMsg::Pool { terraswap_lp_token }** Returns info regarding a certain supported LP token pool.
///
/// * **QueryMsg::UserInfo { address }** Returns info regarding a user (total NTRN rewards, list of lockup positions).
///
/// * **QueryMsg::UserInfoWithLockupsList { address }** Returns info regarding a user with lockups.
///
/// * **QueryMsg::LockUpInfo {
/// user_address,
/// terraswap_lp_token,
/// duration,
/// }** Returns info regarding a particular lockup position with a given duration and identifer for the LP tokens locked.
///
/// * **QueryMsg::PendingAssetReward {
/// user_address,
/// terraswap_lp_token,
/// duration,
/// }** Returns the amount of pending asset rewards for the specified recipient and for a specific lockup position.
///
/// * **QueryUserLockupTotalAtHeight {
/// pool_type: PoolType,
/// user_address: String,
/// height: u64,
/// }** Returns locked amount of LP tokens for the specified user for the specified pool at a specific height.
///
/// * **QueryLockupTotalAtHeight {
/// pool_type: PoolType,
/// height: u64,
/// }** Returns a total amount of LP tokens for the specified pool at a specific height.
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
let migration_state = MIGRATION_STATUS.may_load(deps.storage)?;
Expand Down Expand Up @@ -493,6 +436,7 @@ pub fn migrate(deps: DepsMut, _env: Env, msg: MigrateMsg) -> StdResult<Response>

MIGRATION_STATUS.save(deps.storage, &MigrationState::MigrateLiquidity)?;

set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;
Ok(Response::default().add_attributes(attrs))
}

Expand Down Expand Up @@ -881,7 +825,7 @@ fn migrate_users(
attrs.push(attr("users_count", users.len().to_string()));
for user in users {
for pool_type in &pool_types {
let mut total_lokups = Uint128::zero();
let mut total_lockups = Uint128::zero();
let lookup_infos: Vec<(u64, LockupInfoV2)> = LOCKUP_INFO
.prefix((*pool_type, &user))
.range(deps.storage, None, None, Order::Ascending)
Expand All @@ -895,14 +839,14 @@ fn migrate_users(
lockup_info.lp_units_locked =
(*kf).checked_mul_uint128(lockup_info.lp_units_locked)?;
LOCKUP_INFO.save(deps.storage, (*pool_type, &user, duration), &lockup_info)?;
total_lokups += lockup_info.lp_units_locked;
total_lockups += lockup_info.lp_units_locked;
}
// update user's total lockup amount
TOTAL_USER_LOCKUP_AMOUNT.update(
deps.storage,
(*pool_type, &user),
env.block.height,
|_lockup_amount| -> StdResult<Uint128> { Ok(total_lokups) },
|_lockup_amount| -> StdResult<Uint128> { Ok(total_lockups) },
)?;
}
}
Expand Down
17 changes: 17 additions & 0 deletions contracts/price-feed/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ pub fn instantiate(
Ok(Response::new().add_attribute("method", "instantiate"))
}

/// ## Description
/// Exposes all the execute functions available in the contract.
/// ## Params
/// * **deps** is an object of type [`DepsMut`].
///
/// * **env** is an object of type [`Env`].
///
/// * **info** is an object of type [`MessageInfo`].
///
/// * **msg** is an object of type [`ExecuteMsg`].
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn execute(
deps: DepsMut,
Expand Down Expand Up @@ -177,6 +187,13 @@ pub fn migrate(_deps: DepsMut, _env: Env, _msg: Empty) -> StdResult<Response> {
Ok(Response::default())
}

/// Exposes all the queries available in the contract.
/// ## Params
/// * **deps** is an object of type [`Deps`].
///
/// * **_env** is an object of type [`Env`].
///
/// * **msg** is an object of type [`QueryMsg`].
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
Expand Down
18 changes: 17 additions & 1 deletion contracts/vesting-investors/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,16 @@ pub fn instantiate(
Ok(Response::default())
}

/// Exposes execute functions available in the contract.
/// ## Description
/// Exposes all the execute functions available in the contract.
/// ## Params
/// * **deps** is an object of type [`DepsMut`].
///
/// * **env** is an object of type [`Env`].
///
/// * **info** is an object of type [`MessageInfo`].
///
/// * **msg** is an object of type [`ExecuteMsg`].
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn execute(
deps: DepsMut,
Expand All @@ -43,6 +52,12 @@ pub fn execute(
}

/// Exposes all the queries available in the contract.
/// ## Params
/// * **deps** is an object of type [`Deps`].
///
/// * **_env** is an object of type [`Env`].
///
/// * **msg** is an object of type [`QueryMsg`].
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
base_query(deps, env, msg)
Expand All @@ -51,5 +66,6 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
/// Exposes migrate function.
#[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)?;
base_migrate(deps, env, msg)
}
18 changes: 17 additions & 1 deletion contracts/vesting-lp/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,16 @@ pub fn instantiate(
Ok(Response::default())
}

/// Exposes execute functions available in the contract.
/// ## Description
/// Exposes all the execute functions available in the contract.
/// ## Params
/// * **deps** is an object of type [`DepsMut`].
///
/// * **env** is an object of type [`Env`].
///
/// * **info** is an object of type [`MessageInfo`].
///
/// * **msg** is an object of type [`ExecuteMsg`].
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn execute(
deps: DepsMut,
Expand All @@ -43,6 +52,12 @@ pub fn execute(
}

/// Exposes all the queries available in the contract.
/// ## Params
/// * **deps** is an object of type [`Deps`].
///
/// * **_env** is an object of type [`Env`].
///
/// * **msg** is an object of type [`QueryMsg`].
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
base_query(deps, env, msg)
Expand All @@ -51,5 +66,6 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
/// Exposes migrate functions available in the contract.
#[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)?;
base_migrate(deps, env, msg)
}
17 changes: 16 additions & 1 deletion contracts/vesting-lti/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,16 @@ pub fn instantiate(
Ok(Response::default())
}

/// Exposes execute functions available in the contract.
/// ## Description
/// Exposes all the execute functions available in the contract.
/// ## Params
/// * **deps** is an object of type [`DepsMut`].
///
/// * **env** is an object of type [`Env`].
///
/// * **info** is an object of type [`MessageInfo`].
///
/// * **msg** is an object of type [`ExecuteMsg`].
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn execute(
deps: DepsMut,
Expand All @@ -50,6 +59,12 @@ pub fn execute(
}

/// Exposes all the queries available in the contract.
/// ## Params
/// * **deps** is an object of type [`Deps`].
///
/// * **_env** is an object of type [`Env`].
///
/// * **msg** is an object of type [`QueryMsg`].
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
base_query(deps, env, msg)
Expand Down
7 changes: 2 additions & 5 deletions packages/astroport_periphery/src/lockdrop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,9 @@ pub struct State {
pub total_incentives_share: Uint128,
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, Default)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
pub enum MigrationState {
#[default]
/// Migration is started
Started,
///
/// Migration is started, the first step is liquidity migration
MigrateLiquidity,
/// Liquidity is migrated, can migrate users with pagination
MigrateUsers,
Expand Down
Loading

0 comments on commit 3264ab5

Please sign in to comment.