Skip to content

Commit

Permalink
More queries, update schema
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeHartnell authored and Jake Hartnell committed Mar 26, 2024
1 parent 71832ce commit 33927a1
Show file tree
Hide file tree
Showing 4 changed files with 237 additions and 42 deletions.
210 changes: 192 additions & 18 deletions contracts/external/cw-abc/schema/cw-abc.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@
"type": "object",
"required": [
"contribution_limits",
"exit_fee",
"entry_fee",
"exit_fee",
"initial_raise"
],
"properties": {
Expand All @@ -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"
Expand Down Expand Up @@ -838,7 +838,7 @@
}
]
},
"exit_fee": {
"entry_fee": {
"anyOf": [
{
"$ref": "#/definitions/Decimal"
Expand All @@ -848,7 +848,7 @@
}
]
},
"entry_fee": {
"exit_fee": {
"anyOf": [
{
"$ref": "#/definitions/Decimal"
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -1396,8 +1570,8 @@
"type": "object",
"required": [
"contribution_limits",
"exit_fee",
"entry_fee",
"exit_fee",
"initial_raise"
],
"properties": {
Expand All @@ -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"
Expand Down
8 changes: 6 additions & 2 deletions contracts/external/cw-abc/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?),
}
}
Expand Down
Loading

0 comments on commit 33927a1

Please sign in to comment.