Skip to content

Commit

Permalink
Merge pull request #82 from neutron-org/feat/pcl-lp-migration
Browse files Browse the repository at this point in the history
Feat: PCL LP migration
  • Loading branch information
pr0n00gler authored Apr 28, 2024
2 parents 2dc53b4 + e10629b commit 127d9f8
Show file tree
Hide file tree
Showing 100 changed files with 13,345 additions and 843 deletions.
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

0 comments on commit 127d9f8

Please sign in to comment.