From 29d95fb9c75634f57f15e0616a6141d3dfcdf850 Mon Sep 17 00:00:00 2001 From: wc117 Date: Sat, 17 Aug 2024 02:22:26 +0800 Subject: [PATCH] migrate from wynd to paloma, remove migration feature --- .github/workflows/Release.yml | 10 +- Cargo.lock | 298 +++++++++--------- Cargo.toml | 26 +- NOTICE | 4 +- README.md | 6 +- contracts/cw-placeholder/Cargo.toml | 2 +- contracts/cw-placeholder/src/contract.rs | 6 - contracts/factory/Cargo.toml | 12 +- contracts/factory/README.md | 10 +- contracts/factory/src/bin/factory_schema.rs | 2 +- contracts/factory/src/contract.rs | 73 +---- contracts/factory/src/mock_querier.rs | 24 +- contracts/factory/src/querier.rs | 4 +- contracts/factory/src/state.rs | 8 +- contracts/factory/src/testing.rs | 20 +- contracts/factory/tests/factory_helper.rs | 40 +-- contracts/factory/tests/integration.rs | 21 +- contracts/factory/tests/migration.rs | 207 ------------ contracts/gauge-adapter/Cargo.toml | 12 +- contracts/gauge-adapter/src/contract.rs | 70 +--- contracts/gauge-adapter/src/msg.rs | 2 +- .../gauge-adapter/src/multitest/options.rs | 2 +- .../gauge-adapter/src/multitest/sample.rs | 18 +- .../gauge-adapter/src/multitest/suite.rs | 51 ++- contracts/gauge-adapter/src/querier.rs | 4 +- contracts/gauge-adapter/src/state.rs | 2 +- contracts/junoswap-staking/Cargo.toml | 16 +- contracts/junoswap-staking/README.md | 2 +- contracts/junoswap-staking/src/contract.rs | 104 ++---- contracts/junoswap-staking/src/msg.rs | 6 +- .../src/multitest/migration.rs | 183 ++++++----- .../junoswap-staking/src/multitest/suite.rs | 141 ++++----- contracts/junoswap-staking/src/state.rs | 10 +- contracts/lp-converter/Cargo.toml | 12 +- contracts/lp-converter/README.md | 2 +- contracts/lp-converter/src/bin/schema.rs | 2 +- contracts/lp-converter/src/contract.rs | 15 +- .../src/multitest/migrate_stake.rs | 8 +- contracts/lp-converter/src/multitest/suite.rs | 39 ++- contracts/lp-converter/src/state.rs | 2 +- contracts/multi-hop/Cargo.toml | 14 +- contracts/multi-hop/README.md | 24 +- .../multi-hop/src/bin/multi_hop_schema.rs | 2 +- contracts/multi-hop/src/contract.rs | 61 ++-- contracts/multi-hop/src/msg.rs | 16 +- contracts/multi-hop/src/multitest/suite.rs | 36 +-- contracts/multi-hop/src/multitest/swap.rs | 70 ++-- contracts/multi-hop/src/state.rs | 2 +- contracts/nominated-trader/Cargo.toml | 18 +- contracts/nominated-trader/README.md | 6 +- contracts/nominated-trader/src/contract.rs | 29 +- contracts/nominated-trader/src/error.rs | 2 +- contracts/nominated-trader/src/msg.rs | 28 +- .../nominated-trader/src/multitest/flows.rs | 48 +-- .../nominated-trader/src/multitest/suite.rs | 32 +- contracts/nominated-trader/src/state.rs | 12 +- contracts/nominated-trader/src/utils.rs | 16 +- contracts/pair/Cargo.toml | 12 +- contracts/pair/README.md | 8 +- contracts/pair/src/bin/pair_schema.rs | 2 +- contracts/pair/src/contract.rs | 56 +--- contracts/pair/src/mock_querier.rs | 4 +- contracts/pair/src/state.rs | 2 +- contracts/pair/src/testing.rs | 37 +-- contracts/pair/tests/integration.rs | 32 +- contracts/pair_lsd/Cargo.toml | 12 +- contracts/pair_lsd/README.md | 8 +- .../pair_lsd/src/bin/pair_stable_schema.rs | 2 +- contracts/pair_lsd/src/contract.rs | 36 +-- contracts/pair_lsd/src/math.rs | 6 +- contracts/pair_lsd/src/mock_querier.rs | 4 +- .../pair_lsd/src/multitest/simulation.rs | 4 +- contracts/pair_lsd/src/multitest/suite.rs | 32 +- .../pair_lsd/src/multitest/target_rate.rs | 4 +- contracts/pair_lsd/src/state.rs | 6 +- contracts/pair_lsd/src/testing.rs | 22 +- contracts/pair_lsd/src/utils.rs | 6 +- contracts/pair_lsd/tests/3pool_tests.rs | 4 +- contracts/pair_lsd/tests/helper.rs | 37 +-- contracts/pair_lsd/tests/integration.rs | 34 +- contracts/raw-migration/Cargo.toml | 16 +- contracts/raw-migration/README.md | 2 +- contracts/raw-migration/src/contract.rs | 130 ++------ contracts/raw-migration/src/msg.rs | 16 +- .../raw-migration/src/multitest/migration.rs | 125 ++++---- .../raw-migration/src/multitest/suite.rs | 151 +++++---- contracts/raw-migration/src/state.rs | 14 +- contracts/splitter/Cargo.toml | 4 +- contracts/splitter/src/contract.rs | 52 +-- contracts/stake/Cargo.toml | 6 +- contracts/stake/NOTICE | 2 +- contracts/stake/README.md | 2 +- contracts/stake/src/bin/stake_schema.rs | 4 +- contracts/stake/src/contract.rs | 45 +-- contracts/stake/src/distribution.rs | 2 +- contracts/stake/src/error.rs | 2 +- contracts/stake/src/lib.rs | 4 +- contracts/stake/src/msg.rs | 4 +- contracts/stake/src/multitest.rs | 1 - contracts/stake/src/multitest/distribution.rs | 78 ++--- contracts/stake/src/multitest/migration.rs | 184 ----------- contracts/stake/src/multitest/quick_unbond.rs | 2 +- .../stake/src/multitest/staking_rewards.rs | 4 +- contracts/stake/src/multitest/suite.rs | 4 +- contracts/stake/src/multitest/unbond_all.rs | 10 +- contracts/stake/src/state.rs | 4 +- packages/{wyndex => palomadex}/.cargo/config | 0 packages/{wyndex => palomadex}/Cargo.toml | 10 +- packages/{wyndex => palomadex}/README.md | 4 +- packages/{wyndex => palomadex}/src/asset.rs | 0 packages/{wyndex => palomadex}/src/common.rs | 0 packages/{wyndex => palomadex}/src/factory.rs | 2 +- .../{wyndex => palomadex}/src/fee_config.rs | 0 packages/{wyndex => palomadex}/src/lib.rs | 0 .../{wyndex => palomadex}/src/lp_converter.rs | 0 .../{wyndex => palomadex}/src/mock_querier.rs | 20 +- packages/{wyndex => palomadex}/src/oracle.rs | 0 .../{wyndex => palomadex}/src/oracle_old.rs | 0 packages/{wyndex => palomadex}/src/pair.rs | 4 +- .../{wyndex => palomadex}/src/pair/error.rs | 0 .../src/pair/instantiate.rs | 2 +- .../src/pair/mock_querier.rs | 2 +- .../src/pair/referral.rs | 0 .../{wyndex => palomadex}/src/pair/utils.rs | 0 packages/{wyndex => palomadex}/src/querier.rs | 2 +- packages/{wyndex => palomadex}/src/stake.rs | 0 packages/{wyndex => palomadex}/src/testing.rs | 6 +- tests/Cargo.toml | 10 +- tests/src/suite.rs | 48 +-- tests/tests/staking.rs | 18 +- tests/tests/swap.rs | 14 +- 131 files changed, 1269 insertions(+), 2003 deletions(-) delete mode 100644 contracts/factory/tests/migration.rs delete mode 100644 contracts/stake/src/multitest/migration.rs rename packages/{wyndex => palomadex}/.cargo/config (100%) rename packages/{wyndex => palomadex}/Cargo.toml (76%) rename packages/{wyndex => palomadex}/README.md (97%) rename packages/{wyndex => palomadex}/src/asset.rs (100%) rename packages/{wyndex => palomadex}/src/common.rs (100%) rename packages/{wyndex => palomadex}/src/factory.rs (99%) rename packages/{wyndex => palomadex}/src/fee_config.rs (100%) rename packages/{wyndex => palomadex}/src/lib.rs (100%) rename packages/{wyndex => palomadex}/src/lp_converter.rs (100%) rename packages/{wyndex => palomadex}/src/mock_querier.rs (93%) rename packages/{wyndex => palomadex}/src/oracle.rs (100%) rename packages/{wyndex => palomadex}/src/oracle_old.rs (100%) rename packages/{wyndex => palomadex}/src/pair.rs (99%) rename packages/{wyndex => palomadex}/src/pair/error.rs (100%) rename packages/{wyndex => palomadex}/src/pair/instantiate.rs (98%) rename packages/{wyndex => palomadex}/src/pair/mock_querier.rs (99%) rename packages/{wyndex => palomadex}/src/pair/referral.rs (100%) rename packages/{wyndex => palomadex}/src/pair/utils.rs (100%) rename packages/{wyndex => palomadex}/src/querier.rs (99%) rename packages/{wyndex => palomadex}/src/stake.rs (100%) rename packages/{wyndex => palomadex}/src/testing.rs (98%) diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index b56cb5d..035e85b 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -26,11 +26,11 @@ jobs: artifacts/gauge_adapter.wasm artifacts/lp_converter.wasm artifacts/nominated_trader.wasm - artifacts/wyndex_multi_hop.wasm - artifacts/wyndex_stake.wasm + artifacts/palomadex_multi_hop.wasm + artifacts/palomadex_stake.wasm artifacts/checksums.txt artifacts/raw_migration.wasm - artifacts/wyndex_pair_lsd.wasm + artifacts/palomadex_pair_lsd.wasm artifacts/junoswap_staking.wasm - artifacts/wyndex_factory.wasm - artifacts/wyndex_pair.wasm + artifacts/palomadex_factory.wasm + artifacts/palomadex_pair.wasm diff --git a/Cargo.lock b/Cargo.lock index efd8e28..c0a88a9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -801,13 +801,13 @@ dependencies = [ "cw2 1.0.1", "cw20 1.0.1", "cw20-base 1.0.1", + "palomadex", + "palomadex-factory", + "palomadex-pair", + "palomadex-pair-lsd", + "palomadex-stake", "thiserror", "wynd-utils 1.6.0 (git+https://github.com/wynddao/wynddao.git?tag=v1.6.0)", - "wyndex 2.2.0", - "wyndex-factory 2.2.0", - "wyndex-pair", - "wyndex-pair-lsd", - "wyndex-stake 2.2.0", ] [[package]] @@ -941,14 +941,14 @@ dependencies = [ "cw20 1.0.1", "cw20-base 0.10.3", "cw20-base 1.0.1", + "palomadex", + "palomadex-factory", + "palomadex-pair", + "palomadex-stake", "serde", "stake-cw20", "thiserror", "wasmswap", - "wyndex 2.2.0", - "wyndex-factory 2.2.0", - "wyndex-pair", - "wyndex-stake 2.2.0", ] [[package]] @@ -1005,12 +1005,12 @@ dependencies = [ "cw2 1.0.1", "cw20 1.0.1", "cw20-base 1.0.1", + "palomadex", + "palomadex-factory", + "palomadex-pair", + "palomadex-stake", "thiserror", "wynd-lsd-hub", - "wyndex 2.2.0", - "wyndex-factory 2.2.0", - "wyndex-pair", - "wyndex-stake 2.2.0", ] [[package]] @@ -1032,13 +1032,13 @@ dependencies = [ "cw2 1.0.1", "cw20 1.0.1", "cw20-base 1.0.1", + "palomadex", + "palomadex-factory", + "palomadex-multi-hop", + "palomadex-pair", + "palomadex-pair-lsd", + "palomadex-stake", "thiserror", - "wyndex 2.2.0", - "wyndex-factory 2.2.0", - "wyndex-multi-hop", - "wyndex-pair", - "wyndex-pair-lsd", - "wyndex-stake 2.2.0", ] [[package]] @@ -1063,6 +1063,127 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "palomadex" +version = "2.2.0" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw-storage-plus 1.1.0", + "cw-utils 1.0.1", + "cw20 1.0.1", + "cw20-base 1.0.1", + "itertools", + "thiserror", + "uint", +] + +[[package]] +name = "palomadex-factory" +version = "2.2.0" +dependencies = [ + "anyhow", + "cosmwasm-schema", + "cosmwasm-std", + "cw-multi-test", + "cw-placeholder 2.2.0", + "cw-storage-plus 1.1.0", + "cw-utils 1.0.1", + "cw2 1.0.1", + "cw20 1.0.1", + "cw20-base 1.0.1", + "itertools", + "palomadex", + "palomadex-pair", + "palomadex-stake", + "thiserror", + "wyndex-factory", +] + +[[package]] +name = "palomadex-multi-hop" +version = "2.2.0" +dependencies = [ + "anyhow", + "cosmwasm-schema", + "cosmwasm-std", + "cw-multi-test", + "cw-storage-plus 1.1.0", + "cw-utils 1.0.1", + "cw2 1.0.1", + "cw20 1.0.1", + "cw20-base 1.0.1", + "palomadex", + "palomadex-factory", + "palomadex-pair", + "palomadex-stake", + "thiserror", +] + +[[package]] +name = "palomadex-pair" +version = "2.2.0" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw-multi-test", + "cw-storage-plus 1.1.0", + "cw-utils 1.0.1", + "cw2 1.0.1", + "cw20 1.0.1", + "cw20-base 1.0.1", + "palomadex", + "palomadex-factory", + "palomadex-stake", + "proptest", +] + +[[package]] +name = "palomadex-pair-lsd" +version = "2.2.0" +dependencies = [ + "anyhow", + "cosmwasm-schema", + "cosmwasm-std", + "cw-multi-test", + "cw-storage-plus 1.1.0", + "cw-utils 1.0.1", + "cw2 1.0.1", + "cw20 1.0.1", + "cw20-base 1.0.1", + "derivative", + "itertools", + "palomadex", + "palomadex-factory", + "palomadex-pair", + "palomadex-stake", + "proptest", +] + +[[package]] +name = "palomadex-stake" +version = "2.2.0" +dependencies = [ + "anyhow", + "cosmwasm-schema", + "cosmwasm-std", + "cw-controllers 1.0.1", + "cw-multi-test", + "cw-storage-plus 1.1.0", + "cw-utils 1.0.1", + "cw2 1.0.1", + "cw20 1.0.1", + "cw20-base 1.0.1", + "lp-converter", + "palomadex", + "serde", + "test-case", + "thiserror", + "wynd-utils 1.6.0 (git+https://github.com/wynddao/wynddao.git?tag=v1.6.0)", + "wyndex 2.0.2", + "wyndex-stake 2.0.2", +] + [[package]] name = "pkcs8" version = "0.9.0" @@ -1242,14 +1363,14 @@ dependencies = [ "cw20 1.0.1", "cw20-base 0.10.3", "cw20-base 1.0.1", + "palomadex", + "palomadex-factory", + "palomadex-pair", + "palomadex-stake", "serde", "stake-cw20", "thiserror", "wasmswap", - "wyndex 2.2.0", - "wyndex-factory 2.2.0", - "wyndex-pair", - "wyndex-stake 2.2.0", ] [[package]] @@ -1578,11 +1699,11 @@ dependencies = [ "cw-multi-test", "cw20 1.0.1", "cw20-base 1.0.1", - "wyndex 2.2.0", - "wyndex-factory 2.2.0", - "wyndex-multi-hop", - "wyndex-pair", - "wyndex-stake 2.2.0", + "palomadex", + "palomadex-factory", + "palomadex-multi-hop", + "palomadex-pair", + "palomadex-stake", ] [[package]] @@ -1816,21 +1937,6 @@ dependencies = [ "uint", ] -[[package]] -name = "wyndex" -version = "2.2.0" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus 1.1.0", - "cw-utils 1.0.1", - "cw20 1.0.1", - "cw20-base 1.0.1", - "itertools", - "thiserror", - "uint", -] - [[package]] name = "wyndex-factory" version = "2.1.0" @@ -1848,88 +1954,6 @@ dependencies = [ "wyndex-stake 2.1.0", ] -[[package]] -name = "wyndex-factory" -version = "2.2.0" -dependencies = [ - "anyhow", - "cosmwasm-schema", - "cosmwasm-std", - "cw-multi-test", - "cw-placeholder 2.2.0", - "cw-storage-plus 1.1.0", - "cw-utils 1.0.1", - "cw2 1.0.1", - "cw20 1.0.1", - "cw20-base 1.0.1", - "itertools", - "thiserror", - "wyndex 2.2.0", - "wyndex-factory 2.1.0", - "wyndex-pair", - "wyndex-stake 2.2.0", -] - -[[package]] -name = "wyndex-multi-hop" -version = "2.2.0" -dependencies = [ - "anyhow", - "cosmwasm-schema", - "cosmwasm-std", - "cw-multi-test", - "cw-storage-plus 1.1.0", - "cw-utils 1.0.1", - "cw2 1.0.1", - "cw20 1.0.1", - "cw20-base 1.0.1", - "thiserror", - "wyndex 2.2.0", - "wyndex-factory 2.2.0", - "wyndex-pair", - "wyndex-stake 2.2.0", -] - -[[package]] -name = "wyndex-pair" -version = "2.2.0" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-multi-test", - "cw-storage-plus 1.1.0", - "cw-utils 1.0.1", - "cw2 1.0.1", - "cw20 1.0.1", - "cw20-base 1.0.1", - "proptest", - "wyndex 2.2.0", - "wyndex-factory 2.2.0", - "wyndex-stake 2.2.0", -] - -[[package]] -name = "wyndex-pair-lsd" -version = "2.2.0" -dependencies = [ - "anyhow", - "cosmwasm-schema", - "cosmwasm-std", - "cw-multi-test", - "cw-storage-plus 1.1.0", - "cw-utils 1.0.1", - "cw2 1.0.1", - "cw20 1.0.1", - "cw20-base 1.0.1", - "derivative", - "itertools", - "proptest", - "wyndex 2.2.0", - "wyndex-factory 2.2.0", - "wyndex-pair", - "wyndex-stake 2.2.0", -] - [[package]] name = "wyndex-stake" version = "2.0.2" @@ -1966,30 +1990,6 @@ dependencies = [ "wyndex 2.1.0", ] -[[package]] -name = "wyndex-stake" -version = "2.2.0" -dependencies = [ - "anyhow", - "cosmwasm-schema", - "cosmwasm-std", - "cw-controllers 1.0.1", - "cw-multi-test", - "cw-storage-plus 1.1.0", - "cw-utils 1.0.1", - "cw2 1.0.1", - "cw20 1.0.1", - "cw20-base 1.0.1", - "lp-converter", - "serde", - "test-case", - "thiserror", - "wynd-utils 1.6.0 (git+https://github.com/wynddao/wynddao.git?tag=v1.6.0)", - "wyndex 2.0.2", - "wyndex 2.2.0", - "wyndex-stake 2.0.2", -] - [[package]] name = "zeroize" version = "1.6.0" diff --git a/Cargo.toml b/Cargo.toml index 950dd24..7bf43bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,19 +5,19 @@ members = ["packages/*", "contracts/*", "tests", "utils/*"] version = "2.2.0" edition = "2021" license = "GPL 3.0" -repository = "https://github.com/cosmorama/wynddex" +repository = "https://github.com/volumefi/palomadex" [workspace.dependencies] anyhow = "1" -wyndex = { path = "./packages/wyndex", default-features = false } +palomadex = { path = "./packages/palomadex", default-features = false } wynd-curve-utils = { git = "https://github.com/wynddao/wynddao.git", tag = "v1.6.0", package = "wynd-utils" } cw20-base = { version = "1.0", package = "cw20-base", features = ["library"] } -wyndex-factory = { path = "./contracts/factory" } +palomadex-factory = { path = "./contracts/factory" } cw-placeholder = { path = "./contracts/cw-placeholder" } -wyndex-pair = { path = "./contracts/pair" } -wyndex-pair-lsd = { path = "./contracts/pair_lsd" } -wyndex-multi-hop = { path = "./contracts/multi-hop" } -wyndex-stake = { path = "./contracts/stake" } +palomadex-pair = { path = "./contracts/pair" } +palomadex-pair-lsd = { path = "./contracts/pair_lsd" } +palomadex-multi-hop = { path = "./contracts/multi-hop" } +palomadex-stake = { path = "./contracts/stake" } wynd-lsd-hub = { git = "https://github.com/wynddao/wynd-lsd.git", version = "1.2.1", features = [ "library", ] } @@ -26,7 +26,7 @@ cosmwasm-schema = "1.1" cosmwasm-std = "1.1" cw2 = "1.0" cw20 = "1.0" -semver = "1" +semver = "1" cw-controllers = "1.0" cw-multi-test = "0.16" cw-storage-plus = "1.0" @@ -41,23 +41,23 @@ uint = "0.9" wyndex-stake-2_0_0 = { package = "wyndex-stake", git = "https://github.com/wynddao/wynddex", tag = "v2.0.0" } -[profile.release.package.wyndex-factory] +[profile.release.package.palomadex-factory] codegen-units = 1 incremental = false -[profile.release.package.wyndex-multi-hop] +[profile.release.package.palomadex-multi-hop] codegen-units = 1 incremental = false -[profile.release.package.wyndex-pair] +[profile.release.package.palomadex-pair] codegen-units = 1 incremental = false -[profile.release.package.wyndex-pair-lsd] +[profile.release.package.palomadex-pair-lsd] codegen-units = 1 incremental = false -[profile.release.package.wyndex-stake] +[profile.release.package.palomadex-stake] codegen-units = 1 incremental = false diff --git a/NOTICE b/NOTICE index 4504535..9e6f5ea 100644 --- a/NOTICE +++ b/NOTICE @@ -1,6 +1,6 @@ -WYNDEX: Innovative CosmWasm-based Decentralized Exchange +PALOMADEX: Innovative CosmWasm-based Decentralized Exchange -Copyright (C) 2022 Wynd Foundation +Copyright (C) 2022 Volume Fi Copyright (C) 2021-2022 Delphi Labs (original Astroport contracts) This program is free software: you can redistribute it and/or modify diff --git a/README.md b/README.md index 05144ec..0d13fa2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# WynDex +# PalomaDex -A Multi-chain Decentralized Exchange (DEX) built on CosmWasm for the WYND DAO. +A Multi-chain Decentralized Exchange (DEX) built on CosmWasm for the PALOMACHAIN. ## Overview @@ -8,7 +8,7 @@ A Multi-chain Decentralized Exchange (DEX) built on CosmWasm for the WYND DAO. ## License The initial pool types were copied from [astroport-core](https://github.com/astroport-fi/astroport-core) -and modified to fit the needs of the WynDex. We will be extending this project to include +and modified to fit the needs of the PalomaDex. We will be extending this project to include more pool types and other features. As per the requirements of the original Astroport license, all code is licensed under GPL-3.0. diff --git a/contracts/cw-placeholder/Cargo.toml b/contracts/cw-placeholder/Cargo.toml index 1a6f537..20b2106 100644 --- a/contracts/cw-placeholder/Cargo.toml +++ b/contracts/cw-placeholder/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "cw-placeholder" version = { workspace = true } -authors = ["Cosmorama "] +authors = ["Volume Fi"] edition = { workspace = true } license = { workspace = true } diff --git a/contracts/cw-placeholder/src/contract.rs b/contracts/cw-placeholder/src/contract.rs index 4cf9aa0..e8dbaff 100644 --- a/contracts/cw-placeholder/src/contract.rs +++ b/contracts/cw-placeholder/src/contract.rs @@ -1,15 +1,10 @@ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult}; -use cw2::set_contract_version; use crate::error::ContractError; use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; -// version info for migration info -pub const CONTRACT_NAME: &str = "crates.io:cw-placeholder"; -const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); - #[cfg_attr(not(feature = "library"), entry_point)] pub fn instantiate( deps: DepsMut, @@ -17,7 +12,6 @@ pub fn instantiate( _info: MessageInfo, _msg: InstantiateMsg, ) -> Result { - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; Ok(Response::default()) } diff --git a/contracts/factory/Cargo.toml b/contracts/factory/Cargo.toml index cd670f7..c890b62 100644 --- a/contracts/factory/Cargo.toml +++ b/contracts/factory/Cargo.toml @@ -1,9 +1,9 @@ [package] -name = "wyndex-factory" +name = "palomadex-factory" version = { workspace = true } -authors = ["Cosmorama "] +authors = ["Volume Fi"] edition = { workspace = true } -description = "Wyndex factory contract - pair contract generator" +description = "PalomaDex factory contract - pair contract generator" license = { workspace = true } [lib] @@ -23,8 +23,8 @@ cw2 = { workspace = true } cw20 = { workspace = true } itertools = { workspace = true } thiserror = { workspace = true } -wyndex = { workspace = true } -wyndex-stake = { workspace = true, features = ["library"] } +palomadex = { workspace = true } +palomadex-stake = { workspace = true, features = ["library"] } cw-placeholder = { workspace = true, features = ["library"] } [dev-dependencies] @@ -32,5 +32,5 @@ anyhow = { workspace = true } cw-multi-test = { workspace = true } cw20-base = { workspace = true } cw20 = { workspace = true } -wyndex-pair = { workspace = true } +palomadex-pair = { workspace = true } wyndex-factory-2_1_0 = { package = "wyndex-factory", git = "https://github.com/wynddao/wynddex", tag = "v2.1.0" } diff --git a/contracts/factory/README.md b/contracts/factory/README.md index 8de5725..a4f95aa 100644 --- a/contracts/factory/README.md +++ b/contracts/factory/README.md @@ -1,12 +1,12 @@ -# Wyndex Factory +# Palomadex Factory -The factory contract can create new Wyndex pair contracts (and associated LP token contracts) and it is used as a directory for all pairs. The default pair types are constant product and stableswap but governance may decide to add custom pools that can have any implementation. +The factory contract can create new Palomadex pair contracts (and associated LP token contracts) and it is used as a directory for all pairs. The default pair types are constant product and stableswap but governance may decide to add custom pools that can have any implementation. --- ## InstantiateMsg -The instantiation message takes in the token code ID for the token type supported on Wyndex. It also takes in the `fee_address` that collects fees for governance, the contract `owner` and the initial pair types available to create. +The instantiation message takes in the token code ID for the token type supported on Palomadex. It also takes in the `fee_address` that collects fees for governance, the contract `owner` and the initial pair types available to create. ```json { @@ -30,7 +30,7 @@ The instantiation message takes in the token code ID for the token type supporte ### `update_config` -Updates contract variables, namely the code ID of the token implementation used in Wyndex, the address that receives governance fees and the Generator contract address. +Updates contract variables, namely the code ID of the token implementation used in Palomadex, the address that receives governance fees and the Generator contract address. ```json { @@ -76,7 +76,7 @@ As an example, let's say a pool charged 30bps (`total_fee_bps` is 30) and we wan ### `create_pair` -Anyone can execute this function to create an Wyndex pair. `CreatePair` creates both a `Pair` contract and a `LP(liquidity provider)` token contract. The account that instantiates the pair must specify the pair type they want as well as the assets for which the pool is created. +Anyone can execute this function to create an Palomadex pair. `CreatePair` creates both a `Pair` contract and a `LP(liquidity provider)` token contract. The account that instantiates the pair must specify the pair type they want as well as the assets for which the pool is created. Custom pool types may also need extra parameters which can be packed in `init_params`. diff --git a/contracts/factory/src/bin/factory_schema.rs b/contracts/factory/src/bin/factory_schema.rs index ec1ec41..165026c 100644 --- a/contracts/factory/src/bin/factory_schema.rs +++ b/contracts/factory/src/bin/factory_schema.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::write_api; -use wyndex::factory::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; +use palomadex::factory::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; fn main() { write_api! { diff --git a/contracts/factory/src/contract.rs b/contracts/factory/src/contract.rs index 0a7163b..88d49fb 100644 --- a/contracts/factory/src/contract.rs +++ b/contracts/factory/src/contract.rs @@ -2,22 +2,20 @@ use cosmwasm_std::{ attr, entry_point, from_binary, to_binary, Addr, Binary, CosmosMsg, Decimal, Deps, DepsMut, Env, MessageInfo, Order, Reply, ReplyOn, Response, StdError, StdResult, SubMsg, WasmMsg, }; -use cw2::set_contract_version; use cw20::Cw20ReceiveMsg; -use cw_utils::ensure_from_older_version; -use wyndex::asset::{addr_opt_validate, Asset, AssetInfo}; -use wyndex::common::{ +use palomadex::asset::{addr_opt_validate, Asset, AssetInfo}; +use palomadex::common::{ claim_ownership, drop_ownership_proposal, propose_new_owner, validate_addresses, }; -use wyndex::factory::{ +use palomadex::factory::{ ConfigResponse, DistributionFlow, ExecuteMsg, FeeInfoResponse, InstantiateMsg, MigrateMsg, PairConfig, PairType, PairsResponse, PartialDefaultStakeConfig, PartialStakeConfig, QueryMsg, ReceiveMsg, ROUTE, }; -use wyndex::fee_config::FeeConfig; -use wyndex::stake::UnbondingPeriod; -use wyndex_stake::msg::ExecuteMsg as StakeExecuteMsg; +use palomadex::fee_config::FeeConfig; +use palomadex::stake::UnbondingPeriod; +use palomadex_stake::msg::ExecuteMsg as StakeExecuteMsg; use crate::error::ContractError; use crate::querier::query_pair_info; @@ -30,12 +28,9 @@ use crate::state::{ use itertools::Itertools; use std::collections::HashSet; -use cw_placeholder::contract::CONTRACT_NAME as PLACEHOLDER_CONTRACT_NAME; -use wyndex::pair::{ExecuteMsg as PairExecuteMsg, InstantiateMsg as PairInstantiateMsg, PairInfo}; -/// Contract name that is used for migration. -const CONTRACT_NAME: &str = "wyndex-factory"; -/// Contract version that is used for migration. -const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); +use palomadex::pair::{ + ExecuteMsg as PairExecuteMsg, InstantiateMsg as PairInstantiateMsg, PairInfo, +}; /// A `reply` call code ID used in a sub-message. const INSTANTIATE_PAIR_REPLY_ID: u64 = 1; @@ -53,8 +48,6 @@ pub fn instantiate( _info: MessageInfo, msg: InstantiateMsg, ) -> Result { - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - if msg.max_referral_commission > Decimal::one() { return Err(ContractError::InvalidReferralCommission( msg.max_referral_commission, @@ -540,7 +533,7 @@ pub fn execute_create_pair( circuit_breaker: None, })?, funds: vec![], - label: "Wyndex pair".to_string(), + label: "Palomadex pair".to_string(), } .into(), gas_limit: None, @@ -643,7 +636,7 @@ pub mod reply { SubMsg::new( wasm_execute( &pair_info.staking_addr, - &wyndex_stake::msg::ExecuteMsg::CreateDistributionFlow { + &palomadex_stake::msg::ExecuteMsg::CreateDistributionFlow { manager: env.contract.address.to_string(), asset: flow.asset, rewards: flow.rewards, @@ -720,10 +713,10 @@ pub fn deregister_pool_and_staking( /// ## Queries /// * **QueryMsg::Config {}** Returns general contract parameters using a custom [`ConfigResponse`] structure. /// -/// * **QueryMsg::Pair { asset_infos }** Returns a [`PairInfo`] object with information about a specific Wyndex pair. +/// * **QueryMsg::Pair { asset_infos }** Returns a [`PairInfo`] object with information about a specific Palomadex pair. /// /// * **QueryMsg::Pairs { start_after, limit }** Returns an array that contains items of type [`PairInfo`]. -/// This returns information about multiple Wyndex pairs +/// This returns information about multiple Palomadex pairs /// /// * **QueryMsg::FeeInfo { pair_type }** Returns the fee structure (total and protocol fees) for a specific pair type. /// @@ -826,43 +819,3 @@ pub fn query_fee_info(deps: Deps, pair_type: PairType) -> StdResult Result { - match msg { - MigrateMsg::Init(msg) => { - // Enforce previous contract name was crates.io:cw-placeholder - let ver = cw2::get_contract_version(deps.storage)?; - if ver.contract != PLACEHOLDER_CONTRACT_NAME { - return Err(ContractError::NotPlaceholder); - } - - // Gather contract info to pass admin - let contract_info = deps - .querier - .query_wasm_contract_info(env.contract.address.clone())?; - let contract_addr = deps - .api - .addr_validate(contract_info.admin.unwrap().as_str())?; - instantiate( - deps, - env, - MessageInfo { - sender: contract_addr, - funds: vec![], - }, - msg, - ) - .unwrap(); - } - MigrateMsg::Update() => { - ensure_from_older_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - } - MigrateMsg::AddPermissionlessPoolDeposit(asset) => { - PERMISSIONLESS_DEPOSIT.save(deps.storage, &asset)?; - } - }; - - Ok(Response::new()) -} diff --git a/contracts/factory/src/mock_querier.rs b/contracts/factory/src/mock_querier.rs index cddad13..6ed9ed3 100644 --- a/contracts/factory/src/mock_querier.rs +++ b/contracts/factory/src/mock_querier.rs @@ -3,12 +3,12 @@ use cosmwasm_std::{ from_binary, from_slice, to_binary, Coin, Empty, OwnedDeps, Querier, QuerierResult, QueryRequest, SystemError, SystemResult, WasmQuery, }; +use palomadex::pair::PairInfo; +use palomadex::pair::QueryMsg; use std::collections::HashMap; -use wyndex::pair::PairInfo; -use wyndex::pair::QueryMsg; /// mock_dependencies is a drop-in replacement for cosmwasm_std::testing::mock_dependencies. -/// This uses the Wyndex CustomQuerier. +/// This uses the Palomadex CustomQuerier. pub fn mock_dependencies( contract_balance: &[Coin], ) -> OwnedDeps { @@ -25,17 +25,17 @@ pub fn mock_dependencies( pub struct WasmMockQuerier { base: MockQuerier, - wyndex_pair_querier: WyndexPairQuerier, + palomadex_pair_querier: PalomadexPairQuerier, } #[derive(Clone, Default)] -pub struct WyndexPairQuerier { +pub struct PalomadexPairQuerier { pairs: HashMap, } -impl WyndexPairQuerier { +impl PalomadexPairQuerier { pub fn new(pairs: &[(&String, &PairInfo)]) -> Self { - WyndexPairQuerier { + PalomadexPairQuerier { pairs: pairs_to_map(pairs), } } @@ -72,7 +72,7 @@ impl WasmMockQuerier { => match from_binary(msg).unwrap() { QueryMsg::Pair {} => { let pair_info: PairInfo = - match self.wyndex_pair_querier.pairs.get(contract_addr) { + match self.palomadex_pair_querier.pairs.get(contract_addr) { Some(v) => v.clone(), None => { return SystemResult::Err(SystemError::NoSuchContract { @@ -94,12 +94,12 @@ impl WasmMockQuerier { pub fn new(base: MockQuerier) -> Self { WasmMockQuerier { base, - wyndex_pair_querier: WyndexPairQuerier::default(), + palomadex_pair_querier: PalomadexPairQuerier::default(), } } - // Configure the Wyndex pair - pub fn with_wyndex_pairs(&mut self, pairs: &[(&String, &PairInfo)]) { - self.wyndex_pair_querier = WyndexPairQuerier::new(pairs); + // Configure the Palomadex pair + pub fn with_palomadex_pairs(&mut self, pairs: &[(&String, &PairInfo)]) { + self.palomadex_pair_querier = PalomadexPairQuerier::new(pairs); } } diff --git a/contracts/factory/src/querier.rs b/contracts/factory/src/querier.rs index b3ce604..1918eec 100644 --- a/contracts/factory/src/querier.rs +++ b/contracts/factory/src/querier.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{QuerierWrapper, StdResult}; -use wyndex::pair::PairInfo; -use wyndex::pair::QueryMsg; +use palomadex::pair::PairInfo; +use palomadex::pair::QueryMsg; /// Returns information about a pair (using the [`PairInfo`] struct). /// diff --git a/contracts/factory/src/state.rs b/contracts/factory/src/state.rs index 58492a8..398db90 100644 --- a/contracts/factory/src/state.rs +++ b/contracts/factory/src/state.rs @@ -4,9 +4,9 @@ use cw_storage_plus::{Bound, Item, Map}; use itertools::Itertools; use crate::error::ContractError; -use wyndex::asset::{Asset, AssetInfo, AssetInfoValidated}; -use wyndex::common::OwnershipProposal; -use wyndex::factory::{DefaultStakeConfig, DistributionFlow, PairConfig}; +use palomadex::asset::{Asset, AssetInfo, AssetInfoValidated}; +use palomadex::common::OwnershipProposal; +use palomadex::factory::{DefaultStakeConfig, DistributionFlow, PairConfig}; /// This structure holds the main contract parameters. #[cw_serde] @@ -153,7 +153,7 @@ pub const PAIRS_TO_MIGRATE: Item> = Item::new("pairs_to_migrate"); #[cfg(test)] mod tests { use cosmwasm_std::testing::MockApi; - use wyndex::asset::{native_asset_info, token_asset_info}; + use palomadex::asset::{native_asset_info, token_asset_info}; use super::*; diff --git a/contracts/factory/src/testing.rs b/contracts/factory/src/testing.rs index 70d8019..1a8d774 100644 --- a/contracts/factory/src/testing.rs +++ b/contracts/factory/src/testing.rs @@ -2,7 +2,7 @@ use cosmwasm_std::{ attr, from_binary, to_binary, Addr, Decimal, ReplyOn, SubMsg, Uint128, WasmMsg, }; use cw_utils::MsgInstantiateContractResponse; -use wyndex::fee_config::FeeConfig; +use palomadex::fee_config::FeeConfig; use crate::mock_querier::mock_dependencies; use crate::state::CONFIG; @@ -10,16 +10,16 @@ use crate::{ contract::{execute, instantiate, query}, error::ContractError, }; -use wyndex::asset::AssetInfo; -use wyndex::factory::{ +use palomadex::asset::AssetInfo; +use palomadex::factory::{ ConfigResponse, DefaultStakeConfig, ExecuteMsg, InstantiateMsg, PairConfig, PairType, PairsResponse, PartialStakeConfig, QueryMsg, }; -use wyndex::pair::PairInfo; +use palomadex::pair::PairInfo; use crate::contract::reply; use cosmwasm_std::testing::{mock_env, mock_info, MOCK_CONTRACT_ADDR}; -use wyndex::pair::InstantiateMsg as PairInstantiateMsg; +use palomadex::pair::InstantiateMsg as PairInstantiateMsg; fn default_stake_config() -> DefaultStakeConfig { DefaultStakeConfig { @@ -540,7 +540,7 @@ fn create_pair() { code_id: pair_config.code_id, funds: vec![], admin: Some(config.unwrap().owner.to_string()), - label: String::from("Wyndex pair"), + label: String::from("Palomadex pair"), } .into(), id: 1, @@ -614,8 +614,8 @@ fn register() { let mut deployed_pairs = vec![(&pair0_addr, &pair0_info)]; - // Register an Wyndex pair querier - deps.querier.with_wyndex_pairs(&deployed_pairs); + // Register an Palomadex pair querier + deps.querier.with_palomadex_pairs(&deployed_pairs); let instantiate_res = MsgInstantiateContractResponse { contract_address: String::from("pair0000"), @@ -691,8 +691,8 @@ fn register() { deployed_pairs.push((&pair1_addr, &pair1_info)); - // Register wyndex pair querier - deps.querier.with_wyndex_pairs(&deployed_pairs); + // Register palomadex pair querier + deps.querier.with_palomadex_pairs(&deployed_pairs); let instantiate_res = MsgInstantiateContractResponse { contract_address: String::from("pair0001"), diff --git a/contracts/factory/tests/factory_helper.rs b/contracts/factory/tests/factory_helper.rs index d0c4482..c10b726 100644 --- a/contracts/factory/tests/factory_helper.rs +++ b/contracts/factory/tests/factory_helper.rs @@ -2,13 +2,13 @@ use anyhow::Result as AnyResult; use cosmwasm_std::{Addr, Binary, Decimal, Uint128}; use cw20::MinterResponse; use cw_multi_test::{App, AppResponse, ContractWrapper, Executor}; -use wyndex::asset::AssetInfo; -use wyndex::factory::{ +use palomadex::asset::AssetInfo; +use palomadex::factory::{ DefaultStakeConfig, PairConfig, PairType, PartialDefaultStakeConfig, PartialStakeConfig, QueryMsg, }; -use wyndex::fee_config::FeeConfig; -use wyndex::pair::PairInfo; +use palomadex::fee_config::FeeConfig; +use palomadex::pair::PairInfo; pub struct FactoryHelper { pub owner: Addr, @@ -57,11 +57,11 @@ impl FactoryHelper { let pair_contract = Box::new( ContractWrapper::new_with_empty( - wyndex_pair::contract::execute, - wyndex_pair::contract::instantiate, - wyndex_pair::contract::query, + palomadex_pair::contract::execute, + palomadex_pair::contract::instantiate, + palomadex_pair::contract::query, ) - .with_reply_empty(wyndex_pair::contract::reply), + .with_reply_empty(palomadex_pair::contract::reply), ); let pair_code_id = router.store_code(pair_contract); @@ -71,24 +71,24 @@ impl FactoryHelper { } else { let factory_contract = Box::new( ContractWrapper::new_with_empty( - wyndex_factory::contract::execute, - wyndex_factory::contract::instantiate, - wyndex_factory::contract::query, + palomadex_factory::contract::execute, + palomadex_factory::contract::instantiate, + palomadex_factory::contract::query, ) - .with_reply_empty(wyndex_factory::contract::reply), + .with_reply_empty(palomadex_factory::contract::reply), ); router.store_code(factory_contract) }; let staking_contract = Box::new(ContractWrapper::new_with_empty( - wyndex_stake::contract::execute, - wyndex_stake::contract::instantiate, - wyndex_stake::contract::query, + palomadex_stake::contract::execute, + palomadex_stake::contract::instantiate, + palomadex_stake::contract::query, )); let staking_code_id = router.store_code(staking_contract); - let msg = wyndex::factory::InstantiateMsg { + let msg = palomadex::factory::InstantiateMsg { pair_configs: vec![PairConfig { code_id: pair_code_id, pair_type: PairType::Xyk {}, @@ -141,7 +141,7 @@ impl FactoryHelper { only_owner_can_create_pairs: Option, default_stake_config: Option, ) -> AnyResult { - let msg = wyndex::factory::ExecuteMsg::UpdateConfig { + let msg = palomadex::factory::ExecuteMsg::UpdateConfig { token_code_id, fee_address, only_owner_can_create_pairs, @@ -165,7 +165,7 @@ impl FactoryHelper { AssetInfo::Token(tokens[1].to_owned()), ]; - let msg = wyndex::factory::ExecuteMsg::CreatePair { + let msg = palomadex::factory::ExecuteMsg::CreatePair { pair_type, asset_infos, init_params, @@ -183,7 +183,7 @@ impl FactoryHelper { sender: &Addr, asset_infos: Vec, ) -> AnyResult { - let msg = wyndex::factory::ExecuteMsg::Deregister { asset_infos }; + let msg = palomadex::factory::ExecuteMsg::Deregister { asset_infos }; router.execute_contract(sender.clone(), self.factory.clone(), &msg, &[]) } @@ -218,7 +218,7 @@ impl FactoryHelper { asset_infos: Vec, fee_config: FeeConfig, ) -> AnyResult { - let msg = wyndex::factory::ExecuteMsg::UpdatePairFees { + let msg = palomadex::factory::ExecuteMsg::UpdatePairFees { asset_infos, fee_config, }; diff --git a/contracts/factory/tests/integration.rs b/contracts/factory/tests/integration.rs index bbd8a97..4560ee6 100644 --- a/contracts/factory/tests/integration.rs +++ b/contracts/factory/tests/integration.rs @@ -1,19 +1,19 @@ mod factory_helper; use cosmwasm_std::{attr, from_slice, Addr, Decimal, StdError, Uint128}; -use wyndex::asset::AssetInfo; -use wyndex::factory::{ +use palomadex::asset::AssetInfo; +use palomadex::factory::{ ConfigResponse, DefaultStakeConfig, ExecuteMsg, FeeInfoResponse, InstantiateMsg, MigrateMsg, PairConfig, PairType, PartialDefaultStakeConfig, QueryMsg, }; -use wyndex::fee_config::FeeConfig; -use wyndex::pair::PairInfo; -use wyndex_factory::{error::ContractError, state::Config}; +use palomadex::fee_config::FeeConfig; +use palomadex::pair::PairInfo; +use palomadex_factory::{error::ContractError, state::Config}; use crate::factory_helper::{instantiate_token, FactoryHelper}; use cw_multi_test::{App, ContractWrapper, Executor}; use cw_placeholder::msg::InstantiateMsg as PlaceholderContractInstantiateMsg; -use wyndex::pair::ExecuteMsg as PairExecuteMsg; +use palomadex::pair::ExecuteMsg as PairExecuteMsg; fn mock_app() -> App { App::default() } @@ -31,12 +31,11 @@ fn store_placeholder_code(app: &mut App) -> u64 { fn store_factory_code(app: &mut App) -> u64 { let factory_contract = Box::new( ContractWrapper::new_with_empty( - wyndex_factory::contract::execute, - wyndex_factory::contract::instantiate, - wyndex_factory::contract::query, + palomadex_factory::contract::execute, + palomadex_factory::contract::instantiate, + palomadex_factory::contract::query, ) - .with_reply_empty(wyndex_factory::contract::reply) - .with_migrate_empty(wyndex_factory::contract::migrate), + .with_reply_empty(palomadex_factory::contract::reply), ); app.store_code(factory_contract) diff --git a/contracts/factory/tests/migration.rs b/contracts/factory/tests/migration.rs deleted file mode 100644 index 3c9bd40..0000000 --- a/contracts/factory/tests/migration.rs +++ /dev/null @@ -1,207 +0,0 @@ -mod factory_helper; - -use cosmwasm_std::{to_binary, Addr, Uint128}; -use wyndex::asset::{Asset, AssetInfo}; -use wyndex::factory::{MigrateMsg, PairType, PartialStakeConfig}; - -use wyndex_factory::error::ContractError; - -use crate::factory_helper::{instantiate_token, FactoryHelper}; -use cw_multi_test::{App, ContractWrapper, Executor}; - -use cw20::Cw20ExecuteMsg; - -fn mock_app() -> App { - App::default() -} - -fn store_factory_210_code(app: &mut App) -> u64 { - let factory_contract = Box::new( - ContractWrapper::new_with_empty( - wyndex_factory_2_1_0::contract::execute, - wyndex_factory_2_1_0::contract::instantiate, - wyndex_factory_2_1_0::contract::query, - ) - .with_reply_empty(wyndex_factory_2_1_0::contract::reply) - .with_migrate_empty(wyndex_factory_2_1_0::contract::migrate), - ); - - app.store_code(factory_contract) -} - -#[test] -fn migrate_factory_and_setup_deposit() { - let mut app = mock_app(); - - let owner = Addr::unchecked("owner"); - - // store old version of factory - let factory_code_id = store_factory_210_code(&mut app); - - let mut helper = FactoryHelper::instantiate(&mut app, &owner, Some(factory_code_id)); - - let wynd = instantiate_token(&mut app, helper.cw20_token_code_id, &owner, "WYND", None); - // mint some tokens for random "someone" user - app.execute_contract( - owner.clone(), - wynd.clone(), - &Cw20ExecuteMsg::Mint { - recipient: "someone".to_string(), - amount: Uint128::from(1_000_001u128), - }, - &[], - ) - .unwrap(); - - let token_instance0 = - instantiate_token(&mut app, helper.cw20_token_code_id, &owner, "tokenX", None); - let token_instance1 = - instantiate_token(&mut app, helper.cw20_token_code_id, &owner, "tokenY", None); - let token_instance2 = - instantiate_token(&mut app, helper.cw20_token_code_id, &owner, "tokenZ", None); - - // store new factory - let factory_contract = Box::new( - ContractWrapper::new_with_empty( - wyndex_factory::contract::execute, - wyndex_factory::contract::instantiate, - wyndex_factory::contract::query, - ) - .with_reply_empty(wyndex_factory::contract::reply) - .with_migrate_empty(wyndex_factory::contract::migrate), - ); - let new_factory_code_id = app.store_code(factory_contract); - - // only admin can migrate contract - helper - .create_pair_with_addr( - &mut app, - &Addr::unchecked("someone"), - PairType::Xyk {}, - [token_instance0.as_str(), token_instance1.as_str()], - None, - ) - .unwrap_err(); - - // update factory so that everyone can create pools - helper - .update_config(&mut app, &owner, None, None, Some(false), None) - .unwrap(); - - // now anyone can create pairs - helper - .create_pair_with_addr( - &mut app, - &Addr::unchecked("someone"), - PairType::Xyk {}, - [token_instance0.as_str(), token_instance1.as_str()], - None, - ) - .unwrap(); - - // Migrate the contract and set the deposit - app.migrate_contract( - owner.clone(), - helper.factory.clone(), - &MigrateMsg::AddPermissionlessPoolDeposit(Asset { - info: AssetInfo::Token(wynd.to_string()), - amount: Uint128::new(1_000_000), - }), - new_factory_code_id, - ) - .unwrap(); - - // new version enforces deposit to be send - let err = helper - .create_pair_with_addr( - &mut app, - &Addr::unchecked("someone"), - PairType::Xyk {}, - [token_instance1.as_str(), token_instance2.as_str()], - None, - ) - .unwrap_err(); - assert_eq!( - ContractError::PermissionlessRequiresDeposit {}, - err.downcast().unwrap() - ); - - // sent amount is too small - let err = app - .execute_contract( - Addr::unchecked("someone"), - wynd.clone(), - &Cw20ExecuteMsg::Send { - contract: helper.factory.to_string(), - amount: Uint128::new(1_000), - msg: to_binary(&wyndex::factory::ExecuteMsg::CreatePair { - pair_type: PairType::Xyk {}, - asset_infos: vec![ - AssetInfo::Token(token_instance1.to_string()), - AssetInfo::Token(token_instance2.to_string()), - ], - init_params: None, - staking_config: PartialStakeConfig::default(), - total_fee_bps: None, - }) - .unwrap(), - }, - &[], - ) - .unwrap_err(); - assert_eq!( - ContractError::DepositRequired(Uint128::new(1_000_000), wynd.to_string()), - err.downcast().unwrap() - ); - - // sent amount is too big - let err = app - .execute_contract( - Addr::unchecked("someone"), - wynd.clone(), - &Cw20ExecuteMsg::Send { - contract: helper.factory.to_string(), - amount: Uint128::new(1_000_001), - msg: to_binary(&wyndex::factory::ExecuteMsg::CreatePair { - pair_type: PairType::Xyk {}, - asset_infos: vec![ - AssetInfo::Token(token_instance1.to_string()), - AssetInfo::Token(token_instance2.to_string()), - ], - init_params: None, - staking_config: PartialStakeConfig::default(), - total_fee_bps: None, - }) - .unwrap(), - }, - &[], - ) - .unwrap_err(); - assert_eq!( - ContractError::DepositRequired(Uint128::new(1_000_000), wynd.to_string()), - err.downcast().unwrap() - ); - - // creating a new pool works - app.execute_contract( - Addr::unchecked("someone"), - wynd, - &Cw20ExecuteMsg::Send { - contract: helper.factory.to_string(), - amount: Uint128::new(1_000_000), - msg: to_binary(&wyndex::factory::ExecuteMsg::CreatePair { - pair_type: PairType::Xyk {}, - asset_infos: vec![ - AssetInfo::Token(token_instance1.to_string()), - AssetInfo::Token(token_instance2.to_string()), - ], - init_params: None, - staking_config: PartialStakeConfig::default(), - total_fee_bps: None, - }) - .unwrap(), - }, - &[], - ) - .unwrap(); -} diff --git a/contracts/gauge-adapter/Cargo.toml b/contracts/gauge-adapter/Cargo.toml index b8449fa..98931c6 100644 --- a/contracts/gauge-adapter/Cargo.toml +++ b/contracts/gauge-adapter/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gauge-adapter" -authors = ["Cosmorama , 0xFable <0xfable@protonmail.com>"] +authors = ["Volume Fi"] version = { workspace = true } edition = { workspace = true } license = { workspace = true } @@ -25,8 +25,8 @@ cw2 = { workspace = true } cw20 = { workspace = true } thiserror = { workspace = true } wynd-curve-utils = { workspace = true } -wyndex = { workspace = true } -wyndex-stake = { workspace = true, features = ["library"] } +palomadex = { workspace = true } +palomadex-stake = { workspace = true, features = ["library"] } cw-placeholder = { workspace = true, features = ["library"] } [dev-dependencies] @@ -34,6 +34,6 @@ anyhow = { workspace = true } cw-multi-test = { workspace = true } cw20 = { workspace = true } cw20-base = { workspace = true } -wyndex-factory = { workspace = true } -wyndex-pair = { workspace = true } -wyndex-pair-lsd = { workspace = true } +palomadex-factory = { workspace = true } +palomadex-pair = { workspace = true } +palomadex-pair-lsd = { workspace = true } diff --git a/contracts/gauge-adapter/src/contract.rs b/contracts/gauge-adapter/src/contract.rs index 733645f..90fd08f 100644 --- a/contracts/gauge-adapter/src/contract.rs +++ b/contracts/gauge-adapter/src/contract.rs @@ -4,22 +4,16 @@ use cosmwasm_std::{ coins, to_binary, Addr, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Response, StdResult, Uint128, WasmMsg, }; -use cw2::set_contract_version; use cw20::Cw20ExecuteMsg; -use cw_placeholder::contract::CONTRACT_NAME as PLACEHOLDER_CONTRACT_NAME; -use wyndex::asset::{AssetInfoValidated, AssetValidated}; -use wyndex::stake::{FundingInfo, ReceiveMsg as StakeReceiveDelegationMsg}; -use wyndex_stake::msg::ExecuteMsg as StakeExecuteMsg; +use palomadex::asset::{AssetInfoValidated, AssetValidated}; +use palomadex::stake::{FundingInfo, ReceiveMsg as StakeReceiveDelegationMsg}; +use palomadex_stake::msg::ExecuteMsg as StakeExecuteMsg; use crate::error::ContractError; use crate::msg::{AdapterQueryMsg, ExecuteMsg, InstantiateMsg, MigrateMsg}; use crate::state::{Config, CONFIG}; -// version info for migration info -const CONTRACT_NAME: &str = "crates.io:gauge-adapter"; -const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); - #[cfg_attr(not(feature = "library"), entry_point)] pub fn instantiate( deps: DepsMut, @@ -27,8 +21,6 @@ pub fn instantiate( _info: MessageInfo, msg: InstantiateMsg, ) -> Result { - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - if msg.epoch_length == 0u64 { return Err(ContractError::ZeroDistributionDuration {}); }; @@ -188,47 +180,13 @@ fn create_distribute_msgs( } } -/// Manages the contract migration. -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn migrate(deps: DepsMut, env: Env, msg: MigrateMsg) -> Result { - match msg { - MigrateMsg::Init(msg) => { - // Enforce previous contract name was crates.io:cw-placeholder - let ver = cw2::get_contract_version(deps.storage)?; - if ver.contract != PLACEHOLDER_CONTRACT_NAME { - return Err(ContractError::NotPlaceholder); - } - - // Gather contract info to pass admin - let contract_info = deps - .querier - .query_wasm_contract_info(env.contract.address.clone())?; - let sender = deps.api.addr_validate(&contract_info.admin.unwrap())?; - - instantiate( - deps, - env, - MessageInfo { - sender, - funds: vec![], - }, - msg, - ) - .unwrap(); - } - MigrateMsg::Update {} => {} - }; - - Ok(Response::new()) -} - #[cfg(test)] mod tests { use cosmwasm_std::{ testing::{mock_dependencies, mock_env, mock_info}, to_binary, Coin, CosmosMsg, Decimal, Uint128, WasmMsg, }; - use wyndex::stake::FundingInfo; + use palomadex::stake::FundingInfo; use super::{execute, instantiate, query}; use crate::{ @@ -236,7 +194,7 @@ mod tests { msg::{ExecuteMsg, InstantiateMsg}, state::CONFIG, }; - use wyndex::asset::{Asset, AssetInfo}; + use palomadex::asset::{Asset, AssetInfo}; const EPOCH_LENGTH: u64 = 86_400; @@ -247,8 +205,8 @@ mod tests { let mut msg = InstantiateMsg { factory: "factory".to_string(), owner: "owner".to_string(), - rewards_asset: wyndex::asset::Asset { - info: wyndex::asset::AssetInfo::Native("juno".to_string()), + rewards_asset: palomadex::asset::Asset { + info: palomadex::asset::AssetInfo::Native("juno".to_string()), amount: amount.into(), }, epoch_length: 0u64, @@ -276,7 +234,7 @@ mod tests { assert_eq!(config.factory, "factory"); assert_eq!( config.rewards_asset.info, - wyndex::asset::AssetInfoValidated::Native("juno".to_string()) + palomadex::asset::AssetInfoValidated::Native("juno".to_string()) ); assert_eq!(config.rewards_asset.amount.u128(), 1000); assert_eq!(config.distribution_duration, EPOCH_LENGTH); @@ -294,8 +252,8 @@ mod tests { InstantiateMsg { factory: "factory".to_string(), owner: "owner".to_string(), - rewards_asset: wyndex::asset::Asset { - info: wyndex::asset::AssetInfo::Native("juno".to_string()), + rewards_asset: palomadex::asset::Asset { + info: palomadex::asset::AssetInfo::Native("juno".to_string()), amount: amount.into(), }, epoch_length: EPOCH_LENGTH, @@ -314,7 +272,7 @@ mod tests { res.execute[0], CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: "juno1555".to_string(), - msg: to_binary(&wyndex_stake::msg::ExecuteMsg::FundDistribution { + msg: to_binary(&palomadex_stake::msg::ExecuteMsg::FundDistribution { funding_info: FundingInfo { start_time: mock_env().block.time.seconds(), distribution_duration: EPOCH_LENGTH, @@ -332,7 +290,7 @@ mod tests { res.execute[1], CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: "juno1444".to_string(), - msg: to_binary(&wyndex_stake::msg::ExecuteMsg::FundDistribution { + msg: to_binary(&palomadex_stake::msg::ExecuteMsg::FundDistribution { funding_info: FundingInfo { start_time: mock_env().block.time.seconds(), distribution_duration: EPOCH_LENGTH, @@ -350,7 +308,7 @@ mod tests { res.execute[2], CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: "juno1333".to_string(), - msg: to_binary(&wyndex_stake::msg::ExecuteMsg::FundDistribution { + msg: to_binary(&palomadex_stake::msg::ExecuteMsg::FundDistribution { funding_info: FundingInfo { start_time: mock_env().block.time.seconds(), distribution_duration: EPOCH_LENGTH, @@ -419,7 +377,7 @@ mod tests { let config = CONFIG.load(deps.as_ref().storage).unwrap(); assert_eq!( config.rewards_asset.info, - wyndex::asset::AssetInfoValidated::Native("juno".to_string()) + palomadex::asset::AssetInfoValidated::Native("juno".to_string()) ); assert_eq!(config.rewards_asset.amount.u128(), 2000); } diff --git a/contracts/gauge-adapter/src/msg.rs b/contracts/gauge-adapter/src/msg.rs index 56c93e1..78a2633 100644 --- a/contracts/gauge-adapter/src/msg.rs +++ b/contracts/gauge-adapter/src/msg.rs @@ -1,6 +1,6 @@ use cosmwasm_schema::{cw_serde, QueryResponses}; use cosmwasm_std::{CosmosMsg, Decimal, Uint128}; -use wyndex::asset::Asset; +use palomadex::asset::Asset; #[cw_serde] pub struct InstantiateMsg { diff --git a/contracts/gauge-adapter/src/multitest/options.rs b/contracts/gauge-adapter/src/multitest/options.rs index 9c86526..2a0cbed 100644 --- a/contracts/gauge-adapter/src/multitest/options.rs +++ b/contracts/gauge-adapter/src/multitest/options.rs @@ -1,5 +1,5 @@ use cosmwasm_std::Addr; -use wyndex::asset::AssetInfo; +use palomadex::asset::AssetInfo; use crate::multitest::suite::SuiteBuilder; diff --git a/contracts/gauge-adapter/src/multitest/sample.rs b/contracts/gauge-adapter/src/multitest/sample.rs index 8506576..dbeeca8 100644 --- a/contracts/gauge-adapter/src/multitest/sample.rs +++ b/contracts/gauge-adapter/src/multitest/sample.rs @@ -1,6 +1,6 @@ use crate::multitest::suite::Suite; use cosmwasm_std::{assert_approx_eq, coin, Addr, Decimal}; -use wyndex::{asset::AssetInfo, factory::DefaultStakeConfig}; +use palomadex::{asset::AssetInfo, factory::DefaultStakeConfig}; use super::suite::SuiteBuilder; @@ -22,14 +22,14 @@ fn native_rewards_work() { .build(); // create cw20 token - let wynd = suite.instantiate_token("owner", "WYND"); - let wynd_info = AssetInfo::Token(wynd.to_string()); + let paloma = suite.instantiate_token("owner", "PALOMA"); + let paloma_info = AssetInfo::Token(paloma.to_string()); let juno = AssetInfo::Native("juno".to_string()); let asdf = AssetInfo::Native("asdf".to_string()); // create pairs to reward let (pair1_staking, pair1_lpt) = suite - .create_pair_staking(juno.clone(), wynd_info.clone()) + .create_pair_staking(juno.clone(), paloma_info.clone()) .unwrap(); let (pair2_staking, pair2_lpt) = suite .create_pair_staking(juno.clone(), asdf.clone()) @@ -59,7 +59,7 @@ fn native_rewards_work() { suite .create_distribution_flow( "owner", - vec![juno.clone(), wynd_info], + vec![juno.clone(), paloma_info], juno.clone(), vec![(SECONDS_PER_DAY * 7, Decimal::one())], ) @@ -196,14 +196,14 @@ fn cw20_rewards_work(mut suite: Suite) { .unwrap(); // create cw20 token - let wynd = suite.instantiate_token("owner", "WYND"); - let wynd_info = AssetInfo::Token(wynd.to_string()); + let paloma = suite.instantiate_token("owner", "PALOMA"); + let paloma_info = AssetInfo::Token(paloma.to_string()); let juno = AssetInfo::Native("juno".to_string()); let asdf = AssetInfo::Native("asdf".to_string()); // create pairs to reward let (pair1_staking, pair1_lpt) = suite - .create_pair_staking(juno.clone(), wynd_info.clone()) + .create_pair_staking(juno.clone(), paloma_info.clone()) .unwrap(); let (pair2_staking, pair2_lpt) = suite .create_pair_staking(juno.clone(), asdf.clone()) @@ -233,7 +233,7 @@ fn cw20_rewards_work(mut suite: Suite) { suite .create_distribution_flow( "owner", - vec![juno.clone(), wynd_info], + vec![juno.clone(), paloma_info], AssetInfo::Token(reward_contract.to_string()), vec![(SECONDS_PER_DAY * 7, Decimal::one())], ) diff --git a/contracts/gauge-adapter/src/multitest/suite.rs b/contracts/gauge-adapter/src/multitest/suite.rs index 18c13bb..8cf8221 100644 --- a/contracts/gauge-adapter/src/multitest/suite.rs +++ b/contracts/gauge-adapter/src/multitest/suite.rs @@ -6,15 +6,15 @@ use cw20_base::msg::InstantiateMsg as Cw20BaseInstantiateMsg; use cw_multi_test::{App, AppResponse, BankSudo, ContractWrapper, Executor, SudoMsg}; use cw_placeholder::msg::InstantiateMsg as PlaceholderContractInstantiateMsg; -use wyndex::asset::{Asset, AssetInfo, AssetValidated}; -use wyndex::factory::{ +use palomadex::asset::{Asset, AssetInfo, AssetValidated}; +use palomadex::factory::{ DefaultStakeConfig, ExecuteMsg as FactoryExecuteMsg, InstantiateMsg as FactoryInstantiateMsg, PairConfig, PairType, PartialStakeConfig, QueryMsg as FactoryQueryMsg, }; -use wyndex::fee_config::FeeConfig; -use wyndex::pair::{ExecuteMsg as PairExecuteMsg, PairInfo, QueryMsg as PairQueryMsg}; -use wyndex::stake::{ReceiveMsg, UnbondingPeriod}; -use wyndex_stake::msg::{ +use palomadex::fee_config::FeeConfig; +use palomadex::pair::{ExecuteMsg as PairExecuteMsg, PairInfo, QueryMsg as PairQueryMsg}; +use palomadex::stake::{ReceiveMsg, UnbondingPeriod}; +use palomadex_stake::msg::{ ExecuteMsg as StakingExecuteMsg, QueryMsg as StakingQueryMsg, WithdrawableRewardsResponse, }; @@ -23,14 +23,11 @@ use crate::msg::{ }; fn store_gauge_adapter(app: &mut App) -> u64 { - let contract = Box::new( - ContractWrapper::new_with_empty( - crate::contract::execute, - crate::contract::instantiate, - crate::contract::query, - ) - .with_migrate_empty(crate::contract::migrate), - ); + let contract = Box::new(ContractWrapper::new_with_empty( + crate::contract::execute, + crate::contract::instantiate, + crate::contract::query, + )); app.store_code(contract) } @@ -38,11 +35,11 @@ fn store_gauge_adapter(app: &mut App) -> u64 { fn store_factory(app: &mut App) -> u64 { let contract = Box::new( ContractWrapper::new_with_empty( - wyndex_factory::contract::execute, - wyndex_factory::contract::instantiate, - wyndex_factory::contract::query, + palomadex_factory::contract::execute, + palomadex_factory::contract::instantiate, + palomadex_factory::contract::query, ) - .with_reply_empty(wyndex_factory::contract::reply), + .with_reply_empty(palomadex_factory::contract::reply), ); app.store_code(contract) @@ -51,11 +48,11 @@ fn store_factory(app: &mut App) -> u64 { fn store_pair(app: &mut App) -> u64 { let contract = Box::new( ContractWrapper::new_with_empty( - wyndex_pair::contract::execute, - wyndex_pair::contract::instantiate, - wyndex_pair::contract::query, + palomadex_pair::contract::execute, + palomadex_pair::contract::instantiate, + palomadex_pair::contract::query, ) - .with_reply_empty(wyndex_pair::contract::reply), + .with_reply_empty(palomadex_pair::contract::reply), ); app.store_code(contract) @@ -73,9 +70,9 @@ fn store_cw20(app: &mut App) -> u64 { fn store_staking(app: &mut App) -> u64 { let contract = Box::new(ContractWrapper::new( - wyndex_stake::contract::execute, - wyndex_stake::contract::instantiate, - wyndex_stake::contract::query, + palomadex_stake::contract::execute, + palomadex_stake::contract::instantiate, + palomadex_stake::contract::query, )); app.store_code(contract) @@ -200,7 +197,7 @@ impl SuiteBuilder { trading_starts: None, }, &[], - "Wyndex Factory", + "Palomadex Factory", None, ) .unwrap(); @@ -327,7 +324,7 @@ impl Suite { let pair = self .create_pair_and_provide_liquidity( - wyndex::factory::PairType::Xyk {}, + palomadex::factory::PairType::Xyk {}, (first_asset, 1_000_000), (second_asset, 1_000_000), funds, diff --git a/contracts/gauge-adapter/src/querier.rs b/contracts/gauge-adapter/src/querier.rs index 9630074..19e91ec 100644 --- a/contracts/gauge-adapter/src/querier.rs +++ b/contracts/gauge-adapter/src/querier.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{QuerierWrapper, StdResult}; -use wyndex::factory::PairsResponse; -use wyndex::factory::QueryMsg; +use palomadex::factory::PairsResponse; +use palomadex::factory::QueryMsg; /// Returns a list of all pairs pub fn query_pairs( diff --git a/contracts/gauge-adapter/src/state.rs b/contracts/gauge-adapter/src/state.rs index 20bfceb..bbe7e41 100644 --- a/contracts/gauge-adapter/src/state.rs +++ b/contracts/gauge-adapter/src/state.rs @@ -1,7 +1,7 @@ use cosmwasm_schema::cw_serde; use cosmwasm_std::Addr; use cw_storage_plus::Item; -use wyndex::asset::AssetValidated; +use palomadex::asset::AssetValidated; #[cw_serde] pub struct Config { diff --git a/contracts/junoswap-staking/Cargo.toml b/contracts/junoswap-staking/Cargo.toml index 7e44249..892c0d9 100644 --- a/contracts/junoswap-staking/Cargo.toml +++ b/contracts/junoswap-staking/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "junoswap-staking" -authors = ["Cosmorama "] +authors = ["Volume Fi"] version = { workspace = true } edition = { workspace = true } -description = "Contract aimed just for migration - take JunoSwap staked LP and migrate to WYND DEX" +description = "Contract aimed just for migration - take JunoSwap staked LP and migrate to PALOMA DEX" license = { workspace = true } repository = { workspace = true } -homepage = "https://www.wynddao.com" +homepage = "https://www.palomachain.com" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -28,9 +28,9 @@ cw20 = { workspace = true } cw-utils = { workspace = true } thiserror = { workspace = true } -wyndex = { workspace = true } -wyndex-factory = { workspace = true } -wyndex-stake = { workspace = true } +palomadex = { workspace = true } +palomadex-factory = { workspace = true } +palomadex-stake = { workspace = true } # this is old version of cw20 used by wasmswap wasmswap_cw20 = { package = "cw20", version = "0.10.0" } # this is the staking contract we are migrating from (use the state variables there) @@ -44,6 +44,6 @@ cw-multi-test = { workspace = true } serde = { workspace = true } wasmswap_cw20-base = { package = "cw20-base", version = "0.10.0" } wasmswap_cw-utils = { package = "cw-utils", version = "0.11" } -wyndex-factory = { workspace = true } -wyndex-pair = { workspace = true } +palomadex-factory = { workspace = true } +palomadex-pair = { workspace = true } cw20-base = { workspace = true } diff --git a/contracts/junoswap-staking/README.md b/contracts/junoswap-staking/README.md index 49742e2..4c3b105 100644 --- a/contracts/junoswap-staking/README.md +++ b/contracts/junoswap-staking/README.md @@ -6,6 +6,6 @@ as we want to perform the migration proposal concurrently with the pool deployme Once it is migrated, the staking contract will be locked, and the only action is that a nominated migrator account can trigger the transfer of the LP controlled by the staking pool -to a wynddex pool. We add some constraints to ensure this is transferred to a valid target contract +to a palomadex pool. We add some constraints to ensure this is transferred to a valid target contract to minimize any trust requirements on the migrator (they just have "censorship" power). diff --git a/contracts/junoswap-staking/src/contract.rs b/contracts/junoswap-staking/src/contract.rs index 5b91243..c88af48 100644 --- a/contracts/junoswap-staking/src/contract.rs +++ b/contracts/junoswap-staking/src/contract.rs @@ -7,8 +7,8 @@ use cosmwasm_std::{ use cw2::{get_contract_version, set_contract_version}; use cw_utils::ensure_from_older_version; +use palomadex::asset::{Asset, AssetInfo}; use wasmswap::msg::InfoResponse; -use wyndex::asset::{Asset, AssetInfo}; use crate::error::ContractError; use crate::msg::{ExecuteMsg, MigrateMsg, QueryMsg}; @@ -44,60 +44,6 @@ pub fn query(_deps: Deps, _env: Env, msg: QueryMsg) -> Result Result { - // if we got an init, then do from junoswap loop - if let Some(msg) = msg.init { - // ensure contract being migrated is actually junoswap staking - let old = get_contract_version(deps.storage)?; - if old.contract != STAKE_CW20_NAME { - return Err(ContractError::CannotMigrate(old.contract)); - } - // question: check version?? - - // update the cw2 contract version - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - - // check the unbonding period is valid - let factory = deps.api.addr_validate(&msg.factory)?; - let unbonding_period = msg.unbonding_period; - let wyndex_factory::state::Config { - default_stake_config, - .. - } = wyndex_factory::state::CONFIG.query(&deps.querier, factory.clone())?; - if !default_stake_config - .unbonding_periods - .iter() - .any(|x| x == &unbonding_period) - { - return Err(ContractError::InvalidUnbondingPeriod(unbonding_period)); - } - - // Validate arguments and set config for future calls - let wynddex_pool = msg - .wynddex_pool - .map(|p| deps.api.addr_validate(&p)) - .transpose()?; - let config = MigrateConfig { - migrator: deps.api.addr_validate(&msg.migrator)?, - junoswap_pool: deps.api.addr_validate(&msg.junoswap_pool)?, - factory, - unbonding_period, - wynddex_pool, - migrate_stakers_config: None, - }; - MIGRATION.save(deps.storage, &config)?; - } else { - // self-migrate - // this is only used as a bug-fix-patch on the older version of this code. - ensure_from_older_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - // update the cw2 contract version - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - } - - Ok(Response::new()) -} - #[cfg_attr(not(feature = "library"), entry_point)] pub fn execute( deps: DepsMut, @@ -106,19 +52,19 @@ pub fn execute( msg: ExecuteMsg, ) -> Result { match msg { - ExecuteMsg::MigrateTokens { wynddex_pool } => migrate_tokens(deps, env, info, wynddex_pool), + ExecuteMsg::MigrateTokens { palomadex_pool } => migrate_tokens(deps, env, info, palomadex_pool), ExecuteMsg::MigrateStakers { limit } => migrate_stakers(deps, env, info, limit), } } -/// Allow `migrator` to pull out LP positions and send them to wynd dex pool +/// Allow `migrator` to pull out LP positions and send them to paloma dex pool /// First step figures out how many LPs we have and withdraws them. /// Follow up via reply. pub fn migrate_tokens( deps: DepsMut, env: Env, info: MessageInfo, - wynddex_pool: String, + palomadex_pool: String, ) -> Result { // make sure called by proper account let mut migration = MIGRATION.load(deps.storage)?; @@ -127,15 +73,15 @@ pub fn migrate_tokens( } // ensure the requested target pool is valid - let w_pool = deps.api.addr_validate(&wynddex_pool)?; - if let Some(ref target) = migration.wynddex_pool { + let w_pool = deps.api.addr_validate(&palomadex_pool)?; + if let Some(ref target) = migration.palomadex_pool { if target != w_pool { - return Err(ContractError::InvalidDestination(wynddex_pool)); + return Err(ContractError::InvalidDestination(palomadex_pool)); } } let ci = deps.querier.query_wasm_contract_info(&w_pool)?; if ci.creator != migration.factory { - return Err(ContractError::InvalidDestination(wynddex_pool)); + return Err(ContractError::InvalidDestination(palomadex_pool)); } // save target pool for later reply block @@ -147,14 +93,14 @@ pub fn migrate_tokens( let token = cw20::Cw20Contract(stake_cfg.token_address); let balance = token.balance(&deps.querier, env.contract.address)?; - // fill in most of the migration data now (minus wynd dex LP) - let wyndex::pair::PairInfo { + // fill in most of the migration data now (minus paloma dex LP) + let palomadex::pair::PairInfo { liquidity_token, staking_addr, .. } = deps .querier - .query_wasm_smart(&w_pool, &wyndex::pair::QueryMsg::Pair {})?; + .query_wasm_smart(&w_pool, &palomadex::pair::QueryMsg::Pair {})?; // total_staked is same a balance of junoswap lp token held by this contract migration.migrate_stakers_config = Some(MigrateStakersConfig { @@ -231,7 +177,7 @@ pub fn migrate_stakers( let batch_lp: Uint128 = staker_lps.iter().map(|(_, x)| x).sum(); // bonding has full info on who receives the delegation - let bond_msg = wyndex::stake::ReceiveMsg::MassDelegate { + let bond_msg = palomadex::stake::ReceiveMsg::MassDelegate { unbonding_period: migration.unbonding_period, delegate_to: staker_lps, }; @@ -265,17 +211,17 @@ pub fn reply(deps: DepsMut, env: Env, msg: Reply) -> Result Result { let migration = MIGRATION.load(deps.storage)?; let destination = DESTINATION.load(deps.storage)?; - // get the JS asset types and convert to WYND DEX types + // get the JS asset types and convert to PALOMA DEX types let info: InfoResponse = deps .querier .query_wasm_smart(migration.junoswap_pool, &wasmswap::msg::QueryMsg::Info {})?; - let assets = to_wyndex_assets(deps.as_ref(), env.contract.address, info)?; + let assets = to_palomadex_assets(deps.as_ref(), env.contract.address, info)?; // figure out how to transfer these... previous cw20 allowances or // sending native funds inline with providing liquidity @@ -283,7 +229,7 @@ pub fn reply_one(deps: DepsMut, env: Env) -> Result { let deposit = WasmMsg::Execute { contract_addr: destination.into_string(), funds, - msg: to_binary(&wyndex::pair::ExecuteMsg::ProvideLiquidity { + msg: to_binary(&palomadex::pair::ExecuteMsg::ProvideLiquidity { assets, // TODO: set some value here? slippage_tolerance: None, @@ -340,13 +286,17 @@ fn prepare_denom_deposit( Ok(()) } -fn to_wyndex_assets(deps: Deps, me: Addr, info: InfoResponse) -> Result, ContractError> { - let asset1 = to_wyndex_asset(deps, &me, info.token1_denom)?; - let asset2 = to_wyndex_asset(deps, &me, info.token2_denom)?; +fn to_palomadex_assets( + deps: Deps, + me: Addr, + info: InfoResponse, +) -> Result, ContractError> { + let asset1 = to_palomadex_asset(deps, &me, info.token1_denom)?; + let asset2 = to_palomadex_asset(deps, &me, info.token2_denom)?; Ok(vec![asset1, asset2]) } -fn to_wyndex_asset( +fn to_palomadex_asset( deps: Deps, me: &Addr, token: wasmswap_cw20::Denom, @@ -371,7 +321,7 @@ fn to_wyndex_asset( Ok(asset) } -/// Finally, with those WYND DEX LP tokens, we will take them all on behalf +/// Finally, with those PALOMA DEX LP tokens, we will take them all on behalf /// of the original JunoSwap LP stakers. pub fn reply_two(deps: DepsMut, env: Env) -> Result { // load config for LP token and staking contract @@ -475,7 +425,7 @@ mod tests { let assets = vec![ Asset { - info: AssetInfo::Token("juno1wynd".to_owned()), + info: AssetInfo::Token("paloma1paloma".to_owned()), amount: Uint128::new(69_000_000_000u128), }, Asset { diff --git a/contracts/junoswap-staking/src/msg.rs b/contracts/junoswap-staking/src/msg.rs index d0ea9fe..0141c70 100644 --- a/contracts/junoswap-staking/src/msg.rs +++ b/contracts/junoswap-staking/src/msg.rs @@ -20,7 +20,7 @@ pub struct MigrateMsg { pub struct OrigMigrateMsg { /// This is the address that can run ExecuteMsg::MigrateTokens pub migrator: String, - /// This is how long it will be staked on WYND DEX + /// This is how long it will be staked on PALOMA DEX pub unbonding_period: u64, /// This is the junoswap pool where the LP will be withdrawn from @@ -29,7 +29,7 @@ pub struct OrigMigrateMsg { /// Can be deposited in any pool created by this factory pub factory: String, /// If set, only can be deposited in this pool (which must also be created by the factory) - pub wynddex_pool: Option, + pub palomadex_pool: Option, } #[cw_serde] @@ -38,7 +38,7 @@ pub enum ExecuteMsg { /// This moves the LP tokens to this contract, which are later given to the stakers in `MigrateStakers`. /// Must be called by migrator. /// Target pool must match constraints above - MigrateTokens { wynddex_pool: String }, + MigrateTokens { palomadex_pool: String }, /// Give the next `limit` stakers their LP tokens. /// Must be called by migrator. diff --git a/contracts/junoswap-staking/src/multitest/migration.rs b/contracts/junoswap-staking/src/multitest/migration.rs index a784ab7..106ca51 100644 --- a/contracts/junoswap-staking/src/multitest/migration.rs +++ b/contracts/junoswap-staking/src/multitest/migration.rs @@ -84,7 +84,7 @@ fn partial_migration() { // only 5 stakers should have tokens now let lp_tokens: Vec<_> = users .iter() - .map(|u| suite.wyndex_staked(u, suite.migration_unbonding_period())) + .map(|u| suite.palomadex_staked(u, suite.migration_unbonding_period())) .filter(|lp| *lp > 0) .collect(); assert_eq!(lp_tokens.len(), 5); @@ -97,7 +97,7 @@ fn partial_migration() { // next 5 stakers should also have tokens now let lp_tokens: Vec<_> = users .iter() - .map(|u| suite.wyndex_staked(u, suite.migration_unbonding_period())) + .map(|u| suite.palomadex_staked(u, suite.migration_unbonding_period())) .filter(|lp| *lp > 0) .collect(); assert_eq!(lp_tokens.len(), 10); @@ -121,23 +121,23 @@ fn migration_sanity_check() { suite.stake_junoswap_lp(user, to_stake, None, None).unwrap(); // make sure no lp before the deposit - let wyndex_total = suite.total_wyndex_lp(); - assert_eq!(wyndex_total, 0u128); + let palomadex_total = suite.total_palomadex_lp(); + assert_eq!(palomadex_total, 0u128); // cross our fingers this works ;) - suite.migrate_to_wyndex(None, None, None).unwrap(); + suite.migrate_to_palomadex(None, None, None).unwrap(); - // 80% of liquidity moved to wyndex pool - let wyndex = suite + // 80% of liquidity moved to palomadex pool + let palomadex = suite .app .wrap() - .query_all_balances(&suite.wyndex_pair_contract) + .query_all_balances(&suite.palomadex_pair_contract) .unwrap(); let expected = liquidity .iter() .map(|Coin { amount, denom }| coin(amount.u128() * 4 / 5, denom)) .collect::>(); - assert_eq!(wyndex, expected); + assert_eq!(palomadex, expected); // 20% of liquidity still in junoswap let junoswap = suite @@ -154,16 +154,19 @@ fn migration_sanity_check() { // ensure all lp belong to the staking contract // except for the MINIMUM_LIQUIDITY_DEPOSIT - held by pool // https://github.com/cosmorama/wyndex-priv/blob/d39f7369d22d458a85c6828d151bc3844a1604bf/contracts/pair/src/contract.rs#L381-L395 - let wyndex_total = suite.total_wyndex_lp(); - let wyndex_staked = suite.total_wyndex_staked(); - let pool = suite.wyndex_pair_contract.to_string(); - let pool_own_lp = suite.wyndex_lp(&pool); - assert_eq!(wyndex_total, wyndex_staked + pool_own_lp); - assert_eq!(pool_own_lp, wyndex::asset::MINIMUM_LIQUIDITY_AMOUNT.u128()); + let palomadex_total = suite.total_palomadex_lp(); + let palomadex_staked = suite.total_palomadex_staked(); + let pool = suite.palomadex_pair_contract.to_string(); + let pool_own_lp = suite.palomadex_lp(&pool); + assert_eq!(palomadex_total, palomadex_staked + pool_own_lp); + assert_eq!( + pool_own_lp, + palomadex::asset::MINIMUM_LIQUIDITY_AMOUNT.u128() + ); // ensure all staked tokens belong to the migrated user - let user_staked = suite.wyndex_staked(user, suite.migration_unbonding_period()); - assert_eq!(user_staked, wyndex_staked); + let user_staked = suite.palomadex_staked(user, suite.migration_unbonding_period()); + assert_eq!(user_staked, palomadex_staked); } #[test] @@ -181,7 +184,7 @@ fn non_migrator_cant_migrate() { // this won't work, not the migrator let err = suite - .migrate_to_wyndex(Some(Addr::unchecked("notthemigrator")), None, None) + .migrate_to_palomadex(Some(Addr::unchecked("notthemigrator")), None, None) .unwrap_err(); assert_eq!(ContractError::Unauthorized {}, err.downcast().unwrap()) } @@ -200,9 +203,9 @@ fn migrator_cant_migrate_to_own_addr() { // this won't work, we can only migrate to a deployed pool contract. let err = suite - .migrate_to_wyndex( + .migrate_to_palomadex( Some(Addr::unchecked("owner")), - Some(suite.wyndex_pair_contract.clone()), + Some(suite.palomadex_pair_contract.clone()), Some(Addr::unchecked("owner")), ) .unwrap_err(); @@ -317,33 +320,33 @@ fn migration_multiple_users() { .unwrap(); // perform the migration of liquidity - suite.migrate_to_wyndex(None, None, None).unwrap(); + suite.migrate_to_palomadex(None, None, None).unwrap(); - // 80% of liquidity moved to wyndex pool - let wyndex = suite + // 80% of liquidity moved to palomadex pool + let palomadex = suite .app .wrap() - .query_all_balances(&suite.wyndex_pair_contract) + .query_all_balances(&suite.palomadex_pair_contract) .unwrap(); let expected = liquidity .iter() .map(|Coin { amount, denom }| coin(amount.u128() * 4 / 5, denom)) .collect::>(); - assert_eq!(wyndex, expected); + assert_eq!(palomadex, expected); // ensure all lp belong to the staking contract - let wyndex_total = suite.total_wyndex_lp(); - let wyndex_staked = suite.total_wyndex_staked(); - assert_approx_eq!(wyndex_total, wyndex_staked, "0.01"); + let palomadex_total = suite.total_palomadex_lp(); + let palomadex_staked = suite.total_palomadex_staked(); + assert_approx_eq!(palomadex_total, palomadex_staked, "0.01"); // ensure all staked tokens belong to the migrated user - let user_staked = suite.wyndex_staked(users[0], suite.migration_unbonding_period()); - assert_eq!(user_staked, wyndex_staked / 10 * 3); + let user_staked = suite.palomadex_staked(users[0], suite.migration_unbonding_period()); + assert_eq!(user_staked, palomadex_staked / 10 * 3); // user 2 staked 500k so they should have about 10% of the staked tokens - let user_staked = suite.wyndex_staked(users[1], suite.migration_unbonding_period()); - assert_eq!(user_staked, wyndex_staked / 10,); + let user_staked = suite.palomadex_staked(users[1], suite.migration_unbonding_period()); + assert_eq!(user_staked, palomadex_staked / 10,); // user 3 did 3m and should have 60% - let user_staked = suite.wyndex_staked(users[2], suite.migration_unbonding_period()); - assert_eq!(user_staked, wyndex_staked / 10 * 6); + let user_staked = suite.palomadex_staked(users[2], suite.migration_unbonding_period()); + assert_eq!(user_staked, palomadex_staked / 10 * 6); } #[test] @@ -414,7 +417,7 @@ fn migrate_with_mixed_pairs() { .unwrap(); assert_eq!(junoswap.u128(), liquidity_cw20); - suite.wyndex_lp_holders(); + suite.palomadex_lp_holders(); // stake some of these tokens - 80% of liquidity should be moved // users[0] will keep everything staked @@ -463,40 +466,40 @@ fn migrate_with_mixed_pairs() { .unwrap(); // perform the migration of liquidity - suite.migrate_to_wyndex(None, None, None).unwrap(); + suite.migrate_to_palomadex(None, None, None).unwrap(); - // 80% of native liquidity moved to wyndex pool - let wyndex = suite + // 80% of native liquidity moved to palomadex pool + let palomadex = suite .app .wrap() - .query_all_balances(&suite.wyndex_pair_contract) + .query_all_balances(&suite.palomadex_pair_contract) .unwrap(); let expected = liquidity .iter() .map(|Coin { amount, denom }| coin(amount.u128() * 4 / 5, denom)) .collect::>(); - assert_eq!(wyndex, expected); + assert_eq!(palomadex, expected); - // 80% of cw20 liquidity moved to wyndex pool - let wyndex = cw20::Cw20Contract(raw_address.clone()) - .balance(&suite.app.wrap(), suite.wyndex_pair_contract.clone()) + // 80% of cw20 liquidity moved to palomadex pool + let palomadex = cw20::Cw20Contract(raw_address.clone()) + .balance(&suite.app.wrap(), suite.palomadex_pair_contract.clone()) .unwrap(); let expected = liquidity_cw20 * 4 / 5; - assert_eq!(wyndex.u128(), expected); + assert_eq!(palomadex.u128(), expected); // ensure all lp belong to the staking contract - let wyndex_total = suite.total_wyndex_lp(); - let wyndex_staked = suite.total_wyndex_staked(); - assert_approx_eq!(wyndex_total, wyndex_staked, "0.001"); + let palomadex_total = suite.total_palomadex_lp(); + let palomadex_staked = suite.total_palomadex_staked(); + assert_approx_eq!(palomadex_total, palomadex_staked, "0.001"); // ensure all staked tokens belong to the migrated user - let user_staked = suite.wyndex_staked(users[0], suite.migration_unbonding_period()); - assert_eq!(user_staked, wyndex_staked / 3); + let user_staked = suite.palomadex_staked(users[0], suite.migration_unbonding_period()); + assert_eq!(user_staked, palomadex_staked / 3); // user 2 staked 500k so they should have about 10% of the staked tokens - let user_staked = suite.wyndex_staked(users[1], suite.migration_unbonding_period()); - assert_eq!(user_staked, wyndex_staked / 3); + let user_staked = suite.palomadex_staked(users[1], suite.migration_unbonding_period()); + assert_eq!(user_staked, palomadex_staked / 3); // user 3 did 3m and should have 60% - let user_staked = suite.wyndex_staked(users[2], suite.migration_unbonding_period()); - assert_eq!(user_staked, wyndex_staked / 3); + let user_staked = suite.palomadex_staked(users[2], suite.migration_unbonding_period()); + assert_eq!(user_staked, palomadex_staked / 3); } #[test] @@ -525,23 +528,23 @@ fn migrate_with_unbonding_claims() { ); // make sure no lp before the deposit - let wyndex_total = suite.total_wyndex_lp(); - assert_eq!(wyndex_total, 0u128); + let palomadex_total = suite.total_palomadex_lp(); + assert_eq!(palomadex_total, 0u128); - // Migrate the liquidity to Wyndex, the liquidity includes 1 pair with 1 user who is currently unstaking - suite.migrate_to_wyndex(None, None, None).unwrap(); + // Migrate the liquidity to Palomadex, the liquidity includes 1 pair with 1 user who is currently unstaking + suite.migrate_to_palomadex(None, None, None).unwrap(); - // 80% of liquidity moved to wyndex pool - let wyndex = suite + // 80% of liquidity moved to palomadex pool + let palomadex = suite .app .wrap() - .query_all_balances(&suite.wyndex_pair_contract) + .query_all_balances(&suite.palomadex_pair_contract) .unwrap(); let expected = liquidity .iter() .map(|Coin { amount, denom }| coin(amount.u128() * 4 / 5, denom)) .collect::>(); - assert_eq!(wyndex, expected); + assert_eq!(palomadex, expected); // 20% of liquidity still in junoswap let junoswap = suite @@ -558,16 +561,19 @@ fn migrate_with_unbonding_claims() { // ensure all lp belong to the staking contract // except for the MINIMUM_LIQUIDITY_DEPOSIT - held by pool // https://github.com/cosmorama/wyndex-priv/blob/d39f7369d22d458a85c6828d151bc3844a1604bf/contracts/pair/src/contract.rs#L381-L395 - let wyndex_total = suite.total_wyndex_lp(); - let wyndex_staked = suite.total_wyndex_staked(); - let pool = suite.wyndex_pair_contract.to_string(); - let pool_own_lp = suite.wyndex_lp(&pool); - assert_eq!(wyndex_total, wyndex_staked + pool_own_lp); - assert_eq!(pool_own_lp, wyndex::asset::MINIMUM_LIQUIDITY_AMOUNT.u128()); + let palomadex_total = suite.total_palomadex_lp(); + let palomadex_staked = suite.total_palomadex_staked(); + let pool = suite.palomadex_pair_contract.to_string(); + let pool_own_lp = suite.palomadex_lp(&pool); + assert_eq!(palomadex_total, palomadex_staked + pool_own_lp); + assert_eq!( + pool_own_lp, + palomadex::asset::MINIMUM_LIQUIDITY_AMOUNT.u128() + ); // ensure all staked tokens belong to the migrated user - let user_staked = suite.wyndex_staked(user, suite.migration_unbonding_period()); - assert_eq!(user_staked, wyndex_staked); + let user_staked = suite.palomadex_staked(user, suite.migration_unbonding_period()); + assert_eq!(user_staked, palomadex_staked); } #[test] @@ -617,33 +623,36 @@ fn migration_two_cw20() { .unwrap(); // make sure no lp before the deposit - let wyndex_total = suite.total_wyndex_lp(); - assert_eq!(wyndex_total, 0u128); + let palomadex_total = suite.total_palomadex_lp(); + assert_eq!(palomadex_total, 0u128); // cross our fingers this works ;) - suite.migrate_to_wyndex(None, None, None).unwrap(); + suite.migrate_to_palomadex(None, None, None).unwrap(); - // 80% of liquidity moved to wyndex pool - let wyndex = cw20::Cw20Contract(raw_address.clone()) - .balance(&suite.app.wrap(), suite.wyndex_pair_contract.clone()) + // 80% of liquidity moved to palomadex pool + let palomadex = cw20::Cw20Contract(raw_address.clone()) + .balance(&suite.app.wrap(), suite.palomadex_pair_contract.clone()) .unwrap(); let expected = liquidity * 4 / 5; - assert_eq!(wyndex.u128(), expected); - let wyndex = cw20::Cw20Contract(cw20_address.clone()) - .balance(&suite.app.wrap(), suite.wyndex_pair_contract.clone()) + assert_eq!(palomadex.u128(), expected); + let palomadex = cw20::Cw20Contract(cw20_address.clone()) + .balance(&suite.app.wrap(), suite.palomadex_pair_contract.clone()) .unwrap(); let expected = liquidity * 4 / 5; - assert_eq!(wyndex.u128(), expected); + assert_eq!(palomadex.u128(), expected); // ensure all lp belong to the staking contract - let wyndex_total = suite.total_wyndex_lp(); - let wyndex_staked = suite.total_wyndex_staked(); - let pool = suite.wyndex_pair_contract.to_string(); - let pool_own_lp = suite.wyndex_lp(&pool); - assert_eq!(wyndex_total, wyndex_staked + pool_own_lp); - assert_eq!(pool_own_lp, wyndex::asset::MINIMUM_LIQUIDITY_AMOUNT.u128()); + let palomadex_total = suite.total_palomadex_lp(); + let palomadex_staked = suite.total_palomadex_staked(); + let pool = suite.palomadex_pair_contract.to_string(); + let pool_own_lp = suite.palomadex_lp(&pool); + assert_eq!(palomadex_total, palomadex_staked + pool_own_lp); + assert_eq!( + pool_own_lp, + palomadex::asset::MINIMUM_LIQUIDITY_AMOUNT.u128() + ); // ensure all staked tokens belong to the migrated user - let user_staked = suite.wyndex_staked(user, suite.migration_unbonding_period()); - assert_eq!(user_staked, wyndex_staked); + let user_staked = suite.palomadex_staked(user, suite.migration_unbonding_period()); + assert_eq!(user_staked, palomadex_staked); } diff --git a/contracts/junoswap-staking/src/multitest/suite.rs b/contracts/junoswap-staking/src/multitest/suite.rs index c8ee1c5..6438cbb 100644 --- a/contracts/junoswap-staking/src/multitest/suite.rs +++ b/contracts/junoswap-staking/src/multitest/suite.rs @@ -1,13 +1,13 @@ use anyhow::Result as AnyResult; use cw20::MinterResponse; -use wyndex::asset::AssetInfo; -use wyndex::factory::{ +use palomadex::asset::AssetInfo; +use palomadex::factory::{ DefaultStakeConfig, ExecuteMsg as FactoryExecuteMsg, InstantiateMsg as FactoryInstantiateMsg, PairConfig, PairType, PartialStakeConfig, QueryMsg as FactoryQueryMsg, }; -use wyndex::fee_config::FeeConfig; -use wyndex::pair::PairInfo; +use palomadex::fee_config::FeeConfig; +use palomadex::pair::PairInfo; use crate::msg::{MigrateMsg, OrigMigrateMsg, QueryMsg}; use cosmwasm_std::{coin, to_binary, Addr, Coin, Decimal, Uint128}; @@ -53,36 +53,36 @@ pub fn store_cw20(app: &mut App) -> u64 { app.store_code(contract) } -pub fn store_wyndex_staking(app: &mut App) -> u64 { +pub fn store_palomadex_staking(app: &mut App) -> u64 { let contract = Box::new(ContractWrapper::new( - wyndex_stake::contract::execute, - wyndex_stake::contract::instantiate, - wyndex_stake::contract::query, + palomadex_stake::contract::execute, + palomadex_stake::contract::instantiate, + palomadex_stake::contract::query, )); app.store_code(contract) } -fn store_wyndex_factory(app: &mut App) -> u64 { +fn store_palomadex_factory(app: &mut App) -> u64 { let factory_contract = Box::new( ContractWrapper::new_with_empty( - wyndex_factory::contract::execute, - wyndex_factory::contract::instantiate, - wyndex_factory::contract::query, + palomadex_factory::contract::execute, + palomadex_factory::contract::instantiate, + palomadex_factory::contract::query, ) - .with_reply_empty(wyndex_factory::contract::reply), + .with_reply_empty(palomadex_factory::contract::reply), ); app.store_code(factory_contract) } -fn store_wyndex_pair(app: &mut App) -> u64 { +fn store_palomadex_pair(app: &mut App) -> u64 { let factory_contract = Box::new( ContractWrapper::new_with_empty( - wyndex_pair::contract::execute, - wyndex_pair::contract::instantiate, - wyndex_pair::contract::query, + palomadex_pair::contract::execute, + palomadex_pair::contract::instantiate, + palomadex_pair::contract::query, ) - .with_reply_empty(wyndex_pair::contract::reply), + .with_reply_empty(palomadex_pair::contract::reply), ); app.store_code(factory_contract) @@ -95,7 +95,6 @@ pub fn store_migrator(app: &mut App) -> u64 { crate::contract::instantiate, crate::contract::query, ) - .with_migrate(crate::contract::migrate) .with_reply(crate::contract::reply), ); app.store_code(contract) @@ -238,18 +237,18 @@ impl SuiteBuilder { .unwrap(); app.update_block(next_block); - // Instantiate wyndex factory - let wyndex_stake_code_id = store_wyndex_staking(&mut app); - let wyndex_pair_code_id = store_wyndex_pair(&mut app); - let wyndex_factory_code_id = store_wyndex_factory(&mut app); + // Instantiate palomadex factory + let palomadex_stake_code_id = store_palomadex_staking(&mut app); + let palomadex_pair_code_id = store_palomadex_pair(&mut app); + let palomadex_factory_code_id = store_palomadex_factory(&mut app); let factory_contract = app .instantiate_contract( - wyndex_factory_code_id, + palomadex_factory_code_id, owner.clone(), &FactoryInstantiateMsg { pair_configs: vec![PairConfig { pair_type: PairType::Xyk {}, - code_id: wyndex_pair_code_id, + code_id: palomadex_pair_code_id, fee_config: FeeConfig { total_fee_bps: 0, protocol_fee_bps: 0, @@ -261,7 +260,7 @@ impl SuiteBuilder { owner: owner.to_string(), max_referral_commission: Decimal::one(), default_stake_config: DefaultStakeConfig { - staking_code_id: wyndex_stake_code_id, + staking_code_id: palomadex_stake_code_id, tokens_per_power: Uint128::new(1000), min_bond: Uint128::new(1000), unbonding_periods: self.unbonding_periods.clone(), @@ -271,7 +270,7 @@ impl SuiteBuilder { trading_starts: None, }, &[], - "wyndex-factory", + "palomadex-factory", Some(owner.to_string()), ) .unwrap(); @@ -289,7 +288,7 @@ impl SuiteBuilder { }, ]; - // Instantiate wyndex pair contract through factory + // Instantiate palomadex pair contract through factory app.execute_contract( owner.clone(), factory_contract.clone(), @@ -319,9 +318,9 @@ impl SuiteBuilder { ) .unwrap(); - let wyndex_pair_contract = pair_info.contract_addr; - let wyndex_staking_contract = pair_info.staking_addr; - let wyndex_token_contract = pair_info.liquidity_token; + let palomadex_pair_contract = pair_info.contract_addr; + let palomadex_staking_contract = pair_info.staking_addr; + let palomadex_token_contract = pair_info.liquidity_token; // add funds to the contract let funds = self.funds; @@ -342,9 +341,9 @@ impl SuiteBuilder { junoswap_pool_contract, junoswap_staking_contract, factory_contract, - wyndex_pair_contract, - wyndex_staking_contract, - wyndex_token_contract, + palomadex_pair_contract, + palomadex_staking_contract, + palomadex_token_contract, migrator_code_id, cw20_code_id, pool_denom1, @@ -364,9 +363,9 @@ pub struct Suite { pub junoswap_token_contract: Addr, pub junoswap_pool_contract: Addr, pub junoswap_staking_contract: Addr, - pub wyndex_token_contract: Addr, - pub wyndex_staking_contract: Addr, - pub wyndex_pair_contract: Addr, + pub palomadex_token_contract: Addr, + pub palomadex_staking_contract: Addr, + pub palomadex_pair_contract: Addr, pub pool_denom1: Denom, pub pool_denom2: Denom, @@ -380,9 +379,9 @@ struct SuiteInfo<'a> { pub junoswap_pool_contract: &'a Addr, pub junoswap_staking_contract: &'a Addr, pub factory_contract: &'a Addr, - pub wyndex_token_contract: &'a Addr, - pub wyndex_staking_contract: &'a Addr, - pub wyndex_pair_contract: &'a Addr, + pub palomadex_token_contract: &'a Addr, + pub palomadex_staking_contract: &'a Addr, + pub palomadex_pair_contract: &'a Addr, } impl Suite { @@ -394,9 +393,9 @@ impl Suite { junoswap_pool_contract: &self.junoswap_pool_contract, junoswap_staking_contract: &self.junoswap_staking_contract, factory_contract: &self.factory_contract, - wyndex_token_contract: &self.wyndex_token_contract, - wyndex_staking_contract: &self.wyndex_staking_contract, - wyndex_pair_contract: &self.wyndex_pair_contract, + palomadex_token_contract: &self.palomadex_token_contract, + palomadex_staking_contract: &self.palomadex_staking_contract, + palomadex_pair_contract: &self.palomadex_pair_contract, }; println!("{:?}", info); } @@ -422,8 +421,8 @@ impl Suite { pub fn migrate_tokens_with_self_upgrade( &mut self, migrator: Option, - wyndex_pair_migrate: Option, - wyndex_pair: Option, + palomadex_pair_migrate: Option, + palomadex_pair: Option, ) -> AnyResult { // first set up the migration self.app.migrate_contract( @@ -435,7 +434,7 @@ impl Suite { unbonding_period: self.migration_unbonding_period(), junoswap_pool: self.junoswap_pool_contract.to_string(), factory: self.factory_contract.to_string(), - wynddex_pool: wyndex_pair_migrate.map(|p| p.to_string()), + palomadex_pool: palomadex_pair_migrate.map(|p| p.to_string()), }), }, self.migrator_code_id, @@ -454,8 +453,8 @@ impl Suite { self.owner.clone(), self.junoswap_staking_contract.clone(), &crate::msg::ExecuteMsg::MigrateTokens { - wynddex_pool: wyndex_pair - .unwrap_or_else(|| self.wyndex_pair_contract.clone()) + palomadex_pool: palomadex_pair + .unwrap_or_else(|| self.palomadex_pair_contract.clone()) .to_string(), }, &[], @@ -466,8 +465,8 @@ impl Suite { pub fn migrate_tokens( &mut self, migrator: Option, - wyndex_pair_migrate: Option, - wyndex_pair: Option, + palomadex_pair_migrate: Option, + palomadex_pair: Option, ) -> AnyResult { // first set up the migration self.app.migrate_contract( @@ -479,7 +478,7 @@ impl Suite { unbonding_period: self.migration_unbonding_period(), junoswap_pool: self.junoswap_pool_contract.to_string(), factory: self.factory_contract.to_string(), - wynddex_pool: wyndex_pair_migrate.map(|p| p.to_string()), + palomadex_pool: palomadex_pair_migrate.map(|p| p.to_string()), }), }, self.migrator_code_id, @@ -490,8 +489,8 @@ impl Suite { self.owner.clone(), self.junoswap_staking_contract.clone(), &crate::msg::ExecuteMsg::MigrateTokens { - wynddex_pool: wyndex_pair - .unwrap_or_else(|| self.wyndex_pair_contract.clone()) + palomadex_pool: palomadex_pair + .unwrap_or_else(|| self.palomadex_pair_contract.clone()) .to_string(), }, &[], @@ -509,13 +508,13 @@ impl Suite { ) } - pub fn migrate_to_wyndex( + pub fn migrate_to_palomadex( &mut self, migrator: Option, - wyndex_pair_migrate: Option, - wyndex_pair: Option, + palomadex_pair_migrate: Option, + palomadex_pair: Option, ) -> AnyResult<()> { - self.migrate_tokens(migrator, wyndex_pair_migrate, wyndex_pair)?; + self.migrate_tokens(migrator, palomadex_pair_migrate, palomadex_pair)?; // now migrate all the stakers while !self.migration_finished()? { @@ -683,12 +682,12 @@ impl Suite { resp } - pub fn total_wyndex_lp(&mut self) -> u128 { + pub fn total_palomadex_lp(&mut self) -> u128 { let cw20::TokenInfoResponse { total_supply, .. } = self .app .wrap() .query_wasm_smart( - &self.wyndex_token_contract, + &self.palomadex_token_contract, &cw20::Cw20QueryMsg::TokenInfo {}, ) .unwrap(); @@ -696,12 +695,12 @@ impl Suite { total_supply.u128() } - pub fn wyndex_lp(&mut self, user: &str) -> u128 { + pub fn palomadex_lp(&mut self, user: &str) -> u128 { let cw20::BalanceResponse { balance } = self .app .wrap() .query_wasm_smart( - &self.wyndex_token_contract, + &self.palomadex_token_contract, &cw20::Cw20QueryMsg::Balance { address: user.to_string(), }, @@ -713,12 +712,12 @@ impl Suite { // for debugging tests #[allow(dead_code)] - pub fn wyndex_lp_holders(&mut self) -> Vec<(String, u128)> { + pub fn palomadex_lp_holders(&mut self) -> Vec<(String, u128)> { let cw20::AllAccountsResponse { accounts } = self .app .wrap() .query_wasm_smart( - &self.wyndex_token_contract, + &self.palomadex_token_contract, &cw20::Cw20QueryMsg::AllAccounts { start_after: None, limit: None, @@ -727,22 +726,22 @@ impl Suite { .unwrap(); accounts .into_iter() - .map(|addr| (addr.clone(), self.wyndex_lp(&addr))) + .map(|addr| (addr.clone(), self.palomadex_lp(&addr))) .collect() } - pub fn total_wyndex_staked(&mut self) -> u128 { - let addr = self.wyndex_staking_contract.clone(); - self.wyndex_lp(addr.as_str()) + pub fn total_palomadex_staked(&mut self) -> u128 { + let addr = self.palomadex_staking_contract.clone(); + self.palomadex_lp(addr.as_str()) } - pub fn wyndex_staked(&mut self, user: &str, unbonding_period: u64) -> u128 { - let wyndex_stake::msg::StakedResponse { stake, .. } = self + pub fn palomadex_staked(&mut self, user: &str, unbonding_period: u64) -> u128 { + let palomadex_stake::msg::StakedResponse { stake, .. } = self .app .wrap() .query_wasm_smart( - &self.wyndex_staking_contract, - &wyndex_stake::msg::QueryMsg::Staked { + &self.palomadex_staking_contract, + &palomadex_stake::msg::QueryMsg::Staked { address: user.to_string(), unbonding_period, }, diff --git a/contracts/junoswap-staking/src/state.rs b/contracts/junoswap-staking/src/state.rs index 4d7c1f5..804de3b 100644 --- a/contracts/junoswap-staking/src/state.rs +++ b/contracts/junoswap-staking/src/state.rs @@ -6,7 +6,7 @@ use cw_storage_plus::Item; pub struct MigrateConfig { /// This is the address that can run ExecuteMsg::MigrateTokens pub migrator: Addr, - /// This is how long it will be staked on WYND DEX + /// This is how long it will be staked on PALOMA DEX pub unbonding_period: u64, /// This is the junoswap pool where the LP will be withdrawn from @@ -15,7 +15,7 @@ pub struct MigrateConfig { /// Can be deposited in any pool created by this factory pub factory: Addr, /// If set, only can be deposited in this pool (which must also be created by the factory) - pub wynddex_pool: Option, + pub palomadex_pool: Option, /// This is set when token migration is finished. /// It is used to calculate the amount of LP tokens to give to each staker. @@ -25,11 +25,11 @@ pub struct MigrateConfig { /// The necessary information to migrate stakers. #[cw_serde] pub struct MigrateStakersConfig { - /// The wyndex LP token contract + /// The palomadex LP token contract pub lp_token: Addr, - /// The wyndex LP staking contract + /// The palomadex LP staking contract pub staking_addr: Addr, - /// The total amount of wyndex LP tokens this contract received after token migration. + /// The total amount of palomadex LP tokens this contract received after token migration. pub total_lp_tokens: Uint128, /// The total amount of staked junoswap LP tokens. pub total_staked: Uint128, diff --git a/contracts/lp-converter/Cargo.toml b/contracts/lp-converter/Cargo.toml index d9a676e..086a998 100644 --- a/contracts/lp-converter/Cargo.toml +++ b/contracts/lp-converter/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "lp-converter" -description = "Wyndex LP token converter - mechanism, which takes bonded token from one staking contract and allows them to be moved to another staking contract" +description = "PalomaDex LP token converter - mechanism, which takes bonded token from one staking contract and allows them to be moved to another staking contract" version = { workspace = true } -authors = ["Cosmorama "] +authors = ["Volume Fi"] edition = { workspace = true } license = { workspace = true } @@ -19,7 +19,7 @@ cosmwasm-std = { workspace = true } cw-storage-plus = { workspace = true } cw2 = { workspace = true } thiserror = { workspace = true } -wyndex = { workspace = true } +palomadex = { workspace = true } wynd-lsd-hub = { workspace = true } cw20 = { workspace = true } @@ -27,7 +27,7 @@ cw20 = { workspace = true } anyhow = { workspace = true } cw-multi-test = { workspace = true } cw20-base = { workspace = true } -wyndex-factory = { workspace = true } -wyndex-pair = { workspace = true } -wyndex-stake = { workspace = true } +palomadex-factory = { workspace = true } +palomadex-pair = { workspace = true } +palomadex-stake = { workspace = true } wynd-lsd-hub = { workspace = true } diff --git a/contracts/lp-converter/README.md b/contracts/lp-converter/README.md index b62039d..b4bcde6 100644 --- a/contracts/lp-converter/README.md +++ b/contracts/lp-converter/README.md @@ -1,3 +1,3 @@ -# WyndDex Token Converter +# PalomaDex Token Converter See [LP Converter Documentation](../../docs/lp-converter.md) \ No newline at end of file diff --git a/contracts/lp-converter/src/bin/schema.rs b/contracts/lp-converter/src/bin/schema.rs index c5752d0..9a67ef3 100644 --- a/contracts/lp-converter/src/bin/schema.rs +++ b/contracts/lp-converter/src/bin/schema.rs @@ -1,7 +1,7 @@ use cosmwasm_schema::write_api; use lp_converter::msg::{InstantiateMsg, QueryMsg}; -use wyndex::lp_converter::ExecuteMsg; +use palomadex::lp_converter::ExecuteMsg; fn main() { write_api! { diff --git a/contracts/lp-converter/src/contract.rs b/contracts/lp-converter/src/contract.rs index 76e5ef0..db351a0 100644 --- a/contracts/lp-converter/src/contract.rs +++ b/contracts/lp-converter/src/contract.rs @@ -2,10 +2,10 @@ use cosmwasm_std::entry_point; use cosmwasm_std::{Binary, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdResult}; use cw2::set_contract_version; +use palomadex::lp_converter::ExecuteMsg; use wynd_lsd_hub::msg::{ ConfigResponse as HubConfigResponse, QueryMsg as HubQueryMsg, SupplyResponse, }; -use wyndex::lp_converter::ExecuteMsg; use crate::error::ContractError; use crate::msg::{InstantiateMsg, QueryMsg}; @@ -15,10 +15,6 @@ const WITHDRAW_LIQUIDITY_REPLY_ID: u64 = 1; const BOND_REPLY_ID: u64 = 2; const PROVIDE_LIQUIDITY_REPLY_ID: u64 = 3; -// version info for migration info -pub const CONTRACT_NAME: &str = "crates.io:wynd-lp-converter"; -const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); - #[cfg_attr(not(feature = "library"), entry_point)] pub fn instantiate( deps: DepsMut, @@ -44,7 +40,6 @@ pub fn instantiate( }; CONFIG.save(deps.storage, &config)?; - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; Ok(Response::default()) } @@ -92,7 +87,7 @@ pub fn query(_deps: Deps, _env: Env, _msg: QueryMsg) -> StdResult { mod execute { use cosmwasm_std::{to_binary, SubMsg, Uint128, WasmMsg}; use cw20::Cw20ExecuteMsg; - use wyndex::{ + use palomadex::{ asset::AssetInfoValidated, pair::{Cw20HookMsg, PairInfo, QueryMsg as PairQueryMsg}, }; @@ -163,13 +158,13 @@ mod execute { mod reply { use cosmwasm_std::{to_binary, Coin, Decimal, SubMsg, WasmMsg}; use cw20::Cw20ExecuteMsg; - use wynd_lsd_hub::msg::ExecuteMsg as HubExecuteMsg; - use wyndex::stake::ReceiveMsg; - use wyndex::{ + use palomadex::stake::ReceiveMsg; + use palomadex::{ asset::{AssetInfo, AssetInfoExt}, pair::{ExecuteMsg as PairExecuteMsg, PairInfo, QueryMsg as PairQueryMsg}, querier::query_token_balance, }; + use wynd_lsd_hub::msg::ExecuteMsg as HubExecuteMsg; use crate::state::TMP_DATA; diff --git a/contracts/lp-converter/src/multitest/migrate_stake.rs b/contracts/lp-converter/src/multitest/migrate_stake.rs index 7187f55..81a25f7 100644 --- a/contracts/lp-converter/src/multitest/migrate_stake.rs +++ b/contracts/lp-converter/src/multitest/migrate_stake.rs @@ -1,5 +1,5 @@ -use wyndex::{asset::MINIMUM_LIQUIDITY_AMOUNT, stake::ConverterConfig}; -use wyndex_stake::msg::MigrateMsg; +use palomadex::{asset::MINIMUM_LIQUIDITY_AMOUNT, stake::ConverterConfig}; +use palomadex_stake::msg::MigrateMsg; use super::suite::{juno, uusd, Pair, SuiteBuilder, DAY}; @@ -48,7 +48,7 @@ fn migrate_to_existing_pool() { .migrate_stake(Pair::Lsd, user, lsd_lp, unbonding_period) .unwrap_err(); assert_eq!( - wyndex_stake::ContractError::NoConverter {}, + palomadex_stake::ContractError::NoConverter {}, err.downcast().unwrap() ); @@ -102,7 +102,7 @@ fn migrate_converter_config() { .migrate_stake(Pair::Native, user, native_lp, unbonding_period) .unwrap_err(); assert_eq!( - wyndex_stake::ContractError::NoConverter {}, + palomadex_stake::ContractError::NoConverter {}, err.downcast().unwrap() ); diff --git a/contracts/lp-converter/src/multitest/suite.rs b/contracts/lp-converter/src/multitest/suite.rs index 16b4486..f5789ca 100644 --- a/contracts/lp-converter/src/multitest/suite.rs +++ b/contracts/lp-converter/src/multitest/suite.rs @@ -11,8 +11,7 @@ use cosmwasm_std::{ }; use cw20::{BalanceResponse, Cw20ExecuteMsg, Cw20QueryMsg}; use cw_multi_test::{App, AppResponse, Contract, ContractWrapper, Executor, StakingInfo}; -use wynd_lsd_hub::msg::{ConfigResponse, TokenInitInfo}; -use wyndex::{ +use palomadex::{ asset::{Asset, AssetInfo, AssetInfoExt}, factory::{ DefaultStakeConfig, ExecuteMsg as FactoryExecuteMsg, PairConfig, PairType, @@ -22,40 +21,40 @@ use wyndex::{ pair::{ExecuteMsg as PairExecuteMsg, PairInfo}, stake::{ConverterConfig, ReceiveMsg, UnbondingPeriod}, }; -use wyndex_stake::msg::{ExecuteMsg as StakeExecuteMsg, StakedResponse}; +use palomadex_stake::msg::{ExecuteMsg as StakeExecuteMsg, StakedResponse}; +use wynd_lsd_hub::msg::{ConfigResponse, TokenInitInfo}; pub const DAY: u64 = 24 * HOUR; pub const HOUR: u64 = 60 * 60; fn contract_factory() -> Box> { let contract = ContractWrapper::new_with_empty( - wyndex_factory::contract::execute, - wyndex_factory::contract::instantiate, - wyndex_factory::contract::query, + palomadex_factory::contract::execute, + palomadex_factory::contract::instantiate, + palomadex_factory::contract::query, ) - .with_reply_empty(wyndex_factory::contract::reply); + .with_reply_empty(palomadex_factory::contract::reply); Box::new(contract) } fn contract_pair() -> Box> { let contract = ContractWrapper::new_with_empty( - wyndex_pair::contract::execute, - wyndex_pair::contract::instantiate, - wyndex_pair::contract::query, + palomadex_pair::contract::execute, + palomadex_pair::contract::instantiate, + palomadex_pair::contract::query, ) - .with_reply_empty(wyndex_pair::contract::reply); + .with_reply_empty(palomadex_pair::contract::reply); Box::new(contract) } fn contract_stake() -> Box> { let contract = ContractWrapper::new_with_empty( - wyndex_stake::contract::execute, - wyndex_stake::contract::instantiate, - wyndex_stake::contract::query, - ) - .with_migrate(wyndex_stake::contract::migrate); + palomadex_stake::contract::execute, + palomadex_stake::contract::instantiate, + palomadex_stake::contract::query, + ); Box::new(contract) } @@ -199,7 +198,7 @@ impl SuiteBuilder { .instantiate_contract( factory_code_id, owner.clone(), - &wyndex::factory::InstantiateMsg { + &palomadex::factory::InstantiateMsg { pair_configs: vec![PairConfig { code_id: pair_code_id, pair_type: PairType::Xyk {}, @@ -553,7 +552,7 @@ impl Suite { pub fn migrate_staking_contract( &mut self, pair: Pair, - msg: wyndex_stake::msg::MigrateMsg, + msg: palomadex_stake::msg::MigrateMsg, ) -> AnyResult { self.app.migrate_contract( Addr::unchecked("owner"), @@ -571,7 +570,7 @@ impl Suite { ) -> AnyResult { Ok(self.app.wrap().query_wasm_smart( pair.staking_addr(self), - &wyndex_stake::msg::QueryMsg::Staked { + &palomadex_stake::msg::QueryMsg::Staked { address: addr.to_string(), unbonding_period, }, @@ -589,7 +588,7 @@ impl Suite { Ok(self .app .wrap() - .query_wasm_smart(pair.addr(self), &wyndex::pair::QueryMsg::Pair {})?) + .query_wasm_smart(pair.addr(self), &palomadex::pair::QueryMsg::Pair {})?) } pub fn query_cw20_balance(&self, address: &str, cw20: impl Into) -> StdResult { diff --git a/contracts/lp-converter/src/state.rs b/contracts/lp-converter/src/state.rs index f7eaca3..d6c5dac 100644 --- a/contracts/lp-converter/src/state.rs +++ b/contracts/lp-converter/src/state.rs @@ -1,7 +1,7 @@ use cosmwasm_schema::cw_serde; use cosmwasm_std::Addr; use cw_storage_plus::Item; -use wyndex::asset::AssetInfoValidated; +use palomadex::asset::AssetInfoValidated; #[cw_serde] pub struct Config { diff --git a/contracts/multi-hop/Cargo.toml b/contracts/multi-hop/Cargo.toml index 6277915..36cd6d6 100644 --- a/contracts/multi-hop/Cargo.toml +++ b/contracts/multi-hop/Cargo.toml @@ -1,9 +1,9 @@ [package] -name = "wyndex-multi-hop" +name = "palomadex-multi-hop" version = { workspace = true } -authors = ["Cosmorama "] +authors = ["Volume Fi"] edition = { workspace = true } -description = "Wyndex Multi-hop - provides multi-hop swap functionality for wyndex pools" +description = "PalomaDex Multi-hop - provides multi-hop swap functionality for palomadex pools" license = { workspace = true } [lib] @@ -21,12 +21,12 @@ cw2 = { workspace = true } cw20 = { workspace = true } cw-utils = { workspace = true } thiserror = { workspace = true } -wyndex = { workspace = true } +palomadex = { workspace = true } [dev-dependencies] anyhow = { workspace = true } cw-multi-test = { workspace = true } cw20-base = { workspace = true } -wyndex-factory = { workspace = true } -wyndex-pair = { workspace = true } -wyndex-stake = { workspace = true } +palomadex-factory = { workspace = true } +palomadex-pair = { workspace = true } +palomadex-stake = { workspace = true } diff --git a/contracts/multi-hop/README.md b/contracts/multi-hop/README.md index a245ea4..00b1083 100644 --- a/contracts/multi-hop/README.md +++ b/contracts/multi-hop/README.md @@ -1,6 +1,6 @@ -# Wyndex Router +# PalomaDex Router -The Router contract contains logic to facilitate multi-hop swaps for Terra native & Wyndex tokens. +The Router contract contains logic to facilitate multi-hop swaps for Terra native & PalomaDex tokens. --- @@ -10,11 +10,11 @@ For every swap, the contract checks if the resulting token is the one that was a ## InstantiateMsg -Initializes the contract with the Wyndex factory contract address. +Initializes the contract with the PalomaDex factory contract address. ```json { - "wyndex_factory": "terra..." + "palomadex_factory": "paloma..." } ``` @@ -36,7 +36,7 @@ CW20 receive msg. ### `execute_swap_operation` -Swaps one token to another. _single_ defines whether this swap is single or part of a multi hop route. +Swaps one token to another. _single_ defines whether this swap is single or part of a multi hop route. This message is for internal use. ### Example @@ -47,15 +47,15 @@ Swap UST => mABNB { "execute_swap_operation": { "operation": { - "wyndex_swap": { + "palomadex_swap": { "offer_asset_info": { "native_token": { - "denom": "uusd" + "denom": "ugrain" } }, "ask_asset_info": { "token": { - "contract_addr": "terra..." + "contract_addr": "paloma..." } } } @@ -69,7 +69,7 @@ Swap UST => mABNB ### `execute_swap_operations` -Performs multi-hop swap operations for native & Wyndex tokens. Swaps execute one-by-one and the last swap will return the ask token. This function is public (can be called by anyone). +Performs multi-hop swap operations for native & PalomaDex tokens. Swaps execute one-by-one and the last swap will return the ask token. This function is public (can be called by anyone). ### Example @@ -86,7 +86,7 @@ Swap KRT => UST => mABNB } }, { - "wyndex_swap": { + "palomadex_swap": { "offer_asset_info": { "native_token": { "denom": "uusd" @@ -158,7 +158,7 @@ Simulates multi-hop swap operations. Examples: } }, { - "wyndex_swap": { + "palomadex_swap": { "offer_asset_info": { "native_token": { "denom": "uusd" @@ -190,7 +190,7 @@ Simulates multi-hop swap operations. Examples: } }, { - "wyndex_swap": { + "palomadex_swap": { "offer_asset_info": { "token": { "contract_addr": "terra..." diff --git a/contracts/multi-hop/src/bin/multi_hop_schema.rs b/contracts/multi-hop/src/bin/multi_hop_schema.rs index 4cf48a8..d894048 100644 --- a/contracts/multi-hop/src/bin/multi_hop_schema.rs +++ b/contracts/multi-hop/src/bin/multi_hop_schema.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::write_api; -use wyndex_multi_hop::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use palomadex_multi_hop::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; fn main() { write_api! { diff --git a/contracts/multi-hop/src/contract.rs b/contracts/multi-hop/src/contract.rs index 6a05d75..a37dce7 100644 --- a/contracts/multi-hop/src/contract.rs +++ b/contracts/multi-hop/src/contract.rs @@ -4,7 +4,6 @@ use cosmwasm_std::{ entry_point, from_binary, to_binary, Addr, Api, Binary, Coin, CosmosMsg, Decimal, Deps, DepsMut, Env, MessageInfo, Response, StdError, StdResult, Uint128, WasmMsg, }; -use cw2::set_contract_version; use cw20::{Cw20ExecuteMsg, Cw20ReceiveMsg}; use cw_utils::ensure_from_older_version; @@ -12,17 +11,13 @@ use crate::msg::{ ConfigResponse, Cw20HookMsg, ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg, SimulateSwapOperationsResponse, SwapOperation, MAX_SWAP_OPERATIONS, }; -use wyndex::asset::{addr_opt_validate, Asset, AssetInfo, AssetInfoExt}; -use wyndex::pair::{ExecuteMsg as PairExecuteMsg, QueryMsg as PairQueryMsg, SimulationResponse}; -use wyndex::querier::{query_balance, query_pair_info, query_token_balance}; +use palomadex::asset::{addr_opt_validate, Asset, AssetInfo, AssetInfoExt}; +use palomadex::pair::{ExecuteMsg as PairExecuteMsg, QueryMsg as PairQueryMsg, SimulationResponse}; +use palomadex::querier::{query_balance, query_pair_info, query_token_balance}; use crate::error::ContractError; use crate::state::{Config, CONFIG}; -/// Version info for migration -const CONTRACT_NAME: &str = "wynd-multi-hop"; -const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); - #[cfg_attr(not(feature = "library"), entry_point)] pub fn instantiate( deps: DepsMut, @@ -30,12 +25,10 @@ pub fn instantiate( _info: MessageInfo, msg: InstantiateMsg, ) -> Result { - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - CONFIG.save( deps.storage, &Config { - wyndex_factory: deps.api.addr_validate(&msg.wyndex_factory)?, + palomadex_factory: deps.api.addr_validate(&msg.palomadex_factory)?, }, )?; @@ -150,14 +143,14 @@ mod execute { } let message = match operation { - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info, ask_asset_info, } => { let config = CONFIG.load(deps.storage)?; let pair_info = query_pair_info( &deps.querier, - config.wyndex_factory, + config.palomadex_factory, &[offer_asset_info.clone(), ask_asset_info.clone()], )?; @@ -234,7 +227,7 @@ mod execute { msg: to_binary(&Cw20ExecuteMsg::Send { contract: pair_contract, amount: offer_asset.amount, - msg: to_binary(&wyndex::pair::Cw20HookMsg::Swap { + msg: to_binary(&palomadex::pair::Cw20HookMsg::Swap { ask_asset_info: Some(ask_asset_info), belief_price, max_spread, @@ -382,7 +375,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> Result Result { let state = CONFIG.load(deps.storage)?; let resp = ConfigResponse { - wyndex_factory: state.wyndex_factory.into_string(), + palomadex_factory: state.palomadex_factory.into_string(), }; Ok(resp) @@ -411,7 +404,7 @@ mod query { operations: Vec, ) -> Result { let config = CONFIG.load(deps.storage)?; - let wyndex_factory = config.wyndex_factory; + let palomadex_factory = config.palomadex_factory; let operations_len = operations.len(); if operations_len == 0 { @@ -432,13 +425,13 @@ mod query { let mut percent_of_ideal = Decimal::one(); for (idx, operation) in operations.into_iter().enumerate() { match operation { - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info, ask_asset_info, } => { let pair_info = query_pair_info( &deps.querier, - wyndex_factory.clone(), + palomadex_factory.clone(), &[offer_asset_info.clone(), ask_asset_info.clone()], )?; @@ -504,7 +497,7 @@ mod query { operations: Vec, ) -> Result { let config = CONFIG.load(deps.storage)?; - let wyndex_factory = config.wyndex_factory; + let palomadex_factory = config.palomadex_factory; let operations_len = operations.len(); if operations_len == 0 { @@ -525,13 +518,13 @@ mod query { let mut percent_of_ideal = Decimal::one(); for (idx, operation) in operations.into_iter().enumerate().rev() { match operation { - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info, ask_asset_info, } => { let pair_info = query_pair_info( &deps.querier, - wyndex_factory.clone(), + palomadex_factory.clone(), &[offer_asset_info.clone(), ask_asset_info.clone()], )?; @@ -589,7 +582,7 @@ fn assert_operations(api: &dyn Api, operations: &[SwapOperation]) -> Result<(), let mut ask_asset_map: HashSet = HashSet::new(); for operation in operations { let (offer_asset, ask_asset) = match operation { - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info, ask_asset_info, } => ( @@ -609,12 +602,6 @@ fn assert_operations(api: &dyn Api, operations: &[SwapOperation]) -> Result<(), Ok(()) } -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result { - ensure_from_older_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - Ok(Response::new()) -} - #[cfg(test)] mod testing { use super::*; @@ -630,11 +617,11 @@ mod testing { assert!(assert_operations( deps.as_ref().api, &[ - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info: AssetInfo::Native("ukrw".to_string()), ask_asset_info: AssetInfo::Token("asset0001".to_string()), }, - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info: AssetInfo::Token("asset0001".to_string()), ask_asset_info: AssetInfo::Native("uluna".to_string()), }, @@ -646,15 +633,15 @@ mod testing { assert!(assert_operations( deps.as_ref().api, &[ - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info: AssetInfo::Native("ukrw".to_string()), ask_asset_info: AssetInfo::Token("asset0001".to_string()), }, - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info: AssetInfo::Token("asset0001".to_string()), ask_asset_info: AssetInfo::Native("uluna".to_string()), }, - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info: AssetInfo::Native("uluna".to_string()), ask_asset_info: AssetInfo::Token("asset0002".to_string()), }, @@ -666,15 +653,15 @@ mod testing { assert!(assert_operations( deps.as_ref().api, &[ - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info: AssetInfo::Native("ukrw".to_string()), ask_asset_info: AssetInfo::Token("asset0001".to_string()), }, - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info: AssetInfo::Token("asset0001".to_string()), ask_asset_info: AssetInfo::Native("uaud".to_string()), }, - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info: AssetInfo::Native("uluna".to_string()), ask_asset_info: AssetInfo::Token("asset0002".to_string()), }, diff --git a/contracts/multi-hop/src/msg.rs b/contracts/multi-hop/src/msg.rs index a47129c..e0e3283 100644 --- a/contracts/multi-hop/src/msg.rs +++ b/contracts/multi-hop/src/msg.rs @@ -3,15 +3,15 @@ use cosmwasm_schema::{cw_serde, QueryResponses}; use cosmwasm_std::{Decimal, Uint128}; use cw20::Cw20ReceiveMsg; -use wyndex::asset::{AssetInfo, AssetValidated}; +use palomadex::asset::{AssetInfo, AssetValidated}; pub const MAX_SWAP_OPERATIONS: usize = 50; /// This structure holds the parameters used for creating a contract. #[cw_serde] pub struct InstantiateMsg { - /// The wyndex factory contract address - pub wyndex_factory: String, + /// The palomadex factory contract address + pub palomadex_factory: String, } /// This enum describes a swap operation. @@ -19,8 +19,8 @@ pub struct InstantiateMsg { /// so we can add other AMMs in the future. #[cw_serde] pub enum SwapOperation { - /// Wyndex swap - WyndexSwap { + /// Palomadex swap + PalomadexSwap { /// Information about the asset being swapped offer_asset_info: AssetInfo, /// Information about the asset we swap to @@ -31,7 +31,7 @@ pub enum SwapOperation { impl SwapOperation { pub fn get_target_asset_info(&self) -> AssetInfo { match self { - SwapOperation::WyndexSwap { ask_asset_info, .. } => ask_asset_info.clone(), + SwapOperation::PalomadexSwap { ask_asset_info, .. } => ask_asset_info.clone(), } } } @@ -147,8 +147,8 @@ pub enum QueryMsg { /// This structure describes a custom struct to return a query response containing the base contract configuration. #[cw_serde] pub struct ConfigResponse { - /// The Wyndex factory contract address - pub wyndex_factory: String, + /// The Palomadex factory contract address + pub palomadex_factory: String, } /// This structure describes a custom struct to return a query response containing the end amount of a swap simulation diff --git a/contracts/multi-hop/src/multitest/suite.rs b/contracts/multi-hop/src/multitest/suite.rs index 01f8ee2..71aac08 100644 --- a/contracts/multi-hop/src/multitest/suite.rs +++ b/contracts/multi-hop/src/multitest/suite.rs @@ -8,13 +8,13 @@ use cw_multi_test::{App, AppResponse, BankSudo, ContractWrapper, Executor, SudoM use crate::msg::{ ExecuteMsg, InstantiateMsg, QueryMsg, SimulateSwapOperationsResponse, SwapOperation, }; -use wyndex::asset::{Asset, AssetInfo}; -use wyndex::factory::{ +use palomadex::asset::{Asset, AssetInfo}; +use palomadex::factory::{ DefaultStakeConfig, ExecuteMsg as FactoryExecuteMsg, InstantiateMsg as FactoryInstantiateMsg, PairConfig, PairType, QueryMsg as FactoryQueryMsg, }; -use wyndex::fee_config::FeeConfig; -use wyndex::pair::{ExecuteMsg as PairExecuteMsg, PairInfo}; +use palomadex::fee_config::FeeConfig; +use palomadex::pair::{ExecuteMsg as PairExecuteMsg, PairInfo}; const SECONDS_PER_DAY: u64 = 60 * 60 * 24; @@ -31,11 +31,11 @@ fn store_multi_hop(app: &mut App) -> u64 { fn store_factory(app: &mut App) -> u64 { let contract = Box::new( ContractWrapper::new_with_empty( - wyndex_factory::contract::execute, - wyndex_factory::contract::instantiate, - wyndex_factory::contract::query, + palomadex_factory::contract::execute, + palomadex_factory::contract::instantiate, + palomadex_factory::contract::query, ) - .with_reply_empty(wyndex_factory::contract::reply), + .with_reply_empty(palomadex_factory::contract::reply), ); app.store_code(contract) @@ -44,11 +44,11 @@ fn store_factory(app: &mut App) -> u64 { fn store_pair(app: &mut App) -> u64 { let contract = Box::new( ContractWrapper::new_with_empty( - wyndex_pair::contract::execute, - wyndex_pair::contract::instantiate, - wyndex_pair::contract::query, + palomadex_pair::contract::execute, + palomadex_pair::contract::instantiate, + palomadex_pair::contract::query, ) - .with_reply_empty(wyndex_pair::contract::reply), + .with_reply_empty(palomadex_pair::contract::reply), ); app.store_code(contract) @@ -66,9 +66,9 @@ fn store_cw20(app: &mut App) -> u64 { fn store_staking(app: &mut App) -> u64 { let contract = Box::new(ContractWrapper::new( - wyndex_stake::contract::execute, - wyndex_stake::contract::instantiate, - wyndex_stake::contract::query, + palomadex_stake::contract::execute, + palomadex_stake::contract::instantiate, + palomadex_stake::contract::query, )); app.store_code(contract) @@ -166,7 +166,7 @@ impl SuiteBuilder { trading_starts: None, }, &[], - "Wyndex Factory", + "Palomadex Factory", None, ) .unwrap(); @@ -177,10 +177,10 @@ impl SuiteBuilder { multi_hop_code_id, owner.clone(), &InstantiateMsg { - wyndex_factory: factory.to_string(), + palomadex_factory: factory.to_string(), }, &[], - "Wyndex Multi Hop", + "Palomadex Multi Hop", None, ) .unwrap(); diff --git a/contracts/multi-hop/src/multitest/swap.rs b/contracts/multi-hop/src/multitest/swap.rs index 5de3c53..795a2c9 100644 --- a/contracts/multi-hop/src/multitest/swap.rs +++ b/contracts/multi-hop/src/multitest/swap.rs @@ -2,13 +2,13 @@ use super::suite::SuiteBuilder; use cosmwasm_std::testing::MockApi; use cosmwasm_std::{assert_approx_eq, coin, Decimal, Fraction, Uint128}; -use wyndex::pair::{add_referral, take_referral}; -use wyndex::querier::query_factory_config; +use palomadex::pair::{add_referral, take_referral}; +use palomadex::querier::query_factory_config; use crate::error::ContractError; use crate::msg::{SwapOperation, MAX_SWAP_OPERATIONS}; -use wyndex::asset::{AssetInfo, AssetInfoExt, AssetInfoValidated}; -use wyndex::factory::PairType; +use palomadex::asset::{AssetInfo, AssetInfoExt, AssetInfoValidated}; +use palomadex::factory::PairType; #[test] fn must_provide_operations() { @@ -37,7 +37,7 @@ fn single_swap() { let owner = suite.owner.clone(); - let token = suite.instantiate_token(&owner, "wynd"); + let token = suite.instantiate_token(&owner, "paloma"); // create LP for just instantiated tokens suite @@ -59,7 +59,7 @@ fn single_swap() { user, &token, 100_000u128, - vec![SwapOperation::WyndexSwap { + vec![SwapOperation::PalomadexSwap { offer_asset_info: AssetInfo::Token(token.to_string()), ask_asset_info: AssetInfo::Native(ujuno.to_string()), }], @@ -81,7 +81,7 @@ fn multiple_swaps() { let owner = suite.owner.clone(); - let token_a = suite.instantiate_token(&owner, "wynd"); + let token_a = suite.instantiate_token(&owner, "paloma"); let token_b = suite.instantiate_token(&owner, "ueco"); // create LP for just instantiated tokens @@ -115,15 +115,15 @@ fn multiple_swaps() { user, coin(100_000u128, "ujuno"), vec![ - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info: AssetInfo::Native(ujuno.to_string()), ask_asset_info: AssetInfo::Token(token_a.to_string()), }, - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info: AssetInfo::Token(token_a.to_string()), ask_asset_info: AssetInfo::Native(uluna.to_string()), }, - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info: AssetInfo::Native(uluna.to_string()), ask_asset_info: AssetInfo::Token(token_b.to_string()), }, @@ -177,11 +177,11 @@ fn multi_hop_does_not_enforce_spread_assetion() { &token_a, 50_000_000_000u128, vec![ - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info: AssetInfo::Token(token_a.to_string()), ask_asset_info: AssetInfo::Token(token_b.to_string()), }, - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info: AssetInfo::Token(token_b.to_string()), ask_asset_info: AssetInfo::Token(token_c.to_string()), }, @@ -195,14 +195,14 @@ fn multi_hop_does_not_enforce_spread_assetion() { user, &token_a, 50_000_000_000u128, - vec![SwapOperation::WyndexSwap { + vec![SwapOperation::PalomadexSwap { offer_asset_info: AssetInfo::Token(token_a.to_string()), ask_asset_info: AssetInfo::Token(token_b.to_string()), }], ) .unwrap_err(); assert_eq!( - wyndex::pair::ContractError::MaxSpreadAssertion {}, + palomadex::pair::ContractError::MaxSpreadAssertion {}, err.downcast().unwrap() ) } @@ -240,11 +240,11 @@ fn query_buy_with_routes() { .query_simulate_swap_operations( 1_000_000u128, vec![ - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info: AssetInfo::Native("ujuno".to_owned()), ask_asset_info: AssetInfo::Token(token.to_string()), }, - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info: AssetInfo::Token(token.to_string()), ask_asset_info: AssetInfo::Native("uluna".to_owned()), }, @@ -265,11 +265,11 @@ fn query_buy_with_routes() { .query_simulate_reverse_swap_operations( 998_002u128, vec![ - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info: AssetInfo::Native("ujuno".to_owned()), ask_asset_info: AssetInfo::Token(token.to_string()), }, - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info: AssetInfo::Token(token.to_string()), ask_asset_info: AssetInfo::Native("uluna".to_owned()), }, @@ -326,11 +326,11 @@ fn simulation_with_fee() { .query_simulate_swap_operations( 1_000_000u128, vec![ - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info: ujuno_info.clone(), ask_asset_info: token_info.clone(), }, - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info: token_info.clone(), ask_asset_info: uluna_info.clone(), }, @@ -380,11 +380,11 @@ fn simulation_with_fee() { .query_simulate_swap_operations_ref( 1_000_000u128, vec![ - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info: ujuno_info.clone(), ask_asset_info: token_info.clone(), }, - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info: token_info.clone(), ask_asset_info: uluna_info.clone(), }, @@ -427,11 +427,11 @@ fn simulation_with_fee() { .query_simulate_reverse_swap_operations_ref( 968_391u128, vec![ - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info: ujuno_info, ask_asset_info: token_info.clone(), }, - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info: token_info, ask_asset_info: uluna_info, }, @@ -527,7 +527,7 @@ fn maximum_receive_swap_operations() { user, coin(100_000u128, "ujuno"), vec![ - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info: AssetInfo::Native(ujuno.to_string()), ask_asset_info: AssetInfo::Native(uluna.to_owned()), }; @@ -590,7 +590,7 @@ fn referral_single() { let owner = suite.owner.clone(); - let token = suite.instantiate_token(&owner, "wynd"); + let token = suite.instantiate_token(&owner, "paloma"); // create LP for just instantiated tokens suite @@ -612,7 +612,7 @@ fn referral_single() { user, &token, 101_010u128, - vec![SwapOperation::WyndexSwap { + vec![SwapOperation::PalomadexSwap { offer_asset_info: AssetInfo::Token(token.to_string()), ask_asset_info: AssetInfo::Native(ujuno.to_string()), }], @@ -642,7 +642,7 @@ fn referral_multiple() { let owner = suite.owner.clone(); - let token_a = suite.instantiate_token(&owner, "wynd"); + let token_a = suite.instantiate_token(&owner, "paloma"); let token_b = suite.instantiate_token(&owner, "ueco"); // create LP for just instantiated tokens @@ -672,15 +672,15 @@ fn referral_multiple() { .unwrap(); let operations = vec![ - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info: AssetInfo::Native(ujuno.to_string()), ask_asset_info: AssetInfo::Token(token_a.to_string()), }, - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info: AssetInfo::Token(token_a.to_string()), ask_asset_info: AssetInfo::Native(uluna.to_string()), }, - SwapOperation::WyndexSwap { + SwapOperation::PalomadexSwap { offer_asset_info: AssetInfo::Native(uluna.to_string()), ask_asset_info: AssetInfo::Token(token_b.to_string()), }, @@ -729,7 +729,7 @@ fn invalid_referral_commission() { let owner = suite.owner.clone(); - let token = suite.instantiate_token(&owner, "wynd"); + let token = suite.instantiate_token(&owner, "paloma"); // create LP for just instantiated tokens suite @@ -752,7 +752,7 @@ fn invalid_referral_commission() { user, &token, 100_000, - vec![SwapOperation::WyndexSwap { + vec![SwapOperation::PalomadexSwap { offer_asset_info: AssetInfo::Token(token.to_string()), ask_asset_info: AssetInfo::Native(ujuno.to_string()), }], @@ -779,7 +779,7 @@ fn referral_commission_zero() { let owner = suite.owner.clone(); - let token = suite.instantiate_token(&owner, "wynd"); + let token = suite.instantiate_token(&owner, "paloma"); // create LP for just instantiated tokens suite @@ -800,7 +800,7 @@ fn referral_commission_zero() { user, &token, 1000, - vec![SwapOperation::WyndexSwap { + vec![SwapOperation::PalomadexSwap { offer_asset_info: AssetInfo::Token(token.to_string()), ask_asset_info: AssetInfo::Native(ujuno.to_string()), }], diff --git a/contracts/multi-hop/src/state.rs b/contracts/multi-hop/src/state.rs index 761d2ac..4cb04e4 100644 --- a/contracts/multi-hop/src/state.rs +++ b/contracts/multi-hop/src/state.rs @@ -7,5 +7,5 @@ pub const CONFIG: Item = Item::new("config"); #[cw_serde] pub struct Config { /// The factory contract address - pub wyndex_factory: Addr, + pub palomadex_factory: Addr, } diff --git a/contracts/nominated-trader/Cargo.toml b/contracts/nominated-trader/Cargo.toml index 4dd17e2..990dc30 100644 --- a/contracts/nominated-trader/Cargo.toml +++ b/contracts/nominated-trader/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "nominated-trader" -authors = ["Cosmorama , 0xFable <0xfable@protonmail.com>"] +authors = ["Volume Fi"] version = { workspace = true } edition = { workspace = true } -description = "Collects and swaps collected protocol fees as WYND tokens. Actively managed funds owned by WYND DAO" +description = "Collects and swaps collected protocol fees as Grain tokens. Actively managed funds owned by PALOMACHAIN" license = { workspace = true } repository = { workspace = true } -homepage = "https://www.wynddao.com" +homepage = "https://www.palomachain.com" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -26,15 +26,15 @@ cw-storage-plus = { workspace = true } cw2 = { workspace = true } cw-utils = { workspace = true } thiserror = { workspace = true } -wyndex = { workspace = true } +palomadex = { workspace = true } cw20 = { workspace = true } [dev-dependencies] anyhow = { workspace = true } cw-multi-test = { workspace = true } cw20-base = { workspace = true } -wyndex-factory = { workspace = true } -wyndex-pair = { workspace = true } -wyndex-multi-hop = { workspace = true } -wyndex-pair-lsd = { workspace = true } -wyndex-stake = { workspace = true } +palomadex-factory = { workspace = true } +palomadex-pair = { workspace = true } +palomadex-multi-hop = { workspace = true } +palomadex-pair-lsd = { workspace = true } +palomadex-stake = { workspace = true } diff --git a/contracts/nominated-trader/README.md b/contracts/nominated-trader/README.md index af9d1c0..a33ab69 100644 --- a/contracts/nominated-trader/README.md +++ b/contracts/nominated-trader/README.md @@ -1,7 +1,7 @@ -# Wynd Nominated Trader +# Paloma Nominated Trader -The Nominated Trader accumulates Wyndex protocol fees and swaps them to WYND through a nominated route of pool hops. +The Nominated Trader accumulates PalomaDex protocol fees and swaps them to PALOMA through a nominated route of pool hops. ## Example Use -A number of pairs are created using the factory. When fees are ready for collection, a set of `hops` (routes) are submitted for each pair detailing how its fee token should be swapped to the WYND token. After necessary `hops` are defined for each fee token, a collection can be done for N tokens in one call. \ No newline at end of file +A number of pairs are created using the factory. When fees are ready for collection, a set of `hops` (routes) are submitted for each pair detailing how its fee token should be swapped to the Grain token. After necessary `hops` are defined for each fee token, a collection can be done for N tokens in one call. \ No newline at end of file diff --git a/contracts/nominated-trader/src/contract.rs b/contracts/nominated-trader/src/contract.rs index 70345ad..2caee65 100644 --- a/contracts/nominated-trader/src/contract.rs +++ b/contracts/nominated-trader/src/contract.rs @@ -6,10 +6,9 @@ use cosmwasm_std::{ to_binary, Addr, Binary, CosmosMsg, Decimal, Deps, DepsMut, Env, MessageInfo, Order, Response, StdResult, SubMsg, Uint128, WasmMsg, }; -use cw2::set_contract_version; use cw20::Cw20ExecuteMsg; -use wyndex::asset::{Asset, AssetInfo}; +use palomadex::asset::{Asset, AssetInfo}; use crate::error::ContractError; use crate::msg::{ @@ -21,10 +20,6 @@ use crate::utils::{ ROUTES_INITIAL_DEPTH, }; -// version info for migration info -const CONTRACT_NAME: &str = "crates.io:nominated-trader"; -const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); - #[cfg_attr(not(feature = "library"), entry_point)] pub fn instantiate( deps: DepsMut, @@ -32,8 +27,6 @@ pub fn instantiate( info: MessageInfo, msg: InstantiateMsg, ) -> Result { - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - let config = Config { owner: info.sender, nominated_trader: deps.api.addr_validate(&msg.nominated_trader)?, @@ -112,7 +105,7 @@ pub fn collect_fees_to_base_token( assets: Vec, ) -> Result { let cfg = CONFIG.load(deps.storage)?; - let wynd: AssetInfo = cfg.token_contract.clone().into(); + let paloma: AssetInfo = cfg.token_contract.clone().into(); // Permission check if info.sender != cfg.nominated_trader { @@ -131,12 +124,12 @@ pub fn collect_fees_to_base_token( return Err(ContractError::DuplicatedAsset {}); } - // Swap all non WYND tokens to Wynd + // Swap all non Grain tokens to Paloma let response = swap_assets( deps.as_ref(), &env.contract.address, &cfg, - assets.into_iter().filter(|a| a.info != wynd).collect(), + assets.into_iter().filter(|a| a.info != paloma).collect(), None, )?; Ok(response) @@ -298,11 +291,11 @@ fn swap_hop_assets( Ok(response.add_attribute("action", "swap_route_assets")) } -/// Adds or removes defined routes used to swap fee tokens to WYND. +/// Adds or removes defined routes used to swap fee tokens to PALOMA. /// -/// * **add** array of routes defining hops needed to swap fee tokens to Wynd. +/// * **add** array of routes defining hops needed to swap fee tokens to Paloma. /// -/// * **remove** array of routes defining hops needed to swap fee tokens to Wynd. +/// * **remove** array of routes defining hops needed to swap fee tokens to Paloma. /// /// ## Executor /// Only the owner can execute this. @@ -330,18 +323,18 @@ fn update_routes( ); } } - let wynd = AssetInfo::Token(cfg.token_contract.to_string()); + let paloma = AssetInfo::Token(cfg.token_contract.to_string()); // Add new routes if let Some(routes_to_add) = add { for (asset, route) in routes_to_add { // Verify asset is not same as route - // Check that route tokens can be swapped to WYND + // Check that route tokens can be swapped to PALOMA validate_route( deps.as_ref(), &cfg.dex_factory_contract, &asset, &route, - &wynd, + &paloma, ROUTES_INITIAL_DEPTH, None, )?; @@ -394,7 +387,7 @@ fn query_get_balances(deps: Deps, env: Env, assets: Vec) -> StdResult Ok(resp) } -/// Returns route tokens used for swapping fee tokens to WYND. +/// Returns route tokens used for swapping fee tokens to PALOMA. fn query_routes(deps: Deps) -> StdResult> { ROUTES .range(deps.storage, None, None, Order::Ascending) diff --git a/contracts/nominated-trader/src/error.rs b/contracts/nominated-trader/src/error.rs index 11da53c..2e183f9 100644 --- a/contracts/nominated-trader/src/error.rs +++ b/contracts/nominated-trader/src/error.rs @@ -1,6 +1,6 @@ use cosmwasm_std::StdError; +use palomadex::asset::AssetInfo; use thiserror::Error; -use wyndex::asset::AssetInfo; #[derive(Error, Debug)] pub enum ContractError { diff --git a/contracts/nominated-trader/src/msg.rs b/contracts/nominated-trader/src/msg.rs index ec336cd..d7d049f 100644 --- a/contracts/nominated-trader/src/msg.rs +++ b/contracts/nominated-trader/src/msg.rs @@ -1,32 +1,32 @@ use cosmwasm_schema::{cw_serde, QueryResponses}; use cosmwasm_std::{Decimal, Uint128}; -use wyndex::asset::{Asset, AssetInfo}; +use palomadex::asset::{Asset, AssetInfo}; #[cw_serde] pub struct InstantiateMsg { /// Address that's allowed to change contract parameters pub owner: String, - /// Address that's allowed to perform swaps and convert fee tokens to Wynd as needed + /// Address that's allowed to perform swaps and convert fee tokens to Paloma as needed pub nominated_trader: String, /// Address specified to receive any payouts, usually distinct from the nominated_trader address pub beneficiary: String, - /// The WYND token contract address + /// The Grain token contract address pub token_contract: AssetInfo, - /// The Wyndex factory contract address + /// The Palomadex factory contract address pub dex_factory_contract: String, - /// The maximum spread used when swapping fee tokens to WYND + /// The maximum spread used when swapping fee tokens to PALOMA pub max_spread: Option, } #[cw_serde] pub enum ExecuteMsg { - /// Collects and swaps fee tokens to WYND after sending the Swap msgs as SubMsgs + /// Collects and swaps fee tokens to PALOMA after sending the Swap msgs as SubMsgs /// This call is restricted to the currently nominated trader which can perform fee collections and swaps Collect { - /// The nominated assets to swap to WYND + /// The nominated assets to swap to PALOMA assets: Vec, }, - /// Add or remove route definitions for tokens used to swap specific fee tokens to WYND + /// Add or remove route definitions for tokens used to swap specific fee tokens to PALOMA /// (effectively declaring the hops to be taken for a swap route) /// Only the `owner` can call this Execute action UpdateRoutes { @@ -37,7 +37,7 @@ pub enum ExecuteMsg { /// Only the collector contract itself can call this /// No limit is specified for each asset and a maximum route depth is also exposed SwapHopAssets { assets: Vec, depth: u64 }, - /// Allows the owner to spend the contract's WYND balance. The trader contract will not be able to spend the WYND but can trade other assets to it. + /// Allows the owner to spend the contract's PALOMA balance. The trader contract will not be able to spend the PALOMA but can trade other assets to it. Transfer { recipient: String, amount: Uint128 }, } @@ -59,15 +59,15 @@ pub enum QueryMsg { pub struct ConfigResponse { /// Address that's allowed to change contract parameters pub owner: String, - /// Address that's allowed to perform swaps and convert fee tokens to Wynd as needed + /// Address that's allowed to perform swaps and convert fee tokens to Paloma as needed pub nominated_trader: String, /// Address specified to receive any payouts usually distinct from the nominated_trader address pub beneficiary: String, - /// The WYND token contract address + /// The Grain token contract address pub token_contract: String, - /// The Wyndex factory contract address + /// The Palomadex factory contract address pub dex_factory_contract: String, - /// The maximum spread used when swapping fee tokens to WYND + /// The maximum spread used when swapping fee tokens to PALOMA pub max_spread: Decimal, } @@ -87,7 +87,7 @@ pub struct RoutesResponse { #[cw_serde] pub struct MigrateMsg {} -/// This struct holds parameters to help with swapping a specific amount of a fee token to WYND. +/// This struct holds parameters to help with swapping a specific amount of a fee token to PALOMA. #[cw_serde] pub struct AssetWithLimit { /// Information about the fee token to swap diff --git a/contracts/nominated-trader/src/multitest/flows.rs b/contracts/nominated-trader/src/multitest/flows.rs index 22ea91b..8ced4d3 100644 --- a/contracts/nominated-trader/src/multitest/flows.rs +++ b/contracts/nominated-trader/src/multitest/flows.rs @@ -11,8 +11,8 @@ mod fail_cases { use crate::multitest::suite::SuiteBuilder; use cosmwasm_std::{Addr, Uint128}; - use wyndex::asset::token_asset_info; - use wyndex::asset::AssetInfo; + use palomadex::asset::token_asset_info; + use palomadex::asset::AssetInfo; #[test] fn collect_without_any_routes() { @@ -20,9 +20,9 @@ mod fail_cases { let owner = suite.owner.clone(); - let token = suite.instantiate_token(&owner, "wynd"); + let token = suite.instantiate_token(&owner, "grain"); - let token_to_swap = suite.instantiate_token(&owner, "notwynd"); + let token_to_swap = suite.instantiate_token(&owner, "notgrain"); let nominated_trader_contract = suite .setup_trader( @@ -64,9 +64,9 @@ mod fail_cases { let owner = suite.owner.clone(); - let token = suite.instantiate_token(&owner, "wynd"); + let token = suite.instantiate_token(&owner, "grain"); - let token_to_swap = suite.instantiate_token(&owner, "notwynd"); + let token_to_swap = suite.instantiate_token(&owner, "notgrain"); let nominated_trader_contract = suite .setup_trader( @@ -110,9 +110,9 @@ mod fail_cases { let owner = suite.owner.clone(); - let token = suite.instantiate_token(&owner, "wynd"); + let token = suite.instantiate_token(&owner, "grain"); - let token_to_swap = suite.instantiate_token(&owner, "notwynd"); + let token_to_swap = suite.instantiate_token(&owner, "notgrain"); let nominated_trader_contract = suite .setup_trader( @@ -156,9 +156,9 @@ mod fail_cases { let owner = suite.owner.clone(); - let token = suite.instantiate_token(&owner, "wynd"); + let token = suite.instantiate_token(&owner, "grain"); - let token_to_swap = suite.instantiate_token(&owner, "notwynd"); + let token_to_swap = suite.instantiate_token(&owner, "notgrain"); let nominated_trader_contract = suite .setup_trader( @@ -206,9 +206,9 @@ mod fail_cases { let owner = suite.owner.clone(); - let token = suite.instantiate_token(&owner, "wynd"); + let token = suite.instantiate_token(&owner, "grain"); - let token_to_swap = suite.instantiate_token(&owner, "notwynd"); + let token_to_swap = suite.instantiate_token(&owner, "notgrain"); let nominated_trader_contract = suite .setup_trader( @@ -242,8 +242,8 @@ mod trader_flows { use crate::multitest::suite::SuiteBuilder; use cosmwasm_std::{assert_approx_eq, coin, Addr, Uint128}; - use wyndex::asset::{native_asset_info, token_asset_info}; - use wyndex::{asset::AssetInfo, factory::PairType}; + use palomadex::asset::{native_asset_info, token_asset_info}; + use palomadex::{asset::AssetInfo, factory::PairType}; #[test] // This test ensures that an owner can both add and remove assets as designated routes @@ -255,9 +255,9 @@ mod trader_flows { let owner = suite.owner.clone(); - let token = suite.instantiate_token(&owner, "wynd"); + let token = suite.instantiate_token(&owner, "grain"); - let token_to_swap = suite.instantiate_token(&owner, "notwynd"); + let token_to_swap = suite.instantiate_token(&owner, "notgrain"); let nominated_trader_contract = suite .setup_trader( @@ -378,7 +378,7 @@ mod trader_flows { let owner = suite.owner.clone(); - let token_to_swap = suite.instantiate_token(&owner, "notwynd"); + let token_to_swap = suite.instantiate_token(&owner, "notgrain"); let nominated_trader_contract = suite .setup_trader( @@ -451,9 +451,9 @@ mod trader_flows { let owner = suite.owner.clone(); - let token = suite.instantiate_token(&owner, "wynd"); + let token = suite.instantiate_token(&owner, "grain"); - let token_to_swap = suite.instantiate_token(&owner, "notwynd"); + let token_to_swap = suite.instantiate_token(&owner, "notgrain"); let nominated_trader_contract = suite .setup_trader( @@ -557,8 +557,8 @@ mod trader_flows { let owner = suite.owner.clone(); - let token = suite.instantiate_token(&owner, "wynd"); - let token_to_swap = suite.instantiate_token(&owner, "notwynd"); + let token = suite.instantiate_token(&owner, "grain"); + let token_to_swap = suite.instantiate_token(&owner, "notgrain"); let nominated_trader_contract = suite .setup_trader( @@ -669,7 +669,7 @@ mod trader_flows { let owner = suite.owner.clone(); - let token = suite.instantiate_token(&owner, "wynd"); + let token = suite.instantiate_token(&owner, "grain"); let nominated_trader_contract = suite .setup_trader( @@ -720,9 +720,9 @@ mod trader_flows { let owner = suite.owner.clone(); - let token = suite.instantiate_token(&owner, "wynd"); + let token = suite.instantiate_token(&owner, "grain"); - let token_to_swap = suite.instantiate_token(&owner, "notwynd"); + let token_to_swap = suite.instantiate_token(&owner, "notgrain"); let bridge = suite.instantiate_token(&owner, "bridge"); diff --git a/contracts/nominated-trader/src/multitest/suite.rs b/contracts/nominated-trader/src/multitest/suite.rs index 324af66..f585ea6 100644 --- a/contracts/nominated-trader/src/multitest/suite.rs +++ b/contracts/nominated-trader/src/multitest/suite.rs @@ -5,13 +5,13 @@ use cw20::{BalanceResponse, Cw20ExecuteMsg, Cw20QueryMsg, MinterResponse}; use cw20_base::msg::InstantiateMsg as Cw20BaseInstantiateMsg; use cw_multi_test::{App, AppResponse, BankSudo, ContractWrapper, Executor, SudoMsg}; -use wyndex::asset::{Asset, AssetInfo}; -use wyndex::factory::{ +use palomadex::asset::{Asset, AssetInfo}; +use palomadex::factory::{ DefaultStakeConfig, ExecuteMsg as FactoryExecuteMsg, InstantiateMsg as FactoryInstantiateMsg, PairConfig, PairType, PartialStakeConfig, QueryMsg as FactoryQueryMsg, }; -use wyndex::fee_config::FeeConfig; -use wyndex::pair::{ExecuteMsg as PairExecuteMsg, PairInfo}; +use palomadex::fee_config::FeeConfig; +use palomadex::pair::{ExecuteMsg as PairExecuteMsg, PairInfo}; use crate::msg::AssetWithLimit; use crate::msg::BalancesResponse as TraderBalancesResponse; @@ -31,11 +31,11 @@ fn contract_trader(app: &mut App) -> u64 { fn store_factory(app: &mut App) -> u64 { let contract = Box::new( ContractWrapper::new_with_empty( - wyndex_factory::contract::execute, - wyndex_factory::contract::instantiate, - wyndex_factory::contract::query, + palomadex_factory::contract::execute, + palomadex_factory::contract::instantiate, + palomadex_factory::contract::query, ) - .with_reply_empty(wyndex_factory::contract::reply), + .with_reply_empty(palomadex_factory::contract::reply), ); app.store_code(contract) @@ -43,9 +43,9 @@ fn store_factory(app: &mut App) -> u64 { fn store_staking(app: &mut App) -> u64 { let contract = Box::new(ContractWrapper::new_with_empty( - wyndex_stake::contract::execute, - wyndex_stake::contract::instantiate, - wyndex_stake::contract::query, + palomadex_stake::contract::execute, + palomadex_stake::contract::instantiate, + palomadex_stake::contract::query, )); app.store_code(contract) @@ -54,11 +54,11 @@ fn store_staking(app: &mut App) -> u64 { fn store_pair(app: &mut App) -> u64 { let contract = Box::new( ContractWrapper::new_with_empty( - wyndex_pair::contract::execute, - wyndex_pair::contract::instantiate, - wyndex_pair::contract::query, + palomadex_pair::contract::execute, + palomadex_pair::contract::instantiate, + palomadex_pair::contract::query, ) - .with_reply_empty(wyndex_pair::contract::reply), + .with_reply_empty(palomadex_pair::contract::reply), ); app.store_code(contract) @@ -140,7 +140,7 @@ impl SuiteBuilder { trading_starts: None, }, &[], - "Wyndex Factory", + "Palomadex Factory", None, ) .unwrap(); diff --git a/contracts/nominated-trader/src/state.rs b/contracts/nominated-trader/src/state.rs index f993159..b228067 100644 --- a/contracts/nominated-trader/src/state.rs +++ b/contracts/nominated-trader/src/state.rs @@ -1,26 +1,26 @@ use cosmwasm_schema::cw_serde; use cosmwasm_std::{Addr, Decimal}; use cw_storage_plus::{Item, Map}; -use wyndex::asset::{AssetInfo, AssetInfoValidated}; +use palomadex::asset::{AssetInfo, AssetInfoValidated}; #[cw_serde] pub struct Config { /// Address that's allowed to change contract parameters pub owner: Addr, - /// Address that's allowed to perform swaps and convert fee tokens to Wynd as needed + /// Address that's allowed to perform swaps and convert fee tokens to Paloma as needed pub nominated_trader: Addr, /// Address specified to receive any payouts usually distinct from the nominated_trader address pub beneficiary: Addr, - /// The WYND token contract address + /// The Grain token contract address pub token_contract: AssetInfoValidated, - /// The Wyndex factory contract address + /// The Palomadex factory contract address pub dex_factory_contract: Addr, - /// The maximum spread used when swapping fee tokens to WYND + /// The maximum spread used when swapping fee tokens to PALOMA pub max_spread: Decimal, } /// Stores the contract configuration at the given key pub const CONFIG: Item = Item::new("config"); -/// Stores bridge tokens used to swap fee tokens to WYND +/// Stores bridge tokens used to swap fee tokens to PALOMA pub const ROUTES: Map = Map::new("routes"); diff --git a/contracts/nominated-trader/src/utils.rs b/contracts/nominated-trader/src/utils.rs index 397673f..b70e09d 100644 --- a/contracts/nominated-trader/src/utils.rs +++ b/contracts/nominated-trader/src/utils.rs @@ -1,12 +1,12 @@ use crate::error::ContractError; use crate::state::{Config, ROUTES}; -use wyndex::asset::{Asset, AssetInfo}; -use wyndex::pair::PairInfo; +use palomadex::asset::{Asset, AssetInfo}; +use palomadex::pair::PairInfo; use cosmwasm_std::{ to_binary, Addr, Coin, Decimal, Deps, QuerierWrapper, StdResult, SubMsg, Uint128, WasmMsg, }; -use wyndex::pair::{Cw20HookMsg, SimulationResponse}; +use palomadex::pair::{Cw20HookMsg, SimulationResponse}; /// The default route depth for a fee token pub const ROUTES_INITIAL_DEPTH: u64 = 0; @@ -78,7 +78,7 @@ pub fn build_swap_msg( Ok(SubMsg::new(WasmMsg::Execute { contract_addr: pool.contract_addr.to_string(), - msg: to_binary(&wyndex::pair::ExecuteMsg::Swap { + msg: to_binary(&palomadex::pair::ExecuteMsg::Swap { offer_asset: offer_asset.clone(), ask_asset_info: to.cloned(), belief_price, @@ -119,7 +119,7 @@ pub fn build_swap_msg( /// /// * **to_token** asset we want to swap to. /// -/// * **desired token** represents $WYND. +/// * **desired token** represents $PALOMA. /// /// * **depth** current recursion depth of the validation. /// @@ -189,7 +189,7 @@ pub fn get_pool( amount: Option, ) -> Result<(PairInfo, Option), ContractError> { // We use raw query to save gas - let result = wyndex::factory::ROUTE.query( + let result = palomadex::factory::ROUTE.query( querier, factory_contract.clone(), (from.to_string(), to.to_string()), @@ -205,7 +205,7 @@ pub fn get_pool( // Perform a simulation swap to get the return amount for each pool let sim_res: SimulationResponse = querier.query_wasm_smart( &pair_contract, - &wyndex::pair::QueryMsg::Simulation { + &palomadex::pair::QueryMsg::Simulation { offer_asset: Asset { info: from.clone(), amount: amount.unwrap_or(SWAP_SIMULATION_AMOUNT), @@ -226,7 +226,7 @@ pub fn get_pool( .unwrap(); // Return the best pair's PairInfo and the return amount Ok(( - querier.query_wasm_smart(best_pair, &wyndex::pair::QueryMsg::Pair {})?, + querier.query_wasm_smart(best_pair, &palomadex::pair::QueryMsg::Pair {})?, Some(sim_res.return_amount), )) } diff --git a/contracts/pair/Cargo.toml b/contracts/pair/Cargo.toml index b30c8ce..70fb374 100644 --- a/contracts/pair/Cargo.toml +++ b/contracts/pair/Cargo.toml @@ -1,9 +1,9 @@ [package] -name = "wyndex-pair" +name = "palomadex-pair" version = { workspace = true } -authors = ["Cosmorama "] +authors = ["Volume Fi"] edition = { workspace = true } -description = "The Wyndex constant product pool contract implementation" +description = "The PalomaDex constant product pool contract implementation" license = { workspace = true } [lib] @@ -22,10 +22,10 @@ cw20 = { workspace = true } cw20-base = { workspace = true } cw-storage-plus = { workspace = true } cw-utils = { workspace = true } -wyndex-stake = { workspace = true } -wyndex = { workspace = true } +palomadex-stake = { workspace = true } +palomadex = { workspace = true } [dev-dependencies] cw-multi-test = { workspace = true } proptest = { workspace = true } -wyndex-factory = { workspace = true } +palomadex-factory = { workspace = true } diff --git a/contracts/pair/README.md b/contracts/pair/README.md index 9e9f7bd..4007a1e 100644 --- a/contracts/pair/README.md +++ b/contracts/pair/README.md @@ -1,4 +1,4 @@ -# Wyndex Constant Product Pair +# PalomaDex Constant Product Pair The constant product pool uses the widely known xy=k formula. More details around how the pool functions can be found [here](https://docs.astroport.fi/astroport/astroport/astro-pools/constant-product-pools). @@ -12,7 +12,7 @@ Whenever liquidity is deposited into a pool, special tokens known as "liquidity When providing liquidity from a smart contract, the most important thing to keep in mind is that the amount of tokens deposited into a pool and the amount of tokens withdrawn later from the pool will most likely not be the same. This is because of the way constant product pools work where, as the token prices in the pool change, so do the respective token amounts that a LP can withdraw. -As an example, let's say the global ratio between two tokens x:y is 10:2 (i.e. 1 x = 0.2 y), but the current ratio between the tokens in an Wyndex pair is 5:2 (1 x = 0.4 y). Let's also say that someone may decide to LP in the x:y Wyndex pool at the current 5:2 ratio. As the Wyndex pool gets arbitraged to the global ratio, the amount of x & y tokens that the LP can withdraw changes because the total amounts of x & y tokens in the pool also change. +As an example, let's say the global ratio between two tokens x:y is 10:2 (i.e. 1 x = 0.2 y), but the current ratio between the tokens in an PalomaDex pair is 5:2 (1 x = 0.4 y). Let's also say that someone may decide to LP in the x:y PalomaDex pool at the current 5:2 ratio. As the PalomaDex pool gets arbitraged to the global ratio, the amount of x & y tokens that the LP can withdraw changes because the total amounts of x & y tokens in the pool also change. > Note that before executing the `provide_liqudity` operation, a user must allow the pool contract to take tokens from their wallet @@ -26,7 +26,7 @@ As an example, let's say someone LPs in a pool and specifies a 1% slippage toler ### Slippage Tolerance for Swaps -Wyndex has two options to protect traders against slippage during swaps: +PalomaDex has two options to protect traders against slippage during swaps: 1. Providing `max_spread` The spread is calculated as the difference between the ask amount (using the constant pool price) before and after the swap operation. Once `max_spread` is set, it will be compared against the actual swap spread. In case the swap spread exceeds the provided max limit, the swap will fail. @@ -36,7 +36,7 @@ Note that the spread is calculated before commission deduction in order to prope 2. Providing `max_spread` + `belief_price` If `belief_price` is provided in combination with `max_spread`, the pool will check the difference between the return amount (using `belief_price`) and the real pool price. -Please note that Wyndex has the default value for the spread set to 0.5% and the max allowed spread set to 50%. +Please note that PalomaDex has the default value for the spread set to 0.5% and the max allowed spread set to 50%. ## InstantiateMsg diff --git a/contracts/pair/src/bin/pair_schema.rs b/contracts/pair/src/bin/pair_schema.rs index 08a7923..5ce162f 100644 --- a/contracts/pair/src/bin/pair_schema.rs +++ b/contracts/pair/src/bin/pair_schema.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::write_api; -use wyndex::pair::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use palomadex::pair::{ExecuteMsg, InstantiateMsg, QueryMsg}; fn main() { write_api! { diff --git a/contracts/pair/src/contract.rs b/contracts/pair/src/contract.rs index c811954..268b767 100644 --- a/contracts/pair/src/contract.rs +++ b/contracts/pair/src/contract.rs @@ -6,33 +6,27 @@ use cosmwasm_std::{ StdResult, Uint128, Uint256, WasmMsg, }; -use cw2::set_contract_version; use cw20::{Cw20ExecuteMsg, Cw20ReceiveMsg}; -use std::str::FromStr; -use std::vec; -use wyndex::asset::{ +use palomadex::asset::{ addr_opt_validate, check_swap_parameters, Asset, AssetInfoValidated, AssetValidated, MINIMUM_LIQUIDITY_AMOUNT, }; -use wyndex::decimal2decimal256; -use wyndex::factory::{ConfigResponse as FactoryConfig, PairType}; -use wyndex::fee_config::FeeConfig; -use wyndex::pair::{ +use palomadex::decimal2decimal256; +use palomadex::factory::{ConfigResponse as FactoryConfig, PairType}; +use palomadex::fee_config::FeeConfig; +use palomadex::pair::{ add_referral, assert_max_spread, check_asset_infos, check_assets, check_cw20_in_pool, create_lp_token, get_share_in_assets, handle_referral, handle_reply, migration_check, mint_token_message, save_tmp_staking_config, take_referral, ConfigResponse, ContractError, - Cw20HookMsg, MigrateMsg, DEFAULT_SLIPPAGE, MAX_ALLOWED_SLIPPAGE, + Cw20HookMsg, DEFAULT_SLIPPAGE, MAX_ALLOWED_SLIPPAGE, }; -use wyndex::pair::{ +use palomadex::pair::{ CumulativePricesResponse, ExecuteMsg, InstantiateMsg, PairInfo, PoolResponse, QueryMsg, ReverseSimulationResponse, SimulationResponse, TWAP_PRECISION, }; -use wyndex::querier::{query_factory_config, query_supply}; - -/// Contract name that is used for migration. -const CONTRACT_NAME: &str = "wyndex-pair"; -/// Contract version that is used for migration. -const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); +use palomadex::querier::{query_factory_config, query_supply}; +use std::str::FromStr; +use std::vec; /// Creates a new contract with the specified parameters in the [`InstantiateMsg`]. #[cfg_attr(not(feature = "library"), entry_point)] @@ -48,8 +42,6 @@ pub fn instantiate( return Err(ContractError::InvalidNumberOfAssets { min: 2, max: 2 }); } - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - msg.validate_fees()?; let factory_addr = deps.api.addr_validate(msg.factory_addr.as_str())?; @@ -95,24 +87,6 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result Result { - match msg { - MigrateMsg::UpdateFreeze { - frozen, - circuit_breaker, - } => { - FROZEN.save(deps.storage, &frozen)?; - if let Some(circuit_breaker) = circuit_breaker { - CIRCUIT_BREAKER.save(deps.storage, &deps.api.addr_validate(&circuit_breaker)?)?; - } - } - } - - Ok(Response::new()) -} - /// Exposes all the execute functions available in the contract. /// /// ## Variants @@ -465,9 +439,9 @@ pub fn provide_liquidity( let price = Decimal::from_ratio(new_pool0, new_pool1); if total_share.is_zero() { // initialize oracle storage - wyndex::oracle::initialize_oracle(deps.storage, &env, price)?; + palomadex::oracle::initialize_oracle(deps.storage, &env, price)?; } else { - wyndex::oracle::store_oracle_price(deps.storage, &env, price)?; + palomadex::oracle::store_oracle_price(deps.storage, &env, price)?; } // Accumulate prices for the assets in the pool @@ -515,7 +489,7 @@ pub fn withdraw_liquidity( .zip(refund_assets.iter()) .map(|(p, r)| p.amount - r.amount); let (new_pool0, new_pool1) = (new_pools.next().unwrap(), new_pools.next().unwrap()); - wyndex::oracle::store_oracle_price( + palomadex::oracle::store_oracle_price( deps.storage, &env, Decimal::from_ratio(new_pool0, new_pool1), @@ -757,7 +731,7 @@ fn do_swap( pools[1].amount - protocol_fee_amount - return_amount, ) }; - wyndex::oracle::store_oracle_price( + palomadex::oracle::store_oracle_price( deps.storage, env, Decimal::from_ratio(new_pool0, new_pool1), @@ -904,7 +878,7 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { duration, start_age, end_age, - } => to_binary(&wyndex::oracle::query_oracle_range( + } => to_binary(&palomadex::oracle::query_oracle_range( deps.storage, &env, &CONFIG.load(deps.storage)?.pair_info.asset_infos, diff --git a/contracts/pair/src/mock_querier.rs b/contracts/pair/src/mock_querier.rs index 8ab0529..3cf9063 100644 --- a/contracts/pair/src/mock_querier.rs +++ b/contracts/pair/src/mock_querier.rs @@ -6,13 +6,13 @@ use cosmwasm_std::{ use std::collections::HashMap; use cw20::{BalanceResponse, Cw20QueryMsg, TokenInfoResponse}; -use wyndex::factory::{ +use palomadex::factory::{ ConfigResponse, FeeInfoResponse, QueryMsg::{Config, FeeInfo}, }; /// mock_dependencies is a drop-in replacement for cosmwasm_std::testing::mock_dependencies. -/// This uses the Wyndex CustomQuerier. +/// This uses the Palomadex CustomQuerier. pub fn mock_dependencies( contract_balance: &[Coin], ) -> OwnedDeps { diff --git a/contracts/pair/src/state.rs b/contracts/pair/src/state.rs index 3aff9cd..7f22d4c 100644 --- a/contracts/pair/src/state.rs +++ b/contracts/pair/src/state.rs @@ -1,7 +1,7 @@ use cosmwasm_schema::cw_serde; use cosmwasm_std::{Addr, Uint128}; use cw_storage_plus::Item; -use wyndex::pair::PairInfo; +use palomadex::pair::PairInfo; /// This structure stores the main config parameters for a constant product pair contract. #[cw_serde] diff --git a/contracts/pair/src/testing.rs b/contracts/pair/src/testing.rs index f241fc1..204917b 100644 --- a/contracts/pair/src/testing.rs +++ b/contracts/pair/src/testing.rs @@ -9,21 +9,21 @@ use cw_utils::MsgInstantiateContractResponse; use proptest::prelude::*; use cw20_base::msg::InstantiateMsg as TokenInstantiateMsg; -use wyndex::asset::{ +use palomadex::asset::{ Asset, AssetInfo, AssetInfoValidated, AssetValidated, MINIMUM_LIQUIDITY_AMOUNT, }; -use wyndex::factory::PairType; -use wyndex::fee_config::FeeConfig; -use wyndex::oracle::{SamplePeriod, TwapResponse}; -use wyndex::pair::{ +use palomadex::factory::PairType; +use palomadex::fee_config::FeeConfig; +use palomadex::oracle::{SamplePeriod, TwapResponse}; +use palomadex::pair::{ assert_max_spread, ContractError, Cw20HookMsg, ExecuteMsg, InstantiateMsg, PairInfo, PoolResponse, ReverseSimulationResponse, SimulationResponse, StakeConfig, TWAP_PRECISION, }; -use wyndex::pair::{MigrateMsg, QueryMsg}; +use palomadex::pair::{MigrateMsg, QueryMsg}; use crate::contract::{ - accumulate_prices, compute_swap, execute, instantiate, migrate, query_pool, - query_reverse_simulation, query_share, query_simulation, + accumulate_prices, compute_swap, execute, instantiate, query_pool, query_reverse_simulation, + query_share, query_simulation, }; use crate::contract::{compute_offer_amount, query}; use crate::state::{Config, CONFIG}; @@ -37,7 +37,7 @@ fn store_liquidity_token(deps: DepsMut, contract_addr: String) { }; let mut config = CONFIG.load(deps.storage).unwrap(); - let _res = wyndex::pair::instantiate_lp_token_reply( + let _res = palomadex::pair::instantiate_lp_token_reply( &deps, res, &config.factory_addr, @@ -108,7 +108,7 @@ fn proper_initialization() { .unwrap(), funds: vec![], admin: Some("owner".to_owned()), - label: String::from("Wyndex LP token"), + label: String::from("Palomadex LP token"), } .into(), id: 1, @@ -240,17 +240,6 @@ fn test_freezing_a_pool_blocking_actions_then_unfreeze() { ), ]); - // Migrate with the freeze migrate message - migrate( - deps.as_mut(), - env.clone(), - MigrateMsg::UpdateFreeze { - frozen: true, - circuit_breaker: Some("addr0000".to_string()), - }, - ) - .unwrap(); - // Failing Execute Actions due to frozen // This should now fail, its a good TX with all the normal setup done but because of freezing it should fail @@ -940,7 +929,7 @@ fn withdraw_liquidity() { store_liquidity_token(deps.as_mut(), "liquidity0000".to_string()); // need to initialize oracle, because we don't call `provide_liquidity` in this test - wyndex::oracle::initialize_oracle( + palomadex::oracle::initialize_oracle( &mut deps.storage, &mock_env_with_block_time(0), Decimal::one(), @@ -1230,7 +1219,7 @@ fn try_native_to_token() { store_liquidity_token(deps.as_mut(), "liquidity0000".to_string()); // need to initialize oracle, because we don't call `provide_liquidity` in this test - wyndex::oracle::initialize_oracle( + palomadex::oracle::initialize_oracle( &mut deps.storage, &mock_env_with_block_time(0), Decimal::one(), @@ -1448,7 +1437,7 @@ fn try_token_to_native() { store_liquidity_token(deps.as_mut(), "liquidity0000".to_string()); // need to initialize oracle, because we don't call `provide_liquidity` in this test - wyndex::oracle::initialize_oracle( + palomadex::oracle::initialize_oracle( &mut deps.storage, &mock_env_with_block_time(0), Decimal::one(), diff --git a/contracts/pair/tests/integration.rs b/contracts/pair/tests/integration.rs index f8517b3..fdaf5b1 100644 --- a/contracts/pair/tests/integration.rs +++ b/contracts/pair/tests/integration.rs @@ -2,17 +2,17 @@ use cosmwasm_std::{attr, to_binary, Addr, Coin, Decimal, Uint128}; use cw20::{BalanceResponse, Cw20Coin, Cw20ExecuteMsg, Cw20QueryMsg, MinterResponse}; use cw20_base::msg::InstantiateMsg as TokenInstantiateMsg; use cw_multi_test::{App, ContractWrapper, Executor}; -use wyndex::asset::{native_asset_info, Asset, AssetInfo, AssetInfoExt, AssetInfoValidated}; -use wyndex::factory::{ +use palomadex::asset::{native_asset_info, Asset, AssetInfo, AssetInfoExt, AssetInfoValidated}; +use palomadex::factory::{ DefaultStakeConfig, ExecuteMsg as FactoryExecuteMsg, InstantiateMsg as FactoryInstantiateMsg, PairConfig, PairType, PartialStakeConfig, QueryMsg as FactoryQueryMsg, }; -use wyndex::fee_config::FeeConfig; -use wyndex::pair::{ +use palomadex::fee_config::FeeConfig; +use palomadex::pair::{ ConfigResponse, CumulativePricesResponse, Cw20HookMsg, ExecuteMsg, InstantiateMsg, PairInfo, PoolResponse, QueryMsg, SimulationResponse, TWAP_PRECISION, }; -use wyndex::querier::query_token_balance; +use palomadex::querier::query_token_balance; const OWNER: &str = "owner"; @@ -36,11 +36,11 @@ fn store_token_code(app: &mut App) -> u64 { fn store_pair_code(app: &mut App) -> u64 { let pair_contract = Box::new( ContractWrapper::new_with_empty( - wyndex_pair::contract::execute, - wyndex_pair::contract::instantiate, - wyndex_pair::contract::query, + palomadex_pair::contract::execute, + palomadex_pair::contract::instantiate, + palomadex_pair::contract::query, ) - .with_reply_empty(wyndex_pair::contract::reply), + .with_reply_empty(palomadex_pair::contract::reply), ); app.store_code(pair_contract) @@ -49,11 +49,11 @@ fn store_pair_code(app: &mut App) -> u64 { fn store_factory_code(app: &mut App) -> u64 { let factory_contract = Box::new( ContractWrapper::new_with_empty( - wyndex_factory::contract::execute, - wyndex_factory::contract::instantiate, - wyndex_factory::contract::query, + palomadex_factory::contract::execute, + palomadex_factory::contract::instantiate, + palomadex_factory::contract::query, ) - .with_reply_empty(wyndex_factory::contract::reply), + .with_reply_empty(palomadex_factory::contract::reply), ); app.store_code(factory_contract) @@ -61,9 +61,9 @@ fn store_factory_code(app: &mut App) -> u64 { fn store_staking_code(app: &mut App) -> u64 { let stake_contract = Box::new(ContractWrapper::new_with_empty( - wyndex_stake::contract::execute, - wyndex_stake::contract::instantiate, - wyndex_stake::contract::query, + palomadex_stake::contract::execute, + palomadex_stake::contract::instantiate, + palomadex_stake::contract::query, )); app.store_code(stake_contract) diff --git a/contracts/pair_lsd/Cargo.toml b/contracts/pair_lsd/Cargo.toml index e8a0177..fd1d5b0 100644 --- a/contracts/pair_lsd/Cargo.toml +++ b/contracts/pair_lsd/Cargo.toml @@ -1,7 +1,7 @@ [package] -name = "wyndex-pair-lsd" +name = "palomadex-pair-lsd" version = { workspace = true } -authors = ["Cosmorama "] +authors = ["Volume Fi"] edition = { workspace = true } description = "The Wydex stableswap pair contract implementation" license = { workspace = true } @@ -32,13 +32,13 @@ cw20-base = { workspace = true } cw-storage-plus = { workspace = true } cw-utils = { workspace = true } itertools = { workspace = true } -wyndex = { workspace = true } +palomadex = { workspace = true } [dev-dependencies] anyhow = { workspace = true } cw-multi-test = { workspace = true } derivative = { workspace = true } proptest = { workspace = true } -wyndex-factory = { workspace = true } -wyndex-stake = { workspace = true } -wyndex-pair = { workspace = true } +palomadex-factory = { workspace = true } +palomadex-stake = { workspace = true } +palomadex-pair = { workspace = true } diff --git a/contracts/pair_lsd/README.md b/contracts/pair_lsd/README.md index b158295..e62f211 100644 --- a/contracts/pair_lsd/README.md +++ b/contracts/pair_lsd/README.md @@ -1,4 +1,4 @@ -# Wyndex Base Stableswap Pair +# PalomaDex Base Stableswap Pair The stableswap pool uses the 4A(Rx+Ry) + D formula, resulting in a constant price ∆x / ∆y = 1. More details around how the pool functions can be found [here](https://docs.astroport.fi/astroport/astroport/astro-pools/stableswap-invariant-pools). @@ -12,7 +12,7 @@ Whenever liquidity is deposited into a pool, special tokens known as "liquidity When providing liquidity from a smart contract, the most important thing to keep in mind is that the amount of tokens deposited into a pool and the amount of tokens withdrawn later from the pool will most likely not be the same (even if stableswap encourages a constant 1:1 ratio between all assets in the pool). -As an example, let's say the global ratio between two tokens x:y is 1.01:1 (1 x = 0.99 y), but the current ratio between the tokens in an Wyndex pair is 1:1.01 (1 x = 1.01 y). Let's also say that someone may decide to LP in the x:y Wyndex pool at the current 1:1.01 ratio. As the Wyndex pool gets arbitraged to the global ratio, the amount of x & y tokens that the LP can withdraw changes because the total amounts of x & y tokens in the pool also change. +As an example, let's say the global ratio between two tokens x:y is 1.01:1 (1 x = 0.99 y), but the current ratio between the tokens in an PalomaDex pair is 1:1.01 (1 x = 1.01 y). Let's also say that someone may decide to LP in the x:y PalomaDex pool at the current 1:1.01 ratio. As the PalomaDex pool gets arbitraged to the global ratio, the amount of x & y tokens that the LP can withdraw changes because the total amounts of x & y tokens in the pool also change. > Note that before executing the `provide_liqudity` operation, a user must allow the pool contract to take tokens from their wallet @@ -26,7 +26,7 @@ As an example, let's say someone LPs in a pool and specifies a 1% slippage toler ### Slippage Tolerance for Swaps -Wyndex has two options to protect traders against slippage during swaps: +PalomaDex has two options to protect traders against slippage during swaps: 1. Providing `max_spread` The spread is calculated as the difference between the ask amount (using the constant pool price) before and after the swap operation. @@ -38,7 +38,7 @@ Note that the spread is calculated before commission deduction in order to prope 2. Providing `max_spread` + `belief_price` If `belief_price` is provided in combination with `max_spread`, the pool will check the difference between the return amount (using `belief_price`) and the real pool price. -Please note that Wyndex has the default value for the spread set to 0.5% and the max allowed spread set to 50%. +Please note that PalomaDex has the default value for the spread set to 0.5% and the max allowed spread set to 50%. ## Known Issues diff --git a/contracts/pair_lsd/src/bin/pair_stable_schema.rs b/contracts/pair_lsd/src/bin/pair_stable_schema.rs index 08a7923..5ce162f 100644 --- a/contracts/pair_lsd/src/bin/pair_stable_schema.rs +++ b/contracts/pair_lsd/src/bin/pair_stable_schema.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::write_api; -use wyndex::pair::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use palomadex::pair::{ExecuteMsg, InstantiateMsg, QueryMsg}; fn main() { write_api! { diff --git a/contracts/pair_lsd/src/contract.rs b/contracts/pair_lsd/src/contract.rs index 40c6e8f..fb8d9b4 100644 --- a/contracts/pair_lsd/src/contract.rs +++ b/contracts/pair_lsd/src/contract.rs @@ -8,30 +8,29 @@ use cosmwasm_std::{ Decimal256, Deps, DepsMut, Empty, Env, Fraction, MessageInfo, QuerierWrapper, Reply, Response, StdError, StdResult, Uint128, Uint256, WasmMsg, }; -use cw2::set_contract_version; use cw20::{Cw20ExecuteMsg, Cw20ReceiveMsg}; use itertools::Itertools; -use wyndex::asset::{ +use palomadex::asset::{ addr_opt_validate, check_swap_parameters, Asset, AssetInfo, AssetInfoValidated, AssetValidated, Decimal256Ext, DecimalAsset, MINIMUM_LIQUIDITY_AMOUNT, }; -use wyndex::common::{claim_ownership, drop_ownership_proposal, propose_new_owner}; -use wyndex::factory::PairType; -use wyndex::fee_config::FeeConfig; -use wyndex::pair::{ +use palomadex::common::{claim_ownership, drop_ownership_proposal, propose_new_owner}; +use palomadex::factory::PairType; +use palomadex::fee_config::FeeConfig; +use palomadex::pair::{ add_referral, assert_max_spread, check_asset_infos, check_assets, check_cw20_in_pool, create_lp_token, get_share_in_assets, handle_referral, handle_reply, migration_check, mint_token_message, save_tmp_staking_config, take_referral, ConfigResponse, Cw20HookMsg, InstantiateMsg, MigrateMsg, SpotPricePredictionResponse, SpotPriceResponse, StablePoolParams, StablePoolUpdateParams, }; -use wyndex::pair::{ +use palomadex::pair::{ CumulativePricesResponse, ExecuteMsg, PairInfo, PoolResponse, QueryMsg, ReverseSimulationResponse, SimulationResponse, StablePoolConfig, }; -use wyndex::querier::{query_factory_config, query_fee_info, query_supply}; -use wyndex::DecimalCheckedOps; +use palomadex::querier::{query_factory_config, query_fee_info, query_supply}; +use palomadex::DecimalCheckedOps; use crate::math::{ calc_y, compute_d, AMP_PRECISION, MAX_AMP, MAX_AMP_CHANGE, MIN_AMP_CHANGING_TIME, @@ -45,12 +44,7 @@ use crate::utils::{ accumulate_prices, adjust_precision, calc_new_price_a_per_b, calc_spot_price, compute_current_amp, compute_swap, find_spot_price, select_pools, SwapResult, }; -use wyndex::pair::ContractError; - -/// Contract name that is used for migration. -const CONTRACT_NAME: &str = "wyndex-pair-lsd"; -/// Contract version that is used for migration. -const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); +use palomadex::pair::ContractError; const WEEK: u64 = 7 * 24 * 60 * 60; @@ -97,8 +91,6 @@ pub fn instantiate( None }; - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - let greatest_precision = store_precisions(deps.branch(), &asset_infos)?; // Initializing cumulative prices @@ -606,9 +598,9 @@ pub fn provide_liquidity( if total_share.is_zero() { // initialize oracle storage - wyndex::oracle::initialize_oracle(deps.storage, &env, new_price)?; + palomadex::oracle::initialize_oracle(deps.storage, &env, new_price)?; } else { - wyndex::oracle::store_oracle_price(deps.storage, &env, new_price)?; + palomadex::oracle::store_oracle_price(deps.storage, &env, new_price)?; } if accumulate_prices(deps.as_ref(), &env, &mut config, &old_pools)? || save_config { @@ -712,7 +704,7 @@ pub fn withdraw_liquidity( }) .collect::>>()?; let new_price = calc_new_price_a_per_b(deps.as_ref(), &env, &config, &new_pools)?; - wyndex::oracle::store_oracle_price(deps.storage, &env, new_price)?; + palomadex::oracle::store_oracle_price(deps.storage, &env, new_price)?; if accumulate_prices(deps.as_ref(), &env, &mut config, &old_pools)? || save_config { CONFIG.save(deps.storage, &config)?; @@ -1020,7 +1012,7 @@ pub fn swap( }) .collect::>>()?; let new_price = calc_new_price_a_per_b(deps.as_ref(), &env, &config, &new_pools)?; - wyndex::oracle::store_oracle_price(deps.storage, &env, new_price)?; + palomadex::oracle::store_oracle_price(deps.storage, &env, new_price)?; if accumulate_prices(deps.as_ref(), &env, &mut config, &pools)? || save_config { CONFIG.save(deps.storage, &config)?; @@ -1129,7 +1121,7 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { duration, start_age, end_age, - } => to_binary(&wyndex::oracle::query_oracle_range( + } => to_binary(&palomadex::oracle::query_oracle_range( deps.storage, &env, &CONFIG.load(deps.storage)?.pair_info.asset_infos, diff --git a/contracts/pair_lsd/src/math.rs b/contracts/pair_lsd/src/math.rs index c9d28ea..80999e0 100644 --- a/contracts/pair_lsd/src/math.rs +++ b/contracts/pair_lsd/src/math.rs @@ -1,7 +1,7 @@ use crate::state::Config; use cosmwasm_std::{Decimal256, Fraction, StdError, StdResult, Uint128, Uint256, Uint64}; use itertools::Itertools; -use wyndex::asset::{AssetInfoValidated, Decimal256Ext, DecimalAsset}; +use palomadex::asset::{AssetInfoValidated, Decimal256Ext, DecimalAsset}; /// The maximum number of calculation steps for Newton's method. const ITERATIONS: u8 = 32; @@ -184,9 +184,9 @@ fn inverse_rate(to: &AssetInfoValidated, y: Uint128, config: &Config) -> Uint128 mod tests { use super::*; use cosmwasm_std::{Uint128, Uint256}; + use palomadex::asset::native_asset; + use palomadex::querier::NATIVE_TOKEN_PRECISION; use sim::StableSwapModel; - use wyndex::asset::native_asset; - use wyndex::querier::NATIVE_TOKEN_PRECISION; #[test] fn test_compute_d() { diff --git a/contracts/pair_lsd/src/mock_querier.rs b/contracts/pair_lsd/src/mock_querier.rs index 8ab0529..3cf9063 100644 --- a/contracts/pair_lsd/src/mock_querier.rs +++ b/contracts/pair_lsd/src/mock_querier.rs @@ -6,13 +6,13 @@ use cosmwasm_std::{ use std::collections::HashMap; use cw20::{BalanceResponse, Cw20QueryMsg, TokenInfoResponse}; -use wyndex::factory::{ +use palomadex::factory::{ ConfigResponse, FeeInfoResponse, QueryMsg::{Config, FeeInfo}, }; /// mock_dependencies is a drop-in replacement for cosmwasm_std::testing::mock_dependencies. -/// This uses the Wyndex CustomQuerier. +/// This uses the Palomadex CustomQuerier. pub fn mock_dependencies( contract_balance: &[Coin], ) -> OwnedDeps { diff --git a/contracts/pair_lsd/src/multitest/simulation.rs b/contracts/pair_lsd/src/multitest/simulation.rs index d961d30..1a34fd1 100644 --- a/contracts/pair_lsd/src/multitest/simulation.rs +++ b/contracts/pair_lsd/src/multitest/simulation.rs @@ -2,8 +2,8 @@ use std::str::FromStr; use cosmwasm_std::{assert_approx_eq, coin, Addr, Decimal, Fraction, Uint128}; use cw_multi_test::AppResponse; -use wyndex::pair::LsdInfo; -use wyndex::{ +use palomadex::pair::LsdInfo; +use palomadex::{ asset::{Asset, AssetInfo, AssetInfoExt}, factory::PairType, pair::StablePoolParams, diff --git a/contracts/pair_lsd/src/multitest/suite.rs b/contracts/pair_lsd/src/multitest/suite.rs index dce1e28..b8f5cf5 100644 --- a/contracts/pair_lsd/src/multitest/suite.rs +++ b/contracts/pair_lsd/src/multitest/suite.rs @@ -5,13 +5,13 @@ use cw20::{BalanceResponse, Cw20ExecuteMsg, Cw20QueryMsg, MinterResponse}; use cw20_base::msg::InstantiateMsg as Cw20BaseInstantiateMsg; use cw_multi_test::{App, AppResponse, BankSudo, ContractWrapper, Executor, SudoMsg}; -use wyndex::asset::{Asset, AssetInfo}; -use wyndex::factory::{ +use palomadex::asset::{Asset, AssetInfo}; +use palomadex::factory::{ DefaultStakeConfig, ExecuteMsg as FactoryExecuteMsg, InstantiateMsg as FactoryInstantiateMsg, PairConfig, PairType, QueryMsg as FactoryQueryMsg, }; -use wyndex::fee_config::FeeConfig; -use wyndex::pair::{ +use palomadex::fee_config::FeeConfig; +use palomadex::pair::{ Cw20HookMsg, ExecuteMsg as PairExecuteMsg, PairInfo, QueryMsg, SimulationResponse, SpotPricePredictionResponse, SpotPriceResponse, StablePoolParams, StablePoolUpdateParams, }; @@ -33,11 +33,11 @@ fn store_mock_hub(app: &mut App) -> u64 { fn store_factory(app: &mut App) -> u64 { let contract = Box::new( ContractWrapper::new_with_empty( - wyndex_factory::contract::execute, - wyndex_factory::contract::instantiate, - wyndex_factory::contract::query, + palomadex_factory::contract::execute, + palomadex_factory::contract::instantiate, + palomadex_factory::contract::query, ) - .with_reply_empty(wyndex_factory::contract::reply), + .with_reply_empty(palomadex_factory::contract::reply), ); app.store_code(contract) @@ -59,11 +59,11 @@ fn store_pair(app: &mut App) -> u64 { fn store_xyk_pair(app: &mut App) -> u64 { let contract = Box::new( ContractWrapper::new_with_empty( - wyndex_pair::contract::execute, - wyndex_pair::contract::instantiate, - wyndex_pair::contract::query, + palomadex_pair::contract::execute, + palomadex_pair::contract::instantiate, + palomadex_pair::contract::query, ) - .with_reply_empty(wyndex_pair::contract::reply), + .with_reply_empty(palomadex_pair::contract::reply), ); app.store_code(contract) @@ -81,9 +81,9 @@ fn store_cw20(app: &mut App) -> u64 { fn store_staking(app: &mut App) -> u64 { let contract = Box::new(ContractWrapper::new( - wyndex_stake::contract::execute, - wyndex_stake::contract::instantiate, - wyndex_stake::contract::query, + palomadex_stake::contract::execute, + palomadex_stake::contract::instantiate, + palomadex_stake::contract::query, )); app.store_code(contract) @@ -190,7 +190,7 @@ impl SuiteBuilder { trading_starts: None, }, &[], - "Wyndex Factory", + "Palomadex Factory", None, ) .unwrap(); diff --git a/contracts/pair_lsd/src/multitest/target_rate.rs b/contracts/pair_lsd/src/multitest/target_rate.rs index aeac144..d520412 100644 --- a/contracts/pair_lsd/src/multitest/target_rate.rs +++ b/contracts/pair_lsd/src/multitest/target_rate.rs @@ -2,8 +2,8 @@ use std::str::FromStr; use cosmwasm_std::{assert_approx_eq, coin, Addr, Decimal, Fraction, Uint128}; use cw_multi_test::{BankSudo, SudoMsg}; -use wyndex::pair::LsdInfo; -use wyndex::{ +use palomadex::pair::LsdInfo; +use palomadex::{ asset::{AssetInfo, AssetInfoExt}, factory::PairType, pair::StablePoolParams, diff --git a/contracts/pair_lsd/src/state.rs b/contracts/pair_lsd/src/state.rs index 6965e57..bb4c74b 100644 --- a/contracts/pair_lsd/src/state.rs +++ b/contracts/pair_lsd/src/state.rs @@ -1,9 +1,9 @@ use cosmwasm_schema::cw_serde; use cosmwasm_std::{Addr, Decimal, DepsMut, StdResult, Storage, Uint128}; use cw_storage_plus::{Item, Map}; -use wyndex::asset::AssetInfoValidated; -use wyndex::common::OwnershipProposal; -use wyndex::pair::PairInfo; +use palomadex::asset::AssetInfoValidated; +use palomadex::common::OwnershipProposal; +use palomadex::pair::PairInfo; /// This structure stores the main stableswap pair parameters. #[cw_serde] diff --git a/contracts/pair_lsd/src/testing.rs b/contracts/pair_lsd/src/testing.rs index c3b83df..051e6db 100644 --- a/contracts/pair_lsd/src/testing.rs +++ b/contracts/pair_lsd/src/testing.rs @@ -1,7 +1,7 @@ use crate::contract::{execute, instantiate, migrate, query}; use crate::state::CONFIG; -use wyndex::fee_config::FeeConfig; -use wyndex::oracle::{SamplePeriod, TwapResponse}; +use palomadex::fee_config::FeeConfig; +use palomadex::oracle::{SamplePeriod, TwapResponse}; // TODO: Copied here just as a temporary measure use crate::mock_querier::mock_dependencies; @@ -13,8 +13,8 @@ use cosmwasm_std::{ use cw20::{Cw20ExecuteMsg, Cw20ReceiveMsg, MinterResponse}; use cw20_base::msg::InstantiateMsg as TokenInstantiateMsg; use cw_utils::MsgInstantiateContractResponse; -use wyndex::asset::{Asset, AssetInfo, AssetInfoValidated, MINIMUM_LIQUIDITY_AMOUNT}; -use wyndex::pair::{ +use palomadex::asset::{Asset, AssetInfo, AssetInfoValidated, MINIMUM_LIQUIDITY_AMOUNT}; +use palomadex::pair::{ ContractError, Cw20HookMsg, ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg, StablePoolParams, StakeConfig, }; @@ -36,7 +36,7 @@ fn store_liquidity_token(deps: DepsMut, contract_addr: String) { }; let mut config = CONFIG.load(deps.storage).unwrap(); - let _res = wyndex::pair::instantiate_lp_token_reply( + let _res = palomadex::pair::instantiate_lp_token_reply( &deps, res, &config.factory_addr, @@ -114,7 +114,7 @@ fn proper_initialization() { .unwrap(), funds: vec![], admin: Some("owner".to_owned()), - label: String::from("Wyndex LP token"), + label: String::from("Palomadex LP token"), } .into(), id: 1, @@ -926,7 +926,7 @@ fn withdraw_liquidity() { store_liquidity_token(deps.as_mut(), "liquidity0000".to_string()); // need to initialize oracle, because we don't call `provide_liquidity` in this test - wyndex::oracle::initialize_oracle( + palomadex::oracle::initialize_oracle( &mut deps.storage, &mock_env_with_block_time(0), Decimal::one(), @@ -1173,10 +1173,10 @@ fn query_twap() { mod disabled { use super::*; use crate::utils::{accumulate_prices, compute_swap, select_pools}; + use palomadex::factory::PairType; + use palomadex::querier::NATIVE_TOKEN_PRECISION; use proptest::prelude::*; use sim::StableSwapModel; - use wyndex::factory::PairType; - use wyndex::querier::NATIVE_TOKEN_PRECISION; use crate::contract::{ assert_max_spread, query_pool, query_reverse_simulation, query_share, query_simulation, @@ -1185,8 +1185,8 @@ mod disabled { use crate::state::{store_precisions, Config}; use cosmwasm_std::coin; use itertools::Itertools; - use wyndex::asset::{native_asset, native_asset_info, PairInfo}; - use wyndex::pair::{PoolResponse, SimulationResponse, TWAP_PRECISION}; + use palomadex::asset::{native_asset, native_asset_info, PairInfo}; + use palomadex::pair::{PoolResponse, SimulationResponse, TWAP_PRECISION}; #[test] fn try_native_to_token() { diff --git a/contracts/pair_lsd/src/utils.rs b/contracts/pair_lsd/src/utils.rs index 46fd5e5..7a65cb9 100644 --- a/contracts/pair_lsd/src/utils.rs +++ b/contracts/pair_lsd/src/utils.rs @@ -2,12 +2,12 @@ use cosmwasm_std::{Decimal, Decimal256, Deps, Env, StdResult, Storage, Uint128, use itertools::Itertools; use std::cmp::Ordering; -use wyndex::asset::{AssetInfoValidated, Decimal256Ext, DecimalAsset}; -use wyndex::pair::TWAP_PRECISION; +use palomadex::asset::{AssetInfoValidated, Decimal256Ext, DecimalAsset}; +use palomadex::pair::TWAP_PRECISION; use crate::math::{apply_rate, calc_y}; use crate::state::{get_precision, Config}; -use wyndex::pair::ContractError; +use palomadex::pair::ContractError; /// Select offer and ask pools based on given offer and ask infos. /// This function works with pools with up to 5 assets. Returns (offer_pool, ask_pool) in case of success. diff --git a/contracts/pair_lsd/tests/3pool_tests.rs b/contracts/pair_lsd/tests/3pool_tests.rs index 1120e85..1916928 100644 --- a/contracts/pair_lsd/tests/3pool_tests.rs +++ b/contracts/pair_lsd/tests/3pool_tests.rs @@ -2,8 +2,8 @@ use cosmwasm_std::Addr; use itertools::Itertools; use helper::AppExtension; -use wyndex::asset::AssetInfoExt; -use wyndex::pair::ContractError; +use palomadex::asset::AssetInfoExt; +use palomadex::pair::ContractError; use crate::helper::{Helper, TestCoin}; diff --git a/contracts/pair_lsd/tests/helper.rs b/contracts/pair_lsd/tests/helper.rs index 9fc21e8..7ddc132 100644 --- a/contracts/pair_lsd/tests/helper.rs +++ b/contracts/pair_lsd/tests/helper.rs @@ -8,17 +8,17 @@ use cw_multi_test::{App, AppResponse, Contract, ContractWrapper, Executor}; use derivative::Derivative; use itertools::Itertools; -use wyndex::asset::{ +use palomadex::asset::{ native_asset_info, token_asset_info, Asset, AssetInfo, AssetInfoValidated, AssetValidated, }; -use wyndex::factory::{DefaultStakeConfig, PairConfig, PairType, PartialStakeConfig}; -use wyndex::fee_config::FeeConfig; -use wyndex::pair::{ +use palomadex::factory::{DefaultStakeConfig, PairConfig, PairType, PartialStakeConfig}; +use palomadex::fee_config::FeeConfig; +use palomadex::pair::{ CumulativePricesResponse, Cw20HookMsg, ExecuteMsg, PairInfo, QueryMsg, ReverseSimulationResponse, SimulationResponse, StablePoolParams, }; -use wyndex::querier::NATIVE_TOKEN_PRECISION; -use wyndex_pair_lsd::contract::{execute, instantiate, query, reply}; +use palomadex::querier::NATIVE_TOKEN_PRECISION; +use palomadex_pair_lsd::contract::{execute, instantiate, query, reply}; const INIT_BALANCE: u128 = 1_000_000_000_000; @@ -86,19 +86,19 @@ fn pair_contract() -> Box> { fn factory_contract() -> Box> { Box::new( ContractWrapper::new_with_empty( - wyndex_factory::contract::execute, - wyndex_factory::contract::instantiate, - wyndex_factory::contract::query, + palomadex_factory::contract::execute, + palomadex_factory::contract::instantiate, + palomadex_factory::contract::query, ) - .with_reply_empty(wyndex_factory::contract::reply), + .with_reply_empty(palomadex_factory::contract::reply), ) } fn stake_contract() -> Box> { Box::new(ContractWrapper::new_with_empty( - wyndex_stake::contract::execute, - wyndex_stake::contract::instantiate, - wyndex_stake::contract::query, + palomadex_stake::contract::execute, + palomadex_stake::contract::instantiate, + palomadex_stake::contract::query, )) } @@ -148,7 +148,7 @@ impl Helper { let factory_code_id = app.store_code(factory_contract()); let staking_code_id = app.store_code(stake_contract()); - let init_msg = wyndex::factory::InstantiateMsg { + let init_msg = palomadex::factory::InstantiateMsg { fee_address: None, pair_configs: vec![PairConfig { code_id: pair_code_id, @@ -187,7 +187,7 @@ impl Helper { .into_iter() .map(|(_, asset_info)| asset_info) .collect_vec(); - let init_pair_msg = wyndex::factory::ExecuteMsg::CreatePair { + let init_pair_msg = palomadex::factory::ExecuteMsg::CreatePair { pair_type: PairType::Lsd {}, asset_infos: asset_infos.clone(), init_params: Some( @@ -204,9 +204,10 @@ impl Helper { app.execute_contract(owner.clone(), factory.clone(), &init_pair_msg, &[])?; - let resp: PairInfo = app - .wrap() - .query_wasm_smart(&factory, &wyndex::factory::QueryMsg::Pair { asset_infos })?; + let resp: PairInfo = app.wrap().query_wasm_smart( + &factory, + &palomadex::factory::QueryMsg::Pair { asset_infos }, + )?; Ok(Self { app, diff --git a/contracts/pair_lsd/tests/integration.rs b/contracts/pair_lsd/tests/integration.rs index 38702f5..cfb8bf1 100644 --- a/contracts/pair_lsd/tests/integration.rs +++ b/contracts/pair_lsd/tests/integration.rs @@ -1,10 +1,10 @@ -use wyndex::asset::{Asset, AssetInfo, AssetInfoExt, AssetInfoValidated}; -use wyndex::factory::{ +use palomadex::asset::{Asset, AssetInfo, AssetInfoExt, AssetInfoValidated}; +use palomadex::factory::{ DefaultStakeConfig, ExecuteMsg as FactoryExecuteMsg, InstantiateMsg as FactoryInstantiateMsg, PairConfig, PairType, PartialStakeConfig, QueryMsg as FactoryQueryMsg, }; -use wyndex::fee_config::FeeConfig; -use wyndex::pair::{ +use palomadex::fee_config::FeeConfig; +use palomadex::pair::{ ConfigResponse, CumulativePricesResponse, Cw20HookMsg, ExecuteMsg, InstantiateMsg, PairInfo, PoolResponse, QueryMsg, StablePoolConfig, StablePoolParams, StablePoolUpdateParams, TWAP_PRECISION, @@ -16,8 +16,8 @@ use cosmwasm_std::{ use cw20::{BalanceResponse, Cw20Coin, Cw20ExecuteMsg, Cw20QueryMsg, MinterResponse}; use cw20_base::msg::InstantiateMsg as TokenInstantiateMsg; use cw_multi_test::{App, ContractWrapper, Executor}; -use wyndex::querier::query_token_balance; -use wyndex_pair_lsd::math::{MAX_AMP, MAX_AMP_CHANGE, MIN_AMP_CHANGING_TIME}; +use palomadex::querier::query_token_balance; +use palomadex_pair_lsd::math::{MAX_AMP, MAX_AMP_CHANGE, MIN_AMP_CHANGING_TIME}; const OWNER: &str = "owner"; @@ -41,11 +41,11 @@ fn store_token_code(app: &mut App) -> u64 { fn store_pair_code(app: &mut App) -> u64 { let pair_contract = Box::new( ContractWrapper::new_with_empty( - wyndex_pair_lsd::contract::execute, - wyndex_pair_lsd::contract::instantiate, - wyndex_pair_lsd::contract::query, + palomadex_pair_lsd::contract::execute, + palomadex_pair_lsd::contract::instantiate, + palomadex_pair_lsd::contract::query, ) - .with_reply_empty(wyndex_pair_lsd::contract::reply), + .with_reply_empty(palomadex_pair_lsd::contract::reply), ); app.store_code(pair_contract) @@ -54,11 +54,11 @@ fn store_pair_code(app: &mut App) -> u64 { fn store_factory_code(app: &mut App) -> u64 { let factory_contract = Box::new( ContractWrapper::new_with_empty( - wyndex_factory::contract::execute, - wyndex_factory::contract::instantiate, - wyndex_factory::contract::query, + palomadex_factory::contract::execute, + palomadex_factory::contract::instantiate, + palomadex_factory::contract::query, ) - .with_reply_empty(wyndex_factory::contract::reply), + .with_reply_empty(palomadex_factory::contract::reply), ); app.store_code(factory_contract) @@ -66,9 +66,9 @@ fn store_factory_code(app: &mut App) -> u64 { fn store_stake_code(app: &mut App) -> u64 { let staking_contract = Box::new(ContractWrapper::new_with_empty( - wyndex_stake::contract::execute, - wyndex_stake::contract::instantiate, - wyndex_stake::contract::query, + palomadex_stake::contract::execute, + palomadex_stake::contract::instantiate, + palomadex_stake::contract::query, )); app.store_code(staking_contract) diff --git a/contracts/raw-migration/Cargo.toml b/contracts/raw-migration/Cargo.toml index 47176c8..e003a0b 100644 --- a/contracts/raw-migration/Cargo.toml +++ b/contracts/raw-migration/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "raw-migration" -authors = ["Cosmorama "] +authors = ["Volume Fi"] version = { workspace = true } edition = { workspace = true } -description = "Contract aimed just for migration - take JunoSwap RAW paired tokens and swap them to WYND" +description = "Contract aimed just for migration - take JunoSwap RAW paired tokens and swap them to PALOMA" license = { workspace = true } repository = { workspace = true } -homepage = "https://www.wynddao.com" +homepage = "https://www.palomachain.com" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -28,9 +28,9 @@ cw20 = { workspace = true } cw-utils = { workspace = true } thiserror = { workspace = true } -wyndex = { workspace = true } -wyndex-factory = { workspace = true } -wyndex-stake = { workspace = true } +palomadex = { workspace = true } +palomadex-factory = { workspace = true } +palomadex-stake = { workspace = true } # this is old version of cw20 used by wasmswap wasmswap_cw20 = { package = "cw20", version = "0.10.0" } @@ -46,5 +46,5 @@ cw-multi-test = { workspace = true } serde = { workspace = true } wasmswap_cw20-base = { package = "cw20-base", version = "0.10.0" } wasmswap_cw-utils = { package = "cw-utils", version = "0.11" } -wyndex-factory = { workspace = true } -wyndex-pair = { workspace = true } +palomadex-factory = { workspace = true } +palomadex-pair = { workspace = true } diff --git a/contracts/raw-migration/README.md b/contracts/raw-migration/README.md index 10507bf..cf65945 100644 --- a/contracts/raw-migration/README.md +++ b/contracts/raw-migration/README.md @@ -7,7 +7,7 @@ as we want to perform the migration proposal concurrently with the pool deployme Once it is migrated, the staking contract will be locked, and the only action is that a nominated migrator account can trigger the transfer - all RAW tokens will be burned, and in its place -WYND tokens will be staked using predefined exchange rate from configuration. +Grain tokens will be staked using predefined exchange rate from configuration. We add some constraints to ensure this is transferred to a valid target contract to minimize any trust requirements on the migrator (they just have "censorship" power). diff --git a/contracts/raw-migration/src/contract.rs b/contracts/raw-migration/src/contract.rs index 2593ac6..f479f62 100644 --- a/contracts/raw-migration/src/contract.rs +++ b/contracts/raw-migration/src/contract.rs @@ -5,25 +5,17 @@ use cosmwasm_std::{ Reply, Response, StdResult, SubMsg, Uint128, WasmMsg, }; -use cw2::{get_contract_version, set_contract_version}; use cw20::Cw20ExecuteMsg; -use cw_utils::ensure_from_older_version; +use palomadex::asset::{Asset, AssetInfo}; use wasmswap::msg::InfoResponse; -use wyndex::asset::{Asset, AssetInfo}; use crate::error::ContractError; -use crate::msg::{ExecuteMsg, MigrateMsg, QueryMsg}; -use crate::state::{ - ExchangeConfig, MigrateConfig, MigrateStakersConfig, DESTINATION, EXCHANGE_CONFIG, MIGRATION, -}; +use crate::msg::{ExecuteMsg, QueryMsg}; +use crate::state::{MigrateStakersConfig, DESTINATION, EXCHANGE_CONFIG, MIGRATION}; // this is the contract we are migrating from pub const STAKE_CW20_NAME: &str = "crates.io:stake_cw20"; -// version info for migration info -const CONTRACT_NAME: &str = "crates.io:raw-migration"; -const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); - #[cfg_attr(not(feature = "library"), entry_point)] pub fn instantiate( _deps: DepsMut, @@ -47,68 +39,6 @@ pub fn query(_deps: Deps, _env: Env, msg: QueryMsg) -> Result Result { - // if we got an init, then do from junoswap loop - if let Some(msg) = msg.init { - // ensure contract being migrated is actually junoswap staking - let old = get_contract_version(deps.storage)?; - if old.contract != STAKE_CW20_NAME { - return Err(ContractError::CannotMigrate(old.contract)); - } - - // update the cw2 contract version - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - - // check the unbonding period is valid - let factory = deps.api.addr_validate(&msg.factory)?; - let unbonding_period = msg.unbonding_period; - let wyndex_factory::state::Config { - default_stake_config, - .. - } = wyndex_factory::state::CONFIG.query(&deps.querier, factory.clone())?; - if !default_stake_config - .unbonding_periods - .iter() - .any(|x| x == &unbonding_period) - { - return Err(ContractError::InvalidUnbondingPeriod(unbonding_period)); - } - - // Validate arguments and set config for future calls - let wynddex_pool = msg - .wynddex_pool - .map(|p| deps.api.addr_validate(&p)) - .transpose()?; - let config = MigrateConfig { - migrator: deps.api.addr_validate(&msg.migrator)?, - junoswap_pool: deps.api.addr_validate(&msg.junoswap_pool)?, - factory, - unbonding_period, - wynddex_pool, - migrate_stakers_config: None, - }; - MIGRATION.save(deps.storage, &config)?; - - EXCHANGE_CONFIG.save( - deps.storage, - &ExchangeConfig { - raw_to_wynd_exchange_rate: msg.raw_to_wynd_exchange_rate, - raw_token: deps.api.addr_validate(&msg.raw_address)?, - wynd_token: deps.api.addr_validate(&msg.wynd_address)?, - }, - )?; - } else { - // self-migrate - // this is only used as a bug-fix-patch on the older version of this code. - ensure_from_older_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - // update the cw2 contract version - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - } - - Ok(Response::new()) -} - #[cfg_attr(not(feature = "library"), entry_point)] pub fn execute( deps: DepsMut, @@ -117,19 +47,19 @@ pub fn execute( msg: ExecuteMsg, ) -> Result { match msg { - ExecuteMsg::MigrateTokens { wynddex_pool } => migrate_tokens(deps, env, info, wynddex_pool), + ExecuteMsg::MigrateTokens { palomadex_pool } => migrate_tokens(deps, env, info, palomadex_pool), ExecuteMsg::MigrateStakers { limit } => migrate_stakers(deps, env, info, limit), } } -/// Allow `migrator` to pull out LP positions and send them to wynd dex pool +/// Allow `migrator` to pull out LP positions and send them to paloma dex pool /// First step figures out how many LPs we have and withdraws them. /// Follow up via reply. pub fn migrate_tokens( deps: DepsMut, env: Env, info: MessageInfo, - wynddex_pool: String, + palomadex_pool: String, ) -> Result { // make sure called by proper account let mut migration = MIGRATION.load(deps.storage)?; @@ -138,15 +68,15 @@ pub fn migrate_tokens( } // ensure the requested target pool is valid - let w_pool = deps.api.addr_validate(&wynddex_pool)?; - if let Some(ref target) = migration.wynddex_pool { + let w_pool = deps.api.addr_validate(&palomadex_pool)?; + if let Some(ref target) = migration.palomadex_pool { if target != w_pool { - return Err(ContractError::InvalidDestination(wynddex_pool)); + return Err(ContractError::InvalidDestination(palomadex_pool)); } } let ci = deps.querier.query_wasm_contract_info(&w_pool)?; if ci.creator != migration.factory { - return Err(ContractError::InvalidDestination(wynddex_pool)); + return Err(ContractError::InvalidDestination(palomadex_pool)); } // save target pool for later reply block @@ -158,14 +88,14 @@ pub fn migrate_tokens( let token = cw20::Cw20Contract(stake_cfg.token_address); let balance = token.balance(&deps.querier, env.contract.address)?; - // fill in most of the migration data now (minus wynd dex LP) - let wyndex::pair::PairInfo { + // fill in most of the migration data now (minus paloma dex LP) + let palomadex::pair::PairInfo { liquidity_token, staking_addr, .. } = deps .querier - .query_wasm_smart(&w_pool, &wyndex::pair::QueryMsg::Pair {})?; + .query_wasm_smart(&w_pool, &palomadex::pair::QueryMsg::Pair {})?; // total_staked is same a balance of junoswap lp token held by this contract migration.migrate_stakers_config = Some(MigrateStakersConfig { @@ -242,7 +172,7 @@ pub fn migrate_stakers( let batch_lp: Uint128 = staker_lps.iter().map(|(_, x)| x).sum(); // bonding has full info on who receives the delegation - let bond_msg = wyndex::stake::ReceiveMsg::MassDelegate { + let bond_msg = palomadex::stake::ReceiveMsg::MassDelegate { unbonding_period: migration.unbonding_period, delegate_to: staker_lps, }; @@ -276,17 +206,17 @@ pub fn reply(deps: DepsMut, env: Env, msg: Reply) -> Result Result { let migration = MIGRATION.load(deps.storage)?; let destination = DESTINATION.load(deps.storage)?; - // get the JS asset types and convert to WYND DEX types + // get the JS asset types and convert to PALOMA DEX types let info: InfoResponse = deps .querier .query_wasm_smart(migration.junoswap_pool, &wasmswap::msg::QueryMsg::Info {})?; - let assets = to_wyndex_assets(deps.as_ref(), env.contract.address, info)?; + let assets = to_palomadex_assets(deps.as_ref(), env.contract.address, info)?; // figure out how to transfer these... previous cw20 allowances or // sending native funds inline with providing liquidity @@ -298,7 +228,7 @@ pub fn reply_one(deps: DepsMut, env: Env) -> Result { let deposit = WasmMsg::Execute { contract_addr: destination.into_string(), funds, - msg: to_binary(&wyndex::pair::ExecuteMsg::ProvideLiquidity { + msg: to_binary(&palomadex::pair::ExecuteMsg::ProvideLiquidity { assets: new_assets, // TODO: set some value here? slippage_tolerance: None, @@ -320,7 +250,7 @@ struct DenomDeposits { } /// Checks if one of the denoms matches RAW address, then prepares extra BurnMsg -/// and provides WYND equivalent given by specified exchange rate +/// and provides PALOMA equivalent given by specified exchange rate fn prepare_denom_deposits( deps: Deps, destination: &Addr, @@ -346,10 +276,10 @@ fn prepare_denom_deposits( }; // add BurnMsg to messages allowances.push(burn_msg); - // now return wynd tokens instead + // now return grain tokens instead Ok(Asset { - info: AssetInfo::Token(exchange_config.wynd_token.to_string()), - amount: asset.amount * exchange_config.raw_to_wynd_exchange_rate, + info: AssetInfo::Token(exchange_config.grain_token.to_string()), + amount: asset.amount * exchange_config.raw_to_grain_exchange_rate, }) } else { Ok(asset.clone()) @@ -399,13 +329,17 @@ fn prepare_denom_deposit( Ok(()) } -fn to_wyndex_assets(deps: Deps, me: Addr, info: InfoResponse) -> Result, ContractError> { - let asset1 = to_wyndex_asset(deps, &me, info.token1_denom)?; - let asset2 = to_wyndex_asset(deps, &me, info.token2_denom)?; +fn to_palomadex_assets( + deps: Deps, + me: Addr, + info: InfoResponse, +) -> Result, ContractError> { + let asset1 = to_palomadex_asset(deps, &me, info.token1_denom)?; + let asset2 = to_palomadex_asset(deps, &me, info.token2_denom)?; Ok(vec![asset1, asset2]) } -fn to_wyndex_asset( +fn to_palomadex_asset( deps: Deps, me: &Addr, token: wasmswap_cw20::Denom, @@ -430,7 +364,7 @@ fn to_wyndex_asset( Ok(asset) } -/// Finally, with those WYND DEX LP tokens, we will take them all on behalf +/// Finally, with those PALOMA DEX LP tokens, we will take them all on behalf /// of the original JunoSwap LP stakers. pub fn reply_two(deps: DepsMut, env: Env) -> Result { // load config for LP token and staking contract diff --git a/contracts/raw-migration/src/msg.rs b/contracts/raw-migration/src/msg.rs index 60bb45f..a5e9e38 100644 --- a/contracts/raw-migration/src/msg.rs +++ b/contracts/raw-migration/src/msg.rs @@ -25,7 +25,7 @@ pub struct MigrateMsg { pub struct OrigMigrateMsg { /// This is the address that can run ExecuteMsg::MigrateTokens pub migrator: String, - /// This is how long it will be staked on WYND DEX + /// This is how long it will be staked on PALOMA DEX pub unbonding_period: u64, /// This is the junoswap pool where the LP will be withdrawn from @@ -34,16 +34,16 @@ pub struct OrigMigrateMsg { /// Can be deposited in any pool created by this factory pub factory: String, /// If set, only can be deposited in this pool (which must also be created by the factory) - pub wynddex_pool: Option, - // Multiplier applied on amount of RAW to get WYND tokens. + pub palomadex_pool: Option, + // Multiplier applied on amount of RAW to get Grain tokens. // Example: // exchange_rate = 1.5 - // 10 RAW * exchange_rate = 15 WYND - pub raw_to_wynd_exchange_rate: Decimal, + // 10 RAW * exchange_rate = 15 PALOMA + pub raw_to_grain_exchange_rate: Decimal, // Address of cw20 RAW token pub raw_address: String, - // Address of cw20 WYND token - pub wynd_address: String, + // Address of cw20 Grain token + pub grain_address: String, } #[cw_serde] @@ -52,7 +52,7 @@ pub enum ExecuteMsg { /// This moves the LP tokens to this contract, which are later given to the stakers in `MigrateStakers`. /// Must be called by migrator. /// Target pool must match constraints above - MigrateTokens { wynddex_pool: String }, + MigrateTokens { palomadex_pool: String }, /// Give the next `limit` stakers their LP tokens. /// Must be called by migrator. diff --git a/contracts/raw-migration/src/multitest/migration.rs b/contracts/raw-migration/src/multitest/migration.rs index 745caba..63eb70b 100644 --- a/contracts/raw-migration/src/multitest/migration.rs +++ b/contracts/raw-migration/src/multitest/migration.rs @@ -1,7 +1,7 @@ use super::suite::SuiteBuilder; use crate::{multitest::suite::PoolDenom, ContractError}; -use wyndex::asset::{AssetInfoValidated, AssetValidated}; +use palomadex::asset::{AssetInfoValidated, AssetValidated}; use wasmswap_cw20::Denom; @@ -29,14 +29,14 @@ fn migrate_raw_with_native() { _ => panic!("expected cw20 denom"), }; - let wynd_token = suite.wynd_cw20_token.clone(); + let grain_token = suite.grain_cw20_token.clone(); - // mint WYND tokens for migration contract + // mint PALOMA tokens for migration contract let junoswap_staking_contract = suite.junoswap_staking_contract.to_string(); suite .mint_cw20( "owner", - &wynd_token, + &grain_token, 5_000_000u128, &junoswap_staking_contract, ) @@ -88,7 +88,7 @@ fn migrate_raw_with_native() { .unwrap(); assert_eq!(junoswap.u128(), liquidity_cw20); - suite.wyndex_lp_holders(); + suite.palomadex_lp_holders(); // stake some of these tokens - 80% of liquidity should be moved // users[0] will keep everything staked @@ -137,56 +137,56 @@ fn migrate_raw_with_native() { .unwrap(); // perform the migration of liquidity - let raw_to_wynd_exchange_rate = Decimal::percent(200); + let raw_to_grain_exchange_rate = Decimal::percent(200); suite - .migrate_to_wyndex( + .migrate_to_palomadex( None, None, None, - raw_to_wynd_exchange_rate, + raw_to_grain_exchange_rate, raw_address.clone(), ) .unwrap(); - // 80% of native liquidity moved to wyndex pool - let wyndex = suite + // 80% of native liquidity moved to palomadex pool + let palomadex = suite .app .wrap() - .query_all_balances(&suite.wyndex_pair_contract) + .query_all_balances(&suite.palomadex_pair_contract) .unwrap(); let expected = liquidity .iter() .map(|Coin { amount, denom }| coin(amount.u128() * 4 / 5, denom)) .collect::>(); - assert_eq!(wyndex, expected); + assert_eq!(palomadex, expected); - // 80% of cw20 liquidity moved to wyndex pool + // 80% of cw20 liquidity moved to palomadex pool // RAW token is now GONE, it was swapped in prepare_denom_deposits at a rate of 200% (set above) - // Check the balance of WYND token instead, it should have been swapped at a 2-1 rate (200%) - let wyndex = cw20::Cw20Contract(wynd_token.clone()) - .balance(&suite.app.wrap(), suite.wyndex_pair_contract.clone()) + // Check the balance of PALOMA token instead, it should have been swapped at a 2-1 rate (200%) + let palomadex = cw20::Cw20Contract(grain_token.clone()) + .balance(&suite.app.wrap(), suite.palomadex_pair_contract.clone()) .unwrap(); let expected = liquidity_cw20 * 4 / 5; - assert_eq!(wyndex.u128(), expected * 2); + assert_eq!(palomadex.u128(), expected * 2); // ensure all lp belong to the staking contract - let wyndex_total = suite.total_wyndex_lp(); - let wyndex_staked = suite.total_wyndex_staked(); - assert_approx_eq!(wyndex_total, wyndex_staked, "0.001"); + let palomadex_total = suite.total_palomadex_lp(); + let palomadex_staked = suite.total_palomadex_staked(); + assert_approx_eq!(palomadex_total, palomadex_staked, "0.001"); // ensure all staked tokens belong to the migrated user - let user_staked = suite.wyndex_staked(users[0], suite.migration_unbonding_period()); - assert_eq!(user_staked, wyndex_staked / 3); + let user_staked = suite.palomadex_staked(users[0], suite.migration_unbonding_period()); + assert_eq!(user_staked, palomadex_staked / 3); // user 2 staked 500k so they should have about 10% of the staked tokens - let user_staked = suite.wyndex_staked(users[1], suite.migration_unbonding_period()); - assert_eq!(user_staked, wyndex_staked / 3); + let user_staked = suite.palomadex_staked(users[1], suite.migration_unbonding_period()); + assert_eq!(user_staked, palomadex_staked / 3); // user 3 did 3m and should have 60% - let user_staked = suite.wyndex_staked(users[2], suite.migration_unbonding_period()); - assert_eq!(user_staked, wyndex_staked / 3); + let user_staked = suite.palomadex_staked(users[2], suite.migration_unbonding_period()); + assert_eq!(user_staked, palomadex_staked / 3); // now to the meat - check assets of the pool and balance // verify amounts here, for cw20 its 3mil * 2 (exchange rate) * 4/5 (80% of liquidity was moved) = 4.8M // for native, just the 3 mil * 4/5 (80% of liquidity was moved) = 2.4M - let pool_info = suite.query_wyndex_pool(); + let pool_info = suite.query_palomadex_pool(); assert_eq!( pool_info.assets, vec![ @@ -195,7 +195,7 @@ fn migrate_raw_with_native() { amount: Uint128::new(2_400_000) }, AssetValidated { - info: AssetInfoValidated::Token(wynd_token.clone()), + info: AssetInfoValidated::Token(grain_token.clone()), amount: Uint128::new(4_800_002) } ] @@ -219,14 +219,14 @@ fn non_migrator_cant_migrate() { _ => panic!("expected cw20 denom"), }; let cw20_denom = suite.pool_denom2.clone(); - let wynd_token = suite.wynd_cw20_token.clone(); + let grain_token = suite.grain_cw20_token.clone(); - // mint WYND tokens for migration contract + // mint PALOMA tokens for migration contract let junoswap_staking_contract = suite.junoswap_staking_contract.to_string(); suite .mint_cw20( "owner", - &wynd_token, + &grain_token, 5_000_000u128, &junoswap_staking_contract, ) @@ -250,7 +250,7 @@ fn non_migrator_cant_migrate() { // this won't work, not the migrator let err = suite - .migrate_to_wyndex( + .migrate_to_palomadex( Some(Addr::unchecked("notthemigrator")), None, None, @@ -276,14 +276,14 @@ fn migrator_cant_migrate_to_own_addr() { Denom::Cw20(address) => address, _ => panic!("expected cw20 denom"), }; - let wynd_token = suite.wynd_cw20_token.clone(); + let grain_token = suite.grain_cw20_token.clone(); - // mint WYND tokens for migration contract + // mint PALOMA tokens for migration contract let junoswap_staking_contract = suite.junoswap_staking_contract.to_string(); suite .mint_cw20( "owner", - &wynd_token, + &grain_token, 5_000_000u128, &junoswap_staking_contract, ) @@ -307,9 +307,9 @@ fn migrator_cant_migrate_to_own_addr() { // this won't work, we can only migrate to a deployed pool contract. let err = suite - .migrate_to_wyndex( + .migrate_to_palomadex( Some(Addr::unchecked("owner")), - Some(suite.wyndex_pair_contract.clone()), + Some(suite.palomadex_pair_contract.clone()), Some(Addr::unchecked("owner")), Decimal::percent(100), raw_address.clone(), @@ -344,14 +344,14 @@ fn migration_two_cw20() { Denom::Cw20(address) => address, _ => panic!("expected cw20 denom"), }; - let wynd_token = suite.wynd_cw20_token.clone(); + let grain_token = suite.grain_cw20_token.clone(); - // mint WYND tokens for migration contract + // mint PALOMA tokens for migration contract let junoswap_staking_contract = suite.junoswap_staking_contract.to_string(); suite .mint_cw20( "owner", - &wynd_token, + &grain_token, 5_000_000u128, &junoswap_staking_contract, ) @@ -381,47 +381,50 @@ fn migration_two_cw20() { .unwrap(); // make sure no lp before the deposit - let wyndex_total = suite.total_wyndex_lp(); - assert_eq!(wyndex_total, 0u128); + let palomadex_total = suite.total_palomadex_lp(); + assert_eq!(palomadex_total, 0u128); // perform the migration of liquidity - let raw_to_wynd_exchange_rate = Decimal::percent(200); + let raw_to_grain_exchange_rate = Decimal::percent(200); suite - .migrate_to_wyndex( + .migrate_to_palomadex( None, None, None, - raw_to_wynd_exchange_rate, + raw_to_grain_exchange_rate, raw_address.clone(), ) .unwrap(); - // 80% of liquidity moved to wyndex pool + // 80% of liquidity moved to palomadex pool let cw20_token_liquidity = cw20::Cw20Contract(cw20_address.clone()) - .balance(&suite.app.wrap(), suite.wyndex_pair_contract.clone()) + .balance(&suite.app.wrap(), suite.palomadex_pair_contract.clone()) .unwrap(); let expected = liquidity * 4 / 5; assert_eq!(cw20_token_liquidity.u128(), expected); - // Wynd given for RAW tokens - let wyndex = cw20::Cw20Contract(wynd_token.clone()) - .balance(&suite.app.wrap(), suite.wyndex_pair_contract.clone()) + // Grin given for RAW tokens + let palomadex = cw20::Cw20Contract(grain_token.clone()) + .balance(&suite.app.wrap(), suite.palomadex_pair_contract.clone()) .unwrap(); - let expected = Uint128::from(liquidity * 4 / 5) * raw_to_wynd_exchange_rate; - assert_eq!(wyndex, expected); + let expected = Uint128::from(liquidity * 4 / 5) * raw_to_grain_exchange_rate; + assert_eq!(palomadex, expected); let raw = cw20::Cw20Contract(raw_address.clone()) - .balance(&suite.app.wrap(), suite.wyndex_pair_contract.clone()) + .balance(&suite.app.wrap(), suite.palomadex_pair_contract.clone()) .unwrap(); assert_eq!(raw.u128(), 0u128); // ensure all lp belong to the staking contract - let wyndex_total = suite.total_wyndex_lp(); - let wyndex_staked = suite.total_wyndex_staked(); - let pool = suite.wyndex_pair_contract.to_string(); - let pool_own_lp = suite.wyndex_lp(&pool); - assert_eq!(wyndex_total, wyndex_staked + pool_own_lp); - assert_eq!(pool_own_lp, wyndex::asset::MINIMUM_LIQUIDITY_AMOUNT.u128()); + let palomadex_total = suite.total_palomadex_lp(); + let palomadex_staked = suite.total_palomadex_staked(); + let pool = suite.palomadex_pair_contract.to_string(); + let pool_own_lp = suite.palomadex_lp(&pool); + assert_eq!(palomadex_total, palomadex_staked + pool_own_lp); + assert_eq!( + pool_own_lp, + palomadex::asset::MINIMUM_LIQUIDITY_AMOUNT.u128() + ); // ensure all staked tokens belong to the migrated user - let user_staked = suite.wyndex_staked(user, suite.migration_unbonding_period()); - assert_eq!(user_staked, wyndex_staked); + let user_staked = suite.palomadex_staked(user, suite.migration_unbonding_period()); + assert_eq!(user_staked, palomadex_staked); } diff --git a/contracts/raw-migration/src/multitest/suite.rs b/contracts/raw-migration/src/multitest/suite.rs index 337cc27..d8d0f62 100644 --- a/contracts/raw-migration/src/multitest/suite.rs +++ b/contracts/raw-migration/src/multitest/suite.rs @@ -1,13 +1,13 @@ use anyhow::Result as AnyResult; use cw20::MinterResponse; -use wyndex::asset::AssetInfo; -use wyndex::factory::{ +use palomadex::asset::AssetInfo; +use palomadex::factory::{ DefaultStakeConfig, ExecuteMsg as FactoryExecuteMsg, InstantiateMsg as FactoryInstantiateMsg, PairConfig, PairType, PartialStakeConfig, QueryMsg as FactoryQueryMsg, }; -use wyndex::fee_config::FeeConfig; -use wyndex::pair::{PairInfo, PoolResponse, QueryMsg as PairQueryMsg}; +use palomadex::fee_config::FeeConfig; +use palomadex::pair::{PairInfo, PoolResponse, QueryMsg as PairQueryMsg}; use crate::msg::{MigrateMsg, OrigMigrateMsg, QueryMsg}; use cosmwasm_std::{coin, to_binary, Addr, Coin, Decimal, Uint128}; @@ -53,36 +53,36 @@ pub fn store_cw20(app: &mut App) -> u64 { app.store_code(contract) } -pub fn store_wyndex_staking(app: &mut App) -> u64 { +pub fn store_palomadex_staking(app: &mut App) -> u64 { let contract = Box::new(ContractWrapper::new( - wyndex_stake::contract::execute, - wyndex_stake::contract::instantiate, - wyndex_stake::contract::query, + palomadex_stake::contract::execute, + palomadex_stake::contract::instantiate, + palomadex_stake::contract::query, )); app.store_code(contract) } -fn store_wyndex_factory(app: &mut App) -> u64 { +fn store_palomadex_factory(app: &mut App) -> u64 { let factory_contract = Box::new( ContractWrapper::new_with_empty( - wyndex_factory::contract::execute, - wyndex_factory::contract::instantiate, - wyndex_factory::contract::query, + palomadex_factory::contract::execute, + palomadex_factory::contract::instantiate, + palomadex_factory::contract::query, ) - .with_reply_empty(wyndex_factory::contract::reply), + .with_reply_empty(palomadex_factory::contract::reply), ); app.store_code(factory_contract) } -fn store_wyndex_pair(app: &mut App) -> u64 { +fn store_palomadex_pair(app: &mut App) -> u64 { let factory_contract = Box::new( ContractWrapper::new_with_empty( - wyndex_pair::contract::execute, - wyndex_pair::contract::instantiate, - wyndex_pair::contract::query, + palomadex_pair::contract::execute, + palomadex_pair::contract::instantiate, + palomadex_pair::contract::query, ) - .with_reply_empty(wyndex_pair::contract::reply), + .with_reply_empty(palomadex_pair::contract::reply), ); app.store_code(factory_contract) @@ -95,7 +95,6 @@ pub fn store_migrator(app: &mut App) -> u64 { crate::contract::instantiate, crate::contract::query, ) - .with_migrate(crate::contract::migrate) .with_reply(crate::contract::reply), ); app.store_code(contract) @@ -238,18 +237,18 @@ impl SuiteBuilder { .unwrap(); app.update_block(next_block); - // Instantiate wyndex factory - let wyndex_stake_code_id = store_wyndex_staking(&mut app); - let wyndex_pair_code_id = store_wyndex_pair(&mut app); - let wyndex_factory_code_id = store_wyndex_factory(&mut app); + // Instantiate palomadex factory + let palomadex_stake_code_id = store_palomadex_staking(&mut app); + let palomadex_pair_code_id = store_palomadex_pair(&mut app); + let palomadex_factory_code_id = store_palomadex_factory(&mut app); let factory_contract = app .instantiate_contract( - wyndex_factory_code_id, + palomadex_factory_code_id, owner.clone(), &FactoryInstantiateMsg { pair_configs: vec![PairConfig { pair_type: PairType::Xyk {}, - code_id: wyndex_pair_code_id, + code_id: palomadex_pair_code_id, fee_config: FeeConfig { total_fee_bps: 0, protocol_fee_bps: 0, @@ -261,7 +260,7 @@ impl SuiteBuilder { owner: owner.to_string(), max_referral_commission: Decimal::one(), default_stake_config: DefaultStakeConfig { - staking_code_id: wyndex_stake_code_id, + staking_code_id: palomadex_stake_code_id, tokens_per_power: Uint128::new(1000), min_bond: Uint128::new(1000), unbonding_periods: self.unbonding_periods.clone(), @@ -271,7 +270,7 @@ impl SuiteBuilder { trading_starts: None, }, &[], - "wyndex-factory", + "palomadex-factory", Some(owner.to_string()), ) .unwrap(); @@ -281,8 +280,8 @@ impl SuiteBuilder { cw20_code_id, Addr::unchecked(owner.clone()), &Cw20BaseInstantiateMsg { - name: "WYND".to_owned(), - symbol: "WYND".to_owned(), + name: "PALOMA".to_owned(), + symbol: "PALOMA".to_owned(), decimals: 6, initial_balances: vec![], mint: Some(MinterResponse { @@ -292,7 +291,7 @@ impl SuiteBuilder { marketing: None, }, &[], - "WYND".to_owned(), + "PALOMA".to_owned(), None, ) .unwrap(); @@ -307,7 +306,7 @@ impl SuiteBuilder { AssetInfo::Token(wynd_cw20_token.to_string()), ]; - // Instantiate wyndex pair contract through factory + // Instantiate palomadex pair contract through factory app.execute_contract( owner.clone(), factory_contract.clone(), @@ -337,9 +336,9 @@ impl SuiteBuilder { ) .unwrap(); - let wyndex_pair_contract = pair_info.contract_addr; - let wyndex_staking_contract = pair_info.staking_addr; - let wyndex_token_contract = pair_info.liquidity_token; + let palomadex_pair_contract = pair_info.contract_addr; + let palomadex_staking_contract = pair_info.staking_addr; + let palomadex_token_contract = pair_info.liquidity_token; // add funds to the contract let funds = self.funds; @@ -360,10 +359,10 @@ impl SuiteBuilder { junoswap_pool_contract, junoswap_staking_contract, factory_contract, - wyndex_pair_contract, - wyndex_staking_contract, - wyndex_token_contract, - wynd_cw20_token, + palomadex_pair_contract, + palomadex_staking_contract, + palomadex_token_contract, + grain_cw20_token: wynd_cw20_token, migrator_code_id, cw20_code_id, pool_denom1, @@ -383,10 +382,10 @@ pub struct Suite { pub junoswap_token_contract: Addr, pub junoswap_pool_contract: Addr, pub junoswap_staking_contract: Addr, - pub wynd_cw20_token: Addr, - pub wyndex_token_contract: Addr, - pub wyndex_staking_contract: Addr, - pub wyndex_pair_contract: Addr, + pub grain_cw20_token: Addr, + pub palomadex_token_contract: Addr, + pub palomadex_staking_contract: Addr, + pub palomadex_pair_contract: Addr, pub pool_denom1: Denom, pub pool_denom2: Denom, @@ -400,9 +399,9 @@ struct SuiteInfo<'a> { pub junoswap_pool_contract: &'a Addr, pub junoswap_staking_contract: &'a Addr, pub factory_contract: &'a Addr, - pub wyndex_token_contract: &'a Addr, - pub wyndex_staking_contract: &'a Addr, - pub wyndex_pair_contract: &'a Addr, + pub palomadex_token_contract: &'a Addr, + pub palomadex_staking_contract: &'a Addr, + pub palomadex_pair_contract: &'a Addr, } impl Suite { @@ -414,9 +413,9 @@ impl Suite { junoswap_pool_contract: &self.junoswap_pool_contract, junoswap_staking_contract: &self.junoswap_staking_contract, factory_contract: &self.factory_contract, - wyndex_token_contract: &self.wyndex_token_contract, - wyndex_staking_contract: &self.wyndex_staking_contract, - wyndex_pair_contract: &self.wyndex_pair_contract, + palomadex_token_contract: &self.palomadex_token_contract, + palomadex_staking_contract: &self.palomadex_staking_contract, + palomadex_pair_contract: &self.palomadex_pair_contract, }; println!("{:?}", info); } @@ -441,8 +440,8 @@ impl Suite { pub fn migrate_tokens( &mut self, migrator: Option, - wyndex_pair_migrate: Option, - wyndex_pair: Option, + palomadex_pair_migrate: Option, + palomadex_pair: Option, raw_to_wynd_exchange_rate: Decimal, raw_address: Addr, ) -> AnyResult { @@ -461,10 +460,10 @@ impl Suite { unbonding_period: self.migration_unbonding_period(), junoswap_pool: self.junoswap_pool_contract.to_string(), factory: self.factory_contract.to_string(), - wynddex_pool: wyndex_pair_migrate.map(|p| p.to_string()), - raw_to_wynd_exchange_rate, + palomadex_pool: palomadex_pair_migrate.map(|p| p.to_string()), + raw_to_grain_exchange_rate: raw_to_wynd_exchange_rate, raw_address: raw_address.to_string(), - wynd_address: self.wynd_cw20_token.to_string(), + grain_address: self.grain_cw20_token.to_string(), }), }, self.migrator_code_id, @@ -483,8 +482,8 @@ impl Suite { self.owner.clone(), self.junoswap_staking_contract.clone(), &crate::msg::ExecuteMsg::MigrateTokens { - wynddex_pool: wyndex_pair - .unwrap_or_else(|| self.wyndex_pair_contract.clone()) + palomadex_pool: palomadex_pair + .unwrap_or_else(|| self.palomadex_pair_contract.clone()) .to_string(), }, &[], @@ -502,18 +501,18 @@ impl Suite { ) } - pub fn migrate_to_wyndex( + pub fn migrate_to_palomadex( &mut self, migrator: Option, - wyndex_pair_migrate: Option, - wyndex_pair: Option, + palomadex_pair_migrate: Option, + palomadex_pair: Option, raw_to_wynd_exchange_rate: Decimal, raw_address: Addr, ) -> AnyResult<()> { self.migrate_tokens( migrator, - wyndex_pair_migrate, - wyndex_pair, + palomadex_pair_migrate, + palomadex_pair, raw_to_wynd_exchange_rate, raw_address, )?; @@ -684,19 +683,19 @@ impl Suite { resp } - pub fn query_wyndex_pool(&mut self) -> PoolResponse { + pub fn query_palomadex_pool(&mut self) -> PoolResponse { self.app .wrap() - .query_wasm_smart::(&self.wyndex_pair_contract, &PairQueryMsg::Pool {}) + .query_wasm_smart::(&self.palomadex_pair_contract, &PairQueryMsg::Pool {}) .unwrap() } - pub fn total_wyndex_lp(&mut self) -> u128 { + pub fn total_palomadex_lp(&mut self) -> u128 { let cw20::TokenInfoResponse { total_supply, .. } = self .app .wrap() .query_wasm_smart( - &self.wyndex_token_contract, + &self.palomadex_token_contract, &cw20::Cw20QueryMsg::TokenInfo {}, ) .unwrap(); @@ -704,12 +703,12 @@ impl Suite { total_supply.u128() } - pub fn wyndex_lp(&mut self, user: &str) -> u128 { + pub fn palomadex_lp(&mut self, user: &str) -> u128 { let cw20::BalanceResponse { balance } = self .app .wrap() .query_wasm_smart( - &self.wyndex_token_contract, + &self.palomadex_token_contract, &cw20::Cw20QueryMsg::Balance { address: user.to_string(), }, @@ -721,12 +720,12 @@ impl Suite { // for debugging tests #[allow(dead_code)] - pub fn wyndex_lp_holders(&mut self) -> Vec<(String, u128)> { + pub fn palomadex_lp_holders(&mut self) -> Vec<(String, u128)> { let cw20::AllAccountsResponse { accounts } = self .app .wrap() .query_wasm_smart( - &self.wyndex_token_contract, + &self.palomadex_token_contract, &cw20::Cw20QueryMsg::AllAccounts { start_after: None, limit: None, @@ -735,22 +734,22 @@ impl Suite { .unwrap(); accounts .into_iter() - .map(|addr| (addr.clone(), self.wyndex_lp(&addr))) + .map(|addr| (addr.clone(), self.palomadex_lp(&addr))) .collect() } - pub fn total_wyndex_staked(&mut self) -> u128 { - let addr = self.wyndex_staking_contract.clone(); - self.wyndex_lp(addr.as_str()) + pub fn total_palomadex_staked(&mut self) -> u128 { + let addr = self.palomadex_staking_contract.clone(); + self.palomadex_lp(addr.as_str()) } - pub fn wyndex_staked(&mut self, user: &str, unbonding_period: u64) -> u128 { - let wyndex_stake::msg::StakedResponse { stake, .. } = self + pub fn palomadex_staked(&mut self, user: &str, unbonding_period: u64) -> u128 { + let palomadex_stake::msg::StakedResponse { stake, .. } = self .app .wrap() .query_wasm_smart( - &self.wyndex_staking_contract, - &wyndex_stake::msg::QueryMsg::Staked { + &self.palomadex_staking_contract, + &palomadex_stake::msg::QueryMsg::Staked { address: user.to_string(), unbonding_period, }, diff --git a/contracts/raw-migration/src/state.rs b/contracts/raw-migration/src/state.rs index d489f4b..3e69e32 100644 --- a/contracts/raw-migration/src/state.rs +++ b/contracts/raw-migration/src/state.rs @@ -6,7 +6,7 @@ use cw_storage_plus::Item; pub struct MigrateConfig { /// This is the address that can run ExecuteMsg::MigrateTokens pub migrator: Addr, - /// This is how long it will be staked on WYND DEX + /// This is how long it will be staked on PALOMA DEX pub unbonding_period: u64, /// This is the junoswap pool where the LP will be withdrawn from @@ -15,7 +15,7 @@ pub struct MigrateConfig { /// Can be deposited in any pool created by this factory pub factory: Addr, /// If set, only can be deposited in this pool (which must also be created by the factory) - pub wynddex_pool: Option, + pub palomadex_pool: Option, /// This is set when token migration is finished. /// It is used to calculate the amount of LP tokens to give to each staker. @@ -25,11 +25,11 @@ pub struct MigrateConfig { /// The necessary information to migrate stakers. #[cw_serde] pub struct MigrateStakersConfig { - /// The wyndex LP token contract + /// The palomadex LP token contract pub lp_token: Addr, - /// The wyndex LP staking contract + /// The palomadex LP staking contract pub staking_addr: Addr, - /// The total amount of wyndex LP tokens this contract received after token migration. + /// The total amount of palomadex LP tokens this contract received after token migration. pub total_lp_tokens: Uint128, /// The total amount of staked junoswap LP tokens. pub total_staked: Uint128, @@ -43,9 +43,9 @@ pub const DESTINATION: Item = Item::new("destination"); #[cw_serde] pub struct ExchangeConfig { - pub raw_to_wynd_exchange_rate: Decimal, + pub raw_to_grain_exchange_rate: Decimal, pub raw_token: Addr, - pub wynd_token: Addr, + pub grain_token: Addr, } pub const EXCHANGE_CONFIG: Item = Item::new("exchange_config"); diff --git a/contracts/splitter/Cargo.toml b/contracts/splitter/Cargo.toml index b7206ed..43c336f 100644 --- a/contracts/splitter/Cargo.toml +++ b/contracts/splitter/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "cw-splitter" -authors = ["Jakub Bogucki "] +authors = ["Volume Fi"] version = { workspace = true } edition = { workspace = true } description = "Contract that splits balance between payees according to configuration" license = { workspace = true } repository = { workspace = true } -homepage = "https://www.wynddao.com" +homepage = "https://www.palomachain.com" [lib] crate-type = ["cdylib", "rlib"] diff --git a/contracts/splitter/src/contract.rs b/contracts/splitter/src/contract.rs index ec07313..e3b94fb 100644 --- a/contracts/splitter/src/contract.rs +++ b/contracts/splitter/src/contract.rs @@ -5,7 +5,6 @@ use cosmwasm_std::{ MessageInfo, Response, StdResult, WasmMsg, }; -use cw2::set_contract_version; use cw20::{BalanceResponse, Cw20ExecuteMsg, Cw20QueryMsg}; use cw_utils::ensure_from_older_version; @@ -13,10 +12,6 @@ use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; use crate::state::{Config, CONFIG}; use crate::ContractError; -// version info for migration info -const CONTRACT_NAME: &str = "crates.io:cw-splitter"; -const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); - #[cfg_attr(not(feature = "library"), entry_point)] pub fn instantiate( deps: DepsMut, @@ -24,8 +19,6 @@ pub fn instantiate( _info: MessageInfo, msg: InstantiateMsg, ) -> Result { - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - let addresses = validate_addresses(deps.as_ref(), msg.addresses)?; let cw20_addresses = msg .cw20_contracts @@ -177,31 +170,6 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { } } -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn migrate(deps: DepsMut, _env: Env, msg: MigrateMsg) -> Result { - // needed safety check - ensure_from_older_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - - CONFIG.remove(deps.storage); - - let addresses = validate_addresses(deps.as_ref(), msg.new_addresses)?; - let cw20_addresses = msg - .new_cw20_contracts - .into_iter() - .map(|addr| deps.api.addr_validate(&addr)) - .collect::>>()?; - - CONFIG.save( - deps.storage, - &Config { - addresses, - cw20_addresses, - }, - )?; - - Ok(Response::new()) -} - #[cfg(test)] mod tests { use super::*; @@ -390,7 +358,7 @@ mod tests { .init_balance( storage, &Addr::unchecked("owner"), - vec![coin(1_000_000, "ujuno"), coin(200_000, "wynd")], + vec![coin(1_000_000, "ujuno"), coin(200_000, "grain")], ) .unwrap() }); @@ -427,7 +395,7 @@ mod tests { Addr::unchecked("owner"), BankMsg::Send { to_address: splitter_contract.to_string(), - amount: vec![coin(200_000, "wynd")], + amount: vec![coin(200_000, "grain")], } .into(), ) @@ -438,7 +406,7 @@ mod tests { Addr::unchecked("owner"), splitter_contract, &ExecuteMsg::SendTokens { - native_denoms: vec!["ujuno".to_owned(), "wynd".to_owned()], + native_denoms: vec!["ujuno".to_owned(), "grain".to_owned()], cw20_addresses: None, }, &[], @@ -449,13 +417,13 @@ mod tests { app.wrap() .query_all_balances("address1".to_owned()) .unwrap(), - vec![coin(330_000u128, "ujuno"), coin(66_000u128, "wynd")] + vec![coin(330_000u128, "ujuno"), coin(66_000u128, "grain")] ); assert_eq!( app.wrap() .query_all_balances("address2".to_owned()) .unwrap(), - vec![coin(670_000u128, "ujuno"), coin(134_000u128, "wynd")] + vec![coin(670_000u128, "ujuno"), coin(134_000u128, "grain")] ); } @@ -467,7 +435,7 @@ mod tests { .init_balance( storage, &Addr::unchecked("owner"), - vec![coin(1_000_000, "ujuno"), coin(200_000, "wynd")], + vec![coin(1_000_000, "ujuno"), coin(200_000, "grain")], ) .unwrap() }); @@ -504,7 +472,7 @@ mod tests { Addr::unchecked("owner"), BankMsg::Send { to_address: splitter_contract.to_string(), - amount: vec![coin(200_000, "wynd")], + amount: vec![coin(200_000, "grain")], } .into(), ) @@ -514,7 +482,7 @@ mod tests { Addr::unchecked("owner"), splitter_contract.clone(), &ExecuteMsg::SendTokens { - native_denoms: vec!["wynd".to_owned()], + native_denoms: vec!["grain".to_owned()], cw20_addresses: None, }, &[], @@ -525,13 +493,13 @@ mod tests { app.wrap() .query_all_balances("address1".to_owned()) .unwrap(), - vec![coin(66_000u128, "wynd")] + vec![coin(66_000u128, "grain")] ); assert_eq!( app.wrap() .query_all_balances("address2".to_owned()) .unwrap(), - vec![coin(134_000u128, "wynd")] + vec![coin(134_000u128, "grain")] ); // make sure other tokens are still on splitter contract's balance assert_eq!( diff --git a/contracts/stake/Cargo.toml b/contracts/stake/Cargo.toml index 83728b4..25aa7f8 100644 --- a/contracts/stake/Cargo.toml +++ b/contracts/stake/Cargo.toml @@ -1,7 +1,7 @@ [package] -name = "wyndex-stake" +name = "palomadex-stake" version = { workspace = true } -authors = ["Cosmorama "] +authors = ["Volume Fi"] edition = { workspace = true } description = "Multi-timeframe staking contract with support for multiple external rewards for multiple tokens" license = { workspace = true } @@ -16,7 +16,7 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -wyndex = { workspace = true } +palomadex = { workspace = true } # cw-plus cw-utils = { workspace = true } cw2 = { workspace = true } diff --git a/contracts/stake/NOTICE b/contracts/stake/NOTICE index 0e5e584..02b02d6 100644 --- a/contracts/stake/NOTICE +++ b/contracts/stake/NOTICE @@ -1,4 +1,4 @@ -WYND-Stake: Multi-timeframe staking contract with rewards to power cw3 voting +PALOMA-Stake: Multi-timeframe staking contract with rewards to power cw3 voting Copyright (C) 2020 Confio OÜ ((https://github.com/CosmWasm/cw-plus/tree/main/contracts/cw4-stake) Copyright (C) 2022 Cosmorama diff --git a/contracts/stake/README.md b/contracts/stake/README.md index ddd9fbb..14a9ff1 100644 --- a/contracts/stake/README.md +++ b/contracts/stake/README.md @@ -1,4 +1,4 @@ -# WYND Stake +# PALOMA Stake **TODO: Update** This is the original description from cw4-stake for now diff --git a/contracts/stake/src/bin/stake_schema.rs b/contracts/stake/src/bin/stake_schema.rs index b02d178..a2c3012 100644 --- a/contracts/stake/src/bin/stake_schema.rs +++ b/contracts/stake/src/bin/stake_schema.rs @@ -1,6 +1,6 @@ use cosmwasm_schema::write_api; -use wyndex::stake::InstantiateMsg; -use wyndex_stake::msg::{ExecuteMsg, QueryMsg}; +use palomadex::stake::InstantiateMsg; +use palomadex_stake::msg::{ExecuteMsg, QueryMsg}; fn main() { write_api! { diff --git a/contracts/stake/src/contract.rs b/contracts/stake/src/contract.rs index cde982e..9df6ce1 100644 --- a/contracts/stake/src/contract.rs +++ b/contracts/stake/src/contract.rs @@ -9,10 +9,10 @@ use cosmwasm_std::{ use cw20::{Cw20ExecuteMsg, Cw20ReceiveMsg}; use cw_controllers::Claim; use cw_storage_plus::Map; -use wyndex::asset::{addr_opt_validate, AssetInfo, AssetInfoValidated}; -use wyndex::common::validate_addresses; -use wyndex::lp_converter::ExecuteMsg as ConverterExecuteMsg; -use wyndex::stake::{FundingInfo, InstantiateMsg, ReceiveMsg, UnbondingPeriod}; +use palomadex::asset::{addr_opt_validate, AssetInfo, AssetInfoValidated}; +use palomadex::common::validate_addresses; +use palomadex::lp_converter::ExecuteMsg as ConverterExecuteMsg; +use palomadex::stake::{FundingInfo, InstantiateMsg, ReceiveMsg, UnbondingPeriod}; use crate::distribution::{ apply_points_correction, execute_delegate_withdrawal, execute_distribute_rewards, @@ -37,10 +37,6 @@ use wynd_curve_utils::Curve; const SECONDS_PER_YEAR: u64 = 365 * 24 * 60 * 60; -// version info for migration info -const CONTRACT_NAME: &str = concat!("crates.io:", env!("CARGO_CRATE_NAME")); -const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); - // Note, you can use StdResult in some functions where you do not // make use of the custom errors #[cfg_attr(not(feature = "library"), entry_point)] @@ -50,7 +46,6 @@ pub fn instantiate( info: MessageInfo, mut msg: InstantiateMsg, ) -> Result { - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; let api = deps.api; // Set the admin if provided ADMIN.set(deps.branch(), maybe_addr(api, msg.admin.clone())?)?; @@ -1303,38 +1298,13 @@ pub fn query_unbond_all(deps: Deps) -> StdResult { }) } -/// Manages the contract migration. -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn migrate(deps: DepsMut, _env: Env, msg: MigrateMsg) -> Result { - ensure_from_older_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - - // add unbonder to config - let mut config = CONFIG.load(deps.storage)?; - config.unbonder = addr_opt_validate(deps.api, &msg.unbonder)?; - config.converter = msg - .converter - .map(|c| { - StdResult::Ok(ConverterConfig { - contract: deps.api.addr_validate(&c.contract)?, - pair_to: deps.api.addr_validate(&c.pair_to)?, - }) - }) - .transpose()?; - CONFIG.save(deps.storage, &config)?; - - // set unbond all flag - UNBOND_ALL.save(deps.storage, &msg.unbond_all)?; - - Ok(Response::new()) -} - #[cfg(test)] mod tests { use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; use cosmwasm_std::{from_slice, Coin, CosmosMsg, Decimal, WasmMsg}; use cw_controllers::Claim; use cw_utils::Duration; - use wyndex::asset::{native_asset_info, token_asset_info}; + use palomadex::asset::{native_asset_info, token_asset_info}; use crate::error::ContractError; use crate::msg::{DistributionDataResponse, WithdrawAdjustmentDataResponse}; @@ -1354,11 +1324,6 @@ mod tests { const CW20_ADDRESS: &str = "wasm1234567890"; const DENOM: &str = "juno"; - #[test] - fn check_crate_name() { - assert_eq!(CONTRACT_NAME, "crates.io:wyndex_stake"); - } - fn default_instantiate(deps: DepsMut, env: Env) { cw20_instantiate( deps, diff --git a/contracts/stake/src/distribution.rs b/contracts/stake/src/distribution.rs index c177dd7..8fa5743 100644 --- a/contracts/stake/src/distribution.rs +++ b/contracts/stake/src/distribution.rs @@ -1,7 +1,7 @@ use std::collections::HashSet; use cosmwasm_std::{Addr, Deps, DepsMut, Env, MessageInfo, Response, StdResult, Storage, Uint128}; -use wyndex::asset::{AssetInfo, AssetInfoExt, AssetInfoValidated}; +use palomadex::asset::{AssetInfo, AssetInfoExt, AssetInfoValidated}; use crate::error::ContractError; use crate::msg::{ diff --git a/contracts/stake/src/error.rs b/contracts/stake/src/error.rs index d471677..e0a3c4a 100644 --- a/contracts/stake/src/error.rs +++ b/contracts/stake/src/error.rs @@ -2,8 +2,8 @@ use cosmwasm_std::{Coin, OverflowError, StdError, Uint128}; use thiserror::Error; use cw_controllers::{AdminError, HookError}; +use palomadex::asset::AssetInfoValidated; use wynd_curve_utils::CurveError; -use wyndex::asset::AssetInfoValidated; #[derive(Error, Debug, PartialEq)] pub enum ContractError { diff --git a/contracts/stake/src/lib.rs b/contracts/stake/src/lib.rs index 240f508..3e2b0e5 100644 --- a/contracts/stake/src/lib.rs +++ b/contracts/stake/src/lib.rs @@ -1,6 +1,6 @@ //#![warn(missing_docs)] #![doc(html_logo_url = "../../../uml/logo.png")] -//! # WYNDEX Staking +//! # PALOMADEX Staking //! //! ## Description //! @@ -8,7 +8,7 @@ //! //! ## Objectives //! -//! The main goal of the **WYNDEX staking** is to: +//! The main goal of the **PALOMADEX staking** is to: //! - Allow the LP TOKEN to be staked with a proper curve and time. //! diff --git a/contracts/stake/src/msg.rs b/contracts/stake/src/msg.rs index 2f97c4d..0b01c02 100644 --- a/contracts/stake/src/msg.rs +++ b/contracts/stake/src/msg.rs @@ -2,9 +2,9 @@ use cosmwasm_schema::{cw_serde, QueryResponses}; use cw20::Cw20ReceiveMsg; use cosmwasm_std::{Addr, Decimal, Uint128}; -use wyndex::asset::{AssetInfo, AssetInfoValidated, AssetValidated}; +use palomadex::asset::{AssetInfo, AssetInfoValidated, AssetValidated}; -use wyndex::stake::{ConverterConfig, FundingInfo, UnbondingPeriod}; +use palomadex::stake::{ConverterConfig, FundingInfo, UnbondingPeriod}; #[cw_serde] pub enum ExecuteMsg { diff --git a/contracts/stake/src/multitest.rs b/contracts/stake/src/multitest.rs index 4ea34ac..bb0627d 100644 --- a/contracts/stake/src/multitest.rs +++ b/contracts/stake/src/multitest.rs @@ -1,6 +1,5 @@ mod delegate; mod distribution; -mod migration; mod quick_unbond; mod staking_rewards; mod suite; diff --git a/contracts/stake/src/multitest/distribution.rs b/contracts/stake/src/multitest/distribution.rs index e0a3408..650a7f3 100644 --- a/contracts/stake/src/multitest/distribution.rs +++ b/contracts/stake/src/multitest/distribution.rs @@ -2,8 +2,8 @@ use cosmwasm_std::{assert_approx_eq, Addr, Decimal, Uint128}; use cw20::{Cw20Coin, MinterResponse}; use cw20_base::msg::InstantiateMsg as Cw20InstantiateMsg; use cw_multi_test::Executor; -use wyndex::asset::{AssetInfo, AssetInfoExt, AssetInfoValidated}; -use wyndex::stake::FundingInfo; +use palomadex::asset::{AssetInfo, AssetInfoExt, AssetInfoValidated}; +use palomadex::stake::FundingInfo; use super::suite::{contract_token, SuiteBuilder}; use crate::{ @@ -54,16 +54,16 @@ fn multiple_distribution_flows() { ) .unwrap(); - // create wynd token + // create grain token let token_id = suite.app.store_code(contract_token()); - let wynd_token = suite + let grain_token = suite .app .instantiate_contract( token_id, Addr::unchecked("admin"), &Cw20InstantiateMsg { - name: "wynd-token".to_owned(), - symbol: "WYND".to_owned(), + name: "grain-token".to_owned(), + symbol: "PALOMA".to_owned(), decimals: 9, initial_balances: vec![Cw20Coin { // member4 gets some to distribute @@ -140,37 +140,37 @@ fn multiple_distribution_flows() { vec![juno(125), native_token("luna".to_string(), 125)] ); - // add wynd distribution + // add grain distribution suite .create_distribution_flow( "admin", &members[0], - AssetInfo::Token(wynd_token.to_string()), + AssetInfo::Token(grain_token.to_string()), vec![(unbonding_period, Decimal::one())], ) .unwrap(); - // Finally, setup the Wynd distribution before advancing time again to collect rewards + // Finally, setup the Grain distribution before advancing time again to collect rewards suite .execute_fund_distribution_with_cw20( &members[3], - AssetInfoValidated::Token(wynd_token.clone()).with_balance(400u128), + AssetInfoValidated::Token(grain_token.clone()).with_balance(400u128), ) .unwrap(); - // Advance the final 50% for the first two native tokens and 50% for the Wynd token + // Advance the final 50% for the first two native tokens and 50% for the Grain token suite.update_time(50); // Distribute the funds suite.distribute_funds(&members[3], None, None).unwrap(); - // Assert we have gathered all the rewards from the two native tokens and 50% of the rewards from the Wynd token + // Assert we have gathered all the rewards from the two native tokens and 50% of the rewards from the Grain token assert_eq!( suite.withdrawable_rewards(&members[0]).unwrap(), vec![ juno(50), native_token("luna".to_string(), 50), - AssetInfoValidated::Token(wynd_token.clone()).with_balance(25u128) + AssetInfoValidated::Token(grain_token.clone()).with_balance(25u128) ] ); assert_eq!( @@ -178,7 +178,7 @@ fn multiple_distribution_flows() { vec![ juno(100), native_token("luna".to_string(), 100), - AssetInfoValidated::Token(wynd_token.clone()).with_balance(50u128) + AssetInfoValidated::Token(grain_token.clone()).with_balance(50u128) ] ); assert_eq!( @@ -186,7 +186,7 @@ fn multiple_distribution_flows() { vec![ juno(250), native_token("luna".to_string(), 250), - AssetInfoValidated::Token(wynd_token).with_balance(125u128) + AssetInfoValidated::Token(grain_token).with_balance(125u128) ] ); } @@ -237,16 +237,16 @@ fn mass_bond_with_multiple_distribution_flows() { ) .unwrap(); - // create wynd token + // create grain token let token_id = suite.app.store_code(contract_token()); - let wynd_token = suite + let grain_token = suite .app .instantiate_contract( token_id, Addr::unchecked("admin"), &Cw20InstantiateMsg { - name: "wynd-token".to_owned(), - symbol: "WYND".to_owned(), + name: "grain-token".to_owned(), + symbol: "PALOMA".to_owned(), decimals: 9, initial_balances: vec![Cw20Coin { // member4 gets some to distribute @@ -323,37 +323,37 @@ fn mass_bond_with_multiple_distribution_flows() { vec![juno(125), native_token("luna".to_string(), 125)] ); - // add wynd distribution + // add grain distribution suite .create_distribution_flow( "admin", &members[0], - AssetInfo::Token(wynd_token.to_string()), + AssetInfo::Token(grain_token.to_string()), vec![(unbonding_period, Decimal::one())], ) .unwrap(); - // Finally, setup the Wynd distribution before advancing time again to collect rewards + // Finally, setup the Grain distribution before advancing time again to collect rewards suite .execute_fund_distribution_with_cw20( &members[3], - AssetInfoValidated::Token(wynd_token.clone()).with_balance(400u128), + AssetInfoValidated::Token(grain_token.clone()).with_balance(400u128), ) .unwrap(); - // Advance the final 50% for the first two native tokens and 50% for the Wynd token + // Advance the final 50% for the first two native tokens and 50% for the Grain token suite.update_time(50); // Distribute the funds suite.distribute_funds(&members[3], None, None).unwrap(); - // Assert we have gathered all the rewards from the two native tokens and 50% of the rewards from the Wynd token + // Assert we have gathered all the rewards from the two native tokens and 50% of the rewards from the Grain token assert_eq!( suite.withdrawable_rewards(&members[0]).unwrap(), vec![ juno(50), native_token("luna".to_string(), 50), - AssetInfoValidated::Token(wynd_token.clone()).with_balance(25u128) + AssetInfoValidated::Token(grain_token.clone()).with_balance(25u128) ] ); assert_eq!( @@ -361,7 +361,7 @@ fn mass_bond_with_multiple_distribution_flows() { vec![ juno(100), native_token("luna".to_string(), 100), - AssetInfoValidated::Token(wynd_token.clone()).with_balance(50u128) + AssetInfoValidated::Token(grain_token.clone()).with_balance(50u128) ] ); assert_eq!( @@ -369,7 +369,7 @@ fn mass_bond_with_multiple_distribution_flows() { vec![ juno(250), native_token("luna".to_string(), 250), - AssetInfoValidated::Token(wynd_token).with_balance(125u128) + AssetInfoValidated::Token(grain_token).with_balance(125u128) ] ); } @@ -2303,16 +2303,16 @@ fn multiple_rewards() { ) .unwrap(); - // create wynd token + // create grain token let token_id = suite.app.store_code(contract_token()); - let wynd_token = suite + let grain_token = suite .app .instantiate_contract( token_id, Addr::unchecked("admin"), &Cw20InstantiateMsg { - name: "wynd-token".to_owned(), - symbol: "WYND".to_owned(), + name: "grain-token".to_owned(), + symbol: "PALOMA".to_owned(), decimals: 9, initial_balances: vec![Cw20Coin { // executor gets some to distribute @@ -2331,12 +2331,12 @@ fn multiple_rewards() { ) .unwrap(); - // add wynd distribution + // add grain distribution suite .create_distribution_flow( "admin", executor, - AssetInfo::Token(wynd_token.to_string()), + AssetInfo::Token(grain_token.to_string()), vec![ (unbonding_period, Decimal::one()), (unbonding_period2, Decimal::one()), @@ -2356,12 +2356,12 @@ fn multiple_rewards() { suite .distribute_funds(executor, executor, Some(juno(1_000))) .unwrap(); - // distribute wynd + // distribute grain suite .distribute_funds( executor, executor, - Some(AssetInfoValidated::Token(wynd_token.clone()).with_balance(500u128)), + Some(AssetInfoValidated::Token(grain_token.clone()).with_balance(500u128)), ) .unwrap(); @@ -2380,18 +2380,18 @@ fn multiple_rewards() { assert_eq!(suite.query_balance(&members[0], "juno").unwrap(), 200); assert_eq!(suite.query_balance(&members[1], "juno").unwrap(), 800); - // rewards power for wynd: + // rewards power for grain: // member0: 1000 * 1 / 1000 = 1 // member1: 2000 * 1 / 1000 = 2 // => 500 * 1 / 3 = 166, 500 * 2 / 3 = 333 assert_eq!( suite - .query_cw20_balance(&members[0], wynd_token.clone()) + .query_cw20_balance(&members[0], grain_token.clone()) .unwrap(), 166 ); assert_eq!( - suite.query_cw20_balance(&members[1], wynd_token).unwrap(), + suite.query_cw20_balance(&members[1], grain_token).unwrap(), 333 ); } diff --git a/contracts/stake/src/multitest/migration.rs b/contracts/stake/src/multitest/migration.rs deleted file mode 100644 index d126af8..0000000 --- a/contracts/stake/src/multitest/migration.rs +++ /dev/null @@ -1,184 +0,0 @@ -use cosmwasm_std::{to_binary, Addr, Empty, StdError, Uint128}; -use cw_multi_test::{App, Contract, ContractWrapper, Executor}; - -use cw20::{BalanceResponse, Cw20Coin, Cw20ExecuteMsg, Cw20QueryMsg, MinterResponse}; -use cw20_base::msg::InstantiateMsg as Cw20InstantiateMsg; -use wyndex::stake::ReceiveMsg; -use wyndex_stake_2_0_0::msg::TotalStakedResponse; - -use crate::msg::{ExecuteMsg, MigrateMsg, QueryMsg, UnbondAllResponse}; - -// const UNBONDER: &str = "unbonder"; -const MINTER: &str = "minter"; -const USER: &str = "user"; -const UNBONDER: &str = "unbonder"; -const ADMIN: &str = "admin"; -pub const SEVEN_DAYS: u64 = 604800; - -#[test] -fn stake_old_migrate_with_unbond_all_and_unbond() { - let mut app = App::default(); - - let admin = Addr::unchecked(ADMIN); - - // CW20 token - let cw20_contract: Box> = Box::new(ContractWrapper::new_with_empty( - cw20_base::contract::execute, - cw20_base::contract::instantiate, - cw20_base::contract::query, - )); - - // Instantiate Cw20 token. - let token_id = app.store_code(cw20_contract); - let token_contract = app - .instantiate_contract( - token_id, - admin.clone(), - &Cw20InstantiateMsg { - name: "vesting".to_owned(), - symbol: "VEST".to_owned(), - decimals: 9, - initial_balances: vec![Cw20Coin { - address: USER.to_owned(), - amount: 1_000_000u128.into(), - }], - mint: Some(MinterResponse { - minter: MINTER.to_owned(), - cap: None, - }), - marketing: None, - }, - &[], - "vesting", - None, - ) - .unwrap(); - - // Upload old stake contract and create instance - let old_contract: Box> = Box::new(ContractWrapper::new_with_empty( - wyndex_stake_2_0_0::contract::execute, - wyndex_stake_2_0_0::contract::instantiate, - wyndex_stake_2_0_0::contract::query, - )); - let stake_old_id = app.store_code(old_contract); - let stake_old_contract = app - .instantiate_contract( - stake_old_id, - admin.clone(), - &wyndex_2_0_0::stake::InstantiateMsg { - cw20_contract: token_contract.to_string(), - tokens_per_power: Uint128::new(1000), - min_bond: Uint128::new(5000), - unbonding_periods: vec![SEVEN_DAYS], - admin: None, - unbonder: None, - max_distributions: 6, - }, - &[], - "stake", - Some(admin.to_string()), - ) - .unwrap(); - - // Check that UnbondAll is not present. - let err: Result = app - .wrap() - .query_wasm_smart(stake_old_contract.clone(), &QueryMsg::UnbondAll {}); - - assert!(matches!(err.unwrap_err(), StdError::GenericErr { .. })); - - // Delegate tokens into old contract. - app.execute_contract( - Addr::unchecked(USER), - token_contract.clone(), - &Cw20ExecuteMsg::Send { - contract: stake_old_contract.to_string(), - amount: 500_000u128.into(), - msg: to_binary(&ReceiveMsg::Delegate { - unbonding_period: SEVEN_DAYS, - delegate_as: None, - }) - .unwrap(), - }, - &[], - ) - .unwrap(); - - // Check tokens are correctly delegated. - let total_staked_resp: TotalStakedResponse = app - .wrap() - .query_wasm_smart(stake_old_contract.clone(), &QueryMsg::TotalStaked {}) - .unwrap(); - - assert_eq!(Uint128::new(500_000), total_staked_resp.total_staked,); - - // Upload new bytecode. - let new_contract: Box> = Box::new( - ContractWrapper::new_with_empty( - crate::contract::execute, - crate::contract::instantiate, - crate::contract::query, - ) - .with_migrate(crate::contract::migrate), - ); - let stake_new_id = app.store_code(new_contract); - - // Migrate to new contract with unbond all. - app.migrate_contract( - admin, - stake_old_contract.clone(), - &MigrateMsg { - unbonder: Some(UNBONDER.to_owned()), - converter: None, - unbond_all: true, - }, - stake_new_id, - ) - .unwrap(); - - // Check that unbond all has been correctly set. - let resp: UnbondAllResponse = app - .wrap() - .query_wasm_smart(stake_old_contract.clone(), &QueryMsg::UnbondAll {}) - .unwrap(); - - assert!(resp.unbond_all); - - let balance: BalanceResponse = app - .wrap() - .query_wasm_smart( - token_contract.clone(), - &Cw20QueryMsg::Balance { - address: USER.to_owned(), - }, - ) - .unwrap(); - - // Assert that user has initial tokens - staked tokens. - assert_eq!(Uint128::new(500_000), balance.balance,); - - // Unbond tokens staked in old contract - app.execute_contract( - Addr::unchecked(USER), - stake_old_contract, - &ExecuteMsg::Unbond { - tokens: Uint128::new(500_000), - unbonding_period: SEVEN_DAYS, - }, - &[], - ) - .unwrap(); - - let balance: BalanceResponse = app - .wrap() - .query_wasm_smart( - token_contract, - &Cw20QueryMsg::Balance { - address: USER.to_owned(), - }, - ) - .unwrap(); - - // Assert that user has initial tokens. - assert_eq!(Uint128::new(1_000_000), balance.balance,); -} diff --git a/contracts/stake/src/multitest/quick_unbond.rs b/contracts/stake/src/multitest/quick_unbond.rs index f160b2b..68a7e28 100644 --- a/contracts/stake/src/multitest/quick_unbond.rs +++ b/contracts/stake/src/multitest/quick_unbond.rs @@ -1,5 +1,5 @@ use cosmwasm_std::{assert_approx_eq, Decimal}; -use wyndex::asset::{AssetInfo, AssetInfoExt, AssetInfoValidated}; +use palomadex::asset::{AssetInfo, AssetInfoExt, AssetInfoValidated}; use crate::{multitest::suite::SuiteBuilder, ContractError}; diff --git a/contracts/stake/src/multitest/staking_rewards.rs b/contracts/stake/src/multitest/staking_rewards.rs index 13d809a..4237910 100644 --- a/contracts/stake/src/multitest/staking_rewards.rs +++ b/contracts/stake/src/multitest/staking_rewards.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{Decimal, OverflowError, OverflowOperation, StdError, Uint128}; -use wyndex::asset::{AssetInfo, AssetInfoValidated}; -use wyndex::stake::UnbondingPeriod; +use palomadex::asset::{AssetInfo, AssetInfoValidated}; +use palomadex::stake::UnbondingPeriod; use crate::error::ContractError; use crate::msg::{AllStakedResponse, StakedResponse}; diff --git a/contracts/stake/src/multitest/suite.rs b/contracts/stake/src/multitest/suite.rs index 17d6184..c63a0e6 100644 --- a/contracts/stake/src/multitest/suite.rs +++ b/contracts/stake/src/multitest/suite.rs @@ -7,7 +7,7 @@ use cw20::{BalanceResponse, Cw20Coin, Cw20ExecuteMsg, Cw20QueryMsg, MinterRespon use cw20_base::msg::InstantiateMsg as Cw20InstantiateMsg; use cw_controllers::{Claim, ClaimsResponse}; use cw_multi_test::{App, AppResponse, Contract, ContractWrapper, Executor}; -use wyndex::{ +use palomadex::{ asset::{AssetInfo, AssetInfoExt, AssetInfoValidated, AssetValidated}, stake::{InstantiateMsg, UnbondingPeriod}, }; @@ -18,7 +18,7 @@ use crate::msg::{ RewardsPowerResponse, StakedResponse, TotalStakedResponse, UnbondAllResponse, UndistributedRewardsResponse, WithdrawableRewardsResponse, }; -use wyndex::stake::{FundingInfo, ReceiveMsg}; +use palomadex::stake::{FundingInfo, ReceiveMsg}; pub const SEVEN_DAYS: u64 = 604800; diff --git a/contracts/stake/src/multitest/unbond_all.rs b/contracts/stake/src/multitest/unbond_all.rs index 79f92db..c7d7e0d 100644 --- a/contracts/stake/src/multitest/unbond_all.rs +++ b/contracts/stake/src/multitest/unbond_all.rs @@ -3,7 +3,7 @@ use cw20::{Cw20Coin, MinterResponse}; use cw_multi_test::Executor; use cw20_base::msg::InstantiateMsg as Cw20InstantiateMsg; -use wyndex::asset::{AssetInfo, AssetInfoExt, AssetInfoValidated}; +use palomadex::asset::{AssetInfo, AssetInfoExt, AssetInfoValidated}; use crate::{multitest::suite::SuiteBuilder, ContractError}; @@ -294,14 +294,14 @@ fn multiple_distribution_flows() { // Create CW20 token. let token_id = suite.app.store_code(contract_token()); - let wynd_token = suite + let grain_token = suite .app .instantiate_contract( token_id, Addr::unchecked("admin"), &Cw20InstantiateMsg { name: "wynd-token".to_owned(), - symbol: "WYND".to_owned(), + symbol: "PALOMA".to_owned(), decimals: 9, initial_balances: vec![Cw20Coin { // member4 gets some to distribute @@ -334,7 +334,7 @@ fn multiple_distribution_flows() { .create_distribution_flow( "admin", user, - AssetInfo::Token(wynd_token.to_string()), + AssetInfo::Token(grain_token.to_string()), vec![(unbonding_period, Decimal::one())], ) .unwrap(); @@ -348,7 +348,7 @@ fn multiple_distribution_flows() { suite .execute_fund_distribution_with_cw20( user, - AssetInfoValidated::Token(wynd_token).with_balance(400u128), + AssetInfoValidated::Token(grain_token).with_balance(400u128), ) .unwrap(); diff --git a/contracts/stake/src/state.rs b/contracts/stake/src/state.rs index 17cb2b8..161a009 100644 --- a/contracts/stake/src/state.rs +++ b/contracts/stake/src/state.rs @@ -6,8 +6,8 @@ use crate::{utils::calc_power, ContractError}; use cosmwasm_std::{Addr, Decimal, Env, OverflowError, StdResult, Storage, Timestamp, Uint128}; use cw_controllers::{Admin, Claims}; use cw_storage_plus::{Item, Map}; -use wyndex::asset::AssetInfoValidated; -use wyndex::stake::UnbondingPeriod; +use palomadex::asset::AssetInfoValidated; +use palomadex::stake::UnbondingPeriod; pub const CLAIMS: Claims = Claims::new("claims"); diff --git a/packages/wyndex/.cargo/config b/packages/palomadex/.cargo/config similarity index 100% rename from packages/wyndex/.cargo/config rename to packages/palomadex/.cargo/config diff --git a/packages/wyndex/Cargo.toml b/packages/palomadex/Cargo.toml similarity index 76% rename from packages/wyndex/Cargo.toml rename to packages/palomadex/Cargo.toml index 0516db7..ecfdadb 100644 --- a/packages/wyndex/Cargo.toml +++ b/packages/palomadex/Cargo.toml @@ -1,12 +1,12 @@ [package] -name = "wyndex" +name = "palomadex" version = { workspace = true } -authors = ["Cosmorama "] +authors = ["Volume Fi"] edition = { workspace = true } -description = "Common Wyndex types, queriers and other utils" +description = "Common PalomaDex types, queriers and other utils" license = { workspace = true } repository = { workspace = true } -homepage = "https://www.wynddao.com" +homepage = "https://www.palomachain.com" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -24,4 +24,4 @@ cosmwasm-std = { workspace = true } uint = { workspace = true } cw-storage-plus = { workspace = true } itertools = { workspace = true } -cosmwasm-schema = { workspace = true } \ No newline at end of file +cosmwasm-schema = { workspace = true } diff --git a/packages/wyndex/README.md b/packages/palomadex/README.md similarity index 97% rename from packages/wyndex/README.md rename to packages/palomadex/README.md index 4f797ce..7d2fbbf 100644 --- a/packages/wyndex/README.md +++ b/packages/palomadex/README.md @@ -1,6 +1,6 @@ -# Wyndex: Common Types +# PalomaDex: Common Types -This is a collection of common types and queriers which are commonly used in Wyndex contracts. +This is a collection of common types and queriers which are commonly used in PalomaDex contracts. ## Data Types diff --git a/packages/wyndex/src/asset.rs b/packages/palomadex/src/asset.rs similarity index 100% rename from packages/wyndex/src/asset.rs rename to packages/palomadex/src/asset.rs diff --git a/packages/wyndex/src/common.rs b/packages/palomadex/src/common.rs similarity index 100% rename from packages/wyndex/src/common.rs rename to packages/palomadex/src/common.rs diff --git a/packages/wyndex/src/factory.rs b/packages/palomadex/src/factory.rs similarity index 99% rename from packages/wyndex/src/factory.rs rename to packages/palomadex/src/factory.rs index 47877e1..eff0905 100644 --- a/packages/wyndex/src/factory.rs +++ b/packages/palomadex/src/factory.rs @@ -14,7 +14,7 @@ use std::fmt::{Display, Formatter, Result}; /// This enum describes available pair types. /// ## Available pool types /// ``` -/// # use wyndex::factory::PairType::{Custom, Stable, Xyk}; +/// # use palomadex::factory::PairType::{Custom, Stable, Xyk}; /// Xyk {}; /// Stable {}; /// Custom(String::from("Custom")); diff --git a/packages/wyndex/src/fee_config.rs b/packages/palomadex/src/fee_config.rs similarity index 100% rename from packages/wyndex/src/fee_config.rs rename to packages/palomadex/src/fee_config.rs diff --git a/packages/wyndex/src/lib.rs b/packages/palomadex/src/lib.rs similarity index 100% rename from packages/wyndex/src/lib.rs rename to packages/palomadex/src/lib.rs diff --git a/packages/wyndex/src/lp_converter.rs b/packages/palomadex/src/lp_converter.rs similarity index 100% rename from packages/wyndex/src/lp_converter.rs rename to packages/palomadex/src/lp_converter.rs diff --git a/packages/wyndex/src/mock_querier.rs b/packages/palomadex/src/mock_querier.rs similarity index 93% rename from packages/wyndex/src/mock_querier.rs rename to packages/palomadex/src/mock_querier.rs index 2c910e5..34778f7 100644 --- a/packages/wyndex/src/mock_querier.rs +++ b/packages/palomadex/src/mock_querier.rs @@ -11,7 +11,7 @@ use crate::pair::PairInfo; use cw20::{BalanceResponse, Cw20QueryMsg, TokenInfoResponse}; /// mock_dependencies is a drop-in replacement for cosmwasm_std::testing::mock_dependencies -/// This uses the Wyndex CustomQuerier. +/// This uses the Palomadex CustomQuerier. pub fn mock_dependencies( contract_balance: &[Coin], ) -> OwnedDeps { @@ -66,13 +66,13 @@ pub(crate) fn balances_to_map( } #[derive(Clone, Default)] -pub struct WyndexFactoryQuerier { +pub struct PalomadexFactoryQuerier { pairs: HashMap, } -impl WyndexFactoryQuerier { +impl PalomadexFactoryQuerier { pub fn new(pairs: &[(&String, &PairInfo)]) -> Self { - WyndexFactoryQuerier { + PalomadexFactoryQuerier { pairs: pairs_to_map(pairs), } } @@ -173,7 +173,7 @@ impl CW20QueryHandler { struct DefaultQueryHandler { base: MockQuerier, - wyndex_factory_querier: WyndexFactoryQuerier, + palomadex_factory_querier: PalomadexFactoryQuerier, } impl DefaultQueryHandler { @@ -185,7 +185,7 @@ impl DefaultQueryHandler { }) => match from_binary(msg).unwrap() { FactoryQueryMsg::Pair { asset_infos } => { let key = asset_infos[0].to_string() + asset_infos[1].to_string().as_str(); - match self.wyndex_factory_querier.pairs.get(&key) { + match self.palomadex_factory_querier.pairs.get(&key) { Some(v) => SystemResult::Ok(to_binary(&v).into()), None => SystemResult::Err(SystemError::InvalidRequest { error: "No pair info exists".to_string(), @@ -205,7 +205,7 @@ impl WasmMockQuerier { WasmMockQuerier { query_handler: DefaultQueryHandler { base, - wyndex_factory_querier: WyndexFactoryQuerier::default(), + palomadex_factory_querier: PalomadexFactoryQuerier::default(), }, cw20_query_handler: CW20QueryHandler { token_querier: TokenQuerier::default(), @@ -219,9 +219,9 @@ impl WasmMockQuerier { self.cw20_query_handler.token_querier = TokenQuerier::new(balances); } - // Configure the Wyndex pair - pub fn with_wyndex_pairs(&mut self, pairs: &[(&String, &PairInfo)]) { - self.query_handler.wyndex_factory_querier = WyndexFactoryQuerier::new(pairs); + // Configure the Palomadex pair + pub fn with_palomadex_pairs(&mut self, pairs: &[(&String, &PairInfo)]) { + self.query_handler.palomadex_factory_querier = PalomadexFactoryQuerier::new(pairs); } pub fn with_default_query_handler(&mut self) { diff --git a/packages/wyndex/src/oracle.rs b/packages/palomadex/src/oracle.rs similarity index 100% rename from packages/wyndex/src/oracle.rs rename to packages/palomadex/src/oracle.rs diff --git a/packages/wyndex/src/oracle_old.rs b/packages/palomadex/src/oracle_old.rs similarity index 100% rename from packages/wyndex/src/oracle_old.rs rename to packages/palomadex/src/oracle_old.rs diff --git a/packages/wyndex/src/pair.rs b/packages/palomadex/src/pair.rs similarity index 99% rename from packages/wyndex/src/pair.rs rename to packages/palomadex/src/pair.rs index ebae855..7ff0696 100644 --- a/packages/wyndex/src/pair.rs +++ b/packages/palomadex/src/pair.rs @@ -31,7 +31,7 @@ pub use utils::*; /// Decimal precision for TWAP results pub const TWAP_PRECISION: u8 = 6; -/// This structure stores the main parameters for an Wyndex pair +/// This structure stores the main parameters for an Palomadex pair #[cw_serde] pub struct PairInfo { /// Asset information for the assets in the pool @@ -163,7 +163,7 @@ impl StakeConfig { })?, funds: vec![], admin: Some(factory_owner), - label: String::from("Wyndex-Stake"), + label: String::from("Palomadex-Stake"), }) } } diff --git a/packages/wyndex/src/pair/error.rs b/packages/palomadex/src/pair/error.rs similarity index 100% rename from packages/wyndex/src/pair/error.rs rename to packages/palomadex/src/pair/error.rs diff --git a/packages/wyndex/src/pair/instantiate.rs b/packages/palomadex/src/pair/instantiate.rs similarity index 98% rename from packages/wyndex/src/pair/instantiate.rs rename to packages/palomadex/src/pair/instantiate.rs index 8639508..c047a77 100644 --- a/packages/wyndex/src/pair/instantiate.rs +++ b/packages/palomadex/src/pair/instantiate.rs @@ -52,7 +52,7 @@ pub fn create_lp_token( marketing: None, })?, funds: vec![], - label: "Wyndex LP token".to_owned(), + label: "Palomadex LP token".to_owned(), }, INSTANTIATE_TOKEN_REPLY_ID, )) diff --git a/packages/wyndex/src/pair/mock_querier.rs b/packages/palomadex/src/pair/mock_querier.rs similarity index 99% rename from packages/wyndex/src/pair/mock_querier.rs rename to packages/palomadex/src/pair/mock_querier.rs index d1cd46f..5bee51d 100644 --- a/packages/wyndex/src/pair/mock_querier.rs +++ b/packages/palomadex/src/pair/mock_querier.rs @@ -12,7 +12,7 @@ use crate::factory::{ use cw20::{BalanceResponse, Cw20QueryMsg, TokenInfoResponse}; /// mock_dependencies is a drop-in replacement for cosmwasm_std::testing::mock_dependencies. -/// This uses the Wyndex CustomQuerier. +/// This uses the Palomadex CustomQuerier. pub fn mock_dependencies( contract_balance: &[Coin], ) -> OwnedDeps { diff --git a/packages/wyndex/src/pair/referral.rs b/packages/palomadex/src/pair/referral.rs similarity index 100% rename from packages/wyndex/src/pair/referral.rs rename to packages/palomadex/src/pair/referral.rs diff --git a/packages/wyndex/src/pair/utils.rs b/packages/palomadex/src/pair/utils.rs similarity index 100% rename from packages/wyndex/src/pair/utils.rs rename to packages/palomadex/src/pair/utils.rs diff --git a/packages/wyndex/src/querier.rs b/packages/palomadex/src/querier.rs similarity index 99% rename from packages/wyndex/src/querier.rs rename to packages/palomadex/src/querier.rs index d004196..69cc677 100644 --- a/packages/wyndex/src/querier.rs +++ b/packages/palomadex/src/querier.rs @@ -163,7 +163,7 @@ pub fn query_pair_info( } /// Returns a vector that contains items of type [`PairInfo`] which -/// symbolize pairs instantiated in the Wyndex factory +/// symbolize pairs instantiated in the Palomadex factory pub fn query_pairs_info( querier: &QuerierWrapper, factory_contract: impl Into, diff --git a/packages/wyndex/src/stake.rs b/packages/palomadex/src/stake.rs similarity index 100% rename from packages/wyndex/src/stake.rs rename to packages/palomadex/src/stake.rs diff --git a/packages/wyndex/src/testing.rs b/packages/palomadex/src/testing.rs similarity index 98% rename from packages/wyndex/src/testing.rs rename to packages/palomadex/src/testing.rs index 0e995c8..b2d40c6 100644 --- a/packages/wyndex/src/testing.rs +++ b/packages/palomadex/src/testing.rs @@ -200,10 +200,10 @@ fn test_asset() { } #[test] -fn query_wyndex_pair_contract() { +fn query_palomadex_pair_contract() { let mut deps = mock_dependencies(&[]); - deps.querier.with_wyndex_pairs(&[( + deps.querier.with_palomadex_pairs(&[( &"asset0000uusd".to_string(), &PairInfo { asset_infos: vec![ @@ -238,7 +238,7 @@ fn query_wyndex_pair_contract() { #[test] fn test_format_lp_token_name() { let mut deps = mock_dependencies(&[]); - deps.querier.with_wyndex_pairs(&[( + deps.querier.with_palomadex_pairs(&[( &"asset0000uusd".to_string(), &PairInfo { asset_infos: vec![ diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 175f43d..7f39425 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -11,8 +11,8 @@ cosmwasm-std = { workspace = true } cw-multi-test = { workspace = true } cw20 = { workspace = true } cw20-base = { workspace = true } -wyndex = { workspace = true } -wyndex-factory = { workspace = true } -wyndex-multi-hop = { workspace = true } -wyndex-pair = { workspace = true } -wyndex-stake = { workspace = true } +palomadex = { workspace = true } +palomadex-factory = { workspace = true } +palomadex-multi-hop = { workspace = true } +palomadex-pair = { workspace = true } +palomadex-stake = { workspace = true } diff --git a/tests/src/suite.rs b/tests/src/suite.rs index b4aac33..701f8cb 100644 --- a/tests/src/suite.rs +++ b/tests/src/suite.rs @@ -6,25 +6,25 @@ use cw20::{BalanceResponse, Cw20ExecuteMsg, Cw20QueryMsg, MinterResponse}; use cw20_base::msg::InstantiateMsg as Cw20BaseInstantiateMsg; use cw_multi_test::{App, AppResponse, BankSudo, ContractWrapper, Executor, SudoMsg}; -use wyndex::asset::{Asset, AssetInfo}; -use wyndex::factory::{ +use palomadex::asset::{Asset, AssetInfo}; +use palomadex::factory::{ DefaultStakeConfig, DistributionFlow, ExecuteMsg as FactoryExecuteMsg, InstantiateMsg as FactoryInstantiateMsg, PairConfig, PairType, PartialStakeConfig, QueryMsg as FactoryQueryMsg, }; -use wyndex::fee_config::FeeConfig; -use wyndex::pair::{ExecuteMsg as PairExecuteMsg, PairInfo}; -use wyndex::stake::UnbondingPeriod; -use wyndex_multi_hop::msg::{ +use palomadex::fee_config::FeeConfig; +use palomadex::pair::{ExecuteMsg as PairExecuteMsg, PairInfo}; +use palomadex::stake::UnbondingPeriod; +use palomadex_multi_hop::msg::{ ExecuteMsg, InstantiateMsg, QueryMsg, SimulateSwapOperationsResponse, SwapOperation, }; -use wyndex_stake::msg::ExecuteMsg as StakeExecuteMsg; +use palomadex_stake::msg::ExecuteMsg as StakeExecuteMsg; fn store_multi_hop(app: &mut App) -> u64 { let contract = Box::new(ContractWrapper::new_with_empty( - wyndex_multi_hop::contract::execute, - wyndex_multi_hop::contract::instantiate, - wyndex_multi_hop::contract::query, + palomadex_multi_hop::contract::execute, + palomadex_multi_hop::contract::instantiate, + palomadex_multi_hop::contract::query, )); app.store_code(contract) @@ -33,11 +33,11 @@ fn store_multi_hop(app: &mut App) -> u64 { fn store_factory(app: &mut App) -> u64 { let contract = Box::new( ContractWrapper::new_with_empty( - wyndex_factory::contract::execute, - wyndex_factory::contract::instantiate, - wyndex_factory::contract::query, + palomadex_factory::contract::execute, + palomadex_factory::contract::instantiate, + palomadex_factory::contract::query, ) - .with_reply_empty(wyndex_factory::contract::reply), + .with_reply_empty(palomadex_factory::contract::reply), ); app.store_code(contract) @@ -46,11 +46,11 @@ fn store_factory(app: &mut App) -> u64 { fn store_pair(app: &mut App) -> u64 { let contract = Box::new( ContractWrapper::new_with_empty( - wyndex_pair::contract::execute, - wyndex_pair::contract::instantiate, - wyndex_pair::contract::query, + palomadex_pair::contract::execute, + palomadex_pair::contract::instantiate, + palomadex_pair::contract::query, ) - .with_reply_empty(wyndex_pair::contract::reply), + .with_reply_empty(palomadex_pair::contract::reply), ); app.store_code(contract) @@ -58,9 +58,9 @@ fn store_pair(app: &mut App) -> u64 { fn store_staking(app: &mut App) -> u64 { let contract = Box::new(ContractWrapper::new( - wyndex_stake::contract::execute, - wyndex_stake::contract::instantiate, - wyndex_stake::contract::query, + palomadex_stake::contract::execute, + palomadex_stake::contract::instantiate, + palomadex_stake::contract::query, )); app.store_code(contract) @@ -172,7 +172,7 @@ impl SuiteBuilder { trading_starts: self.trading_starts, }, &[], - "Wyndex Factory", + "Palomadex Factory", None, ) .unwrap(); @@ -183,10 +183,10 @@ impl SuiteBuilder { multi_hop_code_id, owner.clone(), &InstantiateMsg { - wyndex_factory: factory.to_string(), + palomadex_factory: factory.to_string(), }, &[], - "Wyndex Multi Hop", + "Palomadex Multi Hop", None, ) .unwrap(); diff --git a/tests/tests/staking.rs b/tests/tests/staking.rs index d8b88a0..5ad9fd9 100644 --- a/tests/tests/staking.rs +++ b/tests/tests/staking.rs @@ -2,16 +2,16 @@ use tests::SuiteBuilder; use cosmwasm_std::{coin, from_slice, Addr, Decimal, Uint128}; -use wyndex::{ +use palomadex::{ asset::{AssetInfo, AssetInfoExt}, factory::PartialStakeConfig, stake::ReceiveMsg, }; -use wyndex_stake::msg::{QueryMsg as StakeQueryMsg, StakedResponse}; -use wyndex_stake::state::Config as WyndexStakeConfig; +use palomadex_stake::msg::{QueryMsg as StakeQueryMsg, StakedResponse}; +use palomadex_stake::state::Config as PalomadexStakeConfig; mod staking { - use wyndex::factory::{DefaultStakeConfig, DistributionFlow}; + use palomadex::factory::{DefaultStakeConfig, DistributionFlow}; use super::*; @@ -44,7 +44,7 @@ mod staking { let pair = suite .create_pair( "owner", - wyndex::factory::PairType::Xyk {}, + palomadex::factory::PairType::Xyk {}, [ujuno_info.clone(), uluna_info.clone()], Some(PartialStakeConfig { tokens_per_power: Some(Uint128::new(100)), @@ -124,7 +124,7 @@ mod staking { // create a pair let pair = suite .create_pair_and_provide_liquidity( - wyndex::factory::PairType::Xyk {}, + palomadex::factory::PairType::Xyk {}, (ujuno_info.clone(), 100_000), (uluna_info.clone(), 100_000), vec![coin(100_000, ujuno), coin(100_000, uluna)], @@ -134,13 +134,13 @@ mod staking { // get info with staking contract address let pair_info = suite.query_pair(vec![ujuno_info, uluna_info]).unwrap(); - let stake_config: WyndexStakeConfig = from_slice( + let stake_config: PalomadexStakeConfig = from_slice( &suite .app .wrap() .query_wasm_raw( pair_info.staking_addr, - wyndex_pair::state::CONFIG.as_slice(), + palomadex_pair::state::CONFIG.as_slice(), ) .unwrap() .unwrap(), @@ -191,7 +191,7 @@ mod staking { suite .create_pair_and_distributions( owner, - wyndex::factory::PairType::Xyk {}, + palomadex::factory::PairType::Xyk {}, vec![ujuno_info.clone(), uluna_info.clone()], None, vec![ diff --git a/tests/tests/swap.rs b/tests/tests/swap.rs index bc7b15c..7dc4a8f 100644 --- a/tests/tests/swap.rs +++ b/tests/tests/swap.rs @@ -1,7 +1,7 @@ use cosmwasm_std::{coin, testing::mock_env}; +use palomadex::asset::{AssetInfo, AssetInfoExt}; +use palomadex_multi_hop::msg::SwapOperation; use tests::SuiteBuilder; -use wyndex::asset::{AssetInfo, AssetInfoExt}; -use wyndex_multi_hop::msg::SwapOperation; #[test] fn trading_frozen() { @@ -19,7 +19,7 @@ fn trading_frozen() { suite .create_pair_and_provide_liquidity( - wyndex::factory::PairType::Xyk {}, + palomadex::factory::PairType::Xyk {}, (ujuno_info.clone(), 1_000_000), (uluna_info.clone(), 1_000_000), vec![coin(1_000_000, ujuno), coin(1_000_000, uluna)], @@ -30,7 +30,7 @@ fn trading_frozen() { .swap_operations( user, coin(1000, ujuno), - vec![SwapOperation::WyndexSwap { + vec![SwapOperation::PalomadexSwap { ask_asset_info: uluna_info.clone(), offer_asset_info: ujuno_info.clone(), }], @@ -46,7 +46,7 @@ fn trading_frozen() { .swap_operations( user, coin(1000, ujuno), - vec![SwapOperation::WyndexSwap { + vec![SwapOperation::PalomadexSwap { ask_asset_info: uluna_info, offer_asset_info: ujuno_info, }], @@ -70,7 +70,7 @@ fn custom_fee_works() { let pair = suite .create_pair( &suite.owner.clone(), - wyndex::factory::PairType::Xyk {}, + palomadex::factory::PairType::Xyk {}, [ujuno_info.clone(), uluna_info.clone()], None, 5_000.into(), // 50% fee for this pair @@ -93,7 +93,7 @@ fn custom_fee_works() { .swap_operations( user, coin(1000, ujuno), - vec![SwapOperation::WyndexSwap { + vec![SwapOperation::PalomadexSwap { ask_asset_info: uluna_info, offer_asset_info: ujuno_info, }],