-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
127 changed files
with
2,074 additions
and
19,185 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,25 +10,32 @@ authors = ["Tasio [email protected]"] | |
license = "BUSL-1.1" | ||
|
||
[workspace.dependencies] | ||
infinity-macros = { path = "./packages/infinity-macros" } | ||
infinity-router = { path = "./contracts/infinity-router" } | ||
infinity-index = { path = "./contracts/infinity-index" } | ||
infinity-pool = { path = "./contracts/infinity-pool" } | ||
infinity-shared = { path = "./packages/infinity-shared" } | ||
infinity-swap = { path = "./contracts/infinity-swap" } | ||
infinity-marketplace-adapter = { path = "./contracts/infinity-marketplace-adapter" } | ||
cosmwasm-schema = "1.2.1" | ||
cosmwasm-std = "1.2.1" | ||
cosmwasm-storage = "1.2.1" | ||
# infinity-macros = { path = "./packages/infinity-macros" } | ||
# infinity-swap = { path = "./contracts/infinity-swap" } | ||
# infinity-marketplace-adapter = { path = "./contracts/infinity-marketplace-adapter" } | ||
cosmwasm-std = { version = "1.2", features = ["staking", "stargate", "ibc3", "cosmwasm_1_1", "cosmwasm_1_2"] } | ||
cosmwasm-schema = "1.2" | ||
cosmwasm-storage = "1.2" | ||
cw-storage-plus = "0.16.0" | ||
cw-storage-macro = "0.16.0" | ||
cw-utils = "0.16.0" | ||
cw2 = "0.16.0" | ||
cw721-base = { version = "0.16.0", features = ["library"] } | ||
cw721 = "0.16.0" | ||
sg1 = "2.1.0" | ||
sg2 = "2.1.0" | ||
sg721-base = { version = "2.1.0", features = ["library"] } | ||
sg721 = { version = "2.1.0", features = ["library"] } | ||
sg-std = "2.1.0" | ||
sg-marketplace = { git = "https://github.com/tasiov/marketplace", branch = "infinity-marketplace-changes", features = ["library"] } | ||
sg-marketplace-common = { git = "https://github.com/tasiov/marketplace", branch = "infinity-marketplace-changes" } | ||
sg1 = { version = "2.1" } | ||
sg2 = { version = "2.1" } | ||
sg721-base = { version = "2.1", features = ["library"] } | ||
sg721 = { version = "2.1", features = ["library"] } | ||
sg-std = { version = "2.1" } | ||
# sg-marketplace = { git = "https://github.com/tasiov/marketplace", branch = "infinity-marketplace-changes", features = ["library"] } | ||
# sg-marketplace-common = { git = "https://github.com/tasiov/marketplace", branch = "infinity-marketplace-changes" } | ||
sg-marketplace = { path = "../marketplace/contracts/marketplace", features = ["library"] } | ||
sg-marketplace-common = { path = "../marketplace/packages/sg-marketplace-common" } | ||
sha2 = "0.10" | ||
thiserror = { version = "1.0.31" } | ||
anyhow = "1.0.51" | ||
proc-macro2 = "1.0" | ||
|
@@ -38,12 +45,13 @@ syn = { version = "1.0", features = ["derive"] } | |
# dev-dependencies | ||
itertools = "0.10.5" | ||
cw-multi-test = "0.16.0" | ||
sg-multi-test = "2.1.0" | ||
test-suite = "2.1.0" | ||
base-minter = "2.1.0" | ||
base-factory = "2.1.0" | ||
vending-minter = "2.1.0" | ||
vending-factory = "2.1.0" | ||
# sg-multi-test = "2.3" | ||
sg-multi-test = { version = "2.1" } | ||
test-suite = { version = "2.1" } | ||
base-minter = { version = "2.1" } | ||
base-factory = { version = "2.1" } | ||
vending-minter = { version = "2.1" } | ||
vending-factory = { version = "2.1" } | ||
mockall = "0.11.4" | ||
cosm-orc = { version = "3.0.1" } | ||
cosm-tome = { version = "0.1.1" } | ||
|
@@ -55,9 +63,9 @@ test-context = "0.1.4" | |
once_cell = "1.13.0" | ||
rand = "0.8" | ||
|
||
[profile.release.package.infinity-swap] | ||
codegen-units = 1 | ||
incremental = false | ||
# [profile.release.package.infinity-swap] | ||
# codegen-units = 1 | ||
# incremental = false | ||
|
||
[profile.release] | ||
rpath = false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use cosmwasm_std::StdError; | ||
use thiserror::Error; | ||
|
||
#[derive(Error, Debug, PartialEq)] | ||
pub enum ContractError { | ||
#[error("{0}")] | ||
Std(#[from] StdError), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
use crate::msg::ExecuteMsg; | ||
use crate::state::PoolQuote; | ||
use crate::{ | ||
error::ContractError, | ||
state::{buy_from_pool_quotes, sell_to_pool_quotes}, | ||
}; | ||
|
||
use cosmwasm_std::{Addr, DepsMut, Env, MessageInfo, Uint128}; | ||
use sg_std::Response; | ||
|
||
#[cfg(not(feature = "library"))] | ||
use cosmwasm_std::entry_point; | ||
|
||
#[cfg_attr(not(feature = "library"), entry_point)] | ||
pub fn execute( | ||
deps: DepsMut, | ||
env: Env, | ||
info: MessageInfo, | ||
msg: ExecuteMsg, | ||
) -> Result<Response, ContractError> { | ||
let api = deps.api; | ||
|
||
match msg { | ||
ExecuteMsg::UpdateBuyFromPoolQuote { | ||
collection, | ||
quote_price, | ||
} => execute_update_buy_from_pool_quote( | ||
deps, | ||
env, | ||
info, | ||
api.addr_validate(&collection)?, | ||
quote_price, | ||
), | ||
ExecuteMsg::UpdateSellToPoolQuote { | ||
collection, | ||
quote_price, | ||
} => execute_update_sell_to_pool_quote( | ||
deps, | ||
env, | ||
info, | ||
api.addr_validate(&collection)?, | ||
quote_price, | ||
), | ||
} | ||
} | ||
|
||
pub fn execute_update_buy_from_pool_quote( | ||
deps: DepsMut, | ||
env: Env, | ||
info: MessageInfo, | ||
collection: Addr, | ||
quote_price: Option<Uint128>, | ||
) -> Result<Response, ContractError> { | ||
if let Some(_quote_price) = quote_price { | ||
buy_from_pool_quotes().save( | ||
deps.storage, | ||
info.sender.clone(), | ||
&PoolQuote { | ||
pool: info.sender, | ||
collection, | ||
quote_price: _quote_price, | ||
}, | ||
)?; | ||
} else { | ||
buy_from_pool_quotes().remove(deps.storage, info.sender)?; | ||
} | ||
|
||
Ok(Response::default()) | ||
} | ||
|
||
pub fn execute_update_sell_to_pool_quote( | ||
deps: DepsMut, | ||
env: Env, | ||
info: MessageInfo, | ||
collection: Addr, | ||
quote_price: Option<Uint128>, | ||
) -> Result<Response, ContractError> { | ||
if let Some(_quote_price) = quote_price { | ||
sell_to_pool_quotes().save( | ||
deps.storage, | ||
info.sender.clone(), | ||
&PoolQuote { | ||
pool: info.sender, | ||
collection, | ||
quote_price: _quote_price, | ||
}, | ||
)?; | ||
} else { | ||
sell_to_pool_quotes().remove(deps.storage, info.sender)?; | ||
} | ||
|
||
Ok(Response::default()) | ||
} |
21 changes: 10 additions & 11 deletions
21
contracts/infinity-swap/src/instantiate.rs → contracts/infinity-index/src/instantiate.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,38 @@ | ||
use crate::error::ContractError; | ||
use crate::msg::InstantiateMsg; | ||
use crate::state::{Config, CONFIG, POOL_COUNTER}; | ||
use crate::state::{Config, CONFIG}; | ||
|
||
#[cfg(not(feature = "library"))] | ||
use cosmwasm_std::entry_point; | ||
use cosmwasm_std::{DepsMut, Env, MessageInfo}; | ||
use cw2::set_contract_version; | ||
use cw_utils::maybe_addr; | ||
use sg_std::Response; | ||
|
||
pub const CONTRACT_NAME: &str = "crates.io:infinity-swap"; | ||
pub const CONTRACT_NAME: &str = "crates.io:infinity-index"; | ||
pub const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); | ||
|
||
#[cfg(not(feature = "library"))] | ||
use cosmwasm_std::entry_point; | ||
|
||
#[cfg_attr(not(feature = "library"), entry_point)] | ||
pub fn instantiate( | ||
deps: DepsMut, | ||
_env: Env, | ||
env: Env, | ||
_info: MessageInfo, | ||
msg: InstantiateMsg, | ||
) -> Result<Response, ContractError> { | ||
set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; | ||
|
||
POOL_COUNTER.save(deps.storage, &1)?; | ||
CONFIG.save( | ||
deps.storage, | ||
&Config { | ||
marketplace_addr: deps.api.addr_validate(&msg.marketplace_addr)?, | ||
developer: maybe_addr(deps.api, msg.developer)?, | ||
global_gov: deps.api.addr_validate(&msg.global_gov)?, | ||
infinity_factory: deps.api.addr_validate(&msg.infinity_factory)?, | ||
}, | ||
)?; | ||
|
||
Ok(Response::new() | ||
.add_attribute("action", "instantiate") | ||
.add_attribute("contract_name", CONTRACT_NAME) | ||
.add_attribute("contract_version", CONTRACT_VERSION) | ||
.add_attribute("denom", msg.denom) | ||
.add_attribute("marketplace_addr", msg.marketplace_addr)) | ||
.add_attribute("global_gov", msg.global_gov) | ||
.add_attribute("infinity_factory", msg.infinity_factory)) | ||
} |
2 changes: 0 additions & 2 deletions
2
...s/infinity-marketplace-adapter/src/lib.rs → contracts/infinity-index/src/lib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use crate::state::PoolQuote; | ||
|
||
use cosmwasm_schema::{cw_serde, QueryResponses}; | ||
use cosmwasm_std::Uint128; | ||
|
||
#[cw_serde] | ||
pub struct InstantiateMsg { | ||
/// The address of the global gov contract | ||
pub global_gov: String, | ||
/// The address of the infinity factory contract | ||
pub infinity_factory: String, | ||
} | ||
|
||
#[cw_serde] | ||
pub enum ExecuteMsg { | ||
UpdateBuyFromPoolQuote { | ||
collection: String, | ||
quote_price: Option<Uint128>, | ||
}, | ||
UpdateSellToPoolQuote { | ||
collection: String, | ||
quote_price: Option<Uint128>, | ||
}, | ||
} | ||
|
||
#[cw_serde] | ||
#[derive(QueryResponses)] | ||
pub enum QueryMsg { | ||
#[returns(PoolQuoteResponse)] | ||
QuoteSellToPool { | ||
collection: String, | ||
limit: u64, | ||
}, | ||
} | ||
|
||
#[cw_serde] | ||
pub struct PoolQuoteResponse { | ||
pub pool_quotes: Vec<PoolQuote>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use crate::msg::{PoolQuoteResponse, QueryMsg}; | ||
use crate::state::{sell_to_pool_quotes, PoolQuote}; | ||
|
||
use cosmwasm_std::{to_binary, Addr, Binary, Deps, Env, Order, StdResult}; | ||
|
||
#[cfg(not(feature = "library"))] | ||
use cosmwasm_std::entry_point; | ||
|
||
#[cfg_attr(not(feature = "library"), entry_point)] | ||
pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> { | ||
match msg { | ||
QueryMsg::QuoteSellToPool { | ||
collection, | ||
limit, | ||
} => to_binary(&query_quotes_sell_to_pool( | ||
deps, | ||
deps.api.addr_validate(&collection)?, | ||
limit, | ||
)?), | ||
} | ||
} | ||
|
||
pub fn query_quotes_sell_to_pool( | ||
deps: Deps, | ||
collection: Addr, | ||
limit: u64, | ||
) -> StdResult<PoolQuoteResponse> { | ||
let pool_quotes: Vec<PoolQuote> = sell_to_pool_quotes() | ||
.idx | ||
.collection_quote_price | ||
.sub_prefix(collection) | ||
.range(deps.storage, None, None, Order::Descending) | ||
.take(limit as usize) | ||
.map(|item| item.map(|(_, v)| v)) | ||
.collect::<StdResult<_>>()?; | ||
|
||
Ok(PoolQuoteResponse { | ||
pool_quotes, | ||
}) | ||
} |
Oops, something went wrong.