Skip to content

Commit bf13722

Browse files
p-offtermattCopilotclaude
authored
Add query for control center pool info right from the vault contract (#363)
* Add new ControlCenterPoolInfo query * Add unit test for ControlCenterPoolInfo query (#364) * Initial plan * Add unit test for ControlCenterPoolInfo query Co-authored-by: p-offtermatt <57488781+p-offtermatt@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: p-offtermatt <57488781+p-offtermatt@users.noreply.github.com> * Regenerate schema * Update changelog: add PR link and ID to filename Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Recompile artifacts --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 9a0b5bd commit bf13722

File tree

13 files changed

+361
-9
lines changed

13 files changed

+361
-9
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Add `ControlCenterPoolInfo` query to the Inflow vault contract that returns the pool info from the Control Center contract. ([\#363](https://github.com/informalsystems/hydro/pull/363))

artifacts/checksums.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
3b7caadd4169d43b5e041f1a0e502c2d0a3116d2c714ab9f5a96e003cfcf8698 control_center.wasm
1+
a4efb284257dd3d7e03c4ed63c60aa3b7c113d8f1cd8df1f192709c07b73747d control_center.wasm
22
50632fa67ac4c20d1757079ea8239293de9228763ab923e6ac8187eec9661e0b d_token_info_provider.wasm
33
d24dc4740ee34a51fe741d3c20c4a6afd5c22465b883a77c6e482d367530e0fc dao_voting_adapter.wasm
44
04b35ce2a2d38d1558a53a8f0e7efd527a1630f3b48897806e109918a711b6b5 gatekeeper.wasm
@@ -12,4 +12,4 @@ c95cda39a291a37c5ec67d049cfddba71b90916ccb9d7dec8023e804aaa90ca5 marketplace.wa
1212
8535ea89d552ea8bae7c005bb375e9cf0114eccafa20d819935d08402e5661a2 st_token_info_provider.wasm
1313
08550312a580125cfd91934ffb287d9d7e5f3db278ea4107602380872c3405a0 tribute.wasm
1414
a107833648b55ffdc7302e2a70d21a8ecfeee71e354168b3ebaf71f9a1d9101f user_registry.wasm
15-
4c9c6b050559152dca93d95a83e88a582a70bd40077bd32f145fc62c281c925f vault.wasm
15+
c18b60172d35992bf76b4344bd0307edc025ccdcf7b223dd314521935caeb83e vault.wasm

artifacts/control_center.wasm

0 Bytes
Binary file not shown.

artifacts/vault.wasm

2.11 KB
Binary file not shown.

contracts/inflow/vault/schema/raw/query.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,20 @@
220220
},
221221
"additionalProperties": false
222222
},
223+
{
224+
"description": "Returns the pool info of the Control Center contract.",
225+
"type": "object",
226+
"required": [
227+
"control_center_pool_info"
228+
],
229+
"properties": {
230+
"control_center_pool_info": {
231+
"type": "object",
232+
"additionalProperties": false
233+
}
234+
},
235+
"additionalProperties": false
236+
},
223237
{
224238
"description": "Returns a list of all registered adapters",
225239
"type": "object",
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"title": "PoolInfoResponse",
4+
"type": "object",
5+
"required": [
6+
"total_pool_value",
7+
"total_shares_issued"
8+
],
9+
"properties": {
10+
"total_pool_value": {
11+
"$ref": "#/definitions/Uint128"
12+
},
13+
"total_shares_issued": {
14+
"$ref": "#/definitions/Uint128"
15+
}
16+
},
17+
"additionalProperties": false,
18+
"definitions": {
19+
"Uint128": {
20+
"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); ```",
21+
"type": "string"
22+
}
23+
}
24+
}

contracts/inflow/vault/schema/vault.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,20 @@
852852
},
853853
"additionalProperties": false
854854
},
855+
{
856+
"description": "Returns the pool info of the Control Center contract.",
857+
"type": "object",
858+
"required": [
859+
"control_center_pool_info"
860+
],
861+
"properties": {
862+
"control_center_pool_info": {
863+
"type": "object",
864+
"additionalProperties": false
865+
}
866+
},
867+
"additionalProperties": false
868+
},
855869
{
856870
"description": "Returns a list of all registered adapters",
857871
"type": "object",
@@ -1089,6 +1103,30 @@
10891103
}
10901104
}
10911105
},
1106+
"control_center_pool_info": {
1107+
"$schema": "http://json-schema.org/draft-07/schema#",
1108+
"title": "PoolInfoResponse",
1109+
"type": "object",
1110+
"required": [
1111+
"total_pool_value",
1112+
"total_shares_issued"
1113+
],
1114+
"properties": {
1115+
"total_pool_value": {
1116+
"$ref": "#/definitions/Uint128"
1117+
},
1118+
"total_shares_issued": {
1119+
"$ref": "#/definitions/Uint128"
1120+
}
1121+
},
1122+
"additionalProperties": false,
1123+
"definitions": {
1124+
"Uint128": {
1125+
"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); ```",
1126+
"type": "string"
1127+
}
1128+
}
1129+
},
10921130
"funded_withdrawal_requests": {
10931131
"$schema": "http://json-schema.org/draft-07/schema#",
10941132
"title": "FundedWithdrawalRequestsResponse",

contracts/inflow/vault/src/contract.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,6 +1722,13 @@ pub fn query(deps: Deps<NeutronQuery>, env: Env, msg: QueryMsg) -> StdResult<Bin
17221722
&deps, address, start_from, limit, order,
17231723
)?),
17241724
QueryMsg::Whitelist {} => to_json_binary(&query_whitelist(&deps)?),
1725+
QueryMsg::ControlCenterPoolInfo {} => {
1726+
let config = load_config(deps.storage)?;
1727+
to_json_binary(&get_control_center_pool_info(
1728+
&deps,
1729+
&config.control_center_contract,
1730+
)?)
1731+
}
17251732
QueryMsg::ListAdapters {} => to_json_binary(&query_list_adapters(&deps)?),
17261733
QueryMsg::AdapterInfo { name } => to_json_binary(&query_adapter_info(&deps, name)?),
17271734
}

contracts/inflow/vault/src/testing.rs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2873,6 +2873,61 @@ fn verify_users_payouts_history(
28732873
}
28742874
}
28752875

2876+
#[test]
2877+
fn control_center_pool_info_query_test() {
2878+
let (mut deps, mut env) = (mock_dependencies(), mock_env());
2879+
2880+
let inflow_contract_addr = deps.api.addr_make(INFLOW);
2881+
let control_center_contract_addr = deps.api.addr_make(CONTROL_CENTER);
2882+
let token_info_provider_contract_addr = deps.api.addr_make(TOKEN_INFO_PROVIDER);
2883+
let whitelist_addr = deps.api.addr_make(WHITELIST_ADDR);
2884+
2885+
env.contract.address = inflow_contract_addr.clone();
2886+
2887+
let instantiate_msg = get_default_instantiate_msg(
2888+
DEPOSIT_DENOM,
2889+
whitelist_addr.clone(),
2890+
control_center_contract_addr.clone(),
2891+
token_info_provider_contract_addr.clone(),
2892+
);
2893+
2894+
let info = get_message_info(&deps.api, "creator", &[]);
2895+
instantiate(deps.as_mut(), env.clone(), info, instantiate_msg).unwrap();
2896+
2897+
// Set up control center mock with specific pool values
2898+
let expected_total_pool_value = Uint128::new(1_000_000);
2899+
let expected_total_shares_issued = Uint128::new(800_000);
2900+
2901+
let wasm_querier = MockWasmQuerier::new(HashMap::from_iter([
2902+
setup_control_center_mock(
2903+
control_center_contract_addr.clone(),
2904+
DEFAULT_DEPOSIT_CAP,
2905+
expected_total_pool_value,
2906+
expected_total_shares_issued,
2907+
),
2908+
setup_token_info_provider_mock(
2909+
token_info_provider_contract_addr,
2910+
DEPOSIT_DENOM.to_string(),
2911+
DATOM_DEFAULT_RATIO,
2912+
),
2913+
]));
2914+
2915+
let querier_for_deps = wasm_querier.clone();
2916+
deps.querier
2917+
.update_wasm(move |q| querier_for_deps.handler(q));
2918+
2919+
// Query the control center pool info through the vault contract
2920+
let query_msg = QueryMsg::ControlCenterPoolInfo {};
2921+
let query_res = query(deps.as_ref(), env.clone(), query_msg);
2922+
assert!(query_res.is_ok());
2923+
2924+
// Verify the response matches what we expect from the control center
2925+
let pool_info: interface::inflow_control_center::PoolInfoResponse =
2926+
from_json(query_res.unwrap()).unwrap();
2927+
assert_eq!(pool_info.total_pool_value, expected_total_pool_value);
2928+
assert_eq!(pool_info.total_shares_issued, expected_total_shares_issued);
2929+
}
2930+
28762931
#[test]
28772932
fn deposit_from_deployment_test() {
28782933
let (mut deps, mut env) = (mock_dependencies(), mock_env());

packages/interface/src/inflow_vault.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,10 @@ pub enum QueryMsg {
241241
#[returns(WhitelistResponse)]
242242
Whitelist {},
243243

244+
/// Returns the pool info of the Control Center contract.
245+
#[returns(super::inflow_control_center::PoolInfoResponse)]
246+
ControlCenterPoolInfo {},
247+
244248
/// Returns a list of all registered adapters
245249
#[returns(AdaptersListResponse)]
246250
ListAdapters {},

0 commit comments

Comments
 (0)