Skip to content

Commit

Permalink
chore: cargo fmt + cargo clippy + just schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
nseguias committed Apr 29, 2024
1 parent b760043 commit deebeee
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 16 deletions.
50 changes: 50 additions & 0 deletions contracts/liquidity_hub/pool-manager/schema/pool-manager.json
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,7 @@
"additionalProperties": false
},
{
"description": "Simulates swap operations.",
"type": "object",
"required": [
"simulate_swap_operations"
Expand Down Expand Up @@ -863,6 +864,35 @@
},
"additionalProperties": false
},
{
"description": "Simulates a reverse swap operations, i.e. given the ask asset, how much of the offer asset is needed to perform the swap.",
"type": "object",
"required": [
"reverse_simulate_swap_operations"
],
"properties": {
"reverse_simulate_swap_operations": {
"type": "object",
"required": [
"ask_amount",
"operations"
],
"properties": {
"ask_amount": {
"$ref": "#/definitions/Uint128"
},
"operations": {
"type": "array",
"items": {
"$ref": "#/definitions/SwapOperation"
}
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
Expand Down Expand Up @@ -1378,6 +1408,26 @@
}
}
},
"reverse_simulate_swap_operations": {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "ReverseSimulateSwapOperationsResponse",
"type": "object",
"required": [
"amount"
],
"properties": {
"amount": {
"$ref": "#/definitions/Uint128"
}
},
"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"
}
}
},
"reverse_simulation": {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "ReverseSimulationResponse",
Expand Down
30 changes: 30 additions & 0 deletions contracts/liquidity_hub/pool-manager/schema/raw/query.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
"additionalProperties": false
},
{
"description": "Simulates swap operations.",
"type": "object",
"required": [
"simulate_swap_operations"
Expand Down Expand Up @@ -166,6 +167,35 @@
},
"additionalProperties": false
},
{
"description": "Simulates a reverse swap operations, i.e. given the ask asset, how much of the offer asset is needed to perform the swap.",
"type": "object",
"required": [
"reverse_simulate_swap_operations"
],
"properties": {
"reverse_simulate_swap_operations": {
"type": "object",
"required": [
"ask_amount",
"operations"
],
"properties": {
"ask_amount": {
"$ref": "#/definitions/Uint128"
},
"operations": {
"type": "array",
"items": {
"$ref": "#/definitions/SwapOperation"
}
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "ReverseSimulateSwapOperationsResponse",
"type": "object",
"required": [
"amount"
],
"properties": {
"amount": {
"$ref": "#/definitions/Uint128"
}
},
"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"
}
}
}
36 changes: 20 additions & 16 deletions contracts/liquidity_hub/pool-manager/src/tests/suite.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use cosmwasm_std::testing::MockStorage;
use white_whale_std::pool_manager::{
Config, FeatureToggle, PairInfoResponse, ReverseSimulateSwapOperationsResponse, SimulateSwapOperationsResponse, SwapOperation, SwapRouteCreatorResponse, SwapRouteResponse, SwapRoutesResponse
Config, FeatureToggle, PairInfoResponse, ReverseSimulateSwapOperationsResponse,
SimulateSwapOperationsResponse, SwapOperation, SwapRouteCreatorResponse, SwapRouteResponse,
SwapRoutesResponse,
};
use white_whale_std::pool_manager::{InstantiateMsg, PairInfo};

Expand All @@ -15,8 +17,8 @@ use white_whale_std::epoch_manager::epoch_manager::{Epoch, EpochConfig};
use white_whale_std::fee::PoolFee;
use white_whale_std::incentive_manager::PositionsResponse;
use white_whale_std::lp_common::LP_SYMBOL;
use white_whale_std::pool_network::asset::{AssetInfo, PairType};
use white_whale_std::pool_manager::{ReverseSimulationResponse, SimulationResponse};
use white_whale_std::pool_network::asset::{AssetInfo, PairType};
use white_whale_testing::multi_test::stargate_mock::StargateMock;

fn contract_pool_manager() -> Box<dyn Contract<Empty>> {
Expand Down Expand Up @@ -614,13 +616,14 @@ impl TestingSuite {
operations: Vec<SwapOperation>,
result: impl Fn(StdResult<SimulateSwapOperationsResponse>),
) -> &mut Self {
let pair_info_response: StdResult<SimulateSwapOperationsResponse> = self.app.wrap().query_wasm_smart(
&self.pool_manager_addr,
&white_whale_std::pool_manager::QueryMsg::SimulateSwapOperations {
offer_amount,
operations,
},
);
let pair_info_response: StdResult<SimulateSwapOperationsResponse> =
self.app.wrap().query_wasm_smart(

Check warning on line 620 in contracts/liquidity_hub/pool-manager/src/tests/suite.rs

View check run for this annotation

Codecov / codecov/patch

contracts/liquidity_hub/pool-manager/src/tests/suite.rs#L620

Added line #L620 was not covered by tests
&self.pool_manager_addr,
&white_whale_std::pool_manager::QueryMsg::SimulateSwapOperations {
offer_amount,

Check warning on line 623 in contracts/liquidity_hub/pool-manager/src/tests/suite.rs

View check run for this annotation

Codecov / codecov/patch

contracts/liquidity_hub/pool-manager/src/tests/suite.rs#L623

Added line #L623 was not covered by tests
operations,
},
);

result(pair_info_response);

Expand All @@ -633,13 +636,14 @@ impl TestingSuite {
operations: Vec<SwapOperation>,
result: impl Fn(StdResult<ReverseSimulateSwapOperationsResponse>),
) -> &mut Self {
let pair_info_response: StdResult<ReverseSimulateSwapOperationsResponse> = self.app.wrap().query_wasm_smart(
&self.pool_manager_addr,
&white_whale_std::pool_manager::QueryMsg::ReverseSimulateSwapOperations {
ask_amount,
operations,
},
);
let pair_info_response: StdResult<ReverseSimulateSwapOperationsResponse> =
self.app.wrap().query_wasm_smart(

Check warning on line 640 in contracts/liquidity_hub/pool-manager/src/tests/suite.rs

View check run for this annotation

Codecov / codecov/patch

contracts/liquidity_hub/pool-manager/src/tests/suite.rs#L640

Added line #L640 was not covered by tests
&self.pool_manager_addr,
&white_whale_std::pool_manager::QueryMsg::ReverseSimulateSwapOperations {
ask_amount,

Check warning on line 643 in contracts/liquidity_hub/pool-manager/src/tests/suite.rs

View check run for this annotation

Codecov / codecov/patch

contracts/liquidity_hub/pool-manager/src/tests/suite.rs#L643

Added line #L643 was not covered by tests
operations,
},
);

result(pair_info_response);

Expand Down

0 comments on commit deebeee

Please sign in to comment.