diff --git a/Cargo.lock b/Cargo.lock index 1e8d1961c..767759528 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -65,8 +65,7 @@ dependencies = [ [[package]] name = "astroport" -version = "2.6.0" -source = "git+https://github.com/astroport-fi/astroport-core?branch=main#e79dc1213cd7535d8e09b713c9d259d5e8564a58" +version = "2.7.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -80,6 +79,7 @@ dependencies = [ [[package]] name = "astroport" version = "2.7.1" +source = "git+https://github.com/astroport-fi/astroport-core?branch=main#c73a2db3c0b4f069e906d90970e1b72a5cf71bbf" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -386,7 +386,7 @@ dependencies = [ "derivative", "itertools", "proptest", - "prost 0.11.8", + "prost 0.11.9", "sim", "thiserror", ] @@ -1075,13 +1075,13 @@ dependencies = [ [[package]] name = "errno" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d6a0976c999d473fe89ad888d5a284e55366d9dc9038b1ba2aa15128c4afa0" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" dependencies = [ "errno-dragonfly", "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1146,7 +1146,7 @@ version = "0.0.0" source = "git+https://github.com/astroport-fi/astro-generator-proxy-contracts?branch=main#e573a8f8542b99015cac910f024a5f20fd793f3c" dependencies = [ "ap-valkyrie", - "astroport 2.6.0", + "astroport 2.7.1 (git+https://github.com/astroport-fi/astroport-core?branch=main)", "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus 0.15.1", @@ -1168,9 +1168,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" dependencies = [ "cfg-if", "libc", @@ -1244,13 +1244,13 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09270fd4fa1111bc614ed2246c7ef56239a3063d5be0d1ec3b589c505d400aeb" +checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" dependencies = [ "hermit-abi", "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1365,7 +1365,7 @@ dependencies = [ "libc", "redox_syscall 0.2.16", "smallvec", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -1426,12 +1426,12 @@ dependencies = [ [[package]] name = "prost" -version = "0.11.8" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e48e50df39172a3e7eb17e14642445da64996989bc212b583015435d39a58537" +checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" dependencies = [ "bytes", - "prost-derive 0.11.8", + "prost-derive 0.11.9", ] [[package]] @@ -1449,9 +1449,9 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.11.8" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ea9b0f8cbe5e15a8a042d030bd96668db28ecb567ec37d691971ff5731d2b1b" +checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" dependencies = [ "anyhow", "itertools", @@ -1471,9 +1471,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.18.2" +version = "0.18.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfb848f80438f926a9ebddf0a539ed6065434fd7aae03a89312a9821f81b8501" +checksum = "e3b1ac5b3731ba34fdaa9785f8d74d17448cd18f30cf19e0c7e7b1fdb5272109" dependencies = [ "cfg-if", "indoc", @@ -1488,9 +1488,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.18.2" +version = "0.18.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98a42e7f42e917ce6664c832d5eee481ad514c98250c49e0b03b20593e2c7ed0" +checksum = "9cb946f5ac61bb61a5014924910d936ebd2b23b705f7a4a3c40b05c720b079a3" dependencies = [ "once_cell", "target-lexicon", @@ -1498,9 +1498,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.18.2" +version = "0.18.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0707f0ab26826fe4ccd59b69106e9df5e12d097457c7b8f9c0fd1d2743eec4d" +checksum = "fd4d7c5337821916ea2a1d21d1092e8443cf34879e53a0ac653fbb98f44ff65c" dependencies = [ "libc", "pyo3-build-config", @@ -1508,9 +1508,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.18.2" +version = "0.18.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978d18e61465ecd389e1f235ff5a467146dc4e3c3968b90d274fe73a5dd4a438" +checksum = "a9d39c55dab3fc5a4b25bbd1ac10a2da452c4aca13bb450f22818a002e29648d" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -1520,9 +1520,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.18.2" +version = "0.18.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e0e1128f85ce3fca66e435e08aa2089a2689c1c48ce97803e13f63124058462" +checksum = "97daff08a4c48320587b5224cc98d609e3c27b6d437315bd40b605c98eeb5918" dependencies = [ "proc-macro2", "quote", @@ -1632,16 +1632,16 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.7" +version = "0.37.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aae838e49b3d63e9274e1c01833cc8139d3fec468c3b84688c628f44b1ae11d" +checksum = "85597d61f83914ddeba6a47b3b8ffe7365107221c2e557ed94426489fefb5f77" dependencies = [ "bitflags", "errno", "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1714,31 +1714,31 @@ checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" [[package]] name = "serde" -version = "1.0.159" +version = "1.0.160" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c04e8343c3daeec41f58990b9d77068df31209f2af111e059e9fe9646693065" +checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c" dependencies = [ "serde_derive", ] [[package]] name = "serde-json-wasm" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15bee9b04dd165c3f4e142628982ddde884c2022a89e8ddf99c4829bf2c3a58" +checksum = "16a62a1fad1e1828b24acac8f2b468971dade7b8c3c2e672bcadefefb1f8c137" dependencies = [ "serde", ] [[package]] name = "serde_derive" -version = "1.0.159" +version = "1.0.160" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c614d17805b093df4b147b51339e7e44bf05ef59fba1e45d83500bcfb4d8585" +checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.15", ] [[package]] @@ -1754,9 +1754,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.95" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d721eca97ac802aa7777b701877c8004d950fc142651367300d21c1cc0194744" +checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" dependencies = [ "itoa", "ryu", @@ -1867,9 +1867,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.13" +version = "2.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c9da457c5285ac1f936ebd076af6dac17a61cfe7826f2076b4d015cf47bc8ec" +checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" dependencies = [ "proc-macro2", "quote", @@ -1892,7 +1892,7 @@ dependencies = [ "fastrand", "redox_syscall 0.3.5", "rustix", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -1912,7 +1912,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.15", ] [[package]] @@ -2052,7 +2052,16 @@ version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" dependencies = [ - "windows-targets", + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.0", ] [[package]] @@ -2061,13 +2070,28 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-targets" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +dependencies = [ + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", ] [[package]] @@ -2076,42 +2100,84 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" + [[package]] name = "windows_aarch64_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" + [[package]] name = "windows_i686_gnu" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +[[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" + [[package]] name = "windows_i686_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +[[package]] +name = "windows_i686_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" + [[package]] name = "windows_x86_64_gnu" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" + [[package]] name = "windows_x86_64_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" + [[package]] name = "zeroize" version = "1.6.0" diff --git a/contracts/pair/src/contract.rs b/contracts/pair/src/contract.rs index 891a7ef9a..22add22e4 100644 --- a/contracts/pair/src/contract.rs +++ b/contracts/pair/src/contract.rs @@ -552,12 +552,8 @@ pub fn withdraw_liquidity( // Update the pool info let messages: Vec = vec![ - refund_assets[0] - .clone() - .into_msg(&deps.querier, sender.clone())?, - refund_assets[1] - .clone() - .into_msg(&deps.querier, sender.clone())?, + refund_assets[0].clone().into_msg(sender.clone())?, + refund_assets[1].clone().into_msg(sender.clone())?, CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: config.pair_info.liquidity_token.to_string(), msg: to_binary(&Cw20ExecuteMsg::Burn { amount })?, @@ -678,17 +674,15 @@ pub fn swap( spread_amount, )?; - // Compute the tax for the receiving asset (if it is a native one) let return_asset = Asset { info: ask_pool.info.clone(), amount: return_amount, }; - let tax_amount = return_asset.compute_tax(&deps.querier)?; let receiver = to.unwrap_or_else(|| sender.clone()); let mut messages = vec![]; if !return_amount.is_zero() { - messages.push(return_asset.into_msg(&deps.querier, receiver.clone())?) + messages.push(return_asset.into_msg(receiver.clone())?) } // Compute the Maker fee @@ -698,7 +692,7 @@ pub fn swap( calculate_maker_fee(&ask_pool.info, commission_amount, fee_info.maker_fee_rate) { maker_fee_amount = f.amount; - messages.push(f.into_msg(&deps.querier, fee_address)?); + messages.push(f.into_msg(fee_address)?); } } @@ -741,7 +735,6 @@ pub fn swap( attr("ask_asset", ask_pool.info.to_string()), attr("offer_amount", offer_amount), attr("return_amount", return_amount), - attr("tax_amount", tax_amount), attr("spread_amount", spread_amount), attr("commission_amount", commission_amount), attr("maker_fee_amount", maker_fee_amount), diff --git a/contracts/pair/src/testing.rs b/contracts/pair/src/testing.rs index d70ff7b6a..691855927 100644 --- a/contracts/pair/src/testing.rs +++ b/contracts/pair/src/testing.rs @@ -824,7 +824,6 @@ fn try_native_to_token() { let expected_return_amount = expected_ret_amount .checked_sub(expected_commission_amount) .unwrap(); - let expected_tax_amount = Uint128::zero(); // no tax for token // Check simulation result deps.querier.with_balance(&[( @@ -920,7 +919,6 @@ fn try_native_to_token() { attr("ask_asset", "asset0000"), attr("offer_amount", offer_amount.to_string()), attr("return_amount", expected_return_amount.to_string()), - attr("tax_amount", expected_tax_amount.to_string()), attr("spread_amount", expected_spread_amount.to_string()), attr("commission_amount", expected_commission_amount.to_string()), attr("maker_fee_amount", expected_maker_fee_amount.to_string()), @@ -1111,7 +1109,6 @@ fn try_token_to_native() { attr("ask_asset", "uusd"), attr("offer_amount", offer_amount.to_string()), attr("return_amount", expected_return_amount.to_string()), - attr("tax_amount", Uint128::zero().to_string()), attr("spread_amount", expected_spread_amount.to_string()), attr("commission_amount", expected_commission_amount.to_string()), attr("maker_fee_amount", expected_maker_fee_amount.to_string()), @@ -1201,36 +1198,6 @@ fn test_max_spread() { .unwrap_err(); } -#[test] -#[ignore] -fn test_deduct() { - let deps = mock_dependencies(&[]); - - let tax_rate = Decimal::percent(2); - let tax_cap = Uint128::from(1_000_000u128); - // deps.querier.with_tax( - // Decimal::percent(2), - // &[(&"uusd".to_string(), &Uint128::from(1000000u128))], - // ); - - let amount = Uint128::new(1000_000_000u128); - let expected_after_amount = std::cmp::max( - amount.checked_sub(amount * tax_rate).unwrap(), - amount.checked_sub(tax_cap).unwrap(), - ); - - let after_amount = (Asset { - info: AssetInfo::NativeToken { - denom: "uusd".to_string(), - }, - amount, - }) - .deduct_tax(&deps.as_ref().querier) - .unwrap(); - - assert_eq!(expected_after_amount, after_amount.amount); -} - #[test] fn test_query_pool() { let total_share_amount = Uint128::from(111u128); diff --git a/contracts/pair_concentrated/src/contract.rs b/contracts/pair_concentrated/src/contract.rs index 9567cf6f0..e19085fb7 100644 --- a/contracts/pair_concentrated/src/contract.rs +++ b/contracts/pair_concentrated/src/contract.rs @@ -635,7 +635,7 @@ fn withdraw_liquidity( refund_assets .iter() .cloned() - .map(|asset| asset.into_msg(&deps.querier, &sender)) + .map(|asset| asset.into_msg(&sender)) .collect::>>()?, ); messages.push( @@ -752,7 +752,7 @@ fn swap( info: pools[ask_ind].info.clone(), amount: return_amount, } - .into_msg(&deps.querier, &receiver)?]; + .into_msg(&receiver)?]; let mut maker_fee = Uint128::zero(); if let Some(fee_address) = fee_info.fee_address { @@ -762,7 +762,7 @@ fn swap( info: pools[ask_ind].info.clone(), amount: maker_fee, }; - messages.push(fee.into_msg(&deps.querier, fee_address)?); + messages.push(fee.into_msg(fee_address)?); } } diff --git a/contracts/pair_stable/src/contract.rs b/contracts/pair_stable/src/contract.rs index dba041308..1f1c17b4d 100644 --- a/contracts/pair_stable/src/contract.rs +++ b/contracts/pair_stable/src/contract.rs @@ -559,7 +559,7 @@ pub fn withdraw_liquidity( let mut messages = refund_assets .clone() .into_iter() - .map(|asset| asset.into_msg(&deps.querier, &sender)) + .map(|asset| asset.into_msg(&sender)) .collect::>>()?; messages.push( wasm_execute( @@ -691,7 +691,7 @@ pub fn swap( let mut messages = vec![]; if !return_amount.is_zero() { - messages.push(return_asset.into_msg(&deps.querier, receiver.clone())?) + messages.push(return_asset.into_msg(receiver.clone())?) } // Compute the Maker fee @@ -701,7 +701,7 @@ pub fn swap( calculate_maker_fee(&ask_pool.info, commission_amount, fee_info.maker_fee_rate) { maker_fee_amount = f.amount; - messages.push(f.into_msg(&deps.querier, fee_address)?); + messages.push(f.into_msg(fee_address)?); } } diff --git a/contracts/router/src/contract.rs b/contracts/router/src/contract.rs index edb711b8e..7acf5128e 100644 --- a/contracts/router/src/contract.rs +++ b/contracts/router/src/contract.rs @@ -331,19 +331,7 @@ fn simulate_swap_operations( &[offer_asset_info.clone(), ask_asset_info.clone()], )?; - // Deduct tax - if let AssetInfo::NativeToken { denom } = &offer_asset_info { - let asset = Asset { - info: AssetInfo::NativeToken { - denom: denom.to_string(), - }, - amount: return_amount, - }; - - return_amount = return_amount.checked_sub(asset.compute_tax(&deps.querier)?)?; - } - - let mut res: SimulationResponse = deps.querier.query_wasm_smart( + let res: SimulationResponse = deps.querier.query_wasm_smart( pair_info.contract_addr, &PairQueryMsg::Simulation { offer_asset: Asset { @@ -354,18 +342,6 @@ fn simulate_swap_operations( }, )?; - // Deduct tax - if let AssetInfo::NativeToken { denom } = ask_asset_info { - let asset = Asset { - info: AssetInfo::NativeToken { denom }, - amount: res.return_amount, - }; - - res.return_amount = res - .return_amount - .checked_sub(asset.compute_tax(&deps.querier)?)?; - } - return_amount = res.return_amount; } SwapOperation::NativeSwap { .. } => { diff --git a/contracts/router/src/operations.rs b/contracts/router/src/operations.rs index 441a65919..759e49e4d 100644 --- a/contracts/router/src/operations.rs +++ b/contracts/router/src/operations.rs @@ -56,7 +56,6 @@ pub fn execute_swap_operation( }; asset_into_swap_msg( - deps, pair_info.contract_addr.to_string(), offer_asset, ask_asset_info, @@ -85,7 +84,6 @@ pub fn execute_swap_operation( /// /// * **single** defines whether this swap is single or part of a multi hop route. pub fn asset_into_swap_msg( - deps: DepsMut, pair_contract: String, offer_asset: Asset, ask_asset_info: AssetInfo, @@ -97,29 +95,23 @@ pub fn asset_into_swap_msg( let belief_price = if single { None } else { Some(Decimal::MAX) }; match &offer_asset.info { - AssetInfo::NativeToken { denom } => { - // Deduct tax first - let amount = offer_asset - .amount - .checked_sub(offer_asset.compute_tax(&deps.querier)?)?; - Ok(CosmosMsg::Wasm(WasmMsg::Execute { - contract_addr: pair_contract, - funds: vec![Coin { - denom: denom.to_string(), - amount, - }], - msg: to_binary(&PairExecuteMsg::Swap { - offer_asset: Asset { - amount, - ..offer_asset - }, - ask_asset_info: Some(ask_asset_info), - belief_price, - max_spread, - to, - })?, - })) - } + AssetInfo::NativeToken { denom } => Ok(CosmosMsg::Wasm(WasmMsg::Execute { + contract_addr: pair_contract, + funds: vec![Coin { + denom: denom.to_string(), + amount: offer_asset.amount, + }], + msg: to_binary(&PairExecuteMsg::Swap { + offer_asset: Asset { + amount: offer_asset.amount, + ..offer_asset + }, + ask_asset_info: Some(ask_asset_info), + belief_price, + max_spread, + to, + })?, + })), AssetInfo::Token { contract_addr } => Ok(CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: contract_addr.to_string(), funds: vec![], diff --git a/contracts/router/src/testing/tests.rs b/contracts/router/src/testing/tests.rs index 804f4001a..84597e83e 100644 --- a/contracts/router/src/testing/tests.rs +++ b/contracts/router/src/testing/tests.rs @@ -429,8 +429,7 @@ fn query_buy_with_routes() { assert_eq!( res, SimulateSwapOperationsResponse { - amount: Uint128::from(1000000u128) // tax rate in Terra is set to zero https://terrawiki.org/en/developers/tx-fees - // amount: Uint128::from(952380u128), // tax charged 1 times uusd => ukrw, ukrw => asset0000, asset0000 => uluna + amount: Uint128::from(1000000u128) } ); @@ -438,8 +437,6 @@ fn query_buy_with_routes() { res, SimulateSwapOperationsResponse { amount: Uint128::from(1000000u128), - // tax rate in Terra is set to zero https://terrawiki.org/en/developers/tx-fees - // amount: Uint128::from(952380u128), // tax charged 1 times uusd => ukrw, ukrw => uluna } ); } diff --git a/contracts/tokenomics/generator/src/contract.rs b/contracts/tokenomics/generator/src/contract.rs index 241e9d75d..5d8cb293c 100644 --- a/contracts/tokenomics/generator/src/contract.rs +++ b/contracts/tokenomics/generator/src/contract.rs @@ -1080,7 +1080,7 @@ pub fn send_pending_rewards( info: asset_info, amount: pending_proxy_rewards, } - .into_msg(&deps.querier, to.clone())?], + .into_msg(to.clone())?], })?, }); } @@ -1349,7 +1349,7 @@ fn send_orphan_proxy_rewards( info: asset_info, amount: *amount, } - .into_msg(&deps.querier, &recipient)?], + .into_msg(&recipient)?], })?, }) } diff --git a/contracts/tokenomics/maker/src/contract.rs b/contracts/tokenomics/maker/src/contract.rs index ca9507079..630d99f5a 100644 --- a/contracts/tokenomics/maker/src/contract.rs +++ b/contracts/tokenomics/maker/src/contract.rs @@ -386,7 +386,6 @@ fn swap( )?; let msg = build_swap_msg( - &deps.querier, cfg.max_spread, &bridge_pool, &from_token, @@ -593,10 +592,9 @@ fn distribute( amount, }; - result.push(SubMsg::new(asset.into_msg( - &deps.querier, - second_receiver_cfg.second_fee_receiver.to_string(), - )?)) + result.push(SubMsg::new( + asset.into_msg(second_receiver_cfg.second_fee_receiver.to_string())?, + )) } amount @@ -632,9 +630,7 @@ fn distribute( info: cfg.astro_token.clone(), amount, }; - result.push(SubMsg::new( - to_staking_asset.into_msg(&deps.querier, staking_contract)?, - )); + result.push(SubMsg::new(to_staking_asset.into_msg(staking_contract)?)); } } diff --git a/contracts/tokenomics/maker/src/utils.rs b/contracts/tokenomics/maker/src/utils.rs index f88d97fe3..c2550fd76 100644 --- a/contracts/tokenomics/maker/src/utils.rs +++ b/contracts/tokenomics/maker/src/utils.rs @@ -35,7 +35,7 @@ pub fn try_build_swap_msg( amount_in: Uint128, ) -> Result { let pool = get_pool(querier, &cfg.factory_contract, from, to)?; - let msg = build_swap_msg(querier, cfg.max_spread, &pool, from, Some(to), amount_in)?; + let msg = build_swap_msg(cfg.max_spread, &pool, from, Some(to), amount_in)?; Ok(msg) } @@ -51,7 +51,6 @@ pub fn try_build_swap_msg( /// /// * **amount_in** amount of tokens to swap. pub fn build_swap_msg( - querier: &QuerierWrapper, max_spread: Decimal, pool: &PairInfo, from: &AssetInfo, @@ -59,24 +58,21 @@ pub fn build_swap_msg( amount_in: Uint128, ) -> Result { if from.is_native_token() { - let mut offer_asset = Asset { + let offer_asset = Asset { info: from.clone(), amount: amount_in, }; - // Deduct tax - let coin = offer_asset.deduct_tax(querier)?; - offer_asset.amount = coin.amount; Ok(SubMsg::new(WasmMsg::Execute { contract_addr: pool.contract_addr.to_string(), msg: to_binary(&astroport::pair::ExecuteMsg::Swap { - offer_asset, + offer_asset: offer_asset.clone(), ask_asset_info: to.cloned(), belief_price: None, max_spread: Some(max_spread), to: None, })?, - funds: vec![coin], + funds: vec![offer_asset.to_coin()?], })) } else { Ok(SubMsg::new(WasmMsg::Execute { diff --git a/contracts/tokenomics/vesting/src/contract.rs b/contracts/tokenomics/vesting/src/contract.rs index e616fb32e..632cc9933 100644 --- a/contracts/tokenomics/vesting/src/contract.rs +++ b/contracts/tokenomics/vesting/src/contract.rs @@ -266,7 +266,6 @@ pub fn claim( if !claim_amount.is_zero() { let transfer_msg = config.vesting_token.with_balance(claim_amount).into_msg( - &deps.querier, addr_opt_validate(deps.api, &recipient)?.unwrap_or_else(|| info.sender.clone()), )?; response = response.add_submessage(SubMsg::new(transfer_msg)); @@ -408,7 +407,7 @@ fn withdraw_from_active_schedule( let transfer_msg = config .vesting_token .with_balance(amount) - .into_msg(&deps.querier, receiver.clone())?; + .into_msg(receiver.clone())?; Ok(Response::new().add_message(transfer_msg).add_attributes([ attr("action", "withdraw_from_active_schedule"), diff --git a/packages/astroport/src/asset.rs b/packages/astroport/src/asset.rs index 8f438d6e5..b78c51977 100644 --- a/packages/astroport/src/asset.rs +++ b/packages/astroport/src/asset.rs @@ -53,33 +53,23 @@ impl Asset { self.info.is_native_token() } - /// Calculates and returns a tax for a chain's native token. For other tokens it returns zero. - pub fn compute_tax(&self, _querier: &QuerierWrapper) -> StdResult { - // tax rate in Terra is set to zero https://terrawiki.org/en/developers/tx-fees - Ok(Uint128::zero()) - } - - /// Calculates and returns a deducted tax for transferring the native token from the chain. For other tokens it returns an [`Err`]. - pub fn deduct_tax(&self, querier: &QuerierWrapper) -> StdResult { + /// Convert a native token of type [`AssetInfo`] to a coin of type [`Coin`]. + /// For other tokens it returns an [`Err`]. + pub fn to_coin(&self) -> StdResult { if let AssetInfo::NativeToken { denom } = &self.info { Ok(Coin { denom: denom.to_string(), - amount: self.amount.checked_sub(self.compute_tax(querier)?)?, + amount: self.amount, }) } else { - Err(StdError::generic_err("cannot deduct tax from token asset")) + Err(StdError::generic_err("Cannot convert token asset to Coin")) } } - /// For native tokens of type [`AssetInfo`] uses the default method [`BankMsg::Send`] to send a token amount to a recipient. - /// Before the token is sent, we need to deduct a tax. - /// - /// For a token of type [`AssetInfo`] we use the default method [`Cw20ExecuteMsg::Transfer`] and so there's no need to deduct any other tax. - pub fn into_msg( - self, - querier: &QuerierWrapper, - recipient: impl Into, - ) -> StdResult { + /// For native tokens of type [`AssetInfo`] uses the default method [`BankMsg::Send`] to send a + /// token amount to a recipient. + /// For a token of type [`AssetInfo`] we use the default method [`Cw20ExecuteMsg::Transfer`]. + pub fn into_msg(self, recipient: impl Into) -> StdResult { let recipient = recipient.into(); match &self.info { AssetInfo::Token { contract_addr } => Ok(CosmosMsg::Wasm(WasmMsg::Execute { @@ -92,7 +82,7 @@ impl Asset { })), AssetInfo::NativeToken { .. } => Ok(CosmosMsg::Bank(BankMsg::Send { to_address: recipient, - amount: vec![self.deduct_tax(querier)?], + amount: vec![self.to_coin()?], })), } } diff --git a/packages/astroport/src/testing.rs b/packages/astroport/src/testing.rs index 792098b13..de0e428de 100644 --- a/packages/astroport/src/testing.rs +++ b/packages/astroport/src/testing.rs @@ -189,30 +189,7 @@ fn test_asset() { }; assert_eq!( - token_asset.compute_tax(&deps.as_ref().querier).unwrap(), - Uint128::zero() - ); - assert_eq!( - native_token_asset - .compute_tax(&deps.as_ref().querier) - .unwrap(), - Uint128::zero() - ); - - assert_eq!( - native_token_asset - .deduct_tax(&deps.as_ref().querier) - .unwrap(), - Coin { - denom: "uusd".to_string(), - amount: Uint128::new(123123u128), - } - ); - - assert_eq!( - token_asset - .into_msg(&deps.as_ref().querier, Addr::unchecked("addr0000")) - .unwrap(), + token_asset.into_msg(Addr::unchecked("addr0000")).unwrap(), CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: String::from("asset0000"), msg: to_binary(&Cw20ExecuteMsg::Transfer { @@ -226,7 +203,7 @@ fn test_asset() { assert_eq!( native_token_asset - .into_msg(&deps.as_ref().querier, Addr::unchecked("addr0000")) + .into_msg(Addr::unchecked("addr0000")) .unwrap(), CosmosMsg::Bank(BankMsg::Send { to_address: String::from("addr0000"), diff --git a/packages/pair_bonded/src/base.rs b/packages/pair_bonded/src/base.rs index e8899b131..00aa2d5f6 100644 --- a/packages/pair_bonded/src/base.rs +++ b/packages/pair_bonded/src/base.rs @@ -384,17 +384,13 @@ pub trait PairBonded<'a> { let offer_amount = offer_asset.amount; let return_amount = ask_asset_info.query_pool(&deps.querier, env.contract.address)?; - // Compute the tax for the receiving asset (if it is a native one) - let mut return_asset = Asset { + let return_asset = Asset { info: ask_asset_info.clone(), amount: return_amount, }; - let tax_amount = return_asset.compute_tax(&deps.querier)?; - return_asset.amount -= tax_amount; - Ok(Response::new() - .add_message(return_asset.into_msg(&deps.querier, receiver.clone())?) + .add_message(return_asset.into_msg(receiver.clone())?) .add_attribute("action", "swap") .add_attribute("sender", sender.to_string()) .add_attribute("receiver", receiver.to_string()) @@ -402,7 +398,6 @@ pub trait PairBonded<'a> { .add_attribute("ask_asset", ask_asset_info.to_string()) .add_attribute("offer_amount", offer_amount.to_string()) .add_attribute("return_amount", return_amount.to_string()) - .add_attribute("tax_amount", tax_amount.to_string()) .add_attribute("spread_amount", "0") .add_attribute("commission_amount", "0") .add_attribute("maker_fee_amount", "0"))