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

Feat: PCL LP migration #82

Merged
merged 39 commits into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
fda6019
shorten lockdrop_pcl contract
sotnikov-s Jan 16, 2024
795ef42
add init version of lockdrop liquidity migration to PCL
sotnikov-s Jan 25, 2024
ec50f68
refine liquidity migration steps, add comments
sotnikov-s Feb 2, 2024
5019e46
rm pcl lockdrop unit tests
sotnikov-s Feb 5, 2024
ee21daf
generate schema for lockdrop and lockdrop_pcl
sotnikov-s Feb 8, 2024
19c6f84
WIP: incentives contract instead of generator
pr0n00gler Feb 8, 2024
123b378
fmt
pr0n00gler Feb 8, 2024
082e44a
adjust lockdrop pcl to incentives contract rewards
sotnikov-s Feb 12, 2024
9a2911b
fix skate rewards calculation
sotnikov-s Feb 13, 2024
3b795c9
fix json schema for lockdrop_pcl
pr0n00gler Feb 15, 2024
5acd141
Merge pull request #77 from neutron-org/feat/incentives-contract
pr0n00gler Feb 16, 2024
1ee7cba
generator -> incentives
pr0n00gler Feb 21, 2024
5b9b1a4
remove is_staked variable from pool info state
pr0n00gler Feb 22, 2024
da45913
format
pr0n00gler Feb 22, 2024
8cb42eb
Merge branch 'feat/pcl-lp-migration' into feat/migrate-lockdrop-to-pcl
pr0n00gler Feb 26, 2024
a1927dc
commit all pcl changes
quasisamurai Feb 26, 2024
0207d5d
recommit new lockfile
quasisamurai Feb 26, 2024
f9afc7a
Merge pull request #73 from neutron-org/feat/migrate-lockdrop-to-pcl
pr0n00gler Feb 26, 2024
7ae0225
Merge pull request #81 from neutron-org/fix/pcl-migrations-conflicts
pr0n00gler Feb 26, 2024
e86b087
fix sender issue & rm whitelist check for lp contract
quasisamurai Feb 27, 2024
54f05d9
remove dust_threshold in migration; make query instead to rule out em…
NeverHappened Mar 13, 2024
8e88409
rename
NeverHappened Mar 13, 2024
3e10ee2
fix: load user info safely #ntrn-240
NeverHappened Mar 20, 2024
374eea0
update pool info on LP deposit to reflect implicit rewards claim
pr0n00gler Mar 21, 2024
d44ee2f
formatting
pr0n00gler Mar 21, 2024
caf5e1e
proper handling of unnecessary vesting lp migration
pr0n00gler Mar 26, 2024
3ecc8c8
format
pr0n00gler Mar 26, 2024
705de7c
pass reward tokens info instead of querying for pcl lockdrop
sotnikov-s Mar 26, 2024
f6cb168
bump lockdrop and vesting-lp contracts versions
sotnikov-s Mar 27, 2024
2aadccf
add missing reward_tokens param description
sotnikov-s Mar 29, 2024
e623c48
Merge pull request #83 from neutron-org/fix/remove-dust-threshold
sotnikov-s Mar 29, 2024
e016b14
Merge pull request #84 from neutron-org/fix/load-user-info-safely
sotnikov-s Mar 29, 2024
1028cd2
Merge pull request #85 from neutron-org/fix/update-pool-on-deposit
sotnikov-s Mar 29, 2024
44d72e7
Merge branch 'feat/pcl-lp-migration' of github.com:neutron-org/neutro…
sotnikov-s Mar 29, 2024
afad579
Merge pull request #86 from neutron-org/fix/proper-handling-of-vestin…
sotnikov-s Mar 29, 2024
13aa3b5
Merge pull request #87 from neutron-org/fix/rewards-passing-for-claim
sotnikov-s Mar 29, 2024
a707793
delay migrated liquidity staking until pool fully migrated
sotnikov-s Apr 4, 2024
44ca3a1
replace reward assets list from PendingRewards with RewardInfo query …
sotnikov-s Apr 11, 2024
e10629b
Merge pull request #89 from neutron-org/fix/pcl-lockdrop-lp-early-sta…
sotnikov-s Apr 16, 2024
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
429 changes: 268 additions & 161 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
members = [
"contracts/auction",
"contracts/lockdrop",
"contracts/lockdrop-pcl",
"contracts/credits",
"contracts/vesting-lp",
"contracts/vesting-lp-pcl",
"contracts/vesting-lti",
"contracts/vesting-investors",
"contracts/cw20-merkle-airdrop",
"contracts/price-feed",
"contracts/astroport/*"
"contracts/astroport/*",
]

[profile.release]
Expand All @@ -33,6 +35,7 @@ cosmwasm-schema = { version = "1.4.1", default-features = false }
astroport = { path = "packages/astroport", default-features = false }
astroport-periphery = { path = "packages/astroport_periphery" }
vesting-base = { path = "packages/vesting-base" }
vesting-base-pcl = { path = "packages/vesting-base-pcl" }
# setting cw-multi-test to 0.17.0 enables cosmwasm_1_1, we don't want that
cw-multi-test = "0.16.5"
itertools = "0.11.0"
Expand Down
12 changes: 6 additions & 6 deletions contracts/astroport/oracle/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use astroport::oracle::{Config, ExecuteMsg, InstantiateMsg, QueryMsg};
use astroport::pair::TWAP_PRECISION;
use astroport::querier::query_pair_info;
use cosmwasm_std::{
entry_point, to_binary, Binary, Decimal256, Deps, DepsMut, Env, MessageInfo, Response, Uint128,
Uint256, Uint64,
entry_point, to_json_binary, Binary, Decimal256, Deps, DepsMut, Env, MessageInfo, Response,
Uint128, Uint256, Uint64,
};
use cw2::set_contract_version;
use std::ops::Div;
Expand Down Expand Up @@ -181,12 +181,12 @@ pub fn update(deps: DepsMut, env: Env) -> Result<Response, ContractError> {
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> Result<Binary, ContractError> {
match msg {
QueryMsg::Consult { token, amount } => Ok(to_binary(&consult(deps, token, amount)?)?),
QueryMsg::Consult { token, amount } => Ok(to_json_binary(&consult(deps, token, amount)?)?),
QueryMsg::TWAPAtHeight { token, height } => {
Ok(to_binary(&twap_at_height(deps, token, height)?)?)
Ok(to_json_binary(&twap_at_height(deps, token, height)?)?)
}
QueryMsg::Config {} => Ok(to_binary(&query_config(deps)?)?),
QueryMsg::LastUpdateTimestamp {} => Ok(to_binary(&query_last_update_ts(deps)?)?),
QueryMsg::Config {} => Ok(to_json_binary(&query_config(deps)?)?),
QueryMsg::LastUpdateTimestamp {} => Ok(to_json_binary(&query_last_update_ts(deps)?)?),
}
}

Expand Down
26 changes: 13 additions & 13 deletions contracts/astroport/oracle/src/mock_querier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use astroport::pair::QueryMsg::{self, CumulativePrices};
use astroport::pair::{CumulativePricesResponse, SimulationResponse};
use cosmwasm_std::testing::{MockApi, MockQuerier, MockStorage, MOCK_CONTRACT_ADDR};
use cosmwasm_std::{
from_binary, from_slice, to_binary, Addr, Coin, Empty, OwnedDeps, Querier, QuerierResult,
QueryRequest, SystemError, SystemResult, Uint128, WasmQuery,
from_json, to_json_binary, Addr, Coin, Empty, OwnedDeps, Querier, QuerierResult, QueryRequest,
SystemError, SystemResult, Uint128, WasmQuery,
};
use cw20::{BalanceResponse, Cw20QueryMsg, TokenInfoResponse};
use std::collections::HashMap;
Expand Down Expand Up @@ -82,7 +82,7 @@ pub(crate) fn balances_to_map(
impl Querier for WasmMockQuerier {
fn raw_query(&self, bin_request: &[u8]) -> QuerierResult {
// MockQuerier doesn't support Custom, so we ignore it completely here
let request: QueryRequest<Empty> = match from_slice(bin_request) {
let request: QueryRequest<Empty> = match from_json(bin_request) {
Ok(v) => v,
Err(e) => {
return SystemResult::Err(SystemError::InvalidRequest {
Expand All @@ -100,9 +100,9 @@ impl WasmMockQuerier {
match &request {
QueryRequest::Wasm(WasmQuery::Smart { contract_addr, msg }) => {
if contract_addr == "factory" {
match from_binary(msg).unwrap() {
match from_json(msg).unwrap() {
Pair { asset_infos } => SystemResult::Ok(
to_binary(&PairInfo {
to_json_binary(&PairInfo {
asset_infos,
contract_addr: Addr::unchecked("pair"),
liquidity_token: Addr::unchecked("lp_token"),
Expand All @@ -113,9 +113,9 @@ impl WasmMockQuerier {
_ => panic!("DO NOT ENTER HERE"),
}
} else if contract_addr == "astro-token" || contract_addr == "usdc-token" {
match from_binary(msg).unwrap() {
match from_json(msg).unwrap() {
Cw20QueryMsg::TokenInfo {} => SystemResult::Ok(
to_binary(&TokenInfoResponse {
to_json_binary(&TokenInfoResponse {
name: contract_addr.to_string(),
symbol: contract_addr.to_string(),
decimals: 6u8,
Expand All @@ -126,21 +126,21 @@ impl WasmMockQuerier {
_ => panic!("DO NOT ENTER HERE"),
}
} else if contract_addr == "pair" {
match from_binary(msg).unwrap() {
match from_json(msg).unwrap() {
CumulativePrices { .. } => {
let balance = match self.token_querier.pairs.get(contract_addr) {
Some(v) => v,
None => {
return SystemResult::Err(SystemError::Unknown {});
}
};
SystemResult::Ok(to_binary(&balance).into())
SystemResult::Ok(to_json_binary(&balance).into())
}
QueryMsg::Simulation {
offer_asset,
ask_asset_info: _,
} => SystemResult::Ok(
to_binary(&SimulationResponse {
to_json_binary(&SimulationResponse {
return_amount: offer_asset.amount,
spread_amount: Uint128::zero(),
commission_amount: Uint128::zero(),
Expand All @@ -150,7 +150,7 @@ impl WasmMockQuerier {
_ => panic!("DO NOT ENTER HERE"),
}
} else {
match from_binary(msg).unwrap() {
match from_json(msg).unwrap() {
Cw20QueryMsg::TokenInfo {} => {
let balances: &HashMap<String, Uint128> =
match self.token_querier.balances.get(contract_addr) {
Expand All @@ -167,7 +167,7 @@ impl WasmMockQuerier {
}

SystemResult::Ok(
to_binary(&TokenInfoResponse {
to_json_binary(&TokenInfoResponse {
name: "mAPPL".to_string(),
symbol: "mAPPL".to_string(),
decimals: 6,
Expand All @@ -193,7 +193,7 @@ impl WasmMockQuerier {
};

SystemResult::Ok(
to_binary(&BalanceResponse { balance: *balance }).into(),
to_json_binary(&BalanceResponse { balance: *balance }).into(),
)
}
_ => panic!("DO NOT ENTER HERE"),
Expand Down
14 changes: 7 additions & 7 deletions contracts/astroport/oracle/src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use astroport::asset::{Asset, AssetInfo, PairInfo};
use astroport::oracle::{Config, ExecuteMsg, InstantiateMsg, QueryMsg};
use cosmwasm_std::testing::{mock_env, mock_info, MOCK_CONTRACT_ADDR};
use cosmwasm_std::{
from_binary, Addr, Decimal256, DepsMut, Env, MessageInfo, Uint128, Uint256, Uint64,
from_json, Addr, Decimal256, DepsMut, Env, MessageInfo, Uint128, Uint256, Uint64,
};
use std::ops::{Add, Mul};

Expand Down Expand Up @@ -205,7 +205,7 @@ fn cfg_and_last_update_ts() {

// make sure config query works as expected
let cfg: Config =
from_binary(&query(deps.as_ref(), env.clone(), QueryMsg::Config {}).unwrap()).unwrap();
from_json(query(deps.as_ref(), env.clone(), QueryMsg::Config {}).unwrap()).unwrap();
assert_eq!(
cfg,
Config {
Expand Down Expand Up @@ -249,7 +249,7 @@ fn cfg_and_last_update_ts() {
)
.unwrap();
let last_update_ts: u64 =
from_binary(&query(deps.as_ref(), env.clone(), QueryMsg::LastUpdateTimestamp {}).unwrap())
from_json(query(deps.as_ref(), env.clone(), QueryMsg::LastUpdateTimestamp {}).unwrap())
.unwrap();
assert_eq!(last_update_ts, first_update_ts);
env.block.time = env.block.time.plus_seconds(100);
Expand All @@ -261,7 +261,7 @@ fn cfg_and_last_update_ts() {
)
.unwrap();
let last_update_ts: u64 =
from_binary(&query(deps.as_ref(), env.clone(), QueryMsg::LastUpdateTimestamp {}).unwrap())
from_json(query(deps.as_ref(), env.clone(), QueryMsg::LastUpdateTimestamp {}).unwrap())
.unwrap();
assert_eq!(last_update_ts, first_update_ts.add(100));

Expand All @@ -274,12 +274,12 @@ fn cfg_and_last_update_ts() {
)
.unwrap();
let cfg: Config =
from_binary(&query(deps.as_ref(), env.clone(), QueryMsg::Config {}).unwrap()).unwrap();
from_json(query(deps.as_ref(), env.clone(), QueryMsg::Config {}).unwrap()).unwrap();
assert_eq!(cfg.period, 500u64);

// make sure premature update doesn't work
let last_update_ts: u64 =
from_binary(&query(deps.as_ref(), env.clone(), QueryMsg::LastUpdateTimestamp {}).unwrap())
from_json(query(deps.as_ref(), env.clone(), QueryMsg::LastUpdateTimestamp {}).unwrap())
.unwrap();
assert_eq!(last_update_ts, first_update_ts.add(100));
env.block.time = env.block.time.plus_seconds(100);
Expand All @@ -295,7 +295,7 @@ fn cfg_and_last_update_ts() {
env.block.time = env.block.time.plus_seconds(500);
execute(deps.as_mut(), env.clone(), info, ExecuteMsg::Update {}).unwrap();
let last_update_ts: u64 =
from_binary(&query(deps.as_ref(), env, QueryMsg::LastUpdateTimestamp {}).unwrap()).unwrap();
from_json(query(deps.as_ref(), env, QueryMsg::LastUpdateTimestamp {}).unwrap()).unwrap();
assert_eq!(last_update_ts, first_update_ts.add(700));
}

Expand Down
Loading
Loading