From 452eb62c92e0bac0ffc70f805c687d08292ee9ad Mon Sep 17 00:00:00 2001 From: larry <26318510+larry0x@users.noreply.github.com> Date: Thu, 12 Oct 2023 09:22:31 +0100 Subject: [PATCH 01/15] rename `mars-red-bank-types` to `mars-types`, update `Cargo.toml`s --- Cargo.lock | 159 ++++++------------ Cargo.toml | 8 +- contracts/account-nft/Cargo.toml | 21 +-- contracts/address-provider/Cargo.toml | 16 +- contracts/credit-manager/Cargo.toml | 27 ++- contracts/health/Cargo.toml | 4 +- contracts/incentives/Cargo.toml | 16 +- contracts/mock-credit-manager/Cargo.toml | 13 +- contracts/mock-health/Cargo.toml | 8 +- contracts/mock-incentives/Cargo.toml | 8 +- contracts/mock-oracle/Cargo.toml | 8 +- contracts/mock-pyth/Cargo.toml | 6 +- contracts/mock-red-bank/Cargo.toml | 10 +- contracts/mock-vault/Cargo.toml | 15 +- contracts/oracle/base/Cargo.toml | 20 +-- contracts/oracle/osmosis/Cargo.toml | 28 +-- contracts/oracle/wasm/Cargo.toml | 16 +- contracts/params/Cargo.toml | 18 +- contracts/red-bank/Cargo.toml | 36 ++-- contracts/rewards-collector/base/Cargo.toml | 20 +-- .../rewards-collector/neutron/Cargo.toml | 2 +- .../rewards-collector/osmosis/Cargo.toml | 2 +- contracts/swapper/astroport/Cargo.toml | 22 +-- contracts/swapper/base/Cargo.toml | 20 +-- contracts/swapper/mock/Cargo.toml | 4 +- contracts/swapper/osmosis/Cargo.toml | 18 +- contracts/v2-zapper/mock/Cargo.toml | 15 +- integration-tests/Cargo.toml | 2 +- packages/health-computer/Cargo.toml | 23 ++- packages/health/Cargo.toml | 8 +- packages/interest-rate/Cargo.toml | 8 +- packages/liquidation/Cargo.toml | 8 +- packages/testing/Cargo.toml | 2 +- packages/types/Cargo.toml | 7 +- 34 files changed, 259 insertions(+), 339 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e0ec223e4..9a57bea29 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2087,28 +2087,15 @@ dependencies = [ "cw721 0.18.0", "cw721-base 0.16.0", "cw721-base 0.18.0", - "mars-account-nft-types", "mars-mock-credit-manager", "mars-mock-rover-health", "mars-owner 2.0.0", - "mars-red-bank-types 2.0.0", - "mars-rover 1.0.0", - "mars-rover 2.0.0", - "mars-rover-health-types", + "mars-rover", + "mars-types", "serde_json", "thiserror", ] -[[package]] -name = "mars-account-nft-types" -version = "2.0.0" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw721 0.18.0", - "cw721-base 0.18.0", -] - [[package]] name = "mars-address-provider" version = "2.0.0" @@ -2119,8 +2106,8 @@ dependencies = [ "cw-storage-plus 1.1.0", "cw2 1.1.1", "mars-owner 2.0.0", - "mars-red-bank-types 2.0.0", "mars-testing", + "mars-types", "serde", "thiserror", ] @@ -2142,7 +2129,6 @@ dependencies = [ "cw721-base 0.18.0", "itertools 0.11.0", "mars-account-nft", - "mars-account-nft-types", "mars-address-provider", "mars-liquidation", "mars-mock-incentives", @@ -2151,11 +2137,9 @@ dependencies = [ "mars-mock-vault", "mars-owner 2.0.0", "mars-params", - "mars-red-bank-types 2.0.0", - "mars-rover 2.0.0", "mars-rover-health", - "mars-rover-health-types", "mars-swapper-mock", + "mars-types", "mars-zapper-mock", "test-case", ] @@ -2175,8 +2159,8 @@ version = "2.0.0" dependencies = [ "cosmwasm-std", "mars-params", - "mars-red-bank-types 2.0.0", "mars-testing", + "mars-types", "thiserror", ] @@ -2191,8 +2175,8 @@ dependencies = [ "mars-owner 2.0.0", "mars-red-bank", "mars-red-bank-types 1.0.0 (git+https://github.com/mars-protocol/red-bank?tag=v1.0.0)", - "mars-red-bank-types 2.0.0", "mars-testing", + "mars-types", "mars-utils 2.0.0", "osmosis-std 0.19.2", "test-case", @@ -2214,10 +2198,10 @@ dependencies = [ "mars-osmosis", "mars-params", "mars-red-bank", - "mars-red-bank-types 2.0.0", "mars-rewards-collector-osmosis", "mars-swapper-osmosis", "mars-testing", + "mars-types", "mars-utils 2.0.0", "osmosis-std 0.19.2", "osmosis-test-tube", @@ -2230,7 +2214,7 @@ version = "2.0.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "mars-red-bank-types 2.0.0", + "mars-types", "mars-utils 2.0.0", ] @@ -2240,7 +2224,7 @@ version = "1.0.0" dependencies = [ "cosmwasm-std", "mars-health 2.0.0", - "mars-red-bank-types 2.0.0", + "mars-types", "thiserror", ] @@ -2252,8 +2236,7 @@ dependencies = [ "cosmwasm-std", "cw-storage-plus 1.1.0", "cw-utils 1.0.2", - "mars-rover 2.0.0", - "mars-rover-health-types", + "mars-types", "thiserror", ] @@ -2264,7 +2247,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus 1.1.0", - "mars-red-bank-types 2.0.0", + "mars-types", ] [[package]] @@ -2274,7 +2257,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus 1.1.0", - "mars-red-bank-types 2.0.0", + "mars-types", ] [[package]] @@ -2294,7 +2277,7 @@ dependencies = [ "cosmwasm-std", "cw-storage-plus 1.1.0", "cw-utils 1.0.2", - "mars-red-bank-types 2.0.0", + "mars-types", ] [[package]] @@ -2304,7 +2287,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus 1.1.0", - "mars-rover-health-types", + "mars-types", ] [[package]] @@ -2316,8 +2299,7 @@ dependencies = [ "cw-storage-plus 1.1.0", "cw-utils 1.0.2", "cw-vault-standard 0.3.3", - "mars-red-bank-types 2.0.0", - "mars-rover 2.0.0", + "mars-types", "thiserror", ] @@ -2329,7 +2311,7 @@ dependencies = [ "cw-storage-plus 1.1.0", "cw2 1.1.1", "mars-owner 2.0.0", - "mars-red-bank-types 2.0.0", + "mars-types", "mars-utils 2.0.0", "pyth-sdk-cw", "schemars", @@ -2349,8 +2331,8 @@ dependencies = [ "mars-oracle-base", "mars-osmosis", "mars-owner 2.0.0", - "mars-red-bank-types 2.0.0", "mars-testing", + "mars-types", "mars-utils 2.0.0", "osmosis-std 0.19.2", "pyth-sdk-cw", @@ -2370,8 +2352,8 @@ dependencies = [ "cw2 1.1.1", "mars-oracle-base", "mars-owner 2.0.0", - "mars-red-bank-types 2.0.0", "mars-testing", + "mars-types", "proptest", "pyth-sdk-cw", "test-case", @@ -2425,8 +2407,8 @@ dependencies = [ "cw2 1.1.1", "mars-interest-rate", "mars-owner 2.0.0", - "mars-red-bank-types 2.0.0", "mars-testing", + "mars-types", "mars-utils 2.0.0", "test-case", "thiserror", @@ -2448,8 +2430,8 @@ dependencies = [ "mars-liquidation", "mars-owner 2.0.0", "mars-params", - "mars-red-bank-types 2.0.0", "mars-testing", + "mars-types", "mars-utils 2.0.0", "pyth-sdk-cw", "test-case", @@ -2481,21 +2463,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "mars-red-bank-types" -version = "2.0.0" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus 1.1.0", - "mars-owner 2.0.0", - "mars-utils 2.0.0", - "serde", - "serde-json-wasm 1.0.0", - "strum 0.25.0", - "thiserror", -] - [[package]] name = "mars-rewards-collector-base" version = "2.0.0" @@ -2505,7 +2472,7 @@ dependencies = [ "cw-storage-plus 1.1.0", "cw2 1.1.1", "mars-owner 2.0.0", - "mars-red-bank-types 2.0.0", + "mars-types", "mars-utils 2.0.0", "schemars", "serde", @@ -2518,8 +2485,8 @@ version = "2.0.0" dependencies = [ "cosmwasm-std", "cw2 1.1.1", - "mars-red-bank-types 2.0.0", "mars-rewards-collector-base", + "mars-types", "neutron-sdk", ] @@ -2533,9 +2500,9 @@ dependencies = [ "cw2 1.1.1", "mars-osmosis", "mars-owner 2.0.0", - "mars-red-bank-types 2.0.0", "mars-rewards-collector-base", "mars-testing", + "mars-types", "mars-utils 2.0.0", "osmosis-std 0.19.2", "serde", @@ -2561,30 +2528,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "mars-rover" -version = "2.0.0" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus 1.1.0", - "cw-utils 1.0.2", - "cw-vault-standard 0.3.3", - "cw2 1.1.1", - "cw721 0.18.0", - "cw721-base 0.18.0", - "mars-account-nft-types", - "mars-liquidation", - "mars-owner 2.0.0", - "mars-params", - "mars-red-bank-types 2.0.0", - "mars-rover-health-types", - "mars-zapper-base", - "schemars", - "serde", - "thiserror", -] - [[package]] name = "mars-rover-health" version = "2.0.0" @@ -2602,10 +2545,8 @@ dependencies = [ "mars-mock-vault", "mars-owner 2.0.0", "mars-params", - "mars-red-bank-types 2.0.0", - "mars-rover 2.0.0", "mars-rover-health-computer", - "mars-rover-health-types", + "mars-types", "thiserror", ] @@ -2617,10 +2558,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-vault-standard 0.3.3", - "mars-params", - "mars-red-bank-types 2.0.0", - "mars-rover 2.0.0", - "mars-rover-health-types", + "mars-types", "proptest", "schemars", "serde", @@ -2629,23 +2567,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "mars-rover-health-types" -version = "2.0.0" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "mars-health 2.0.0", - "mars-owner 2.0.0", - "mars-red-bank-types 2.0.0", - "schemars", - "serde", - "serde_json", - "thiserror", - "tsify", - "wasm-bindgen", -] - [[package]] name = "mars-swapper-astroport" version = "2.0.0" @@ -2657,9 +2578,9 @@ dependencies = [ "cw-it", "cw2 1.1.1", "mars-oracle-wasm", - "mars-red-bank-types 2.0.0", "mars-swapper-base", "mars-testing", + "mars-types", "test-case", ] @@ -2673,7 +2594,7 @@ dependencies = [ "cw-storage-plus 1.1.0", "cw2 1.1.1", "mars-owner 2.0.0", - "mars-red-bank-types 2.0.0", + "mars-types", "schemars", "serde", "thiserror", @@ -2686,7 +2607,7 @@ dependencies = [ "anyhow", "cosmwasm-std", "cw-multi-test", - "mars-red-bank-types 2.0.0", + "mars-types", ] [[package]] @@ -2701,9 +2622,9 @@ dependencies = [ "cw2 1.1.1", "mars-osmosis", "mars-owner 2.0.0", - "mars-red-bank-types 2.0.0", "mars-swapper-base", "mars-testing", + "mars-types", "osmosis-std 0.19.2", ] @@ -2727,14 +2648,31 @@ dependencies = [ "mars-owner 2.0.0", "mars-params", "mars-red-bank", - "mars-red-bank-types 2.0.0", "mars-rewards-collector-osmosis", "mars-swapper-astroport", + "mars-types", "osmosis-std 0.19.2", "prost 0.11.9", "pyth-sdk-cw", ] +[[package]] +name = "mars-types" +version = "2.0.0" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw-storage-plus 1.1.0", + "mars-owner 2.0.0", + "mars-utils 2.0.0", + "serde", + "serde-json-wasm 1.0.0", + "strum 0.25.0", + "thiserror", + "tsify", + "wasm-bindgen", +] + [[package]] name = "mars-utils" version = "1.0.0" @@ -2786,8 +2724,7 @@ dependencies = [ "cosmwasm-std", "cw-storage-plus 1.1.0", "cw-utils 1.0.2", - "mars-red-bank-types 2.0.0", - "mars-rover 2.0.0", + "mars-types", "mars-zapper-base", "thiserror", ] diff --git a/Cargo.toml b/Cargo.toml index d3a5d2db9..6ef965d35 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,14 +24,11 @@ members = [ "contracts/mock-vault", # packages - "packages/account-nft-types", "packages/chains/*", "packages/health", "packages/health-computer", - "packages/health-types", "packages/interest-rate", "packages/liquidation", - "packages/rover", "packages/testing", "packages/types", "packages/utils", @@ -97,18 +94,15 @@ proptest = "1.2.0" test-case = "3.2.1" # packages -mars-account-nft-types = { path = "./packages/account-nft-types" } mars-health = { path = "./packages/health" } mars-rover-health-computer = { path = "./packages/health-computer" } -mars-rover-health-types = { path = "./packages/health-types" } mars-interest-rate = { path = "./packages/interest-rate" } mars-liquidation = { path = "./packages/liquidation" } mars-osmosis = { path = "./packages/chains/osmosis" } -mars-red-bank-types = { path = "./packages/types" } -mars-rover = { path = "./packages/rover" } # Old rover types used for migration (https://github.com/mars-protocol/v2-fields-of-mars/releases/tag/v1.0.0) mars-rover-old = { package = "mars-rover", git = "https://github.com/mars-protocol/v2-fields-of-mars", rev = "183e4c5" } mars-testing = { path = "./packages/testing" } +mars-types = { path = "./packages/types" } mars-utils = { path = "./packages/utils" } # contracts diff --git a/contracts/account-nft/Cargo.toml b/contracts/account-nft/Cargo.toml index 85502dd9a..5cea32827 100644 --- a/contracts/account-nft/Cargo.toml +++ b/contracts/account-nft/Cargo.toml @@ -19,18 +19,15 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-schema = { workspace = true } -cosmwasm-std = { workspace = true } -cw2 = { workspace = true } -cw721 = { workspace = true } -cw721-base = { workspace = true } -cw-storage-plus = { workspace = true } -mars-account-nft-types = { workspace = true } -mars-red-bank-types = { workspace = true } -mars-rover = { workspace = true } -mars-rover-health-types = { workspace = true } -mars-rover-old = { workspace = true } -thiserror = { workspace = true } +cosmwasm-schema = { workspace = true } +cosmwasm-std = { workspace = true } +cw2 = { workspace = true } +cw721 = { workspace = true } +cw721-base = { workspace = true } +cw-storage-plus = { workspace = true } +mars-rover-old = { workspace = true } +mars-types = { workspace = true } +thiserror = { workspace = true } [dev-dependencies] anyhow = { workspace = true } diff --git a/contracts/address-provider/Cargo.toml b/contracts/address-provider/Cargo.toml index 9420e2af2..49bd950f3 100644 --- a/contracts/address-provider/Cargo.toml +++ b/contracts/address-provider/Cargo.toml @@ -20,14 +20,14 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -bech32 = { workspace = true } -cosmwasm-schema = { workspace = true } -cosmwasm-std = { workspace = true } -cw2 = { workspace = true } -cw-storage-plus = { workspace = true } -mars-owner = { workspace = true } -mars-red-bank-types = { workspace = true } -thiserror = { workspace = true } +bech32 = { workspace = true } +cosmwasm-schema = { workspace = true } +cosmwasm-std = { workspace = true } +cw2 = { workspace = true } +cw-storage-plus = { workspace = true } +mars-owner = { workspace = true } +mars-types = { workspace = true } +thiserror = { workspace = true } [dev-dependencies] cosmwasm-schema = { workspace = true } diff --git a/contracts/credit-manager/Cargo.toml b/contracts/credit-manager/Cargo.toml index e468dd03c..e7f4f13f8 100644 --- a/contracts/credit-manager/Cargo.toml +++ b/contracts/credit-manager/Cargo.toml @@ -19,21 +19,18 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-schema = { workspace = true } -cosmwasm-std = { workspace = true } -cw2 = { workspace = true } -cw721 = { workspace = true } -cw721-base = { workspace = true } -cw-paginate = { workspace = true } -cw-storage-plus = { workspace = true } -cw-utils = { workspace = true } -cw-vault-standard = { workspace = true } -mars-account-nft-types = { workspace = true } -mars-liquidation = { workspace = true } -mars-owner = { workspace = true } -mars-red-bank-types = { workspace = true } -mars-rover = { workspace = true } -mars-rover-health-types = { workspace = true } +cosmwasm-schema = { workspace = true } +cosmwasm-std = { workspace = true } +cw2 = { workspace = true } +cw721 = { workspace = true } +cw721-base = { workspace = true } +cw-paginate = { workspace = true } +cw-storage-plus = { workspace = true } +cw-utils = { workspace = true } +cw-vault-standard = { workspace = true } +mars-liquidation = { workspace = true } +mars-owner = { workspace = true } +mars-types = { workspace = true } [dev-dependencies] anyhow = { workspace = true } diff --git a/contracts/health/Cargo.toml b/contracts/health/Cargo.toml index 493e3d787..045b40732 100644 --- a/contracts/health/Cargo.toml +++ b/contracts/health/Cargo.toml @@ -24,10 +24,8 @@ cosmwasm-std = { workspace = true } cw2 = { workspace = true } cw-storage-plus = { workspace = true } mars-owner = { workspace = true } -mars-red-bank-types = { workspace = true } mars-rover-health-computer = { workspace = true } -mars-rover-health-types = { workspace = true } -mars-rover = { workspace = true } +mars-types = { workspace = true } thiserror = { workspace = true } [dev-dependencies] diff --git a/contracts/incentives/Cargo.toml b/contracts/incentives/Cargo.toml index 81ab89822..2300bac42 100644 --- a/contracts/incentives/Cargo.toml +++ b/contracts/incentives/Cargo.toml @@ -20,14 +20,14 @@ backtraces = ["cosmwasm-std/backtraces", "mars-testing/backtraces", "mars-utils/ library = [] [dependencies] -cosmwasm-schema = { workspace = true } -cosmwasm-std = { workspace = true } -cw2 = { workspace = true } -cw-storage-plus = { workspace = true } -mars-owner = { workspace = true } -mars-red-bank-types = { workspace = true } -mars-utils = { workspace = true } -thiserror = { workspace = true } +cosmwasm-schema = { workspace = true } +cosmwasm-std = { workspace = true } +cw2 = { workspace = true } +cw-storage-plus = { workspace = true } +mars-owner = { workspace = true } +mars-types = { workspace = true } +mars-utils = { workspace = true } +thiserror = { workspace = true } # Old red-bank types used for migration. mars-red-bank-types-old = { package = "mars-red-bank-types", git = "https://github.com/mars-protocol/red-bank", tag = "v1.0.0" } diff --git a/contracts/mock-credit-manager/Cargo.toml b/contracts/mock-credit-manager/Cargo.toml index d013f92e3..9c0d5dfc7 100644 --- a/contracts/mock-credit-manager/Cargo.toml +++ b/contracts/mock-credit-manager/Cargo.toml @@ -19,10 +19,9 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-schema = { workspace = true } -cosmwasm-std = { workspace = true } -cw-storage-plus = { workspace = true } -cw-utils = { workspace = true } -mars-rover-health-types = { workspace = true } -mars-rover = { workspace = true } -thiserror = { workspace = true } +cosmwasm-schema = { workspace = true } +cosmwasm-std = { workspace = true } +cw-storage-plus = { workspace = true } +cw-utils = { workspace = true } +mars-types = { workspace = true } +thiserror = { workspace = true } diff --git a/contracts/mock-health/Cargo.toml b/contracts/mock-health/Cargo.toml index 18879c5fe..beefe902e 100644 --- a/contracts/mock-health/Cargo.toml +++ b/contracts/mock-health/Cargo.toml @@ -19,7 +19,7 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-schema = { workspace = true } -cosmwasm-std = { workspace = true } -cw-storage-plus = { workspace = true } -mars-rover-health-types = { workspace = true } +cosmwasm-schema = { workspace = true } +cosmwasm-std = { workspace = true } +cw-storage-plus = { workspace = true } +mars-types = { workspace = true } diff --git a/contracts/mock-incentives/Cargo.toml b/contracts/mock-incentives/Cargo.toml index 820ec89bb..987e8a647 100644 --- a/contracts/mock-incentives/Cargo.toml +++ b/contracts/mock-incentives/Cargo.toml @@ -19,7 +19,7 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-schema = { workspace = true } -cosmwasm-std = { workspace = true } -cw-storage-plus = { workspace = true } -mars-red-bank-types = { workspace = true } +cosmwasm-schema = { workspace = true } +cosmwasm-std = { workspace = true } +cw-storage-plus = { workspace = true } +mars-types = { workspace = true } diff --git a/contracts/mock-oracle/Cargo.toml b/contracts/mock-oracle/Cargo.toml index 92a70d7b9..72ded90b4 100644 --- a/contracts/mock-oracle/Cargo.toml +++ b/contracts/mock-oracle/Cargo.toml @@ -19,7 +19,7 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-schema = { workspace = true } -cosmwasm-std = { workspace = true } -cw-storage-plus = { workspace = true } -mars-red-bank-types = { workspace = true } +cosmwasm-schema = { workspace = true } +cosmwasm-std = { workspace = true } +cw-storage-plus = { workspace = true } +mars-types = { workspace = true } diff --git a/contracts/mock-pyth/Cargo.toml b/contracts/mock-pyth/Cargo.toml index 0c4a6fd25..1d79f10f7 100644 --- a/contracts/mock-pyth/Cargo.toml +++ b/contracts/mock-pyth/Cargo.toml @@ -21,6 +21,6 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-schema = { workspace = true } -cosmwasm-std = { workspace = true } -pyth-sdk-cw = { workspace = true } +cosmwasm-schema = { workspace = true } +cosmwasm-std = { workspace = true } +pyth-sdk-cw = { workspace = true } diff --git a/contracts/mock-red-bank/Cargo.toml b/contracts/mock-red-bank/Cargo.toml index 7bcd571be..b369eff6e 100644 --- a/contracts/mock-red-bank/Cargo.toml +++ b/contracts/mock-red-bank/Cargo.toml @@ -19,8 +19,8 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-schema = { workspace = true } -cosmwasm-std = { workspace = true } -cw-storage-plus = { workspace = true } -cw-utils = { workspace = true } -mars-red-bank-types = { workspace = true } +cosmwasm-schema = { workspace = true } +cosmwasm-std = { workspace = true } +cw-storage-plus = { workspace = true } +cw-utils = { workspace = true } +mars-types = { workspace = true } diff --git a/contracts/mock-vault/Cargo.toml b/contracts/mock-vault/Cargo.toml index 502e45145..5041276b8 100644 --- a/contracts/mock-vault/Cargo.toml +++ b/contracts/mock-vault/Cargo.toml @@ -19,11 +19,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-schema = { workspace = true } -cosmwasm-std = { workspace = true } -cw-storage-plus = { workspace = true } -cw-utils = { workspace = true } -cw-vault-standard = { workspace = true } -mars-red-bank-types = { workspace = true } -mars-rover = { workspace = true } -thiserror = { workspace = true } +cosmwasm-schema = { workspace = true } +cosmwasm-std = { workspace = true } +cw-storage-plus = { workspace = true } +cw-utils = { workspace = true } +cw-vault-standard = { workspace = true } +mars-types = { workspace = true } +thiserror = { workspace = true } diff --git a/contracts/oracle/base/Cargo.toml b/contracts/oracle/base/Cargo.toml index 535dcc096..e04dc0040 100644 --- a/contracts/oracle/base/Cargo.toml +++ b/contracts/oracle/base/Cargo.toml @@ -17,13 +17,13 @@ doctest = false backtraces = ["cosmwasm-std/backtraces"] [dependencies] -cosmwasm-std = { workspace = true } -cw2 = { workspace = true } -cw-storage-plus = { workspace = true } -mars-owner = { workspace = true } -mars-utils = { workspace = true } -mars-red-bank-types = { workspace = true } -pyth-sdk-cw = { workspace = true } -schemars = { workspace = true } -serde = { workspace = true } -thiserror = { workspace = true } +cosmwasm-std = { workspace = true } +cw2 = { workspace = true } +cw-storage-plus = { workspace = true } +mars-owner = { workspace = true } +mars-utils = { workspace = true } +mars-types = { workspace = true } +pyth-sdk-cw = { workspace = true } +schemars = { workspace = true } +serde = { workspace = true } +thiserror = { workspace = true } diff --git a/contracts/oracle/osmosis/Cargo.toml b/contracts/oracle/osmosis/Cargo.toml index 25c70c0be..ccfce87af 100644 --- a/contracts/oracle/osmosis/Cargo.toml +++ b/contracts/oracle/osmosis/Cargo.toml @@ -20,20 +20,20 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-schema = { workspace = true } -cosmwasm-std = { workspace = true } -cw2 = { workspace = true } -cw-storage-plus = { workspace = true } -ica-oracle = { workspace = true } -mars-oracle-base = { workspace = true } -mars-osmosis = { workspace = true } -mars-owner = { workspace = true } -mars-utils = { workspace = true } -mars-red-bank-types = { workspace = true } -osmosis-std = { workspace = true } -pyth-sdk-cw = { workspace = true } -schemars = { workspace = true } -serde = { workspace = true } +cosmwasm-schema = { workspace = true } +cosmwasm-std = { workspace = true } +cw2 = { workspace = true } +cw-storage-plus = { workspace = true } +ica-oracle = { workspace = true } +mars-oracle-base = { workspace = true } +mars-osmosis = { workspace = true } +mars-owner = { workspace = true } +mars-utils = { workspace = true } +mars-types = { workspace = true } +osmosis-std = { workspace = true } +pyth-sdk-cw = { workspace = true } +schemars = { workspace = true } +serde = { workspace = true } [dev-dependencies] cosmwasm-schema = { workspace = true } diff --git a/contracts/oracle/wasm/Cargo.toml b/contracts/oracle/wasm/Cargo.toml index 502618919..477268909 100644 --- a/contracts/oracle/wasm/Cargo.toml +++ b/contracts/oracle/wasm/Cargo.toml @@ -21,14 +21,14 @@ library = [] osmosis-test-app = ["cw-it/osmosis-test-tube", "mars-testing/osmosis-test-tube"] [dependencies] -astroport = { workspace = true } -cosmwasm-schema = { workspace = true } -cosmwasm-std = { workspace = true } -cw2 = { workspace = true } -cw-storage-plus = { workspace = true } -mars-oracle-base = { workspace = true } -mars-red-bank-types = { workspace = true } -pyth-sdk-cw = { workspace = true } +astroport = { workspace = true } +cosmwasm-schema = { workspace = true } +cosmwasm-std = { workspace = true } +cw2 = { workspace = true } +cw-storage-plus = { workspace = true } +mars-oracle-base = { workspace = true } +mars-types = { workspace = true } +pyth-sdk-cw = { workspace = true } [dev-dependencies] cosmwasm-schema = { workspace = true } diff --git a/contracts/params/Cargo.toml b/contracts/params/Cargo.toml index 78ac63bee..eac8c0d78 100644 --- a/contracts/params/Cargo.toml +++ b/contracts/params/Cargo.toml @@ -21,15 +21,15 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-schema = { workspace = true } -cosmwasm-std = { workspace = true } -cw2 = { workspace = true } -cw-storage-plus = { workspace = true } -mars-interest-rate = { workspace = true } -mars-owner = { workspace = true } -mars-red-bank-types = { workspace = true } -mars-utils = { workspace = true } -thiserror = { workspace = true } +cosmwasm-schema = { workspace = true } +cosmwasm-std = { workspace = true } +cw2 = { workspace = true } +cw-storage-plus = { workspace = true } +mars-interest-rate = { workspace = true } +mars-owner = { workspace = true } +mars-types = { workspace = true } +mars-utils = { workspace = true } +thiserror = { workspace = true } [dev-dependencies] anyhow = { workspace = true } diff --git a/contracts/red-bank/Cargo.toml b/contracts/red-bank/Cargo.toml index 4eae110c0..c8191dde6 100644 --- a/contracts/red-bank/Cargo.toml +++ b/contracts/red-bank/Cargo.toml @@ -20,23 +20,23 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-schema = { workspace = true } -cosmwasm-std = { workspace = true } -cw2 = { workspace = true } -cw-storage-plus = { workspace = true } -cw-utils = { workspace = true } -mars-health = { workspace = true } -mars-interest-rate = { workspace = true } -mars-liquidation = { workspace = true } -mars-owner = { workspace = true } -mars-params = { workspace = true } -mars-red-bank-types = { workspace = true } -mars-utils = { workspace = true } -pyth-sdk-cw = { workspace = true } -thiserror = { workspace = true } +cosmwasm-schema = { workspace = true } +cosmwasm-std = { workspace = true } +cw2 = { workspace = true } +cw-storage-plus = { workspace = true } +cw-utils = { workspace = true } +mars-health = { workspace = true } +mars-interest-rate = { workspace = true } +mars-liquidation = { workspace = true } +mars-owner = { workspace = true } +mars-params = { workspace = true } +mars-types = { workspace = true } +mars-utils = { workspace = true } +pyth-sdk-cw = { workspace = true } +thiserror = { workspace = true } [dev-dependencies] -anyhow = { workspace = true } -cw-multi-test = { workspace = true } -mars-testing = { workspace = true } -test-case = { workspace = true } +anyhow = { workspace = true } +cw-multi-test = { workspace = true } +mars-testing = { workspace = true } +test-case = { workspace = true } diff --git a/contracts/rewards-collector/base/Cargo.toml b/contracts/rewards-collector/base/Cargo.toml index f54ebd575..8850e7b90 100644 --- a/contracts/rewards-collector/base/Cargo.toml +++ b/contracts/rewards-collector/base/Cargo.toml @@ -18,13 +18,13 @@ doctest = false backtraces = ["cosmwasm-std/backtraces"] [dependencies] -cosmwasm-schema = { workspace = true } -cosmwasm-std = { workspace = true, features = ["stargate"] } -cw2 = { workspace = true } -cw-storage-plus = { workspace = true } -mars-owner = { workspace = true } -mars-red-bank-types = { workspace = true } -mars-utils = { workspace = true } -schemars = { workspace = true } -serde = { workspace = true } -thiserror = { workspace = true } +cosmwasm-schema = { workspace = true } +cosmwasm-std = { workspace = true, features = ["stargate"] } +cw2 = { workspace = true } +cw-storage-plus = { workspace = true } +mars-owner = { workspace = true } +mars-types = { workspace = true } +mars-utils = { workspace = true } +schemars = { workspace = true } +serde = { workspace = true } +thiserror = { workspace = true } diff --git a/contracts/rewards-collector/neutron/Cargo.toml b/contracts/rewards-collector/neutron/Cargo.toml index 788255ec4..109bab479 100644 --- a/contracts/rewards-collector/neutron/Cargo.toml +++ b/contracts/rewards-collector/neutron/Cargo.toml @@ -21,6 +21,6 @@ library = [] [dependencies] cosmwasm-std = { workspace = true, features = ["stargate"] } cw2 = { workspace = true } -mars-red-bank-types = { workspace = true } mars-rewards-collector-base = { workspace = true } +mars-types = { workspace = true } neutron-sdk = { workspace = true } diff --git a/contracts/rewards-collector/osmosis/Cargo.toml b/contracts/rewards-collector/osmosis/Cargo.toml index 422c5ff52..07726498d 100644 --- a/contracts/rewards-collector/osmosis/Cargo.toml +++ b/contracts/rewards-collector/osmosis/Cargo.toml @@ -24,8 +24,8 @@ cosmwasm-std = { workspace = true, features = ["stargate"] } cw2 = { workspace = true } cw-storage-plus = { workspace = true } mars-owner = { workspace = true } -mars-red-bank-types = { workspace = true } mars-rewards-collector-base = { workspace = true } +mars-types = { workspace = true } [dev-dependencies] mars-osmosis = { workspace = true } diff --git a/contracts/swapper/astroport/Cargo.toml b/contracts/swapper/astroport/Cargo.toml index 00f6aeb37..6e7e43f48 100644 --- a/contracts/swapper/astroport/Cargo.toml +++ b/contracts/swapper/astroport/Cargo.toml @@ -22,16 +22,16 @@ library = [] osmosis-test-tube = ["cw-it/osmosis-test-tube", "mars-testing/osmosis-test-tube"] [dependencies] -astroport = { workspace = true } -cosmwasm-schema = { workspace = true } -cosmwasm-std = { workspace = true } -cw2 = { workspace = true } -mars-red-bank-types = { workspace = true } -mars-swapper-base = { workspace = true } +astroport = { workspace = true } +cosmwasm-schema = { workspace = true } +cosmwasm-std = { workspace = true } +cw2 = { workspace = true } +mars-swapper-base = { workspace = true } +mars-types = { workspace = true } [dev-dependencies] -anyhow = { workspace = true } -cw-it = { workspace = true, features = ["astroport", "astroport-multi-test"] } -mars-oracle-wasm = { workspace = true } -mars-testing = { workspace = true, features = ["astroport"] } -test-case = { workspace = true } +anyhow = { workspace = true } +cw-it = { workspace = true, features = ["astroport", "astroport-multi-test"] } +mars-oracle-wasm = { workspace = true } +mars-testing = { workspace = true, features = ["astroport"] } +test-case = { workspace = true } diff --git a/contracts/swapper/base/Cargo.toml b/contracts/swapper/base/Cargo.toml index 05ac58d8e..e2819d6ae 100644 --- a/contracts/swapper/base/Cargo.toml +++ b/contracts/swapper/base/Cargo.toml @@ -19,13 +19,13 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-schema = { workspace = true } -cosmwasm-std = { workspace = true } -cw2 = { workspace = true } -cw-paginate = { workspace = true } -cw-storage-plus = { workspace = true } -mars-owner = { workspace = true } -mars-red-bank-types = { workspace = true } -schemars = { workspace = true } -serde = { workspace = true } -thiserror = { workspace = true } +cosmwasm-schema = { workspace = true } +cosmwasm-std = { workspace = true } +cw2 = { workspace = true } +cw-paginate = { workspace = true } +cw-storage-plus = { workspace = true } +mars-owner = { workspace = true } +mars-types = { workspace = true } +schemars = { workspace = true } +serde = { workspace = true } +thiserror = { workspace = true } diff --git a/contracts/swapper/mock/Cargo.toml b/contracts/swapper/mock/Cargo.toml index 317ac4cf4..d3503a9cc 100644 --- a/contracts/swapper/mock/Cargo.toml +++ b/contracts/swapper/mock/Cargo.toml @@ -20,8 +20,8 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-std = { workspace = true } -mars-red-bank-types = { workspace = true } +cosmwasm-std = { workspace = true } +mars-types = { workspace = true } [dev-dependencies] anyhow = { workspace = true } diff --git a/contracts/swapper/osmosis/Cargo.toml b/contracts/swapper/osmosis/Cargo.toml index b245e6db8..ec48cbe95 100644 --- a/contracts/swapper/osmosis/Cargo.toml +++ b/contracts/swapper/osmosis/Cargo.toml @@ -20,15 +20,15 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-schema = { workspace = true } -cosmwasm-std = { workspace = true } -cw2 = { workspace = true } -cw-storage-plus = { workspace = true } -mars-osmosis = { workspace = true } -mars-owner = { workspace = true } -mars-swapper-base = { workspace = true } -osmosis-std = { workspace = true } -mars-red-bank-types = { workspace = true } +cosmwasm-schema = { workspace = true } +cosmwasm-std = { workspace = true } +cw2 = { workspace = true } +cw-storage-plus = { workspace = true } +mars-osmosis = { workspace = true } +mars-owner = { workspace = true } +mars-swapper-base = { workspace = true } +mars-types = { workspace = true } +osmosis-std = { workspace = true } [dev-dependencies] anyhow = { workspace = true } diff --git a/contracts/v2-zapper/mock/Cargo.toml b/contracts/v2-zapper/mock/Cargo.toml index a57772faa..5cc829665 100644 --- a/contracts/v2-zapper/mock/Cargo.toml +++ b/contracts/v2-zapper/mock/Cargo.toml @@ -19,11 +19,10 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-schema = { workspace = true } -cosmwasm-std = { workspace = true } -cw-storage-plus = { workspace = true } -cw-utils = { workspace = true } -mars-red-bank-types = { workspace = true } -mars-rover = { workspace = true } -mars-zapper-base = { workspace = true } -thiserror = { workspace = true } +cosmwasm-schema = { workspace = true } +cosmwasm-std = { workspace = true } +cw-storage-plus = { workspace = true } +cw-utils = { workspace = true } +mars-types = { workspace = true } +mars-zapper-base = { workspace = true } +thiserror = { workspace = true } diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 575ffa45a..58332a01f 100755 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -28,10 +28,10 @@ mars-oracle-osmosis = { workspace = true } mars-osmosis = { workspace = true } mars-params = { workspace = true } mars-red-bank = { workspace = true } -mars-red-bank-types = { workspace = true } mars-rewards-collector-osmosis = { workspace = true } mars-swapper-osmosis = { workspace = true } mars-testing = { workspace = true } +mars-types = { workspace = true } mars-utils = { workspace = true } osmosis-std = { workspace = true } osmosis-test-tube = { workspace = true } diff --git a/packages/health-computer/Cargo.toml b/packages/health-computer/Cargo.toml index ebf7ede8e..ce1b2bce7 100644 --- a/packages/health-computer/Cargo.toml +++ b/packages/health-computer/Cargo.toml @@ -13,21 +13,18 @@ doctest = false [features] backtraces = ["cosmwasm-std/backtraces"] default = ["console_error_panic_hook"] -javascript = ["tsify", "wasm-bindgen", "mars-rover-health-types/javascript"] +javascript = ["tsify", "wasm-bindgen", "mars-types/javascript"] [dependencies] -cosmwasm-schema = { workspace = true } -cosmwasm-std = { workspace = true } -cw-vault-standard = { workspace = true } -mars-params = { workspace = true } -mars-red-bank-types = { workspace = true } -mars-rover = { workspace = true } -mars-rover-health-types = { workspace = true } -schemars = { workspace = true } -serde = { workspace = true } -serde_json = { workspace = true } -tsify = { workspace = true, optional = true } -wasm-bindgen = { workspace = true, optional = true } +cosmwasm-schema = { workspace = true } +cosmwasm-std = { workspace = true } +cw-vault-standard = { workspace = true } +mars-types = { workspace = true } +schemars = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +tsify = { workspace = true, optional = true } +wasm-bindgen = { workspace = true, optional = true } # The `console_error_panic_hook` crate provides better debugging of panics by # logging them with `console.error`. This is great for development, but requires diff --git a/packages/health/Cargo.toml b/packages/health/Cargo.toml index 4be4d5a53..cc7cf60fa 100644 --- a/packages/health/Cargo.toml +++ b/packages/health/Cargo.toml @@ -19,10 +19,10 @@ doctest = false backtraces = ["cosmwasm-std/backtraces"] [dependencies] -cosmwasm-std = { workspace = true } -mars-params = { workspace = true } -mars-red-bank-types = { workspace = true } -thiserror = { workspace = true } +cosmwasm-std = { workspace = true } +mars-params = { workspace = true } +mars-types = { workspace = true } +thiserror = { workspace = true } [dev-dependencies] mars-testing = { workspace = true } diff --git a/packages/interest-rate/Cargo.toml b/packages/interest-rate/Cargo.toml index 905f8f5d8..564ab8184 100644 --- a/packages/interest-rate/Cargo.toml +++ b/packages/interest-rate/Cargo.toml @@ -19,7 +19,7 @@ doctest = false backtraces = ["cosmwasm-std/backtraces"] [dependencies] -cosmwasm-schema = { workspace = true } -cosmwasm-std = { workspace = true } -mars-red-bank-types = { workspace = true } -mars-utils = { workspace = true } +cosmwasm-schema = { workspace = true } +cosmwasm-std = { workspace = true } +mars-utils = { workspace = true } +mars-types = { workspace = true } diff --git a/packages/liquidation/Cargo.toml b/packages/liquidation/Cargo.toml index 58b7fc234..925d07c6a 100644 --- a/packages/liquidation/Cargo.toml +++ b/packages/liquidation/Cargo.toml @@ -19,7 +19,7 @@ doctest = false backtraces = ["cosmwasm-std/backtraces"] [dependencies] -cosmwasm-std = { workspace = true } -mars-health = { workspace = true } -mars-red-bank-types = { workspace = true } -thiserror = { workspace = true } +cosmwasm-std = { workspace = true } +mars-health = { workspace = true } +mars-types = { workspace = true } +thiserror = { workspace = true } diff --git a/packages/testing/Cargo.toml b/packages/testing/Cargo.toml index 57e94f83b..355f458ee 100644 --- a/packages/testing/Cargo.toml +++ b/packages/testing/Cargo.toml @@ -35,9 +35,9 @@ mars-osmosis = { workspace = true } mars-owner = { workspace = true } mars-params = { workspace = true } mars-red-bank = { workspace = true } -mars-red-bank-types = { workspace = true } mars-rewards-collector-osmosis = { workspace = true } mars-swapper-astroport = { workspace = true } +mars-types = { workspace = true } prost = { workspace = true } pyth-sdk-cw = { workspace = true } diff --git a/packages/types/Cargo.toml b/packages/types/Cargo.toml index bd0aa368c..b0de016d6 100644 --- a/packages/types/Cargo.toml +++ b/packages/types/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "mars-red-bank-types" -description = "Messages and types for Red Bank smart contracts" +name = "mars-types" +description = "Messages and types for Mars smart contracts" version = { workspace = true } authors = { workspace = true } edition = { workspace = true } @@ -17,6 +17,7 @@ doctest = false # for quicker tests, cargo test --lib # for more explicit tests, cargo test --features=backtraces backtraces = ["cosmwasm-std/backtraces"] +javascript = ["tsify", "wasm-bindgen"] [dependencies] cosmwasm-schema = { workspace = true } @@ -28,3 +29,5 @@ serde = { workspace = true } serde-json-wasm = { workspace = true } strum = { workspace = true, features = ["derive"] } thiserror = { workspace = true } +tsify = { workspace = true, optional = true } +wasm-bindgen = { workspace = true, optional = true } From 061f906a1007d4df7e022b654328ef911959f74c Mon Sep 17 00:00:00 2001 From: larry <26318510+larry0x@users.noreply.github.com> Date: Thu, 12 Oct 2023 09:25:35 +0100 Subject: [PATCH 02/15] move contents of `mars-account-nft-types` into `mars_types::account_nft` --- Cargo.lock | 2 ++ packages/account-nft-types/Cargo.toml | 24 ------------------- packages/account-nft-types/src/lib.rs | 2 -- packages/account-nft-types/src/msg/mod.rs | 7 ------ packages/types/Cargo.toml | 2 ++ .../msg => types/src/account_nft}/execute.rs | 2 +- .../src/account_nft}/instantiate.rs | 0 packages/types/src/account_nft/mod.rs | 9 +++++++ .../src/account_nft}/nft_config.rs | 0 .../msg => types/src/account_nft}/query.rs | 2 +- packages/types/src/lib.rs | 1 + 11 files changed, 16 insertions(+), 35 deletions(-) delete mode 100644 packages/account-nft-types/Cargo.toml delete mode 100644 packages/account-nft-types/src/lib.rs delete mode 100644 packages/account-nft-types/src/msg/mod.rs rename packages/{account-nft-types/src/msg => types/src/account_nft}/execute.rs (99%) rename packages/{account-nft-types/src/msg => types/src/account_nft}/instantiate.rs (100%) create mode 100644 packages/types/src/account_nft/mod.rs rename packages/{account-nft-types/src => types/src/account_nft}/nft_config.rs (100%) rename packages/{account-nft-types/src/msg => types/src/account_nft}/query.rs (99%) diff --git a/Cargo.lock b/Cargo.lock index 9a57bea29..8ffed56d2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2663,6 +2663,8 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus 1.1.0", + "cw721 0.18.0", + "cw721-base 0.18.0", "mars-owner 2.0.0", "mars-utils 2.0.0", "serde", diff --git a/packages/account-nft-types/Cargo.toml b/packages/account-nft-types/Cargo.toml deleted file mode 100644 index 974281382..000000000 --- a/packages/account-nft-types/Cargo.toml +++ /dev/null @@ -1,24 +0,0 @@ -[package] -name = "mars-account-nft-types" -version = { workspace = true } -authors = { workspace = true } -license = { workspace = true } -edition = { workspace = true } -repository = { workspace = true } -homepage = { workspace = true } -documentation = { workspace = true } -keywords = { workspace = true } - -[lib] -doctest = false - -[features] -# for quicker tests, cargo test --lib -# for more explicit tests, cargo test --features=backtraces -backtraces = ["cosmwasm-std/backtraces"] - -[dependencies] -cosmwasm-schema = { workspace = true } -cosmwasm-std = { workspace = true } -cw721 = { workspace = true } -cw721-base = { workspace = true } diff --git a/packages/account-nft-types/src/lib.rs b/packages/account-nft-types/src/lib.rs deleted file mode 100644 index 2d7454db0..000000000 --- a/packages/account-nft-types/src/lib.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod msg; -pub mod nft_config; diff --git a/packages/account-nft-types/src/msg/mod.rs b/packages/account-nft-types/src/msg/mod.rs deleted file mode 100644 index dc5e4ca97..000000000 --- a/packages/account-nft-types/src/msg/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -mod execute; -mod instantiate; -mod query; - -pub use execute::{ExecuteMsg, MigrateV1ToV2}; -pub use instantiate::InstantiateMsg; -pub use query::QueryMsg; diff --git a/packages/types/Cargo.toml b/packages/types/Cargo.toml index b0de016d6..0d8bde971 100644 --- a/packages/types/Cargo.toml +++ b/packages/types/Cargo.toml @@ -22,6 +22,8 @@ javascript = ["tsify", "wasm-bindgen"] [dependencies] cosmwasm-schema = { workspace = true } cosmwasm-std = { workspace = true } +cw721 = { workspace = true } +cw721-base = { workspace = true } cw-storage-plus = { workspace = true } mars-owner = { workspace = true } mars-utils = { workspace = true } diff --git a/packages/account-nft-types/src/msg/execute.rs b/packages/types/src/account_nft/execute.rs similarity index 99% rename from packages/account-nft-types/src/msg/execute.rs rename to packages/types/src/account_nft/execute.rs index eba222047..e1d27cf12 100644 --- a/packages/account-nft-types/src/msg/execute.rs +++ b/packages/types/src/account_nft/execute.rs @@ -5,7 +5,7 @@ use cosmwasm_std::{Binary, Empty, StdError}; use cw721::Expiration; use cw721_base::{Action, ExecuteMsg as ParentExecuteMsg}; -use crate::nft_config::NftConfigUpdates; +use super::NftConfigUpdates; #[cw_serde] pub enum ExecuteMsg { diff --git a/packages/account-nft-types/src/msg/instantiate.rs b/packages/types/src/account_nft/instantiate.rs similarity index 100% rename from packages/account-nft-types/src/msg/instantiate.rs rename to packages/types/src/account_nft/instantiate.rs diff --git a/packages/types/src/account_nft/mod.rs b/packages/types/src/account_nft/mod.rs new file mode 100644 index 000000000..396c2b29e --- /dev/null +++ b/packages/types/src/account_nft/mod.rs @@ -0,0 +1,9 @@ +mod execute; +mod instantiate; +mod nft_config; +mod query; + +pub use execute::*; +pub use instantiate::*; +pub use nft_config::*; +pub use query::*; diff --git a/packages/account-nft-types/src/nft_config.rs b/packages/types/src/account_nft/nft_config.rs similarity index 100% rename from packages/account-nft-types/src/nft_config.rs rename to packages/types/src/account_nft/nft_config.rs diff --git a/packages/account-nft-types/src/msg/query.rs b/packages/types/src/account_nft/query.rs similarity index 99% rename from packages/account-nft-types/src/msg/query.rs rename to packages/types/src/account_nft/query.rs index 9e8e7691b..c0e023f79 100644 --- a/packages/account-nft-types/src/msg/query.rs +++ b/packages/types/src/account_nft/query.rs @@ -10,7 +10,7 @@ pub enum QueryMsg { //-------------------------------------------------------------------------------------------------- // Extended messages //-------------------------------------------------------------------------------------------------- - #[returns(crate::nft_config::UncheckedNftConfig)] + #[returns(super::UncheckedNftConfig)] Config {}, #[returns(String)] diff --git a/packages/types/src/lib.rs b/packages/types/src/lib.rs index c5c411a3a..fa4bcd32c 100644 --- a/packages/types/src/lib.rs +++ b/packages/types/src/lib.rs @@ -1,3 +1,4 @@ +pub mod account_nft; pub mod address_provider; pub mod error; pub mod incentives; From 831f8dbcce649735d142c774e17b62baa90aee69 Mon Sep 17 00:00:00 2001 From: larry <26318510+larry0x@users.noreply.github.com> Date: Thu, 12 Oct 2023 09:28:46 +0100 Subject: [PATCH 03/15] move contents of `mars-rover-health-types` into `mars_types::health` --- packages/health-types/Cargo.toml | 31 ------------------- packages/health-types/examples/schema.rs | 10 ------ packages/health/src/health.rs | 14 +++++++++ .../src => types/src/health}/account.rs | 0 .../src => types/src/health}/error.rs | 0 .../src => types/src/health}/health.rs | 14 --------- .../src/lib.rs => types/src/health/mod.rs} | 0 .../src => types/src/health}/msg.rs | 8 ++--- packages/types/src/lib.rs | 1 + 9 files changed, 19 insertions(+), 59 deletions(-) delete mode 100644 packages/health-types/Cargo.toml delete mode 100644 packages/health-types/examples/schema.rs rename packages/{health-types/src => types/src/health}/account.rs (100%) rename packages/{health-types/src => types/src/health}/error.rs (100%) rename packages/{health-types/src => types/src/health}/health.rs (86%) rename packages/{health-types/src/lib.rs => types/src/health/mod.rs} (100%) rename packages/{health-types/src => types/src/health}/msg.rs (89%) diff --git a/packages/health-types/Cargo.toml b/packages/health-types/Cargo.toml deleted file mode 100644 index faeed237b..000000000 --- a/packages/health-types/Cargo.toml +++ /dev/null @@ -1,31 +0,0 @@ -[package] -name = "mars-rover-health-types" -version = { workspace = true } -authors = { workspace = true } -license = { workspace = true } -edition = { workspace = true } -repository = { workspace = true } -homepage = { workspace = true } -documentation = { workspace = true } -keywords = { workspace = true } - -[lib] -crate-type = ["cdylib", "rlib"] -doctest = false - -[features] -backtraces = ["cosmwasm-std/backtraces"] -javascript = ["tsify", "wasm-bindgen"] - -[dependencies] -cosmwasm-schema = { workspace = true } -cosmwasm-std = { workspace = true } -mars-health = { workspace = true } -mars-red-bank-types = { workspace = true } -mars-owner = { workspace = true } -schemars = { workspace = true } -serde = { workspace = true } -serde_json = { workspace = true } -thiserror = { workspace = true } -tsify = { workspace = true, optional = true } -wasm-bindgen = { workspace = true, optional = true } diff --git a/packages/health-types/examples/schema.rs b/packages/health-types/examples/schema.rs deleted file mode 100644 index 440f56bd9..000000000 --- a/packages/health-types/examples/schema.rs +++ /dev/null @@ -1,10 +0,0 @@ -use cosmwasm_schema::write_api; -use mars_rover_health_types::{ExecuteMsg, InstantiateMsg, QueryMsg}; - -fn main() { - write_api! { - instantiate: InstantiateMsg, - query: QueryMsg, - execute: ExecuteMsg, - } -} diff --git a/packages/health/src/health.rs b/packages/health/src/health.rs index b0dcedac3..f5bda1a45 100644 --- a/packages/health/src/health.rs +++ b/packages/health/src/health.rs @@ -2,6 +2,7 @@ use std::{collections::HashMap, fmt}; use cosmwasm_std::{Addr, Coin, Decimal, Fraction, QuerierWrapper, StdResult, Uint128}; use mars_red_bank_types::params::AssetParams; +use mars_types::health::HealthValuesResponse; use crate::{error::HealthError, query::MarsQuerier}; @@ -46,6 +47,19 @@ impl fmt::Display for Health { } } +impl From for RedBankHealth { + fn from(h: HealthValuesResponse) -> Self { + Self { + total_debt_value: h.total_debt_value, + total_collateral_value: h.total_collateral_value, + max_ltv_adjusted_collateral: h.max_ltv_adjusted_collateral, + liquidation_threshold_adjusted_collateral: h.liquidation_threshold_adjusted_collateral, + max_ltv_health_factor: h.max_ltv_health_factor, + liquidation_health_factor: h.liquidation_health_factor, + } + } +} + impl Health { /// Compute the health from coins (collateral and debt) pub fn compute_health_from_coins( diff --git a/packages/health-types/src/account.rs b/packages/types/src/health/account.rs similarity index 100% rename from packages/health-types/src/account.rs rename to packages/types/src/health/account.rs diff --git a/packages/health-types/src/error.rs b/packages/types/src/health/error.rs similarity index 100% rename from packages/health-types/src/error.rs rename to packages/types/src/health/error.rs diff --git a/packages/health-types/src/health.rs b/packages/types/src/health/health.rs similarity index 86% rename from packages/health-types/src/health.rs rename to packages/types/src/health/health.rs index ef6781322..b59d83b16 100644 --- a/packages/health-types/src/health.rs +++ b/packages/types/src/health/health.rs @@ -2,7 +2,6 @@ use std::fmt; use cosmwasm_schema::cw_serde; use cosmwasm_std::{Decimal, Uint128}; -use mars_health::health::Health as RedBankHealth; #[cfg(feature = "javascript")] use tsify::Tsify; @@ -82,19 +81,6 @@ impl From for HealthValuesResponse { } } -impl From for RedBankHealth { - fn from(h: HealthValuesResponse) -> Self { - Self { - total_debt_value: h.total_debt_value, - total_collateral_value: h.total_collateral_value, - max_ltv_adjusted_collateral: h.max_ltv_adjusted_collateral, - liquidation_threshold_adjusted_collateral: h.liquidation_threshold_adjusted_collateral, - max_ltv_health_factor: h.max_ltv_health_factor, - liquidation_health_factor: h.liquidation_health_factor, - } - } -} - #[cw_serde] pub enum HealthState { Healthy, diff --git a/packages/health-types/src/lib.rs b/packages/types/src/health/mod.rs similarity index 100% rename from packages/health-types/src/lib.rs rename to packages/types/src/health/mod.rs diff --git a/packages/health-types/src/msg.rs b/packages/types/src/health/msg.rs similarity index 89% rename from packages/health-types/src/msg.rs rename to packages/types/src/health/msg.rs index 948bbe894..817e1c427 100644 --- a/packages/health-types/src/msg.rs +++ b/packages/types/src/health/msg.rs @@ -1,8 +1,8 @@ use cosmwasm_schema::{cw_serde, QueryResponses}; use mars_owner::{OwnerResponse, OwnerUpdate}; -use mars_red_bank_types::oracle::ActionKind; -use crate::AccountKind; +use super::AccountKind; +use crate::oracle::ActionKind; #[cw_serde] pub struct InstantiateMsg { @@ -27,7 +27,7 @@ pub enum ExecuteMsg { #[derive(QueryResponses)] pub enum QueryMsg { /// Returns all values that comprise health for account - #[returns(crate::HealthValuesResponse)] + #[returns(super::HealthValuesResponse)] HealthValues { account_id: String, kind: AccountKind, @@ -35,7 +35,7 @@ pub enum QueryMsg { }, /// Returns Healthy or Unhealthy state. Does not do health calculations if no debt. /// This is helpful in the cases like liquidation where we should not query the oracle if can help it. - #[returns(crate::HealthState)] + #[returns(super::HealthState)] HealthState { account_id: String, kind: AccountKind, diff --git a/packages/types/src/lib.rs b/packages/types/src/lib.rs index fa4bcd32c..77530a073 100644 --- a/packages/types/src/lib.rs +++ b/packages/types/src/lib.rs @@ -1,6 +1,7 @@ pub mod account_nft; pub mod address_provider; pub mod error; +pub mod health; pub mod incentives; pub mod keys; pub mod oracle; From 9647a90a7625fd79f11bbc66b2b6a1b2c3343e94 Mon Sep 17 00:00:00 2001 From: larry <26318510+larry0x@users.noreply.github.com> Date: Thu, 12 Oct 2023 09:47:11 +0100 Subject: [PATCH 04/15] move contents of `mars-rover` into `mars_types::{adapter, credit_manager}` --- Cargo.lock | 3 + .../credit-manager}/src/error.rs | 6 - packages/rover/Cargo.toml | 38 --- packages/rover/src/coins.rs | 296 ------------------ packages/rover/src/extensions/mod.rs | 3 - packages/rover/src/lib.rs | 7 - packages/rover/src/msg/mod.rs | 9 - packages/rover/src/reentrancy_guard.rs | 73 ----- packages/types/Cargo.toml | 29 +- .../src/adapters/account_nft.rs | 3 +- .../{rover => types}/src/adapters/health.rs | 7 +- .../src/adapters/incentives.rs | 5 +- packages/{rover => types}/src/adapters/mod.rs | 0 .../{rover => types}/src/adapters/oracle.rs | 22 +- .../{rover => types}/src/adapters/params.rs | 3 +- .../{rover => types}/src/adapters/red_bank.rs | 3 +- .../src/adapters/rewards_collector.rs | 0 .../{rover => types}/src/adapters/swap/mod.rs | 0 .../src/adapters/swap/msgs.rs | 0 .../src/adapters/swap/swapper.rs | 0 .../src/adapters/vault/amount.rs | 46 +-- .../src/adapters/vault/base.rs | 0 .../src/adapters/vault/mod.rs | 0 .../src/adapters/vault/position.rs | 10 +- .../src/adapters/vault/update.rs | 0 .../{rover => types}/src/adapters/zapper.rs | 0 .../src/credit_manager}/execute.rs | 6 +- .../src/credit_manager}/instantiate.rs | 0 .../src/credit_manager}/migrate.rs | 0 packages/types/src/credit_manager/mod.rs | 11 + .../msg => types/src/credit_manager}/query.rs | 5 +- .../src/credit_manager}/reply.rs | 0 packages/types/src/lib.rs | 3 + packages/types/src/rewards_collector.rs | 38 +-- packages/{rover => types}/src/traits.rs | 20 ++ 35 files changed, 124 insertions(+), 522 deletions(-) rename {packages/rover => contracts/credit-manager}/src/error.rs (95%) delete mode 100644 packages/rover/Cargo.toml delete mode 100644 packages/rover/src/coins.rs delete mode 100644 packages/rover/src/extensions/mod.rs delete mode 100644 packages/rover/src/lib.rs delete mode 100644 packages/rover/src/msg/mod.rs delete mode 100644 packages/rover/src/reentrancy_guard.rs rename packages/{rover => types}/src/adapters/account_nft.rs (96%) rename packages/{rover => types}/src/adapters/health.rs (92%) rename packages/{rover => types}/src/adapters/incentives.rs (93%) rename packages/{rover => types}/src/adapters/mod.rs (100%) rename packages/{rover => types}/src/adapters/oracle.rs (75%) rename packages/{rover => types}/src/adapters/params.rs (95%) rename packages/{rover => types}/src/adapters/red_bank.rs (99%) rename packages/{rover => types}/src/adapters/rewards_collector.rs (100%) rename packages/{rover => types}/src/adapters/swap/mod.rs (100%) rename packages/{rover => types}/src/adapters/swap/msgs.rs (100%) rename packages/{rover => types}/src/adapters/swap/swapper.rs (100%) rename packages/{rover => types}/src/adapters/vault/amount.rs (73%) rename packages/{rover => types}/src/adapters/vault/base.rs (100%) rename packages/{rover => types}/src/adapters/vault/mod.rs (100%) rename packages/{rover => types}/src/adapters/vault/position.rs (96%) rename packages/{rover => types}/src/adapters/vault/update.rs (100%) rename packages/{rover => types}/src/adapters/zapper.rs (100%) rename packages/{rover/src/msg => types/src/credit_manager}/execute.rs (98%) rename packages/{rover/src/msg => types/src/credit_manager}/instantiate.rs (100%) rename packages/{rover/src/msg => types/src/credit_manager}/migrate.rs (100%) create mode 100644 packages/types/src/credit_manager/mod.rs rename packages/{rover/src/msg => types/src/credit_manager}/query.rs (97%) rename packages/{rover/src/extensions => types/src/credit_manager}/reply.rs (100%) rename packages/{rover => types}/src/traits.rs (58%) diff --git a/Cargo.lock b/Cargo.lock index 8ffed56d2..eb8c929b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2663,10 +2663,13 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus 1.1.0", + "cw-utils 1.0.2", + "cw-vault-standard 0.3.3", "cw721 0.18.0", "cw721-base 0.18.0", "mars-owner 2.0.0", "mars-utils 2.0.0", + "mars-zapper-base", "serde", "serde-json-wasm 1.0.0", "strum 0.25.0", diff --git a/packages/rover/src/error.rs b/contracts/credit-manager/src/error.rs similarity index 95% rename from packages/rover/src/error.rs rename to contracts/credit-manager/src/error.rs index 671c9aa04..67223a2be 100644 --- a/packages/rover/src/error.rs +++ b/contracts/credit-manager/src/error.rs @@ -101,9 +101,6 @@ pub enum ContractError { request_coin: Coin, }, - #[error("Issued incorrect action for vault type")] - MismatchedVaultType, - #[error("No coin amount set for action")] NoAmount, @@ -113,9 +110,6 @@ pub enum ContractError { #[error("Nothing lent to reclaim")] NoneLent, - #[error("Position {0} was not a valid position for this account id in this vault")] - NoPositionMatch(String), - #[error( "{account_id:?} is not a liquidatable credit account. Health factor: {lqdt_health_factor:?}." )] diff --git a/packages/rover/Cargo.toml b/packages/rover/Cargo.toml deleted file mode 100644 index ec1fa251b..000000000 --- a/packages/rover/Cargo.toml +++ /dev/null @@ -1,38 +0,0 @@ -[package] -name = "mars-rover" -version = { workspace = true } -authors = { workspace = true } -license = { workspace = true } -edition = { workspace = true } -repository = { workspace = true } -homepage = { workspace = true } -documentation = { workspace = true } -keywords = { workspace = true } - -[lib] -doctest = false - -[features] -# for quicker tests, cargo test --lib -# for more explicit tests, cargo test --features=backtraces -backtraces = ["cosmwasm-std/backtraces"] - -[dependencies] -cosmwasm-schema = { workspace = true } -cosmwasm-std = { workspace = true } -cw2 = { workspace = true } -cw721 = { workspace = true } -cw721-base = { workspace = true } -cw-storage-plus = { workspace = true } -cw-utils = { workspace = true } -cw-vault-standard = { workspace = true } -mars-account-nft-types = { workspace = true } -mars-liquidation = { workspace = true } -mars-rover-health-types = { workspace = true } -mars-red-bank-types = { workspace = true } -mars-zapper-base = { workspace = true } -mars-owner = { workspace = true } -mars-params = { workspace = true } -schemars = { workspace = true } -serde = { workspace = true } -thiserror = { workspace = true } diff --git a/packages/rover/src/coins.rs b/packages/rover/src/coins.rs deleted file mode 100644 index b3b8dbe79..000000000 --- a/packages/rover/src/coins.rs +++ /dev/null @@ -1,296 +0,0 @@ -use std::{ - any::type_name, - collections::{BTreeMap, HashSet}, - fmt, - str::FromStr, -}; - -use cosmwasm_std::{Coin, StdError, StdResult, Uint128}; -use schemars::JsonSchema; -use serde::{de, Serialize}; - -use crate::{ - msg::execute::ActionCoin, - traits::{Denoms, Stringify}, -}; - -/// A collection of coins, similar to Cosmos SDK's `sdk.Coins` struct. -/// -/// Differently from `sdk.Coins`, which is a vector of `sdk.Coin`, here we implement Coins as a BTreeMap -/// that maps from coin denoms to amounts. This has a number of advantages: -/// -/// * coins are naturally sorted alphabetically by denom -/// * duplicate denoms are automatically removed -/// * cheaper for searching/inserting/deleting: O(log(n)) compared to O(n) -/// * compared to `Vec`, the map data structure stringifies to a compact JSON representation, -/// therefore is cheaper when writing to contract storage -/// -/// ## On the string representation of coins -/// -/// Two approaches are implemented for stringifing Coins: the JSON representation, and the plain text -/// representation. -/// -/// **The JSON representation** comes in the format below. This is used for contract storage or message -/// passing between contracts: -/// -/// ```json -/// {"uatom":"12345","umars":"42069","uosmo":"88888"} -/// ``` -/// -/// Use the `serde_json` library to convert Coins to/from JSON strings: -/// -/// ```rust -/// use cw_coins::Coins; -/// -/// let coins: Coins = serde_json::from_str(r#"{"uatom":"12345","uosmo":"42069"}"#).unwrap(); -/// let json = serde_json::to_string(&coins).unwrap(); -/// ``` -/// -/// The plain text representation is the same format as the `sdk.Coins.String` method uses. It is used -/// in event logging: -/// -/// ```plain -/// 12345uatom,42069umars,88888uosmo -/// ``` -/// -/// Use `{from,to}_string` methods to convert Coin to/from plain strings: -/// -/// ```rust -/// use std::str::FromStr; -/// use cw_coins::Coins; -/// -/// let coins = Coins::from_str("12345uatom,42069umars,88888uosmo").unwrap(); -/// let plain = coins.to_string(); -/// ``` -#[derive(Serialize, Clone, Default, Debug, PartialEq, Eq, JsonSchema)] -pub struct Coins(BTreeMap); - -// We implement a custom serde::de::Deserialize trait to handle the case where the JSON string contains -// duplicate keys, i.e. duplicate coin denoms. -// -// If we derive the trait, by default, it will not throw an error in such a case. Instead, it takes -// the amount that is seen the last. E.g. the following JSON string -// -// ```json -// { -// "uatom": "12345", -// "uatom", "23456", -// "uatom": "67890" -// } -// ``` -// -// will be deserialized into a Coins object with only one element, with denom `uatom` and amount 67890. -// The amount 67890 is seen the last and overwrites the two amounts seen earlier. -// -// This is NOT a desirable property. We want an error to be thown if the JSON string contain dups. -impl<'de> de::Deserialize<'de> for Coins { - fn deserialize(deserializer: D) -> Result - where - D: de::Deserializer<'de>, - { - struct Visitor; - - impl<'de> de::Visitor<'de> for Visitor { - type Value = Coins; - - fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.write_str("a map with non-duplicating string keys and stringified 128-bit unsigned integer values") - } - - #[inline] - fn visit_map(self, mut access: M) -> Result - where - M: de::MapAccess<'de>, - { - let mut seen_denoms = HashSet::::new(); - let mut coins = BTreeMap::::new(); - - while let Some((denom, amount_str)) = access.next_entry::()? { - if seen_denoms.contains(&denom) { - return Err(de::Error::custom(format!( - "failed to parse into Coins! duplicate denom: {denom}" - ))); - } - - let amount = Uint128::from_str(&amount_str).map_err(|_| { - de::Error::custom(format!( - "failed to parse into Coins! invalid amount: {amount_str}" - )) - })?; - - if amount.is_zero() { - return Err(de::Error::custom(format!("amount for denom {denom} is zero"))); - } - - seen_denoms.insert(denom.clone()); - coins.insert(denom, amount); - } - - Ok(Coins(coins)) - } - } - - deserializer.deserialize_map(Visitor) - } -} - -impl TryFrom> for Coins { - type Error = StdError; - - fn try_from(vec: Vec) -> StdResult { - let vec_len = vec.len(); - let map = vec - .into_iter() - .filter(|coin| !coin.amount.is_zero()) - .map(|coin| (coin.denom, coin.amount)) - .collect::>(); - - // the map having a different length from the vec means the vec must either 1) contain - // duplicate denoms, or 2) contain zero amounts - if map.len() != vec_len { - return Err(StdError::parse_err( - type_name::(), - "duplicate denoms or zero amount", - )); - } - - Ok(Self(map)) - } -} - -impl TryFrom<&[Coin]> for Coins { - type Error = StdError; - - fn try_from(slice: &[Coin]) -> StdResult { - slice.to_vec().try_into() - } -} - -impl FromStr for Coins { - type Err = StdError; - - fn from_str(s: &str) -> StdResult { - // `cosmwasm_std::Coin` does not implement `FromStr`, so we have do it ourselves - // - // Parsing the string with regex doesn't work, because the resulting wasm binary would be - // too big from including the `regex` library. - // - // If the binary size is not a concern, here's an example: - // https://github.com/PFC-Validator/terra-rust/blob/v1.1.8/terra-rust-api/src/client/core_types.rs#L34-L55 - // - // We opt for the following solution: enumerate characters in the string, and break before - // the first non-number character. Split the string at that index. - // - // This assumes the denom never starts with a number, which is the case: - // https://github.com/cosmos/cosmos-sdk/blob/v0.46.0/types/coin.go#L854-L856 - let parse_coin_str = |s: &str| -> StdResult { - for (i, c) in s.chars().enumerate() { - if c.is_alphabetic() { - let amount = Uint128::from_str(&s[..i])?; - let denom = String::from(&s[i..]); - return Ok(Coin { - amount, - denom, - }); - } - } - - Err(StdError::parse_err(type_name::(), format!("invalid coin string: {s}"))) - }; - - s.split(',').map(parse_coin_str).collect::>>()?.try_into() - } -} - -impl fmt::Display for Coins { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - // NOTE: The `iter` method for BTreeMap returns an Iterator where entries are already sorted - // by key, so we don't need to sort the coins manually - let s = self - .0 - .iter() - .map(|(denom, amount)| format!("{amount}{denom}")) - .collect::>() - .join(","); - write!(f, "{s}") - } -} - -impl Coins { - /// Cast to Vec, while NOT consuming the original object - pub fn to_vec(&self) -> Vec { - self.0 - .iter() - .map(|(denom, amount)| Coin { - denom: denom.clone(), - amount: *amount, - }) - .collect() - } - - /// Cast to Vec, consuming the original object - pub fn into_vec(self) -> Vec { - self.0 - .into_iter() - .map(|(denom, amount)| Coin { - denom, - amount, - }) - .collect() - } - - pub fn len(&self) -> usize { - self.0.len() - } - - pub fn is_empty(&self) -> bool { - self.0.is_empty() - } - - pub fn denoms(&self) -> Vec { - self.0.keys().cloned().collect() - } - - pub fn amount(&self, denom: &str) -> Option { - self.0.get(denom).map(Clone::clone) - } - - /// NOTE: the syntax can be simpler if Uint128 has an inplace add method... - pub fn add(&mut self, coin: &Coin) -> StdResult<()> { - let amount = self.0.entry(coin.denom.clone()).or_insert_with(Uint128::zero); - *amount = amount.checked_add(coin.amount)?; - Ok(()) - } - - pub fn deduct(&mut self, to_deduct: &Coin) -> StdResult<()> { - if let Some(amount) = self.amount(&to_deduct.denom) { - let new_amount = amount.checked_sub(to_deduct.amount)?; - if new_amount.is_zero() { - self.0.remove(&to_deduct.denom); - } else { - self.0.insert(to_deduct.denom.clone(), new_amount); - } - Ok(()) - } else { - Err(StdError::generic_err(format!("not found in coin list: {}", to_deduct.denom))) - } - } -} - -impl Stringify for &[Coin] { - fn to_string(&self) -> String { - self.iter().map(|coin| coin.to_string()).collect::>().join(",") - } -} - -impl Denoms for Vec { - fn to_denoms(&self) -> Vec<&str> { - self.iter().map(|c| c.denom.as_str()).collect() - } -} - -impl Denoms for Vec { - fn to_denoms(&self) -> Vec<&str> { - self.iter().map(|c| c.denom.as_str()).collect() - } -} diff --git a/packages/rover/src/extensions/mod.rs b/packages/rover/src/extensions/mod.rs deleted file mode 100644 index 0cbe190b2..000000000 --- a/packages/rover/src/extensions/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub use self::reply::*; - -mod reply; diff --git a/packages/rover/src/lib.rs b/packages/rover/src/lib.rs deleted file mode 100644 index 57ac84984..000000000 --- a/packages/rover/src/lib.rs +++ /dev/null @@ -1,7 +0,0 @@ -pub mod adapters; -pub mod coins; -pub mod error; -pub mod extensions; -pub mod msg; -pub mod reentrancy_guard; -pub mod traits; diff --git a/packages/rover/src/msg/mod.rs b/packages/rover/src/msg/mod.rs deleted file mode 100644 index 2be94301f..000000000 --- a/packages/rover/src/msg/mod.rs +++ /dev/null @@ -1,9 +0,0 @@ -pub mod execute; -pub mod instantiate; -pub mod migrate; -pub mod query; - -pub use execute::ExecuteMsg; -pub use instantiate::InstantiateMsg; -pub use migrate::MigrateMsg; -pub use query::QueryMsg; diff --git a/packages/rover/src/reentrancy_guard.rs b/packages/rover/src/reentrancy_guard.rs deleted file mode 100644 index c5cc01dd7..000000000 --- a/packages/rover/src/reentrancy_guard.rs +++ /dev/null @@ -1,73 +0,0 @@ -use std::fmt::Debug; - -use cosmwasm_schema::{cw_serde, schemars::JsonSchema}; -use cosmwasm_std::{Response, StdResult, Storage}; -use cw_storage_plus::Item; - -use crate::error::{ContractError, ContractResult}; - -#[cw_serde] -pub enum GuardState { - Unlocked, - Locked, -} - -/// Contracts we call from Credit Manager should not be attempting to execute actions. -/// This prevents reentrancy attacks where a contract we call (that turned evil) deposits -/// into their own credit account and trick our state updates like update_coin_balances.rs which -/// rely on pre-post querying of bank balances of Rover. -/// NOTE: https://twitter.com/larry0x/status/1595919149381079041 -pub struct ReentrancyGuard<'a>(Item<'a, GuardState>); - -impl<'a> ReentrancyGuard<'a> { - pub const fn new(namespace: &'a str) -> Self { - Self(Item::new(namespace)) - } - - /// Ensures the guard is unlocked and sets lock - pub fn try_lock(&self, storage: &mut dyn Storage) -> ContractResult<()> { - self.assert_unlocked(storage)?; - self.transition_state(storage, GuardState::Locked)?; - Ok(()) - } - - /// Sets guard to unlocked and returns response to be used for callback - pub fn try_unlock(&self, storage: &mut dyn Storage) -> ContractResult> - where - C: Clone + Debug + PartialEq + JsonSchema, - { - self.transition_state(storage, GuardState::Unlocked)?; - Ok(Response::new().add_attribute("action", "remove_reentrancy_guard")) - } - - fn assert_unlocked(&self, storage: &dyn Storage) -> ContractResult<()> { - match self.state(storage)? { - GuardState::Locked => { - Err(ContractError::ReentrancyGuard("Reentrancy guard is active".to_string())) - } - GuardState::Unlocked => Ok(()), - } - } - - fn state(&self, storage: &dyn Storage) -> StdResult { - Ok(self.0.may_load(storage)?.unwrap_or(GuardState::Unlocked)) - } - - fn transition_state( - &self, - storage: &mut dyn Storage, - new_state: GuardState, - ) -> ContractResult<()> { - let current_state = self.state(storage)?; - - let new_state = match (current_state, new_state) { - (GuardState::Locked, GuardState::Unlocked) => Ok(GuardState::Unlocked), - (GuardState::Unlocked, GuardState::Locked) => Ok(GuardState::Locked), - _ => Err(ContractError::ReentrancyGuard( - "Invalid reentrancy guard state transition".to_string(), - )), - }?; - - Ok(self.0.save(storage, &new_state)?) - } -} diff --git a/packages/types/Cargo.toml b/packages/types/Cargo.toml index 0d8bde971..5c7b558cf 100644 --- a/packages/types/Cargo.toml +++ b/packages/types/Cargo.toml @@ -20,16 +20,19 @@ backtraces = ["cosmwasm-std/backtraces"] javascript = ["tsify", "wasm-bindgen"] [dependencies] -cosmwasm-schema = { workspace = true } -cosmwasm-std = { workspace = true } -cw721 = { workspace = true } -cw721-base = { workspace = true } -cw-storage-plus = { workspace = true } -mars-owner = { workspace = true } -mars-utils = { workspace = true } -serde = { workspace = true } -serde-json-wasm = { workspace = true } -strum = { workspace = true, features = ["derive"] } -thiserror = { workspace = true } -tsify = { workspace = true, optional = true } -wasm-bindgen = { workspace = true, optional = true } +cosmwasm-schema = { workspace = true } +cosmwasm-std = { workspace = true } +cw721 = { workspace = true } +cw721-base = { workspace = true } +cw-storage-plus = { workspace = true } +cw-utils = { workspace = true } +cw-vault-standard = { workspace = true } +mars-owner = { workspace = true } +mars-utils = { workspace = true } +mars-zapper-base = { workspace = true } +serde = { workspace = true } +serde-json-wasm = { workspace = true } +strum = { workspace = true, features = ["derive"] } +thiserror = { workspace = true } +tsify = { workspace = true, optional = true } +wasm-bindgen = { workspace = true, optional = true } diff --git a/packages/rover/src/adapters/account_nft.rs b/packages/types/src/adapters/account_nft.rs similarity index 96% rename from packages/rover/src/adapters/account_nft.rs rename to packages/types/src/adapters/account_nft.rs index e54f33798..0b1d36b3c 100644 --- a/packages/rover/src/adapters/account_nft.rs +++ b/packages/types/src/adapters/account_nft.rs @@ -1,7 +1,8 @@ use cosmwasm_schema::cw_serde; use cosmwasm_std::{Addr, Api, QuerierWrapper, StdResult}; use cw721::TokensResponse; -use mars_account_nft_types::msg::QueryMsg; + +use crate::account_nft::QueryMsg; #[cw_serde] pub struct AccountNftBase(T); diff --git a/packages/rover/src/adapters/health.rs b/packages/types/src/adapters/health.rs similarity index 92% rename from packages/rover/src/adapters/health.rs rename to packages/types/src/adapters/health.rs index 305564f30..172df46f9 100644 --- a/packages/rover/src/adapters/health.rs +++ b/packages/types/src/adapters/health.rs @@ -1,7 +1,10 @@ use cosmwasm_schema::cw_serde; use cosmwasm_std::{Addr, Api, QuerierWrapper, StdResult}; -use mars_red_bank_types::oracle::ActionKind; -use mars_rover_health_types::{AccountKind, HealthState, HealthValuesResponse, QueryMsg}; + +use crate::{ + health::{AccountKind, HealthState, HealthValuesResponse, QueryMsg}, + oracle::ActionKind, +}; #[cw_serde] pub struct HealthContractBase(T); diff --git a/packages/rover/src/adapters/incentives.rs b/packages/types/src/adapters/incentives.rs similarity index 93% rename from packages/rover/src/adapters/incentives.rs rename to packages/types/src/adapters/incentives.rs index c79330c11..e3167128e 100644 --- a/packages/rover/src/adapters/incentives.rs +++ b/packages/types/src/adapters/incentives.rs @@ -1,6 +1,7 @@ use cosmwasm_schema::cw_serde; use cosmwasm_std::{to_binary, Addr, Api, Coin, CosmosMsg, QuerierWrapper, StdResult, WasmMsg}; -use mars_red_bank_types::{incentives, incentives::QueryMsg}; + +use crate::incentives::{ExecuteMsg, QueryMsg}; #[cw_serde] pub struct IncentivesUnchecked(String); @@ -43,7 +44,7 @@ impl Incentives { pub fn claim_rewards_msg(&self, account_id: &str) -> StdResult { Ok(CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: self.addr.to_string(), - msg: to_binary(&incentives::ExecuteMsg::ClaimRewards { + msg: to_binary(&ExecuteMsg::ClaimRewards { account_id: Some(account_id.to_string()), start_after_collateral_denom: None, start_after_incentive_denom: None, diff --git a/packages/rover/src/adapters/mod.rs b/packages/types/src/adapters/mod.rs similarity index 100% rename from packages/rover/src/adapters/mod.rs rename to packages/types/src/adapters/mod.rs diff --git a/packages/rover/src/adapters/oracle.rs b/packages/types/src/adapters/oracle.rs similarity index 75% rename from packages/rover/src/adapters/oracle.rs rename to packages/types/src/adapters/oracle.rs index 795db0bac..14de9d9a8 100644 --- a/packages/rover/src/adapters/oracle.rs +++ b/packages/types/src/adapters/oracle.rs @@ -1,8 +1,9 @@ use cosmwasm_schema::cw_serde; -use cosmwasm_std::{Addr, Api, Coin, QuerierWrapper, StdResult, Uint128}; -use mars_red_bank_types::oracle::{ActionKind, PriceResponse, QueryMsg}; +use cosmwasm_std::{ + Addr, Api, CheckedMultiplyFractionError, Coin, QuerierWrapper, StdError, StdResult, Uint128, +}; -use crate::error::ContractResult; +use crate::oracle::{ActionKind, PriceResponse, QueryMsg}; #[cw_serde] pub struct OracleBase(T); @@ -53,7 +54,7 @@ impl Oracle { querier: &QuerierWrapper, coin: &Coin, action: ActionKind, - ) -> ContractResult { + ) -> Result { self.query_total_value(querier, &[coin.clone()], action) } @@ -62,15 +63,24 @@ impl Oracle { querier: &QuerierWrapper, coins: &[Coin], action: ActionKind, - ) -> ContractResult { + ) -> Result { Ok(coins .iter() .map(|coin| { let res = self.query_price(querier, &coin.denom, action.clone())?; Ok(coin.amount.checked_mul_floor(res.price)?) }) - .collect::>>()? + .collect::, OracleError>>()? .iter() .sum()) } } + +#[derive(Debug, PartialEq, thiserror::Error)] +pub enum OracleError { + #[error(transparent)] + Std(#[from] StdError), + + #[error(transparent)] + CheckedMultiplyFraction(#[from] CheckedMultiplyFractionError), +} diff --git a/packages/rover/src/adapters/params.rs b/packages/types/src/adapters/params.rs similarity index 95% rename from packages/rover/src/adapters/params.rs rename to packages/types/src/adapters/params.rs index 50746f948..47496a682 100644 --- a/packages/rover/src/adapters/params.rs +++ b/packages/types/src/adapters/params.rs @@ -1,6 +1,7 @@ use cosmwasm_schema::cw_serde; use cosmwasm_std::{Addr, Api, Decimal, QuerierWrapper, StdResult}; -use mars_red_bank_types::params::{AssetParams, QueryMsg, TotalDepositResponse, VaultConfig}; + +use crate::params::{AssetParams, QueryMsg, TotalDepositResponse, VaultConfig}; #[cw_serde] pub struct ParamsBase(T); diff --git a/packages/rover/src/adapters/red_bank.rs b/packages/types/src/adapters/red_bank.rs similarity index 99% rename from packages/rover/src/adapters/red_bank.rs rename to packages/types/src/adapters/red_bank.rs index 8d5e08929..8c4f2b468 100644 --- a/packages/rover/src/adapters/red_bank.rs +++ b/packages/types/src/adapters/red_bank.rs @@ -3,7 +3,8 @@ use cosmwasm_std::{ to_binary, Addr, Api, Coin, CosmosMsg, QuerierWrapper, QueryRequest, StdResult, Uint128, WasmMsg, WasmQuery, }; -use mars_red_bank_types::red_bank; + +use crate::red_bank; #[cw_serde] pub struct RedBankUnchecked(String); diff --git a/packages/rover/src/adapters/rewards_collector.rs b/packages/types/src/adapters/rewards_collector.rs similarity index 100% rename from packages/rover/src/adapters/rewards_collector.rs rename to packages/types/src/adapters/rewards_collector.rs diff --git a/packages/rover/src/adapters/swap/mod.rs b/packages/types/src/adapters/swap/mod.rs similarity index 100% rename from packages/rover/src/adapters/swap/mod.rs rename to packages/types/src/adapters/swap/mod.rs diff --git a/packages/rover/src/adapters/swap/msgs.rs b/packages/types/src/adapters/swap/msgs.rs similarity index 100% rename from packages/rover/src/adapters/swap/msgs.rs rename to packages/types/src/adapters/swap/msgs.rs diff --git a/packages/rover/src/adapters/swap/swapper.rs b/packages/types/src/adapters/swap/swapper.rs similarity index 100% rename from packages/rover/src/adapters/swap/swapper.rs rename to packages/types/src/adapters/swap/swapper.rs diff --git a/packages/rover/src/adapters/vault/amount.rs b/packages/types/src/adapters/vault/amount.rs similarity index 73% rename from packages/rover/src/adapters/vault/amount.rs rename to packages/types/src/adapters/vault/amount.rs index b52a80293..5bc105ff7 100644 --- a/packages/rover/src/adapters/vault/amount.rs +++ b/packages/types/src/adapters/vault/amount.rs @@ -1,10 +1,7 @@ use cosmwasm_schema::cw_serde; -use cosmwasm_std::Uint128; +use cosmwasm_std::{OverflowError, Uint128}; -use crate::{ - adapters::vault::{UnlockingChange, UpdateType, VaultPositionUpdate, VaultUnlockingPosition}, - error::{ContractError, ContractResult}, -}; +use super::{UnlockingChange, UpdateType, VaultPositionUpdate, VaultUnlockingPosition}; #[cw_serde] pub enum VaultPositionAmount { @@ -47,14 +44,14 @@ impl VaultPositionAmount { } } - pub fn update(&mut self, update: VaultPositionUpdate) -> ContractResult<()> { + pub fn update(&mut self, update: VaultPositionUpdate) -> Result<(), VaultError> { match self { VaultPositionAmount::Unlocked(amount) => match update { VaultPositionUpdate::Unlocked(u) => match u { UpdateType::Increment(a) => amount.increment(a), UpdateType::Decrement(a) => amount.decrement(a), }, - _ => Err(ContractError::MismatchedVaultType {}), + _ => Err(VaultError::MismatchedVaultType), }, VaultPositionAmount::Locking(amount) => match update { VaultPositionUpdate::Locked(u) => match u { @@ -62,13 +59,16 @@ impl VaultPositionAmount { UpdateType::Decrement(a) => amount.locked.decrement(a), }, VaultPositionUpdate::Unlocking(u) => match u { - UnlockingChange::Add(p) => amount.unlocking.add(p), + UnlockingChange::Add(p) => { + amount.unlocking.add(p); + Ok(()) + } UnlockingChange::Decrement { id, amount: a, } => amount.unlocking.decrement(id, a), }, - _ => Err(ContractError::MismatchedVaultType {}), + _ => Err(VaultError::MismatchedVaultType), }, } } @@ -86,12 +86,12 @@ impl VaultAmount { self.0 } - pub fn increment(&mut self, amount: Uint128) -> ContractResult<()> { + pub fn increment(&mut self, amount: Uint128) -> Result<(), VaultError> { self.0 = self.0.checked_add(amount)?; Ok(()) } - pub fn decrement(&mut self, amount: Uint128) -> ContractResult<()> { + pub fn decrement(&mut self, amount: Uint128) -> Result<(), VaultError> { self.0 = self.0.checked_sub(amount)?; Ok(()) } @@ -123,29 +123,39 @@ impl UnlockingPositions { self.0.is_empty() } - pub fn add(&mut self, position: VaultUnlockingPosition) -> ContractResult<()> { + pub fn add(&mut self, position: VaultUnlockingPosition) { self.0.push(position); - Ok(()) } - pub fn decrement(&mut self, id: u64, amount: Uint128) -> ContractResult<()> { + pub fn decrement(&mut self, id: u64, amount: Uint128) -> Result<(), VaultError> { let res = self.0.iter_mut().find(|p| p.id == id); match res { Some(p) => { let new_amount = p.coin.amount.checked_sub(amount)?; if new_amount.is_zero() { - self.remove(id)?; + self.remove(id); } else { p.coin.amount = new_amount; } } - None => return Err(ContractError::NoPositionMatch(id.to_string())), + None => return Err(VaultError::NoPositionMatch(id.to_string())), } Ok(()) } - pub fn remove(&mut self, id: u64) -> ContractResult<()> { + pub fn remove(&mut self, id: u64) { self.0.retain(|p| p.id != id); - Ok(()) } } + +#[derive(Debug, PartialEq, thiserror::Error)] +pub enum VaultError { + #[error(transparent)] + Overflow(#[from] OverflowError), + + #[error("Issued incorrect action for vault type")] + MismatchedVaultType, + + #[error("Position {0} was not a valid position for this account id in this vault")] + NoPositionMatch(String), +} diff --git a/packages/rover/src/adapters/vault/base.rs b/packages/types/src/adapters/vault/base.rs similarity index 100% rename from packages/rover/src/adapters/vault/base.rs rename to packages/types/src/adapters/vault/base.rs diff --git a/packages/rover/src/adapters/vault/mod.rs b/packages/types/src/adapters/vault/mod.rs similarity index 100% rename from packages/rover/src/adapters/vault/mod.rs rename to packages/types/src/adapters/vault/mod.rs diff --git a/packages/rover/src/adapters/vault/position.rs b/packages/types/src/adapters/vault/position.rs similarity index 96% rename from packages/rover/src/adapters/vault/position.rs rename to packages/types/src/adapters/vault/position.rs index 6ad7c2218..10d847e34 100644 --- a/packages/rover/src/adapters/vault/position.rs +++ b/packages/types/src/adapters/vault/position.rs @@ -1,10 +1,12 @@ use cosmwasm_schema::cw_serde; use cosmwasm_std::{Coin, QuerierWrapper, StdError, StdResult, Uint128}; -use mars_red_bank_types::oracle::ActionKind; -use crate::adapters::{ - oracle::Oracle, - vault::{Vault, VaultPositionAmount}, +use crate::{ + adapters::{ + oracle::Oracle, + vault::{Vault, VaultPositionAmount}, + }, + oracle::ActionKind, }; #[cw_serde] diff --git a/packages/rover/src/adapters/vault/update.rs b/packages/types/src/adapters/vault/update.rs similarity index 100% rename from packages/rover/src/adapters/vault/update.rs rename to packages/types/src/adapters/vault/update.rs diff --git a/packages/rover/src/adapters/zapper.rs b/packages/types/src/adapters/zapper.rs similarity index 100% rename from packages/rover/src/adapters/zapper.rs rename to packages/types/src/adapters/zapper.rs diff --git a/packages/rover/src/msg/execute.rs b/packages/types/src/credit_manager/execute.rs similarity index 98% rename from packages/rover/src/msg/execute.rs rename to packages/types/src/credit_manager/execute.rs index a489b8e89..785e79b08 100644 --- a/packages/rover/src/msg/execute.rs +++ b/packages/types/src/credit_manager/execute.rs @@ -2,13 +2,13 @@ use std::collections::BTreeSet; use cosmwasm_schema::cw_serde; use cosmwasm_std::{to_binary, Addr, Coin, CosmosMsg, Decimal, StdResult, Uint128, WasmMsg}; -use mars_account_nft_types::nft_config::NftConfigUpdates; use mars_owner::OwnerUpdate; -use mars_rover_health_types::{AccountKind, HealthState}; +use super::ConfigUpdates; use crate::{ + account_nft::NftConfigUpdates, adapters::vault::{Vault, VaultPositionType, VaultUnchecked}, - msg::instantiate::ConfigUpdates, + health::{AccountKind, HealthState}, }; #[cw_serde] diff --git a/packages/rover/src/msg/instantiate.rs b/packages/types/src/credit_manager/instantiate.rs similarity index 100% rename from packages/rover/src/msg/instantiate.rs rename to packages/types/src/credit_manager/instantiate.rs diff --git a/packages/rover/src/msg/migrate.rs b/packages/types/src/credit_manager/migrate.rs similarity index 100% rename from packages/rover/src/msg/migrate.rs rename to packages/types/src/credit_manager/migrate.rs diff --git a/packages/types/src/credit_manager/mod.rs b/packages/types/src/credit_manager/mod.rs new file mode 100644 index 000000000..9a01a9236 --- /dev/null +++ b/packages/types/src/credit_manager/mod.rs @@ -0,0 +1,11 @@ +pub mod execute; +pub mod instantiate; +pub mod migrate; +pub mod query; +pub mod reply; + +pub use execute::*; +pub use instantiate::*; +pub use migrate::*; +pub use query::*; +pub use reply::*; diff --git a/packages/rover/src/msg/query.rs b/packages/types/src/credit_manager/query.rs similarity index 97% rename from packages/rover/src/msg/query.rs rename to packages/types/src/credit_manager/query.rs index f1021837b..68fb63cd2 100644 --- a/packages/rover/src/msg/query.rs +++ b/packages/types/src/credit_manager/query.rs @@ -7,13 +7,14 @@ use crate::{ rewards_collector::RewardsCollector, vault::{Vault, VaultPosition, VaultUnchecked}, }, + health::AccountKind, traits::Coins, }; #[cw_serde] #[derive(QueryResponses)] pub enum QueryMsg { - #[returns(mars_rover_health_types::AccountKind)] + #[returns(AccountKind)] AccountKind { account_id: String, }, @@ -176,5 +177,5 @@ pub struct ConfigResponse { #[cw_serde] pub struct Account { pub id: String, - pub kind: mars_rover_health_types::AccountKind, + pub kind: AccountKind, } diff --git a/packages/rover/src/extensions/reply.rs b/packages/types/src/credit_manager/reply.rs similarity index 100% rename from packages/rover/src/extensions/reply.rs rename to packages/types/src/credit_manager/reply.rs diff --git a/packages/types/src/lib.rs b/packages/types/src/lib.rs index 77530a073..8061905ce 100644 --- a/packages/types/src/lib.rs +++ b/packages/types/src/lib.rs @@ -1,5 +1,7 @@ pub mod account_nft; +pub mod adapters; pub mod address_provider; +pub mod credit_manager; pub mod error; pub mod health; pub mod incentives; @@ -9,6 +11,7 @@ pub mod params; pub mod red_bank; pub mod rewards_collector; pub mod swapper; +pub mod traits; use cosmwasm_schema::cw_serde; diff --git a/packages/types/src/rewards_collector.rs b/packages/types/src/rewards_collector.rs index c7b0e2d3a..ad03d79c5 100644 --- a/packages/types/src/rewards_collector.rs +++ b/packages/types/src/rewards_collector.rs @@ -6,7 +6,7 @@ use mars_utils::{ helpers::{decimal_param_le_one, integer_param_gt_zero, validate_native_denom}, }; -use self::credit_manager::Action; +use crate::credit_manager::Action; const MAX_SLIPPAGE_TOLERANCE_PERCENTAGE: u64 = 50; @@ -199,39 +199,3 @@ pub enum QueryMsg { #[returns(ConfigResponse)] Config {}, } - -// TODO: rover is private repo for now so can't use it as a dependency. Use rover types once repo is public. -pub mod credit_manager { - use cosmwasm_schema::cw_serde; - use cosmwasm_std::{Decimal, Uint128}; - - #[cw_serde] - pub enum ExecuteMsg { - UpdateCreditAccount { - account_id: String, - actions: Vec, - }, - } - - #[cw_serde] - pub enum Action { - Withdraw(ActionCoin), - WithdrawLiquidity { - lp_token: ActionCoin, - slippage: Decimal, // value validated in credit-manager - }, - Unknown {}, // Used to simulate allowance only for: Withdraw and WithdrawLiquidity - } - - #[cw_serde] - pub struct ActionCoin { - pub denom: String, - pub amount: ActionAmount, - } - - #[cw_serde] - pub enum ActionAmount { - Exact(Uint128), - AccountBalance, - } -} diff --git a/packages/rover/src/traits.rs b/packages/types/src/traits.rs similarity index 58% rename from packages/rover/src/traits.rs rename to packages/types/src/traits.rs index 729943bf9..45f845cfb 100644 --- a/packages/rover/src/traits.rs +++ b/packages/types/src/traits.rs @@ -1,5 +1,7 @@ use cosmwasm_std::{Coin, Decimal}; +use crate::credit_manager::ActionCoin; + pub trait Stringify { fn to_string(&self) -> String; } @@ -10,10 +12,28 @@ impl Stringify for Option { } } +impl Stringify for &[Coin] { + fn to_string(&self) -> String { + self.iter().map(|coin| coin.to_string()).collect::>().join(",") + } +} + pub trait Denoms { fn to_denoms(&self) -> Vec<&str>; } +impl Denoms for Vec { + fn to_denoms(&self) -> Vec<&str> { + self.iter().map(|c| c.denom.as_str()).collect() + } +} + +impl Denoms for Vec { + fn to_denoms(&self) -> Vec<&str> { + self.iter().map(|c| c.denom.as_str()).collect() + } +} + pub trait Coins { fn to_coins(&self) -> Vec; } From 38a4f3aeac147f26244ce9ffffa799700d3d707b Mon Sep 17 00:00:00 2001 From: larry <26318510+larry0x@users.noreply.github.com> Date: Thu, 12 Oct 2023 09:50:09 +0100 Subject: [PATCH 05/15] move contents of `mars_zapper_base::msg` into `mars_types::zapper` --- Cargo.lock | 2 +- contracts/v2-zapper/base/Cargo.toml | 1 + contracts/v2-zapper/base/src/contract.rs | 3 ++- contracts/v2-zapper/base/src/lib.rs | 2 -- packages/types/Cargo.toml | 1 - packages/types/src/adapters/zapper.rs | 3 ++- packages/types/src/lib.rs | 1 + .../v2-zapper/base/src/msg.rs => packages/types/src/zapper.rs | 0 8 files changed, 7 insertions(+), 6 deletions(-) rename contracts/v2-zapper/base/src/msg.rs => packages/types/src/zapper.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index eb8c929b0..44517cd86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2669,7 +2669,6 @@ dependencies = [ "cw721-base 0.18.0", "mars-owner 2.0.0", "mars-utils 2.0.0", - "mars-zapper-base", "serde", "serde-json-wasm 1.0.0", "strum 0.25.0", @@ -2716,6 +2715,7 @@ dependencies = [ "cw-dex", "cw-utils 1.0.2", "cw2 1.1.1", + "mars-types", "schemars", "serde", "thiserror", diff --git a/contracts/v2-zapper/base/Cargo.toml b/contracts/v2-zapper/base/Cargo.toml index b33069df3..ea5e135c2 100644 --- a/contracts/v2-zapper/base/Cargo.toml +++ b/contracts/v2-zapper/base/Cargo.toml @@ -24,6 +24,7 @@ cosmwasm-std = { workspace = true } cw2 = { workspace = true } cw-dex = { workspace = true } cw-utils = { workspace = true } +mars-types = { workspace = true } schemars = { workspace = true } serde = { workspace = true } thiserror = { workspace = true } diff --git a/contracts/v2-zapper/base/src/contract.rs b/contracts/v2-zapper/base/src/contract.rs index 338c652cb..4b6a1aeba 100644 --- a/contracts/v2-zapper/base/src/contract.rs +++ b/contracts/v2-zapper/base/src/contract.rs @@ -5,8 +5,9 @@ use cosmwasm_std::{ Response, StdResult, Uint128, }; use cw_utils::one_coin; +use mars_types::zapper::{CallbackMsg, ExecuteMsg, InstantiateMsg, QueryMsg}; -use crate::{CallbackMsg, ContractError, ExecuteMsg, InstantiateMsg, LpPool, QueryMsg}; +use crate::{ContractError, LpPool}; pub struct ZapperBase

where diff --git a/contracts/v2-zapper/base/src/lib.rs b/contracts/v2-zapper/base/src/lib.rs index 84b31e55a..d0ca995d1 100644 --- a/contracts/v2-zapper/base/src/lib.rs +++ b/contracts/v2-zapper/base/src/lib.rs @@ -1,9 +1,7 @@ mod contract; mod error; -mod msg; mod traits; pub use contract::*; pub use error::*; -pub use msg::*; pub use traits::*; diff --git a/packages/types/Cargo.toml b/packages/types/Cargo.toml index 5c7b558cf..34a906b28 100644 --- a/packages/types/Cargo.toml +++ b/packages/types/Cargo.toml @@ -29,7 +29,6 @@ cw-utils = { workspace = true } cw-vault-standard = { workspace = true } mars-owner = { workspace = true } mars-utils = { workspace = true } -mars-zapper-base = { workspace = true } serde = { workspace = true } serde-json-wasm = { workspace = true } strum = { workspace = true, features = ["derive"] } diff --git a/packages/types/src/adapters/zapper.rs b/packages/types/src/adapters/zapper.rs index b03dda135..4de4f34f9 100644 --- a/packages/types/src/adapters/zapper.rs +++ b/packages/types/src/adapters/zapper.rs @@ -2,7 +2,8 @@ use cosmwasm_schema::cw_serde; use cosmwasm_std::{ to_binary, Addr, Api, Coin, CosmosMsg, QuerierWrapper, StdResult, Uint128, WasmMsg, }; -use mars_zapper_base::{ExecuteMsg, QueryMsg}; + +use crate::zapper::{ExecuteMsg, QueryMsg}; #[cw_serde] pub struct ZapperBase(T); diff --git a/packages/types/src/lib.rs b/packages/types/src/lib.rs index 8061905ce..ad1edb123 100644 --- a/packages/types/src/lib.rs +++ b/packages/types/src/lib.rs @@ -12,6 +12,7 @@ pub mod red_bank; pub mod rewards_collector; pub mod swapper; pub mod traits; +pub mod zapper; use cosmwasm_schema::cw_serde; diff --git a/contracts/v2-zapper/base/src/msg.rs b/packages/types/src/zapper.rs similarity index 100% rename from contracts/v2-zapper/base/src/msg.rs rename to packages/types/src/zapper.rs From dee5f89e568f5186102b9454c668ed6b6d8e5799 Mon Sep 17 00:00:00 2001 From: larry <26318510+larry0x@users.noreply.github.com> Date: Thu, 12 Oct 2023 11:53:33 +0100 Subject: [PATCH 06/15] fix import errors --- CODING_GUIDELINES.md | 2 +- Cargo.lock | 3 ++ contracts/account-nft/examples/schema.rs | 2 +- contracts/account-nft/src/contract.rs | 5 +- contracts/account-nft/src/execute.rs | 23 ++++---- .../account-nft/src/migrations/v2_0_0.rs | 8 +-- contracts/account-nft/src/query.rs | 2 +- contracts/account-nft/src/state.rs | 2 +- .../tests/helpers/health_responses.rs | 2 +- .../account-nft/tests/helpers/mock_env.rs | 12 +++-- .../tests/helpers/mock_env_builder.rs | 3 +- .../account-nft/tests/test_burn_allowance.rs | 3 +- .../tests/test_burn_empty_accounts.rs | 6 ++- contracts/account-nft/tests/test_migration.rs | 2 +- contracts/account-nft/tests/test_mint.rs | 6 ++- .../account-nft/tests/test_proposed_minter.rs | 2 +- .../account-nft/tests/test_update_config.rs | 2 +- contracts/address-provider/examples/schema.rs | 2 +- contracts/address-provider/src/contract.rs | 2 +- contracts/address-provider/src/key.rs | 2 +- contracts/address-provider/src/state.rs | 2 +- .../tests/tests/helpers/mod.rs | 2 +- .../tests/tests/test_addresses.rs | 4 +- .../tests/tests/test_instantiate.rs | 2 +- .../tests/tests/test_update_owner.rs | 2 +- contracts/credit-manager/Cargo.toml | 2 + contracts/credit-manager/examples/schema.rs | 2 +- contracts/credit-manager/src/borrow.rs | 2 +- contracts/credit-manager/src/claim_rewards.rs | 11 ++-- contracts/credit-manager/src/contract.rs | 6 +-- contracts/credit-manager/src/deposit.rs | 13 ++--- contracts/credit-manager/src/error.rs | 20 +++++-- contracts/credit-manager/src/execute.rs | 20 +++---- contracts/credit-manager/src/health.rs | 13 +++-- contracts/credit-manager/src/hls.rs | 10 ++-- contracts/credit-manager/src/instantiate.rs | 3 +- contracts/credit-manager/src/lend.rs | 6 +-- contracts/credit-manager/src/lib.rs | 4 +- contracts/credit-manager/src/liquidate.rs | 9 ++-- .../credit-manager/src/liquidate_deposit.rs | 6 +-- .../credit-manager/src/liquidate_lend.rs | 2 +- .../credit-manager/src/migrations/v2_0_0.rs | 3 +- contracts/credit-manager/src/query.rs | 10 ++-- contracts/credit-manager/src/reclaim.rs | 9 ++-- contracts/credit-manager/src/refund.rs | 10 +--- contracts/credit-manager/src/repay.rs | 9 +--- contracts/credit-manager/src/state.rs | 8 +-- contracts/credit-manager/src/swap.rs | 6 +-- .../src/update_coin_balances.rs | 6 +-- contracts/credit-manager/src/update_config.rs | 11 ++-- contracts/credit-manager/src/utils.rs | 11 ++-- contracts/credit-manager/src/vault/enter.rs | 11 ++-- contracts/credit-manager/src/vault/exit.rs | 13 +++-- .../credit-manager/src/vault/exit_unlocked.rs | 13 ++--- .../src/vault/liquidate_vault.rs | 18 +++---- .../src/vault/request_unlock.rs | 6 +-- contracts/credit-manager/src/vault/utils.rs | 12 ++--- contracts/credit-manager/src/withdraw.rs | 9 ++-- contracts/credit-manager/src/zap.rs | 6 +-- .../tests/helpers/assertions.rs | 3 +- .../credit-manager/tests/helpers/builders.rs | 2 +- .../tests/helpers/mock_entity_info.rs | 2 +- .../credit-manager/tests/helpers/mock_env.rs | 52 +++++++++---------- .../credit-manager/tests/helpers/types.rs | 8 +-- .../credit-manager/tests/helpers/utils.rs | 2 +- contracts/credit-manager/tests/test_borrow.rs | 7 +-- .../tests/test_claim_rewards.rs | 8 +-- .../tests/test_coin_balances.rs | 6 +-- .../credit-manager/tests/test_deposit.rs | 9 ++-- .../credit-manager/tests/test_deposit_cap.rs | 8 +-- .../credit-manager/tests/test_dispatch.rs | 6 +-- .../tests/test_enumerate_accounts.rs | 3 +- .../tests/test_enumerate_coin_balances.rs | 2 +- .../tests/test_enumerate_debt_shares.rs | 2 +- .../tests/test_enumerate_total_debt_shares.rs | 2 +- .../tests/test_enumerate_vault_positions.rs | 2 +- contracts/credit-manager/tests/test_health.rs | 16 +++--- .../credit-manager/tests/test_hls_accounts.rs | 10 ++-- contracts/credit-manager/tests/test_lend.rs | 10 ++-- .../tests/test_liquidate_deposit.rs | 16 +++--- .../tests/test_liquidate_guard.rs | 10 ++-- .../tests/test_liquidate_lend.rs | 10 ++-- .../tests/test_liquidate_vault.rs | 20 +++---- .../tests/test_liquidation_pricing.rs | 12 ++--- .../credit-manager/tests/test_migration_v2.rs | 6 +-- .../tests/test_no_health_check.rs | 8 +-- .../credit-manager/tests/test_reclaim.rs | 6 +-- .../tests/test_reentrancy_guard.rs | 18 +++---- .../tests/test_refund_balances.rs | 2 +- contracts/credit-manager/tests/test_repay.rs | 9 ++-- .../tests/test_repay_for_recipient.rs | 10 ++-- .../tests/test_repay_from_wallet.rs | 8 +-- contracts/credit-manager/tests/test_swap.rs | 12 ++--- .../credit-manager/tests/test_update_admin.rs | 2 +- .../tests/test_update_config.rs | 10 ++-- .../tests/test_update_nft_config.rs | 4 +- .../tests/test_utilization_query.rs | 6 +-- .../credit-manager/tests/test_vault_enter.rs | 6 +-- .../credit-manager/tests/test_vault_exit.rs | 15 +++--- .../tests/test_vault_exit_unlocked.rs | 11 ++-- .../tests/test_vault_query_value.rs | 4 +- .../tests/test_vault_request_unlock.rs | 18 ++++--- .../credit-manager/tests/test_withdraw.rs | 6 +-- .../credit-manager/tests/test_zap_provide.rs | 14 +++-- .../credit-manager/tests/test_zap_withdraw.rs | 14 +++-- contracts/health/examples/schema.rs | 2 +- contracts/health/src/compute.rs | 8 +-- contracts/health/src/contract.rs | 2 +- contracts/health/src/querier.rs | 8 +-- contracts/health/src/update_config.rs | 2 +- contracts/health/tests/helpers/defaults.rs | 2 +- contracts/health/tests/helpers/mock_env.rs | 13 ++--- .../health/tests/helpers/mock_env_builder.rs | 13 +++-- contracts/health/tests/test_health_state.rs | 9 ++-- contracts/health/tests/test_health_values.rs | 26 +++++----- contracts/health/tests/test_hls.rs | 9 ++-- contracts/health/tests/test_instantiate.rs | 2 +- .../health/tests/test_liquidation_pricing.rs | 6 +-- contracts/health/tests/test_update_config.rs | 2 +- contracts/incentives/examples/schema.rs | 2 +- contracts/incentives/src/contract.rs | 2 +- contracts/incentives/src/error.rs | 2 +- contracts/incentives/src/helpers.rs | 2 +- contracts/incentives/src/migrations/v2_0_0.rs | 2 +- contracts/incentives/src/state.rs | 2 +- .../incentives/tests/tests/helpers/mod.rs | 2 +- .../incentives/tests/tests/test_admin.rs | 2 +- .../tests/tests/test_balance_change.rs | 4 +- .../tests/tests/test_claim_rewards.rs | 4 +- .../tests/tests/test_indices_usage.rs | 2 +- .../tests/tests/test_migration_v2.rs | 4 +- .../incentives/tests/tests/test_quering.rs | 4 +- .../tests/tests/test_set_asset_incentive.rs | 2 +- .../tests/tests/test_update_owner.rs | 2 +- .../incentives/tests/tests/test_whitelist.rs | 4 +- .../mock-credit-manager/examples/schema.rs | 2 +- contracts/mock-credit-manager/src/contract.rs | 2 +- contracts/mock-credit-manager/src/execute.rs | 3 +- contracts/mock-credit-manager/src/msg.rs | 6 ++- contracts/mock-credit-manager/src/query.rs | 6 ++- contracts/mock-credit-manager/src/state.rs | 6 ++- contracts/mock-health/src/contract.rs | 2 +- contracts/mock-health/src/msg.rs | 2 +- contracts/mock-health/src/state.rs | 2 +- contracts/mock-incentives/src/contract.rs | 2 +- contracts/mock-oracle/src/contract.rs | 2 +- contracts/mock-oracle/src/msg.rs | 4 +- contracts/mock-red-bank/examples/schema.rs | 2 +- contracts/mock-red-bank/src/contract.rs | 2 +- contracts/mock-red-bank/src/execute.rs | 2 +- contracts/mock-red-bank/src/query.rs | 2 +- contracts/mock-red-bank/src/state.rs | 2 +- contracts/mock-vault/examples/schema.rs | 2 +- contracts/mock-vault/src/contract.rs | 2 +- contracts/mock-vault/src/deposit.rs | 6 ++- contracts/mock-vault/src/error.rs | 4 +- contracts/mock-vault/src/msg.rs | 2 +- contracts/mock-vault/src/state.rs | 2 +- contracts/oracle/base/src/contract.rs | 2 +- contracts/oracle/base/src/pyth.rs | 2 +- contracts/oracle/base/src/traits.rs | 2 +- contracts/oracle/osmosis/examples/schema.rs | 2 +- contracts/oracle/osmosis/src/contract.rs | 2 +- .../oracle/osmosis/src/migrations/v2_0_0.rs | 2 +- contracts/oracle/osmosis/src/msg.rs | 2 +- contracts/oracle/osmosis/src/price_source.rs | 2 +- .../oracle/osmosis/tests/tests/helpers/mod.rs | 2 +- .../oracle/osmosis/tests/tests/test_admin.rs | 2 +- .../tests/tests/test_custom_execute.rs | 2 +- .../osmosis/tests/tests/test_migration_v2.rs | 2 +- .../osmosis/tests/tests/test_query_price.rs | 2 +- .../tests/tests/test_query_price_for_pyth.rs | 2 +- .../tests/tests/test_remove_price_source.rs | 2 +- .../tests/tests/test_set_price_source.rs | 2 +- .../osmosis/tests/tests/test_update_owner.rs | 2 +- contracts/oracle/wasm/examples/schema.rs | 2 +- contracts/oracle/wasm/src/astroport_twap.rs | 2 +- contracts/oracle/wasm/src/contract.rs | 4 +- contracts/oracle/wasm/src/helpers.rs | 2 +- contracts/oracle/wasm/src/price_source.rs | 2 +- contracts/oracle/wasm/src/state.rs | 2 +- .../oracle/wasm/tests/tests/helpers/mod.rs | 2 +- .../wasm/tests/tests/test_price_source.rs | 6 +-- contracts/params/examples/schema.rs | 2 +- contracts/params/src/contract.rs | 2 +- contracts/params/src/error.rs | 2 +- contracts/params/src/execute.rs | 2 +- contracts/params/src/query.rs | 2 +- contracts/params/src/state.rs | 2 +- .../params/tests/tests/helpers/generator.rs | 2 +- .../params/tests/tests/helpers/mock_env.rs | 2 +- .../tests/tests/test_asset_validation.rs | 2 +- .../params/tests/tests/test_deposit_cap.rs | 4 +- .../tests/tests/test_emergency_powers.rs | 2 +- .../tests/tests/test_update_asset_params.rs | 2 +- .../tests/tests/test_vault_validation.rs | 2 +- contracts/params/tests/tests/test_vaults.rs | 2 +- contracts/red-bank/examples/schema.rs | 2 +- contracts/red-bank/src/asset.rs | 2 +- contracts/red-bank/src/borrow.rs | 2 +- contracts/red-bank/src/collateral.rs | 2 +- contracts/red-bank/src/config.rs | 2 +- contracts/red-bank/src/contract.rs | 2 +- contracts/red-bank/src/deposit.rs | 2 +- contracts/red-bank/src/error.rs | 2 +- contracts/red-bank/src/health.rs | 2 +- contracts/red-bank/src/helpers.rs | 2 +- contracts/red-bank/src/instantiate.rs | 2 +- contracts/red-bank/src/interest_rates.rs | 2 +- contracts/red-bank/src/liquidate.rs | 2 +- contracts/red-bank/src/migrations/v2_0_0.rs | 6 +-- contracts/red-bank/src/query.rs | 2 +- contracts/red-bank/src/repay.rs | 2 +- contracts/red-bank/src/state.rs | 2 +- .../red-bank/src/uncollateralized_loan.rs | 2 +- contracts/red-bank/src/user.rs | 2 +- contracts/red-bank/src/withdraw.rs | 2 +- contracts/red-bank/tests/tests/helpers/mod.rs | 4 +- contracts/red-bank/tests/tests/test_admin.rs | 4 +- contracts/red-bank/tests/tests/test_borrow.rs | 4 +- .../tests/tests/test_credit_accounts.rs | 2 +- .../red-bank/tests/tests/test_deposit.rs | 4 +- contracts/red-bank/tests/tests/test_health.rs | 2 +- .../red-bank/tests/tests/test_liquidate.rs | 10 ++-- .../red-bank/tests/tests/test_migration_v2.rs | 4 +- contracts/red-bank/tests/tests/test_misc.rs | 4 +- .../red-bank/tests/tests/test_payment.rs | 2 +- contracts/red-bank/tests/tests/test_query.rs | 2 +- .../red-bank/tests/tests/test_update_owner.rs | 2 +- .../red-bank/tests/tests/test_withdraw.rs | 8 +-- .../rewards-collector/base/examples/schema.rs | 2 +- .../rewards-collector/base/src/contract.rs | 10 ++-- contracts/rewards-collector/base/src/error.rs | 2 +- .../rewards-collector/base/src/traits.rs | 2 +- .../rewards-collector/neutron/src/lib.rs | 4 +- .../rewards-collector/osmosis/src/lib.rs | 2 +- .../osmosis/tests/tests/helpers/mod.rs | 2 +- .../osmosis/tests/tests/test_admin.rs | 2 +- .../tests/tests/test_distribute_rewards.rs | 2 +- .../osmosis/tests/tests/test_swap.rs | 6 +-- .../osmosis/tests/tests/test_update_owner.rs | 2 +- .../osmosis/tests/tests/test_withdraw.rs | 12 ++--- .../swapper/astroport/examples/schema.rs | 2 +- contracts/swapper/astroport/src/contract.rs | 2 +- contracts/swapper/astroport/src/route.rs | 4 +- .../astroport/tests/tests/test_routes.rs | 4 +- .../tests/tests/test_transfer_result.rs | 2 +- contracts/swapper/base/examples/schema.rs | 2 +- contracts/swapper/base/src/contract.rs | 2 +- contracts/swapper/base/src/traits.rs | 2 +- contracts/swapper/mock/src/contract.rs | 4 +- contracts/swapper/osmosis/examples/schema.rs | 2 +- contracts/swapper/osmosis/src/contract.rs | 2 +- contracts/swapper/osmosis/src/route.rs | 2 +- .../osmosis/tests/tests/helpers/mod.rs | 2 +- .../tests/tests/test_enumerate_routes.rs | 2 +- .../osmosis/tests/tests/test_estimate.rs | 2 +- .../osmosis/tests/tests/test_instantiate.rs | 2 +- .../osmosis/tests/tests/test_set_route.rs | 2 +- .../swapper/osmosis/tests/tests/test_swap.rs | 2 +- .../osmosis/tests/tests/test_update_admin.rs | 2 +- contracts/v2-zapper/base/examples/schema.rs | 2 +- contracts/v2-zapper/mock/examples/schema.rs | 2 +- contracts/v2-zapper/mock/src/contract.rs | 2 +- contracts/v2-zapper/mock/src/error.rs | 4 +- contracts/v2-zapper/mock/src/msg.rs | 2 +- contracts/v2-zapper/mock/src/query.rs | 2 +- contracts/v2-zapper/mock/src/state.rs | 2 +- contracts/v2-zapper/osmosis/Cargo.toml | 1 + contracts/v2-zapper/osmosis/src/contract.rs | 3 +- .../v2-zapper/osmosis/tests/helpers/utils.rs | 2 +- .../v2-zapper/osmosis/tests/test_callback.rs | 3 +- .../osmosis/tests/test_provide_liquidity.rs | 2 +- .../v2-zapper/osmosis/tests/test_queries.rs | 2 +- .../osmosis/tests/test_withdraw_liquidity.rs | 3 +- integration-tests/tests/helpers.rs | 2 +- integration-tests/tests/test_oracles.rs | 20 +++---- .../tests/test_rewards_collector.rs | 16 +++--- integration-tests/tests/test_rover_flow.rs | 2 +- integration-tests/tests/test_user_flow.rs | 2 +- packages/health-computer/src/data_types.rs | 6 ++- .../health-computer/src/health_computer.rs | 16 +++--- .../tests/helpers/mock_coin_info.rs | 2 +- .../tests/helpers/mock_vault_config.rs | 2 +- .../tests/helpers/prop_test_runner_borrow.rs | 8 +-- .../tests/helpers/prop_test_runner_swap.rs | 3 +- .../tests/helpers/prop_test_strategies.rs | 17 +++--- .../tests/test_health_scenarios.rs | 10 ++-- packages/health-computer/tests/test_hls.rs | 10 ++-- .../tests/test_input_validation.rs | 10 ++-- .../tests/test_max_borrow_deposit.rs | 6 ++- .../tests/test_max_borrow_prop.rs | 2 +- .../tests/test_max_borrow_validation.rs | 10 ++-- .../tests/test_max_borrow_vault.rs | 6 ++- .../tests/test_max_borrow_wallet.rs | 6 ++- .../health-computer/tests/test_max_swap.rs | 6 ++- .../tests/test_max_swap_prop.rs | 2 +- .../tests/test_max_swap_validation.rs | 10 ++-- .../tests/test_max_withdraw.rs | 10 ++-- packages/health/src/health.rs | 4 +- packages/health/src/query.rs | 4 +- .../tests/test_from_coins_to_positions.rs | 4 +- .../health/tests/test_health_from_coins.rs | 4 +- packages/interest-rate/src/lib.rs | 2 +- packages/liquidation/src/liquidation.rs | 2 +- packages/testing/src/astroport_swapper.rs | 19 +++---- packages/testing/src/incentives_querier.rs | 2 +- packages/testing/src/integration/mock_env.rs | 12 ++--- packages/testing/src/mars_mock_querier.rs | 5 +- packages/testing/src/mock_address_provider.rs | 2 +- packages/testing/src/oracle_querier.rs | 2 +- packages/testing/src/params_querier.rs | 2 +- packages/testing/src/red_bank_querier.rs | 2 +- packages/testing/src/wasm_oracle.rs | 32 ++++++------ 314 files changed, 799 insertions(+), 822 deletions(-) diff --git a/CODING_GUIDELINES.md b/CODING_GUIDELINES.md index f10b0249c..e77a6efe6 100644 --- a/CODING_GUIDELINES.md +++ b/CODING_GUIDELINES.md @@ -70,7 +70,7 @@ pub use thing_three::*; Later we can import `red-bank` module things with one line: ```rust -use mars_red_bank_types::red_bank::*; +use mars_types::red_bank::*; ``` ## API & Design diff --git a/Cargo.lock b/Cargo.lock index 44517cd86..0167e24e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2140,8 +2140,10 @@ dependencies = [ "mars-rover-health", "mars-swapper-mock", "mars-types", + "mars-utils 2.0.0", "mars-zapper-mock", "test-case", + "thiserror", ] [[package]] @@ -2742,6 +2744,7 @@ dependencies = [ "cw-dex", "cw-utils 1.0.2", "cw2 1.1.1", + "mars-types", "mars-zapper-base", "osmosis-std 0.19.2", "osmosis-test-tube", diff --git a/contracts/account-nft/examples/schema.rs b/contracts/account-nft/examples/schema.rs index 13fbf60ff..2deb93c4a 100644 --- a/contracts/account-nft/examples/schema.rs +++ b/contracts/account-nft/examples/schema.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::write_api; -use mars_account_nft_types::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use mars_types::account_nft::{ExecuteMsg, InstantiateMsg, QueryMsg}; fn main() { write_api! { diff --git a/contracts/account-nft/src/contract.rs b/contracts/account-nft/src/contract.rs index 6b30cbd6e..2c47ad7c5 100644 --- a/contracts/account-nft/src/contract.rs +++ b/contracts/account-nft/src/contract.rs @@ -5,10 +5,7 @@ use cosmwasm_std::{ }; use cw2::set_contract_version; use cw721_base::Cw721Contract; -use mars_account_nft_types::{ - msg::{ExecuteMsg, InstantiateMsg, MigrateV1ToV2, QueryMsg}, - nft_config::NftConfig, -}; +use mars_types::account_nft::{ExecuteMsg, InstantiateMsg, MigrateV1ToV2, NftConfig, QueryMsg}; use crate::{ error::ContractError, diff --git a/contracts/account-nft/src/execute.rs b/contracts/account-nft/src/execute.rs index 17b3d3039..62e164841 100644 --- a/contracts/account-nft/src/execute.rs +++ b/contracts/account-nft/src/execute.rs @@ -6,10 +6,12 @@ use cw721_base::{ ContractError::Ownership, OwnershipError::{NoOwner, NotOwner}, }; -use mars_account_nft_types::nft_config::NftConfigUpdates; -use mars_red_bank_types::oracle::ActionKind; -use mars_rover::msg::QueryMsg; -use mars_rover_health_types::{HealthValuesResponse, QueryMsg::HealthValues}; +use mars_types::{ + account_nft::NftConfigUpdates, + credit_manager::QueryMsg, + health::{AccountKind, HealthValuesResponse, QueryMsg::HealthValues}, + oracle::ActionKind, +}; use crate::{ contract::Parent, @@ -44,13 +46,12 @@ pub fn burn( return Err(CreditManagerContractNotSet); }; - let acc_kind: mars_rover_health_types::AccountKind = - deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart { - contract_addr: cm_contract_addr.into(), - msg: to_binary(&QueryMsg::AccountKind { - account_id: token_id.clone(), - })?, - }))?; + let acc_kind: AccountKind = deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart { + contract_addr: cm_contract_addr.into(), + msg: to_binary(&QueryMsg::AccountKind { + account_id: token_id.clone(), + })?, + }))?; let response: HealthValuesResponse = deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart { diff --git a/contracts/account-nft/src/migrations/v2_0_0.rs b/contracts/account-nft/src/migrations/v2_0_0.rs index 5d0fdc89e..15ba660d1 100644 --- a/contracts/account-nft/src/migrations/v2_0_0.rs +++ b/contracts/account-nft/src/migrations/v2_0_0.rs @@ -3,9 +3,11 @@ use cosmwasm_std::{ }; use cw2::set_contract_version; use cw721::Cw721Query; -use mars_account_nft_types::nft_config::NftConfig; -use mars_red_bank_types::oracle::ActionKind; -use mars_rover_health_types::{AccountKind, HealthValuesResponse, QueryMsg::HealthValues}; +use mars_types::{ + account_nft::NftConfig, + health::{AccountKind, HealthValuesResponse, QueryMsg::HealthValues}, + oracle::ActionKind, +}; use crate::{ contract::{Parent, CONTRACT_NAME, CONTRACT_VERSION}, diff --git a/contracts/account-nft/src/query.rs b/contracts/account-nft/src/query.rs index ed4a5fa0c..4303e7283 100644 --- a/contracts/account-nft/src/query.rs +++ b/contracts/account-nft/src/query.rs @@ -1,5 +1,5 @@ use cosmwasm_std::{Deps, StdResult}; -use mars_account_nft_types::nft_config::UncheckedNftConfig; +use mars_types::account_nft::UncheckedNftConfig; use crate::state::{CONFIG, NEXT_ID}; diff --git a/contracts/account-nft/src/state.rs b/contracts/account-nft/src/state.rs index 828cebfed..f28fa543a 100644 --- a/contracts/account-nft/src/state.rs +++ b/contracts/account-nft/src/state.rs @@ -1,6 +1,6 @@ use cosmwasm_schema::cw_serde; use cw_storage_plus::Item; -use mars_account_nft_types::nft_config::NftConfig; +use mars_types::account_nft::NftConfig; pub const CONFIG: Item = Item::new("config"); pub const NEXT_ID: Item = Item::new("next_id"); diff --git a/contracts/account-nft/tests/helpers/health_responses.rs b/contracts/account-nft/tests/helpers/health_responses.rs index 41977504d..d507f8b41 100644 --- a/contracts/account-nft/tests/helpers/health_responses.rs +++ b/contracts/account-nft/tests/helpers/health_responses.rs @@ -1,7 +1,7 @@ use std::ops::Sub; use cosmwasm_std::Uint128; -use mars_rover_health_types::HealthValuesResponse; +use mars_types::health::HealthValuesResponse; pub const MAX_VALUE_FOR_BURN: Uint128 = Uint128::new(1000); diff --git a/contracts/account-nft/tests/helpers/mock_env.rs b/contracts/account-nft/tests/helpers/mock_env.rs index 631635f37..07a596ad9 100644 --- a/contracts/account-nft/tests/helpers/mock_env.rs +++ b/contracts/account-nft/tests/helpers/mock_env.rs @@ -7,13 +7,15 @@ use cw721_base::{ Ownership, }; use cw_multi_test::{App, AppResponse, BasicApp, Executor}; -use mars_account_nft_types::{ - msg::{ExecuteMsg, ExecuteMsg::UpdateConfig, MigrateV1ToV2, QueryMsg}, - nft_config::{NftConfigUpdates, UncheckedNftConfig}, -}; use mars_mock_credit_manager::msg::ExecuteMsg::SetAccountKindResponse; use mars_mock_rover_health::msg::ExecuteMsg::SetHealthResponse; -use mars_rover_health_types::{AccountKind, HealthValuesResponse}; +use mars_types::{ + account_nft::{ + ExecuteMsg, ExecuteMsg::UpdateConfig, MigrateV1ToV2, NftConfigUpdates, QueryMsg, + UncheckedNftConfig, + }, + health::{AccountKind, HealthValuesResponse}, +}; use crate::helpers::MockEnvBuilder; diff --git a/contracts/account-nft/tests/helpers/mock_env_builder.rs b/contracts/account-nft/tests/helpers/mock_env_builder.rs index 6d0ee334f..d77feca29 100644 --- a/contracts/account-nft/tests/helpers/mock_env_builder.rs +++ b/contracts/account-nft/tests/helpers/mock_env_builder.rs @@ -3,10 +3,9 @@ use std::mem::take; use anyhow::Result as AnyResult; use cosmwasm_std::{Addr, Decimal, Empty}; use cw_multi_test::{BasicApp, Executor}; -use mars_account_nft_types::msg::InstantiateMsg; use mars_mock_credit_manager::msg::InstantiateMsg as CmMockInstantiateMsg; use mars_owner::OwnerResponse; -use mars_rover::msg::query::ConfigResponse; +use mars_types::{account_nft::InstantiateMsg, credit_manager::ConfigResponse}; use super::mock_credit_manager_contract; use crate::helpers::{mock_health_contract, mock_nft_contract, MockEnv, MAX_VALUE_FOR_BURN}; diff --git a/contracts/account-nft/tests/test_burn_allowance.rs b/contracts/account-nft/tests/test_burn_allowance.rs index a29cce899..37a955a81 100644 --- a/contracts/account-nft/tests/test_burn_allowance.rs +++ b/contracts/account-nft/tests/test_burn_allowance.rs @@ -7,8 +7,7 @@ use mars_account_nft::error::{ ContractError, ContractError::{BaseError, BurnNotAllowed, HealthContractNotSet}, }; -use mars_account_nft_types::msg::QueryMsg::NftInfo; -use mars_rover_health_types::AccountKind; +use mars_types::{account_nft::QueryMsg::NftInfo, health::AccountKind}; use crate::helpers::{below_max_for_burn, generate_health_response, MockEnv, MAX_VALUE_FOR_BURN}; diff --git a/contracts/account-nft/tests/test_burn_empty_accounts.rs b/contracts/account-nft/tests/test_burn_empty_accounts.rs index 9d6b408b0..c9ce06c87 100644 --- a/contracts/account-nft/tests/test_burn_empty_accounts.rs +++ b/contracts/account-nft/tests/test_burn_empty_accounts.rs @@ -1,7 +1,9 @@ use cosmwasm_std::{Addr, StdError}; use mars_account_nft::error::{ContractError, ContractError::HealthContractNotSet}; -use mars_account_nft_types::msg::QueryMsg::{AllTokens, NumTokens, Tokens}; -use mars_rover_health_types::AccountKind; +use mars_types::{ + account_nft::QueryMsg::{AllTokens, NumTokens, Tokens}, + health::AccountKind, +}; use crate::helpers::{generate_health_response, MockEnv}; diff --git a/contracts/account-nft/tests/test_migration.rs b/contracts/account-nft/tests/test_migration.rs index 354a7ef7e..722e24171 100644 --- a/contracts/account-nft/tests/test_migration.rs +++ b/contracts/account-nft/tests/test_migration.rs @@ -11,7 +11,7 @@ use cw721_base_v16::{ use mars_account_nft::{ contract::migrate, error::ContractError, migrations::v2_0_0::v1_state, state::CONFIG, }; -use mars_account_nft_types::nft_config::NftConfig; +use mars_types::account_nft::NftConfig; pub mod helpers; diff --git a/contracts/account-nft/tests/test_mint.rs b/contracts/account-nft/tests/test_mint.rs index bfc25e947..dec5b8140 100644 --- a/contracts/account-nft/tests/test_mint.rs +++ b/contracts/account-nft/tests/test_mint.rs @@ -3,8 +3,10 @@ use cw721::OwnerOfResponse; use cw721_base::{ContractError::Ownership, OwnershipError::NotOwner}; use cw_multi_test::Executor; use mars_account_nft::error::{ContractError, ContractError::BaseError}; -use mars_account_nft_types::msg::{ExecuteMsg, QueryMsg::OwnerOf}; -use mars_rover_health_types::AccountKind; +use mars_types::{ + account_nft::{ExecuteMsg, QueryMsg::OwnerOf}, + health::AccountKind, +}; use crate::helpers::{below_max_for_burn, MockEnv}; diff --git a/contracts/account-nft/tests/test_proposed_minter.rs b/contracts/account-nft/tests/test_proposed_minter.rs index df4dd0765..1b0fa0035 100644 --- a/contracts/account-nft/tests/test_proposed_minter.rs +++ b/contracts/account-nft/tests/test_proposed_minter.rs @@ -1,6 +1,6 @@ use cosmwasm_std::Addr; use cw721_base::MinterResponse; -use mars_account_nft_types::msg::QueryMsg; +use mars_types::account_nft::QueryMsg; use crate::helpers::MockEnv; diff --git a/contracts/account-nft/tests/test_update_config.rs b/contracts/account-nft/tests/test_update_config.rs index 33085293b..acafc81b1 100644 --- a/contracts/account-nft/tests/test_update_config.rs +++ b/contracts/account-nft/tests/test_update_config.rs @@ -1,5 +1,5 @@ use cosmwasm_std::{Addr, Uint128}; -use mars_account_nft_types::nft_config::NftConfigUpdates; +use mars_types::account_nft::NftConfigUpdates; use crate::helpers::MockEnv; diff --git a/contracts/address-provider/examples/schema.rs b/contracts/address-provider/examples/schema.rs index 85db0c460..245b8fc20 100644 --- a/contracts/address-provider/examples/schema.rs +++ b/contracts/address-provider/examples/schema.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::write_api; -use mars_red_bank_types::address_provider::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use mars_types::address_provider::{ExecuteMsg, InstantiateMsg, QueryMsg}; fn main() { write_api! { diff --git a/contracts/address-provider/src/contract.rs b/contracts/address-provider/src/contract.rs index 1257e9dc9..b16b4a4c0 100644 --- a/contracts/address-provider/src/contract.rs +++ b/contracts/address-provider/src/contract.rs @@ -8,7 +8,7 @@ use cosmwasm_std::{ use cw2::set_contract_version; use cw_storage_plus::Bound; use mars_owner::{OwnerInit::SetInitialOwner, OwnerUpdate}; -use mars_red_bank_types::address_provider::{ +use mars_types::address_provider::{ AddressResponseItem, Config, ConfigResponse, ExecuteMsg, InstantiateMsg, MarsAddressType, QueryMsg, }; diff --git a/contracts/address-provider/src/key.rs b/contracts/address-provider/src/key.rs index b4a693c1a..53de43b77 100644 --- a/contracts/address-provider/src/key.rs +++ b/contracts/address-provider/src/key.rs @@ -2,7 +2,7 @@ use std::{convert::TryFrom, str::FromStr}; use cosmwasm_std::{StdError, StdResult}; use cw_storage_plus::{Key, KeyDeserialize, Prefixer, PrimaryKey}; -use mars_red_bank_types::address_provider::MarsAddressType; +use mars_types::address_provider::MarsAddressType; #[derive(Clone, Debug, PartialEq, Eq)] pub struct MarsAddressTypeKey(pub Vec); diff --git a/contracts/address-provider/src/state.rs b/contracts/address-provider/src/state.rs index 89b554c2a..e9f2333c7 100644 --- a/contracts/address-provider/src/state.rs +++ b/contracts/address-provider/src/state.rs @@ -1,6 +1,6 @@ use cw_storage_plus::{Item, Map}; use mars_owner::Owner; -use mars_red_bank_types::address_provider::Config; +use mars_types::address_provider::Config; use crate::key::MarsAddressTypeKey; diff --git a/contracts/address-provider/tests/tests/helpers/mod.rs b/contracts/address-provider/tests/tests/helpers/mod.rs index 427e1ecd8..ec33e033e 100644 --- a/contracts/address-provider/tests/tests/helpers/mod.rs +++ b/contracts/address-provider/tests/tests/helpers/mod.rs @@ -8,7 +8,7 @@ use cosmwasm_std::{ Deps, OwnedDeps, }; use mars_address_provider::contract::{instantiate, query}; -use mars_red_bank_types::address_provider::{InstantiateMsg, QueryMsg}; +use mars_types::address_provider::{InstantiateMsg, QueryMsg}; pub fn th_setup() -> OwnedDeps { let mut deps = mock_dependencies_with_balance(&[]); diff --git a/contracts/address-provider/tests/tests/test_addresses.rs b/contracts/address-provider/tests/tests/test_addresses.rs index ced40337a..76a8185da 100644 --- a/contracts/address-provider/tests/tests/test_addresses.rs +++ b/contracts/address-provider/tests/tests/test_addresses.rs @@ -1,9 +1,7 @@ use cosmwasm_std::testing::{mock_env, mock_info}; use mars_address_provider::{contract::execute, error::ContractError, state::ADDRESSES}; use mars_owner::OwnerError; -use mars_red_bank_types::address_provider::{ - AddressResponseItem, ExecuteMsg, MarsAddressType, QueryMsg, -}; +use mars_types::address_provider::{AddressResponseItem, ExecuteMsg, MarsAddressType, QueryMsg}; use super::helpers::{th_query, th_setup}; diff --git a/contracts/address-provider/tests/tests/test_instantiate.rs b/contracts/address-provider/tests/tests/test_instantiate.rs index 71c36766c..b04326ea3 100644 --- a/contracts/address-provider/tests/tests/test_instantiate.rs +++ b/contracts/address-provider/tests/tests/test_instantiate.rs @@ -1,6 +1,6 @@ use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; use mars_address_provider::{contract::instantiate, error::ContractError}; -use mars_red_bank_types::address_provider::{ConfigResponse, InstantiateMsg, QueryMsg}; +use mars_types::address_provider::{ConfigResponse, InstantiateMsg, QueryMsg}; use super::helpers::th_query; diff --git a/contracts/address-provider/tests/tests/test_update_owner.rs b/contracts/address-provider/tests/tests/test_update_owner.rs index a61716795..2f1de8909 100644 --- a/contracts/address-provider/tests/tests/test_update_owner.rs +++ b/contracts/address-provider/tests/tests/test_update_owner.rs @@ -1,7 +1,7 @@ use cosmwasm_std::testing::{mock_env, mock_info}; use mars_address_provider::{contract::execute, error::ContractError}; use mars_owner::{OwnerError::NotOwner, OwnerUpdate}; -use mars_red_bank_types::address_provider::{ConfigResponse, ExecuteMsg, QueryMsg}; +use mars_types::address_provider::{ConfigResponse, ExecuteMsg, QueryMsg}; use super::helpers::{th_query, th_setup}; diff --git a/contracts/credit-manager/Cargo.toml b/contracts/credit-manager/Cargo.toml index e7f4f13f8..54f550145 100644 --- a/contracts/credit-manager/Cargo.toml +++ b/contracts/credit-manager/Cargo.toml @@ -31,6 +31,8 @@ cw-vault-standard = { workspace = true } mars-liquidation = { workspace = true } mars-owner = { workspace = true } mars-types = { workspace = true } +mars-utils = { workspace = true } +thiserror = { workspace = true } [dev-dependencies] anyhow = { workspace = true } diff --git a/contracts/credit-manager/examples/schema.rs b/contracts/credit-manager/examples/schema.rs index 01b4a4eb0..e7ca04319 100644 --- a/contracts/credit-manager/examples/schema.rs +++ b/contracts/credit-manager/examples/schema.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::write_api; -use mars_rover::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use mars_types::credit_manager::{ExecuteMsg, InstantiateMsg, QueryMsg}; fn main() { write_api! { diff --git a/contracts/credit-manager/src/borrow.rs b/contracts/credit-manager/src/borrow.rs index 2de084336..63e3efce7 100644 --- a/contracts/credit-manager/src/borrow.rs +++ b/contracts/credit-manager/src/borrow.rs @@ -1,7 +1,7 @@ use cosmwasm_std::{Coin, DepsMut, Response, Uint128}; -use mars_rover::error::{ContractError, ContractResult}; use crate::{ + error::{ContractError, ContractResult}, state::{DEBT_SHARES, RED_BANK, TOTAL_DEBT_SHARES}, utils::{assert_coin_is_whitelisted, increment_coin_balance}, }; diff --git a/contracts/credit-manager/src/claim_rewards.rs b/contracts/credit-manager/src/claim_rewards.rs index 63b602803..b24918fc2 100644 --- a/contracts/credit-manager/src/claim_rewards.rs +++ b/contracts/credit-manager/src/claim_rewards.rs @@ -2,13 +2,16 @@ use cosmwasm_std::{ to_binary, Addr, BankMsg, Coin, CosmosMsg, DepsMut, Env, QuerierWrapper, Response, StdResult, WasmMsg, }; -use mars_rover::{ - error::{ContractError, ContractResult}, - msg::{execute::CallbackMsg, ExecuteMsg}, +use mars_types::{ + credit_manager::{execute::CallbackMsg, ExecuteMsg}, traits::Denoms, }; -use crate::{state::INCENTIVES, update_coin_balances::query_balance}; +use crate::{ + error::{ContractError, ContractResult}, + state::INCENTIVES, + update_coin_balances::query_balance, +}; pub fn claim_rewards( deps: DepsMut, diff --git a/contracts/credit-manager/src/contract.rs b/contracts/credit-manager/src/contract.rs index 767255790..d8a0e5443 100644 --- a/contracts/credit-manager/src/contract.rs +++ b/contracts/credit-manager/src/contract.rs @@ -2,13 +2,13 @@ use cosmwasm_std::{ entry_point, to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Reply, Response, }; use cw2::set_contract_version; -use mars_rover::{ +use mars_types::{ adapters::vault::VAULT_REQUEST_REPLY_ID, - error::{ContractError, ContractResult}, - msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}, + credit_manager::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}, }; use crate::{ + error::{ContractError, ContractResult}, execute::{create_credit_account, dispatch_actions, execute_callback}, instantiate::store_config, migrations, diff --git a/contracts/credit-manager/src/deposit.rs b/contracts/credit-manager/src/deposit.rs index 70e84bf0b..803fe124d 100644 --- a/contracts/credit-manager/src/deposit.rs +++ b/contracts/credit-manager/src/deposit.rs @@ -1,13 +1,10 @@ use std::collections::BTreeSet; -use cosmwasm_std::{Coin, Deps, DepsMut, Response, Uint128}; -use mars_red_bank_types::params::TotalDepositResponse; -use mars_rover::{ - coins::Coins, - error::{ContractError, ContractResult}, -}; +use cosmwasm_std::{Coin, Coins, Deps, DepsMut, Response}; +use mars_types::params::TotalDepositResponse; use crate::{ + error::{ContractError, ContractResult}, state::PARAMS, utils::{assert_coin_is_whitelisted, increment_coin_balance}, }; @@ -27,7 +24,7 @@ pub fn deposit( assert_sent_fund(coin, received_coins)?; - received_coins.deduct(coin)?; + received_coins.sub(coin.clone())?; increment_coin_balance(deps.storage, account_id, coin)?; @@ -38,7 +35,7 @@ pub fn deposit( /// Assert that fund of exactly the same type and amount was sent along with a message fn assert_sent_fund(expected: &Coin, received_coins: &Coins) -> ContractResult<()> { - let received = received_coins.amount(&expected.denom).unwrap_or_else(Uint128::zero); + let received = received_coins.amount_of(&expected.denom); if received != expected.amount { return Err(ContractError::FundsMismatch { diff --git a/contracts/credit-manager/src/error.rs b/contracts/credit-manager/src/error.rs index 67223a2be..499161941 100644 --- a/contracts/credit-manager/src/error.rs +++ b/contracts/credit-manager/src/error.rs @@ -1,15 +1,15 @@ use cosmwasm_std::{ - CheckedFromRatioError, CheckedMultiplyFractionError, CheckedMultiplyRatioError, Coin, Decimal, - DecimalRangeExceeded, OverflowError, StdError, Uint128, + CheckedFromRatioError, CheckedMultiplyFractionError, CheckedMultiplyRatioError, Coin, Coins, + CoinsError, Decimal, DecimalRangeExceeded, OverflowError, StdError, Uint128, }; use cw2::VersionError; use cw_utils::PaymentError; use mars_liquidation::error::LiquidationError; use mars_owner::OwnerError; +use mars_types::adapters::{oracle::OracleError, vault::VaultError}; +use mars_utils::error::GuardError; use thiserror::Error; -use crate::coins::Coins; - pub type ContractResult = Result; #[derive(Error, Debug, PartialEq)] @@ -174,4 +174,16 @@ pub enum ContractError { slippage: Decimal, max_slippage: Decimal, }, + + #[error(transparent)] + Coins(#[from] CoinsError), + + #[error(transparent)] + Guard(#[from] GuardError), + + #[error(transparent)] + Vault(#[from] VaultError), + + #[error(transparent)] + Oracle(#[from] OracleError), } diff --git a/contracts/credit-manager/src/execute.rs b/contracts/credit-manager/src/execute.rs index 77dd889e1..e85bf858d 100644 --- a/contracts/credit-manager/src/execute.rs +++ b/contracts/credit-manager/src/execute.rs @@ -1,21 +1,20 @@ use std::collections::BTreeSet; use cosmwasm_std::{ - to_binary, Addr, CosmosMsg, DepsMut, Env, MessageInfo, Response, StdResult, WasmMsg, + to_binary, Addr, Coins, CosmosMsg, DepsMut, Env, MessageInfo, Response, StdResult, WasmMsg, }; -use mars_account_nft_types::msg::ExecuteMsg as NftExecuteMsg; -use mars_red_bank_types::oracle::ActionKind; -use mars_rover::{ - coins::Coins, - error::{ContractError, ContractResult}, - msg::execute::{Action, CallbackMsg, LiquidateRequest}, +use mars_types::oracle::ActionKind; +use mars_types::{ + account_nft::ExecuteMsg as NftExecuteMsg, + credit_manager::{Action, CallbackMsg, LiquidateRequest}, + health::AccountKind, }; -use mars_rover_health_types::AccountKind; use crate::{ borrow::borrow, claim_rewards::{claim_rewards, send_rewards}, deposit::{assert_deposit_caps, deposit}, + error::{ContractError, ContractResult}, health::{assert_max_ltv, query_health_state}, hls::assert_hls_rules, lend::lend, @@ -466,7 +465,10 @@ pub fn execute_callback( CallbackMsg::AssertHlsRules { account_id, } => assert_hls_rules(deps.as_ref(), &account_id), - CallbackMsg::RemoveReentrancyGuard {} => REENTRANCY_GUARD.try_unlock(deps.storage), + CallbackMsg::RemoveReentrancyGuard {} => { + REENTRANCY_GUARD.try_unlock(deps.storage)?; + Ok(Response::new().add_attribute("action", "remove_reentrancy_guard")) + } CallbackMsg::SendRewardsToAddr { account_id, previous_balances, diff --git a/contracts/credit-manager/src/health.rs b/contracts/credit-manager/src/health.rs index 84ef6c5de..e2714cc65 100644 --- a/contracts/credit-manager/src/health.rs +++ b/contracts/credit-manager/src/health.rs @@ -1,9 +1,14 @@ use cosmwasm_std::{Deps, Response}; -use mars_red_bank_types::oracle::ActionKind; -use mars_rover::error::{ContractError, ContractResult}; -use mars_rover_health_types::{HealthState, HealthValuesResponse}; +use mars_types::{ + health::{HealthState, HealthValuesResponse}, + oracle::ActionKind, +}; -use crate::{state::HEALTH_CONTRACT, utils::get_account_kind}; +use crate::{ + error::{ContractError, ContractResult}, + state::HEALTH_CONTRACT, + utils::get_account_kind, +}; pub fn query_health_state( deps: Deps, diff --git a/contracts/credit-manager/src/hls.rs b/contracts/credit-manager/src/hls.rs index fcbae52a3..652464649 100644 --- a/contracts/credit-manager/src/hls.rs +++ b/contracts/credit-manager/src/hls.rs @@ -1,9 +1,11 @@ use cosmwasm_std::{Deps, Response}; -use mars_red_bank_types::params::HlsAssetType; -use mars_rover::error::{ContractError, ContractResult}; -use mars_rover_health_types::AccountKind; +use mars_types::{health::AccountKind, params::HlsAssetType}; -use crate::{query::query_positions, state::PARAMS}; +use crate::{ + error::{ContractError, ContractResult}, + query::query_positions, + state::PARAMS, +}; pub fn assert_hls_rules(deps: Deps, account_id: &str) -> ContractResult { // Rule #1 - There can only be 0 or 1 debt denom in the account diff --git a/contracts/credit-manager/src/instantiate.rs b/contracts/credit-manager/src/instantiate.rs index 19b5a3c2f..3a4ec1f99 100644 --- a/contracts/credit-manager/src/instantiate.rs +++ b/contracts/credit-manager/src/instantiate.rs @@ -1,8 +1,9 @@ use cosmwasm_std::{DepsMut, Env}; use mars_owner::OwnerInit::SetInitialOwner; -use mars_rover::{error::ContractResult, msg::InstantiateMsg}; +use mars_types::credit_manager::InstantiateMsg; use crate::{ + error::ContractResult, state::{ HEALTH_CONTRACT, INCENTIVES, MAX_SLIPPAGE, MAX_UNLOCKING_POSITIONS, ORACLE, OWNER, PARAMS, RED_BANK, SWAPPER, ZAPPER, diff --git a/contracts/credit-manager/src/lend.rs b/contracts/credit-manager/src/lend.rs index f75e104bc..d087655b5 100644 --- a/contracts/credit-manager/src/lend.rs +++ b/contracts/credit-manager/src/lend.rs @@ -1,10 +1,8 @@ use cosmwasm_std::{Coin, Deps, DepsMut, Response, Uint128}; -use mars_rover::{ - error::{ContractError, ContractResult}, - msg::execute::ActionCoin, -}; +use mars_types::credit_manager::ActionCoin; use crate::{ + error::{ContractError, ContractResult}, state::{COIN_BALANCES, RED_BANK}, utils::{assert_coin_is_whitelisted, decrement_coin_balance}, }; diff --git a/contracts/credit-manager/src/lib.rs b/contracts/credit-manager/src/lib.rs index 73a3194cc..fe6be5fed 100644 --- a/contracts/credit-manager/src/lib.rs +++ b/contracts/credit-manager/src/lib.rs @@ -1,8 +1,8 @@ -pub mod contract; - pub mod borrow; pub mod claim_rewards; +pub mod contract; pub mod deposit; +pub mod error; pub mod execute; pub mod health; pub mod hls; diff --git a/contracts/credit-manager/src/liquidate.rs b/contracts/credit-manager/src/liquidate.rs index 561ad9c94..80b9b010b 100644 --- a/contracts/credit-manager/src/liquidate.rs +++ b/contracts/credit-manager/src/liquidate.rs @@ -1,13 +1,10 @@ use cosmwasm_std::{Coin, DepsMut, QuerierWrapper, Uint128}; use mars_liquidation::liquidation::calculate_liquidation_amounts; -use mars_red_bank_types::oracle::ActionKind; -use mars_rover::{ - adapters::oracle::Oracle, - error::{ContractError, ContractResult}, - traits::Stringify, -}; +use mars_types::oracle::ActionKind; +use mars_types::{adapters::oracle::Oracle, traits::Stringify}; use crate::{ + error::{ContractError, ContractResult}, health::query_health_values, repay::current_debt_for_denom, state::{ORACLE, PARAMS}, diff --git a/contracts/credit-manager/src/liquidate_deposit.rs b/contracts/credit-manager/src/liquidate_deposit.rs index e3b8cd643..bf2b49971 100644 --- a/contracts/credit-manager/src/liquidate_deposit.rs +++ b/contracts/credit-manager/src/liquidate_deposit.rs @@ -1,10 +1,8 @@ use cosmwasm_std::{Coin, CosmosMsg, DepsMut, Env, Response, Storage}; -use mars_rover::{ - error::{ContractError, ContractResult}, - msg::execute::CallbackMsg, -}; +use mars_types::credit_manager::CallbackMsg; use crate::{ + error::{ContractError, ContractResult}, liquidate::calculate_liquidation, state::{COIN_BALANCES, REWARDS_COLLECTOR}, utils::{decrement_coin_balance, increment_coin_balance}, diff --git a/contracts/credit-manager/src/liquidate_lend.rs b/contracts/credit-manager/src/liquidate_lend.rs index a3f1c6114..0ba58b7e9 100644 --- a/contracts/credit-manager/src/liquidate_lend.rs +++ b/contracts/credit-manager/src/liquidate_lend.rs @@ -1,7 +1,7 @@ use cosmwasm_std::{Coin, DepsMut, Env, Response}; -use mars_rover::error::{ContractError::NoneLent, ContractResult}; use crate::{ + error::{ContractError::NoneLent, ContractResult}, liquidate::calculate_liquidation, liquidate_deposit::repay_debt, state::{RED_BANK, REWARDS_COLLECTOR}, diff --git a/contracts/credit-manager/src/migrations/v2_0_0.rs b/contracts/credit-manager/src/migrations/v2_0_0.rs index a0e34448a..c26f0ead8 100644 --- a/contracts/credit-manager/src/migrations/v2_0_0.rs +++ b/contracts/credit-manager/src/migrations/v2_0_0.rs @@ -1,10 +1,11 @@ use cosmwasm_std::{DepsMut, Env, Response}; use cw2::{assert_contract_version, set_contract_version}; use mars_owner::OwnerInit; -use mars_rover::{adapters::red_bank::RedBank, error::ContractResult, msg::migrate::V2Updates}; +use mars_types::{adapters::red_bank::RedBank, credit_manager::V2Updates}; use crate::{ contract::{CONTRACT_NAME, CONTRACT_VERSION}, + error::ContractResult, state::{HEALTH_CONTRACT, INCENTIVES, MAX_SLIPPAGE, OWNER, PARAMS, RED_BANK, SWAPPER}, utils::assert_max_slippage, }; diff --git a/contracts/credit-manager/src/query.rs b/contracts/credit-manager/src/query.rs index 1df62c470..9eb393500 100644 --- a/contracts/credit-manager/src/query.rs +++ b/contracts/credit-manager/src/query.rs @@ -1,18 +1,18 @@ use cosmwasm_std::{Coin, Deps, Env, Order, StdResult}; use cw_paginate::paginate_map; use cw_storage_plus::Bound; -use mars_red_bank_types::oracle::ActionKind; -use mars_rover::{ +use mars_types::{ adapters::vault::{VaultBase, VaultPosition, VaultPositionValue, VaultUnchecked}, - error::ContractResult, - msg::query::{ + credit_manager::{ Account, CoinBalanceResponseItem, ConfigResponse, DebtAmount, DebtShares, Positions, SharesResponseItem, VaultPositionResponseItem, VaultUtilizationResponse, }, + health::AccountKind, + oracle::ActionKind, }; -use mars_rover_health_types::AccountKind; use crate::{ + error::ContractResult, state::{ ACCOUNT_KINDS, ACCOUNT_NFT, COIN_BALANCES, DEBT_SHARES, HEALTH_CONTRACT, INCENTIVES, MAX_SLIPPAGE, MAX_UNLOCKING_POSITIONS, ORACLE, OWNER, PARAMS, RED_BANK, REWARDS_COLLECTOR, diff --git a/contracts/credit-manager/src/reclaim.rs b/contracts/credit-manager/src/reclaim.rs index 309e6547e..425740381 100644 --- a/contracts/credit-manager/src/reclaim.rs +++ b/contracts/credit-manager/src/reclaim.rs @@ -1,13 +1,14 @@ use std::cmp::min; use cosmwasm_std::{Coin, DepsMut, Response, Uint128}; -use mars_rover::{ +use mars_types::credit_manager::ActionCoin; + +use crate::{ error::{ContractError::NoneLent, ContractResult}, - msg::execute::ActionCoin, + state::RED_BANK, + utils::increment_coin_balance, }; -use crate::{state::RED_BANK, utils::increment_coin_balance}; - pub fn reclaim(deps: DepsMut, account_id: &str, coin: &ActionCoin) -> ContractResult { let red_bank = RED_BANK.load(deps.storage)?; let lent_amount = red_bank.query_lent(&deps.querier, account_id, &coin.denom)?; diff --git a/contracts/credit-manager/src/refund.rs b/contracts/credit-manager/src/refund.rs index 519021e6d..4ae63a97f 100644 --- a/contracts/credit-manager/src/refund.rs +++ b/contracts/credit-manager/src/refund.rs @@ -1,13 +1,7 @@ use cosmwasm_std::{to_binary, Addr, CosmosMsg, DepsMut, Env, Response, WasmMsg}; -use mars_rover::{ - error::ContractResult, - msg::{ - execute::{ActionAmount, ActionCoin, CallbackMsg}, - ExecuteMsg, - }, -}; +use mars_types::credit_manager::{ActionAmount, ActionCoin, CallbackMsg, ExecuteMsg}; -use crate::{query::query_coin_balances, utils::query_nft_token_owner}; +use crate::{error::ContractResult, query::query_coin_balances, utils::query_nft_token_owner}; pub fn refund_coin_balances(deps: DepsMut, env: Env, account_id: &str) -> ContractResult { let coins = query_coin_balances(deps.as_ref(), account_id)?; diff --git a/contracts/credit-manager/src/repay.rs b/contracts/credit-manager/src/repay.rs index d4311b3a5..729e43076 100644 --- a/contracts/credit-manager/src/repay.rs +++ b/contracts/credit-manager/src/repay.rs @@ -5,15 +5,10 @@ use cosmwasm_std::{ WasmMsg, }; use cw_utils::one_coin; -use mars_rover::{ - error::{ContractError, ContractResult}, - msg::{ - execute::{ActionCoin, CallbackMsg::Repay}, - ExecuteMsg, - }, -}; +use mars_types::credit_manager::{ActionCoin, CallbackMsg::Repay, ExecuteMsg}; use crate::{ + error::{ContractError, ContractResult}, state::{DEBT_SHARES, RED_BANK, TOTAL_DEBT_SHARES}, utils::{debt_shares_to_amount, decrement_coin_balance, increment_coin_balance}, }; diff --git a/contracts/credit-manager/src/state.rs b/contracts/credit-manager/src/state.rs index ce8ea3e75..d9d529c9a 100644 --- a/contracts/credit-manager/src/state.rs +++ b/contracts/credit-manager/src/state.rs @@ -1,15 +1,15 @@ use cosmwasm_std::{Addr, Decimal, Uint128}; use cw_storage_plus::{Item, Map}; use mars_owner::Owner; -use mars_rover::{ +use mars_types::{ adapters::{ account_nft::AccountNft, health::HealthContract, incentives::Incentives, oracle::Oracle, params::Params, red_bank::RedBank, rewards_collector::RewardsCollector, swap::Swapper, vault::VaultPositionAmount, zapper::Zapper, }, - reentrancy_guard::ReentrancyGuard, + health::AccountKind, }; -use mars_rover_health_types::AccountKind; +use mars_utils::guard::Guard; use crate::vault::RequestTempStorage; @@ -26,7 +26,7 @@ pub const INCENTIVES: Item = Item::new("incentives"); // Config pub const OWNER: Owner = Owner::new("owner"); pub const MAX_UNLOCKING_POSITIONS: Item = Item::new("max_unlocking_positions"); -pub const REENTRANCY_GUARD: ReentrancyGuard = ReentrancyGuard::new("reentrancy_guard"); +pub const REENTRANCY_GUARD: Guard = Guard::new("reentrancy_guard"); pub const MAX_SLIPPAGE: Item = Item::new("max_slippage"); // Positions diff --git a/contracts/credit-manager/src/swap.rs b/contracts/credit-manager/src/swap.rs index 7c7e5d06f..2a98b0755 100644 --- a/contracts/credit-manager/src/swap.rs +++ b/contracts/credit-manager/src/swap.rs @@ -1,10 +1,8 @@ use cosmwasm_std::{Coin, Decimal, DepsMut, Env, Response, Uint128}; -use mars_rover::{ - error::{ContractError, ContractResult}, - msg::execute::{ActionAmount, ActionCoin, ChangeExpected}, -}; +use mars_types::credit_manager::{ActionAmount, ActionCoin, ChangeExpected}; use crate::{ + error::{ContractError, ContractResult}, state::{COIN_BALANCES, SWAPPER}, utils::{ assert_coin_is_whitelisted, assert_slippage, decrement_coin_balance, update_balance_msg, diff --git a/contracts/credit-manager/src/update_coin_balances.rs b/contracts/credit-manager/src/update_coin_balances.rs index 24c5ecc58..89c108e4e 100644 --- a/contracts/credit-manager/src/update_coin_balances.rs +++ b/contracts/credit-manager/src/update_coin_balances.rs @@ -2,12 +2,10 @@ use cosmwasm_std::{ Addr, BalanceResponse, BankQuery, Coin, Decimal, DepsMut, Env, QuerierWrapper, QueryRequest, Response, StdResult, }; -use mars_rover::{ - error::{ContractError::BalanceChange, ContractResult}, - msg::execute::ChangeExpected, -}; +use mars_types::credit_manager::ChangeExpected; use crate::{ + error::{ContractError::BalanceChange, ContractResult}, state::REWARDS_COLLECTOR, utils::{decrement_coin_balance, increment_coin_balance}, }; diff --git a/contracts/credit-manager/src/update_config.rs b/contracts/credit-manager/src/update_config.rs index 6a76b2ce6..681f51b09 100644 --- a/contracts/credit-manager/src/update_config.rs +++ b/contracts/credit-manager/src/update_config.rs @@ -1,14 +1,15 @@ use cosmwasm_std::{to_binary, CosmosMsg, DepsMut, Env, MessageInfo, Response, WasmMsg}; use cw721_base::Action; -use mars_account_nft_types::{msg::ExecuteMsg as NftExecuteMsg, nft_config::NftConfigUpdates}; use mars_owner::OwnerUpdate; -use mars_rover::{ - adapters::rewards_collector::RewardsCollector, error::ContractResult, - msg::instantiate::ConfigUpdates, +use mars_types::{ + account_nft::{ExecuteMsg as NftExecuteMsg, NftConfigUpdates}, + adapters::rewards_collector::RewardsCollector, + credit_manager::ConfigUpdates, + health::AccountKind, }; -use mars_rover_health_types::AccountKind; use crate::{ + error::ContractResult, execute::create_credit_account, state::{ ACCOUNT_NFT, HEALTH_CONTRACT, INCENTIVES, MAX_SLIPPAGE, MAX_UNLOCKING_POSITIONS, ORACLE, diff --git a/contracts/credit-manager/src/utils.rs b/contracts/credit-manager/src/utils.rs index c57e4c2a3..f286b6324 100644 --- a/contracts/credit-manager/src/utils.rs +++ b/contracts/credit-manager/src/utils.rs @@ -6,16 +6,13 @@ use cosmwasm_std::{ }; use cw721::OwnerOfResponse; use cw721_base::QueryMsg; -use mars_rover::{ - error::{ContractError, ContractResult}, - msg::{ - execute::{CallbackMsg, ChangeExpected}, - ExecuteMsg, - }, +use mars_types::{ + credit_manager::{CallbackMsg, ChangeExpected, ExecuteMsg}, + health::AccountKind, }; -use mars_rover_health_types::AccountKind; use crate::{ + error::{ContractError, ContractResult}, state::{ ACCOUNT_KINDS, ACCOUNT_NFT, COIN_BALANCES, MAX_SLIPPAGE, PARAMS, RED_BANK, TOTAL_DEBT_SHARES, diff --git a/contracts/credit-manager/src/vault/enter.rs b/contracts/credit-manager/src/vault/enter.rs index 3fe1e4781..1b08d30f0 100644 --- a/contracts/credit-manager/src/vault/enter.rs +++ b/contracts/credit-manager/src/vault/enter.rs @@ -1,17 +1,14 @@ use cosmwasm_std::{ to_binary, Addr, Coin, CosmosMsg, Deps, DepsMut, QuerierWrapper, Response, Uint128, WasmMsg, }; -use mars_red_bank_types::oracle::ActionKind; -use mars_rover::{ +use mars_types::oracle::ActionKind; +use mars_types::{ adapters::vault::{UpdateType, Vault, VaultPositionUpdate}, - error::{ContractError, ContractResult}, - msg::{ - execute::{ActionAmount, ActionCoin, CallbackMsg}, - ExecuteMsg, - }, + credit_manager::{ActionAmount, ActionCoin, CallbackMsg, ExecuteMsg}, }; use crate::{ + error::{ContractError, ContractResult}, state::{COIN_BALANCES, ORACLE, PARAMS}, utils::{assert_coin_is_whitelisted, decrement_coin_balance}, vault::{ diff --git a/contracts/credit-manager/src/vault/exit.rs b/contracts/credit-manager/src/vault/exit.rs index e1b134077..d02a7860f 100644 --- a/contracts/credit-manager/src/vault/exit.rs +++ b/contracts/credit-manager/src/vault/exit.rs @@ -1,14 +1,13 @@ use cosmwasm_std::{to_binary, CosmosMsg, DepsMut, Env, Response, Uint128, WasmMsg}; -use mars_rover::{ +use mars_types::{ adapters::vault::{UpdateType, Vault, VaultPositionUpdate}, - error::ContractResult, - msg::{ - execute::{CallbackMsg, ChangeExpected}, - ExecuteMsg as RoverExecuteMsg, - }, + credit_manager::{CallbackMsg, ChangeExpected, ExecuteMsg as RoverExecuteMsg}, }; -use crate::vault::utils::{query_withdraw_denom_balance, update_vault_position}; +use crate::{ + error::ContractResult, + vault::utils::{query_withdraw_denom_balance, update_vault_position}, +}; pub fn exit_vault( deps: DepsMut, diff --git a/contracts/credit-manager/src/vault/exit_unlocked.rs b/contracts/credit-manager/src/vault/exit_unlocked.rs index de1a43fbf..1bc017856 100644 --- a/contracts/credit-manager/src/vault/exit_unlocked.rs +++ b/contracts/credit-manager/src/vault/exit_unlocked.rs @@ -1,15 +1,12 @@ use cosmwasm_std::{to_binary, CosmosMsg, DepsMut, Env, Response, WasmMsg}; use cw_vault_standard::extensions::lockup::UnlockingPosition; -use mars_rover::{ - adapters::vault::{UnlockingChange, Vault, VaultPositionUpdate}, - error::{ContractError, ContractResult}, - msg::{ - execute::{CallbackMsg, ChangeExpected}, - ExecuteMsg, - }, +use mars_types::{ + adapters::vault::{UnlockingChange, Vault, VaultError, VaultPositionUpdate}, + credit_manager::{CallbackMsg, ChangeExpected, ExecuteMsg}, }; use crate::{ + error::{ContractError, ContractResult}, state::VAULT_POSITIONS, vault::utils::{query_withdraw_denom_balance, update_vault_position}, }; @@ -24,7 +21,7 @@ pub fn exit_vault_unlocked( let vault_position = VAULT_POSITIONS.load(deps.storage, (account_id, vault.address.clone()))?; let matching_unlock = vault_position .get_unlocking_position(position_id) - .ok_or_else(|| ContractError::NoPositionMatch(position_id.to_string()))?; + .ok_or_else(|| VaultError::NoPositionMatch(position_id.to_string()))?; let UnlockingPosition { release_at, .. diff --git a/contracts/credit-manager/src/vault/liquidate_vault.rs b/contracts/credit-manager/src/vault/liquidate_vault.rs index 0084d91d7..d3c34371c 100644 --- a/contracts/credit-manager/src/vault/liquidate_vault.rs +++ b/contracts/credit-manager/src/vault/liquidate_vault.rs @@ -2,17 +2,15 @@ use std::cmp::min; use cosmwasm_std::{Coin, Decimal, DepsMut, Env, Response, Uint128}; use cw_vault_standard::VaultInfoResponse; -use mars_rover::{ - adapters::vault::{ - UnlockingChange, UnlockingPositions, UpdateType, Vault, VaultPositionAmount, - VaultPositionType, VaultPositionUpdate, - }, - error::{ContractError, ContractResult}, +use mars_types::adapters::vault::{ + UnlockingChange, UnlockingPositions, UpdateType, Vault, VaultError, VaultPositionAmount, + VaultPositionType, VaultPositionUpdate, }; use crate::{ - liquidate::calculate_liquidation, liquidate_deposit::repay_debt, state::VAULT_POSITIONS, - utils::update_balance_after_vault_liquidation_msg, vault::update_vault_position, + error::ContractResult, liquidate::calculate_liquidation, liquidate_deposit::repay_debt, + state::VAULT_POSITIONS, utils::update_balance_after_vault_liquidation_msg, + vault::update_vault_position, }; pub fn liquidate_vault( @@ -38,7 +36,7 @@ pub fn liquidate_vault( request_vault, a.total(), ), - _ => Err(ContractError::MismatchedVaultType), + _ => Err(VaultError::MismatchedVaultType.into()), }, VaultPositionAmount::Locking(ref a) => match position_type { VaultPositionType::LOCKED => liquidate_locked( @@ -59,7 +57,7 @@ pub fn liquidate_vault( request_vault, liquidatee_position.unlocking(), ), - _ => Err(ContractError::MismatchedVaultType), + _ => Err(VaultError::MismatchedVaultType.into()), }, } } diff --git a/contracts/credit-manager/src/vault/request_unlock.rs b/contracts/credit-manager/src/vault/request_unlock.rs index 59cb0dafe..95c134f88 100644 --- a/contracts/credit-manager/src/vault/request_unlock.rs +++ b/contracts/credit-manager/src/vault/request_unlock.rs @@ -1,14 +1,14 @@ use cosmwasm_schema::cw_serde; use cosmwasm_std::{Addr, Coin, DepsMut, Reply, Response, Uint128}; -use mars_rover::{ +use mars_types::{ adapters::vault::{ UnlockingChange, UpdateType, Vault, VaultBase, VaultPositionUpdate, VaultUnlockingPosition, }, - error::{ContractError, ContractResult}, - extensions::AttrParse, + credit_manager::AttrParse, }; use crate::{ + error::{ContractError, ContractResult}, state::VAULT_REQUEST_TEMP_STORAGE, vault::{ assert_under_max_unlocking_limit, diff --git a/contracts/credit-manager/src/vault/utils.rs b/contracts/credit-manager/src/vault/utils.rs index d794d7905..29cec72bd 100644 --- a/contracts/credit-manager/src/vault/utils.rs +++ b/contracts/credit-manager/src/vault/utils.rs @@ -1,14 +1,12 @@ use cosmwasm_std::{Addr, Coin, Deps, DepsMut, StdResult, Storage, Uint128}; -use mars_red_bank_types::oracle::ActionKind; -use mars_rover::{ - adapters::vault::{ - LockingVaultAmount, UnlockingPositions, Vault, VaultAmount, VaultPosition, - VaultPositionAmount, VaultPositionUpdate, - }, - error::{ContractError, ContractResult}, +use mars_types::adapters::vault::{ + LockingVaultAmount, UnlockingPositions, Vault, VaultAmount, VaultPosition, VaultPositionAmount, + VaultPositionUpdate, }; +use mars_types::oracle::ActionKind; use crate::{ + error::{ContractError, ContractResult}, state::{MAX_UNLOCKING_POSITIONS, ORACLE, PARAMS, VAULT_POSITIONS}, update_coin_balances::query_balance, }; diff --git a/contracts/credit-manager/src/withdraw.rs b/contracts/credit-manager/src/withdraw.rs index 89d3f9ec2..fd68637ac 100644 --- a/contracts/credit-manager/src/withdraw.rs +++ b/contracts/credit-manager/src/withdraw.rs @@ -1,11 +1,12 @@ use cosmwasm_std::{Addr, BankMsg, Coin, CosmosMsg, Deps, DepsMut, Response}; -use mars_rover::{ +use mars_types::credit_manager::{ActionAmount, ActionCoin}; + +use crate::{ error::{ContractError, ContractResult}, - msg::execute::{ActionAmount, ActionCoin}, + state::COIN_BALANCES, + utils::decrement_coin_balance, }; -use crate::{state::COIN_BALANCES, utils::decrement_coin_balance}; - pub fn withdraw( deps: DepsMut, account_id: &str, diff --git a/contracts/credit-manager/src/zap.rs b/contracts/credit-manager/src/zap.rs index 5f375ca54..8c7b7d3bb 100644 --- a/contracts/credit-manager/src/zap.rs +++ b/contracts/credit-manager/src/zap.rs @@ -1,13 +1,13 @@ use cosmwasm_std::{ CheckedMultiplyFractionError, Coin, Decimal, Deps, DepsMut, Env, Response, Uint128, }; -use mars_rover::{ - error::{ContractError, ContractResult}, - msg::execute::{ActionAmount, ActionCoin, ChangeExpected}, +use mars_types::{ + credit_manager::{ActionAmount, ActionCoin, ChangeExpected}, traits::{Denoms, Stringify}, }; use crate::{ + error::{ContractError, ContractResult}, state::{COIN_BALANCES, ZAPPER}, utils::{ assert_coin_is_whitelisted, assert_coins_are_whitelisted, assert_slippage, diff --git a/contracts/credit-manager/tests/helpers/assertions.rs b/contracts/credit-manager/tests/helpers/assertions.rs index 7009ce4ee..15091d492 100644 --- a/contracts/credit-manager/tests/helpers/assertions.rs +++ b/contracts/credit-manager/tests/helpers/assertions.rs @@ -2,8 +2,7 @@ use std::hash::Hash; use anyhow::Result as AnyResult; use cw_multi_test::AppResponse; -use mars_credit_manager::utils::contents_equal; -use mars_rover::error::ContractError; +use mars_credit_manager::{error::ContractError, utils::contents_equal}; pub fn assert_err(res: AnyResult, err: ContractError) { match res { diff --git a/contracts/credit-manager/tests/helpers/builders.rs b/contracts/credit-manager/tests/helpers/builders.rs index 476d2f926..fac7e2760 100644 --- a/contracts/credit-manager/tests/helpers/builders.rs +++ b/contracts/credit-manager/tests/helpers/builders.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{coin, Decimal}; use cw_utils::Duration; -use mars_red_bank_types::params::LiquidationBonus; +use mars_types::params::LiquidationBonus; use crate::helpers::{lp_token_info, CoinInfo, VaultTestInfo}; diff --git a/contracts/credit-manager/tests/helpers/mock_entity_info.rs b/contracts/credit-manager/tests/helpers/mock_entity_info.rs index 67953a2b2..237d2c934 100644 --- a/contracts/credit-manager/tests/helpers/mock_entity_info.rs +++ b/contracts/credit-manager/tests/helpers/mock_entity_info.rs @@ -2,7 +2,7 @@ use std::str::FromStr; use cosmwasm_std::{coin, Decimal}; use cw_utils::Duration; -use mars_red_bank_types::params::{HlsAssetType, HlsParamsUnchecked, LiquidationBonus}; +use mars_types::params::{HlsAssetType, HlsParamsUnchecked, LiquidationBonus}; use crate::helpers::{CoinInfo, VaultTestInfo}; diff --git a/contracts/credit-manager/tests/helpers/mock_env.rs b/contracts/credit-manager/tests/helpers/mock_env.rs index 486e755ba..f9752548a 100644 --- a/contracts/credit-manager/tests/helpers/mock_env.rs +++ b/contracts/credit-manager/tests/helpers/mock_env.rs @@ -9,12 +9,6 @@ use cw_vault_standard::{ extensions::lockup::{LockupQueryMsg, UnlockingPosition}, msg::{ExtensionQueryMsg, VaultStandardQueryMsg::VaultExtension}, }; -use mars_account_nft_types::{ - msg::{ - ExecuteMsg as NftExecuteMsg, InstantiateMsg as NftInstantiateMsg, QueryMsg as NftQueryMsg, - }, - nft_config::{NftConfigUpdates, UncheckedNftConfig}, -}; use mars_mock_oracle::msg::{ CoinPrice, ExecuteMsg as OracleExecuteMsg, InstantiateMsg as OracleInstantiateMsg, }; @@ -22,24 +16,11 @@ use mars_mock_vault::{ contract::DEFAULT_VAULT_TOKEN_PREFUND, msg::InstantiateMsg as VaultInstantiateMsg, }; use mars_owner::OwnerUpdate; -use mars_red_bank_types::{ - address_provider::{self, MarsAddressType}, - incentives::{ExecuteMsg::BalanceChange, QueryMsg::UserUnclaimedRewards}, - oracle::ActionKind, - params::{ - AssetParams, AssetParamsUpdate, - AssetParamsUpdate::AddOrUpdate, - ExecuteMsg::{UpdateAssetParams, UpdateVaultConfig}, - InstantiateMsg as ParamsInstantiateMsg, QueryMsg as ParamsQueryMsg, VaultConfig, - VaultConfigUnchecked, VaultConfigUpdate, - }, - red_bank::{ - self, InitOrUpdateAssetParams, InterestRateModel, - QueryMsg::{UserCollateral, UserDebt}, - UserCollateralResponse, UserDebtResponse, +use mars_types::{ + account_nft::{ + ExecuteMsg as NftExecuteMsg, InstantiateMsg as NftInstantiateMsg, NftConfigUpdates, + QueryMsg as NftQueryMsg, UncheckedNftConfig, }, -}; -use mars_rover::{ adapters::{ account_nft::AccountNftUnchecked, health::HealthContract, @@ -54,7 +35,8 @@ use mars_rover::{ vault::{Vault, VaultPosition, VaultPositionValue as VPositionValue, VaultUnchecked}, zapper::{Zapper, ZapperBase}, }, - msg::{ + address_provider::{self, MarsAddressType}, + credit_manager::{ execute::{Action, CallbackMsg}, instantiate::ConfigUpdates, query::{ @@ -64,10 +46,24 @@ use mars_rover::{ ExecuteMsg, InstantiateMsg, QueryMsg, QueryMsg::{EstimateProvideLiquidity, VaultPositionValue}, }, -}; -use mars_rover_health_types::{ - AccountKind, ExecuteMsg::UpdateConfig, HealthValuesResponse, - InstantiateMsg as HealthInstantiateMsg, QueryMsg::HealthValues, + health::{ + AccountKind, ExecuteMsg::UpdateConfig, HealthValuesResponse, + InstantiateMsg as HealthInstantiateMsg, QueryMsg::HealthValues, + }, + incentives::{ExecuteMsg::BalanceChange, QueryMsg::UserUnclaimedRewards}, + oracle::ActionKind, + params::{ + AssetParams, AssetParamsUpdate, + AssetParamsUpdate::AddOrUpdate, + ExecuteMsg::{UpdateAssetParams, UpdateVaultConfig}, + InstantiateMsg as ParamsInstantiateMsg, QueryMsg as ParamsQueryMsg, VaultConfig, + VaultConfigUnchecked, VaultConfigUpdate, + }, + red_bank::{ + self, InitOrUpdateAssetParams, InterestRateModel, + QueryMsg::{UserCollateral, UserDebt}, + UserCollateralResponse, UserDebtResponse, + }, }; use mars_zapper_mock::msg::{InstantiateMsg as ZapperInstantiateMsg, LpConfig}; diff --git a/contracts/credit-manager/tests/helpers/types.rs b/contracts/credit-manager/tests/helpers/types.rs index de1725675..8219f053d 100644 --- a/contracts/credit-manager/tests/helpers/types.rs +++ b/contracts/credit-manager/tests/helpers/types.rs @@ -1,10 +1,12 @@ use cosmwasm_schema::cw_serde; use cosmwasm_std::{coin, Addr, Coin, Decimal, Uint128}; use cw_utils::Duration; -use mars_red_bank_types::params::{ - AssetParamsUnchecked, CmSettings, HlsParamsUnchecked, LiquidationBonus, RedBankSettings, +use mars_types::{ + credit_manager::{ActionAmount, ActionCoin}, + params::{ + AssetParamsUnchecked, CmSettings, HlsParamsUnchecked, LiquidationBonus, RedBankSettings, + }, }; -use mars_rover::msg::execute::{ActionAmount, ActionCoin}; #[cw_serde] pub struct AccountToFund { diff --git a/contracts/credit-manager/tests/helpers/utils.rs b/contracts/credit-manager/tests/helpers/utils.rs index 967ea80df..0f655ba98 100644 --- a/contracts/credit-manager/tests/helpers/utils.rs +++ b/contracts/credit-manager/tests/helpers/utils.rs @@ -1,5 +1,5 @@ use cosmwasm_std::Coin; -use mars_rover::msg::query::DebtAmount; +use mars_types::credit_manager::DebtAmount; pub fn get_coin(denom: &str, coins: &[Coin]) -> Coin { coins.iter().find(|cv| cv.denom == denom).unwrap().clone() diff --git a/contracts/credit-manager/tests/test_borrow.rs b/contracts/credit-manager/tests/test_borrow.rs index 6f520c16e..0d454eae7 100644 --- a/contracts/credit-manager/tests/test_borrow.rs +++ b/contracts/credit-manager/tests/test_borrow.rs @@ -1,11 +1,8 @@ use std::ops::{Mul, Sub}; use cosmwasm_std::{coin, coins, Addr, Uint128}; -use mars_credit_manager::borrow::DEFAULT_DEBT_SHARES_PER_COIN_BORROWED; -use mars_rover::{ - error::ContractError, - msg::execute::Action::{Borrow, Deposit}, -}; +use mars_credit_manager::{borrow::DEFAULT_DEBT_SHARES_PER_COIN_BORROWED, error::ContractError}; +use mars_types::credit_manager::Action::{Borrow, Deposit}; use crate::helpers::{ assert_err, blacklisted_coin, uosmo_info, AccountToFund, MockEnv, DEFAULT_RED_BANK_COIN_BALANCE, diff --git a/contracts/credit-manager/tests/test_claim_rewards.rs b/contracts/credit-manager/tests/test_claim_rewards.rs index a5506fe57..3f9577df8 100644 --- a/contracts/credit-manager/tests/test_claim_rewards.rs +++ b/contracts/credit-manager/tests/test_claim_rewards.rs @@ -1,8 +1,8 @@ use cosmwasm_std::{Addr, Uint128}; -use mars_red_bank_types::params::{AssetParamsUpdate::AddOrUpdate, HlsAssetType}; -use mars_rover::{ - error::ContractError, - msg::execute::Action::{Borrow, ClaimRewards, Deposit}, +use mars_credit_manager::error::ContractError; +use mars_types::{ + credit_manager::Action::{Borrow, ClaimRewards, Deposit}, + params::{AssetParamsUpdate::AddOrUpdate, HlsAssetType}, }; use crate::helpers::{ diff --git a/contracts/credit-manager/tests/test_coin_balances.rs b/contracts/credit-manager/tests/test_coin_balances.rs index e69ec4db4..0c05e7b6e 100644 --- a/contracts/credit-manager/tests/test_coin_balances.rs +++ b/contracts/credit-manager/tests/test_coin_balances.rs @@ -1,9 +1,7 @@ use cosmwasm_std::{coin, coins, Addr, Uint128}; use cw_multi_test::{BankSudo, SudoMsg}; -use mars_rover::{ - error::ContractError, - msg::execute::{Action::Deposit, CallbackMsg, ChangeExpected}, -}; +use mars_credit_manager::error::ContractError; +use mars_types::credit_manager::{Action::Deposit, CallbackMsg, ChangeExpected}; use crate::helpers::{assert_err, uosmo_info, AccountToFund, MockEnv}; diff --git a/contracts/credit-manager/tests/test_deposit.rs b/contracts/credit-manager/tests/test_deposit.rs index 0c0c2097b..1d41774ca 100644 --- a/contracts/credit-manager/tests/test_deposit.rs +++ b/contracts/credit-manager/tests/test_deposit.rs @@ -1,9 +1,8 @@ -use cosmwasm_std::{coin, coins, Addr, Coin, Uint128}; -use mars_rover::{ - coins::Coins, - error::ContractError::{ExtraFundsReceived, FundsMismatch, NotTokenOwner, NotWhitelisted}, - msg::{execute::Action, query::Positions}, +use cosmwasm_std::{coin, coins, Addr, Coin, Coins, Uint128}; +use mars_credit_manager::error::ContractError::{ + ExtraFundsReceived, FundsMismatch, NotTokenOwner, NotWhitelisted, }; +use mars_types::credit_manager::{Action, Positions}; use crate::helpers::{ assert_err, blacklisted_coin, uatom_info, ujake_info, uosmo_info, AccountToFund, CoinInfo, diff --git a/contracts/credit-manager/tests/test_deposit_cap.rs b/contracts/credit-manager/tests/test_deposit_cap.rs index 858e07fb5..dd2c815fe 100644 --- a/contracts/credit-manager/tests/test_deposit_cap.rs +++ b/contracts/credit-manager/tests/test_deposit_cap.rs @@ -4,10 +4,10 @@ pub mod helpers; use std::collections::HashMap; use cosmwasm_std::{Addr, Coin, Coins, Decimal, StdResult, Uint128}; -use mars_red_bank_types::params::{AssetParams, AssetParamsUpdate}; -use mars_rover::{ - error::ContractError, - msg::execute::{Action, ActionAmount, ActionCoin}, +use mars_credit_manager::error::ContractError; +use mars_types::{ + credit_manager::{Action, ActionAmount, ActionCoin}, + params::{AssetParams, AssetParamsUpdate}, }; use test_case::test_case; diff --git a/contracts/credit-manager/tests/test_dispatch.rs b/contracts/credit-manager/tests/test_dispatch.rs index f46306441..26a8730e7 100644 --- a/contracts/credit-manager/tests/test_dispatch.rs +++ b/contracts/credit-manager/tests/test_dispatch.rs @@ -1,9 +1,7 @@ use cosmwasm_std::{coin, Addr}; use helpers::assert_err; -use mars_rover::{ - error::{ContractError, ContractError::NotTokenOwner}, - msg::execute::CallbackMsg, -}; +use mars_credit_manager::error::{ContractError, ContractError::NotTokenOwner}; +use mars_types::credit_manager::CallbackMsg; use crate::helpers::MockEnv; diff --git a/contracts/credit-manager/tests/test_enumerate_accounts.rs b/contracts/credit-manager/tests/test_enumerate_accounts.rs index c1616ba37..bac6fc157 100644 --- a/contracts/credit-manager/tests/test_enumerate_accounts.rs +++ b/contracts/credit-manager/tests/test_enumerate_accounts.rs @@ -1,6 +1,5 @@ use cosmwasm_std::Addr; -use mars_rover::msg::query::Account; -use mars_rover_health_types::AccountKind; +use mars_types::{credit_manager::Account, health::AccountKind}; use crate::helpers::MockEnv; diff --git a/contracts/credit-manager/tests/test_enumerate_coin_balances.rs b/contracts/credit-manager/tests/test_enumerate_coin_balances.rs index b49a14e51..60ac70fe2 100644 --- a/contracts/credit-manager/tests/test_enumerate_coin_balances.rs +++ b/contracts/credit-manager/tests/test_enumerate_coin_balances.rs @@ -1,5 +1,5 @@ use cosmwasm_std::{coin, Addr, Uint128}; -use mars_rover::msg::{execute::Action, query::CoinBalanceResponseItem}; +use mars_types::credit_manager::{execute::Action, query::CoinBalanceResponseItem}; use crate::helpers::{build_mock_coin_infos, AccountToFund, MockEnv}; diff --git a/contracts/credit-manager/tests/test_enumerate_debt_shares.rs b/contracts/credit-manager/tests/test_enumerate_debt_shares.rs index fe3925d5c..fc94d8acd 100644 --- a/contracts/credit-manager/tests/test_enumerate_debt_shares.rs +++ b/contracts/credit-manager/tests/test_enumerate_debt_shares.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{coin, Addr}; use mars_credit_manager::borrow::DEFAULT_DEBT_SHARES_PER_COIN_BORROWED; -use mars_rover::msg::{execute::Action, query::SharesResponseItem}; +use mars_types::credit_manager::{Action, SharesResponseItem}; use crate::helpers::{build_mock_coin_infos, AccountToFund, MockEnv}; diff --git a/contracts/credit-manager/tests/test_enumerate_total_debt_shares.rs b/contracts/credit-manager/tests/test_enumerate_total_debt_shares.rs index def318920..816806f3e 100644 --- a/contracts/credit-manager/tests/test_enumerate_total_debt_shares.rs +++ b/contracts/credit-manager/tests/test_enumerate_total_debt_shares.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{coin, Addr}; use mars_credit_manager::borrow::DEFAULT_DEBT_SHARES_PER_COIN_BORROWED; -use mars_rover::msg::{execute::Action, query::DebtShares}; +use mars_types::credit_manager::{Action, DebtShares}; use crate::helpers::{build_mock_coin_infos, AccountToFund, MockEnv}; diff --git a/contracts/credit-manager/tests/test_enumerate_vault_positions.rs b/contracts/credit-manager/tests/test_enumerate_vault_positions.rs index a8fcce039..d4a9c1b89 100644 --- a/contracts/credit-manager/tests/test_enumerate_vault_positions.rs +++ b/contracts/credit-manager/tests/test_enumerate_vault_positions.rs @@ -1,6 +1,6 @@ use cosmwasm_std::Addr; use itertools::Itertools; -use mars_rover::msg::execute::Action; +use mars_types::credit_manager::Action; use crate::helpers::{ assert_contents_equal, build_mock_vaults, lp_token_info, AccountToFund, MockEnv, diff --git a/contracts/credit-manager/tests/test_health.rs b/contracts/credit-manager/tests/test_health.rs index dfd968e90..11d3d6201 100644 --- a/contracts/credit-manager/tests/test_health.rs +++ b/contracts/credit-manager/tests/test_health.rs @@ -2,22 +2,22 @@ use std::ops::{Add, Mul}; use cosmwasm_std::{coin, coins, Addr, Coin, Decimal, Uint128}; use mars_credit_manager::borrow::DEFAULT_DEBT_SHARES_PER_COIN_BORROWED; +use mars_credit_manager::error::ContractError; use mars_mock_oracle::msg::CoinPrice; -use mars_red_bank_types::{ - oracle::ActionKind, - params::{AssetParamsUpdate::AddOrUpdate, LiquidationBonus, VaultConfigUpdate}, -}; -use mars_rover::{ - error::ContractError, - msg::{ +use mars_types::{ + credit_manager::{ execute::{ Action::{Borrow, Deposit, EnterVault, Repay, Withdraw}, ActionAmount, ActionCoin, }, query::DebtAmount, }, + health::AccountKind, +}; +use mars_types::{ + oracle::ActionKind, + params::{AssetParamsUpdate::AddOrUpdate, LiquidationBonus, VaultConfigUpdate}, }; -use mars_rover_health_types::AccountKind; use crate::helpers::{ assert_err, lp_token_info, uatom_info, ujake_info, unlocked_vault_info, uosmo_info, diff --git a/contracts/credit-manager/tests/test_hls_accounts.rs b/contracts/credit-manager/tests/test_hls_accounts.rs index ef771cc82..d209194ce 100644 --- a/contracts/credit-manager/tests/test_hls_accounts.rs +++ b/contracts/credit-manager/tests/test_hls_accounts.rs @@ -1,13 +1,11 @@ use cosmwasm_std::{coins, Addr, Decimal, Uint128}; -use mars_red_bank_types::{ +use mars_credit_manager::error::ContractError; +use mars_types::{ + credit_manager::Action::{Borrow, Deposit, EnterVault, Lend}, + health::{AccountKind, HealthValuesResponse}, oracle::ActionKind, params::{AssetParamsUpdate::AddOrUpdate, HlsAssetType}, }; -use mars_rover::{ - error::ContractError, - msg::execute::Action::{Borrow, Deposit, EnterVault, Lend}, -}; -use mars_rover_health_types::{AccountKind, HealthValuesResponse}; use crate::helpers::{ assert_err, lp_token_info, uatom_info, ujake_info, unlocked_vault_info, AccountToFund, MockEnv, diff --git a/contracts/credit-manager/tests/test_lend.rs b/contracts/credit-manager/tests/test_lend.rs index 5f59296a6..d256e1520 100644 --- a/contracts/credit-manager/tests/test_lend.rs +++ b/contracts/credit-manager/tests/test_lend.rs @@ -1,12 +1,10 @@ use std::ops::Add; use cosmwasm_std::{coin, coins, Addr, Coin, OverflowError, OverflowOperation, Uint128}; -use mars_rover::{ - error::ContractError, - msg::execute::{ - Action::{Deposit, Lend}, - ActionAmount, ActionCoin, - }, +use mars_credit_manager::error::ContractError; +use mars_types::credit_manager::{ + Action::{Deposit, Lend}, + ActionAmount, ActionCoin, }; use crate::helpers::{ diff --git a/contracts/credit-manager/tests/test_liquidate_deposit.rs b/contracts/credit-manager/tests/test_liquidate_deposit.rs index 38757d196..3c6901a4a 100644 --- a/contracts/credit-manager/tests/test_liquidate_deposit.rs +++ b/contracts/credit-manager/tests/test_liquidate_deposit.rs @@ -1,17 +1,17 @@ use cosmwasm_std::{coins, Addr, Coin, Decimal, OverflowError, OverflowOperation, Uint128}; +use mars_credit_manager::error::{ + ContractError, + ContractError::{AboveMaxLTV, LiquidationNotProfitable, NotLiquidatable}, +}; use mars_mock_oracle::msg::CoinPrice; -use mars_red_bank_types::oracle::ActionKind; -use mars_rover::{ - error::{ - ContractError, - ContractError::{AboveMaxLTV, LiquidationNotProfitable, NotLiquidatable}, - }, - msg::execute::{ +use mars_types::{ + credit_manager::{ Action::{Borrow, Deposit, EnterVault, Liquidate, Withdraw}, LiquidateRequest, }, + health::AccountKind, + oracle::ActionKind, }; -use mars_rover_health_types::AccountKind; use crate::helpers::{ assert_err, get_coin, get_debt, lp_token_info, uatom_info, ujake_info, unlocked_vault_info, diff --git a/contracts/credit-manager/tests/test_liquidate_guard.rs b/contracts/credit-manager/tests/test_liquidate_guard.rs index 8ff44b5aa..e97f45dd6 100644 --- a/contracts/credit-manager/tests/test_liquidate_guard.rs +++ b/contracts/credit-manager/tests/test_liquidate_guard.rs @@ -1,10 +1,8 @@ use cosmwasm_std::{coins, Addr}; -use mars_rover::{ - error::ContractError, - msg::execute::{ - Action::{Borrow, Deposit, Liquidate}, - LiquidateRequest, - }, +use mars_credit_manager::error::ContractError; +use mars_types::credit_manager::{ + Action::{Borrow, Deposit, Liquidate}, + LiquidateRequest, }; use crate::helpers::{assert_err, uatom_info, uosmo_info, AccountToFund, MockEnv}; diff --git a/contracts/credit-manager/tests/test_liquidate_lend.rs b/contracts/credit-manager/tests/test_liquidate_lend.rs index b53eacc2f..52bd81c51 100644 --- a/contracts/credit-manager/tests/test_liquidate_lend.rs +++ b/contracts/credit-manager/tests/test_liquidate_lend.rs @@ -1,14 +1,14 @@ use cosmwasm_std::{coins, Addr, Decimal, Event, Uint128}; +use mars_credit_manager::error::{ContractError, ContractError::NotLiquidatable}; use mars_mock_oracle::msg::CoinPrice; -use mars_red_bank_types::oracle::ActionKind; -use mars_rover::{ - error::{ContractError, ContractError::NotLiquidatable}, - msg::execute::{ +use mars_types::{ + credit_manager::{ Action::{Borrow, Deposit, Lend, Liquidate}, LiquidateRequest, }, + health::AccountKind, + oracle::ActionKind, }; -use mars_rover_health_types::AccountKind; use crate::helpers::{ assert_err, get_coin, get_debt, uatom_info, ujake_info, uosmo_info, AccountToFund, MockEnv, diff --git a/contracts/credit-manager/tests/test_liquidate_vault.rs b/contracts/credit-manager/tests/test_liquidate_vault.rs index 839208968..0c7bb87bf 100644 --- a/contracts/credit-manager/tests/test_liquidate_vault.rs +++ b/contracts/credit-manager/tests/test_liquidate_vault.rs @@ -1,17 +1,17 @@ use cosmwasm_std::{ Addr, Decimal, OverflowError, OverflowOperation::Sub, StdError::NotFound, Uint128, }; +use mars_credit_manager::error::ContractError; use mars_mock_oracle::msg::CoinPrice; -use mars_red_bank_types::oracle::ActionKind; -use mars_rover::{ - adapters::vault::{VaultBase, VaultPositionType}, - error::ContractError, - msg::execute::{ +use mars_types::{ + adapters::vault::{VaultBase, VaultError, VaultPositionType}, + credit_manager::{ Action::{Borrow, Deposit, EnterVault, Liquidate, RequestVaultUnlock}, LiquidateRequest, }, + health::AccountKind, + oracle::ActionKind, }; -use mars_rover_health_types::AccountKind; use crate::helpers::{ assert_err, get_coin, get_debt, locked_vault_info, lp_token_info, uatom_info, ujake_info, @@ -70,7 +70,7 @@ fn liquidatee_must_have_the_request_vault_position() { assert_err( res, ContractError::Std(NotFound { - kind: "mars_rover::adapters::vault::amount::VaultPositionAmount".to_string(), + kind: "mars_types::adapters::vault::amount::VaultPositionAmount".to_string(), }), ) } @@ -252,7 +252,7 @@ fn wrong_position_type_sent_for_unlocked_vault() { &[], ); - assert_err(res, ContractError::MismatchedVaultType); + assert_err(res, VaultError::MismatchedVaultType.into()); let res = mock.update_credit_account( &liquidator_account_id, @@ -268,7 +268,7 @@ fn wrong_position_type_sent_for_unlocked_vault() { &[], ); - assert_err(res, ContractError::MismatchedVaultType) + assert_err(res, VaultError::MismatchedVaultType.into()) } #[test] @@ -321,7 +321,7 @@ fn wrong_position_type_sent_for_locked_vault() { &[], ); - assert_err(res, ContractError::MismatchedVaultType) + assert_err(res, VaultError::MismatchedVaultType.into()) } #[test] diff --git a/contracts/credit-manager/tests/test_liquidation_pricing.rs b/contracts/credit-manager/tests/test_liquidation_pricing.rs index 33d8c080d..500a5d0fa 100644 --- a/contracts/credit-manager/tests/test_liquidation_pricing.rs +++ b/contracts/credit-manager/tests/test_liquidation_pricing.rs @@ -1,13 +1,11 @@ use cosmwasm_std::{coins, Addr, Coin, Decimal}; +use mars_credit_manager::error::ContractError; use mars_mock_oracle::msg::CoinPrice; -use mars_red_bank_types::oracle::ActionKind; -use mars_rover::{ - error::ContractError, - msg::execute::{ - Action::{Borrow, Deposit, Liquidate}, - LiquidateRequest, - }, +use mars_types::credit_manager::{ + Action::{Borrow, Deposit, Liquidate}, + LiquidateRequest, }; +use mars_types::oracle::ActionKind; use crate::helpers::{assert_err, uatom_info, uosmo_info, AccountToFund, MockEnv}; diff --git a/contracts/credit-manager/tests/test_migration_v2.rs b/contracts/credit-manager/tests/test_migration_v2.rs index d409945bd..dd863b0d6 100644 --- a/contracts/credit-manager/tests/test_migration_v2.rs +++ b/contracts/credit-manager/tests/test_migration_v2.rs @@ -5,19 +5,19 @@ use cosmwasm_std::{ use cw2::VersionError; use mars_credit_manager::{ contract::migrate, + error::ContractError, migrations::v2_0_0::{v1_state, v1_state::OwnerSetNoneProposed}, state::{ ACCOUNT_NFT, HEALTH_CONTRACT, INCENTIVES, MAX_SLIPPAGE, OWNER, PARAMS, RED_BANK, REWARDS_COLLECTOR, SWAPPER, }, }; -use mars_rover::{ +use mars_types::{ adapters::{ health::HealthContractUnchecked, incentives::IncentivesUnchecked, params::ParamsUnchecked, swap::SwapperUnchecked, }, - error::ContractError, - msg::{migrate::V2Updates, MigrateMsg}, + credit_manager::{migrate::V2Updates, MigrateMsg}, }; pub mod helpers; diff --git a/contracts/credit-manager/tests/test_no_health_check.rs b/contracts/credit-manager/tests/test_no_health_check.rs index 28c402768..90556a213 100644 --- a/contracts/credit-manager/tests/test_no_health_check.rs +++ b/contracts/credit-manager/tests/test_no_health_check.rs @@ -1,11 +1,11 @@ use cosmwasm_std::{coin, coins, Addr, StdError, Uint128}; -use mars_red_bank_types::oracle::ActionKind; -use mars_rover::{ - error::ContractError, - msg::execute::{ +use mars_credit_manager::error::ContractError; +use mars_types::{ + credit_manager::{ Action::{Borrow, Deposit, Repay, Withdraw}, ActionAmount, ActionCoin, }, + oracle::ActionKind, }; use crate::helpers::{assert_err, get_coin, get_debt, uosmo_info, AccountToFund, MockEnv}; diff --git a/contracts/credit-manager/tests/test_reclaim.rs b/contracts/credit-manager/tests/test_reclaim.rs index 68be2ff20..3cc5e9afa 100644 --- a/contracts/credit-manager/tests/test_reclaim.rs +++ b/contracts/credit-manager/tests/test_reclaim.rs @@ -1,8 +1,6 @@ use cosmwasm_std::{coin, coins, Addr, Event, Uint128}; -use mars_rover::{ - error::ContractError, - msg::execute::Action::{Deposit, Lend, Reclaim}, -}; +use mars_credit_manager::error::ContractError; +use mars_types::credit_manager::Action::{Deposit, Lend, Reclaim}; use crate::helpers::{assert_err, get_coin, uatom_info, uosmo_info, AccountToFund, MockEnv}; diff --git a/contracts/credit-manager/tests/test_reentrancy_guard.rs b/contracts/credit-manager/tests/test_reentrancy_guard.rs index d922d5347..a93fe16b1 100644 --- a/contracts/credit-manager/tests/test_reentrancy_guard.rs +++ b/contracts/credit-manager/tests/test_reentrancy_guard.rs @@ -1,11 +1,10 @@ use cosmwasm_std::Addr; -use mars_rover::{ - error::ContractError, - msg::execute::{ - Action::{Deposit, EnterVault}, - CallbackMsg, - }, +use mars_credit_manager::error::ContractError; +use mars_types::credit_manager::{ + Action::{Deposit, EnterVault}, + CallbackMsg, }; +use mars_utils::error::GuardError; use crate::helpers::{assert_err, lp_token_info, unlocked_vault_info, AccountToFund, MockEnv}; @@ -46,7 +45,7 @@ fn reentrancy_guard_protects_against_evil_vault() { &[lp_token.to_coin(200)], ); - assert_err(res, ContractError::ReentrancyGuard("Reentrancy guard is active".to_string())); + assert_err(res, GuardError::Active {}.into()); } #[test] @@ -62,8 +61,5 @@ fn only_credit_manager_can_remove_guard() { fn removing_while_inactive() { let mut mock = MockEnv::new().build().unwrap(); let res = mock.execute_callback(&mock.rover.clone(), CallbackMsg::RemoveReentrancyGuard {}); - assert_err( - res, - ContractError::ReentrancyGuard("Invalid reentrancy guard state transition".to_string()), - ); + assert_err(res, GuardError::InvalidState {}.into()); } diff --git a/contracts/credit-manager/tests/test_refund_balances.rs b/contracts/credit-manager/tests/test_refund_balances.rs index fb3dc2216..4efd8ffa9 100644 --- a/contracts/credit-manager/tests/test_refund_balances.rs +++ b/contracts/credit-manager/tests/test_refund_balances.rs @@ -1,5 +1,5 @@ use cosmwasm_std::{coin, Addr, Uint128}; -use mars_rover::msg::execute::Action::{Deposit, EnterVault, RefundAllCoinBalances}; +use mars_types::credit_manager::Action::{Deposit, EnterVault, RefundAllCoinBalances}; use crate::helpers::{ locked_vault_info, lp_token_info, uatom_info, uosmo_info, AccountToFund, MockEnv, diff --git a/contracts/credit-manager/tests/test_repay.rs b/contracts/credit-manager/tests/test_repay.rs index 12ccb54bc..edc19091f 100644 --- a/contracts/credit-manager/tests/test_repay.rs +++ b/contracts/credit-manager/tests/test_repay.rs @@ -1,11 +1,10 @@ use std::ops::{Add, Mul, Sub}; use cosmwasm_std::{coin, coins, Addr, Decimal, OverflowError, OverflowOperation, Uint128}; -use mars_credit_manager::borrow::DEFAULT_DEBT_SHARES_PER_COIN_BORROWED; -use mars_red_bank_types::params::LiquidationBonus; -use mars_rover::{ - error::ContractError, - msg::execute::Action::{Borrow, Deposit, Repay, Withdraw}, +use mars_credit_manager::{borrow::DEFAULT_DEBT_SHARES_PER_COIN_BORROWED, error::ContractError}; +use mars_types::{ + credit_manager::Action::{Borrow, Deposit, Repay, Withdraw}, + params::LiquidationBonus, }; use crate::helpers::{ diff --git a/contracts/credit-manager/tests/test_repay_for_recipient.rs b/contracts/credit-manager/tests/test_repay_for_recipient.rs index d11d65b74..e5c910a00 100644 --- a/contracts/credit-manager/tests/test_repay_for_recipient.rs +++ b/contracts/credit-manager/tests/test_repay_for_recipient.rs @@ -1,12 +1,10 @@ use std::ops::{Add, Sub}; use cosmwasm_std::{coin, coins, Addr, OverflowError, OverflowOperation, Uint128}; -use mars_rover::{ - error::ContractError, - msg::execute::{ - Action::{Borrow, Deposit, Repay}, - ActionAmount, ActionCoin, CallbackMsg, - }, +use mars_credit_manager::error::ContractError; +use mars_types::credit_manager::{ + Action::{Borrow, Deposit, Repay}, + ActionAmount, ActionCoin, CallbackMsg, }; use crate::helpers::{ diff --git a/contracts/credit-manager/tests/test_repay_from_wallet.rs b/contracts/credit-manager/tests/test_repay_from_wallet.rs index fe921c841..262bd3502 100644 --- a/contracts/credit-manager/tests/test_repay_from_wallet.rs +++ b/contracts/credit-manager/tests/test_repay_from_wallet.rs @@ -1,9 +1,9 @@ use cosmwasm_std::{coin, coins, Addr, Uint128}; use cw_utils::PaymentError; -use mars_red_bank_types::params::AssetParamsUpdate::AddOrUpdate; -use mars_rover::{ - error::ContractError, - msg::execute::Action::{Borrow, Deposit}, +use mars_credit_manager::error::ContractError; +use mars_types::{ + credit_manager::Action::{Borrow, Deposit}, + params::AssetParamsUpdate::AddOrUpdate, }; use crate::helpers::{assert_err, uosmo_info, AccountToFund, MockEnv}; diff --git a/contracts/credit-manager/tests/test_swap.rs b/contracts/credit-manager/tests/test_swap.rs index d232aecb1..5e867a1e9 100644 --- a/contracts/credit-manager/tests/test_swap.rs +++ b/contracts/credit-manager/tests/test_swap.rs @@ -1,14 +1,12 @@ use std::str::FromStr; use cosmwasm_std::{coins, Addr, Coin, Decimal, OverflowError, OverflowOperation::Sub, Uint128}; -use mars_rover::{ - error::ContractError, - msg::execute::{ - Action::{Deposit, SwapExactIn}, - ActionAmount, ActionCoin, - }, -}; +use mars_credit_manager::error::ContractError; use mars_swapper_mock::contract::MOCK_SWAP_RESULT; +use mars_types::credit_manager::{ + Action::{Deposit, SwapExactIn}, + ActionAmount, ActionCoin, +}; use crate::helpers::{ assert_err, blacklisted_coin, uatom_info, uosmo_info, AccountToFund, MockEnv, diff --git a/contracts/credit-manager/tests/test_update_admin.rs b/contracts/credit-manager/tests/test_update_admin.rs index 096e3b758..17d201939 100644 --- a/contracts/credit-manager/tests/test_update_admin.rs +++ b/contracts/credit-manager/tests/test_update_admin.rs @@ -1,9 +1,9 @@ use cosmwasm_std::Addr; +use mars_credit_manager::error::ContractError::Owner; use mars_owner::{ OwnerError::{NotOwner, NotProposedOwner, StateTransitionError}, OwnerUpdate, }; -use mars_rover::error::ContractError::Owner; use crate::helpers::{assert_err, MockEnv}; diff --git a/contracts/credit-manager/tests/test_update_config.rs b/contracts/credit-manager/tests/test_update_config.rs index ff29e9336..e93ac4556 100644 --- a/contracts/credit-manager/tests/test_update_config.rs +++ b/contracts/credit-manager/tests/test_update_config.rs @@ -1,18 +1,18 @@ use cosmwasm_std::{Addr, Decimal, Empty, Uint128}; use cw_multi_test::{BasicApp, Executor}; use helpers::assert_err; +use mars_credit_manager::error::ContractError; use mars_mock_oracle::msg::{CoinPrice, InstantiateMsg as OracleInstantiateMsg}; -use mars_red_bank_types::oracle::ActionKind; -use mars_rover::{ +use mars_types::{ adapters::{ health::HealthContractUnchecked, incentives::IncentivesUnchecked, oracle::OracleUnchecked, red_bank::RedBankUnchecked, rewards_collector::RewardsCollector, swap::SwapperBase, zapper::ZapperBase, }, - error::ContractError, - msg::instantiate::ConfigUpdates, + credit_manager::ConfigUpdates, + health::AccountKind, + oracle::ActionKind, }; -use mars_rover_health_types::AccountKind; use crate::helpers::{mock_oracle_contract, mock_red_bank_contract, MockEnv}; diff --git a/contracts/credit-manager/tests/test_update_nft_config.rs b/contracts/credit-manager/tests/test_update_nft_config.rs index 91ca470e9..dabd883f2 100644 --- a/contracts/credit-manager/tests/test_update_nft_config.rs +++ b/contracts/credit-manager/tests/test_update_nft_config.rs @@ -2,9 +2,9 @@ extern crate core; use cosmwasm_std::{Addr, Uint128}; use cw_multi_test::Executor; -use mars_account_nft_types::{msg::ExecuteMsg, nft_config::NftConfigUpdates}; +use mars_credit_manager::error::ContractError; use mars_owner::OwnerError::NotOwner; -use mars_rover::error::ContractError; +use mars_types::account_nft::{ExecuteMsg, NftConfigUpdates}; use crate::helpers::{assert_err, MockEnv}; diff --git a/contracts/credit-manager/tests/test_utilization_query.rs b/contracts/credit-manager/tests/test_utilization_query.rs index 05dad965f..47fa483fa 100644 --- a/contracts/credit-manager/tests/test_utilization_query.rs +++ b/contracts/credit-manager/tests/test_utilization_query.rs @@ -1,14 +1,14 @@ use std::str::FromStr; use cosmwasm_std::{Addr, Decimal, Uint128}; -use mars_red_bank_types::params::LiquidationBonus; -use mars_rover::{ +use mars_types::{ adapters::vault::VaultUnchecked, - msg::execute::{ + credit_manager::{ Action::{Deposit, EnterVault}, ActionAmount::Exact, ActionCoin, }, + params::LiquidationBonus, }; use crate::helpers::{ diff --git a/contracts/credit-manager/tests/test_vault_enter.rs b/contracts/credit-manager/tests/test_vault_enter.rs index 0dc8cc39e..da8ed44ec 100644 --- a/contracts/credit-manager/tests/test_vault_enter.rs +++ b/contracts/credit-manager/tests/test_vault_enter.rs @@ -1,11 +1,11 @@ use cosmwasm_std::{ coin, Addr, Decimal, OverflowError, OverflowOperation::Sub, StdError::NotFound, Uint128, }; +use mars_credit_manager::error::ContractError; use mars_mock_vault::contract::STARTING_VAULT_SHARES; -use mars_rover::{ +use mars_types::{ adapters::vault::VaultBase, - error::ContractError, - msg::execute::{ + credit_manager::{ Action::{Deposit, EnterVault}, ActionAmount, ActionCoin, }, diff --git a/contracts/credit-manager/tests/test_vault_exit.rs b/contracts/credit-manager/tests/test_vault_exit.rs index 5f621dda1..0473ba324 100644 --- a/contracts/credit-manager/tests/test_vault_exit.rs +++ b/contracts/credit-manager/tests/test_vault_exit.rs @@ -1,10 +1,10 @@ use cosmwasm_std::{coin, Addr, Coin, OverflowError, OverflowOperation::Sub, Uint128}; +use mars_credit_manager::error::ContractError::NotTokenOwner; use mars_mock_vault::contract::STARTING_VAULT_SHARES; -use mars_red_bank_types::params::VaultConfigUpdate; -use mars_rover::{ - adapters::vault::VaultBase, - error::{ContractError, ContractError::NotTokenOwner}, - msg::execute::Action::{Deposit, EnterVault, ExitVault}, +use mars_types::{ + adapters::vault::{VaultBase, VaultError}, + credit_manager::Action::{Deposit, EnterVault, ExitVault}, + params::VaultConfigUpdate, }; use crate::helpers::{ @@ -78,11 +78,12 @@ fn no_unlocked_vault_coins_to_withdraw() { assert_err( res, - ContractError::Overflow(OverflowError { + VaultError::from(OverflowError { operation: Sub, operand1: "0".to_string(), operand2: STARTING_VAULT_SHARES.to_string(), - }), + }) + .into(), ) } diff --git a/contracts/credit-manager/tests/test_vault_exit_unlocked.rs b/contracts/credit-manager/tests/test_vault_exit_unlocked.rs index bb7f2b988..04308a8da 100644 --- a/contracts/credit-manager/tests/test_vault_exit_unlocked.rs +++ b/contracts/credit-manager/tests/test_vault_exit_unlocked.rs @@ -1,13 +1,14 @@ use cosmwasm_std::{Addr, Uint128}; use cw_utils::Duration; +use mars_credit_manager::error::ContractError; use mars_mock_vault::contract::STARTING_VAULT_SHARES; -use mars_red_bank_types::params::VaultConfigUpdate; -use mars_rover::{ - error::ContractError, - msg::{ +use mars_types::{ + adapters::vault::VaultError, + credit_manager::{ execute::Action::{Deposit, EnterVault, ExitVaultUnlocked, RequestVaultUnlock}, query::Positions, }, + params::VaultConfigUpdate, }; use crate::helpers::{ @@ -116,7 +117,7 @@ fn not_owner_of_unlocking_position() { &[lp_token.to_coin(2)], ); - assert_err(res, ContractError::NoPositionMatch(lockup_id.to_string())); + assert_err(res, VaultError::NoPositionMatch(lockup_id.to_string()).into()); } #[test] diff --git a/contracts/credit-manager/tests/test_vault_query_value.rs b/contracts/credit-manager/tests/test_vault_query_value.rs index 0a034810b..90795850b 100644 --- a/contracts/credit-manager/tests/test_vault_query_value.rs +++ b/contracts/credit-manager/tests/test_vault_query_value.rs @@ -2,9 +2,9 @@ use std::ops::Div; use cosmwasm_std::{Addr, Uint128}; use mars_mock_vault::contract::STARTING_VAULT_SHARES; -use mars_rover::{ +use mars_types::{ adapters::vault::{Vault, VaultAmount, VaultPosition, VaultPositionAmount}, - msg::execute::Action::{Deposit, EnterVault, RequestVaultUnlock}, + credit_manager::Action::{Deposit, EnterVault, RequestVaultUnlock}, }; use crate::helpers::{ diff --git a/contracts/credit-manager/tests/test_vault_request_unlock.rs b/contracts/credit-manager/tests/test_vault_request_unlock.rs index 4d8858e83..64b596825 100644 --- a/contracts/credit-manager/tests/test_vault_request_unlock.rs +++ b/contracts/credit-manager/tests/test_vault_request_unlock.rs @@ -1,11 +1,11 @@ use cosmwasm_std::{coins, Addr, OverflowError, OverflowOperation::Sub, Uint128}; use cw_multi_test::{BankSudo, SudoMsg}; use cw_utils::{Duration, Expiration}; +use mars_credit_manager::error::ContractError; use mars_mock_vault::contract::STARTING_VAULT_SHARES; -use mars_rover::{ - adapters::vault::VaultUnchecked, - error::ContractError, - msg::execute::Action::{Deposit, EnterVault, RequestVaultUnlock}, +use mars_types::{ + adapters::vault::{VaultError, VaultUnchecked}, + credit_manager::Action::{Deposit, EnterVault, RequestVaultUnlock}, }; use crate::helpers::{ @@ -123,11 +123,12 @@ fn no_vault_tokens_for_request() { assert_err( res, - ContractError::Overflow(OverflowError { + VaultError::Overflow(OverflowError { operation: Sub, operand1: "0".to_string(), operand2: STARTING_VAULT_SHARES.to_string(), - }), + }) + .into(), ); } @@ -177,11 +178,12 @@ fn not_enough_vault_tokens_for_request() { assert_err( res, - ContractError::Overflow(OverflowError { + VaultError::Overflow(OverflowError { operation: Sub, operand1: STARTING_VAULT_SHARES.to_string(), operand2: (STARTING_VAULT_SHARES + Uint128::new(100)).to_string(), - }), + }) + .into(), ); } diff --git a/contracts/credit-manager/tests/test_withdraw.rs b/contracts/credit-manager/tests/test_withdraw.rs index 0c09a7cde..c3c2c3f06 100644 --- a/contracts/credit-manager/tests/test_withdraw.rs +++ b/contracts/credit-manager/tests/test_withdraw.rs @@ -1,8 +1,6 @@ use cosmwasm_std::{coin, coins, Addr, Coin, OverflowError, OverflowOperation::Sub, Uint128}; -use mars_rover::{ - error::{ContractError, ContractError::NotTokenOwner}, - msg::execute::Action, -}; +use mars_credit_manager::error::{ContractError, ContractError::NotTokenOwner}; +use mars_types::credit_manager::Action; use crate::helpers::{assert_err, uatom_info, uosmo_info, AccountToFund, MockEnv}; diff --git a/contracts/credit-manager/tests/test_zap_provide.rs b/contracts/credit-manager/tests/test_zap_provide.rs index 903d7d5cf..c783aa728 100644 --- a/contracts/credit-manager/tests/test_zap_provide.rs +++ b/contracts/credit-manager/tests/test_zap_provide.rs @@ -1,12 +1,10 @@ use std::ops::Mul; use cosmwasm_std::{Addr, Decimal, OverflowError, OverflowOperation::Sub, Uint128}; -use mars_rover::{ - error::ContractError as RoverError, - msg::execute::{ - Action::{Deposit, ProvideLiquidity, WithdrawLiquidity}, - ActionAmount, ActionCoin, - }, +use mars_credit_manager::error::ContractError as RoverError; +use mars_types::credit_manager::{ + Action::{Deposit, ProvideLiquidity, WithdrawLiquidity}, + ActionAmount, ActionCoin, }; use mars_zapper_mock::{contract::STARTING_LP_POOL_TOKENS, error::ContractError}; @@ -188,10 +186,10 @@ fn slippage_too_high() { ) .unwrap_err(); - let contract_err: mars_rover::error::ContractError = err.downcast().unwrap(); + let contract_err: RoverError = err.downcast().unwrap(); assert_eq!( contract_err, - mars_rover::error::ContractError::SlippageExceeded { + RoverError::SlippageExceeded { slippage, max_slippage } diff --git a/contracts/credit-manager/tests/test_zap_withdraw.rs b/contracts/credit-manager/tests/test_zap_withdraw.rs index 9247463ee..554b71d8f 100644 --- a/contracts/credit-manager/tests/test_zap_withdraw.rs +++ b/contracts/credit-manager/tests/test_zap_withdraw.rs @@ -1,10 +1,8 @@ use cosmwasm_std::{Addr, Decimal, OverflowError, OverflowOperation::Sub, Uint128}; -use mars_rover::{ - error::ContractError as RoverError, - msg::execute::{ - Action::{Deposit, ProvideLiquidity, WithdrawLiquidity}, - ActionAmount, ActionCoin, - }, +use mars_credit_manager::error::ContractError as RoverError; +use mars_types::credit_manager::{ + Action::{Deposit, ProvideLiquidity, WithdrawLiquidity}, + ActionAmount, ActionCoin, }; use mars_zapper_mock::contract::STARTING_LP_POOL_TOKENS; @@ -210,10 +208,10 @@ fn slippage_too_high() { ) .unwrap_err(); - let contract_err: mars_rover::error::ContractError = err.downcast().unwrap(); + let contract_err: RoverError = err.downcast().unwrap(); assert_eq!( contract_err, - mars_rover::error::ContractError::SlippageExceeded { + RoverError::SlippageExceeded { slippage, max_slippage } diff --git a/contracts/health/examples/schema.rs b/contracts/health/examples/schema.rs index 440f56bd9..5f3ec6518 100644 --- a/contracts/health/examples/schema.rs +++ b/contracts/health/examples/schema.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::write_api; -use mars_rover_health_types::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use mars_types::health::{ExecuteMsg, InstantiateMsg, QueryMsg}; fn main() { write_api! { diff --git a/contracts/health/src/compute.rs b/contracts/health/src/compute.rs index eb613ca8a..b6a2dae27 100644 --- a/contracts/health/src/compute.rs +++ b/contracts/health/src/compute.rs @@ -1,10 +1,12 @@ use std::collections::HashMap; use cosmwasm_std::{Deps, StdResult}; -use mars_red_bank_types::oracle::ActionKind; -use mars_rover::msg::query::Positions; use mars_rover_health_computer::{DenomsData, HealthComputer, VaultsData}; -use mars_rover_health_types::{AccountKind, HealthResult, HealthState, HealthValuesResponse}; +use mars_types::{ + credit_manager::Positions, + health::{AccountKind, HealthResult, HealthState, HealthValuesResponse}, + oracle::ActionKind, +}; use crate::querier::HealthQuerier; diff --git a/contracts/health/src/contract.rs b/contracts/health/src/contract.rs index cfa0ff359..19dc09075 100644 --- a/contracts/health/src/contract.rs +++ b/contracts/health/src/contract.rs @@ -3,7 +3,7 @@ use cosmwasm_std::entry_point; use cosmwasm_std::{to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response}; use cw2::set_contract_version; use mars_owner::OwnerInit::SetInitialOwner; -use mars_rover_health_types::{ConfigResponse, ExecuteMsg, HealthResult, InstantiateMsg, QueryMsg}; +use mars_types::health::{ConfigResponse, ExecuteMsg, HealthResult, InstantiateMsg, QueryMsg}; use crate::{ compute::{health_state, health_values}, diff --git a/contracts/health/src/querier.rs b/contracts/health/src/querier.rs index 029e1296d..cc5396504 100644 --- a/contracts/health/src/querier.rs +++ b/contracts/health/src/querier.rs @@ -1,10 +1,10 @@ use cosmwasm_std::{Addr, Deps, QuerierWrapper, StdError, StdResult}; -use mars_red_bank_types::params::VaultConfig; -use mars_rover::{ +use mars_types::{ adapters::{oracle::Oracle, params::Params, vault::Vault}, - msg::query::{ConfigResponse, Positions, QueryMsg as CmQueryMsg}, + credit_manager::{ConfigResponse, Positions, QueryMsg as CmQueryMsg}, + health::HealthResult, + params::VaultConfig, }; -use mars_rover_health_types::HealthResult; use crate::state::CREDIT_MANAGER; diff --git a/contracts/health/src/update_config.rs b/contracts/health/src/update_config.rs index e0ea9efd3..dfd5e7977 100644 --- a/contracts/health/src/update_config.rs +++ b/contracts/health/src/update_config.rs @@ -1,5 +1,5 @@ use cosmwasm_std::{DepsMut, MessageInfo, Response}; -use mars_rover_health_types::HealthResult; +use mars_types::health::HealthResult; use crate::state::{CREDIT_MANAGER, OWNER}; diff --git a/contracts/health/tests/helpers/defaults.rs b/contracts/health/tests/helpers/defaults.rs index dbb490f61..879c3d6b7 100644 --- a/contracts/health/tests/helpers/defaults.rs +++ b/contracts/health/tests/helpers/defaults.rs @@ -1,7 +1,7 @@ use std::str::FromStr; use cosmwasm_std::Decimal; -use mars_red_bank_types::params::{ +use mars_types::params::{ AssetParamsUnchecked, CmSettings, HlsParamsUnchecked, LiquidationBonus, RedBankSettings, }; diff --git a/contracts/health/tests/helpers/mock_env.rs b/contracts/health/tests/helpers/mock_env.rs index 79d04964c..3b1613a75 100644 --- a/contracts/health/tests/helpers/mock_env.rs +++ b/contracts/health/tests/helpers/mock_env.rs @@ -7,7 +7,13 @@ use cw_vault_standard::{ use mars_mock_credit_manager::msg::ExecuteMsg::SetPositionsResponse; use mars_mock_oracle::msg::{CoinPrice, ExecuteMsg::ChangePrice}; use mars_mock_vault::contract::STARTING_VAULT_SHARES; -use mars_red_bank_types::{ +use mars_types::{ + adapters::vault::VaultUnchecked, + credit_manager::Positions, + health::{ + AccountKind, ConfigResponse, ExecuteMsg::UpdateConfig, HealthState, HealthValuesResponse, + QueryMsg, + }, oracle::ActionKind, params::{ AssetParamsUpdate, @@ -15,11 +21,6 @@ use mars_red_bank_types::{ QueryMsg as ParamsQueryMsg, VaultConfig, VaultConfigUpdate, }, }; -use mars_rover::{adapters::vault::VaultUnchecked, msg::query::Positions}; -use mars_rover_health_types::{ - AccountKind, ConfigResponse, ExecuteMsg::UpdateConfig, HealthState, HealthValuesResponse, - QueryMsg, -}; use crate::helpers::MockEnvBuilder; diff --git a/contracts/health/tests/helpers/mock_env_builder.rs b/contracts/health/tests/helpers/mock_env_builder.rs index 9ddb76a56..2ac69f474 100644 --- a/contracts/health/tests/helpers/mock_env_builder.rs +++ b/contracts/health/tests/helpers/mock_env_builder.rs @@ -8,12 +8,15 @@ use mars_mock_credit_manager::msg::InstantiateMsg as CmMockInstantiateMsg; use mars_mock_oracle::msg::InstantiateMsg as OracleInstantiateMsg; use mars_mock_vault::msg::InstantiateMsg as VaultInstantiateMsg; use mars_owner::OwnerResponse; -use mars_red_bank_types::params::{ - ExecuteMsg::UpdateVaultConfig, HlsParamsUnchecked, InstantiateMsg as ParamsInstantiateMsg, - VaultConfigUnchecked, VaultConfigUpdate::AddOrUpdate, +use mars_types::{ + adapters::oracle::OracleUnchecked, + credit_manager::ConfigResponse, + health::{ExecuteMsg::UpdateConfig, InstantiateMsg}, + params::{ + ExecuteMsg::UpdateVaultConfig, HlsParamsUnchecked, InstantiateMsg as ParamsInstantiateMsg, + VaultConfigUnchecked, VaultConfigUpdate::AddOrUpdate, + }, }; -use mars_rover::{adapters::oracle::OracleUnchecked, msg::query::ConfigResponse}; -use mars_rover_health_types::{ExecuteMsg::UpdateConfig, InstantiateMsg}; use crate::helpers::{ mock_credit_manager_contract, mock_health_contract, mock_oracle_contract, mock_params_contract, diff --git a/contracts/health/tests/test_health_state.rs b/contracts/health/tests/test_health_state.rs index fe992cf55..78c5e7294 100644 --- a/contracts/health/tests/test_health_state.rs +++ b/contracts/health/tests/test_health_state.rs @@ -1,7 +1,10 @@ use cosmwasm_std::{Coin, Decimal, Uint128}; -use mars_red_bank_types::{oracle::ActionKind, params::AssetParamsUpdate::AddOrUpdate}; -use mars_rover::msg::query::{DebtAmount, Positions}; -use mars_rover_health_types::{AccountKind, HealthState}; +use mars_types::{ + credit_manager::{DebtAmount, Positions}, + health::{AccountKind, HealthState}, + oracle::ActionKind, + params::AssetParamsUpdate::AddOrUpdate, +}; use crate::helpers::{default_asset_params, MockEnv}; diff --git a/contracts/health/tests/test_health_values.rs b/contracts/health/tests/test_health_values.rs index 8bdcb121a..44159cdaf 100644 --- a/contracts/health/tests/test_health_values.rs +++ b/contracts/health/tests/test_health_values.rs @@ -1,21 +1,19 @@ -use std::str::FromStr; +use std::{any::type_name, str::FromStr}; use cosmwasm_std::{Coin, Decimal, StdError, Uint128}; -use mars_red_bank_types::{ +use mars_types::{ + adapters::vault::{ + LockingVaultAmount, UnlockingPositions, Vault, VaultAmount, VaultPosition, + VaultPositionAmount, VaultUnlockingPosition, + }, + credit_manager::Positions, + health::AccountKind, oracle::ActionKind, params::{ AssetParamsUnchecked, AssetParamsUpdate::AddOrUpdate, CmSettings, HlsParamsUnchecked, LiquidationBonus, RedBankSettings, VaultConfigUpdate, }, }; -use mars_rover::{ - adapters::vault::{ - LockingVaultAmount, UnlockingPositions, Vault, VaultAmount, VaultPosition, - VaultPositionAmount, VaultUnlockingPosition, - }, - msg::query::Positions, -}; -use mars_rover_health_types::AccountKind; use crate::helpers::MockEnv; @@ -41,10 +39,10 @@ fn raises_with_non_existent_account_id() { mock.query_health_values("xyz", AccountKind::Default, ActionKind::Default).unwrap_err(); assert_eq!( err, - StdError::generic_err( - "Querier contract error: Generic error: Querier contract error: mars_rover::msg::query::Positions not found" - .to_string() - ) + StdError::generic_err(format!( + "Querier contract error: Generic error: Querier contract error: {} not found", + type_name::() + )) ); } diff --git a/contracts/health/tests/test_hls.rs b/contracts/health/tests/test_hls.rs index 5a6b9fec4..159103dd0 100644 --- a/contracts/health/tests/test_hls.rs +++ b/contracts/health/tests/test_hls.rs @@ -1,12 +1,13 @@ use std::str::FromStr; use cosmwasm_std::{Decimal, Uint128}; -use mars_red_bank_types::{oracle::ActionKind, params::AssetParamsUpdate::AddOrUpdate}; -use mars_rover::{ +use mars_types::{ adapters::vault::{Vault, VaultAmount, VaultPosition, VaultPositionAmount}, - msg::query::{DebtAmount, Positions}, + credit_manager::{DebtAmount, Positions}, + health::AccountKind, + oracle::ActionKind, + params::AssetParamsUpdate::AddOrUpdate, }; -use mars_rover_health_types::AccountKind; use crate::helpers::{default_asset_params, MockEnv}; diff --git a/contracts/health/tests/test_instantiate.rs b/contracts/health/tests/test_instantiate.rs index 15afdae22..adad1e1ae 100644 --- a/contracts/health/tests/test_instantiate.rs +++ b/contracts/health/tests/test_instantiate.rs @@ -3,7 +3,7 @@ use mars_rover_health::{ contract::instantiate, state::{CREDIT_MANAGER, OWNER}, }; -use mars_rover_health_types::InstantiateMsg; +use mars_types::health::InstantiateMsg; pub mod helpers; diff --git a/contracts/health/tests/test_liquidation_pricing.rs b/contracts/health/tests/test_liquidation_pricing.rs index 697ab5caf..1da92e102 100644 --- a/contracts/health/tests/test_liquidation_pricing.rs +++ b/contracts/health/tests/test_liquidation_pricing.rs @@ -1,15 +1,15 @@ use std::str::FromStr; use cosmwasm_std::{Coin, Decimal, StdError, Uint128}; -use mars_red_bank_types::{ +use mars_types::{ + credit_manager::{DebtAmount, Positions}, + health::AccountKind, oracle::ActionKind, params::{ AssetParamsUnchecked, AssetParamsUpdate::AddOrUpdate, CmSettings, HlsParamsUnchecked, LiquidationBonus, RedBankSettings, }, }; -use mars_rover::msg::query::{DebtAmount, Positions}; -use mars_rover_health_types::AccountKind; use crate::helpers::MockEnv; diff --git a/contracts/health/tests/test_update_config.rs b/contracts/health/tests/test_update_config.rs index c7f51a41e..2b2ead9d8 100644 --- a/contracts/health/tests/test_update_config.rs +++ b/contracts/health/tests/test_update_config.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{Addr, StdError}; use mars_owner::OwnerError::NotOwner; -use mars_rover_health_types::{ +use mars_types::health::{ HealthError, HealthError::{Owner, Std}, }; diff --git a/contracts/incentives/examples/schema.rs b/contracts/incentives/examples/schema.rs index 230e84c60..dc8202770 100644 --- a/contracts/incentives/examples/schema.rs +++ b/contracts/incentives/examples/schema.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::write_api; -use mars_red_bank_types::incentives::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use mars_types::incentives::{ExecuteMsg, InstantiateMsg, QueryMsg}; fn main() { write_api! { diff --git a/contracts/incentives/src/contract.rs b/contracts/incentives/src/contract.rs index c6f24762d..cf328fc53 100644 --- a/contracts/incentives/src/contract.rs +++ b/contracts/incentives/src/contract.rs @@ -7,7 +7,7 @@ use cosmwasm_std::{ use cw2::set_contract_version; use cw_storage_plus::Bound; use mars_owner::{OwnerInit::SetInitialOwner, OwnerUpdate}; -use mars_red_bank_types::{ +use mars_types::{ address_provider::{self, MarsAddressType}, error::MarsError, incentives::{ diff --git a/contracts/incentives/src/error.rs b/contracts/incentives/src/error.rs index 859f40c74..daabb8db1 100644 --- a/contracts/incentives/src/error.rs +++ b/contracts/incentives/src/error.rs @@ -2,7 +2,7 @@ use std::string::FromUtf8Error; use cosmwasm_std::{Coin, StdError}; use mars_owner::OwnerError; -use mars_red_bank_types::error::MarsError; +use mars_types::error::MarsError; use mars_utils::error::{GuardError, ValidationError}; use thiserror::Error; diff --git a/contracts/incentives/src/helpers.rs b/contracts/incentives/src/helpers.rs index 1822e08de..42efd1c61 100644 --- a/contracts/incentives/src/helpers.rs +++ b/contracts/incentives/src/helpers.rs @@ -5,7 +5,7 @@ use cosmwasm_std::{ QuerierWrapper, StdError, StdResult, Storage, Uint128, }; use cw_storage_plus::Bound; -use mars_red_bank_types::{ +use mars_types::{ address_provider::{self, MarsAddressType}, incentives::IncentiveState, keys::{UserId, UserIdKey}, diff --git a/contracts/incentives/src/migrations/v2_0_0.rs b/contracts/incentives/src/migrations/v2_0_0.rs index a40e01e3b..5f4ff8e5e 100644 --- a/contracts/incentives/src/migrations/v2_0_0.rs +++ b/contracts/incentives/src/migrations/v2_0_0.rs @@ -4,7 +4,7 @@ use cosmwasm_std::{Addr, DepsMut, Env, MessageInfo, Order, Response, StdResult, use cw2::{assert_contract_version, set_contract_version}; use cw_storage_plus::Bound; use mars_owner::OwnerInit; -use mars_red_bank_types::{ +use mars_types::{ address_provider::{helpers, MarsAddressType}, incentives::{Config, IncentiveState, MigrateMsg, MigrateV1ToV2}, keys::{UserId, UserIdKey}, diff --git a/contracts/incentives/src/state.rs b/contracts/incentives/src/state.rs index 77337a67c..8a82a1899 100644 --- a/contracts/incentives/src/state.rs +++ b/contracts/incentives/src/state.rs @@ -1,7 +1,7 @@ use cosmwasm_std::{Addr, Decimal, Order, StdResult, Storage, Uint128}; use cw_storage_plus::{Bound, Item, Map, PrefixBound}; use mars_owner::Owner; -use mars_red_bank_types::{ +use mars_types::{ incentives::{Config, IncentiveState}, keys::{UserId, UserIdKey}, }; diff --git a/contracts/incentives/tests/tests/helpers/mod.rs b/contracts/incentives/tests/tests/helpers/mod.rs index 5f5b0e6f9..9fa4a3121 100644 --- a/contracts/incentives/tests/tests/helpers/mod.rs +++ b/contracts/incentives/tests/tests/helpers/mod.rs @@ -7,8 +7,8 @@ use cosmwasm_std::{ Deps, DepsMut, Env, OwnedDeps, Uint128, }; use mars_incentives::contract::{execute, instantiate, query}; -use mars_red_bank_types::incentives::{ExecuteMsg, InstantiateMsg, QueryMsg}; use mars_testing::{mock_dependencies, MarsMockQuerier}; +use mars_types::incentives::{ExecuteMsg, InstantiateMsg, QueryMsg}; pub fn th_setup() -> OwnedDeps { th_setup_with_env(mock_env()) diff --git a/contracts/incentives/tests/tests/test_admin.rs b/contracts/incentives/tests/tests/test_admin.rs index 1d23dc7a2..b58ddcf6b 100644 --- a/contracts/incentives/tests/tests/test_admin.rs +++ b/contracts/incentives/tests/tests/test_admin.rs @@ -7,8 +7,8 @@ use mars_incentives::{ ContractError, }; use mars_owner::OwnerError::NotOwner; -use mars_red_bank_types::incentives::{ConfigResponse, ExecuteMsg, InstantiateMsg, QueryMsg}; use mars_testing::mock_dependencies; +use mars_types::incentives::{ConfigResponse, ExecuteMsg, InstantiateMsg, QueryMsg}; use super::helpers::{th_query, th_setup}; diff --git a/contracts/incentives/tests/tests/test_balance_change.rs b/contracts/incentives/tests/tests/test_balance_change.rs index 388c6f820..cd7317ab1 100644 --- a/contracts/incentives/tests/tests/test_balance_change.rs +++ b/contracts/incentives/tests/tests/test_balance_change.rs @@ -8,13 +8,13 @@ use mars_incentives::{ helpers::{compute_incentive_index, compute_user_accrued_rewards}, state::{EMISSIONS, INCENTIVE_STATES, USER_ASSET_INDICES, USER_UNCLAIMED_REWARDS}, }; -use mars_red_bank_types::{ +use mars_testing::MockEnvParams; +use mars_types::{ error::MarsError, incentives::{ExecuteMsg, IncentiveState}, keys::{UserId, UserIdKey}, red_bank::{Market, UserCollateralResponse}, }; -use mars_testing::MockEnvParams; use super::helpers::{th_setup, ths_setup_with_epoch_duration}; diff --git a/contracts/incentives/tests/tests/test_claim_rewards.rs b/contracts/incentives/tests/tests/test_claim_rewards.rs index d6508f448..b65b42aa0 100644 --- a/contracts/incentives/tests/tests/test_claim_rewards.rs +++ b/contracts/incentives/tests/tests/test_claim_rewards.rs @@ -8,12 +8,12 @@ use mars_incentives::{ helpers::{compute_incentive_index, compute_user_accrued_rewards}, state::{EMISSIONS, INCENTIVE_STATES, USER_ASSET_INDICES, USER_UNCLAIMED_REWARDS}, }; -use mars_red_bank_types::{ +use mars_testing::MockEnvParams; +use mars_types::{ incentives::{ExecuteMsg, IncentiveState}, keys::{UserId, UserIdKey}, red_bank::{Market, UserCollateralResponse}, }; -use mars_testing::MockEnvParams; use super::helpers::{th_setup, ths_setup_with_epoch_duration}; diff --git a/contracts/incentives/tests/tests/test_indices_usage.rs b/contracts/incentives/tests/tests/test_indices_usage.rs index ef02de18a..0d44f41da 100644 --- a/contracts/incentives/tests/tests/test_indices_usage.rs +++ b/contracts/incentives/tests/tests/test_indices_usage.rs @@ -9,7 +9,7 @@ use mars_incentives::{ }, state::{CONFIG, EMISSIONS, EPOCH_DURATION, INCENTIVE_STATES}, }; -use mars_red_bank_types::incentives::{Config, IncentiveState}; +use mars_types::incentives::{Config, IncentiveState}; fn store_config_with_epoch_duration(storage: &mut dyn Storage, epoch_duration: u64) { CONFIG diff --git a/contracts/incentives/tests/tests/test_migration_v2.rs b/contracts/incentives/tests/tests/test_migration_v2.rs index 3e6f6e831..bc4eafa8d 100644 --- a/contracts/incentives/tests/tests/test_migration_v2.rs +++ b/contracts/incentives/tests/tests/test_migration_v2.rs @@ -15,12 +15,12 @@ use mars_incentives::{ }, ContractError, }; -use mars_red_bank_types::{ +use mars_testing::{mock_dependencies, MockEnvParams}; +use mars_types::{ incentives::{Config, ExecuteMsg, IncentiveState, MigrateMsg, MigrateV1ToV2}, keys::{UserId, UserIdKey}, red_bank::{Market, UserCollateralResponse}, }; -use mars_testing::{mock_dependencies, MockEnvParams}; use mars_utils::error::GuardError; #[test] diff --git a/contracts/incentives/tests/tests/test_quering.rs b/contracts/incentives/tests/tests/test_quering.rs index ba4a12f5c..2f1b20d75 100644 --- a/contracts/incentives/tests/tests/test_quering.rs +++ b/contracts/incentives/tests/tests/test_quering.rs @@ -1,9 +1,9 @@ use cosmwasm_std::{Decimal, Timestamp, Uint128}; use mars_incentives::state::{EMISSIONS, INCENTIVE_STATES}; -use mars_red_bank_types::incentives::{ +use mars_testing::{mock_env, MockEnvParams}; +use mars_types::incentives::{ ActiveEmission, EmissionResponse, IncentiveState, IncentiveStateResponse, QueryMsg, }; -use mars_testing::{mock_env, MockEnvParams}; use test_case::test_case; use super::helpers::{th_query, th_query_with_env, th_setup}; diff --git a/contracts/incentives/tests/tests/test_set_asset_incentive.rs b/contracts/incentives/tests/tests/test_set_asset_incentive.rs index bf24c9d07..d3dac87c4 100644 --- a/contracts/incentives/tests/tests/test_set_asset_incentive.rs +++ b/contracts/incentives/tests/tests/test_set_asset_incentive.rs @@ -8,8 +8,8 @@ use mars_incentives::{ state::{EMISSIONS, INCENTIVE_STATES}, ContractError, }; -use mars_red_bank_types::{incentives::ExecuteMsg, red_bank::Market}; use mars_testing::MockEnvParams; +use mars_types::{incentives::ExecuteMsg, red_bank::Market}; use mars_utils::error::ValidationError; use super::helpers::{ diff --git a/contracts/incentives/tests/tests/test_update_owner.rs b/contracts/incentives/tests/tests/test_update_owner.rs index 3989240ad..a91020c20 100644 --- a/contracts/incentives/tests/tests/test_update_owner.rs +++ b/contracts/incentives/tests/tests/test_update_owner.rs @@ -1,7 +1,7 @@ use cosmwasm_std::testing::{mock_env, mock_info}; use mars_incentives::{contract::execute, ContractError}; use mars_owner::{OwnerError::NotOwner, OwnerUpdate}; -use mars_red_bank_types::incentives::{ConfigResponse, ExecuteMsg, QueryMsg}; +use mars_types::incentives::{ConfigResponse, ExecuteMsg, QueryMsg}; use super::helpers::{th_query, th_setup}; diff --git a/contracts/incentives/tests/tests/test_whitelist.rs b/contracts/incentives/tests/tests/test_whitelist.rs index 0873e14b6..cff866681 100644 --- a/contracts/incentives/tests/tests/test_whitelist.rs +++ b/contracts/incentives/tests/tests/test_whitelist.rs @@ -9,11 +9,11 @@ use mars_incentives::{ ContractError, }; use mars_owner::OwnerError::NotOwner; -use mars_red_bank_types::{ +use mars_testing::MockEnvParams; +use mars_types::{ incentives::{ConfigResponse, ExecuteMsg, QueryMsg, WhitelistEntry}, red_bank::{Market, UserCollateralResponse}, }; -use mars_testing::MockEnvParams; use mars_utils::error::ValidationError; use super::helpers::{ diff --git a/contracts/mock-credit-manager/examples/schema.rs b/contracts/mock-credit-manager/examples/schema.rs index c620e6d74..ab40848cc 100644 --- a/contracts/mock-credit-manager/examples/schema.rs +++ b/contracts/mock-credit-manager/examples/schema.rs @@ -1,7 +1,7 @@ use cosmwasm_schema::write_api; use cosmwasm_std::Empty; use mars_mock_credit_manager::msg::ExecuteMsg; -use mars_rover::msg::QueryMsg; +use mars_types::credit_manager::QueryMsg; fn main() { write_api! { diff --git a/contracts/mock-credit-manager/src/contract.rs b/contracts/mock-credit-manager/src/contract.rs index 494c293ff..abc171e24 100644 --- a/contracts/mock-credit-manager/src/contract.rs +++ b/contracts/mock-credit-manager/src/contract.rs @@ -1,7 +1,7 @@ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult}; -use mars_rover::msg::QueryMsg; +use mars_types::credit_manager::QueryMsg; use crate::{ execute::{set_account_kind_response, set_position_response}, diff --git a/contracts/mock-credit-manager/src/execute.rs b/contracts/mock-credit-manager/src/execute.rs index a76ba3325..85c38a70e 100644 --- a/contracts/mock-credit-manager/src/execute.rs +++ b/contracts/mock-credit-manager/src/execute.rs @@ -1,6 +1,5 @@ use cosmwasm_std::{DepsMut, Response, StdResult}; -use mars_rover::msg::query::Positions; -use mars_rover_health_types::AccountKind; +use mars_types::{credit_manager::Positions, health::AccountKind}; use crate::state::{ACCOUNT_KINDS, POSITION_RESPONSES}; diff --git a/contracts/mock-credit-manager/src/msg.rs b/contracts/mock-credit-manager/src/msg.rs index 0b9852606..7bf3da2ac 100644 --- a/contracts/mock-credit-manager/src/msg.rs +++ b/contracts/mock-credit-manager/src/msg.rs @@ -1,6 +1,8 @@ use cosmwasm_schema::cw_serde; -use mars_rover::msg::query::{ConfigResponse, Positions}; -use mars_rover_health_types::AccountKind; +use mars_types::{ + credit_manager::{ConfigResponse, Positions}, + health::AccountKind, +}; #[cw_serde] pub struct InstantiateMsg { diff --git a/contracts/mock-credit-manager/src/query.rs b/contracts/mock-credit-manager/src/query.rs index 962daba9d..6bb2acd97 100644 --- a/contracts/mock-credit-manager/src/query.rs +++ b/contracts/mock-credit-manager/src/query.rs @@ -1,6 +1,8 @@ use cosmwasm_std::{Deps, StdResult}; -use mars_rover::msg::query::{ConfigResponse, Positions}; -use mars_rover_health_types::AccountKind; +use mars_types::{ + credit_manager::{ConfigResponse, Positions}, + health::AccountKind, +}; use crate::state::{ACCOUNT_KINDS, CONFIG, POSITION_RESPONSES}; diff --git a/contracts/mock-credit-manager/src/state.rs b/contracts/mock-credit-manager/src/state.rs index 4afd64334..ad145528f 100644 --- a/contracts/mock-credit-manager/src/state.rs +++ b/contracts/mock-credit-manager/src/state.rs @@ -1,6 +1,8 @@ use cw_storage_plus::{Item, Map}; -use mars_rover::msg::query::{ConfigResponse, Positions}; -use mars_rover_health_types::AccountKind; +use mars_types::{ + credit_manager::{ConfigResponse, Positions}, + health::AccountKind, +}; pub const CONFIG: Item = Item::new("config"); diff --git a/contracts/mock-health/src/contract.rs b/contracts/mock-health/src/contract.rs index 50b68ddab..b6bd169a6 100644 --- a/contracts/mock-health/src/contract.rs +++ b/contracts/mock-health/src/contract.rs @@ -3,7 +3,7 @@ use cosmwasm_std::entry_point; use cosmwasm_std::{ to_binary, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Response, StdResult, }; -use mars_rover_health_types::{AccountKind, HealthResult, HealthValuesResponse, QueryMsg}; +use mars_types::health::{AccountKind, HealthResult, HealthValuesResponse, QueryMsg}; use crate::{msg::ExecuteMsg, state::HEALTH_RESPONSES}; diff --git a/contracts/mock-health/src/msg.rs b/contracts/mock-health/src/msg.rs index 76999e1df..81013e1dd 100644 --- a/contracts/mock-health/src/msg.rs +++ b/contracts/mock-health/src/msg.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::cw_serde; -use mars_rover_health_types::{AccountKind, HealthValuesResponse}; +use mars_types::health::{AccountKind, HealthValuesResponse}; #[cw_serde] pub enum ExecuteMsg { diff --git a/contracts/mock-health/src/state.rs b/contracts/mock-health/src/state.rs index b29a02281..a1011f5ae 100644 --- a/contracts/mock-health/src/state.rs +++ b/contracts/mock-health/src/state.rs @@ -1,4 +1,4 @@ use cw_storage_plus::Map; -use mars_rover_health_types::HealthValuesResponse; +use mars_types::health::HealthValuesResponse; pub const HEALTH_RESPONSES: Map<(&str, &str), HealthValuesResponse> = Map::new("health_responses"); // Map<(account_id, AccountKind string), HealthResponse> diff --git a/contracts/mock-incentives/src/contract.rs b/contracts/mock-incentives/src/contract.rs index 9eb10dba1..6058b5027 100644 --- a/contracts/mock-incentives/src/contract.rs +++ b/contracts/mock-incentives/src/contract.rs @@ -3,7 +3,7 @@ use cosmwasm_std::entry_point; use cosmwasm_std::{ to_binary, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Response, StdResult, }; -use mars_red_bank_types::incentives; +use mars_types::incentives; use crate::{ execute::{balance_change, claim_rewards}, diff --git a/contracts/mock-oracle/src/contract.rs b/contracts/mock-oracle/src/contract.rs index a23b7bfc8..e4a32e3b1 100644 --- a/contracts/mock-oracle/src/contract.rs +++ b/contracts/mock-oracle/src/contract.rs @@ -1,7 +1,7 @@ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult}; -use mars_red_bank_types::oracle::{ActionKind, PriceResponse}; +use mars_types::oracle::{ActionKind, PriceResponse}; use crate::{ msg::{CoinPrice, ExecuteMsg, InstantiateMsg, QueryMsg}, diff --git a/contracts/mock-oracle/src/msg.rs b/contracts/mock-oracle/src/msg.rs index 6af6e8f3e..a47d67033 100644 --- a/contracts/mock-oracle/src/msg.rs +++ b/contracts/mock-oracle/src/msg.rs @@ -1,6 +1,6 @@ use cosmwasm_schema::{cw_serde, QueryResponses}; use cosmwasm_std::Decimal; -use mars_red_bank_types::oracle::ActionKind; +use mars_types::oracle::ActionKind; #[cw_serde] pub struct CoinPrice { @@ -31,7 +31,7 @@ pub enum ExecuteMsg { #[cw_serde] #[derive(QueryResponses)] pub enum QueryMsg { - #[returns(mars_red_bank_types::oracle::PriceResponse)] + #[returns(mars_types::oracle::PriceResponse)] Price { denom: String, kind: Option, diff --git a/contracts/mock-red-bank/examples/schema.rs b/contracts/mock-red-bank/examples/schema.rs index 5ffb204e9..2c5476a3e 100644 --- a/contracts/mock-red-bank/examples/schema.rs +++ b/contracts/mock-red-bank/examples/schema.rs @@ -1,6 +1,6 @@ use cosmwasm_schema::write_api; use cosmwasm_std::Empty; -use mars_red_bank_types::red_bank::{ExecuteMsg, QueryMsg}; +use mars_types::red_bank::{ExecuteMsg, QueryMsg}; fn main() { write_api! { diff --git a/contracts/mock-red-bank/src/contract.rs b/contracts/mock-red-bank/src/contract.rs index bd6d15e90..d7afd005e 100644 --- a/contracts/mock-red-bank/src/contract.rs +++ b/contracts/mock-red-bank/src/contract.rs @@ -3,7 +3,7 @@ use cosmwasm_std::entry_point; use cosmwasm_std::{ to_binary, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Response, StdResult, }; -use mars_red_bank_types::red_bank; +use mars_types::red_bank; use crate::{ execute::{borrow, deposit, init_asset, repay, withdraw}, diff --git a/contracts/mock-red-bank/src/execute.rs b/contracts/mock-red-bank/src/execute.rs index 8c532635b..4059f7d55 100644 --- a/contracts/mock-red-bank/src/execute.rs +++ b/contracts/mock-red-bank/src/execute.rs @@ -3,7 +3,7 @@ use cosmwasm_std::{ StdResult, Uint128, }; use cw_utils::one_coin; -use mars_red_bank_types::red_bank::{InitOrUpdateAssetParams, Market}; +use mars_types::red_bank::{InitOrUpdateAssetParams, Market}; use crate::{ helpers::{load_collateral_amount, load_debt_amount}, diff --git a/contracts/mock-red-bank/src/query.rs b/contracts/mock-red-bank/src/query.rs index 0b3882c4c..152a200b9 100644 --- a/contracts/mock-red-bank/src/query.rs +++ b/contracts/mock-red-bank/src/query.rs @@ -1,5 +1,5 @@ use cosmwasm_std::{Deps, StdResult, Uint128}; -use mars_red_bank_types::{ +use mars_types::{ red_bank::{Market, PaginatedUserCollateralResponse, UserCollateralResponse, UserDebtResponse}, Metadata, }; diff --git a/contracts/mock-red-bank/src/state.rs b/contracts/mock-red-bank/src/state.rs index 4277cb829..79aba0392 100644 --- a/contracts/mock-red-bank/src/state.rs +++ b/contracts/mock-red-bank/src/state.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{Addr, Uint128}; use cw_storage_plus::Map; -use mars_red_bank_types::red_bank::Market; +use mars_types::red_bank::Market; // Map pub const MARKETS: Map<&str, Market> = Map::new("markets"); diff --git a/contracts/mock-vault/examples/schema.rs b/contracts/mock-vault/examples/schema.rs index 4a0e8f245..ef3bd83cb 100644 --- a/contracts/mock-vault/examples/schema.rs +++ b/contracts/mock-vault/examples/schema.rs @@ -1,6 +1,6 @@ use cosmwasm_schema::write_api; use mars_mock_vault::msg::InstantiateMsg; -use mars_rover::adapters::vault::{ExecuteMsg, QueryMsg}; +use mars_types::adapters::vault::{ExecuteMsg, QueryMsg}; fn main() { write_api! { diff --git a/contracts/mock-vault/src/contract.rs b/contracts/mock-vault/src/contract.rs index e968a8f29..80d5c36fb 100644 --- a/contracts/mock-vault/src/contract.rs +++ b/contracts/mock-vault/src/contract.rs @@ -8,7 +8,7 @@ use cw_vault_standard::{ }, msg::{ExtensionExecuteMsg, ExtensionQueryMsg}, }; -use mars_rover::adapters::vault::{ExecuteMsg, QueryMsg}; +use mars_types::adapters::vault::{ExecuteMsg, QueryMsg}; use crate::{ deposit::deposit, diff --git a/contracts/mock-vault/src/deposit.rs b/contracts/mock-vault/src/deposit.rs index 0891cbdff..1c4218e66 100644 --- a/contracts/mock-vault/src/deposit.rs +++ b/contracts/mock-vault/src/deposit.rs @@ -2,8 +2,10 @@ use cosmwasm_std::{ to_binary, BankMsg, Coin, CosmosMsg, DepsMut, MessageInfo, Response, StdResult, Uint128, WasmMsg, }; -use mars_red_bank_types::oracle::ActionKind; -use mars_rover::msg::{execute::Action::Deposit, ExecuteMsg::UpdateCreditAccount}; +use mars_types::{ + credit_manager::{Action::Deposit, ExecuteMsg::UpdateCreditAccount}, + oracle::ActionKind, +}; use crate::{ contract::STARTING_VAULT_SHARES, diff --git a/contracts/mock-vault/src/error.rs b/contracts/mock-vault/src/error.rs index e83f91950..c17a9b1d1 100644 --- a/contracts/mock-vault/src/error.rs +++ b/contracts/mock-vault/src/error.rs @@ -1,5 +1,5 @@ use cosmwasm_std::{CheckedMultiplyRatioError, StdError}; -use mars_rover::error::ContractError as RoverError; +use mars_types::adapters::oracle::OracleError; use thiserror::Error; pub type ContractResult = Result; @@ -10,7 +10,7 @@ pub enum ContractError { Std(#[from] StdError), #[error("{0}")] - RoverError(#[from] RoverError), + Oracle(#[from] OracleError), #[error("{0}")] CheckedMultiply(#[from] CheckedMultiplyRatioError), diff --git a/contracts/mock-vault/src/msg.rs b/contracts/mock-vault/src/msg.rs index c217a6b63..c38161c30 100644 --- a/contracts/mock-vault/src/msg.rs +++ b/contracts/mock-vault/src/msg.rs @@ -1,6 +1,6 @@ use cosmwasm_schema::cw_serde; use cw_utils::Duration; -use mars_rover::adapters::oracle::OracleUnchecked; +use mars_types::adapters::oracle::OracleUnchecked; // Remaining messages in cw-vault-standard #[cw_serde] diff --git a/contracts/mock-vault/src/state.rs b/contracts/mock-vault/src/state.rs index e2c2f4762..05ef4cd31 100644 --- a/contracts/mock-vault/src/state.rs +++ b/contracts/mock-vault/src/state.rs @@ -2,7 +2,7 @@ use cosmwasm_std::{Addr, Coin, Uint128}; use cw_storage_plus::{Item, Map}; use cw_utils::Duration; use cw_vault_standard::extensions::lockup::UnlockingPosition; -use mars_rover::adapters::oracle::Oracle; +use mars_types::adapters::oracle::Oracle; pub const VAULT_TOKEN_DENOM: Item = Item::new("vault_token_denom"); pub const TOTAL_VAULT_SHARES: Item = Item::new("total_vault_shares"); diff --git a/contracts/oracle/base/src/contract.rs b/contracts/oracle/base/src/contract.rs index b402c913b..7258edda2 100644 --- a/contracts/oracle/base/src/contract.rs +++ b/contracts/oracle/base/src/contract.rs @@ -6,7 +6,7 @@ use cosmwasm_std::{ }; use cw_storage_plus::{Bound, Item, Map}; use mars_owner::{Owner, OwnerInit::SetInitialOwner, OwnerUpdate}; -use mars_red_bank_types::oracle::msg::{ +use mars_types::oracle::msg::{ ActionKind, Config, ConfigResponse, ExecuteMsg, InstantiateMsg, PriceResponse, PriceSourceResponse, QueryMsg, }; diff --git a/contracts/oracle/base/src/pyth.rs b/contracts/oracle/base/src/pyth.rs index f0d25ed86..cd7dcefcd 100644 --- a/contracts/oracle/base/src/pyth.rs +++ b/contracts/oracle/base/src/pyth.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{Addr, Decimal, Deps, Empty, Env, StdError, Uint128}; use cw_storage_plus::Map; -use mars_red_bank_types::oracle::{ActionKind, Config}; +use mars_types::oracle::{ActionKind, Config}; use pyth_sdk_cw::{query_price_feed, Price, PriceFeed, PriceFeedResponse, PriceIdentifier}; use super::*; diff --git a/contracts/oracle/base/src/traits.rs b/contracts/oracle/base/src/traits.rs index 2577bbc15..8ea98b94f 100644 --- a/contracts/oracle/base/src/traits.rs +++ b/contracts/oracle/base/src/traits.rs @@ -2,7 +2,7 @@ use std::fmt::{Debug, Display}; use cosmwasm_std::{CustomQuery, Decimal, Deps, Env}; use cw_storage_plus::Map; -use mars_red_bank_types::oracle::{ActionKind, Config}; +use mars_types::oracle::{ActionKind, Config}; use schemars::JsonSchema; use serde::{de::DeserializeOwned, Serialize}; diff --git a/contracts/oracle/osmosis/examples/schema.rs b/contracts/oracle/osmosis/examples/schema.rs index 0ba057079..a6ed64861 100644 --- a/contracts/oracle/osmosis/examples/schema.rs +++ b/contracts/oracle/osmosis/examples/schema.rs @@ -1,6 +1,6 @@ use cosmwasm_schema::write_api; use mars_oracle_osmosis::OsmosisPriceSourceUnchecked; -use mars_red_bank_types::oracle::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use mars_types::oracle::{ExecuteMsg, InstantiateMsg, QueryMsg}; fn main() { write_api! { diff --git a/contracts/oracle/osmosis/src/contract.rs b/contracts/oracle/osmosis/src/contract.rs index 3b457d52f..526dc8c62 100644 --- a/contracts/oracle/osmosis/src/contract.rs +++ b/contracts/oracle/osmosis/src/contract.rs @@ -16,7 +16,7 @@ pub mod entry { use cosmwasm_std::{entry_point, Binary, Deps, DepsMut, Env, MessageInfo, Response}; use cw2::set_contract_version; use mars_oracle_base::ContractResult; - use mars_red_bank_types::oracle::{ + use mars_types::oracle::{ msg::{ExecuteMsg, InstantiateMsg, QueryMsg}, MigrateMsg, }; diff --git a/contracts/oracle/osmosis/src/migrations/v2_0_0.rs b/contracts/oracle/osmosis/src/migrations/v2_0_0.rs index 13ad96b54..9f3a0125f 100644 --- a/contracts/oracle/osmosis/src/migrations/v2_0_0.rs +++ b/contracts/oracle/osmosis/src/migrations/v2_0_0.rs @@ -1,7 +1,7 @@ use cosmwasm_std::{Decimal, DepsMut, Order, Response, StdResult}; use cw2::{assert_contract_version, set_contract_version}; use mars_oracle_base::ContractError; -use mars_red_bank_types::oracle::MigrateMsg; +use mars_types::oracle::MigrateMsg; use osmosis_std::types::osmosis::downtimedetector::v1beta1::Downtime; use crate::{ diff --git a/contracts/oracle/osmosis/src/msg.rs b/contracts/oracle/osmosis/src/msg.rs index 0abea7564..3b757b41f 100644 --- a/contracts/oracle/osmosis/src/msg.rs +++ b/contracts/oracle/osmosis/src/msg.rs @@ -1,4 +1,4 @@ -use mars_red_bank_types::oracle; +use mars_types::oracle; use crate::price_source::{OsmosisPriceSourceChecked, OsmosisPriceSourceUnchecked}; diff --git a/contracts/oracle/osmosis/src/price_source.rs b/contracts/oracle/osmosis/src/price_source.rs index f6c3bec17..f738d2705 100644 --- a/contracts/oracle/osmosis/src/price_source.rs +++ b/contracts/oracle/osmosis/src/price_source.rs @@ -12,7 +12,7 @@ use mars_osmosis::helpers::{ query_arithmetic_twap_price, query_geometric_twap_price, query_pool, query_spot_price, recovered_since_downtime_of_length, Pool, }; -use mars_red_bank_types::oracle::{ActionKind, Config}; +use mars_types::oracle::{ActionKind, Config}; use mars_utils::helpers::validate_native_denom; use osmosis_std::types::osmosis::downtimedetector::v1beta1::Downtime; use pyth_sdk_cw::PriceIdentifier; diff --git a/contracts/oracle/osmosis/tests/tests/helpers/mod.rs b/contracts/oracle/osmosis/tests/tests/helpers/mod.rs index ba18c9670..398723878 100644 --- a/contracts/oracle/osmosis/tests/tests/helpers/mod.rs +++ b/contracts/oracle/osmosis/tests/tests/helpers/mod.rs @@ -10,8 +10,8 @@ use cosmwasm_std::{ use mars_oracle_base::ContractError; use mars_oracle_osmosis::{contract::entry, msg::ExecuteMsg, OsmosisPriceSourceUnchecked}; use mars_osmosis::{BalancerPool, ConcentratedLiquidityPool, StableSwapPool}; -use mars_red_bank_types::oracle::msg::{InstantiateMsg, QueryMsg}; use mars_testing::{mock_info, MarsMockQuerier}; +use mars_types::oracle::msg::{InstantiateMsg, QueryMsg}; use osmosis_std::types::osmosis::{gamm::v1beta1::PoolAsset, poolmanager::v1beta1::PoolResponse}; use pyth_sdk_cw::PriceIdentifier; diff --git a/contracts/oracle/osmosis/tests/tests/test_admin.rs b/contracts/oracle/osmosis/tests/tests/test_admin.rs index 06758b60c..4550085fe 100644 --- a/contracts/oracle/osmosis/tests/tests/test_admin.rs +++ b/contracts/oracle/osmosis/tests/tests/test_admin.rs @@ -2,8 +2,8 @@ use cosmwasm_std::{attr, testing::mock_env}; use mars_oracle_base::ContractError; use mars_oracle_osmosis::{contract::entry, msg::ExecuteMsg}; use mars_owner::OwnerError::NotOwner; -use mars_red_bank_types::oracle::{ConfigResponse, InstantiateMsg, QueryMsg}; use mars_testing::{mock_dependencies, mock_info}; +use mars_types::oracle::{ConfigResponse, InstantiateMsg, QueryMsg}; use mars_utils::error::ValidationError; use super::helpers; diff --git a/contracts/oracle/osmosis/tests/tests/test_custom_execute.rs b/contracts/oracle/osmosis/tests/tests/test_custom_execute.rs index a0b7e8fcc..67e9fd05a 100644 --- a/contracts/oracle/osmosis/tests/tests/test_custom_execute.rs +++ b/contracts/oracle/osmosis/tests/tests/test_custom_execute.rs @@ -1,8 +1,8 @@ use cosmwasm_std::{testing::mock_env, Empty}; use mars_oracle_base::ContractError; use mars_oracle_osmosis::contract::entry; -use mars_red_bank_types::oracle::ExecuteMsg; use mars_testing::mock_info; +use mars_types::oracle::ExecuteMsg; use super::helpers; diff --git a/contracts/oracle/osmosis/tests/tests/test_migration_v2.rs b/contracts/oracle/osmosis/tests/tests/test_migration_v2.rs index b0c8f1bea..7b3ce4b59 100644 --- a/contracts/oracle/osmosis/tests/tests/test_migration_v2.rs +++ b/contracts/oracle/osmosis/tests/tests/test_migration_v2.rs @@ -8,8 +8,8 @@ use mars_oracle_osmosis::{ migrations::v2_0_0::v1_state, DowntimeDetector, OsmosisPriceSourceChecked, }; -use mars_red_bank_types::oracle::MigrateMsg; use mars_testing::mock_dependencies; +use mars_types::oracle::MigrateMsg; use osmosis_std::types::osmosis::downtimedetector::v1beta1::Downtime; use pyth_sdk_cw::PriceIdentifier; diff --git a/contracts/oracle/osmosis/tests/tests/test_query_price.rs b/contracts/oracle/osmosis/tests/tests/test_query_price.rs index 736ebb72d..e57b53f61 100644 --- a/contracts/oracle/osmosis/tests/tests/test_query_price.rs +++ b/contracts/oracle/osmosis/tests/tests/test_query_price.rs @@ -11,8 +11,8 @@ use mars_oracle_base::{pyth::scale_pyth_price, ContractError}; use mars_oracle_osmosis::{ contract::entry, DowntimeDetector, GeometricTwap, OsmosisPriceSourceUnchecked, RedemptionRate, }; -use mars_red_bank_types::oracle::{PriceResponse, QueryMsg}; use mars_testing::{mock_env_at_block_time, MarsMockQuerier}; +use mars_types::oracle::{PriceResponse, QueryMsg}; use osmosis_std::types::osmosis::{ downtimedetector::v1beta1::Downtime, poolmanager::v1beta1::SpotPriceResponse, diff --git a/contracts/oracle/osmosis/tests/tests/test_query_price_for_pyth.rs b/contracts/oracle/osmosis/tests/tests/test_query_price_for_pyth.rs index be8145645..207ebb52d 100644 --- a/contracts/oracle/osmosis/tests/tests/test_query_price_for_pyth.rs +++ b/contracts/oracle/osmosis/tests/tests/test_query_price_for_pyth.rs @@ -1,8 +1,8 @@ use cosmwasm_std::{from_binary, Decimal}; use mars_oracle_base::ContractError; use mars_oracle_osmosis::{contract::entry, OsmosisPriceSourceUnchecked}; -use mars_red_bank_types::oracle::{ActionKind, PriceResponse, QueryMsg}; use mars_testing::mock_env_at_block_time; +use mars_types::oracle::{ActionKind, PriceResponse, QueryMsg}; use pyth_sdk_cw::{Price, PriceFeed, PriceFeedResponse, PriceIdentifier}; use super::helpers; diff --git a/contracts/oracle/osmosis/tests/tests/test_remove_price_source.rs b/contracts/oracle/osmosis/tests/tests/test_remove_price_source.rs index 330622199..7b53647c0 100644 --- a/contracts/oracle/osmosis/tests/tests/test_remove_price_source.rs +++ b/contracts/oracle/osmosis/tests/tests/test_remove_price_source.rs @@ -6,8 +6,8 @@ use mars_oracle_osmosis::{ OsmosisPriceSourceUnchecked, }; use mars_owner::OwnerError::NotOwner; -use mars_red_bank_types::oracle::msg::QueryMsg; use mars_testing::mock_info; +use mars_types::oracle::msg::QueryMsg; use super::helpers; diff --git a/contracts/oracle/osmosis/tests/tests/test_set_price_source.rs b/contracts/oracle/osmosis/tests/tests/test_set_price_source.rs index 06e9feb92..83e2d6094 100644 --- a/contracts/oracle/osmosis/tests/tests/test_set_price_source.rs +++ b/contracts/oracle/osmosis/tests/tests/test_set_price_source.rs @@ -9,8 +9,8 @@ use mars_oracle_osmosis::{ RedemptionRate, }; use mars_owner::OwnerError::NotOwner; -use mars_red_bank_types::oracle::msg::QueryMsg; use mars_testing::mock_info; +use mars_types::oracle::msg::QueryMsg; use mars_utils::error::ValidationError; use osmosis_std::types::osmosis::downtimedetector::v1beta1::Downtime; use pyth_sdk_cw::PriceIdentifier; diff --git a/contracts/oracle/osmosis/tests/tests/test_update_owner.rs b/contracts/oracle/osmosis/tests/tests/test_update_owner.rs index c56f49c64..44881b4b2 100644 --- a/contracts/oracle/osmosis/tests/tests/test_update_owner.rs +++ b/contracts/oracle/osmosis/tests/tests/test_update_owner.rs @@ -3,7 +3,7 @@ use helpers::{query, setup_test_with_pools}; use mars_oracle_base::ContractError; use mars_oracle_osmosis::contract::entry::execute; use mars_owner::{OwnerError::NotOwner, OwnerUpdate}; -use mars_red_bank_types::oracle::msg::{ConfigResponse, ExecuteMsg, QueryMsg}; +use mars_types::oracle::msg::{ConfigResponse, ExecuteMsg, QueryMsg}; use super::helpers; diff --git a/contracts/oracle/wasm/examples/schema.rs b/contracts/oracle/wasm/examples/schema.rs index a73956d31..510c3fdc0 100644 --- a/contracts/oracle/wasm/examples/schema.rs +++ b/contracts/oracle/wasm/examples/schema.rs @@ -1,6 +1,6 @@ use cosmwasm_schema::write_api; use mars_oracle_wasm::WasmPriceSourceUnchecked; -use mars_red_bank_types::oracle::{ +use mars_types::oracle::{ msg::{ExecuteMsg, InstantiateMsg, QueryMsg}, WasmOracleCustomExecuteMsg, WasmOracleCustomInitParams, }; diff --git a/contracts/oracle/wasm/src/astroport_twap.rs b/contracts/oracle/wasm/src/astroport_twap.rs index d210e1f19..d9ce8a32f 100644 --- a/contracts/oracle/wasm/src/astroport_twap.rs +++ b/contracts/oracle/wasm/src/astroport_twap.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{attr, Attribute, DepsMut, Env, Response}; use mars_oracle_base::{ContractError, ContractResult}; -use mars_red_bank_types::oracle::AstroportTwapSnapshot; +use mars_types::oracle::AstroportTwapSnapshot; use crate::{ contract::WasmOracle, helpers::query_astroport_cumulative_price, diff --git a/contracts/oracle/wasm/src/contract.rs b/contracts/oracle/wasm/src/contract.rs index efc7d1624..3bb7e5012 100644 --- a/contracts/oracle/wasm/src/contract.rs +++ b/contracts/oracle/wasm/src/contract.rs @@ -1,6 +1,6 @@ use cosmwasm_std::Empty; use mars_oracle_base::OracleBase; -use mars_red_bank_types::oracle::{WasmOracleCustomExecuteMsg, WasmOracleCustomInitParams}; +use mars_types::oracle::{WasmOracleCustomExecuteMsg, WasmOracleCustomInitParams}; use crate::{ astroport_twap::ExecuteTwapSnapshots, WasmPriceSourceChecked, WasmPriceSourceUnchecked, @@ -25,7 +25,7 @@ pub mod entry { use cosmwasm_std::{entry_point, Binary, Decimal, Deps, DepsMut, Env, MessageInfo, Response}; use cw2::set_contract_version; use mars_oracle_base::{ContractError, ContractResult}; - use mars_red_bank_types::oracle::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; + use mars_types::oracle::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; use super::*; use crate::{state::ASTROPORT_FACTORY, WasmPriceSourceUnchecked}; diff --git a/contracts/oracle/wasm/src/helpers.rs b/contracts/oracle/wasm/src/helpers.rs index 1305acb4c..04be8e315 100644 --- a/contracts/oracle/wasm/src/helpers.rs +++ b/contracts/oracle/wasm/src/helpers.rs @@ -10,7 +10,7 @@ use cosmwasm_std::{ }; use cw_storage_plus::Map; use mars_oracle_base::{ContractError, ContractResult, PriceSourceChecked}; -use mars_red_bank_types::oracle::{ActionKind, AstroportTwapSnapshot, Config}; +use mars_types::oracle::{ActionKind, AstroportTwapSnapshot, Config}; use crate::WasmPriceSourceChecked; diff --git a/contracts/oracle/wasm/src/price_source.rs b/contracts/oracle/wasm/src/price_source.rs index 4df7140a7..fe1a6e101 100644 --- a/contracts/oracle/wasm/src/price_source.rs +++ b/contracts/oracle/wasm/src/price_source.rs @@ -8,7 +8,7 @@ use mars_oracle_base::{ ContractError::{self}, ContractResult, PriceSourceChecked, PriceSourceUnchecked, }; -use mars_red_bank_types::oracle::{ActionKind, AstroportTwapSnapshot, Config}; +use mars_types::oracle::{ActionKind, AstroportTwapSnapshot, Config}; use pyth_sdk_cw::PriceIdentifier; use crate::{ diff --git a/contracts/oracle/wasm/src/state.rs b/contracts/oracle/wasm/src/state.rs index 0dc178a2c..d597989a6 100644 --- a/contracts/oracle/wasm/src/state.rs +++ b/contracts/oracle/wasm/src/state.rs @@ -1,6 +1,6 @@ use cosmwasm_std::Addr; use cw_storage_plus::{Item, Map}; -use mars_red_bank_types::oracle::AstroportTwapSnapshot; +use mars_types::oracle::AstroportTwapSnapshot; /// The Astroport Factory contract address pub const ASTROPORT_FACTORY: Item = Item::new("astroport_factory"); diff --git a/contracts/oracle/wasm/tests/tests/helpers/mod.rs b/contracts/oracle/wasm/tests/tests/helpers/mod.rs index d97604d49..09f8f0845 100644 --- a/contracts/oracle/wasm/tests/tests/helpers/mod.rs +++ b/contracts/oracle/wasm/tests/tests/helpers/mod.rs @@ -5,8 +5,8 @@ use cosmwasm_std::{ DepsMut, OwnedDeps, }; use mars_oracle_wasm::{contract::entry, WasmPriceSourceUnchecked}; -use mars_red_bank_types::oracle::{ExecuteMsg, InstantiateMsg, WasmOracleCustomInitParams}; use mars_testing::{mock_info, MarsMockQuerier}; +use mars_types::oracle::{ExecuteMsg, InstantiateMsg, WasmOracleCustomInitParams}; pub fn setup_test( astroport_factory_address: &str, diff --git a/contracts/oracle/wasm/tests/tests/test_price_source.rs b/contracts/oracle/wasm/tests/tests/test_price_source.rs index 9949ff95f..b92652170 100644 --- a/contracts/oracle/wasm/tests/tests/test_price_source.rs +++ b/contracts/oracle/wasm/tests/tests/test_price_source.rs @@ -21,7 +21,7 @@ use mars_oracle_wasm::{ contract::entry::{self, execute}, WasmPriceSource, WasmPriceSourceChecked, WasmPriceSourceUnchecked, }; -use mars_red_bank_types::oracle::{ExecuteMsg, PriceResponse, QueryMsg}; +use mars_types::oracle::{ExecuteMsg, PriceResponse, QueryMsg}; use pyth_sdk_cw::PriceIdentifier; const ONE: Decimal = Decimal::one(); @@ -288,7 +288,7 @@ fn test_query_astroport_twap_price_with_only_one_snapshot() { let err = robot .wasm() - .query::<_, mars_red_bank_types::oracle::PriceResponse>( + .query::<_, mars_types::oracle::PriceResponse>( &robot.mars_oracle_contract_addr, &QueryMsg::Price { denom: "uatom".to_string(), @@ -746,7 +746,7 @@ fn twap_window_size_not_gt_tolerance() { }; let wasm = Wasm::new(&runner); - let msg = mars_red_bank_types::oracle::msg::ExecuteMsg::<_, Empty>::SetPriceSource { + let msg = mars_types::oracle::msg::ExecuteMsg::<_, Empty>::SetPriceSource { denom: "uatom".to_string(), price_source, }; diff --git a/contracts/params/examples/schema.rs b/contracts/params/examples/schema.rs index 4f1a23384..f575151e5 100644 --- a/contracts/params/examples/schema.rs +++ b/contracts/params/examples/schema.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::write_api; -use mars_red_bank_types::params::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use mars_types::params::{ExecuteMsg, InstantiateMsg, QueryMsg}; fn main() { write_api! { diff --git a/contracts/params/src/contract.rs b/contracts/params/src/contract.rs index 28d53f554..e4a7a36ee 100644 --- a/contracts/params/src/contract.rs +++ b/contracts/params/src/contract.rs @@ -3,7 +3,7 @@ use cosmwasm_std::entry_point; use cosmwasm_std::{to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response}; use cw2::set_contract_version; use mars_owner::OwnerInit::SetInitialOwner; -use mars_red_bank_types::params::{ +use mars_types::params::{ CmEmergencyUpdate, EmergencyUpdate, ExecuteMsg, InstantiateMsg, QueryMsg, RedBankEmergencyUpdate, }; diff --git a/contracts/params/src/error.rs b/contracts/params/src/error.rs index 495c631a9..69c7c1909 100644 --- a/contracts/params/src/error.rs +++ b/contracts/params/src/error.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{DecimalRangeExceeded, StdError}; use mars_owner::OwnerError; -use mars_red_bank_types::error::MarsError; +use mars_types::error::MarsError; pub use mars_utils::error::ValidationError; use thiserror::Error; diff --git a/contracts/params/src/execute.rs b/contracts/params/src/execute.rs index a70d5a773..b30779eae 100644 --- a/contracts/params/src/execute.rs +++ b/contracts/params/src/execute.rs @@ -1,5 +1,5 @@ use cosmwasm_std::{Decimal, DepsMut, MessageInfo, Response}; -use mars_red_bank_types::params::{AssetParamsUpdate, VaultConfigUpdate}; +use mars_types::params::{AssetParamsUpdate, VaultConfigUpdate}; use mars_utils::{error::ValidationError, helpers::option_string_to_addr}; use crate::{ diff --git a/contracts/params/src/query.rs b/contracts/params/src/query.rs index 32cf80a6b..2a660fa89 100644 --- a/contracts/params/src/query.rs +++ b/contracts/params/src/query.rs @@ -1,7 +1,7 @@ use cosmwasm_std::{Addr, Deps, Env, Order, StdResult, Uint128}; use cw_storage_plus::Bound; use mars_interest_rate::get_underlying_liquidity_amount; -use mars_red_bank_types::{ +use mars_types::{ address_provider::{self, MarsAddressType}, params::{AssetParams, ConfigResponse, TotalDepositResponse, VaultConfig}, red_bank::{self, Market, UserDebtResponse}, diff --git a/contracts/params/src/state.rs b/contracts/params/src/state.rs index eb48d8879..cf819f644 100644 --- a/contracts/params/src/state.rs +++ b/contracts/params/src/state.rs @@ -1,7 +1,7 @@ use cosmwasm_std::{Addr, Decimal}; use cw_storage_plus::{Item, Map}; use mars_owner::Owner; -use mars_red_bank_types::params::{AssetParams, VaultConfig}; +use mars_types::params::{AssetParams, VaultConfig}; pub const OWNER: Owner = Owner::new("owner"); pub const ADDRESS_PROVIDER: Item = Item::new("address_provider"); diff --git a/contracts/params/tests/tests/helpers/generator.rs b/contracts/params/tests/tests/helpers/generator.rs index 590cb9e64..d313364d0 100644 --- a/contracts/params/tests/tests/helpers/generator.rs +++ b/contracts/params/tests/tests/helpers/generator.rs @@ -1,7 +1,7 @@ use std::str::FromStr; use cosmwasm_std::{coin, Decimal, Uint128}; -use mars_red_bank_types::params::{ +use mars_types::params::{ AssetParamsUnchecked, CmSettings, LiquidationBonus, RedBankSettings, VaultConfigUnchecked, }; diff --git a/contracts/params/tests/tests/helpers/mock_env.rs b/contracts/params/tests/tests/helpers/mock_env.rs index d74855f49..f8eb5bf63 100644 --- a/contracts/params/tests/tests/helpers/mock_env.rs +++ b/contracts/params/tests/tests/helpers/mock_env.rs @@ -4,7 +4,7 @@ use anyhow::Result as AnyResult; use cosmwasm_std::{Addr, Decimal}; use cw_multi_test::{App, AppResponse, BasicApp, Executor}; use mars_owner::{OwnerResponse, OwnerUpdate}; -use mars_red_bank_types::params::{ +use mars_types::params::{ AssetParams, AssetParamsUpdate, ConfigResponse, EmergencyUpdate, ExecuteMsg, InstantiateMsg, QueryMsg, VaultConfig, VaultConfigUpdate, }; diff --git a/contracts/params/tests/tests/test_asset_validation.rs b/contracts/params/tests/tests/test_asset_validation.rs index 7613cfb9f..13a72c92d 100644 --- a/contracts/params/tests/tests/test_asset_validation.rs +++ b/contracts/params/tests/tests/test_asset_validation.rs @@ -2,7 +2,7 @@ use std::str::FromStr; use cosmwasm_std::Decimal; use mars_params::error::ContractError; -use mars_red_bank_types::{ +use mars_types::{ error::MarsError::Validation, params::{AssetParamsUpdate, HlsAssetType, HlsParamsUnchecked}, }; diff --git a/contracts/params/tests/tests/test_deposit_cap.rs b/contracts/params/tests/tests/test_deposit_cap.rs index a8fbc0038..d4f47290f 100644 --- a/contracts/params/tests/tests/test_deposit_cap.rs +++ b/contracts/params/tests/tests/test_deposit_cap.rs @@ -6,11 +6,11 @@ use mars_params::{ query::query_total_deposit, state::{ADDRESS_PROVIDER, ASSET_PARAMS}, }; -use mars_red_bank_types::{ +use mars_testing::{mock_dependencies, mock_env_at_block_time}; +use mars_types::{ params::TotalDepositResponse, red_bank::{Market, UserDebtResponse}, }; -use mars_testing::{mock_dependencies, mock_env_at_block_time}; use test_case::test_case; use super::helpers::default_asset_params; diff --git a/contracts/params/tests/tests/test_emergency_powers.rs b/contracts/params/tests/tests/test_emergency_powers.rs index 6081b97c5..7859eada0 100644 --- a/contracts/params/tests/tests/test_emergency_powers.rs +++ b/contracts/params/tests/tests/test_emergency_powers.rs @@ -1,7 +1,7 @@ use cosmwasm_std::Addr; use mars_owner::OwnerError; use mars_params::error::ContractError::Owner; -use mars_red_bank_types::params::{ +use mars_types::params::{ AssetParamsUpdate, CmEmergencyUpdate, EmergencyUpdate, RedBankEmergencyUpdate, VaultConfigUpdate, }; diff --git a/contracts/params/tests/tests/test_update_asset_params.rs b/contracts/params/tests/tests/test_update_asset_params.rs index 3c4a90344..14d514c5b 100644 --- a/contracts/params/tests/tests/test_update_asset_params.rs +++ b/contracts/params/tests/tests/test_update_asset_params.rs @@ -1,7 +1,7 @@ use cosmwasm_std::Addr; use mars_owner::OwnerError; use mars_params::error::ContractError::Owner; -use mars_red_bank_types::params::AssetParamsUpdate; +use mars_types::params::AssetParamsUpdate; use super::helpers::{assert_contents_equal, assert_err, default_asset_params, MockEnv}; diff --git a/contracts/params/tests/tests/test_vault_validation.rs b/contracts/params/tests/tests/test_vault_validation.rs index 0ec498f6d..167f0fafc 100644 --- a/contracts/params/tests/tests/test_vault_validation.rs +++ b/contracts/params/tests/tests/test_vault_validation.rs @@ -2,7 +2,7 @@ use std::str::FromStr; use cosmwasm_std::{Decimal, StdError::GenericErr}; use mars_params::error::ContractError; -use mars_red_bank_types::{ +use mars_types::{ error::MarsError::{Std, Validation}, params::{HlsParamsUnchecked, VaultConfigUpdate}, }; diff --git a/contracts/params/tests/tests/test_vaults.rs b/contracts/params/tests/tests/test_vaults.rs index 4d47c5aeb..3d65704b4 100644 --- a/contracts/params/tests/tests/test_vaults.rs +++ b/contracts/params/tests/tests/test_vaults.rs @@ -3,7 +3,7 @@ use std::str::FromStr; use cosmwasm_std::{Addr, Decimal}; use mars_owner::OwnerError; use mars_params::error::ContractError::Owner; -use mars_red_bank_types::params::{VaultConfigUnchecked, VaultConfigUpdate}; +use mars_types::params::{VaultConfigUnchecked, VaultConfigUpdate}; use super::helpers::{assert_contents_equal, assert_err, default_vault_config, MockEnv}; diff --git a/contracts/red-bank/examples/schema.rs b/contracts/red-bank/examples/schema.rs index 284869f78..ceb234f61 100644 --- a/contracts/red-bank/examples/schema.rs +++ b/contracts/red-bank/examples/schema.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::write_api; -use mars_red_bank_types::red_bank::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use mars_types::red_bank::{ExecuteMsg, InstantiateMsg, QueryMsg}; fn main() { write_api! { diff --git a/contracts/red-bank/src/asset.rs b/contracts/red-bank/src/asset.rs index 587c44011..2650d3a93 100644 --- a/contracts/red-bank/src/asset.rs +++ b/contracts/red-bank/src/asset.rs @@ -1,5 +1,5 @@ use cosmwasm_std::{Decimal, DepsMut, Env, MessageInfo, Response, Uint128}; -use mars_red_bank_types::{ +use mars_types::{ address_provider, address_provider::MarsAddressType, error::MarsError, diff --git a/contracts/red-bank/src/borrow.rs b/contracts/red-bank/src/borrow.rs index ad57b1a14..fc7345043 100644 --- a/contracts/red-bank/src/borrow.rs +++ b/contracts/red-bank/src/borrow.rs @@ -2,7 +2,7 @@ use cosmwasm_std::{DepsMut, Env, MessageInfo, Response, Uint128}; use mars_interest_rate::{ get_scaled_debt_amount, get_underlying_debt_amount, get_underlying_liquidity_amount, }; -use mars_red_bank_types::{address_provider, address_provider::MarsAddressType}; +use mars_types::{address_provider, address_provider::MarsAddressType}; use mars_utils::helpers::build_send_asset_msg; use crate::{ diff --git a/contracts/red-bank/src/collateral.rs b/contracts/red-bank/src/collateral.rs index ea0f07891..8f68fdfda 100644 --- a/contracts/red-bank/src/collateral.rs +++ b/contracts/red-bank/src/collateral.rs @@ -1,5 +1,5 @@ use cosmwasm_std::{DepsMut, Env, MessageInfo, Response}; -use mars_red_bank_types::{ +use mars_types::{ self, address_provider::{self, MarsAddressType}, keys::{UserId, UserIdKey}, diff --git a/contracts/red-bank/src/config.rs b/contracts/red-bank/src/config.rs index eede3e1c2..b9f9bfa66 100644 --- a/contracts/red-bank/src/config.rs +++ b/contracts/red-bank/src/config.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{DepsMut, MessageInfo, Response}; use mars_owner::OwnerUpdate; -use mars_red_bank_types::red_bank::CreateOrUpdateConfig; +use mars_types::red_bank::CreateOrUpdateConfig; use mars_utils::helpers::option_string_to_addr; use crate::{ diff --git a/contracts/red-bank/src/contract.rs b/contracts/red-bank/src/contract.rs index 880d19fa1..b941f7dd7 100644 --- a/contracts/red-bank/src/contract.rs +++ b/contracts/red-bank/src/contract.rs @@ -1,7 +1,7 @@ use cosmwasm_std::{ entry_point, to_binary, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Response, }; -use mars_red_bank_types::red_bank::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use mars_types::red_bank::{ExecuteMsg, InstantiateMsg, QueryMsg}; use crate::{ asset, borrow, collateral, config, deposit, error::ContractError, instantiate, liquidate, diff --git a/contracts/red-bank/src/deposit.rs b/contracts/red-bank/src/deposit.rs index e3fe60668..43a67c77f 100644 --- a/contracts/red-bank/src/deposit.rs +++ b/contracts/red-bank/src/deposit.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{Addr, DepsMut, Env, MessageInfo, Response, Uint128}; use mars_interest_rate::get_scaled_liquidity_amount; -use mars_red_bank_types::{ +use mars_types::{ address_provider::{self, MarsAddressType}, error::MarsError, }; diff --git a/contracts/red-bank/src/error.rs b/contracts/red-bank/src/error.rs index 1a2b950df..26b9728da 100644 --- a/contracts/red-bank/src/error.rs +++ b/contracts/red-bank/src/error.rs @@ -5,7 +5,7 @@ use cw_utils::PaymentError; use mars_health::error::HealthError; use mars_liquidation::error::LiquidationError; use mars_owner::OwnerError; -use mars_red_bank_types::error::MarsError; +use mars_types::error::MarsError; use mars_utils::error::{GuardError, ValidationError}; use thiserror::Error; diff --git a/contracts/red-bank/src/health.rs b/contracts/red-bank/src/health.rs index 5bf86bcd9..1a26ff975 100644 --- a/contracts/red-bank/src/health.rs +++ b/contracts/red-bank/src/health.rs @@ -3,7 +3,7 @@ use std::collections::{HashMap, HashSet}; use cosmwasm_std::{Addr, Deps, Env, Order, StdError, StdResult, Uint128}; use mars_health::health::{Health, Position as HealthPosition}; use mars_interest_rate::{get_underlying_debt_amount, get_underlying_liquidity_amount}; -use mars_red_bank_types::{ +use mars_types::{ keys::{UserId, UserIdKey}, oracle, red_bank::Position, diff --git a/contracts/red-bank/src/helpers.rs b/contracts/red-bank/src/helpers.rs index f9bd0cc78..3fe929e90 100644 --- a/contracts/red-bank/src/helpers.rs +++ b/contracts/red-bank/src/helpers.rs @@ -1,5 +1,5 @@ use cosmwasm_std::{Coin, Decimal, QuerierWrapper, StdResult}; -use mars_red_bank_types::params::{AssetParams, QueryMsg}; +use mars_types::params::{AssetParams, QueryMsg}; pub fn query_asset_params( querier: &QuerierWrapper, diff --git a/contracts/red-bank/src/instantiate.rs b/contracts/red-bank/src/instantiate.rs index a007a5b2f..e42091c48 100644 --- a/contracts/red-bank/src/instantiate.rs +++ b/contracts/red-bank/src/instantiate.rs @@ -1,7 +1,7 @@ use cosmwasm_std::{DepsMut, Response}; use cw2::set_contract_version; use mars_owner::OwnerInit::SetInitialOwner; -use mars_red_bank_types::{ +use mars_types::{ error::MarsError, red_bank::{Config, CreateOrUpdateConfig, InstantiateMsg}, }; diff --git a/contracts/red-bank/src/interest_rates.rs b/contracts/red-bank/src/interest_rates.rs index d0efc4c80..0132729f7 100644 --- a/contracts/red-bank/src/interest_rates.rs +++ b/contracts/red-bank/src/interest_rates.rs @@ -5,7 +5,7 @@ use mars_interest_rate::{ calculate_applied_linear_interest_rate, compute_scaled_amount, compute_underlying_amount, get_underlying_debt_amount, get_underlying_liquidity_amount, ScalingOperation, }; -use mars_red_bank_types::red_bank::Market; +use mars_types::red_bank::Market; use crate::{error::ContractError, user::User}; diff --git a/contracts/red-bank/src/liquidate.rs b/contracts/red-bank/src/liquidate.rs index b426785c0..de2e8684b 100644 --- a/contracts/red-bank/src/liquidate.rs +++ b/contracts/red-bank/src/liquidate.rs @@ -4,7 +4,7 @@ use mars_interest_rate::{ get_underlying_liquidity_amount, }; use mars_liquidation::liquidation::calculate_liquidation_amounts; -use mars_red_bank_types::{ +use mars_types::{ address_provider::{self, MarsAddressType}, keys::{UserId, UserIdKey}, }; diff --git a/contracts/red-bank/src/migrations/v2_0_0.rs b/contracts/red-bank/src/migrations/v2_0_0.rs index 3a85d103a..f396ed177 100644 --- a/contracts/red-bank/src/migrations/v2_0_0.rs +++ b/contracts/red-bank/src/migrations/v2_0_0.rs @@ -2,7 +2,7 @@ use cosmwasm_std::{Addr, DepsMut, MessageInfo, Order, Response, StdResult}; use cw2::{assert_contract_version, set_contract_version}; use cw_storage_plus::Bound; use mars_owner::OwnerInit; -use mars_red_bank_types::{ +use mars_types::{ keys::{UserId, UserIdKey}, red_bank::{Config, Market, MigrateV1ToV2}, }; @@ -19,7 +19,7 @@ pub mod v1_state { use cosmwasm_schema::cw_serde; use cosmwasm_std::{Addr, Decimal, Uint128}; use cw_storage_plus::{Item, Map}; - use mars_red_bank_types::red_bank::{Collateral, InterestRateModel}; + use mars_types::red_bank::{Collateral, InterestRateModel}; pub const OWNER: Item = Item::new("owner"); pub const CONFIG: Item = Item::new("config"); @@ -223,7 +223,7 @@ mod tests { use std::collections::HashMap; use cosmwasm_std::{attr, testing::mock_dependencies, Addr, Uint128}; - use mars_red_bank_types::red_bank::Collateral; + use mars_types::red_bank::Collateral; use mars_utils::error::GuardError; use super::*; diff --git a/contracts/red-bank/src/query.rs b/contracts/red-bank/src/query.rs index 824dfb71e..db8325fdc 100644 --- a/contracts/red-bank/src/query.rs +++ b/contracts/red-bank/src/query.rs @@ -4,7 +4,7 @@ use mars_interest_rate::{ get_scaled_debt_amount, get_scaled_liquidity_amount, get_underlying_debt_amount, get_underlying_liquidity_amount, }; -use mars_red_bank_types::{ +use mars_types::{ address_provider::{self, MarsAddressType}, keys::{UserId, UserIdKey}, red_bank::{ diff --git a/contracts/red-bank/src/repay.rs b/contracts/red-bank/src/repay.rs index b9c0fcc8c..e831ab6f6 100644 --- a/contracts/red-bank/src/repay.rs +++ b/contracts/red-bank/src/repay.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{Addr, DepsMut, Env, MessageInfo, Response, Uint128}; use mars_interest_rate::{get_scaled_debt_amount, get_underlying_debt_amount}; -use mars_red_bank_types::{address_provider, address_provider::MarsAddressType}; +use mars_types::{address_provider, address_provider::MarsAddressType}; use mars_utils::helpers::build_send_asset_msg; use crate::{ diff --git a/contracts/red-bank/src/state.rs b/contracts/red-bank/src/state.rs index d13b2767d..8554919f5 100644 --- a/contracts/red-bank/src/state.rs +++ b/contracts/red-bank/src/state.rs @@ -1,7 +1,7 @@ use cosmwasm_std::{Addr, Uint128}; use cw_storage_plus::{Item, Map}; use mars_owner::Owner; -use mars_red_bank_types::{ +use mars_types::{ keys::UserIdKey, red_bank::{Collateral, Config, Debt, Market}, }; diff --git a/contracts/red-bank/src/uncollateralized_loan.rs b/contracts/red-bank/src/uncollateralized_loan.rs index 7b4d839f9..175bfa8bc 100644 --- a/contracts/red-bank/src/uncollateralized_loan.rs +++ b/contracts/red-bank/src/uncollateralized_loan.rs @@ -1,5 +1,5 @@ use cosmwasm_std::{Addr, DepsMut, MessageInfo, Response, StdResult, Uint128}; -use mars_red_bank_types::red_bank::Debt; +use mars_types::red_bank::Debt; use crate::{ error::ContractError, diff --git a/contracts/red-bank/src/user.rs b/contracts/red-bank/src/user.rs index fc24f40fb..cd8adae87 100644 --- a/contracts/red-bank/src/user.rs +++ b/contracts/red-bank/src/user.rs @@ -1,7 +1,7 @@ use cosmwasm_std::{ to_binary, Addr, CosmosMsg, Order, Response, StdResult, Storage, Uint128, WasmMsg, }; -use mars_red_bank_types::{ +use mars_types::{ incentives, keys::{UserId, UserIdKey}, red_bank::{Collateral, Debt, Market}, diff --git a/contracts/red-bank/src/withdraw.rs b/contracts/red-bank/src/withdraw.rs index 890feec52..6f68fb15b 100644 --- a/contracts/red-bank/src/withdraw.rs +++ b/contracts/red-bank/src/withdraw.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{DepsMut, Env, MessageInfo, Response, Uint128}; use mars_interest_rate::{get_scaled_liquidity_amount, get_underlying_liquidity_amount}; -use mars_red_bank_types::{address_provider, address_provider::MarsAddressType, error::MarsError}; +use mars_types::{address_provider, address_provider::MarsAddressType, error::MarsError}; use mars_utils::helpers::build_send_asset_msg; use crate::{ diff --git a/contracts/red-bank/tests/tests/helpers/mod.rs b/contracts/red-bank/tests/tests/helpers/mod.rs index 23760fef2..cb790c956 100644 --- a/contracts/red-bank/tests/tests/helpers/mod.rs +++ b/contracts/red-bank/tests/tests/helpers/mod.rs @@ -19,7 +19,8 @@ use mars_red_bank::{ error::ContractError, state::{COLLATERALS, DEBTS, MARKETS}, }; -use mars_red_bank_types::{ +use mars_testing::{mock_dependencies, mock_env, mock_info, MarsMockQuerier, MockEnvParams}; +use mars_types::{ keys::{UserId, UserIdKey}, params::{AssetParams, CmSettings, LiquidationBonus, RedBankSettings}, red_bank::{ @@ -28,7 +29,6 @@ use mars_red_bank_types::{ UserHealthStatus, UserPositionResponse, }, }; -use mars_testing::{mock_dependencies, mock_env, mock_info, MarsMockQuerier, MockEnvParams}; pub fn set_collateral( deps: DepsMut, diff --git a/contracts/red-bank/tests/tests/test_admin.rs b/contracts/red-bank/tests/tests/test_admin.rs index 824772026..fbf8cc6c4 100644 --- a/contracts/red-bank/tests/tests/test_admin.rs +++ b/contracts/red-bank/tests/tests/test_admin.rs @@ -6,7 +6,8 @@ use mars_red_bank::{ error::ContractError, state::{COLLATERALS, MARKETS}, }; -use mars_red_bank_types::{ +use mars_testing::{mock_dependencies, mock_env, mock_env_at_block_time, MockEnvParams}; +use mars_types::{ address_provider::MarsAddressType, error::MarsError, keys::{UserId, UserIdKey}, @@ -15,7 +16,6 @@ use mars_red_bank_types::{ InterestRateModel, Market, QueryMsg, }, }; -use mars_testing::{mock_dependencies, mock_env, mock_env_at_block_time, MockEnvParams}; use mars_utils::error::ValidationError; use super::helpers::{th_get_expected_indices, th_init_market, th_setup}; diff --git a/contracts/red-bank/tests/tests/test_borrow.rs b/contracts/red-bank/tests/tests/test_borrow.rs index 4fd373b8a..9a78dafe5 100644 --- a/contracts/red-bank/tests/tests/test_borrow.rs +++ b/contracts/red-bank/tests/tests/test_borrow.rs @@ -11,11 +11,11 @@ use mars_red_bank::{ error::ContractError, state::{DEBTS, MARKETS, UNCOLLATERALIZED_LOAN_LIMITS}, }; -use mars_red_bank_types::{ +use mars_testing::{mock_env, mock_env_at_block_time, MockEnvParams}; +use mars_types::{ params::{AssetParams, CmSettings, RedBankSettings}, red_bank::{ExecuteMsg, Market}, }; -use mars_testing::{mock_env, mock_env_at_block_time, MockEnvParams}; use super::helpers::{ has_collateral_position, has_debt_position, set_collateral, th_build_interests_updated_event, diff --git a/contracts/red-bank/tests/tests/test_credit_accounts.rs b/contracts/red-bank/tests/tests/test_credit_accounts.rs index edbce8428..cf2fce548 100644 --- a/contracts/red-bank/tests/tests/test_credit_accounts.rs +++ b/contracts/red-bank/tests/tests/test_credit_accounts.rs @@ -1,7 +1,7 @@ use cosmwasm_std::{coin, Addr, Decimal, Uint128}; use mars_red_bank::error::ContractError; -use mars_red_bank_types::red_bank::UserHealthStatus; use mars_testing::integration::mock_env::MockEnvBuilder; +use mars_types::red_bank::UserHealthStatus; use super::helpers::assert_err; use crate::tests::helpers::{osmo_asset_params, usdc_asset_params}; diff --git a/contracts/red-bank/tests/tests/test_deposit.rs b/contracts/red-bank/tests/tests/test_deposit.rs index 271ea392f..0e9ce2ba7 100644 --- a/contracts/red-bank/tests/tests/test_deposit.rs +++ b/contracts/red-bank/tests/tests/test_deposit.rs @@ -14,7 +14,8 @@ use mars_red_bank::{ error::ContractError, state::{COLLATERALS, MARKETS}, }; -use mars_red_bank_types::{ +use mars_testing::{mock_env_at_block_time, MarsMockQuerier}; +use mars_types::{ address_provider::MarsAddressType, error::MarsError, incentives, @@ -22,7 +23,6 @@ use mars_red_bank_types::{ params::{AssetParams, CmSettings, LiquidationBonus, RedBankSettings}, red_bank::{Collateral, ExecuteMsg, Market}, }; -use mars_testing::{mock_env_at_block_time, MarsMockQuerier}; use test_case::test_case; use super::helpers::{ diff --git a/contracts/red-bank/tests/tests/test_health.rs b/contracts/red-bank/tests/tests/test_health.rs index d85bd664c..cbab4cd70 100644 --- a/contracts/red-bank/tests/tests/test_health.rs +++ b/contracts/red-bank/tests/tests/test_health.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use cosmwasm_std::{CheckedMultiplyRatioError, Decimal, Uint128}; use mars_health::error::HealthError; use mars_red_bank::{error::ContractError, health::compute_position_health}; -use mars_red_bank_types::red_bank::Position; +use mars_types::red_bank::Position; #[test] fn health_position() { diff --git a/contracts/red-bank/tests/tests/test_liquidate.rs b/contracts/red-bank/tests/tests/test_liquidate.rs index b2a1a92e3..88d01bf0a 100644 --- a/contracts/red-bank/tests/tests/test_liquidate.rs +++ b/contracts/red-bank/tests/tests/test_liquidate.rs @@ -7,7 +7,11 @@ use cosmwasm_std::{ }; use cw_utils::PaymentError; use mars_red_bank::{contract::execute, error::ContractError}; -use mars_red_bank_types::{ +use mars_testing::{ + integration::mock_env::{MockEnv, MockEnvBuilder}, + mock_env_at_block_time, +}; +use mars_types::{ address_provider::MarsAddressType, incentives, params::{AssetParams, CmSettings, LiquidationBonus, RedBankSettings}, @@ -16,10 +20,6 @@ use mars_red_bank_types::{ UserCollateralResponse, UserDebtResponse, }, }; -use mars_testing::{ - integration::mock_env::{MockEnv, MockEnvBuilder}, - mock_env_at_block_time, -}; use super::helpers::{ assert_err, liq_threshold_hf, merge_collaterals_and_debts, th_build_interests_updated_event, diff --git a/contracts/red-bank/tests/tests/test_migration_v2.rs b/contracts/red-bank/tests/tests/test_migration_v2.rs index 488b5310c..fa4213ee9 100644 --- a/contracts/red-bank/tests/tests/test_migration_v2.rs +++ b/contracts/red-bank/tests/tests/test_migration_v2.rs @@ -12,11 +12,11 @@ use mars_red_bank::{ migrations::v2_0_0::v1_state::{self, OwnerSetNoneProposed}, state::{COLLATERALS, CONFIG, MARKETS, MIGRATION_GUARD, OWNER}, }; -use mars_red_bank_types::{ +use mars_testing::mock_dependencies; +use mars_types::{ keys::{UserId, UserIdKey}, red_bank::{Collateral, ExecuteMsg, InterestRateModel, Market, MigrateV1ToV2}, }; -use mars_testing::mock_dependencies; use mars_utils::error::GuardError; #[test] diff --git a/contracts/red-bank/tests/tests/test_misc.rs b/contracts/red-bank/tests/tests/test_misc.rs index a6404532a..0c0c697f4 100644 --- a/contracts/red-bank/tests/tests/test_misc.rs +++ b/contracts/red-bank/tests/tests/test_misc.rs @@ -12,11 +12,11 @@ use mars_red_bank::{ health, state::{DEBTS, MARKETS, UNCOLLATERALIZED_LOAN_LIMITS}, }; -use mars_red_bank_types::{ +use mars_testing::{mock_env, mock_env_at_block_time, MockEnvParams}; +use mars_types::{ params::AssetParams, red_bank::{Debt, ExecuteMsg, Market}, }; -use mars_testing::{mock_env, mock_env_at_block_time, MockEnvParams}; use super::helpers::{ has_collateral_enabled, has_collateral_position, has_debt_position, set_collateral, set_debt, diff --git a/contracts/red-bank/tests/tests/test_payment.rs b/contracts/red-bank/tests/tests/test_payment.rs index 551b6cfbb..d1b1aad86 100644 --- a/contracts/red-bank/tests/tests/test_payment.rs +++ b/contracts/red-bank/tests/tests/test_payment.rs @@ -5,7 +5,7 @@ use cosmwasm_std::{ }; use cw_utils::PaymentError; use mars_red_bank::contract; -use mars_red_bank_types::red_bank::ExecuteMsg; +use mars_types::red_bank::ExecuteMsg; use super::helpers::th_setup; diff --git a/contracts/red-bank/tests/tests/test_query.rs b/contracts/red-bank/tests/tests/test_query.rs index 92a213bd4..c853cd371 100644 --- a/contracts/red-bank/tests/tests/test_query.rs +++ b/contracts/red-bank/tests/tests/test_query.rs @@ -4,7 +4,7 @@ use mars_red_bank::{ query::{query_user_collaterals, query_user_collaterals_v2, query_user_debt, query_user_debts}, state::DEBTS, }; -use mars_red_bank_types::red_bank::{Debt, Market, UserCollateralResponse, UserDebtResponse}; +use mars_types::red_bank::{Debt, Market, UserCollateralResponse, UserDebtResponse}; use super::helpers::{set_collateral, th_init_market, th_setup}; diff --git a/contracts/red-bank/tests/tests/test_update_owner.rs b/contracts/red-bank/tests/tests/test_update_owner.rs index 8cd8975f5..cdd48ee26 100644 --- a/contracts/red-bank/tests/tests/test_update_owner.rs +++ b/contracts/red-bank/tests/tests/test_update_owner.rs @@ -1,7 +1,7 @@ use cosmwasm_std::testing::{mock_env, mock_info}; use mars_owner::{OwnerError::NotOwner, OwnerUpdate}; use mars_red_bank::{contract::execute, error::ContractError}; -use mars_red_bank_types::red_bank::{ConfigResponse, ExecuteMsg, QueryMsg}; +use mars_types::red_bank::{ConfigResponse, ExecuteMsg, QueryMsg}; use super::helpers::{th_query, th_setup}; diff --git a/contracts/red-bank/tests/tests/test_withdraw.rs b/contracts/red-bank/tests/tests/test_withdraw.rs index 25c75aa6b..55e2fe05a 100644 --- a/contracts/red-bank/tests/tests/test_withdraw.rs +++ b/contracts/red-bank/tests/tests/test_withdraw.rs @@ -14,7 +14,10 @@ use mars_red_bank::{ error::ContractError, state::{COLLATERALS, DEBTS, MARKETS}, }; -use mars_red_bank_types::{ +use mars_testing::{ + integration::mock_env::MockEnvBuilder, mock_env_at_block_time, MarsMockQuerier, +}; +use mars_types::{ address_provider::MarsAddressType, error::MarsError, incentives, @@ -22,9 +25,6 @@ use mars_red_bank_types::{ params::AssetParams, red_bank::{Collateral, Debt, ExecuteMsg, Market}, }; -use mars_testing::{ - integration::mock_env::MockEnvBuilder, mock_env_at_block_time, MarsMockQuerier, -}; use super::helpers::{ has_collateral_position, set_collateral, th_build_interests_updated_event, diff --git a/contracts/rewards-collector/base/examples/schema.rs b/contracts/rewards-collector/base/examples/schema.rs index 695dede36..a551d114f 100644 --- a/contracts/rewards-collector/base/examples/schema.rs +++ b/contracts/rewards-collector/base/examples/schema.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::write_api; -use mars_red_bank_types::rewards_collector::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use mars_types::rewards_collector::{ExecuteMsg, InstantiateMsg, QueryMsg}; fn main() { write_api! { diff --git a/contracts/rewards-collector/base/src/contract.rs b/contracts/rewards-collector/base/src/contract.rs index 40c2d26ec..da2e4d3e7 100644 --- a/contracts/rewards-collector/base/src/contract.rs +++ b/contracts/rewards-collector/base/src/contract.rs @@ -4,11 +4,11 @@ use cosmwasm_std::{ }; use cw_storage_plus::Item; use mars_owner::{Owner, OwnerInit::SetInitialOwner, OwnerUpdate}; -use mars_red_bank_types::{ +use mars_types::{ address_provider::{self, AddressResponseItem, MarsAddressType}, + credit_manager::{self, Action}, incentives, red_bank, rewards_collector::{ - credit_manager::{self, Action}, Config, ConfigResponse, ExecuteMsg, InstantiateMsg, QueryMsg, UpdateConfig, }, }; @@ -280,7 +280,7 @@ where .querier .query_wasm_smart::( cfg.address_provider, - &mars_red_bank_types::address_provider::QueryMsg::Address(MarsAddressType::Swapper), + &mars_types::address_provider::QueryMsg::Address(MarsAddressType::Swapper), )? .address; @@ -299,7 +299,7 @@ where let coin_in_safety_fund = coin(amount_safety_fund.u128(), denom.clone()); messages.push(WasmMsg::Execute { contract_addr: swapper_addr.clone(), - msg: to_binary(&mars_red_bank_types::swapper::ExecuteMsg::::SwapExactIn { + msg: to_binary(&mars_types::swapper::ExecuteMsg::::SwapExactIn { coin_in: coin_in_safety_fund.clone(), denom_out: cfg.safety_fund_denom, slippage: cfg.slippage_tolerance, @@ -314,7 +314,7 @@ where let coin_in_fee_collector = coin(amount_fee_collector.u128(), denom.clone()); messages.push(WasmMsg::Execute { contract_addr: swapper_addr, - msg: to_binary(&mars_red_bank_types::swapper::ExecuteMsg::::SwapExactIn { + msg: to_binary(&mars_types::swapper::ExecuteMsg::::SwapExactIn { coin_in: coin_in_fee_collector.clone(), denom_out: cfg.fee_collector_denom, slippage: cfg.slippage_tolerance, diff --git a/contracts/rewards-collector/base/src/error.rs b/contracts/rewards-collector/base/src/error.rs index 23f56ee6c..9c0acad1b 100644 --- a/contracts/rewards-collector/base/src/error.rs +++ b/contracts/rewards-collector/base/src/error.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{CheckedMultiplyRatioError, OverflowError, StdError, Uint128}; use mars_owner::OwnerError; -use mars_red_bank_types::error::MarsError; +use mars_types::error::MarsError; use mars_utils::error::ValidationError; use thiserror::Error; diff --git a/contracts/rewards-collector/base/src/traits.rs b/contracts/rewards-collector/base/src/traits.rs index f909dcf41..824910d96 100644 --- a/contracts/rewards-collector/base/src/traits.rs +++ b/contracts/rewards-collector/base/src/traits.rs @@ -4,7 +4,7 @@ use cosmwasm_std::{ Coin, CosmosMsg, CustomMsg, CustomQuery, Decimal, Empty, Env, IbcMsg, IbcTimeout, QuerierWrapper, Uint128, }; -use mars_red_bank_types::rewards_collector::Config; +use mars_types::rewards_collector::Config; use schemars::JsonSchema; use serde::{de::DeserializeOwned, Serialize}; diff --git a/contracts/rewards-collector/neutron/src/lib.rs b/contracts/rewards-collector/neutron/src/lib.rs index d84861f71..bdb98bf55 100644 --- a/contracts/rewards-collector/neutron/src/lib.rs +++ b/contracts/rewards-collector/neutron/src/lib.rs @@ -16,7 +16,7 @@ impl IbcTransferMsg for NeutronIbcMsgFactory { env: Env, to_address: String, amount: Coin, - cfg: mars_red_bank_types::rewards_collector::Config, + cfg: mars_types::rewards_collector::Config, ) -> ContractResult> { let neutron_config = cfg.neutron_ibc_config.ok_or(ContractError::Std( StdError::generic_err("source_port must be provided for neutron"), @@ -51,8 +51,8 @@ pub mod entry { entry_point, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Response, StdResult, }; use cw2::set_contract_version; - use mars_red_bank_types::rewards_collector::{ExecuteMsg, InstantiateMsg, QueryMsg}; use mars_rewards_collector_base::ContractResult; + use mars_types::rewards_collector::{ExecuteMsg, InstantiateMsg, QueryMsg}; use neutron_sdk::bindings::msg::NeutronMsg; use crate::NeutronCollector; diff --git a/contracts/rewards-collector/osmosis/src/lib.rs b/contracts/rewards-collector/osmosis/src/lib.rs index 651feb072..93f9b1560 100644 --- a/contracts/rewards-collector/osmosis/src/lib.rs +++ b/contracts/rewards-collector/osmosis/src/lib.rs @@ -6,8 +6,8 @@ pub mod entry { entry_point, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Response, StdResult, }; use cw2::set_contract_version; - use mars_red_bank_types::rewards_collector::{ExecuteMsg, InstantiateMsg, QueryMsg}; use mars_rewards_collector_base::{contract::Collector, ContractError, ContractResult}; + use mars_types::rewards_collector::{ExecuteMsg, InstantiateMsg, QueryMsg}; use crate::migrations; diff --git a/contracts/rewards-collector/osmosis/tests/tests/helpers/mod.rs b/contracts/rewards-collector/osmosis/tests/tests/helpers/mod.rs index 6760a31b3..1a42ae2ae 100644 --- a/contracts/rewards-collector/osmosis/tests/tests/helpers/mod.rs +++ b/contracts/rewards-collector/osmosis/tests/tests/helpers/mod.rs @@ -6,9 +6,9 @@ use cosmwasm_std::{ Coin, Decimal, Deps, OwnedDeps, }; use mars_osmosis::BalancerPool; -use mars_red_bank_types::rewards_collector::{Config, InstantiateMsg, QueryMsg}; use mars_rewards_collector_osmosis::entry; use mars_testing::{mock_info, MarsMockQuerier}; +use mars_types::rewards_collector::{Config, InstantiateMsg, QueryMsg}; use osmosis_std::types::osmosis::{gamm::v1beta1::PoolAsset, poolmanager::v1beta1::PoolResponse}; pub fn mock_instantiate_msg() -> InstantiateMsg { diff --git a/contracts/rewards-collector/osmosis/tests/tests/test_admin.rs b/contracts/rewards-collector/osmosis/tests/tests/test_admin.rs index 8cbe282b0..4c08242f8 100644 --- a/contracts/rewards-collector/osmosis/tests/tests/test_admin.rs +++ b/contracts/rewards-collector/osmosis/tests/tests/test_admin.rs @@ -1,9 +1,9 @@ use cosmwasm_std::{testing::mock_env, Decimal}; use mars_owner::OwnerError::NotOwner; -use mars_red_bank_types::rewards_collector::{ConfigResponse, ExecuteMsg, QueryMsg, UpdateConfig}; use mars_rewards_collector_base::ContractError; use mars_rewards_collector_osmosis::entry::{execute, instantiate}; use mars_testing::mock_info; +use mars_types::rewards_collector::{ConfigResponse, ExecuteMsg, QueryMsg, UpdateConfig}; use mars_utils::error::ValidationError; use super::{ diff --git a/contracts/rewards-collector/osmosis/tests/tests/test_distribute_rewards.rs b/contracts/rewards-collector/osmosis/tests/tests/test_distribute_rewards.rs index fd7373b68..b5f52d9a3 100644 --- a/contracts/rewards-collector/osmosis/tests/tests/test_distribute_rewards.rs +++ b/contracts/rewards-collector/osmosis/tests/tests/test_distribute_rewards.rs @@ -1,10 +1,10 @@ use cosmwasm_std::{ coin, testing::mock_env, CosmosMsg, IbcMsg, IbcTimeout, SubMsg, Timestamp, Uint128, }; -use mars_red_bank_types::rewards_collector::ExecuteMsg; use mars_rewards_collector_base::ContractError; use mars_rewards_collector_osmosis::entry::execute; use mars_testing::{mock_env as mock_env_at_height_and_time, mock_info, MockEnvParams}; +use mars_types::rewards_collector::ExecuteMsg; use super::helpers; diff --git a/contracts/rewards-collector/osmosis/tests/tests/test_swap.rs b/contracts/rewards-collector/osmosis/tests/tests/test_swap.rs index 3bbaa7e38..56ccb5b92 100644 --- a/contracts/rewards-collector/osmosis/tests/tests/test_swap.rs +++ b/contracts/rewards-collector/osmosis/tests/tests/test_swap.rs @@ -1,12 +1,12 @@ use cosmwasm_std::{ coin, testing::mock_env, to_binary, CosmosMsg, Decimal, Empty, SubMsg, Uint128, WasmMsg, }; -use mars_red_bank_types::{ +use mars_rewards_collector_osmosis::entry::execute; +use mars_testing::mock_info; +use mars_types::{ rewards_collector::{ConfigResponse, ExecuteMsg, QueryMsg}, swapper, }; -use mars_rewards_collector_osmosis::entry::execute; -use mars_testing::mock_info; use osmosis_std::types::osmosis::twap::v1beta1::ArithmeticTwapToNowResponse; use super::{helpers, helpers::mock_instantiate_msg}; diff --git a/contracts/rewards-collector/osmosis/tests/tests/test_update_owner.rs b/contracts/rewards-collector/osmosis/tests/tests/test_update_owner.rs index 102b46a91..f04ce4a1b 100644 --- a/contracts/rewards-collector/osmosis/tests/tests/test_update_owner.rs +++ b/contracts/rewards-collector/osmosis/tests/tests/test_update_owner.rs @@ -1,8 +1,8 @@ use cosmwasm_std::testing::{mock_env, mock_info}; use mars_owner::{OwnerError::NotOwner, OwnerUpdate}; -use mars_red_bank_types::rewards_collector::{ConfigResponse, ExecuteMsg, QueryMsg}; use mars_rewards_collector_base::ContractError; use mars_rewards_collector_osmosis::entry::execute; +use mars_types::rewards_collector::{ConfigResponse, ExecuteMsg, QueryMsg}; use super::helpers::{query, setup_test}; diff --git a/contracts/rewards-collector/osmosis/tests/tests/test_withdraw.rs b/contracts/rewards-collector/osmosis/tests/tests/test_withdraw.rs index 9ce1f6616..d25baa6cf 100644 --- a/contracts/rewards-collector/osmosis/tests/tests/test_withdraw.rs +++ b/contracts/rewards-collector/osmosis/tests/tests/test_withdraw.rs @@ -1,11 +1,11 @@ use cosmwasm_std::{testing::mock_env, to_binary, CosmosMsg, Decimal, SubMsg, Uint128, WasmMsg}; -use mars_red_bank_types::rewards_collector::{ - credit_manager::{self, Action, ActionAmount, ActionCoin}, - ExecuteMsg, -}; use mars_rewards_collector_base::ContractError; use mars_rewards_collector_osmosis::entry::execute; use mars_testing::mock_info; +use mars_types::{ + credit_manager::{self, Action, ActionAmount, ActionCoin}, + rewards_collector::ExecuteMsg, +}; use super::helpers; @@ -30,7 +30,7 @@ fn withdrawing_from_red_bank() { res.messages[0], SubMsg::new(CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: "red_bank".to_string(), - msg: to_binary(&mars_red_bank_types::red_bank::ExecuteMsg::Withdraw { + msg: to_binary(&mars_types::red_bank::ExecuteMsg::Withdraw { denom: "uatom".to_string(), amount: Some(Uint128::new(42069)), recipient: None, @@ -59,7 +59,6 @@ fn withdrawing_from_cm_if_action_not_allowed() { denom: "uatom".to_string(), amount: ActionAmount::Exact(Uint128::new(100)), }), - Action::Unknown {}, Action::WithdrawLiquidity { lp_token: ActionCoin { denom: "gamm/pool/1".to_string(), @@ -67,6 +66,7 @@ fn withdrawing_from_cm_if_action_not_allowed() { }, slippage: Decimal::percent(5), }, + Action::RefundAllCoinBalances {}, ], }, ) diff --git a/contracts/swapper/astroport/examples/schema.rs b/contracts/swapper/astroport/examples/schema.rs index f9222947f..268a16673 100644 --- a/contracts/swapper/astroport/examples/schema.rs +++ b/contracts/swapper/astroport/examples/schema.rs @@ -1,6 +1,6 @@ use cosmwasm_schema::write_api; -use mars_red_bank_types::swapper::{ExecuteMsg, InstantiateMsg, QueryMsg}; use mars_swapper_astroport::route::AstroportRoute; +use mars_types::swapper::{ExecuteMsg, InstantiateMsg, QueryMsg}; fn main() { write_api! { diff --git a/contracts/swapper/astroport/src/contract.rs b/contracts/swapper/astroport/src/contract.rs index 671b03cce..376fe2390 100644 --- a/contracts/swapper/astroport/src/contract.rs +++ b/contracts/swapper/astroport/src/contract.rs @@ -1,7 +1,7 @@ use cosmwasm_std::{entry_point, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Response}; use cw2::set_contract_version; -use mars_red_bank_types::swapper::{ExecuteMsg, InstantiateMsg, QueryMsg}; use mars_swapper_base::{ContractResult, SwapBase}; +use mars_types::swapper::{ExecuteMsg, InstantiateMsg, QueryMsg}; use crate::route::AstroportRoute; diff --git a/contracts/swapper/astroport/src/route.rs b/contracts/swapper/astroport/src/route.rs index 96cebe3a6..a526c4c91 100644 --- a/contracts/swapper/astroport/src/route.rs +++ b/contracts/swapper/astroport/src/route.rs @@ -6,8 +6,8 @@ use cosmwasm_std::{ to_binary, Coin, CosmosMsg, Decimal, Empty, Env, QuerierWrapper, QueryRequest, StdError, StdResult, Uint128, WasmMsg, WasmQuery, }; -use mars_red_bank_types::{oracle::PriceResponse, swapper::EstimateExactInSwapResponse}; use mars_swapper_base::{ContractError, ContractResult, Route}; +use mars_types::{oracle::PriceResponse, swapper::EstimateExactInSwapResponse}; use crate::helpers::hashset; @@ -54,7 +54,7 @@ impl AstroportRoute { querier .query::(&QueryRequest::Wasm(WasmQuery::Smart { contract_addr: self.oracle.clone(), - msg: to_binary(&mars_red_bank_types::oracle::QueryMsg::Price { + msg: to_binary(&mars_types::oracle::QueryMsg::Price { denom: denom.to_string(), kind: None, })?, diff --git a/contracts/swapper/astroport/tests/tests/test_routes.rs b/contracts/swapper/astroport/tests/tests/test_routes.rs index 6a5e084e3..03da80c05 100644 --- a/contracts/swapper/astroport/tests/tests/test_routes.rs +++ b/contracts/swapper/astroport/tests/tests/test_routes.rs @@ -1,9 +1,9 @@ use astroport::{asset::AssetInfo, router::SwapOperation}; use cosmwasm_std::coin; use cw_it::{astroport::robot::AstroportTestRobot, robot::TestRobot, traits::CwItRunner}; -use mars_red_bank_types::swapper::RouteResponse; use mars_swapper_astroport::route::AstroportRoute; use mars_testing::{astroport_swapper::AstroportSwapperRobot, test_runner::get_test_runner}; +use mars_types::swapper::RouteResponse; use test_case::test_case; fn to_native_swap_operation((denom_in, denom_out): (&str, &str)) -> SwapOperation { @@ -101,7 +101,7 @@ fn query_non_existing_route() { .wasm() .query::<_, RouteResponse>( &robot.swapper, - &mars_red_bank_types::swapper::QueryMsg::Route { + &mars_types::swapper::QueryMsg::Route { denom_in: denom_in.into(), denom_out: denom_out.into(), }, diff --git a/contracts/swapper/astroport/tests/tests/test_transfer_result.rs b/contracts/swapper/astroport/tests/tests/test_transfer_result.rs index 25dc82877..8ad670d24 100644 --- a/contracts/swapper/astroport/tests/tests/test_transfer_result.rs +++ b/contracts/swapper/astroport/tests/tests/test_transfer_result.rs @@ -15,7 +15,7 @@ fn transfer_result_unauthorized() { let denom_in = "uosmo".to_string(); let denom_out = "usd".to_string(); - let msg = mars_red_bank_types::swapper::ExecuteMsg::::TransferResult { + let msg = mars_types::swapper::ExecuteMsg::::TransferResult { recipient: Addr::unchecked(admin.address()), denom_in, denom_out, diff --git a/contracts/swapper/base/examples/schema.rs b/contracts/swapper/base/examples/schema.rs index bd347f5f1..5b359e32f 100644 --- a/contracts/swapper/base/examples/schema.rs +++ b/contracts/swapper/base/examples/schema.rs @@ -1,6 +1,6 @@ use cosmwasm_schema::write_api; use cosmwasm_std::Empty; -use mars_red_bank_types::swapper::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use mars_types::swapper::{ExecuteMsg, InstantiateMsg, QueryMsg}; fn main() { write_api! { diff --git a/contracts/swapper/base/src/contract.rs b/contracts/swapper/base/src/contract.rs index f597aa0e6..548815f49 100644 --- a/contracts/swapper/base/src/contract.rs +++ b/contracts/swapper/base/src/contract.rs @@ -7,7 +7,7 @@ use cosmwasm_std::{ use cw_paginate::paginate_map; use cw_storage_plus::{Bound, Map}; use mars_owner::{Owner, OwnerInit::SetInitialOwner, OwnerUpdate}; -use mars_red_bank_types::swapper::{ +use mars_types::swapper::{ EstimateExactInSwapResponse, ExecuteMsg, InstantiateMsg, QueryMsg, RouteResponse, RoutesResponse, }; diff --git a/contracts/swapper/base/src/traits.rs b/contracts/swapper/base/src/traits.rs index a607d1e5c..c95b7a6e9 100644 --- a/contracts/swapper/base/src/traits.rs +++ b/contracts/swapper/base/src/traits.rs @@ -1,7 +1,7 @@ use std::fmt::{Debug, Display}; use cosmwasm_std::{Coin, CosmosMsg, CustomMsg, CustomQuery, Decimal, Env, QuerierWrapper}; -use mars_red_bank_types::swapper::EstimateExactInSwapResponse; +use mars_types::swapper::EstimateExactInSwapResponse; use schemars::JsonSchema; use serde::{de::DeserializeOwned, Serialize}; diff --git a/contracts/swapper/mock/src/contract.rs b/contracts/swapper/mock/src/contract.rs index cffd7fcfe..39162838d 100644 --- a/contracts/swapper/mock/src/contract.rs +++ b/contracts/swapper/mock/src/contract.rs @@ -2,9 +2,7 @@ use cosmwasm_std::{ coins, to_binary, BankMsg, Binary, Coin, CosmosMsg, Decimal, Deps, DepsMut, Empty, Env, MessageInfo, Response, StdError, StdResult, Uint128, }; -use mars_red_bank_types::swapper::{ - EstimateExactInSwapResponse, ExecuteMsg, InstantiateMsg, QueryMsg, -}; +use mars_types::swapper::{EstimateExactInSwapResponse, ExecuteMsg, InstantiateMsg, QueryMsg}; pub const MOCK_SWAP_RESULT: Uint128 = Uint128::new(1337); diff --git a/contracts/swapper/osmosis/examples/schema.rs b/contracts/swapper/osmosis/examples/schema.rs index 33e2fd793..6fa64c5f0 100644 --- a/contracts/swapper/osmosis/examples/schema.rs +++ b/contracts/swapper/osmosis/examples/schema.rs @@ -1,6 +1,6 @@ use cosmwasm_schema::write_api; -use mars_red_bank_types::swapper::{ExecuteMsg, InstantiateMsg, QueryMsg}; use mars_swapper_osmosis::route::OsmosisRoute; +use mars_types::swapper::{ExecuteMsg, InstantiateMsg, QueryMsg}; fn main() { write_api! { diff --git a/contracts/swapper/osmosis/src/contract.rs b/contracts/swapper/osmosis/src/contract.rs index ddd50c129..55b87815f 100644 --- a/contracts/swapper/osmosis/src/contract.rs +++ b/contracts/swapper/osmosis/src/contract.rs @@ -1,7 +1,7 @@ use cosmwasm_std::{entry_point, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Response}; use cw2::set_contract_version; -use mars_red_bank_types::swapper::{ExecuteMsg, InstantiateMsg, QueryMsg}; use mars_swapper_base::{ContractError, ContractResult, SwapBase}; +use mars_types::swapper::{ExecuteMsg, InstantiateMsg, QueryMsg}; use crate::{migrations, route::OsmosisRoute}; diff --git a/contracts/swapper/osmosis/src/route.rs b/contracts/swapper/osmosis/src/route.rs index 85a12f706..79720c59b 100644 --- a/contracts/swapper/osmosis/src/route.rs +++ b/contracts/swapper/osmosis/src/route.rs @@ -3,8 +3,8 @@ use std::fmt; use cosmwasm_schema::cw_serde; use cosmwasm_std::{BlockInfo, CosmosMsg, Decimal, Empty, Env, Fraction, QuerierWrapper, Uint128}; use mars_osmosis::helpers::{query_arithmetic_twap_price, query_pool, CommonPoolData}; -use mars_red_bank_types::swapper::EstimateExactInSwapResponse; use mars_swapper_base::{ContractError, ContractResult, Route}; +use mars_types::swapper::EstimateExactInSwapResponse; use osmosis_std::types::osmosis::gamm::v1beta1::MsgSwapExactAmountIn; pub use osmosis_std::types::osmosis::poolmanager::v1beta1::SwapAmountInRoute as OsmosisSwapAmountInRoute; diff --git a/contracts/swapper/osmosis/tests/tests/helpers/mod.rs b/contracts/swapper/osmosis/tests/tests/helpers/mod.rs index ee5a08430..3ef7d5c88 100644 --- a/contracts/swapper/osmosis/tests/tests/helpers/mod.rs +++ b/contracts/swapper/osmosis/tests/tests/helpers/mod.rs @@ -14,7 +14,7 @@ use cw_it::{ Wasm, }, }; -use mars_red_bank_types::swapper::InstantiateMsg; +use mars_types::swapper::InstantiateMsg; const CONTRACT_NAME: &str = env!("CARGO_PKG_NAME"); diff --git a/contracts/swapper/osmosis/tests/tests/test_enumerate_routes.rs b/contracts/swapper/osmosis/tests/tests/test_enumerate_routes.rs index fa55a4fa5..e014303d6 100644 --- a/contracts/swapper/osmosis/tests/tests/test_enumerate_routes.rs +++ b/contracts/swapper/osmosis/tests/tests/test_enumerate_routes.rs @@ -4,8 +4,8 @@ use std::collections::HashMap; use cosmwasm_std::coin; use cw_it::osmosis_test_tube::{Gamm, Module, OsmosisTestApp, SigningAccount, Wasm}; -use mars_red_bank_types::swapper::{ExecuteMsg, QueryMsg, RouteResponse}; use mars_swapper_osmosis::route::{OsmosisRoute, SwapAmountInRoute}; +use mars_types::swapper::{ExecuteMsg, QueryMsg, RouteResponse}; use super::helpers::instantiate_contract; diff --git a/contracts/swapper/osmosis/tests/tests/test_estimate.rs b/contracts/swapper/osmosis/tests/tests/test_estimate.rs index 42aeff7d8..e09b1f546 100644 --- a/contracts/swapper/osmosis/tests/tests/test_estimate.rs +++ b/contracts/swapper/osmosis/tests/tests/test_estimate.rs @@ -1,7 +1,7 @@ use cosmwasm_std::{coin, Uint128}; use cw_it::osmosis_test_tube::{Gamm, Module, OsmosisTestApp, RunnerResult, Wasm}; -use mars_red_bank_types::swapper::{EstimateExactInSwapResponse, ExecuteMsg, QueryMsg}; use mars_swapper_osmosis::route::{OsmosisRoute, SwapAmountInRoute}; +use mars_types::swapper::{EstimateExactInSwapResponse, ExecuteMsg, QueryMsg}; use super::helpers::{ assert_err, instantiate_contract, query_price_from_pool, swap_to_create_twap_records, diff --git a/contracts/swapper/osmosis/tests/tests/test_instantiate.rs b/contracts/swapper/osmosis/tests/tests/test_instantiate.rs index 684230e7d..281f551e9 100644 --- a/contracts/swapper/osmosis/tests/tests/test_instantiate.rs +++ b/contracts/swapper/osmosis/tests/tests/test_instantiate.rs @@ -1,7 +1,7 @@ use cosmwasm_std::coin; use cw_it::osmosis_test_tube::{Account, Module, OsmosisTestApp, Wasm}; use mars_owner::OwnerResponse; -use mars_red_bank_types::swapper::{InstantiateMsg, QueryMsg}; +use mars_types::swapper::{InstantiateMsg, QueryMsg}; use super::helpers::{instantiate_contract, wasm_file}; diff --git a/contracts/swapper/osmosis/tests/tests/test_set_route.rs b/contracts/swapper/osmosis/tests/tests/test_set_route.rs index 150d23325..c66ff41d2 100644 --- a/contracts/swapper/osmosis/tests/tests/test_set_route.rs +++ b/contracts/swapper/osmosis/tests/tests/test_set_route.rs @@ -1,9 +1,9 @@ use cosmwasm_std::{coin, StdError}; use cw_it::osmosis_test_tube::{Gamm, Module, OsmosisTestApp, Wasm}; use mars_owner::OwnerError; -use mars_red_bank_types::swapper::{ExecuteMsg, QueryMsg, RouteResponse}; use mars_swapper_base::ContractError; use mars_swapper_osmosis::route::{OsmosisRoute, SwapAmountInRoute}; +use mars_types::swapper::{ExecuteMsg, QueryMsg, RouteResponse}; use super::helpers::{assert_err, instantiate_contract}; diff --git a/contracts/swapper/osmosis/tests/tests/test_swap.rs b/contracts/swapper/osmosis/tests/tests/test_swap.rs index 9f39206ca..f15415004 100644 --- a/contracts/swapper/osmosis/tests/tests/test_swap.rs +++ b/contracts/swapper/osmosis/tests/tests/test_swap.rs @@ -3,9 +3,9 @@ use cw_it::{ osmosis_test_tube::{Account, Bank, Gamm, Module, OsmosisTestApp, Wasm}, test_tube::FeeSetting, }; -use mars_red_bank_types::swapper::ExecuteMsg; use mars_swapper_base::ContractError; use mars_swapper_osmosis::route::{OsmosisRoute, SwapAmountInRoute}; +use mars_types::swapper::ExecuteMsg; use super::helpers::{ assert_err, instantiate_contract, query_balance, swap_to_create_twap_records, diff --git a/contracts/swapper/osmosis/tests/tests/test_update_admin.rs b/contracts/swapper/osmosis/tests/tests/test_update_admin.rs index a47e7ba8e..1e6bf19f7 100644 --- a/contracts/swapper/osmosis/tests/tests/test_update_admin.rs +++ b/contracts/swapper/osmosis/tests/tests/test_update_admin.rs @@ -1,8 +1,8 @@ use cosmwasm_std::coin; use cw_it::osmosis_test_tube::{Account, Module, OsmosisTestApp, Wasm}; use mars_owner::{OwnerResponse, OwnerUpdate}; -use mars_red_bank_types::swapper::{ExecuteMsg, QueryMsg}; use mars_swapper_osmosis::route::OsmosisRoute; +use mars_types::swapper::{ExecuteMsg, QueryMsg}; use super::helpers::instantiate_contract; diff --git a/contracts/v2-zapper/base/examples/schema.rs b/contracts/v2-zapper/base/examples/schema.rs index b38f8cc09..dbec511f0 100644 --- a/contracts/v2-zapper/base/examples/schema.rs +++ b/contracts/v2-zapper/base/examples/schema.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::write_api; -use mars_zapper_base::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use mars_types::zapper::{ExecuteMsg, InstantiateMsg, QueryMsg}; fn main() { write_api! { diff --git a/contracts/v2-zapper/mock/examples/schema.rs b/contracts/v2-zapper/mock/examples/schema.rs index b38f8cc09..dbec511f0 100644 --- a/contracts/v2-zapper/mock/examples/schema.rs +++ b/contracts/v2-zapper/mock/examples/schema.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::write_api; -use mars_zapper_base::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use mars_types::zapper::{ExecuteMsg, InstantiateMsg, QueryMsg}; fn main() { write_api! { diff --git a/contracts/v2-zapper/mock/src/contract.rs b/contracts/v2-zapper/mock/src/contract.rs index 38f98d8c9..1a7bfbd86 100644 --- a/contracts/v2-zapper/mock/src/contract.rs +++ b/contracts/v2-zapper/mock/src/contract.rs @@ -1,7 +1,7 @@ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, Uint128}; -use mars_zapper_base::{ExecuteMsg, QueryMsg}; +use mars_types::zapper::{ExecuteMsg, QueryMsg}; use crate::{ error::ContractResult, diff --git a/contracts/v2-zapper/mock/src/error.rs b/contracts/v2-zapper/mock/src/error.rs index b1212fbd8..230e5d9f7 100644 --- a/contracts/v2-zapper/mock/src/error.rs +++ b/contracts/v2-zapper/mock/src/error.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{CheckedMultiplyRatioError, StdError}; use cw_utils::PaymentError; -use mars_rover::error::ContractError as RoverError; +use mars_types::adapters::oracle::OracleError; use thiserror::Error; pub type ContractResult = Result; @@ -11,7 +11,7 @@ pub enum ContractError { Std(#[from] StdError), #[error("{0}")] - RoverError(#[from] RoverError), + OracleError(#[from] OracleError), #[error("{0}")] CheckedMultiply(#[from] CheckedMultiplyRatioError), diff --git a/contracts/v2-zapper/mock/src/msg.rs b/contracts/v2-zapper/mock/src/msg.rs index 173fb4a83..a4d73029e 100644 --- a/contracts/v2-zapper/mock/src/msg.rs +++ b/contracts/v2-zapper/mock/src/msg.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::cw_serde; -use mars_rover::adapters::oracle::OracleUnchecked; +use mars_types::adapters::oracle::OracleUnchecked; #[cw_serde] pub struct LpConfig { diff --git a/contracts/v2-zapper/mock/src/query.rs b/contracts/v2-zapper/mock/src/query.rs index 8e4829867..8a9cd17cb 100644 --- a/contracts/v2-zapper/mock/src/query.rs +++ b/contracts/v2-zapper/mock/src/query.rs @@ -1,5 +1,5 @@ use cosmwasm_std::{Coin, Deps, StdResult, Storage, Uint128}; -use mars_red_bank_types::oracle::ActionKind; +use mars_types::oracle::ActionKind; use crate::{ contract::STARTING_LP_POOL_TOKENS, diff --git a/contracts/v2-zapper/mock/src/state.rs b/contracts/v2-zapper/mock/src/state.rs index d030f0a00..ffeb20a8f 100644 --- a/contracts/v2-zapper/mock/src/state.rs +++ b/contracts/v2-zapper/mock/src/state.rs @@ -1,6 +1,6 @@ use cosmwasm_std::Uint128; use cw_storage_plus::{Item, Map}; -use mars_rover::adapters::oracle::Oracle; +use mars_types::adapters::oracle::Oracle; pub const ORACLE: Item = Item::new("oracle"); diff --git a/contracts/v2-zapper/osmosis/Cargo.toml b/contracts/v2-zapper/osmosis/Cargo.toml index 5c9dcefc2..811bf15c5 100644 --- a/contracts/v2-zapper/osmosis/Cargo.toml +++ b/contracts/v2-zapper/osmosis/Cargo.toml @@ -22,6 +22,7 @@ library = [] cosmwasm-std = { workspace = true } cw2 = { workspace = true } cw-dex = { workspace = true } +mars-types = { workspace = true } mars-zapper-base = { workspace = true } [dev-dependencies] diff --git a/contracts/v2-zapper/osmosis/src/contract.rs b/contracts/v2-zapper/osmosis/src/contract.rs index 49146bf49..032e6b867 100644 --- a/contracts/v2-zapper/osmosis/src/contract.rs +++ b/contracts/v2-zapper/osmosis/src/contract.rs @@ -2,7 +2,8 @@ use cosmwasm_std::{ entry_point, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Response, StdResult, }; use cw2::set_contract_version; -use mars_zapper_base::{ContractError, ExecuteMsg, InstantiateMsg, QueryMsg, ZapperBase}; +use mars_types::zapper::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use mars_zapper_base::{ContractError, ZapperBase}; use crate::{lp_pool::OsmosisLpPool, migrations}; diff --git a/contracts/v2-zapper/osmosis/tests/helpers/utils.rs b/contracts/v2-zapper/osmosis/tests/helpers/utils.rs index a7083148e..c2538d057 100644 --- a/contracts/v2-zapper/osmosis/tests/helpers/utils.rs +++ b/contracts/v2-zapper/osmosis/tests/helpers/utils.rs @@ -1,6 +1,6 @@ use std::{fmt::Display, str::FromStr}; -use mars_zapper_base::InstantiateMsg; +use mars_types::zapper::InstantiateMsg; use osmosis_std::types::cosmos::bank::v1beta1::QueryBalanceRequest; use osmosis_test_tube::{Bank, OsmosisTestApp, RunnerError, SigningAccount, Wasm}; diff --git a/contracts/v2-zapper/osmosis/tests/test_callback.rs b/contracts/v2-zapper/osmosis/tests/test_callback.rs index bbb5a57f6..f16df5295 100644 --- a/contracts/v2-zapper/osmosis/tests/test_callback.rs +++ b/contracts/v2-zapper/osmosis/tests/test_callback.rs @@ -1,5 +1,6 @@ use cosmwasm_std::{coin, Addr, Coin}; -use mars_zapper_base::{CallbackMsg, ContractError, ExecuteMsg}; +use mars_types::zapper::{CallbackMsg, ExecuteMsg}; +use mars_zapper_base::ContractError; use osmosis_test_tube::{Account, Module, OsmosisTestApp, Wasm}; use crate::helpers::{assert_err, instantiate_contract}; diff --git a/contracts/v2-zapper/osmosis/tests/test_provide_liquidity.rs b/contracts/v2-zapper/osmosis/tests/test_provide_liquidity.rs index f5e52a039..a767d2bcb 100644 --- a/contracts/v2-zapper/osmosis/tests/test_provide_liquidity.rs +++ b/contracts/v2-zapper/osmosis/tests/test_provide_liquidity.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{coin, Coin, Uint128}; use cw_dex::CwDexError; -use mars_zapper_base::{ExecuteMsg, QueryMsg}; +use mars_types::zapper::{ExecuteMsg, QueryMsg}; use osmosis_test_tube::{Account, Bank, FeeSetting, Gamm, Module, OsmosisTestApp, Wasm}; use crate::helpers::{assert_err, instantiate_contract, query_balance}; diff --git a/contracts/v2-zapper/osmosis/tests/test_queries.rs b/contracts/v2-zapper/osmosis/tests/test_queries.rs index 17167d2f2..62676dc49 100644 --- a/contracts/v2-zapper/osmosis/tests/test_queries.rs +++ b/contracts/v2-zapper/osmosis/tests/test_queries.rs @@ -2,7 +2,7 @@ use std::{ops::Div, str::FromStr}; use cosmwasm_std::{coin, Coin, Uint128}; use cw_dex::CwDexError; -use mars_zapper_base::QueryMsg; +use mars_types::zapper::QueryMsg; use osmosis_test_tube::{Gamm, Module, OsmosisTestApp, Wasm}; use crate::helpers::{assert_err, instantiate_contract}; diff --git a/contracts/v2-zapper/osmosis/tests/test_withdraw_liquidity.rs b/contracts/v2-zapper/osmosis/tests/test_withdraw_liquidity.rs index 69b98e45c..901ea01ef 100644 --- a/contracts/v2-zapper/osmosis/tests/test_withdraw_liquidity.rs +++ b/contracts/v2-zapper/osmosis/tests/test_withdraw_liquidity.rs @@ -1,7 +1,8 @@ use cosmwasm_std::{coin, Coin, Uint128}; use cw_dex::CwDexError; use cw_utils::PaymentError; -use mars_zapper_base::{ContractError, ExecuteMsg, QueryMsg}; +use mars_types::zapper::{ExecuteMsg, QueryMsg}; +use mars_zapper_base::ContractError; use osmosis_test_tube::{Account, Bank, Gamm, Module, OsmosisTestApp, Wasm}; use crate::helpers::{assert_err, instantiate_contract, query_balance}; diff --git a/integration-tests/tests/helpers.rs b/integration-tests/tests/helpers.rs index 6603cbe44..bad1484c5 100644 --- a/integration-tests/tests/helpers.rs +++ b/integration-tests/tests/helpers.rs @@ -3,7 +3,7 @@ use anyhow::Result as AnyResult; use cosmwasm_std::{Coin, Decimal, Fraction, Uint128}; use cw_multi_test::AppResponse; -use mars_red_bank_types::{ +use mars_types::{ params::{AssetParams, CmSettings, LiquidationBonus, RedBankSettings}, red_bank::{ InitOrUpdateAssetParams, InterestRateModel, UserHealthStatus, UserPositionResponse, diff --git a/integration-tests/tests/test_oracles.rs b/integration-tests/tests/test_oracles.rs index 49e44ccdc..8a10e1b9e 100644 --- a/integration-tests/tests/test_oracles.rs +++ b/integration-tests/tests/test_oracles.rs @@ -7,7 +7,7 @@ use mars_oracle_osmosis::{ msg::PriceSourceResponse, DowntimeDetector, GeometricTwap, OsmosisPriceSourceChecked, OsmosisPriceSourceUnchecked, RedemptionRate, }; -use mars_red_bank_types::{ +use mars_types::{ address_provider::{ ExecuteMsg::SetAddress, InstantiateMsg as InstantiateAddr, MarsAddressType, }, @@ -1292,7 +1292,7 @@ fn setup_redbank(wasm: &Wasm, signer: &SigningAccount) -> (Strin wasm, signer, OSMOSIS_PARAMS_CONTRACT_NAME, - &mars_red_bank_types::params::InstantiateMsg { + &mars_types::params::InstantiateMsg { owner: (signer.address()), address_provider: addr_provider_addr.clone(), target_health_factor: Decimal::from_str("1.05").unwrap(), @@ -1380,11 +1380,9 @@ fn setup_redbank(wasm: &Wasm, signer: &SigningAccount) -> (Strin .unwrap(); wasm.execute( ¶ms_addr, - &mars_red_bank_types::params::ExecuteMsg::UpdateAssetParams( - AssetParamsUpdate::AddOrUpdate { - params: asset_params.into(), - }, - ), + &mars_types::params::ExecuteMsg::UpdateAssetParams(AssetParamsUpdate::AddOrUpdate { + params: asset_params.into(), + }), &[], signer, ) @@ -1405,11 +1403,9 @@ fn setup_redbank(wasm: &Wasm, signer: &SigningAccount) -> (Strin wasm.execute( ¶ms_addr, - &mars_red_bank_types::params::ExecuteMsg::UpdateAssetParams( - AssetParamsUpdate::AddOrUpdate { - params: asset_params.into(), - }, - ), + &mars_types::params::ExecuteMsg::UpdateAssetParams(AssetParamsUpdate::AddOrUpdate { + params: asset_params.into(), + }), &[], signer, ) diff --git a/integration-tests/tests/test_rewards_collector.rs b/integration-tests/tests/test_rewards_collector.rs index cdaa615d2..664a0c581 100644 --- a/integration-tests/tests/test_rewards_collector.rs +++ b/integration-tests/tests/test_rewards_collector.rs @@ -1,11 +1,11 @@ use cosmwasm_std::{coin, Decimal}; -use mars_red_bank_types::{ +use mars_swapper_osmosis::route::{OsmosisRoute, SwapAmountInRoute}; +use mars_types::{ address_provider::{ ExecuteMsg as ExecuteMsgAddr, InstantiateMsg as InstantiateAddr, MarsAddressType, }, rewards_collector::{ExecuteMsg, InstantiateMsg as InstantiateRewards, UpdateConfig}, }; -use mars_swapper_osmosis::route::{OsmosisRoute, SwapAmountInRoute}; use osmosis_test_tube::{Account, Gamm, Module, OsmosisTestApp, Wasm}; use crate::{ @@ -76,7 +76,7 @@ fn swapping_rewards() { &wasm, signer, OSMOSIS_SWAPPER_CONTRACT_NAME, - &mars_red_bank_types::swapper::InstantiateMsg { + &mars_types::swapper::InstantiateMsg { owner: signer.address(), }, ); @@ -84,7 +84,7 @@ fn swapping_rewards() { // Set swapper addr in address provider wasm.execute( &addr_provider_addr, - &mars_red_bank_types::address_provider::ExecuteMsg::SetAddress { + &mars_types::address_provider::ExecuteMsg::SetAddress { address_type: MarsAddressType::Swapper, address: swapper_addr.clone(), }, @@ -142,7 +142,7 @@ fn swapping_rewards() { // set routes wasm.execute( &swapper_addr, - &mars_red_bank_types::swapper::ExecuteMsg::SetRoute { + &mars_types::swapper::ExecuteMsg::SetRoute { denom_in: "uosmo".to_string(), denom_out: safety_fund_denom.to_string(), route: OsmosisRoute(vec![SwapAmountInRoute { @@ -156,7 +156,7 @@ fn swapping_rewards() { .unwrap(); wasm.execute( &swapper_addr, - &mars_red_bank_types::swapper::ExecuteMsg::SetRoute { + &mars_types::swapper::ExecuteMsg::SetRoute { denom_in: "uosmo".to_string(), denom_out: fee_collector_denom.to_string(), route: OsmosisRoute(vec![SwapAmountInRoute { @@ -170,7 +170,7 @@ fn swapping_rewards() { .unwrap(); wasm.execute( &swapper_addr, - &mars_red_bank_types::swapper::ExecuteMsg::SetRoute { + &mars_types::swapper::ExecuteMsg::SetRoute { denom_in: "uatom".to_string(), denom_out: safety_fund_denom.to_string(), route: OsmosisRoute(vec![ @@ -190,7 +190,7 @@ fn swapping_rewards() { .unwrap(); wasm.execute( &swapper_addr, - &mars_red_bank_types::swapper::ExecuteMsg::SetRoute { + &mars_types::swapper::ExecuteMsg::SetRoute { denom_in: "uatom".to_string(), denom_out: fee_collector_denom.to_string(), route: OsmosisRoute(vec![ diff --git a/integration-tests/tests/test_rover_flow.rs b/integration-tests/tests/test_rover_flow.rs index 0abc8c868..4935e2874 100644 --- a/integration-tests/tests/test_rover_flow.rs +++ b/integration-tests/tests/test_rover_flow.rs @@ -1,7 +1,7 @@ use cosmwasm_std::{coin, Addr, Decimal, Uint128}; use mars_red_bank::error::ContractError; -use mars_red_bank_types::red_bank::UserHealthStatus; use mars_testing::integration::mock_env::MockEnvBuilder; +use mars_types::red_bank::UserHealthStatus; use crate::helpers::{assert_red_bank_err, default_asset_params}; diff --git a/integration-tests/tests/test_user_flow.rs b/integration-tests/tests/test_user_flow.rs index 9bf105429..97d6ea55a 100644 --- a/integration-tests/tests/test_user_flow.rs +++ b/integration-tests/tests/test_user_flow.rs @@ -2,8 +2,8 @@ use std::str::FromStr; use cosmwasm_std::{coin, Addr, Decimal, Uint128}; use mars_red_bank::error::ContractError; -use mars_red_bank_types::params::LiquidationBonus; use mars_testing::integration::mock_env::{MockEnv, MockEnvBuilder, RedBank}; +use mars_types::params::LiquidationBonus; use crate::helpers::{assert_red_bank_err, default_asset_params, default_asset_params_with}; diff --git a/packages/health-computer/src/data_types.rs b/packages/health-computer/src/data_types.rs index ac4658b4e..7058703e1 100644 --- a/packages/health-computer/src/data_types.rs +++ b/packages/health-computer/src/data_types.rs @@ -2,8 +2,10 @@ use std::collections::HashMap; use cosmwasm_schema::cw_serde; use cosmwasm_std::{Addr, Decimal, Uint128}; -use mars_red_bank_types::params::{AssetParams, VaultConfig}; -use mars_rover::adapters::vault::VaultPositionValue; +use mars_types::{ + adapters::vault::VaultPositionValue, + params::{AssetParams, VaultConfig}, +}; /// Used as storage when trying to compute Health #[cw_serde] diff --git a/packages/health-computer/src/health_computer.rs b/packages/health-computer/src/health_computer.rs index 07c1c3e71..9fce642b0 100644 --- a/packages/health-computer/src/health_computer.rs +++ b/packages/health-computer/src/health_computer.rs @@ -2,14 +2,16 @@ use std::cmp::min; use cosmwasm_schema::cw_serde; use cosmwasm_std::{Coin, Decimal, Uint128}; -use mars_red_bank_types::params::{AssetParams, CmSettings, VaultConfig}; -use mars_rover::msg::query::Positions; -use mars_rover_health_types::{ - AccountKind, BorrowTarget, Health, - HealthError::{ - MissingHLSParams, MissingParams, MissingPrice, MissingVaultConfig, MissingVaultValues, +use mars_types::{ + credit_manager::Positions, + health::{ + AccountKind, BorrowTarget, Health, + HealthError::{ + MissingHLSParams, MissingParams, MissingPrice, MissingVaultConfig, MissingVaultValues, + }, + HealthResult, SwapKind, }, - HealthResult, SwapKind, + params::{AssetParams, CmSettings, VaultConfig}, }; #[cfg(feature = "javascript")] use tsify::Tsify; diff --git a/packages/health-computer/tests/helpers/mock_coin_info.rs b/packages/health-computer/tests/helpers/mock_coin_info.rs index a84229cd9..01db06feb 100644 --- a/packages/health-computer/tests/helpers/mock_coin_info.rs +++ b/packages/health-computer/tests/helpers/mock_coin_info.rs @@ -2,7 +2,7 @@ use std::str::FromStr; use cosmwasm_schema::cw_serde; use cosmwasm_std::Decimal; -use mars_red_bank_types::params::{ +use mars_types::params::{ AssetParams, CmSettings, HlsAssetType, HlsParams, LiquidationBonus, RedBankSettings, }; diff --git a/packages/health-computer/tests/helpers/mock_vault_config.rs b/packages/health-computer/tests/helpers/mock_vault_config.rs index 8a1b9850d..7888f88bf 100644 --- a/packages/health-computer/tests/helpers/mock_vault_config.rs +++ b/packages/health-computer/tests/helpers/mock_vault_config.rs @@ -1,5 +1,5 @@ use cosmwasm_std::{coin, Addr, Decimal}; -use mars_red_bank_types::params::VaultConfig; +use mars_types::params::VaultConfig; pub fn osmo_atom_1_config() -> VaultConfig { VaultConfig { diff --git a/packages/health-computer/tests/helpers/prop_test_runner_borrow.rs b/packages/health-computer/tests/helpers/prop_test_runner_borrow.rs index 3860542fb..57e539451 100644 --- a/packages/health-computer/tests/helpers/prop_test_runner_borrow.rs +++ b/packages/health-computer/tests/helpers/prop_test_runner_borrow.rs @@ -1,10 +1,10 @@ use cosmwasm_std::{Coin, StdResult, Uint128}; -use mars_rover::{ +use mars_rover_health_computer::HealthComputer; +use mars_types::{ adapters::vault::{CoinValue, VaultPositionValue}, - msg::query::DebtAmount, + credit_manager::DebtAmount, + health::BorrowTarget, }; -use mars_rover_health_computer::HealthComputer; -use mars_rover_health_types::BorrowTarget; use proptest::{ strategy::Strategy, test_runner::{Config, TestRunner}, diff --git a/packages/health-computer/tests/helpers/prop_test_runner_swap.rs b/packages/health-computer/tests/helpers/prop_test_runner_swap.rs index e8b9e2ac9..6ad6eaa4c 100644 --- a/packages/health-computer/tests/helpers/prop_test_runner_swap.rs +++ b/packages/health-computer/tests/helpers/prop_test_runner_swap.rs @@ -1,7 +1,6 @@ use cosmwasm_std::{Coin, StdResult, Uint128}; -use mars_rover::msg::query::DebtAmount; use mars_rover_health_computer::HealthComputer; -use mars_rover_health_types::SwapKind; +use mars_types::{credit_manager::DebtAmount, health::SwapKind}; use proptest::{ strategy::Strategy, test_runner::{Config, TestRunner}, diff --git a/packages/health-computer/tests/helpers/prop_test_strategies.rs b/packages/health-computer/tests/helpers/prop_test_strategies.rs index e81451874..bf504b333 100644 --- a/packages/health-computer/tests/helpers/prop_test_strategies.rs +++ b/packages/health-computer/tests/helpers/prop_test_strategies.rs @@ -1,18 +1,16 @@ use std::collections::HashMap; use cosmwasm_std::{Addr, Coin, Decimal, Uint128}; -use mars_red_bank_types::params::{ - AssetParams, CmSettings, HlsParams, LiquidationBonus, RedBankSettings, VaultConfig, -}; -use mars_rover::{ +use mars_rover_health_computer::{DenomsData, HealthComputer, VaultsData}; +use mars_types::{ adapters::vault::{ CoinValue, LockingVaultAmount, UnlockingPositions, Vault, VaultAmount, VaultPosition, VaultPositionAmount, VaultPositionValue, }, - msg::query::{DebtAmount, Positions}, + credit_manager::{DebtAmount, Positions}, + health::AccountKind, + params::{AssetParams, CmSettings, HlsParams, LiquidationBonus, RedBankSettings, VaultConfig}, }; -use mars_rover_health_computer::{DenomsData, HealthComputer, VaultsData}; -use mars_rover_health_types::AccountKind; use proptest::{ collection::vec, prelude::{Just, Strategy}, @@ -172,10 +170,7 @@ fn random_param_maps() -> impl Strategy { random_denoms_data().prop_flat_map(|denoms_data| { vec(random_vault(denoms_data.clone()), 0..=3).prop_map(move |vaults| { let mut vault_values = HashMap::new(); - let mut vault_configs: HashMap< - Addr, - mars_red_bank_types::params::VaultConfigBase, - > = HashMap::new(); + let mut vault_configs: HashMap = HashMap::new(); for (addr, position_val, config) in vaults { let addr = Addr::unchecked(addr.clone()); diff --git a/packages/health-computer/tests/test_health_scenarios.rs b/packages/health-computer/tests/test_health_scenarios.rs index fa47223ac..473620223 100644 --- a/packages/health-computer/tests/test_health_scenarios.rs +++ b/packages/health-computer/tests/test_health_scenarios.rs @@ -1,16 +1,16 @@ use std::{collections::HashMap, ops::Add, str::FromStr}; use cosmwasm_std::{coin, Addr, Coin, Decimal, Uint128}; -use mars_red_bank_types::params::VaultConfig; -use mars_rover::{ +use mars_rover_health_computer::{DenomsData, HealthComputer, VaultsData}; +use mars_types::{ adapters::vault::{ CoinValue, LockingVaultAmount, UnlockingPositions, Vault, VaultAmount, VaultPosition, VaultPositionAmount, VaultPositionValue, VaultUnlockingPosition, }, - msg::query::{DebtAmount, Positions}, + credit_manager::{DebtAmount, Positions}, + health::AccountKind, + params::VaultConfig, }; -use mars_rover_health_computer::{DenomsData, HealthComputer, VaultsData}; -use mars_rover_health_types::AccountKind; use crate::helpers::{udai_info, ujuno_info, uluna_info, umars_info, ustars_info}; diff --git a/packages/health-computer/tests/test_hls.rs b/packages/health-computer/tests/test_hls.rs index b0f7876f4..ea9c78afb 100644 --- a/packages/health-computer/tests/test_hls.rs +++ b/packages/health-computer/tests/test_hls.rs @@ -1,15 +1,15 @@ use std::{collections::HashMap, str::FromStr}; use cosmwasm_std::{coin, Addr, Coin, Decimal, Uint128}; -use mars_red_bank_types::params::{HlsParams, VaultConfig}; -use mars_rover::{ +use mars_rover_health_computer::{DenomsData, HealthComputer, VaultsData}; +use mars_types::{ adapters::vault::{ CoinValue, Vault, VaultAmount, VaultPosition, VaultPositionAmount, VaultPositionValue, }, - msg::query::{DebtAmount, Positions}, + credit_manager::{DebtAmount, Positions}, + health::AccountKind, + params::{HlsParams, VaultConfig}, }; -use mars_rover_health_computer::{DenomsData, HealthComputer, VaultsData}; -use mars_rover_health_types::AccountKind; use crate::helpers::{udai_info, ustars_info}; diff --git a/packages/health-computer/tests/test_input_validation.rs b/packages/health-computer/tests/test_input_validation.rs index 11c2d369c..d98166a9d 100644 --- a/packages/health-computer/tests/test_input_validation.rs +++ b/packages/health-computer/tests/test_input_validation.rs @@ -1,15 +1,15 @@ use std::collections::HashMap; use cosmwasm_std::{coin, Addr, Uint128}; -use mars_red_bank_types::params::VaultConfig; -use mars_rover::{ +use mars_rover_health_computer::{DenomsData, HealthComputer, VaultsData}; +use mars_types::{ adapters::vault::{ CoinValue, Vault, VaultAmount, VaultPosition, VaultPositionAmount, VaultPositionValue, }, - msg::query::{DebtAmount, Positions}, + credit_manager::{DebtAmount, Positions}, + health::{AccountKind, HealthError}, + params::VaultConfig, }; -use mars_rover_health_computer::{DenomsData, HealthComputer, VaultsData}; -use mars_rover_health_types::{AccountKind, HealthError}; use crate::helpers::{udai_info, umars_info}; diff --git a/packages/health-computer/tests/test_max_borrow_deposit.rs b/packages/health-computer/tests/test_max_borrow_deposit.rs index 1b23064cb..963edbfe4 100644 --- a/packages/health-computer/tests/test_max_borrow_deposit.rs +++ b/packages/health-computer/tests/test_max_borrow_deposit.rs @@ -1,9 +1,11 @@ use std::collections::HashMap; use cosmwasm_std::{coin, Uint128}; -use mars_rover::msg::query::Positions; use mars_rover_health_computer::{DenomsData, HealthComputer, VaultsData}; -use mars_rover_health_types::{AccountKind, BorrowTarget}; +use mars_types::{ + credit_manager::Positions, + health::{AccountKind, BorrowTarget}, +}; use crate::helpers::{udai_info, umars_info}; diff --git a/packages/health-computer/tests/test_max_borrow_prop.rs b/packages/health-computer/tests/test_max_borrow_prop.rs index 5788a455a..7b402064a 100644 --- a/packages/health-computer/tests/test_max_borrow_prop.rs +++ b/packages/health-computer/tests/test_max_borrow_prop.rs @@ -1,6 +1,6 @@ use cosmwasm_std::Addr; use helpers::max_borrow_prop_test_runner; -use mars_rover_health_types::BorrowTarget; +use mars_types::health::BorrowTarget; pub mod helpers; diff --git a/packages/health-computer/tests/test_max_borrow_validation.rs b/packages/health-computer/tests/test_max_borrow_validation.rs index 2ebe557ac..10fed7925 100644 --- a/packages/health-computer/tests/test_max_borrow_validation.rs +++ b/packages/health-computer/tests/test_max_borrow_validation.rs @@ -1,15 +1,15 @@ use std::{collections::HashMap, str::FromStr}; use cosmwasm_std::{coin, Addr, Decimal, Uint128}; -use mars_red_bank_types::params::{HlsParams, VaultConfig}; -use mars_rover::{ +use mars_rover_health_computer::{DenomsData, HealthComputer, VaultsData}; +use mars_types::{ adapters::vault::{ CoinValue, Vault, VaultAmount, VaultPosition, VaultPositionAmount, VaultPositionValue, }, - msg::query::{DebtAmount, Positions}, + credit_manager::{DebtAmount, Positions}, + health::{AccountKind, BorrowTarget, HealthError}, + params::{HlsParams, VaultConfig}, }; -use mars_rover_health_computer::{DenomsData, HealthComputer, VaultsData}; -use mars_rover_health_types::{AccountKind, BorrowTarget, HealthError}; use crate::helpers::{udai_info, umars_info, ustars_info}; diff --git a/packages/health-computer/tests/test_max_borrow_vault.rs b/packages/health-computer/tests/test_max_borrow_vault.rs index d9b13c570..f4c5a33e6 100644 --- a/packages/health-computer/tests/test_max_borrow_vault.rs +++ b/packages/health-computer/tests/test_max_borrow_vault.rs @@ -1,9 +1,11 @@ use std::collections::HashMap; use cosmwasm_std::{coin, Uint128}; -use mars_rover::msg::query::Positions; use mars_rover_health_computer::{DenomsData, HealthComputer, VaultsData}; -use mars_rover_health_types::{AccountKind, BorrowTarget}; +use mars_types::{ + credit_manager::Positions, + health::{AccountKind, BorrowTarget}, +}; use crate::helpers::{osmo_atom_1_config, udai_info, umars_info}; diff --git a/packages/health-computer/tests/test_max_borrow_wallet.rs b/packages/health-computer/tests/test_max_borrow_wallet.rs index b13c84305..ab617f6db 100644 --- a/packages/health-computer/tests/test_max_borrow_wallet.rs +++ b/packages/health-computer/tests/test_max_borrow_wallet.rs @@ -1,9 +1,11 @@ use std::collections::HashMap; use cosmwasm_std::{coin, Uint128}; -use mars_rover::msg::query::Positions; use mars_rover_health_computer::{DenomsData, HealthComputer, VaultsData}; -use mars_rover_health_types::{AccountKind, BorrowTarget}; +use mars_types::{ + credit_manager::Positions, + health::{AccountKind, BorrowTarget}, +}; use crate::helpers::{udai_info, umars_info}; diff --git a/packages/health-computer/tests/test_max_swap.rs b/packages/health-computer/tests/test_max_swap.rs index 9b461b004..4d3904719 100644 --- a/packages/health-computer/tests/test_max_swap.rs +++ b/packages/health-computer/tests/test_max_swap.rs @@ -1,9 +1,11 @@ use std::collections::HashMap; use cosmwasm_std::{coin, Uint128}; -use mars_rover::msg::query::Positions; use mars_rover_health_computer::{DenomsData, HealthComputer, VaultsData}; -use mars_rover_health_types::{AccountKind, SwapKind}; +use mars_types::{ + credit_manager::Positions, + health::{AccountKind, SwapKind}, +}; use crate::helpers::{udai_info, umars_info}; diff --git a/packages/health-computer/tests/test_max_swap_prop.rs b/packages/health-computer/tests/test_max_swap_prop.rs index 6068fb5df..543312d1a 100644 --- a/packages/health-computer/tests/test_max_swap_prop.rs +++ b/packages/health-computer/tests/test_max_swap_prop.rs @@ -1,5 +1,5 @@ use helpers::max_swap_prop_test_runner; -use mars_rover_health_types::SwapKind; +use mars_types::health::SwapKind; pub mod helpers; diff --git a/packages/health-computer/tests/test_max_swap_validation.rs b/packages/health-computer/tests/test_max_swap_validation.rs index ccdd07ce4..56b10cd38 100644 --- a/packages/health-computer/tests/test_max_swap_validation.rs +++ b/packages/health-computer/tests/test_max_swap_validation.rs @@ -1,15 +1,15 @@ use std::{collections::HashMap, str::FromStr}; use cosmwasm_std::{coin, Addr, Decimal, Uint128}; -use mars_red_bank_types::params::{HlsParams, VaultConfig}; -use mars_rover::{ +use mars_rover_health_computer::{DenomsData, HealthComputer, VaultsData}; +use mars_types::{ adapters::vault::{ CoinValue, Vault, VaultAmount, VaultPosition, VaultPositionAmount, VaultPositionValue, }, - msg::query::{DebtAmount, Positions}, + credit_manager::{DebtAmount, Positions}, + health::{AccountKind, HealthError, SwapKind}, + params::{HlsParams, VaultConfig}, }; -use mars_rover_health_computer::{DenomsData, HealthComputer, VaultsData}; -use mars_rover_health_types::{AccountKind, HealthError, SwapKind}; use crate::helpers::{uatom_info, udai_info, umars_info, ustars_info}; diff --git a/packages/health-computer/tests/test_max_withdraw.rs b/packages/health-computer/tests/test_max_withdraw.rs index 451e493e1..755278392 100644 --- a/packages/health-computer/tests/test_max_withdraw.rs +++ b/packages/health-computer/tests/test_max_withdraw.rs @@ -1,15 +1,15 @@ use std::{collections::HashMap, str::FromStr}; use cosmwasm_std::{coin, Addr, Decimal, Uint128}; -use mars_red_bank_types::params::{HlsParams, VaultConfig}; -use mars_rover::{ +use mars_rover_health_computer::{DenomsData, HealthComputer, VaultsData}; +use mars_types::{ adapters::vault::{ CoinValue, Vault, VaultAmount, VaultPosition, VaultPositionAmount, VaultPositionValue, }, - msg::query::{DebtAmount, Positions}, + credit_manager::{DebtAmount, Positions}, + health::{AccountKind, HealthError}, + params::{HlsParams, VaultConfig}, }; -use mars_rover_health_computer::{DenomsData, HealthComputer, VaultsData}; -use mars_rover_health_types::{AccountKind, HealthError}; use crate::helpers::{udai_info, umars_info, ustars_info}; diff --git a/packages/health/src/health.rs b/packages/health/src/health.rs index f5bda1a45..eab66de34 100644 --- a/packages/health/src/health.rs +++ b/packages/health/src/health.rs @@ -1,8 +1,8 @@ use std::{collections::HashMap, fmt}; use cosmwasm_std::{Addr, Coin, Decimal, Fraction, QuerierWrapper, StdResult, Uint128}; -use mars_red_bank_types::params::AssetParams; use mars_types::health::HealthValuesResponse; +use mars_types::params::AssetParams; use crate::{error::HealthError, query::MarsQuerier}; @@ -47,7 +47,7 @@ impl fmt::Display for Health { } } -impl From for RedBankHealth { +impl From for Health { fn from(h: HealthValuesResponse) -> Self { Self { total_debt_value: h.total_debt_value, diff --git a/packages/health/src/query.rs b/packages/health/src/query.rs index a1d90e028..9b09faa99 100644 --- a/packages/health/src/query.rs +++ b/packages/health/src/query.rs @@ -1,5 +1,5 @@ use cosmwasm_std::{Addr, Decimal, QuerierWrapper, StdResult}; -use mars_red_bank_types::{ +use mars_types::{ oracle::{self, ActionKind, PriceResponse}, params::AssetParams, }; @@ -22,7 +22,7 @@ impl<'a> MarsQuerier<'a> { pub fn query_asset_params(&self, denom: &str) -> StdResult { self.querier.query_wasm_smart( self.params_addr, - &mars_red_bank_types::params::QueryMsg::AssetParams { + &mars_types::params::QueryMsg::AssetParams { denom: denom.to_string(), }, ) diff --git a/packages/health/tests/test_from_coins_to_positions.rs b/packages/health/tests/test_from_coins_to_positions.rs index 9613b7f19..a28b556a1 100644 --- a/packages/health/tests/test_from_coins_to_positions.rs +++ b/packages/health/tests/test_from_coins_to_positions.rs @@ -7,11 +7,11 @@ use mars_health::{ health::{Health, Position}, query::MarsQuerier, }; -use mars_red_bank_types::{ +use mars_testing::MarsMockQuerier; +use mars_types::{ params::{AssetParams, CmSettings, LiquidationBonus, RedBankSettings}, red_bank::Market, }; -use mars_testing::MarsMockQuerier; // Test converting a collection of coins (collateral and debts) to a map of `Position` #[test] diff --git a/packages/health/tests/test_health_from_coins.rs b/packages/health/tests/test_health_from_coins.rs index 215fbb2dd..6174d6220 100644 --- a/packages/health/tests/test_health_from_coins.rs +++ b/packages/health/tests/test_health_from_coins.rs @@ -5,11 +5,11 @@ use cosmwasm_std::{ Uint128, }; use mars_health::{error::HealthError, health::Health}; -use mars_red_bank_types::{ +use mars_testing::MarsMockQuerier; +use mars_types::{ params::{AssetParams, CmSettings, LiquidationBonus, RedBankSettings}, red_bank::Market, }; -use mars_testing::MarsMockQuerier; #[test] fn health_success_from_coins() { diff --git a/packages/interest-rate/src/lib.rs b/packages/interest-rate/src/lib.rs index e8631da1c..f3798b1b8 100644 --- a/packages/interest-rate/src/lib.rs +++ b/packages/interest-rate/src/lib.rs @@ -1,5 +1,5 @@ use cosmwasm_std::{Decimal, StdError, StdResult, Uint128}; -use mars_red_bank_types::{error::MarsError, red_bank::Market}; +use mars_types::{error::MarsError, red_bank::Market}; /// Scaling factor used to keep more precision during division / multiplication by index. pub const SCALING_FACTOR: Uint128 = Uint128::new(1_000_000); diff --git a/packages/liquidation/src/liquidation.rs b/packages/liquidation/src/liquidation.rs index b2123bfd3..c989a5f97 100644 --- a/packages/liquidation/src/liquidation.rs +++ b/packages/liquidation/src/liquidation.rs @@ -5,7 +5,7 @@ use std::{ use cosmwasm_std::{Decimal, StdError, Uint128}; use mars_health::health::Health; -use mars_red_bank_types::params::AssetParams; +use mars_types::params::AssetParams; use crate::error::LiquidationError; diff --git a/packages/testing/src/astroport_swapper.rs b/packages/testing/src/astroport_swapper.rs index bbc9d9371..75f70050c 100644 --- a/packages/testing/src/astroport_swapper.rs +++ b/packages/testing/src/astroport_swapper.rs @@ -11,8 +11,8 @@ use cw_it::{ ContractMap, ContractType, TestRunner, }; use mars_owner::OwnerResponse; -use mars_red_bank_types::swapper::{EstimateExactInSwapResponse, RouteResponse, RoutesResponse}; use mars_swapper_astroport::route::AstroportRoute; +use mars_types::swapper::{EstimateExactInSwapResponse, RouteResponse, RoutesResponse}; use crate::wasm_oracle::{get_wasm_oracle_contract, WasmOracleTestRobot}; @@ -103,7 +103,7 @@ impl<'a> AstroportSwapperRobot<'a> { let swapper = wasm .instantiate( swapper_code_id, - &mars_red_bank_types::swapper::InstantiateMsg { + &mars_types::swapper::InstantiateMsg { owner: admin.address(), }, None, @@ -144,7 +144,7 @@ impl<'a> AstroportSwapperRobot<'a> { self.wasm() .execute( &self.swapper, - &mars_red_bank_types::swapper::ExecuteMsg::SetRoute { + &mars_types::swapper::ExecuteMsg::SetRoute { route: AstroportRoute { operations, router: self.astroport_contracts().router.address.clone(), @@ -183,7 +183,7 @@ impl<'a> AstroportSwapperRobot<'a> { println!("sending {} to swapper contract", coin_in); self.wasm().execute( &self.swapper, - &mars_red_bank_types::swapper::ExecuteMsg::::SwapExactIn { + &mars_types::swapper::ExecuteMsg::::SwapExactIn { coin_in: coin_in.clone(), denom_out: denom_out.into(), slippage, @@ -201,7 +201,7 @@ impl<'a> AstroportSwapperRobot<'a> { self.wasm() .query::<_, EstimateExactInSwapResponse>( &self.swapper, - &mars_red_bank_types::swapper::QueryMsg::EstimateExactInSwap { + &mars_types::swapper::QueryMsg::EstimateExactInSwap { coin_in: coin_in.clone(), denom_out: denom_out.into(), }, @@ -218,7 +218,7 @@ impl<'a> AstroportSwapperRobot<'a> { self.wasm() .query::<_, RouteResponse>( &self.swapper, - &mars_red_bank_types::swapper::QueryMsg::Route { + &mars_types::swapper::QueryMsg::Route { denom_in: denom_in.into(), denom_out: denom_out.into(), }, @@ -235,7 +235,7 @@ impl<'a> AstroportSwapperRobot<'a> { self.wasm() .query::<_, RoutesResponse>( &self.swapper, - &mars_red_bank_types::swapper::QueryMsg::Routes { + &mars_types::swapper::QueryMsg::Routes { start_after, limit, }, @@ -245,10 +245,7 @@ impl<'a> AstroportSwapperRobot<'a> { pub fn query_owner(&self) -> Option { self.wasm() - .query::<_, OwnerResponse>( - &self.swapper, - &mars_red_bank_types::swapper::QueryMsg::Owner {}, - ) + .query::<_, OwnerResponse>(&self.swapper, &mars_types::swapper::QueryMsg::Owner {}) .unwrap() .owner } diff --git a/packages/testing/src/incentives_querier.rs b/packages/testing/src/incentives_querier.rs index 1d2b76c8d..6b5e1e6db 100644 --- a/packages/testing/src/incentives_querier.rs +++ b/packages/testing/src/incentives_querier.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use cosmwasm_std::{to_binary, Addr, Binary, Coin, ContractResult, QuerierResult, Uint128}; -use mars_red_bank_types::incentives::QueryMsg; +use mars_types::incentives::QueryMsg; pub struct IncentivesQuerier { /// incentives contract address to be used in queries diff --git a/packages/testing/src/integration/mock_env.rs b/packages/testing/src/integration/mock_env.rs index f67eb7dd2..3ac2aae93 100644 --- a/packages/testing/src/integration/mock_env.rs +++ b/packages/testing/src/integration/mock_env.rs @@ -6,7 +6,7 @@ use anyhow::Result as AnyResult; use cosmwasm_std::{coin, Addr, Coin, Decimal, Empty, StdResult, Uint128}; use cw_multi_test::{App, AppResponse, BankSudo, BasicApp, Executor, SudoMsg}; use mars_oracle_osmosis::OsmosisPriceSourceUnchecked; -use mars_red_bank_types::{ +use mars_types::{ address_provider::{self, MarsAddressType}, incentives, oracle::{ @@ -675,7 +675,7 @@ impl RewardsCollector { .execute_contract( Addr::unchecked("anyone"), self.contract_addr.clone(), - &mars_red_bank_types::rewards_collector::ExecuteMsg::WithdrawFromRedBank { + &mars_types::rewards_collector::ExecuteMsg::WithdrawFromRedBank { denom: denom.to_string(), amount, }, @@ -688,7 +688,7 @@ impl RewardsCollector { env.app.execute_contract( Addr::unchecked("anyone"), self.contract_addr.clone(), - &mars_red_bank_types::rewards_collector::ExecuteMsg::ClaimIncentiveRewards { + &mars_types::rewards_collector::ExecuteMsg::ClaimIncentiveRewards { start_after_collateral_denom: None, start_after_incentive_denom: None, limit: None, @@ -704,7 +704,7 @@ impl Params { .execute_contract( env.owner.clone(), self.contract_addr.clone(), - &mars_red_bank_types::params::ExecuteMsg::UpdateAssetParams( + &mars_types::params::ExecuteMsg::UpdateAssetParams( AssetParamsUpdate::AddOrUpdate { params: params.into(), }, @@ -719,7 +719,7 @@ impl Params { .wrap() .query_wasm_smart( self.contract_addr.clone(), - &mars_red_bank_types::params::QueryMsg::AssetParams { + &mars_types::params::QueryMsg::AssetParams { denom: denom.to_string(), }, ) @@ -985,7 +985,7 @@ impl MockEnvBuilder { .instantiate_contract( code_id, self.owner.clone(), - &mars_red_bank_types::params::InstantiateMsg { + &mars_types::params::InstantiateMsg { owner: self.owner.to_string(), address_provider: address_provider_addr.to_string(), target_health_factor: self.target_health_factor, diff --git a/packages/testing/src/mars_mock_querier.rs b/packages/testing/src/mars_mock_querier.rs index 97ec5564e..56c2b7f0a 100644 --- a/packages/testing/src/mars_mock_querier.rs +++ b/packages/testing/src/mars_mock_querier.rs @@ -6,7 +6,7 @@ use cosmwasm_std::{ }; use ica_oracle::msg::RedemptionRateResponse; use mars_oracle_osmosis::DowntimeDetector; -use mars_red_bank_types::{address_provider, incentives, oracle, params::AssetParams, red_bank}; +use mars_types::{address_provider, incentives, oracle, params::AssetParams, red_bank}; use osmosis_std::types::osmosis::{ downtimedetector::v1beta1::RecoveredSinceDowntimeOfLengthResponse, poolmanager::v1beta1::{PoolResponse, SpotPriceResponse}, @@ -255,8 +255,7 @@ impl MarsMockQuerier { } // Params Queries - if let Ok(params_query) = from_binary::(msg) - { + if let Ok(params_query) = from_binary::(msg) { return self.params_querier.handle_query(params_query); } diff --git a/packages/testing/src/mock_address_provider.rs b/packages/testing/src/mock_address_provider.rs index 2d4096f12..ad9b7cb52 100644 --- a/packages/testing/src/mock_address_provider.rs +++ b/packages/testing/src/mock_address_provider.rs @@ -1,5 +1,5 @@ use cosmwasm_std::{to_binary, Addr, Binary, ContractResult, QuerierResult}; -use mars_red_bank_types::address_provider::{AddressResponseItem, QueryMsg}; +use mars_types::address_provider::{AddressResponseItem, QueryMsg}; // NOTE: Addresses here are all hardcoded as we always use those to target a specific contract // in tests. This module implicitly supposes those are used. diff --git a/packages/testing/src/oracle_querier.rs b/packages/testing/src/oracle_querier.rs index 3fbd243da..8cfcbdd7a 100644 --- a/packages/testing/src/oracle_querier.rs +++ b/packages/testing/src/oracle_querier.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use cosmwasm_std::{to_binary, Addr, Binary, ContractResult, Decimal, QuerierResult}; -use mars_red_bank_types::oracle::msg::{PriceResponse, QueryMsg}; +use mars_types::oracle::msg::{PriceResponse, QueryMsg}; #[derive(Default)] pub struct OracleQuerier { diff --git a/packages/testing/src/params_querier.rs b/packages/testing/src/params_querier.rs index 032d33fa7..8b014e7ba 100644 --- a/packages/testing/src/params_querier.rs +++ b/packages/testing/src/params_querier.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use cosmwasm_std::{to_binary, Binary, Coin, ContractResult, Decimal, QuerierResult, Uint128}; -use mars_red_bank_types::params::{AssetParams, QueryMsg}; +use mars_types::params::{AssetParams, QueryMsg}; #[derive(Default)] pub struct ParamsQuerier { diff --git a/packages/testing/src/red_bank_querier.rs b/packages/testing/src/red_bank_querier.rs index 05902a61c..3189e1705 100644 --- a/packages/testing/src/red_bank_querier.rs +++ b/packages/testing/src/red_bank_querier.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use cosmwasm_std::{to_binary, Binary, ContractResult, QuerierResult}; -use mars_red_bank_types::red_bank::{ +use mars_types::red_bank::{ Market, QueryMsg, UserCollateralResponse, UserDebtResponse, UserPositionResponse, }; diff --git a/packages/testing/src/wasm_oracle.rs b/packages/testing/src/wasm_oracle.rs index bcfd982e6..08e59e3a1 100644 --- a/packages/testing/src/wasm_oracle.rs +++ b/packages/testing/src/wasm_oracle.rs @@ -14,9 +14,7 @@ use cw_it::{ }; use mars_oracle_wasm::WasmPriceSourceUnchecked; use mars_owner::OwnerUpdate; -use mars_red_bank_types::oracle::{ - InstantiateMsg, WasmOracleCustomExecuteMsg, WasmOracleCustomInitParams, -}; +use mars_types::oracle::{InstantiateMsg, WasmOracleCustomExecuteMsg, WasmOracleCustomInitParams}; use crate::test_runner::get_test_runner; @@ -116,7 +114,7 @@ impl<'a> WasmOracleTestRobot<'a> { price_source: WasmPriceSourceUnchecked, signer: &SigningAccount, ) -> &Self { - let msg = mars_red_bank_types::oracle::msg::ExecuteMsg::<_, Empty>::SetPriceSource { + let msg = mars_types::oracle::msg::ExecuteMsg::<_, Empty>::SetPriceSource { denom: denom.to_string(), price_source, }; @@ -136,7 +134,7 @@ impl<'a> WasmOracleTestRobot<'a> { } pub fn remove_price_source(&self, signer: &SigningAccount, denom: &str) -> &Self { - let msg = mars_red_bank_types::oracle::msg::ExecuteMsg::::RemovePriceSource { + let msg = mars_types::oracle::msg::ExecuteMsg::::RemovePriceSource { denom: denom.to_string(), }; self.wasm().execute(&self.mars_oracle_contract_addr, &msg, &[], signer).unwrap(); @@ -147,8 +145,8 @@ impl<'a> WasmOracleTestRobot<'a> { &self, start_after: Option, limit: Option, - ) -> Vec> { - let msg = &mars_red_bank_types::oracle::msg::QueryMsg::PriceSources { + ) -> Vec> { + let msg = &mars_types::oracle::msg::QueryMsg::PriceSources { start_after, limit, }; @@ -158,15 +156,15 @@ impl<'a> WasmOracleTestRobot<'a> { pub fn query_price_source( &self, denom: &str, - ) -> mars_red_bank_types::oracle::PriceSourceResponse { - let msg = &mars_red_bank_types::oracle::msg::QueryMsg::PriceSource { + ) -> mars_types::oracle::PriceSourceResponse { + let msg = &mars_types::oracle::msg::QueryMsg::PriceSource { denom: denom.to_string(), }; self.wasm().query(&self.mars_oracle_contract_addr, &msg).unwrap() } - pub fn query_price(&self, denom: &str) -> mars_red_bank_types::oracle::PriceResponse { - let msg = &mars_red_bank_types::oracle::msg::QueryMsg::Price { + pub fn query_price(&self, denom: &str) -> mars_types::oracle::PriceResponse { + let msg = &mars_types::oracle::msg::QueryMsg::Price { denom: denom.to_string(), kind: None, }; @@ -177,8 +175,8 @@ impl<'a> WasmOracleTestRobot<'a> { &self, start_after: Option, limit: Option, - ) -> Vec { - let msg = &mars_red_bank_types::oracle::msg::QueryMsg::Prices { + ) -> Vec { + let msg = &mars_types::oracle::msg::QueryMsg::Prices { start_after, limit, kind: None, @@ -230,7 +228,7 @@ impl<'a> WasmOracleTestRobot<'a> { } pub fn record_twap_snapshots(&self, denoms: &[&str], signer: &SigningAccount) -> &Self { - let msg = &mars_red_bank_types::oracle::msg::ExecuteMsg::::Custom( + let msg = &mars_types::oracle::msg::ExecuteMsg::::Custom( WasmOracleCustomExecuteMsg::RecordTwapSnapshots { denoms: denoms.iter().map(|d| d.to_string()).collect(), }, @@ -253,13 +251,13 @@ impl<'a> WasmOracleTestRobot<'a> { // ===== Owner update methods ====== pub fn owner_update(&self, update_msg: OwnerUpdate, signer: &SigningAccount) -> &Self { - let msg = &mars_red_bank_types::oracle::msg::ExecuteMsg::::UpdateOwner(update_msg); + let msg = &mars_types::oracle::msg::ExecuteMsg::::UpdateOwner(update_msg); self.wasm().execute(&self.mars_oracle_contract_addr, &msg, &[], signer).unwrap(); self } - pub fn query_config(&self) -> mars_red_bank_types::oracle::ConfigResponse { - let msg = &mars_red_bank_types::oracle::msg::QueryMsg::Config {}; + pub fn query_config(&self) -> mars_types::oracle::ConfigResponse { + let msg = &mars_types::oracle::msg::QueryMsg::Config {}; self.wasm().query(&self.mars_oracle_contract_addr, &msg).unwrap() } From 6351d3171ca04231a953df7bbcb8c3e25b2b42b6 Mon Sep 17 00:00:00 2001 From: larry <26318510+larry0x@users.noreply.github.com> Date: Thu, 12 Oct 2023 11:58:35 +0100 Subject: [PATCH 07/15] remove duplicate files --- contracts/credit-manager/src/state.rs | 2 +- .../credit-manager/tests/helpers/mock_env.rs | 9 ++- .../credit-manager/tests/test_migration_v2.rs | 2 +- .../tests/test_update_config.rs | 2 +- packages/types/src/adapters/mod.rs | 2 +- packages/types/src/adapters/swap/mod.rs | 4 - packages/types/src/adapters/swap/swapper.rs | 52 ------------- .../adapter.rs => adapters/swapper.rs} | 0 .../types/src/credit_manager/instantiate.rs | 2 +- packages/types/src/credit_manager/migrate.rs | 2 +- .../src/{adapters/swap/msgs.rs => swapper.rs} | 0 packages/types/src/swapper/mod.rs | 4 - packages/types/src/swapper/msgs.rs | 77 ------------------- 13 files changed, 11 insertions(+), 147 deletions(-) delete mode 100644 packages/types/src/adapters/swap/mod.rs delete mode 100644 packages/types/src/adapters/swap/swapper.rs rename packages/types/src/{swapper/adapter.rs => adapters/swapper.rs} (100%) rename packages/types/src/{adapters/swap/msgs.rs => swapper.rs} (100%) delete mode 100644 packages/types/src/swapper/mod.rs delete mode 100644 packages/types/src/swapper/msgs.rs diff --git a/contracts/credit-manager/src/state.rs b/contracts/credit-manager/src/state.rs index d9d529c9a..cbe7fd944 100644 --- a/contracts/credit-manager/src/state.rs +++ b/contracts/credit-manager/src/state.rs @@ -4,7 +4,7 @@ use mars_owner::Owner; use mars_types::{ adapters::{ account_nft::AccountNft, health::HealthContract, incentives::Incentives, oracle::Oracle, - params::Params, red_bank::RedBank, rewards_collector::RewardsCollector, swap::Swapper, + params::Params, red_bank::RedBank, rewards_collector::RewardsCollector, swapper::Swapper, vault::VaultPositionAmount, zapper::Zapper, }, health::AccountKind, diff --git a/contracts/credit-manager/tests/helpers/mock_env.rs b/contracts/credit-manager/tests/helpers/mock_env.rs index f9752548a..12dda1ea1 100644 --- a/contracts/credit-manager/tests/helpers/mock_env.rs +++ b/contracts/credit-manager/tests/helpers/mock_env.rs @@ -28,10 +28,7 @@ use mars_types::{ oracle::{Oracle, OracleBase, OracleUnchecked}, params::Params, red_bank::RedBankUnchecked, - swap::{ - EstimateExactInSwapResponse, InstantiateMsg as SwapperInstantiateMsg, - QueryMsg::EstimateExactInSwap, Swapper, SwapperBase, - }, + swapper::{Swapper, SwapperBase}, vault::{Vault, VaultPosition, VaultPositionValue as VPositionValue, VaultUnchecked}, zapper::{Zapper, ZapperBase}, }, @@ -64,6 +61,10 @@ use mars_types::{ QueryMsg::{UserCollateral, UserDebt}, UserCollateralResponse, UserDebtResponse, }, + swapper::{ + EstimateExactInSwapResponse, InstantiateMsg as SwapperInstantiateMsg, + QueryMsg::EstimateExactInSwap, + }, }; use mars_zapper_mock::msg::{InstantiateMsg as ZapperInstantiateMsg, LpConfig}; diff --git a/contracts/credit-manager/tests/test_migration_v2.rs b/contracts/credit-manager/tests/test_migration_v2.rs index dd863b0d6..7230bfbef 100644 --- a/contracts/credit-manager/tests/test_migration_v2.rs +++ b/contracts/credit-manager/tests/test_migration_v2.rs @@ -15,7 +15,7 @@ use mars_credit_manager::{ use mars_types::{ adapters::{ health::HealthContractUnchecked, incentives::IncentivesUnchecked, params::ParamsUnchecked, - swap::SwapperUnchecked, + swapper::SwapperUnchecked, }, credit_manager::{migrate::V2Updates, MigrateMsg}, }; diff --git a/contracts/credit-manager/tests/test_update_config.rs b/contracts/credit-manager/tests/test_update_config.rs index e93ac4556..5a10b401b 100644 --- a/contracts/credit-manager/tests/test_update_config.rs +++ b/contracts/credit-manager/tests/test_update_config.rs @@ -6,7 +6,7 @@ use mars_mock_oracle::msg::{CoinPrice, InstantiateMsg as OracleInstantiateMsg}; use mars_types::{ adapters::{ health::HealthContractUnchecked, incentives::IncentivesUnchecked, oracle::OracleUnchecked, - red_bank::RedBankUnchecked, rewards_collector::RewardsCollector, swap::SwapperBase, + red_bank::RedBankUnchecked, rewards_collector::RewardsCollector, swapper::SwapperBase, zapper::ZapperBase, }, credit_manager::ConfigUpdates, diff --git a/packages/types/src/adapters/mod.rs b/packages/types/src/adapters/mod.rs index 244546040..ab5db35f9 100644 --- a/packages/types/src/adapters/mod.rs +++ b/packages/types/src/adapters/mod.rs @@ -5,6 +5,6 @@ pub mod oracle; pub mod params; pub mod red_bank; pub mod rewards_collector; -pub mod swap; +pub mod swapper; pub mod vault; pub mod zapper; diff --git a/packages/types/src/adapters/swap/mod.rs b/packages/types/src/adapters/swap/mod.rs deleted file mode 100644 index 6afc2b84f..000000000 --- a/packages/types/src/adapters/swap/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -mod msgs; -mod swapper; - -pub use self::{msgs::*, swapper::*}; diff --git a/packages/types/src/adapters/swap/swapper.rs b/packages/types/src/adapters/swap/swapper.rs deleted file mode 100644 index 0b77e82c9..000000000 --- a/packages/types/src/adapters/swap/swapper.rs +++ /dev/null @@ -1,52 +0,0 @@ -use cosmwasm_schema::cw_serde; -use cosmwasm_std::{to_binary, Addr, Api, Coin, CosmosMsg, Decimal, Empty, StdResult, WasmMsg}; - -use crate::adapters::swap::ExecuteMsg; - -#[cw_serde] -pub struct SwapperBase(T); - -impl SwapperBase { - pub fn new(address: T) -> SwapperBase { - SwapperBase(address) - } - - pub fn address(&self) -> &T { - &self.0 - } -} - -pub type SwapperUnchecked = SwapperBase; -pub type Swapper = SwapperBase; - -impl From for SwapperUnchecked { - fn from(s: Swapper) -> Self { - Self(s.address().to_string()) - } -} - -impl SwapperUnchecked { - pub fn check(&self, api: &dyn Api) -> StdResult { - Ok(SwapperBase::new(api.addr_validate(self.address())?)) - } -} - -impl Swapper { - /// Generate message for performing a swapper - pub fn swap_exact_in_msg( - &self, - coin_in: &Coin, - denom_out: &str, - slippage: Decimal, - ) -> StdResult { - Ok(CosmosMsg::Wasm(WasmMsg::Execute { - contract_addr: self.address().to_string(), - msg: to_binary(&ExecuteMsg::::SwapExactIn { - coin_in: coin_in.clone(), - denom_out: denom_out.to_string(), - slippage, - })?, - funds: vec![coin_in.clone()], - })) - } -} diff --git a/packages/types/src/swapper/adapter.rs b/packages/types/src/adapters/swapper.rs similarity index 100% rename from packages/types/src/swapper/adapter.rs rename to packages/types/src/adapters/swapper.rs diff --git a/packages/types/src/credit_manager/instantiate.rs b/packages/types/src/credit_manager/instantiate.rs index 5aa0373bc..73a766fea 100644 --- a/packages/types/src/credit_manager/instantiate.rs +++ b/packages/types/src/credit_manager/instantiate.rs @@ -4,7 +4,7 @@ use cosmwasm_std::{Decimal, Uint128}; use crate::adapters::{ account_nft::AccountNftUnchecked, health::HealthContractUnchecked, incentives::IncentivesUnchecked, oracle::OracleUnchecked, params::ParamsUnchecked, - red_bank::RedBankUnchecked, swap::SwapperUnchecked, zapper::ZapperUnchecked, + red_bank::RedBankUnchecked, swapper::SwapperUnchecked, zapper::ZapperUnchecked, }; #[cw_serde] diff --git a/packages/types/src/credit_manager/migrate.rs b/packages/types/src/credit_manager/migrate.rs index f62eb8263..a35c64f85 100644 --- a/packages/types/src/credit_manager/migrate.rs +++ b/packages/types/src/credit_manager/migrate.rs @@ -3,7 +3,7 @@ use cosmwasm_std::Decimal; use crate::adapters::{ health::HealthContractUnchecked, incentives::IncentivesUnchecked, params::ParamsUnchecked, - swap::SwapperUnchecked, + swapper::SwapperUnchecked, }; #[cw_serde] diff --git a/packages/types/src/adapters/swap/msgs.rs b/packages/types/src/swapper.rs similarity index 100% rename from packages/types/src/adapters/swap/msgs.rs rename to packages/types/src/swapper.rs diff --git a/packages/types/src/swapper/mod.rs b/packages/types/src/swapper/mod.rs deleted file mode 100644 index 6071d7839..000000000 --- a/packages/types/src/swapper/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod adapter; -pub mod msgs; - -pub use self::{adapter::*, msgs::*}; diff --git a/packages/types/src/swapper/msgs.rs b/packages/types/src/swapper/msgs.rs deleted file mode 100644 index bd270548a..000000000 --- a/packages/types/src/swapper/msgs.rs +++ /dev/null @@ -1,77 +0,0 @@ -use cosmwasm_schema::{cw_serde, QueryResponses}; -use cosmwasm_std::{Addr, Coin, Decimal, Uint128}; -use mars_owner::OwnerUpdate; - -#[cw_serde] -pub struct InstantiateMsg { - /// The contract's owner, who can update config - pub owner: String, -} - -#[cw_serde] -pub enum ExecuteMsg { - /// Manges owner role state - UpdateOwner(OwnerUpdate), - /// Configure the route for swapping an asset - /// - /// This is chain-specific, and can include parameters such as slippage tolerance and the routes - /// for multi-step swaps - SetRoute { - denom_in: String, - denom_out: String, - route: Route, - }, - /// Perform a swapper with an exact-in amount. Requires slippage allowance %. - SwapExactIn { - coin_in: Coin, - denom_out: String, - slippage: Decimal, - }, - /// Send swapper results back to swapper. Also refunds extra if sent more than needed. Internal use only. - TransferResult { - recipient: Addr, - denom_in: String, - denom_out: String, - }, -} - -#[cw_serde] -#[derive(QueryResponses)] -pub enum QueryMsg { - /// Query contract owner config - #[returns(mars_owner::OwnerResponse)] - Owner {}, - /// Get route for swapping an input denom into an output denom - #[returns(RouteResponse)] - Route { - denom_in: String, - denom_out: String, - }, - /// Enumerate all swapper routes - #[returns(RoutesResponse)] - Routes { - start_after: Option<(String, String)>, - limit: Option, - }, - /// Return current spot price swapping In for Out - /// Warning: Do not use this as an oracle price feed. Use Mars-Oracle for pricing. - #[returns(EstimateExactInSwapResponse)] - EstimateExactInSwap { - coin_in: Coin, - denom_out: String, - }, -} - -#[cw_serde] -pub struct RouteResponse { - pub denom_in: String, - pub denom_out: String, - pub route: Route, -} - -pub type RoutesResponse = Vec>; - -#[cw_serde] -pub struct EstimateExactInSwapResponse { - pub amount: Uint128, -} From 2792ab07029886c0df458b4034a4306db3b00dd7 Mon Sep 17 00:00:00 2001 From: larry <26318510+larry0x@users.noreply.github.com> Date: Thu, 12 Oct 2023 12:03:44 +0100 Subject: [PATCH 08/15] update some exports --- contracts/credit-manager/src/claim_rewards.rs | 2 +- .../credit-manager/tests/helpers/mock_env.rs | 10 +++------- .../tests/test_enumerate_coin_balances.rs | 2 +- contracts/credit-manager/tests/test_health.rs | 7 ++----- .../credit-manager/tests/test_migration_v2.rs | 2 +- .../tests/test_vault_exit_unlocked.rs | 4 ++-- contracts/oracle/base/src/contract.rs | 2 +- contracts/oracle/osmosis/src/contract.rs | 5 +---- .../oracle/osmosis/tests/tests/helpers/mod.rs | 2 +- .../tests/tests/test_remove_price_source.rs | 2 +- .../tests/tests/test_set_price_source.rs | 2 +- .../osmosis/tests/tests/test_update_owner.rs | 2 +- contracts/oracle/wasm/examples/schema.rs | 3 +-- contracts/oracle/wasm/src/contract.rs | 2 +- .../wasm/tests/tests/test_price_source.rs | 2 +- packages/testing/src/oracle_querier.rs | 2 +- packages/testing/src/wasm_oracle.rs | 18 +++++++++--------- packages/types/src/credit_manager/mod.rs | 10 +++++----- packages/types/src/oracle/mod.rs | 4 ++-- 19 files changed, 36 insertions(+), 47 deletions(-) diff --git a/contracts/credit-manager/src/claim_rewards.rs b/contracts/credit-manager/src/claim_rewards.rs index b24918fc2..195ff6628 100644 --- a/contracts/credit-manager/src/claim_rewards.rs +++ b/contracts/credit-manager/src/claim_rewards.rs @@ -3,7 +3,7 @@ use cosmwasm_std::{ WasmMsg, }; use mars_types::{ - credit_manager::{execute::CallbackMsg, ExecuteMsg}, + credit_manager::{CallbackMsg, ExecuteMsg}, traits::Denoms, }; diff --git a/contracts/credit-manager/tests/helpers/mock_env.rs b/contracts/credit-manager/tests/helpers/mock_env.rs index 12dda1ea1..aa23f09b3 100644 --- a/contracts/credit-manager/tests/helpers/mock_env.rs +++ b/contracts/credit-manager/tests/helpers/mock_env.rs @@ -34,14 +34,10 @@ use mars_types::{ }, address_provider::{self, MarsAddressType}, credit_manager::{ - execute::{Action, CallbackMsg}, - instantiate::ConfigUpdates, - query::{ - Account, CoinBalanceResponseItem, ConfigResponse, DebtShares, Positions, - SharesResponseItem, VaultPositionResponseItem, VaultUtilizationResponse, - }, - ExecuteMsg, InstantiateMsg, QueryMsg, + Account, Action, CallbackMsg, CoinBalanceResponseItem, ConfigResponse, ConfigUpdates, + DebtShares, ExecuteMsg, InstantiateMsg, Positions, QueryMsg, QueryMsg::{EstimateProvideLiquidity, VaultPositionValue}, + SharesResponseItem, VaultPositionResponseItem, VaultUtilizationResponse, }, health::{ AccountKind, ExecuteMsg::UpdateConfig, HealthValuesResponse, diff --git a/contracts/credit-manager/tests/test_enumerate_coin_balances.rs b/contracts/credit-manager/tests/test_enumerate_coin_balances.rs index 60ac70fe2..37c660c65 100644 --- a/contracts/credit-manager/tests/test_enumerate_coin_balances.rs +++ b/contracts/credit-manager/tests/test_enumerate_coin_balances.rs @@ -1,5 +1,5 @@ use cosmwasm_std::{coin, Addr, Uint128}; -use mars_types::credit_manager::{execute::Action, query::CoinBalanceResponseItem}; +use mars_types::credit_manager::{Action, CoinBalanceResponseItem}; use crate::helpers::{build_mock_coin_infos, AccountToFund, MockEnv}; diff --git a/contracts/credit-manager/tests/test_health.rs b/contracts/credit-manager/tests/test_health.rs index 11d3d6201..0e136e66e 100644 --- a/contracts/credit-manager/tests/test_health.rs +++ b/contracts/credit-manager/tests/test_health.rs @@ -6,11 +6,8 @@ use mars_credit_manager::error::ContractError; use mars_mock_oracle::msg::CoinPrice; use mars_types::{ credit_manager::{ - execute::{ - Action::{Borrow, Deposit, EnterVault, Repay, Withdraw}, - ActionAmount, ActionCoin, - }, - query::DebtAmount, + Action::{Borrow, Deposit, EnterVault, Repay, Withdraw}, + ActionAmount, ActionCoin, DebtAmount, }, health::AccountKind, }; diff --git a/contracts/credit-manager/tests/test_migration_v2.rs b/contracts/credit-manager/tests/test_migration_v2.rs index 7230bfbef..c6af64099 100644 --- a/contracts/credit-manager/tests/test_migration_v2.rs +++ b/contracts/credit-manager/tests/test_migration_v2.rs @@ -17,7 +17,7 @@ use mars_types::{ health::HealthContractUnchecked, incentives::IncentivesUnchecked, params::ParamsUnchecked, swapper::SwapperUnchecked, }, - credit_manager::{migrate::V2Updates, MigrateMsg}, + credit_manager::{MigrateMsg, V2Updates}, }; pub mod helpers; diff --git a/contracts/credit-manager/tests/test_vault_exit_unlocked.rs b/contracts/credit-manager/tests/test_vault_exit_unlocked.rs index 04308a8da..885203591 100644 --- a/contracts/credit-manager/tests/test_vault_exit_unlocked.rs +++ b/contracts/credit-manager/tests/test_vault_exit_unlocked.rs @@ -5,8 +5,8 @@ use mars_mock_vault::contract::STARTING_VAULT_SHARES; use mars_types::{ adapters::vault::VaultError, credit_manager::{ - execute::Action::{Deposit, EnterVault, ExitVaultUnlocked, RequestVaultUnlock}, - query::Positions, + Action::{Deposit, EnterVault, ExitVaultUnlocked, RequestVaultUnlock}, + Positions, }, params::VaultConfigUpdate, }; diff --git a/contracts/oracle/base/src/contract.rs b/contracts/oracle/base/src/contract.rs index 7258edda2..274c5069b 100644 --- a/contracts/oracle/base/src/contract.rs +++ b/contracts/oracle/base/src/contract.rs @@ -6,7 +6,7 @@ use cosmwasm_std::{ }; use cw_storage_plus::{Bound, Item, Map}; use mars_owner::{Owner, OwnerInit::SetInitialOwner, OwnerUpdate}; -use mars_types::oracle::msg::{ +use mars_types::oracle::{ ActionKind, Config, ConfigResponse, ExecuteMsg, InstantiateMsg, PriceResponse, PriceSourceResponse, QueryMsg, }; diff --git a/contracts/oracle/osmosis/src/contract.rs b/contracts/oracle/osmosis/src/contract.rs index 526dc8c62..c26eb54a3 100644 --- a/contracts/oracle/osmosis/src/contract.rs +++ b/contracts/oracle/osmosis/src/contract.rs @@ -16,10 +16,7 @@ pub mod entry { use cosmwasm_std::{entry_point, Binary, Deps, DepsMut, Env, MessageInfo, Response}; use cw2::set_contract_version; use mars_oracle_base::ContractResult; - use mars_types::oracle::{ - msg::{ExecuteMsg, InstantiateMsg, QueryMsg}, - MigrateMsg, - }; + use mars_types::oracle::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; use super::*; use crate::migrations; diff --git a/contracts/oracle/osmosis/tests/tests/helpers/mod.rs b/contracts/oracle/osmosis/tests/tests/helpers/mod.rs index 398723878..bbb1c248a 100644 --- a/contracts/oracle/osmosis/tests/tests/helpers/mod.rs +++ b/contracts/oracle/osmosis/tests/tests/helpers/mod.rs @@ -11,7 +11,7 @@ use mars_oracle_base::ContractError; use mars_oracle_osmosis::{contract::entry, msg::ExecuteMsg, OsmosisPriceSourceUnchecked}; use mars_osmosis::{BalancerPool, ConcentratedLiquidityPool, StableSwapPool}; use mars_testing::{mock_info, MarsMockQuerier}; -use mars_types::oracle::msg::{InstantiateMsg, QueryMsg}; +use mars_types::oracle::{InstantiateMsg, QueryMsg}; use osmosis_std::types::osmosis::{gamm::v1beta1::PoolAsset, poolmanager::v1beta1::PoolResponse}; use pyth_sdk_cw::PriceIdentifier; diff --git a/contracts/oracle/osmosis/tests/tests/test_remove_price_source.rs b/contracts/oracle/osmosis/tests/tests/test_remove_price_source.rs index 7b53647c0..ac3bd72e6 100644 --- a/contracts/oracle/osmosis/tests/tests/test_remove_price_source.rs +++ b/contracts/oracle/osmosis/tests/tests/test_remove_price_source.rs @@ -7,7 +7,7 @@ use mars_oracle_osmosis::{ }; use mars_owner::OwnerError::NotOwner; use mars_testing::mock_info; -use mars_types::oracle::msg::QueryMsg; +use mars_types::oracle::QueryMsg; use super::helpers; diff --git a/contracts/oracle/osmosis/tests/tests/test_set_price_source.rs b/contracts/oracle/osmosis/tests/tests/test_set_price_source.rs index 83e2d6094..86e084aa1 100644 --- a/contracts/oracle/osmosis/tests/tests/test_set_price_source.rs +++ b/contracts/oracle/osmosis/tests/tests/test_set_price_source.rs @@ -10,7 +10,7 @@ use mars_oracle_osmosis::{ }; use mars_owner::OwnerError::NotOwner; use mars_testing::mock_info; -use mars_types::oracle::msg::QueryMsg; +use mars_types::oracle::QueryMsg; use mars_utils::error::ValidationError; use osmosis_std::types::osmosis::downtimedetector::v1beta1::Downtime; use pyth_sdk_cw::PriceIdentifier; diff --git a/contracts/oracle/osmosis/tests/tests/test_update_owner.rs b/contracts/oracle/osmosis/tests/tests/test_update_owner.rs index 44881b4b2..ec863e1b5 100644 --- a/contracts/oracle/osmosis/tests/tests/test_update_owner.rs +++ b/contracts/oracle/osmosis/tests/tests/test_update_owner.rs @@ -3,7 +3,7 @@ use helpers::{query, setup_test_with_pools}; use mars_oracle_base::ContractError; use mars_oracle_osmosis::contract::entry::execute; use mars_owner::{OwnerError::NotOwner, OwnerUpdate}; -use mars_types::oracle::msg::{ConfigResponse, ExecuteMsg, QueryMsg}; +use mars_types::oracle::{ConfigResponse, ExecuteMsg, QueryMsg}; use super::helpers; diff --git a/contracts/oracle/wasm/examples/schema.rs b/contracts/oracle/wasm/examples/schema.rs index 510c3fdc0..8190369c9 100644 --- a/contracts/oracle/wasm/examples/schema.rs +++ b/contracts/oracle/wasm/examples/schema.rs @@ -1,8 +1,7 @@ use cosmwasm_schema::write_api; use mars_oracle_wasm::WasmPriceSourceUnchecked; use mars_types::oracle::{ - msg::{ExecuteMsg, InstantiateMsg, QueryMsg}, - WasmOracleCustomExecuteMsg, WasmOracleCustomInitParams, + ExecuteMsg, InstantiateMsg, QueryMsg, WasmOracleCustomExecuteMsg, WasmOracleCustomInitParams, }; fn main() { diff --git a/contracts/oracle/wasm/src/contract.rs b/contracts/oracle/wasm/src/contract.rs index 3bb7e5012..ae042f125 100644 --- a/contracts/oracle/wasm/src/contract.rs +++ b/contracts/oracle/wasm/src/contract.rs @@ -25,7 +25,7 @@ pub mod entry { use cosmwasm_std::{entry_point, Binary, Decimal, Deps, DepsMut, Env, MessageInfo, Response}; use cw2::set_contract_version; use mars_oracle_base::{ContractError, ContractResult}; - use mars_types::oracle::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; + use mars_types::oracle::{ExecuteMsg, InstantiateMsg, QueryMsg}; use super::*; use crate::{state::ASTROPORT_FACTORY, WasmPriceSourceUnchecked}; diff --git a/contracts/oracle/wasm/tests/tests/test_price_source.rs b/contracts/oracle/wasm/tests/tests/test_price_source.rs index b92652170..a431922d8 100644 --- a/contracts/oracle/wasm/tests/tests/test_price_source.rs +++ b/contracts/oracle/wasm/tests/tests/test_price_source.rs @@ -746,7 +746,7 @@ fn twap_window_size_not_gt_tolerance() { }; let wasm = Wasm::new(&runner); - let msg = mars_types::oracle::msg::ExecuteMsg::<_, Empty>::SetPriceSource { + let msg = mars_types::oracle::ExecuteMsg::<_, Empty>::SetPriceSource { denom: "uatom".to_string(), price_source, }; diff --git a/packages/testing/src/oracle_querier.rs b/packages/testing/src/oracle_querier.rs index 8cfcbdd7a..d32138c31 100644 --- a/packages/testing/src/oracle_querier.rs +++ b/packages/testing/src/oracle_querier.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use cosmwasm_std::{to_binary, Addr, Binary, ContractResult, Decimal, QuerierResult}; -use mars_types::oracle::msg::{PriceResponse, QueryMsg}; +use mars_types::oracle::{PriceResponse, QueryMsg}; #[derive(Default)] pub struct OracleQuerier { diff --git a/packages/testing/src/wasm_oracle.rs b/packages/testing/src/wasm_oracle.rs index 08e59e3a1..97099bed1 100644 --- a/packages/testing/src/wasm_oracle.rs +++ b/packages/testing/src/wasm_oracle.rs @@ -114,7 +114,7 @@ impl<'a> WasmOracleTestRobot<'a> { price_source: WasmPriceSourceUnchecked, signer: &SigningAccount, ) -> &Self { - let msg = mars_types::oracle::msg::ExecuteMsg::<_, Empty>::SetPriceSource { + let msg = mars_types::oracle::ExecuteMsg::<_, Empty>::SetPriceSource { denom: denom.to_string(), price_source, }; @@ -134,7 +134,7 @@ impl<'a> WasmOracleTestRobot<'a> { } pub fn remove_price_source(&self, signer: &SigningAccount, denom: &str) -> &Self { - let msg = mars_types::oracle::msg::ExecuteMsg::::RemovePriceSource { + let msg = mars_types::oracle::ExecuteMsg::::RemovePriceSource { denom: denom.to_string(), }; self.wasm().execute(&self.mars_oracle_contract_addr, &msg, &[], signer).unwrap(); @@ -146,7 +146,7 @@ impl<'a> WasmOracleTestRobot<'a> { start_after: Option, limit: Option, ) -> Vec> { - let msg = &mars_types::oracle::msg::QueryMsg::PriceSources { + let msg = &mars_types::oracle::QueryMsg::PriceSources { start_after, limit, }; @@ -157,14 +157,14 @@ impl<'a> WasmOracleTestRobot<'a> { &self, denom: &str, ) -> mars_types::oracle::PriceSourceResponse { - let msg = &mars_types::oracle::msg::QueryMsg::PriceSource { + let msg = &mars_types::oracle::QueryMsg::PriceSource { denom: denom.to_string(), }; self.wasm().query(&self.mars_oracle_contract_addr, &msg).unwrap() } pub fn query_price(&self, denom: &str) -> mars_types::oracle::PriceResponse { - let msg = &mars_types::oracle::msg::QueryMsg::Price { + let msg = &mars_types::oracle::QueryMsg::Price { denom: denom.to_string(), kind: None, }; @@ -176,7 +176,7 @@ impl<'a> WasmOracleTestRobot<'a> { start_after: Option, limit: Option, ) -> Vec { - let msg = &mars_types::oracle::msg::QueryMsg::Prices { + let msg = &mars_types::oracle::QueryMsg::Prices { start_after, limit, kind: None, @@ -228,7 +228,7 @@ impl<'a> WasmOracleTestRobot<'a> { } pub fn record_twap_snapshots(&self, denoms: &[&str], signer: &SigningAccount) -> &Self { - let msg = &mars_types::oracle::msg::ExecuteMsg::::Custom( + let msg = &mars_types::oracle::ExecuteMsg::::Custom( WasmOracleCustomExecuteMsg::RecordTwapSnapshots { denoms: denoms.iter().map(|d| d.to_string()).collect(), }, @@ -251,13 +251,13 @@ impl<'a> WasmOracleTestRobot<'a> { // ===== Owner update methods ====== pub fn owner_update(&self, update_msg: OwnerUpdate, signer: &SigningAccount) -> &Self { - let msg = &mars_types::oracle::msg::ExecuteMsg::::UpdateOwner(update_msg); + let msg = &mars_types::oracle::ExecuteMsg::::UpdateOwner(update_msg); self.wasm().execute(&self.mars_oracle_contract_addr, &msg, &[], signer).unwrap(); self } pub fn query_config(&self) -> mars_types::oracle::ConfigResponse { - let msg = &mars_types::oracle::msg::QueryMsg::Config {}; + let msg = &mars_types::oracle::QueryMsg::Config {}; self.wasm().query(&self.mars_oracle_contract_addr, &msg).unwrap() } diff --git a/packages/types/src/credit_manager/mod.rs b/packages/types/src/credit_manager/mod.rs index 9a01a9236..58a0df623 100644 --- a/packages/types/src/credit_manager/mod.rs +++ b/packages/types/src/credit_manager/mod.rs @@ -1,8 +1,8 @@ -pub mod execute; -pub mod instantiate; -pub mod migrate; -pub mod query; -pub mod reply; +mod execute; +mod instantiate; +mod migrate; +mod query; +mod reply; pub use execute::*; pub use instantiate::*; diff --git a/packages/types/src/oracle/mod.rs b/packages/types/src/oracle/mod.rs index 65238184b..4115e8da0 100644 --- a/packages/types/src/oracle/mod.rs +++ b/packages/types/src/oracle/mod.rs @@ -1,5 +1,5 @@ -pub mod msg; -pub mod wasm_oracle; +mod msg; +mod wasm_oracle; pub use msg::*; pub use wasm_oracle::*; From 776851d7ce9b89ca421e5f86373e6e17fa01e584 Mon Sep 17 00:00:00 2001 From: larry <26318510+larry0x@users.noreply.github.com> Date: Thu, 12 Oct 2023 12:04:42 +0100 Subject: [PATCH 09/15] remove an unnecessary export --- contracts/params/src/error.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/params/src/error.rs b/contracts/params/src/error.rs index 69c7c1909..409766955 100644 --- a/contracts/params/src/error.rs +++ b/contracts/params/src/error.rs @@ -1,7 +1,7 @@ use cosmwasm_std::{DecimalRangeExceeded, StdError}; use mars_owner::OwnerError; use mars_types::error::MarsError; -pub use mars_utils::error::ValidationError; +use mars_utils::error::ValidationError; use thiserror::Error; pub type ContractResult = Result; From 61d5e25e75bdbcc52ffe9cf38f174a7ccc17b328 Mon Sep 17 00:00:00 2001 From: larry <26318510+larry0x@users.noreply.github.com> Date: Thu, 12 Oct 2023 13:03:13 +0100 Subject: [PATCH 10/15] fix an error --- packages/health-computer/src/javascript.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/health-computer/src/javascript.rs b/packages/health-computer/src/javascript.rs index 7e226b176..c93a1cde4 100644 --- a/packages/health-computer/src/javascript.rs +++ b/packages/health-computer/src/javascript.rs @@ -1,4 +1,4 @@ -use mars_rover_health_types::{BorrowTarget, HealthValuesResponse, SwapKind}; +use mars_types::health::{BorrowTarget, HealthValuesResponse, SwapKind}; use wasm_bindgen::prelude::*; use crate::HealthComputer; From 6e556acbcd843b83a8718f6460c5bec4af83ea60 Mon Sep 17 00:00:00 2001 From: larry <26318510+larry0x@users.noreply.github.com> Date: Thu, 12 Oct 2023 13:04:03 +0100 Subject: [PATCH 11/15] remove unused dependencies --- Cargo.lock | 4 ---- contracts/red-bank/Cargo.toml | 2 -- contracts/v2-zapper/mock/Cargo.toml | 1 - packages/health/Cargo.toml | 1 - 4 files changed, 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0167e24e8..e3f1dd012 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2160,7 +2160,6 @@ name = "mars-health" version = "2.0.0" dependencies = [ "cosmwasm-std", - "mars-params", "mars-testing", "mars-types", "thiserror", @@ -2431,11 +2430,9 @@ dependencies = [ "mars-interest-rate", "mars-liquidation", "mars-owner 2.0.0", - "mars-params", "mars-testing", "mars-types", "mars-utils 2.0.0", - "pyth-sdk-cw", "test-case", "thiserror", ] @@ -2732,7 +2729,6 @@ dependencies = [ "cw-storage-plus 1.1.0", "cw-utils 1.0.2", "mars-types", - "mars-zapper-base", "thiserror", ] diff --git a/contracts/red-bank/Cargo.toml b/contracts/red-bank/Cargo.toml index c8191dde6..ff4b71600 100644 --- a/contracts/red-bank/Cargo.toml +++ b/contracts/red-bank/Cargo.toml @@ -29,10 +29,8 @@ mars-health = { workspace = true } mars-interest-rate = { workspace = true } mars-liquidation = { workspace = true } mars-owner = { workspace = true } -mars-params = { workspace = true } mars-types = { workspace = true } mars-utils = { workspace = true } -pyth-sdk-cw = { workspace = true } thiserror = { workspace = true } [dev-dependencies] diff --git a/contracts/v2-zapper/mock/Cargo.toml b/contracts/v2-zapper/mock/Cargo.toml index 5cc829665..23eae4c4a 100644 --- a/contracts/v2-zapper/mock/Cargo.toml +++ b/contracts/v2-zapper/mock/Cargo.toml @@ -24,5 +24,4 @@ cosmwasm-std = { workspace = true } cw-storage-plus = { workspace = true } cw-utils = { workspace = true } mars-types = { workspace = true } -mars-zapper-base = { workspace = true } thiserror = { workspace = true } diff --git a/packages/health/Cargo.toml b/packages/health/Cargo.toml index cc7cf60fa..8346f5721 100644 --- a/packages/health/Cargo.toml +++ b/packages/health/Cargo.toml @@ -20,7 +20,6 @@ backtraces = ["cosmwasm-std/backtraces"] [dependencies] cosmwasm-std = { workspace = true } -mars-params = { workspace = true } mars-types = { workspace = true } thiserror = { workspace = true } From c2855db7046b7f7fa524bb0a8347e513bfb6c060 Mon Sep 17 00:00:00 2001 From: larry <26318510+larry0x@users.noreply.github.com> Date: Thu, 12 Oct 2023 13:06:06 +0100 Subject: [PATCH 12/15] ignore a linter warning --- packages/types/src/health/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/types/src/health/mod.rs b/packages/types/src/health/mod.rs index bd7160733..3110a9a28 100644 --- a/packages/types/src/health/mod.rs +++ b/packages/types/src/health/mod.rs @@ -1,5 +1,6 @@ mod account; mod error; +#[allow(clippy::module_inception)] mod health; mod msg; From 1312ac0318351064c97fe3e100c96215e04a6227 Mon Sep 17 00:00:00 2001 From: larry <26318510+larry0x@users.noreply.github.com> Date: Thu, 12 Oct 2023 13:20:11 +0100 Subject: [PATCH 13/15] regenerate schemas and fix scripts --- schema.Makefile.toml | 1 - .../mars-rewards-collector-base.json | 388 ++++++++++++++++- .../mars-rover-health-types.json | 406 ------------------ scripts/deploy/base/deployer.rover.ts | 6 +- scripts/health/DataFetcher.ts | 2 +- scripts/health/example-react/src/utils.ts | 2 +- .../MarsRewardsCollectorBase.client.ts | 3 + .../MarsRewardsCollectorBase.react-query.ts | 3 + .../MarsRewardsCollectorBase.types.ts | 85 +++- .../MarsRoverHealthTypes.client.ts | 175 -------- .../MarsRoverHealthTypes.react-query.ts | 173 -------- .../MarsRoverHealthTypes.types.ts | 85 ---- .../mars-rover-health-types/bundle.ts | 13 - .../mars-swapper-astroport/bundle.ts | 8 +- .../generated/mars-swapper-base/bundle.ts | 8 +- .../generated/mars-swapper-osmosis/bundle.ts | 8 +- .../generated/mars-zapper-base/bundle.ts | 8 +- scripts/types/instantiateMsgs.ts | 2 +- 18 files changed, 498 insertions(+), 878 deletions(-) delete mode 100644 schemas/mars-rover-health-types/mars-rover-health-types.json delete mode 100644 scripts/types/generated/mars-rover-health-types/MarsRoverHealthTypes.client.ts delete mode 100644 scripts/types/generated/mars-rover-health-types/MarsRoverHealthTypes.react-query.ts delete mode 100644 scripts/types/generated/mars-rover-health-types/MarsRoverHealthTypes.types.ts delete mode 100644 scripts/types/generated/mars-rover-health-types/bundle.ts diff --git a/schema.Makefile.toml b/schema.Makefile.toml index 3626aa49d..4443c0429 100644 --- a/schema.Makefile.toml +++ b/schema.Makefile.toml @@ -24,7 +24,6 @@ fn main() -> std::io::Result<()> { "mars-params", "mars-rover-health", "mars-rover-health-computer", - "mars-rover-health-types", "mars-swapper-base", "mars-swapper-osmosis", "mars-swapper-astroport", diff --git a/schemas/mars-rewards-collector-base/mars-rewards-collector-base.json b/schemas/mars-rewards-collector-base/mars-rewards-collector-base.json index 4a4e229bb..3028b36a4 100644 --- a/schemas/mars-rewards-collector-base/mars-rewards-collector-base.json +++ b/schemas/mars-rewards-collector-base/mars-rewards-collector-base.json @@ -330,8 +330,23 @@ ], "definitions": { "Action": { + "description": "The list of actions that users can perform on their positions", "oneOf": [ { + "description": "Deposit coin of specified denom and amount. Verifies if the correct amount is sent with transaction.", + "type": "object", + "required": [ + "deposit" + ], + "properties": { + "deposit": { + "$ref": "#/definitions/Coin" + } + }, + "additionalProperties": false + }, + { + "description": "Withdraw coin of specified denom and amount", "type": "object", "required": [ "withdraw" @@ -344,6 +359,298 @@ "additionalProperties": false }, { + "description": "Borrow coin of specified amount from Red Bank", + "type": "object", + "required": [ + "borrow" + ], + "properties": { + "borrow": { + "$ref": "#/definitions/Coin" + } + }, + "additionalProperties": false + }, + { + "description": "Lend coin to the Red Bank", + "type": "object", + "required": [ + "lend" + ], + "properties": { + "lend": { + "$ref": "#/definitions/ActionCoin" + } + }, + "additionalProperties": false + }, + { + "description": "Reclaim the coins that were lent to the Red Bank.", + "type": "object", + "required": [ + "reclaim" + ], + "properties": { + "reclaim": { + "$ref": "#/definitions/ActionCoin" + } + }, + "additionalProperties": false + }, + { + "description": "For assets lent to the Red Bank, some can accumulate incentive rewards. This message claims all of them adds them to account balance.", + "type": "object", + "required": [ + "claim_rewards" + ], + "properties": { + "claim_rewards": { + "type": "object", + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "Repay coin of specified amount back to Red Bank. If `amount: AccountBalance` is passed, the repaid amount will be the minimum between account balance for denom and total owed. The sender will repay on behalf of the recipient account. If 'recipient_account_id: None', the sender repays to its own account.", + "type": "object", + "required": [ + "repay" + ], + "properties": { + "repay": { + "type": "object", + "required": [ + "coin" + ], + "properties": { + "coin": { + "$ref": "#/definitions/ActionCoin" + }, + "recipient_account_id": { + "type": [ + "string", + "null" + ] + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "Deposit coins into vault strategy If `coin.amount: AccountBalance`, Rover attempts to deposit the account's entire balance into the vault", + "type": "object", + "required": [ + "enter_vault" + ], + "properties": { + "enter_vault": { + "type": "object", + "required": [ + "coin", + "vault" + ], + "properties": { + "coin": { + "$ref": "#/definitions/ActionCoin" + }, + "vault": { + "$ref": "#/definitions/VaultBase_for_String" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "Withdraw underlying coins from vault", + "type": "object", + "required": [ + "exit_vault" + ], + "properties": { + "exit_vault": { + "type": "object", + "required": [ + "amount", + "vault" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "vault": { + "$ref": "#/definitions/VaultBase_for_String" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "Requests unlocking of shares for a vault with a required lock period", + "type": "object", + "required": [ + "request_vault_unlock" + ], + "properties": { + "request_vault_unlock": { + "type": "object", + "required": [ + "amount", + "vault" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "vault": { + "$ref": "#/definitions/VaultBase_for_String" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "Withdraws the assets for unlocking position id from vault. Required time must have elapsed.", + "type": "object", + "required": [ + "exit_vault_unlocked" + ], + "properties": { + "exit_vault_unlocked": { + "type": "object", + "required": [ + "id", + "vault" + ], + "properties": { + "id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "vault": { + "$ref": "#/definitions/VaultBase_for_String" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "Pay back debt of a liquidatable rover account for a via liquidating a specific type of the position.", + "type": "object", + "required": [ + "liquidate" + ], + "properties": { + "liquidate": { + "type": "object", + "required": [ + "debt_coin", + "liquidatee_account_id", + "request" + ], + "properties": { + "debt_coin": { + "description": "The coin they wish to acquire from the liquidatee (amount returned will include the bonus)", + "allOf": [ + { + "$ref": "#/definitions/Coin" + } + ] + }, + "liquidatee_account_id": { + "description": "The credit account id of the one with a liquidation threshold health factor 1 or below", + "type": "string" + }, + "request": { + "description": "Position details to be liquidated", + "allOf": [ + { + "$ref": "#/definitions/LiquidateRequest_for_VaultBase_for_String" + } + ] + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "Perform a swapper with an exact-in amount. Requires slippage allowance %. If `coin_in.amount: AccountBalance`, the accounts entire balance of `coin_in.denom` will be used.", + "type": "object", + "required": [ + "swap_exact_in" + ], + "properties": { + "swap_exact_in": { + "type": "object", + "required": [ + "coin_in", + "denom_out", + "slippage" + ], + "properties": { + "coin_in": { + "$ref": "#/definitions/ActionCoin" + }, + "denom_out": { + "type": "string" + }, + "slippage": { + "$ref": "#/definitions/Decimal" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "Add Vec to liquidity pool in exchange for LP tokens. Slippage allowance (%) is used to calculate the minimum amount of LP tokens to receive.", + "type": "object", + "required": [ + "provide_liquidity" + ], + "properties": { + "provide_liquidity": { + "type": "object", + "required": [ + "coins_in", + "lp_token_out", + "slippage" + ], + "properties": { + "coins_in": { + "type": "array", + "items": { + "$ref": "#/definitions/ActionCoin" + } + }, + "lp_token_out": { + "type": "string" + }, + "slippage": { + "$ref": "#/definitions/Decimal" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "description": "Send LP token and withdraw corresponding reserve assets from pool. If `lp_token.amount: AccountBalance`, the account balance of `lp_token.denom` will be used. /// Slippage allowance (%) is used to calculate the minimum amount of reserve assets to receive.", "type": "object", "required": [ "withdraw_liquidity" @@ -369,12 +676,13 @@ "additionalProperties": false }, { + "description": "Refunds all coin balances back to user wallet", "type": "object", "required": [ - "unknown" + "refund_all_coin_balances" ], "properties": { - "unknown": { + "refund_all_coin_balances": { "type": "object", "additionalProperties": false } @@ -440,6 +748,62 @@ "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", "type": "string" }, + "LiquidateRequest_for_VaultBase_for_String": { + "oneOf": [ + { + "description": "Pay back debt of a liquidatable rover account for a bonus. Requires specifying 1) the debt denom/amount of what the liquidator wants to payoff and 2) the request coin denom which the liquidatee should have a balance of. The amount returned to liquidator will be the request coin of the amount that precisely matches the value of the debt + a liquidation bonus. The debt amount will be adjusted down if: - Exceeds liquidatee's total debt for denom - Not enough liquidatee request coin balance to match - The value of the debt repaid exceeds the maximum close factor %\n\nLiquidation should prioritize first the not lent coin and if more needs to be serviced to the liquidator it should reclaim (withdrawn from Red Bank).", + "type": "object", + "required": [ + "deposit" + ], + "properties": { + "deposit": { + "type": "string" + } + }, + "additionalProperties": false + }, + { + "description": "Pay back debt of a liquidatable rover account for a via liquidating a Lent position. Lent shares are transfered from the liquidatable to the liquidator.", + "type": "object", + "required": [ + "lend" + ], + "properties": { + "lend": { + "type": "string" + } + }, + "additionalProperties": false + }, + { + "description": "Pay back debt of a liquidatable rover account for a via liquidating a vault position. Similar to `Deposit` msg and will make similar adjustments to the request. The vault position will be withdrawn (and force withdrawn if a locked vault position) and the underlying assets will transferred to the liquidator. The `VaultPositionType` will determine which bucket to liquidate from.", + "type": "object", + "required": [ + "vault" + ], + "properties": { + "vault": { + "type": "object", + "required": [ + "position_type", + "request_vault" + ], + "properties": { + "position_type": { + "$ref": "#/definitions/VaultPositionType" + }, + "request_vault": { + "$ref": "#/definitions/VaultBase_for_String" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + } + ] + }, "NeutronIbcConfig": { "type": "object", "required": [ @@ -621,6 +985,26 @@ } }, "additionalProperties": false + }, + "VaultBase_for_String": { + "type": "object", + "required": [ + "address" + ], + "properties": { + "address": { + "type": "string" + } + }, + "additionalProperties": false + }, + "VaultPositionType": { + "type": "string", + "enum": [ + "u_n_l_o_c_k_e_d", + "l_o_c_k_e_d", + "u_n_l_o_c_k_i_n_g" + ] } } }, diff --git a/schemas/mars-rover-health-types/mars-rover-health-types.json b/schemas/mars-rover-health-types/mars-rover-health-types.json deleted file mode 100644 index f1f78b3a5..000000000 --- a/schemas/mars-rover-health-types/mars-rover-health-types.json +++ /dev/null @@ -1,406 +0,0 @@ -{ - "contract_name": "mars-rover-health-types", - "contract_version": "2.0.0", - "idl_version": "1.0.0", - "instantiate": { - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "InstantiateMsg", - "type": "object", - "required": [ - "owner" - ], - "properties": { - "credit_manager": { - "description": "Credit Manager contract address", - "type": [ - "string", - "null" - ] - }, - "owner": { - "description": "The address with privileged access to update config", - "type": "string" - } - }, - "additionalProperties": false - }, - "execute": { - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ExecuteMsg", - "oneOf": [ - { - "description": "Manages owner role state", - "type": "object", - "required": [ - "update_owner" - ], - "properties": { - "update_owner": { - "$ref": "#/definitions/OwnerUpdate" - } - }, - "additionalProperties": false - }, - { - "description": "Update contract config constants", - "type": "object", - "required": [ - "update_config" - ], - "properties": { - "update_config": { - "type": "object", - "required": [ - "credit_manager" - ], - "properties": { - "credit_manager": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - } - ], - "definitions": { - "OwnerUpdate": { - "oneOf": [ - { - "description": "Proposes a new owner to take role. Only current owner can execute.", - "type": "object", - "required": [ - "propose_new_owner" - ], - "properties": { - "propose_new_owner": { - "type": "object", - "required": [ - "proposed" - ], - "properties": { - "proposed": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Clears the currently proposed owner. Only current owner can execute.", - "type": "string", - "enum": [ - "clear_proposed" - ] - }, - { - "description": "Promotes the proposed owner to be the current one. Only the proposed owner can execute.", - "type": "string", - "enum": [ - "accept_proposed" - ] - }, - { - "description": "Throws away the keys to the Owner role forever. Once done, no owner can ever be set later.", - "type": "string", - "enum": [ - "abolish_owner_role" - ] - }, - { - "description": "A separate entity managed by Owner that can be used for granting specific emergency powers.", - "type": "object", - "required": [ - "set_emergency_owner" - ], - "properties": { - "set_emergency_owner": { - "type": "object", - "required": [ - "emergency_owner" - ], - "properties": { - "emergency_owner": { - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Remove the entity in the Emergency Owner role", - "type": "string", - "enum": [ - "clear_emergency_owner" - ] - } - ] - } - } - }, - "query": { - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "QueryMsg", - "oneOf": [ - { - "description": "Returns all values that comprise health for account", - "type": "object", - "required": [ - "health_values" - ], - "properties": { - "health_values": { - "type": "object", - "required": [ - "account_id", - "action", - "kind" - ], - "properties": { - "account_id": { - "type": "string" - }, - "action": { - "$ref": "#/definitions/ActionKind" - }, - "kind": { - "$ref": "#/definitions/AccountKind" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "description": "Returns Healthy or Unhealthy state. Does not do health calculations if no debt. This is helpful in the cases like liquidation where we should not query the oracle if can help it.", - "type": "object", - "required": [ - "health_state" - ], - "properties": { - "health_state": { - "type": "object", - "required": [ - "account_id", - "action", - "kind" - ], - "properties": { - "account_id": { - "type": "string" - }, - "action": { - "$ref": "#/definitions/ActionKind" - }, - "kind": { - "$ref": "#/definitions/AccountKind" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "config" - ], - "properties": { - "config": { - "type": "object", - "additionalProperties": false - } - }, - "additionalProperties": false - } - ], - "definitions": { - "AccountKind": { - "type": "string", - "enum": [ - "default", - "high_levered_strategy" - ] - }, - "ActionKind": { - "description": "Differentiator for the action (liquidate, withdraw, borrow etc.) being performed.", - "type": "string", - "enum": [ - "default", - "liquidation" - ] - } - } - }, - "migrate": null, - "sudo": null, - "responses": { - "config": { - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ConfigResponse", - "type": "object", - "required": [ - "owner_response" - ], - "properties": { - "credit_manager": { - "type": [ - "string", - "null" - ] - }, - "owner_response": { - "$ref": "#/definitions/OwnerResponse" - } - }, - "additionalProperties": false, - "definitions": { - "OwnerResponse": { - "description": "Returned from Owner.query()", - "type": "object", - "required": [ - "abolished", - "initialized" - ], - "properties": { - "abolished": { - "type": "boolean" - }, - "emergency_owner": { - "type": [ - "string", - "null" - ] - }, - "initialized": { - "type": "boolean" - }, - "owner": { - "type": [ - "string", - "null" - ] - }, - "proposed": { - "type": [ - "string", - "null" - ] - } - }, - "additionalProperties": false - } - } - }, - "health_state": { - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "HealthState", - "oneOf": [ - { - "type": "string", - "enum": [ - "healthy" - ] - }, - { - "type": "object", - "required": [ - "unhealthy" - ], - "properties": { - "unhealthy": { - "type": "object", - "required": [ - "max_ltv_health_factor" - ], - "properties": { - "max_ltv_health_factor": { - "$ref": "#/definitions/Decimal" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - } - ], - "definitions": { - "Decimal": { - "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", - "type": "string" - } - } - }, - "health_values": { - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "HealthValuesResponse", - "type": "object", - "required": [ - "above_max_ltv", - "liquidatable", - "liquidation_threshold_adjusted_collateral", - "max_ltv_adjusted_collateral", - "total_collateral_value", - "total_debt_value" - ], - "properties": { - "above_max_ltv": { - "type": "boolean" - }, - "liquidatable": { - "type": "boolean" - }, - "liquidation_health_factor": { - "anyOf": [ - { - "$ref": "#/definitions/Decimal" - }, - { - "type": "null" - } - ] - }, - "liquidation_threshold_adjusted_collateral": { - "$ref": "#/definitions/Uint128" - }, - "max_ltv_adjusted_collateral": { - "$ref": "#/definitions/Uint128" - }, - "max_ltv_health_factor": { - "anyOf": [ - { - "$ref": "#/definitions/Decimal" - }, - { - "type": "null" - } - ] - }, - "total_collateral_value": { - "$ref": "#/definitions/Uint128" - }, - "total_debt_value": { - "$ref": "#/definitions/Uint128" - } - }, - "additionalProperties": false, - "definitions": { - "Decimal": { - "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", - "type": "string" - }, - "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" - } - } - } - } -} diff --git a/scripts/deploy/base/deployer.rover.ts b/scripts/deploy/base/deployer.rover.ts index dbfe8df1e..748c9e5fc 100644 --- a/scripts/deploy/base/deployer.rover.ts +++ b/scripts/deploy/base/deployer.rover.ts @@ -6,7 +6,7 @@ import fs from 'fs' import { InstantiateMsgs } from '../../types/instantiateMsgs' import { InstantiateMsg as NftInstantiateMsg } from '../../types/generated/mars-account-nft/MarsAccountNft.types' import { InstantiateMsg as VaultInstantiateMsg } from '../../types/generated/mars-mock-vault/MarsMockVault.types' -import { InstantiateMsg as HealthInstantiateMsg } from '../../types/generated/mars-rover-health-types/MarsRoverHealthTypes.types' +import { InstantiateMsg as HealthInstantiateMsg } from '../../types/generated/mars-rover-health/MarsRoverHealth.types' import { InstantiateMsg as ZapperInstantiateMsg } from '../../types/generated/mars-zapper-base/MarsZapperBase.types' import { ExecuteMsg as CreditManagerExecute, @@ -26,7 +26,7 @@ import { MarsCreditManagerQueryClient, } from '../../types/generated/mars-credit-manager/MarsCreditManager.client' import { kebabCase } from 'lodash' -import { MarsRoverHealthTypesClient } from '../../types/generated/mars-rover-health-types/MarsRoverHealthTypes.client' +import { MarsRoverHealthClient } from '../../types/generated/mars-rover-health/MarsRoverHealth.client' export class Deployer { constructor( @@ -80,7 +80,7 @@ export class Deployer { if (this.storage.actions.healthContractConfigUpdate) { printGray('Credit manager address') } else { - const hExec = new MarsRoverHealthTypesClient( + const hExec = new MarsRoverHealthClient( this.cwClient, this.deployerAddr, this.storage.addresses.healthContract!, diff --git a/scripts/health/DataFetcher.ts b/scripts/health/DataFetcher.ts index 99497f661..1d8866c4a 100644 --- a/scripts/health/DataFetcher.ts +++ b/scripts/health/DataFetcher.ts @@ -4,7 +4,7 @@ import { CosmWasmClient } from '@cosmjs/cosmwasm-stargate/build/cosmwasmclient' import { AccountKind, HealthValuesResponse, -} from '../types/generated/mars-rover-health-types/MarsRoverHealthTypes.types' +} from '../types/generated/mars-rover-health/MarsRoverHealth.types' import { DenomsData, HealthComputer, diff --git a/scripts/health/example-react/src/utils.ts b/scripts/health/example-react/src/utils.ts index acc16a9b2..c4d8a1bea 100644 --- a/scripts/health/example-react/src/utils.ts +++ b/scripts/health/example-react/src/utils.ts @@ -5,7 +5,7 @@ import init, { max_withdraw_estimate_js, max_borrow_estimate_js, } from '../../pkg-web' -import { HealthValuesResponse } from '../../../types/generated/mars-rover-health-types/MarsRoverHealthTypes.types' +import { HealthValuesResponse } from '../../../types/generated/mars-rover-health/MarsRoverHealth.types' import { DataFetcher } from '../../DataFetcher' import { osmosisTestnetConfig } from '../../../deploy/osmosis/testnet-config' diff --git a/scripts/types/generated/mars-rewards-collector-base/MarsRewardsCollectorBase.client.ts b/scripts/types/generated/mars-rewards-collector-base/MarsRewardsCollectorBase.client.ts index 54cb31a16..375b49c66 100644 --- a/scripts/types/generated/mars-rewards-collector-base/MarsRewardsCollectorBase.client.ts +++ b/scripts/types/generated/mars-rewards-collector-base/MarsRewardsCollectorBase.client.ts @@ -17,8 +17,11 @@ import { OwnerUpdate, Action, ActionAmount, + LiquidateRequestForVaultBaseForString, + VaultPositionType, UpdateConfig, ActionCoin, + VaultBaseForString, QueryMsg, ConfigResponse, } from './MarsRewardsCollectorBase.types' diff --git a/scripts/types/generated/mars-rewards-collector-base/MarsRewardsCollectorBase.react-query.ts b/scripts/types/generated/mars-rewards-collector-base/MarsRewardsCollectorBase.react-query.ts index 2c2ab177e..eb3895edf 100644 --- a/scripts/types/generated/mars-rewards-collector-base/MarsRewardsCollectorBase.react-query.ts +++ b/scripts/types/generated/mars-rewards-collector-base/MarsRewardsCollectorBase.react-query.ts @@ -18,8 +18,11 @@ import { OwnerUpdate, Action, ActionAmount, + LiquidateRequestForVaultBaseForString, + VaultPositionType, UpdateConfig, ActionCoin, + VaultBaseForString, QueryMsg, ConfigResponse, } from './MarsRewardsCollectorBase.types' diff --git a/scripts/types/generated/mars-rewards-collector-base/MarsRewardsCollectorBase.types.ts b/scripts/types/generated/mars-rewards-collector-base/MarsRewardsCollectorBase.types.ts index 2f770c6ec..4def839cd 100644 --- a/scripts/types/generated/mars-rewards-collector-base/MarsRewardsCollectorBase.types.ts +++ b/scripts/types/generated/mars-rewards-collector-base/MarsRewardsCollectorBase.types.ts @@ -84,9 +84,75 @@ export type OwnerUpdate = } | 'clear_emergency_owner' export type Action = + | { + deposit: Coin + } | { withdraw: ActionCoin } + | { + borrow: Coin + } + | { + lend: ActionCoin + } + | { + reclaim: ActionCoin + } + | { + claim_rewards: {} + } + | { + repay: { + coin: ActionCoin + recipient_account_id?: string | null + } + } + | { + enter_vault: { + coin: ActionCoin + vault: VaultBaseForString + } + } + | { + exit_vault: { + amount: Uint128 + vault: VaultBaseForString + } + } + | { + request_vault_unlock: { + amount: Uint128 + vault: VaultBaseForString + } + } + | { + exit_vault_unlocked: { + id: number + vault: VaultBaseForString + } + } + | { + liquidate: { + debt_coin: Coin + liquidatee_account_id: string + request: LiquidateRequestForVaultBaseForString + } + } + | { + swap_exact_in: { + coin_in: ActionCoin + denom_out: string + slippage: Decimal + } + } + | { + provide_liquidity: { + coins_in: ActionCoin[] + lp_token_out: string + slippage: Decimal + } + } | { withdraw_liquidity: { lp_token: ActionCoin @@ -94,13 +160,27 @@ export type Action = } } | { - unknown: {} + refund_all_coin_balances: {} } export type ActionAmount = | 'account_balance' | { exact: Uint128 } +export type LiquidateRequestForVaultBaseForString = + | { + deposit: string + } + | { + lend: string + } + | { + vault: { + position_type: VaultPositionType + request_vault: VaultBaseForString + } + } +export type VaultPositionType = 'u_n_l_o_c_k_e_d' | 'l_o_c_k_e_d' | 'u_n_l_o_c_k_i_n_g' export interface UpdateConfig { address_provider?: string | null channel_id?: string | null @@ -115,6 +195,9 @@ export interface ActionCoin { amount: ActionAmount denom: string } +export interface VaultBaseForString { + address: string +} export type QueryMsg = { config: {} } diff --git a/scripts/types/generated/mars-rover-health-types/MarsRoverHealthTypes.client.ts b/scripts/types/generated/mars-rover-health-types/MarsRoverHealthTypes.client.ts deleted file mode 100644 index 09384426b..000000000 --- a/scripts/types/generated/mars-rover-health-types/MarsRoverHealthTypes.client.ts +++ /dev/null @@ -1,175 +0,0 @@ -// @ts-nocheck -/** - * This file was automatically generated by @cosmwasm/ts-codegen@0.35.3. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run the @cosmwasm/ts-codegen generate command to regenerate this file. - */ - -import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from '@cosmjs/cosmwasm-stargate' -import { Coin, StdFee } from '@cosmjs/amino' -import { - InstantiateMsg, - ExecuteMsg, - OwnerUpdate, - QueryMsg, - ActionKind, - AccountKind, - ConfigResponse, - OwnerResponse, - HealthState, - Decimal, - Uint128, - HealthValuesResponse, -} from './MarsRoverHealthTypes.types' -export interface MarsRoverHealthTypesReadOnlyInterface { - contractAddress: string - healthValues: ({ - accountId, - action, - kind, - }: { - accountId: string - action: ActionKind - kind: AccountKind - }) => Promise - healthState: ({ - accountId, - action, - kind, - }: { - accountId: string - action: ActionKind - kind: AccountKind - }) => Promise - config: () => Promise -} -export class MarsRoverHealthTypesQueryClient implements MarsRoverHealthTypesReadOnlyInterface { - client: CosmWasmClient - contractAddress: string - - constructor(client: CosmWasmClient, contractAddress: string) { - this.client = client - this.contractAddress = contractAddress - this.healthValues = this.healthValues.bind(this) - this.healthState = this.healthState.bind(this) - this.config = this.config.bind(this) - } - - healthValues = async ({ - accountId, - action, - kind, - }: { - accountId: string - action: ActionKind - kind: AccountKind - }): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - health_values: { - account_id: accountId, - action, - kind, - }, - }) - } - healthState = async ({ - accountId, - action, - kind, - }: { - accountId: string - action: ActionKind - kind: AccountKind - }): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - health_state: { - account_id: accountId, - action, - kind, - }, - }) - } - config = async (): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - config: {}, - }) - } -} -export interface MarsRoverHealthTypesInterface extends MarsRoverHealthTypesReadOnlyInterface { - contractAddress: string - sender: string - updateOwner: ( - ownerUpdate: OwnerUpdate, - fee?: number | StdFee | 'auto', - memo?: string, - _funds?: Coin[], - ) => Promise - updateConfig: ( - { - creditManager, - }: { - creditManager: string - }, - fee?: number | StdFee | 'auto', - memo?: string, - _funds?: Coin[], - ) => Promise -} -export class MarsRoverHealthTypesClient - extends MarsRoverHealthTypesQueryClient - implements MarsRoverHealthTypesInterface -{ - client: SigningCosmWasmClient - sender: string - contractAddress: string - - constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string) { - super(client, contractAddress) - this.client = client - this.sender = sender - this.contractAddress = contractAddress - this.updateOwner = this.updateOwner.bind(this) - this.updateConfig = this.updateConfig.bind(this) - } - - updateOwner = async ( - ownerUpdate: OwnerUpdate, - fee: number | StdFee | 'auto' = 'auto', - memo?: string, - _funds?: Coin[], - ): Promise => { - return await this.client.execute( - this.sender, - this.contractAddress, - { - update_owner: ownerUpdate, - }, - fee, - memo, - _funds, - ) - } - updateConfig = async ( - { - creditManager, - }: { - creditManager: string - }, - fee: number | StdFee | 'auto' = 'auto', - memo?: string, - _funds?: Coin[], - ): Promise => { - return await this.client.execute( - this.sender, - this.contractAddress, - { - update_config: { - credit_manager: creditManager, - }, - }, - fee, - memo, - _funds, - ) - } -} diff --git a/scripts/types/generated/mars-rover-health-types/MarsRoverHealthTypes.react-query.ts b/scripts/types/generated/mars-rover-health-types/MarsRoverHealthTypes.react-query.ts deleted file mode 100644 index 34ff6f607..000000000 --- a/scripts/types/generated/mars-rover-health-types/MarsRoverHealthTypes.react-query.ts +++ /dev/null @@ -1,173 +0,0 @@ -// @ts-nocheck -/** - * This file was automatically generated by @cosmwasm/ts-codegen@0.35.3. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run the @cosmwasm/ts-codegen generate command to regenerate this file. - */ - -import { UseQueryOptions, useQuery, useMutation, UseMutationOptions } from '@tanstack/react-query' -import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' -import { StdFee, Coin } from '@cosmjs/amino' -import { - InstantiateMsg, - ExecuteMsg, - OwnerUpdate, - QueryMsg, - ActionKind, - AccountKind, - ConfigResponse, - OwnerResponse, - HealthState, - Decimal, - Uint128, - HealthValuesResponse, -} from './MarsRoverHealthTypes.types' -import { - MarsRoverHealthTypesQueryClient, - MarsRoverHealthTypesClient, -} from './MarsRoverHealthTypes.client' -export const marsRoverHealthTypesQueryKeys = { - contract: [ - { - contract: 'marsRoverHealthTypes', - }, - ] as const, - address: (contractAddress: string | undefined) => - [{ ...marsRoverHealthTypesQueryKeys.contract[0], address: contractAddress }] as const, - healthValues: (contractAddress: string | undefined, args?: Record) => - [ - { - ...marsRoverHealthTypesQueryKeys.address(contractAddress)[0], - method: 'health_values', - args, - }, - ] as const, - healthState: (contractAddress: string | undefined, args?: Record) => - [ - { - ...marsRoverHealthTypesQueryKeys.address(contractAddress)[0], - method: 'health_state', - args, - }, - ] as const, - config: (contractAddress: string | undefined, args?: Record) => - [ - { ...marsRoverHealthTypesQueryKeys.address(contractAddress)[0], method: 'config', args }, - ] as const, -} -export interface MarsRoverHealthTypesReactQuery { - client: MarsRoverHealthTypesQueryClient | undefined - options?: Omit< - UseQueryOptions, - "'queryKey' | 'queryFn' | 'initialData'" - > & { - initialData?: undefined - } -} -export interface MarsRoverHealthTypesConfigQuery - extends MarsRoverHealthTypesReactQuery {} -export function useMarsRoverHealthTypesConfigQuery({ - client, - options, -}: MarsRoverHealthTypesConfigQuery) { - return useQuery( - marsRoverHealthTypesQueryKeys.config(client?.contractAddress), - () => (client ? client.config() : Promise.reject(new Error('Invalid client'))), - { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, - ) -} -export interface MarsRoverHealthTypesHealthStateQuery - extends MarsRoverHealthTypesReactQuery { - args: { - accountId: string - action: ActionKind - kind: AccountKind - } -} -export function useMarsRoverHealthTypesHealthStateQuery({ - client, - args, - options, -}: MarsRoverHealthTypesHealthStateQuery) { - return useQuery( - marsRoverHealthTypesQueryKeys.healthState(client?.contractAddress, args), - () => - client - ? client.healthState({ - accountId: args.accountId, - action: args.action, - kind: args.kind, - }) - : Promise.reject(new Error('Invalid client')), - { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, - ) -} -export interface MarsRoverHealthTypesHealthValuesQuery - extends MarsRoverHealthTypesReactQuery { - args: { - accountId: string - action: ActionKind - kind: AccountKind - } -} -export function useMarsRoverHealthTypesHealthValuesQuery({ - client, - args, - options, -}: MarsRoverHealthTypesHealthValuesQuery) { - return useQuery( - marsRoverHealthTypesQueryKeys.healthValues(client?.contractAddress, args), - () => - client - ? client.healthValues({ - accountId: args.accountId, - action: args.action, - kind: args.kind, - }) - : Promise.reject(new Error('Invalid client')), - { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) }, - ) -} -export interface MarsRoverHealthTypesUpdateConfigMutation { - client: MarsRoverHealthTypesClient - msg: { - creditManager: string - } - args?: { - fee?: number | StdFee | 'auto' - memo?: string - funds?: Coin[] - } -} -export function useMarsRoverHealthTypesUpdateConfigMutation( - options?: Omit< - UseMutationOptions, - 'mutationFn' - >, -) { - return useMutation( - ({ client, msg, args: { fee, memo, funds } = {} }) => - client.updateConfig(msg, fee, memo, funds), - options, - ) -} -export interface MarsRoverHealthTypesUpdateOwnerMutation { - client: MarsRoverHealthTypesClient - msg: OwnerUpdate - args?: { - fee?: number | StdFee | 'auto' - memo?: string - funds?: Coin[] - } -} -export function useMarsRoverHealthTypesUpdateOwnerMutation( - options?: Omit< - UseMutationOptions, - 'mutationFn' - >, -) { - return useMutation( - ({ client, msg, args: { fee, memo, funds } = {} }) => client.updateOwner(msg, fee, memo, funds), - options, - ) -} diff --git a/scripts/types/generated/mars-rover-health-types/MarsRoverHealthTypes.types.ts b/scripts/types/generated/mars-rover-health-types/MarsRoverHealthTypes.types.ts deleted file mode 100644 index dfe5c81e9..000000000 --- a/scripts/types/generated/mars-rover-health-types/MarsRoverHealthTypes.types.ts +++ /dev/null @@ -1,85 +0,0 @@ -// @ts-nocheck -/** - * This file was automatically generated by @cosmwasm/ts-codegen@0.35.3. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run the @cosmwasm/ts-codegen generate command to regenerate this file. - */ - -export interface InstantiateMsg { - credit_manager?: string | null - owner: string -} -export type ExecuteMsg = - | { - update_owner: OwnerUpdate - } - | { - update_config: { - credit_manager: string - } - } -export type OwnerUpdate = - | { - propose_new_owner: { - proposed: string - } - } - | 'clear_proposed' - | 'accept_proposed' - | 'abolish_owner_role' - | { - set_emergency_owner: { - emergency_owner: string - } - } - | 'clear_emergency_owner' -export type QueryMsg = - | { - health_values: { - account_id: string - action: ActionKind - kind: AccountKind - } - } - | { - health_state: { - account_id: string - action: ActionKind - kind: AccountKind - } - } - | { - config: {} - } -export type ActionKind = 'default' | 'liquidation' -export type AccountKind = 'default' | 'high_levered_strategy' -export interface ConfigResponse { - credit_manager?: string | null - owner_response: OwnerResponse -} -export interface OwnerResponse { - abolished: boolean - emergency_owner?: string | null - initialized: boolean - owner?: string | null - proposed?: string | null -} -export type HealthState = - | 'healthy' - | { - unhealthy: { - max_ltv_health_factor: Decimal - } - } -export type Decimal = string -export type Uint128 = string -export interface HealthValuesResponse { - above_max_ltv: boolean - liquidatable: boolean - liquidation_health_factor?: Decimal | null - liquidation_threshold_adjusted_collateral: Uint128 - max_ltv_adjusted_collateral: Uint128 - max_ltv_health_factor?: Decimal | null - total_collateral_value: Uint128 - total_debt_value: Uint128 -} diff --git a/scripts/types/generated/mars-rover-health-types/bundle.ts b/scripts/types/generated/mars-rover-health-types/bundle.ts deleted file mode 100644 index 6bb25e955..000000000 --- a/scripts/types/generated/mars-rover-health-types/bundle.ts +++ /dev/null @@ -1,13 +0,0 @@ -// @ts-nocheck -/** - * This file was automatically generated by @cosmwasm/ts-codegen@0.35.3. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run the @cosmwasm/ts-codegen generate command to regenerate this file. - */ - -import * as _45 from './MarsRoverHealthTypes.types' -import * as _46 from './MarsRoverHealthTypes.client' -import * as _47 from './MarsRoverHealthTypes.react-query' -export namespace contracts { - export const MarsRoverHealthTypes = { ..._45, ..._46, ..._47 } -} diff --git a/scripts/types/generated/mars-swapper-astroport/bundle.ts b/scripts/types/generated/mars-swapper-astroport/bundle.ts index 164f7a8da..e8656da18 100644 --- a/scripts/types/generated/mars-swapper-astroport/bundle.ts +++ b/scripts/types/generated/mars-swapper-astroport/bundle.ts @@ -5,9 +5,9 @@ * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import * as _48 from './MarsSwapperAstroport.types' -import * as _49 from './MarsSwapperAstroport.client' -import * as _50 from './MarsSwapperAstroport.react-query' +import * as _45 from './MarsSwapperAstroport.types' +import * as _46 from './MarsSwapperAstroport.client' +import * as _47 from './MarsSwapperAstroport.react-query' export namespace contracts { - export const MarsSwapperAstroport = { ..._48, ..._49, ..._50 } + export const MarsSwapperAstroport = { ..._45, ..._46, ..._47 } } diff --git a/scripts/types/generated/mars-swapper-base/bundle.ts b/scripts/types/generated/mars-swapper-base/bundle.ts index 280dd2770..dcdbe9aa0 100644 --- a/scripts/types/generated/mars-swapper-base/bundle.ts +++ b/scripts/types/generated/mars-swapper-base/bundle.ts @@ -5,9 +5,9 @@ * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import * as _51 from './MarsSwapperBase.types' -import * as _52 from './MarsSwapperBase.client' -import * as _53 from './MarsSwapperBase.react-query' +import * as _48 from './MarsSwapperBase.types' +import * as _49 from './MarsSwapperBase.client' +import * as _50 from './MarsSwapperBase.react-query' export namespace contracts { - export const MarsSwapperBase = { ..._51, ..._52, ..._53 } + export const MarsSwapperBase = { ..._48, ..._49, ..._50 } } diff --git a/scripts/types/generated/mars-swapper-osmosis/bundle.ts b/scripts/types/generated/mars-swapper-osmosis/bundle.ts index de313e5c7..3e982a415 100644 --- a/scripts/types/generated/mars-swapper-osmosis/bundle.ts +++ b/scripts/types/generated/mars-swapper-osmosis/bundle.ts @@ -5,9 +5,9 @@ * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import * as _54 from './MarsSwapperOsmosis.types' -import * as _55 from './MarsSwapperOsmosis.client' -import * as _56 from './MarsSwapperOsmosis.react-query' +import * as _51 from './MarsSwapperOsmosis.types' +import * as _52 from './MarsSwapperOsmosis.client' +import * as _53 from './MarsSwapperOsmosis.react-query' export namespace contracts { - export const MarsSwapperOsmosis = { ..._54, ..._55, ..._56 } + export const MarsSwapperOsmosis = { ..._51, ..._52, ..._53 } } diff --git a/scripts/types/generated/mars-zapper-base/bundle.ts b/scripts/types/generated/mars-zapper-base/bundle.ts index 2f0515d36..11df52a21 100644 --- a/scripts/types/generated/mars-zapper-base/bundle.ts +++ b/scripts/types/generated/mars-zapper-base/bundle.ts @@ -5,9 +5,9 @@ * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import * as _57 from './MarsZapperBase.types' -import * as _58 from './MarsZapperBase.client' -import * as _59 from './MarsZapperBase.react-query' +import * as _54 from './MarsZapperBase.types' +import * as _55 from './MarsZapperBase.client' +import * as _56 from './MarsZapperBase.react-query' export namespace contracts { - export const MarsZapperBase = { ..._57, ..._58, ..._59 } + export const MarsZapperBase = { ..._54, ..._55, ..._56 } } diff --git a/scripts/types/instantiateMsgs.ts b/scripts/types/instantiateMsgs.ts index dc712679c..6a5b0a75d 100644 --- a/scripts/types/instantiateMsgs.ts +++ b/scripts/types/instantiateMsgs.ts @@ -5,7 +5,7 @@ import { InstantiateMsg as OracleInstantiateMsg } from './generated/mars-mock-or import { InstantiateMsg as RoverInstantiateMsg } from './generated/mars-credit-manager/MarsCreditManager.types' import { InstantiateMsg as SwapperInstantiateMsg } from './generated/mars-swapper-base/MarsSwapperBase.types' import { InstantiateMsg as ZapperInstantiateMsg } from './generated/mars-zapper-base/MarsZapperBase.types' -import { InstantiateMsg as HealthInstantiateMsg } from './generated/mars-rover-health-types/MarsRoverHealthTypes.types' +import { InstantiateMsg as HealthInstantiateMsg } from './generated/mars-rover-health/MarsRoverHealth.types' export type InstantiateMsgs = | NftInstantiateMsg From 070cf28be5ced818df9b0896eb8a98b90c368435 Mon Sep 17 00:00:00 2001 From: larry <26318510+larry0x@users.noreply.github.com> Date: Thu, 12 Oct 2023 13:26:15 +0100 Subject: [PATCH 14/15] run formatter --- contracts/credit-manager/src/execute.rs | 2 +- contracts/credit-manager/src/liquidate.rs | 3 +-- contracts/credit-manager/src/vault/enter.rs | 2 +- contracts/credit-manager/src/vault/utils.rs | 10 ++++++---- contracts/credit-manager/tests/test_health.rs | 5 +---- .../credit-manager/tests/test_liquidation_pricing.rs | 10 ++++++---- packages/health/src/health.rs | 3 +-- 7 files changed, 17 insertions(+), 18 deletions(-) diff --git a/contracts/credit-manager/src/execute.rs b/contracts/credit-manager/src/execute.rs index e85bf858d..676299eb3 100644 --- a/contracts/credit-manager/src/execute.rs +++ b/contracts/credit-manager/src/execute.rs @@ -3,11 +3,11 @@ use std::collections::BTreeSet; use cosmwasm_std::{ to_binary, Addr, Coins, CosmosMsg, DepsMut, Env, MessageInfo, Response, StdResult, WasmMsg, }; -use mars_types::oracle::ActionKind; use mars_types::{ account_nft::ExecuteMsg as NftExecuteMsg, credit_manager::{Action, CallbackMsg, LiquidateRequest}, health::AccountKind, + oracle::ActionKind, }; use crate::{ diff --git a/contracts/credit-manager/src/liquidate.rs b/contracts/credit-manager/src/liquidate.rs index 80b9b010b..498b93f6f 100644 --- a/contracts/credit-manager/src/liquidate.rs +++ b/contracts/credit-manager/src/liquidate.rs @@ -1,7 +1,6 @@ use cosmwasm_std::{Coin, DepsMut, QuerierWrapper, Uint128}; use mars_liquidation::liquidation::calculate_liquidation_amounts; -use mars_types::oracle::ActionKind; -use mars_types::{adapters::oracle::Oracle, traits::Stringify}; +use mars_types::{adapters::oracle::Oracle, oracle::ActionKind, traits::Stringify}; use crate::{ error::{ContractError, ContractResult}, diff --git a/contracts/credit-manager/src/vault/enter.rs b/contracts/credit-manager/src/vault/enter.rs index 1b08d30f0..1b1acc4ec 100644 --- a/contracts/credit-manager/src/vault/enter.rs +++ b/contracts/credit-manager/src/vault/enter.rs @@ -1,10 +1,10 @@ use cosmwasm_std::{ to_binary, Addr, Coin, CosmosMsg, Deps, DepsMut, QuerierWrapper, Response, Uint128, WasmMsg, }; -use mars_types::oracle::ActionKind; use mars_types::{ adapters::vault::{UpdateType, Vault, VaultPositionUpdate}, credit_manager::{ActionAmount, ActionCoin, CallbackMsg, ExecuteMsg}, + oracle::ActionKind, }; use crate::{ diff --git a/contracts/credit-manager/src/vault/utils.rs b/contracts/credit-manager/src/vault/utils.rs index 29cec72bd..a2174b735 100644 --- a/contracts/credit-manager/src/vault/utils.rs +++ b/contracts/credit-manager/src/vault/utils.rs @@ -1,9 +1,11 @@ use cosmwasm_std::{Addr, Coin, Deps, DepsMut, StdResult, Storage, Uint128}; -use mars_types::adapters::vault::{ - LockingVaultAmount, UnlockingPositions, Vault, VaultAmount, VaultPosition, VaultPositionAmount, - VaultPositionUpdate, +use mars_types::{ + adapters::vault::{ + LockingVaultAmount, UnlockingPositions, Vault, VaultAmount, VaultPosition, + VaultPositionAmount, VaultPositionUpdate, + }, + oracle::ActionKind, }; -use mars_types::oracle::ActionKind; use crate::{ error::{ContractError, ContractResult}, diff --git a/contracts/credit-manager/tests/test_health.rs b/contracts/credit-manager/tests/test_health.rs index 0e136e66e..faf04482b 100644 --- a/contracts/credit-manager/tests/test_health.rs +++ b/contracts/credit-manager/tests/test_health.rs @@ -1,8 +1,7 @@ use std::ops::{Add, Mul}; use cosmwasm_std::{coin, coins, Addr, Coin, Decimal, Uint128}; -use mars_credit_manager::borrow::DEFAULT_DEBT_SHARES_PER_COIN_BORROWED; -use mars_credit_manager::error::ContractError; +use mars_credit_manager::{borrow::DEFAULT_DEBT_SHARES_PER_COIN_BORROWED, error::ContractError}; use mars_mock_oracle::msg::CoinPrice; use mars_types::{ credit_manager::{ @@ -10,8 +9,6 @@ use mars_types::{ ActionAmount, ActionCoin, DebtAmount, }, health::AccountKind, -}; -use mars_types::{ oracle::ActionKind, params::{AssetParamsUpdate::AddOrUpdate, LiquidationBonus, VaultConfigUpdate}, }; diff --git a/contracts/credit-manager/tests/test_liquidation_pricing.rs b/contracts/credit-manager/tests/test_liquidation_pricing.rs index 500a5d0fa..0af800d7e 100644 --- a/contracts/credit-manager/tests/test_liquidation_pricing.rs +++ b/contracts/credit-manager/tests/test_liquidation_pricing.rs @@ -1,11 +1,13 @@ use cosmwasm_std::{coins, Addr, Coin, Decimal}; use mars_credit_manager::error::ContractError; use mars_mock_oracle::msg::CoinPrice; -use mars_types::credit_manager::{ - Action::{Borrow, Deposit, Liquidate}, - LiquidateRequest, +use mars_types::{ + credit_manager::{ + Action::{Borrow, Deposit, Liquidate}, + LiquidateRequest, + }, + oracle::ActionKind, }; -use mars_types::oracle::ActionKind; use crate::helpers::{assert_err, uatom_info, uosmo_info, AccountToFund, MockEnv}; diff --git a/packages/health/src/health.rs b/packages/health/src/health.rs index eab66de34..c84616930 100644 --- a/packages/health/src/health.rs +++ b/packages/health/src/health.rs @@ -1,8 +1,7 @@ use std::{collections::HashMap, fmt}; use cosmwasm_std::{Addr, Coin, Decimal, Fraction, QuerierWrapper, StdResult, Uint128}; -use mars_types::health::HealthValuesResponse; -use mars_types::params::AssetParams; +use mars_types::{health::HealthValuesResponse, params::AssetParams}; use crate::{error::HealthError, query::MarsQuerier}; From 408ff2bad89cc500c271e5628a4fc900dd9a4a89 Mon Sep 17 00:00:00 2001 From: larry <26318510+larry0x@users.noreply.github.com> Date: Thu, 12 Oct 2023 13:28:25 +0100 Subject: [PATCH 15/15] update README --- packages/types/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/types/README.md b/packages/types/README.md index c300ca42e..ba51a0d25 100644 --- a/packages/types/README.md +++ b/packages/types/README.md @@ -1,6 +1,6 @@ -# Mars Red Bank +# Mars Types -Contains messages and types for Red Bank smart contracts. +Contains messages and types for Mars smart contracts. ## License