diff --git a/contracts/external/cw-abc/schema/cw-abc.json b/contracts/external/cw-abc/schema/cw-abc.json index c703f505e..0a0187250 100644 --- a/contracts/external/cw-abc/schema/cw-abc.json +++ b/contracts/external/cw-abc/schema/cw-abc.json @@ -233,8 +233,8 @@ "type": "object", "required": [ "contribution_limits", - "exit_fee", "entry_fee", + "exit_fee", "initial_raise" ], "properties": { @@ -246,16 +246,16 @@ } ] }, - "exit_fee": { - "description": "Exit tax for the hatch phase", + "entry_fee": { + "description": "The initial allocation (θ), percentage of the initial raise allocated to the Funding Pool", "allOf": [ { "$ref": "#/definitions/Decimal" } ] }, - "entry_fee": { - "description": "The initial allocation (θ), percentage of the initial raise allocated to the Funding Pool", + "exit_fee": { + "description": "Exit tax for the hatch phase", "allOf": [ { "$ref": "#/definitions/Decimal" @@ -838,7 +838,7 @@ } ] }, - "exit_fee": { + "entry_fee": { "anyOf": [ { "$ref": "#/definitions/Decimal" @@ -848,7 +848,7 @@ } ] }, - "entry_fee": { + "exit_fee": { "anyOf": [ { "$ref": "#/definitions/Decimal" @@ -947,13 +947,27 @@ "additionalProperties": false }, { - "description": "Returns the current phase configuration Returns [`CommonsPhaseConfigResponse`]", + "description": "Returns information about the curve type (i.e. linear, constant, etc.)", "type": "object", "required": [ - "phase_config" + "curve_type" ], "properties": { - "phase_config": { + "curve_type": { + "type": "object", + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "Returns Token Factory Denom for the supply", + "type": "object", + "required": [ + "denom" + ], + "properties": { + "denom": { "type": "object", "additionalProperties": false } @@ -990,6 +1004,20 @@ }, "additionalProperties": false }, + { + "description": "Returns the Fee Recipient for the contract. This is the address that recieves any fees collected from bonding curve operation", + "type": "object", + "required": [ + "fees_recipient" + ], + "properties": { + "fees_recipient": { + "type": "object", + "additionalProperties": false + } + }, + "additionalProperties": false + }, { "description": "List the hatchers and their contributions Returns [`HatchersResponse`]", "type": "object", @@ -1021,13 +1049,41 @@ "additionalProperties": false }, { - "description": "Returns Token Factory Denom for the supply", + "description": "Returns the Maxiumum Supply of the supply token", "type": "object", "required": [ - "denom" + "max_supply" ], "properties": { - "denom": { + "max_supply": { + "type": "object", + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "Returns the current phase", + "type": "object", + "required": [ + "phase" + ], + "properties": { + "phase": { + "type": "object", + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "Returns the current phase configuration Returns [`CommonsPhaseConfigResponse`]", + "type": "object", + "required": [ + "phase_config" + ], + "properties": { + "phase_config": { "type": "object", "additionalProperties": false } @@ -1128,6 +1184,102 @@ } } }, + "curve_type": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "CurveType", + "oneOf": [ + { + "description": "Constant always returns `value * 10^-scale` as spot price", + "type": "object", + "required": [ + "constant" + ], + "properties": { + "constant": { + "type": "object", + "required": [ + "scale", + "value" + ], + "properties": { + "scale": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "value": { + "$ref": "#/definitions/Uint128" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "Linear returns `slope * 10^-scale * supply` as spot price", + "type": "object", + "required": [ + "linear" + ], + "properties": { + "linear": { + "type": "object", + "required": [ + "scale", + "slope" + ], + "properties": { + "scale": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "slope": { + "$ref": "#/definitions/Uint128" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "SquareRoot returns `slope * 10^-scale * supply^0.5` as spot price", + "type": "object", + "required": [ + "square_root" + ], + "properties": { + "square_root": { + "type": "object", + "required": [ + "scale", + "slope" + ], + "properties": { + "scale": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "slope": { + "$ref": "#/definitions/Uint128" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + } + ], + "definitions": { + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + } + } + }, "denom": { "$schema": "http://json-schema.org/draft-07/schema#", "title": "DenomResponse", @@ -1180,6 +1332,12 @@ } } }, + "fees_recipient": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Addr", + "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.", + "type": "string" + }, "hatchers": { "$schema": "http://json-schema.org/draft-07/schema#", "title": "HatchersResponse", @@ -1218,6 +1376,12 @@ } } }, + "max_supply": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Uint128", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + }, "ownership": { "$schema": "http://json-schema.org/draft-07/schema#", "title": "Ownership_for_String", @@ -1313,6 +1477,16 @@ } } }, + "phase": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "CommonsPhase", + "type": "string", + "enum": [ + "hatch", + "open", + "closed" + ] + }, "phase_config": { "$schema": "http://json-schema.org/draft-07/schema#", "title": "CommonsPhaseConfigResponse", @@ -1396,8 +1570,8 @@ "type": "object", "required": [ "contribution_limits", - "exit_fee", "entry_fee", + "exit_fee", "initial_raise" ], "properties": { @@ -1409,16 +1583,16 @@ } ] }, - "exit_fee": { - "description": "Exit tax for the hatch phase", + "entry_fee": { + "description": "The initial allocation (θ), percentage of the initial raise allocated to the Funding Pool", "allOf": [ { "$ref": "#/definitions/Decimal" } ] }, - "entry_fee": { - "description": "The initial allocation (θ), percentage of the initial raise allocated to the Funding Pool", + "exit_fee": { + "description": "Exit tax for the hatch phase", "allOf": [ { "$ref": "#/definitions/Decimal" diff --git a/contracts/external/cw-abc/src/contract.rs b/contracts/external/cw-abc/src/contract.rs index 091111936..968516e54 100644 --- a/contracts/external/cw-abc/src/contract.rs +++ b/contracts/external/cw-abc/src/contract.rs @@ -157,15 +157,19 @@ pub fn do_query( match msg { // custom queries QueryMsg::CurveInfo {} => to_json_binary(&queries::query_curve_info(deps, curve_fn)?), - QueryMsg::PhaseConfig {} => to_json_binary(&queries::query_phase_config(deps)?), + QueryMsg::CurveType {} => to_json_binary(&CURVE_TYPE.load(deps.storage)?), + QueryMsg::Denom {} => to_json_binary(&queries::get_denom(deps)?), QueryMsg::Donations { start_after, limit } => { to_json_binary(&queries::query_donations(deps, start_after, limit)?) } + QueryMsg::FeesRecipient {} => to_json_binary(&FEES_RECIPIENT.load(deps.storage)?), QueryMsg::Hatchers { start_after, limit } => { to_json_binary(&queries::query_hatchers(deps, start_after, limit)?) } + QueryMsg::MaxSupply {} => to_json_binary(&queries::query_max_supply(deps)?), QueryMsg::Ownership {} => to_json_binary(&cw_ownable::get_ownership(deps.storage)?), - QueryMsg::Denom {} => to_json_binary(&queries::get_denom(deps)?), + QueryMsg::PhaseConfig {} => to_json_binary(&queries::query_phase_config(deps)?), + QueryMsg::Phase {} => to_json_binary(&PHASE.load(deps.storage)?), QueryMsg::TokenContract {} => to_json_binary(&TOKEN_ISSUER_CONTRACT.load(deps.storage)?), } } diff --git a/contracts/external/cw-abc/src/msg.rs b/contracts/external/cw-abc/src/msg.rs index 1f4ca3519..c201760e2 100644 --- a/contracts/external/cw-abc/src/msg.rs +++ b/contracts/external/cw-abc/src/msg.rs @@ -88,9 +88,6 @@ pub enum ExecuteMsg { Close {}, } -// TODO Price queries: -// - Price to buy a certain amount? -// - What can be bought for a certain amount? #[cw_ownable::cw_ownable_query] #[cw_serde] #[derive(QueryResponses)] @@ -99,10 +96,12 @@ pub enum QueryMsg { /// Returns [`CurveInfoResponse`] #[returns(CurveInfoResponse)] CurveInfo {}, - /// Returns the current phase configuration - /// Returns [`CommonsPhaseConfigResponse`] - #[returns(CommonsPhaseConfigResponse)] - PhaseConfig {}, + /// Returns information about the curve type (i.e. linear, constant, etc.) + #[returns(CurveType)] + CurveType {}, + /// Returns Token Factory Denom for the supply + #[returns(DenomResponse)] + Denom {}, /// Returns a list of the donors and their donations /// Returns [`DonationsResponse`] #[returns(DonationsResponse)] @@ -110,6 +109,10 @@ pub enum QueryMsg { start_after: Option, limit: Option, }, + /// Returns the Fee Recipient for the contract. This is the address that + /// recieves any fees collected from bonding curve operation + #[returns(::cosmwasm_std::Addr)] + FeesRecipient {}, /// List the hatchers and their contributions /// Returns [`HatchersResponse`] #[returns(HatchersResponse)] @@ -117,9 +120,16 @@ pub enum QueryMsg { start_after: Option, limit: Option, }, - /// Returns Token Factory Denom for the supply - #[returns(DenomResponse)] - Denom {}, + /// Returns the Maxiumum Supply of the supply token + #[returns(Uint128)] + MaxSupply {}, + /// Returns the current phase + #[returns(CommonsPhase)] + Phase {}, + /// Returns the current phase configuration + /// Returns [`CommonsPhaseConfigResponse`] + #[returns(CommonsPhaseConfigResponse)] + PhaseConfig {}, /// Returns the address of the cw-tokenfactory-issuer contract #[returns(::cosmwasm_std::Addr)] TokenContract {}, diff --git a/contracts/external/cw-abc/src/queries.rs b/contracts/external/cw-abc/src/queries.rs index b83cd70a9..1d113df3d 100644 --- a/contracts/external/cw-abc/src/queries.rs +++ b/contracts/external/cw-abc/src/queries.rs @@ -4,9 +4,9 @@ use crate::msg::{ HatchersResponse, }; use crate::state::{ - CurveState, CURVE_STATE, DONATIONS, HATCHERS, PHASE, PHASE_CONFIG, SUPPLY_DENOM, + CurveState, CURVE_STATE, DONATIONS, HATCHERS, MAX_SUPPLY, PHASE, PHASE_CONFIG, SUPPLY_DENOM, }; -use cosmwasm_std::{Deps, Order, QuerierWrapper, StdResult}; +use cosmwasm_std::{Deps, Order, QuerierWrapper, StdResult, Uint128}; use std::ops::Deref; use token_bindings::TokenFactoryQuery; @@ -36,16 +36,6 @@ pub fn query_curve_info( }) } -/// Load and return the phase config -pub fn query_phase_config(deps: Deps) -> StdResult { - let phase = PHASE.load(deps.storage)?; - let phase_config = PHASE_CONFIG.load(deps.storage)?; - Ok(CommonsPhaseConfigResponse { - phase_config, - phase, - }) -} - /// Returns information about the supply Denom pub fn get_denom(deps: Deps) -> StdResult { let denom = SUPPLY_DENOM.load(deps.storage)?; @@ -75,6 +65,7 @@ pub fn query_donations( Ok(DonationsResponse { donations }) } +/// Query hatchers who contributed during the hatch phase pub fn query_hatchers( deps: Deps, start_aftor: Option, @@ -97,3 +88,19 @@ pub fn query_hatchers( Ok(HatchersResponse { hatchers }) } + +/// Query the max supply of the supply token +pub fn query_max_supply(deps: Deps) -> StdResult { + let max_supply = MAX_SUPPLY.may_load(deps.storage)?; + Ok(max_supply.unwrap_or(Uint128::MAX)) +} + +/// Load and return the phase config +pub fn query_phase_config(deps: Deps) -> StdResult { + let phase = PHASE.load(deps.storage)?; + let phase_config = PHASE_CONFIG.load(deps.storage)?; + Ok(CommonsPhaseConfigResponse { + phase_config, + phase, + }) +}