diff --git a/checksum b/checksum index d38aed15..b95c31cf 100644 --- a/checksum +++ b/checksum @@ -1,2 +1,2 @@ -c678d3d62965d9ba4982766fbd4bafcb8d7c0df2bdc089da0f975f3d78c84c0d cw_croncat.wasm +5b3d3dcfb83ae291ee39c7c3f34626995036caa6deec74a08f08b163fbbb9ecc cw_croncat.wasm 348ce203ce7a18c2e28f001139c1f7a215f7a569c735825dc819dc79692aaffb cw_rules.wasm diff --git a/ci/gas-benchmark/src/helpers.rs b/ci/gas-benchmark/src/helpers.rs index e4a38891..e943fe4f 100644 --- a/ci/gas-benchmark/src/helpers.rs +++ b/ci/gas-benchmark/src/helpers.rs @@ -14,12 +14,12 @@ use cosm_orc::{ use cosmwasm_std::Binary; use cw20::Cw20Coin; use cw_croncat::contract::{ - GAS_ACTION_FEE, GAS_BASE_FEE, GAS_DENOMINATOR, GAS_NUMERATOR_DEFAULT, GAS_QUERY_FEE, - GAS_WASM_QUERY_FEE, + GAS_ACTION_FEE, GAS_ADJUSTMENT_NUMERATOR_DEFAULT, GAS_BASE_FEE, GAS_DENOMINATOR, + GAS_NUMERATOR_DEFAULT, GAS_QUERY_FEE, GAS_WASM_QUERY_FEE, }; use cw_croncat_core::{ msg::{TaskRequest, TaskResponse, TaskWithQueriesResponse}, - types::Action, + types::{Action, GasPrice}, }; use cw_rules_core::{msg::QueryResponse, types::CroncatQuery}; @@ -89,7 +89,7 @@ pub(crate) fn init_contracts( gas_action_fee: None, gas_query_fee: None, gas_wasm_query_fee: None, - gas_fraction: None, + gas_price: None, agent_nomination_duration: None, gas_base_fee: None, }; @@ -196,8 +196,13 @@ where let gas_for_task = GAS_BASE_FEE + min_gas_for_actions(&task.actions) + min_gas_for_queries(task.queries.as_ref()); - let gas_to_attached_deposit = - add_agent_fee(gas_for_task) * GAS_NUMERATOR_DEFAULT / GAS_DENOMINATOR; + let gas_to_attached_deposit = GasPrice { + numerator: GAS_NUMERATOR_DEFAULT, + denominator: GAS_DENOMINATOR, + gas_adjustment_numerator: GAS_ADJUSTMENT_NUMERATOR_DEFAULT, + } + .calculate(add_agent_fee(gas_for_task)) + .unwrap() as u64; let amount = (gas_to_attached_deposit + extra_funds) * 3; create_task(task, orc, user_key, prefix, &denom, amount)?; } diff --git a/ci/gas-benchmark/src/main.rs b/ci/gas-benchmark/src/main.rs index 61f9f683..3045a6a2 100644 --- a/ci/gas-benchmark/src/main.rs +++ b/ci/gas-benchmark/src/main.rs @@ -203,7 +203,7 @@ fn main() -> Result<()> { gas_action_fee: None, gas_query_fee: None, gas_wasm_query_fee: None, - gas_fraction: None, + gas_price: None, proxy_callback_gas: None, min_tasks_per_agent: None, agents_eject_threshold: None, diff --git a/contracts/cw-croncat/src/agent.rs b/contracts/cw-croncat/src/agent.rs index 07a37970..4283a4a3 100644 --- a/contracts/cw-croncat/src/agent.rs +++ b/contracts/cw-croncat/src/agent.rs @@ -11,7 +11,7 @@ use std::ops::Div; use crate::ContractError::*; use cw_croncat_core::msg::{AgentResponse, AgentTaskResponse, GetAgentIdsResponse}; -use cw_croncat_core::types::{calculate_required_amount, Agent, AgentStatus}; +use cw_croncat_core::types::{gas_amount_with_agent_fee, Agent, AgentStatus}; impl<'a> CwCroncat<'a> { /// Get a single agent details @@ -140,10 +140,9 @@ impl<'a> CwCroncat<'a> { // REF: https://github.com/CosmWasm/cw-tokens/tree/main/contracts/cw20-escrow // Check if native token balance is sufficient for a few txns, in this case 4 txns - // TODO: Adjust gas & costs based on real usage cost let agent_wallet_balances = deps.querier.query_all_balances(account.clone())?; - let gas_cost = calculate_required_amount(c.gas_action_fee, c.agent_fee)?; - let unit_cost = c.gas_fraction.calculate(4 * gas_cost, 1)?; + let gas_amount_with_agent_fee = gas_amount_with_agent_fee(c.gas_action_fee, c.agent_fee)?; + let unit_cost = c.gas_price.calculate(4 * gas_amount_with_agent_fee)?; if !has_coins( &agent_wallet_balances, &Coin::new(unit_cost, c.native_denom), diff --git a/contracts/cw-croncat/src/contract.rs b/contracts/cw-croncat/src/contract.rs index 8e086875..9de92081 100644 --- a/contracts/cw-croncat/src/contract.rs +++ b/contracts/cw-croncat/src/contract.rs @@ -7,7 +7,7 @@ use cosmwasm_std::{ }; use cw2::set_contract_version; use cw_croncat_core::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; -use cw_croncat_core::types::{GasFraction, SlotType}; +use cw_croncat_core::types::{GasPrice, SlotType}; // version info for migration info const CONTRACT_NAME: &str = "crates.io:cw-croncat"; @@ -25,10 +25,13 @@ pub const GAS_QUERY_FEE: u64 = 5_000; pub const GAS_WASM_QUERY_FEE: u64 = 60_000; /// We can't store gas_price as floats inside cosmwasm /// so insted of having 0.04 we use GasFraction{4/100} -/// and multiply numerator by `gas_adjustment` (1.5) -pub const GAS_NUMERATOR_DEFAULT: u64 = 6; -pub const GAS_DENOMINATOR: u64 = 100; - +/// and after that multiply Gas by `gas_adjustment` {150/100} (1.5) +pub mod gas_price_defaults { + pub const GAS_NUMERATOR_DEFAULT: u64 = 4; + pub const GAS_ADJUSTMENT_NUMERATOR_DEFAULT: u64 = 150; + pub const GAS_DENOMINATOR: u64 = 100; +} +pub use gas_price_defaults::*; // #[cfg(not(feature = "library"))] impl<'a> CwCroncat<'a> { pub fn instantiate( @@ -60,9 +63,10 @@ impl<'a> CwCroncat<'a> { available_balance, staked_balance: GenericBalance::default(), agent_fee: 5, - gas_fraction: msg.gas_fraction.unwrap_or(GasFraction { + gas_price: msg.gas_price.unwrap_or(GasPrice { numerator: GAS_NUMERATOR_DEFAULT, denominator: GAS_DENOMINATOR, + gas_adjustment_numerator: GAS_ADJUSTMENT_NUMERATOR_DEFAULT, }), proxy_callback_gas: 3, gas_base_fee: msg.gas_base_fee.map(Into::into).unwrap_or(GAS_BASE_FEE), @@ -122,7 +126,6 @@ impl<'a> CwCroncat<'a> { ) .add_attribute("native_denom", config.native_denom) .add_attribute("agent_fee", config.agent_fee.to_string()) - //.add_attribute("gas_fraction", config.gas_fraction.to_string()) .add_attribute("proxy_callback_gas", config.proxy_callback_gas.to_string()) .add_attribute( "slot_granularity_time", diff --git a/contracts/cw-croncat/src/helpers.rs b/contracts/cw-croncat/src/helpers.rs index c81ed94e..3d963207 100644 --- a/contracts/cw-croncat/src/helpers.rs +++ b/contracts/cw-croncat/src/helpers.rs @@ -11,7 +11,7 @@ use cosmwasm_std::{ use cw20::{Cw20CoinVerified, Cw20ExecuteMsg}; use cw_croncat_core::msg::ExecuteMsg; use cw_croncat_core::traits::{BalancesOperations, FindAndMutate}; -use cw_croncat_core::types::{calculate_required_amount, AgentStatus}; +use cw_croncat_core::types::{gas_amount_with_agent_fee, AgentStatus}; pub use cw_croncat_core::types::{GenericBalance, Task}; //use regex::Regex; use schemars::JsonSchema; @@ -235,8 +235,8 @@ pub(crate) fn proxy_call_submsgs_price( cfg.gas_wasm_query_fee, next_idx, )?; - let gas_amount = calculate_required_amount(gas_total, cfg.agent_fee)?; - let price_amount = cfg.gas_fraction.calculate(gas_amount, 1)?; + let gas_amount_with_agent_fee = gas_amount_with_agent_fee(gas_total, cfg.agent_fee)?; + let price_amount = cfg.gas_price.calculate(gas_amount_with_agent_fee)?; let price = coin(price_amount, cfg.native_denom); Ok((sub_msgs, price)) } diff --git a/contracts/cw-croncat/src/owner.rs b/contracts/cw-croncat/src/owner.rs index 7a72f4e1..5c5d28a5 100644 --- a/contracts/cw-croncat/src/owner.rs +++ b/contracts/cw-croncat/src/owner.rs @@ -23,7 +23,7 @@ impl<'a> CwCroncat<'a> { agents_eject_threshold: c.agents_eject_threshold, native_denom: c.native_denom, agent_fee: c.agent_fee, - gas_fraction: c.gas_fraction, + gas_price: c.gas_price, proxy_callback_gas: c.proxy_callback_gas, slot_granularity_time: c.slot_granularity_time, cw_rules_addr: c.cw_rules_addr, @@ -84,7 +84,7 @@ impl<'a> CwCroncat<'a> { gas_action_fee, gas_query_fee, gas_wasm_query_fee, - gas_fraction, + gas_price, proxy_callback_gas, min_tasks_per_agent, agents_eject_threshold, @@ -112,7 +112,7 @@ impl<'a> CwCroncat<'a> { agent_nomination_duration: old_config.agent_nomination_duration, cw_rules_addr: old_config.cw_rules_addr, agent_fee: agent_fee.unwrap_or(old_config.agent_fee), - gas_fraction: gas_fraction.unwrap_or(old_config.gas_fraction), + gas_price: gas_price.unwrap_or(old_config.gas_price), gas_base_fee: gas_base_fee .map(Into::into) .unwrap_or(old_config.gas_base_fee), @@ -165,7 +165,6 @@ impl<'a> CwCroncat<'a> { ) .add_attribute("native_denom", c.native_denom) .add_attribute("agent_fee", c.agent_fee.to_string()) - //.add_attribute("gas_price", c.gas_fraction.to_string()) .add_attribute("proxy_callback_gas", c.proxy_callback_gas.to_string()) .add_attribute("slot_granularity_time", c.slot_granularity_time.to_string())) } diff --git a/contracts/cw-croncat/src/state.rs b/contracts/cw-croncat/src/state.rs index 124ede04..c087f08d 100644 --- a/contracts/cw-croncat/src/state.rs +++ b/contracts/cw-croncat/src/state.rs @@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize}; use crate::helpers::Task; use cw_croncat_core::{ query::CroncatQuerier, - types::{Agent, GasFraction, GenericBalance, SlotType}, + types::{Agent, GasPrice, GenericBalance, SlotType}, }; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] @@ -38,7 +38,7 @@ pub struct Config { // Economics pub agent_fee: u64, - pub gas_fraction: GasFraction, + pub gas_price: GasPrice, pub gas_base_fee: u64, pub gas_action_fee: u64, pub gas_query_fee: u64, diff --git a/contracts/cw-croncat/src/tasks.rs b/contracts/cw-croncat/src/tasks.rs index 5e3acadd..2b6dc969 100644 --- a/contracts/cw-croncat/src/tasks.rs +++ b/contracts/cw-croncat/src/tasks.rs @@ -13,7 +13,7 @@ use cw_croncat_core::msg::{ }; use cw_croncat_core::traits::{BalancesOperations, FindAndMutate, Intervals}; use cw_croncat_core::types::{ - calculate_required_amount, BoundaryValidated, GenericBalance, SlotType, Task, + gas_amount_with_agent_fee, BoundaryValidated, GenericBalance, SlotType, Task, }; impl<'a> CwCroncat<'a> { @@ -265,8 +265,8 @@ impl<'a> CwCroncat<'a> { cfg.gas_query_fee, cfg.gas_wasm_query_fee, )?; - let gas_price = calculate_required_amount(gas_amount, cfg.agent_fee)?; - let price = cfg.gas_fraction.calculate(gas_price, 1)?; + let gas_amount_with_agent_fee = gas_amount_with_agent_fee(gas_amount, cfg.agent_fee)?; + let price = cfg.gas_price.calculate(gas_amount_with_agent_fee)?; amount_for_one_task .native .find_checked_add(&coin(price, &cfg.native_denom))?; diff --git a/contracts/cw-croncat/src/tests/agent.rs b/contracts/cw-croncat/src/tests/agent.rs index 1b26edb0..bd20a7b4 100644 --- a/contracts/cw-croncat/src/tests/agent.rs +++ b/contracts/cw-croncat/src/tests/agent.rs @@ -11,7 +11,7 @@ use cw_croncat_core::msg::{ AgentResponse, AgentTaskResponse, ExecuteMsg, GetAgentIdsResponse, InstantiateMsg, QueryMsg, TaskRequest, TaskResponse, }; -use cw_croncat_core::types::{Action, Agent, AgentStatus, GasFraction, GenericBalance, Interval}; +use cw_croncat_core::types::{Action, Agent, AgentStatus, GasPrice, GenericBalance, Interval}; use cw_multi_test::{App, AppResponse, BankSudo, Executor, SudoMsg}; use super::helpers::{ @@ -258,7 +258,7 @@ fn test_instantiate_sets_balance() { gas_action_fee: None, gas_query_fee: None, gas_wasm_query_fee: None, - gas_fraction: None, + gas_price: None, agent_nomination_duration: None, gas_base_fee: None, }, @@ -311,7 +311,7 @@ fn register_agent_fail_cases() { agent_fee: None, min_tasks_per_agent: None, agents_eject_threshold: None, - gas_fraction: None, + gas_price: None, proxy_callback_gas: None, gas_base_fee: None, gas_action_fee: None, @@ -345,9 +345,10 @@ fn register_agent_fail_cases() { agent_fee: None, min_tasks_per_agent: None, agents_eject_threshold: None, - gas_fraction: Some(GasFraction { + gas_price: Some(GasPrice { numerator: 1, denominator: 1, + gas_adjustment_numerator: 1, }), proxy_callback_gas: None, slot_granularity_time: None, @@ -759,7 +760,7 @@ fn test_get_agent_status() { gas_action_fee: None, gas_query_fee: None, gas_wasm_query_fee: None, - gas_fraction: None, + gas_price: None, agent_nomination_duration: Some(360), cw_rules_addr: "todo".to_string(), gas_base_fee: None, diff --git a/contracts/cw-croncat/src/tests/balance.rs b/contracts/cw-croncat/src/tests/balance.rs index 751bf9e9..83816c3f 100644 --- a/contracts/cw-croncat/src/tests/balance.rs +++ b/contracts/cw-croncat/src/tests/balance.rs @@ -1,13 +1,13 @@ use crate::balancer::{Balancer, BalancerMode, RoundRobinBalancer}; use crate::contract::{ - GAS_ACTION_FEE, GAS_BASE_FEE, GAS_DENOMINATOR, GAS_NUMERATOR_DEFAULT, GAS_QUERY_FEE, - GAS_WASM_QUERY_FEE, + GAS_ACTION_FEE, GAS_ADJUSTMENT_NUMERATOR_DEFAULT, GAS_BASE_FEE, GAS_DENOMINATOR, + GAS_NUMERATOR_DEFAULT, GAS_QUERY_FEE, GAS_WASM_QUERY_FEE, }; use crate::state::{Config, TaskInfo}; use crate::tests::helpers::{default_task, AGENT0, AGENT1, AGENT2, AGENT3, AGENT4}; use cosmwasm_std::testing::{mock_dependencies_with_balance, mock_env}; use cosmwasm_std::{coins, Addr}; -use cw_croncat_core::types::{GasFraction, GenericBalance, SlotType}; +use cw_croncat_core::types::{GasPrice, GenericBalance, SlotType}; use crate::CwCroncat; @@ -24,9 +24,10 @@ fn mock_config() -> Config { available_balance: GenericBalance::default(), staked_balance: GenericBalance::default(), agent_fee: 5, - gas_fraction: GasFraction { + gas_price: GasPrice { numerator: GAS_NUMERATOR_DEFAULT, denominator: GAS_DENOMINATOR, + gas_adjustment_numerator: GAS_ADJUSTMENT_NUMERATOR_DEFAULT, }, gas_action_fee: GAS_ACTION_FEE, gas_query_fee: GAS_QUERY_FEE, diff --git a/contracts/cw-croncat/src/tests/contract.rs b/contracts/cw-croncat/src/tests/contract.rs index 6784dd27..6ff7be21 100644 --- a/contracts/cw-croncat/src/tests/contract.rs +++ b/contracts/cw-croncat/src/tests/contract.rs @@ -1,3 +1,4 @@ +use crate::contract::GAS_ADJUSTMENT_NUMERATOR_DEFAULT; use crate::contract::GAS_DENOMINATOR; use crate::contract::GAS_NUMERATOR_DEFAULT; use crate::state::QueueItem; @@ -12,7 +13,7 @@ use cosmwasm_std::testing::{ }; use cosmwasm_std::{coins, from_binary, Addr, Binary, Event, Reply, SubMsgResponse, SubMsgResult}; use cw_croncat_core::msg::{GetConfigResponse, QueryMsg}; -use cw_croncat_core::types::GasFraction; +use cw_croncat_core::types::GasPrice; use cw_croncat_core::types::SlotType; #[test] @@ -26,7 +27,7 @@ fn configure() { gas_action_fee: None, gas_query_fee: None, gas_wasm_query_fee: None, - gas_fraction: None, + gas_price: None, agent_nomination_duration: Some(360), cw_rules_addr: "todo".to_string(), gas_base_fee: None, @@ -56,11 +57,12 @@ fn configure() { assert_eq!("atom", value.native_denom); assert_eq!(5, value.agent_fee); assert_eq!( - GasFraction { + GasPrice { numerator: GAS_NUMERATOR_DEFAULT, - denominator: GAS_DENOMINATOR + denominator: GAS_DENOMINATOR, + gas_adjustment_numerator: GAS_ADJUSTMENT_NUMERATOR_DEFAULT, }, - value.gas_fraction + value.gas_price ); assert_eq!(3, value.proxy_callback_gas); assert_eq!(10_000_000_000, value.slot_granularity_time); diff --git a/contracts/cw-croncat/src/tests/helpers.rs b/contracts/cw-croncat/src/tests/helpers.rs index fd6db476..17f5f126 100644 --- a/contracts/cw-croncat/src/tests/helpers.rs +++ b/contracts/cw-croncat/src/tests/helpers.rs @@ -40,7 +40,7 @@ pub fn mock_init(store: &CwCroncat, deps: DepsMut) -> Result (App, CwTemplateContract, Addr) { gas_action_fee: None, gas_query_fee: None, gas_wasm_query_fee: None, - gas_fraction: None, + gas_price: None, agent_nomination_duration: None, }; let cw_template_contract_addr = app diff --git a/contracts/cw-croncat/src/tests/manager.rs b/contracts/cw-croncat/src/tests/manager.rs index d37f34b4..e454320a 100644 --- a/contracts/cw-croncat/src/tests/manager.rs +++ b/contracts/cw-croncat/src/tests/manager.rs @@ -1,6 +1,6 @@ use crate::contract::{ - GAS_ACTION_FEE, GAS_BASE_FEE, GAS_DENOMINATOR, GAS_NUMERATOR_DEFAULT, GAS_QUERY_FEE, - GAS_WASM_QUERY_FEE, + GAS_ACTION_FEE, GAS_ADJUSTMENT_NUMERATOR_DEFAULT, GAS_BASE_FEE, GAS_DENOMINATOR, + GAS_NUMERATOR_DEFAULT, GAS_QUERY_FEE, GAS_WASM_QUERY_FEE, }; use crate::tests::helpers::{ add_1000_blocks, add_little_time, add_one_duration_of_time, cw4_template, proper_instantiate, @@ -13,10 +13,10 @@ use cosmwasm_std::{ use cw20::Cw20Coin; use cw_croncat_core::error::CoreError; use cw_croncat_core::msg::{ - AgentResponse, AgentTaskResponse, ExecuteMsg, GetAgentIdsResponse, QueryMsg, TaskRequest, - TaskResponse, TaskWithQueriesResponse, + AgentResponse, AgentTaskResponse, ExecuteMsg, GetAgentIdsResponse, GetConfigResponse, QueryMsg, + TaskRequest, TaskResponse, TaskWithQueriesResponse, }; -use cw_croncat_core::types::{Action, Boundary, Interval, Transform}; +use cw_croncat_core::types::{Action, Boundary, GasPrice, Interval, Transform}; use cw_multi_test::Executor; use cw_rules_core::types::{CroncatQuery, HasBalanceGte}; use cwd_core::state::ProposalModule; @@ -102,7 +102,7 @@ fn proxy_call_fail_cases() -> StdResult<()> { agent_fee: None, min_tasks_per_agent: None, agents_eject_threshold: None, - gas_fraction: None, + gas_price: None, proxy_callback_gas: None, slot_granularity_time: None, gas_base_fee: None, @@ -170,7 +170,7 @@ fn proxy_call_fail_cases() -> StdResult<()> { agent_fee: None, min_tasks_per_agent: None, agents_eject_threshold: None, - gas_fraction: None, + gas_price: None, proxy_callback_gas: None, slot_granularity_time: None, gas_base_fee: None, @@ -439,7 +439,9 @@ fn proxy_call_no_task_and_withdraw() -> StdResult<()> { }, }; let gas_for_one = GAS_BASE_FEE + gas_limit; - let amount_for_one_task = gas_for_one * GAS_NUMERATOR_DEFAULT / GAS_DENOMINATOR; + let amount_for_one_task = gas_for_one * GAS_ADJUSTMENT_NUMERATOR_DEFAULT / GAS_DENOMINATOR + * GAS_NUMERATOR_DEFAULT + / GAS_DENOMINATOR; let agent_fee = amount_for_one_task * 5 / 100; let amount_with_fee = gas_limit + agent_fee + 1000; // create a task @@ -1375,8 +1377,13 @@ fn test_balance_changes() { let gas_for_one = GAS_BASE_FEE + (GAS_ACTION_FEE * 2); let agent_fee = gas_for_one * 5 / 100; let extra = 50; // extra for checking refunds at task removal - let amount_for_one_task = - (gas_for_one + agent_fee) * GAS_NUMERATOR_DEFAULT / GAS_DENOMINATOR + 3 + 4 + extra; // + 3 + 4 atoms sent + let amount_for_one_task = (gas_for_one + agent_fee) * GAS_ADJUSTMENT_NUMERATOR_DEFAULT + / GAS_DENOMINATOR + * GAS_NUMERATOR_DEFAULT + / GAS_DENOMINATOR + + 3 + + 4 + + extra; // + 3 + 4 atoms sent // create a task app.execute_contract( @@ -1509,8 +1516,11 @@ fn test_no_reschedule_if_lack_balance() { let gas_for_one = GAS_BASE_FEE + GAS_ACTION_FEE; let agent_fee = gas_for_one * 5 / 100; let extra = 50; // extra for checking nonzero task balance - let amount_for_one_task = - (gas_for_one + agent_fee) * GAS_NUMERATOR_DEFAULT / GAS_DENOMINATOR + 3; // + 3 atoms sent + let amount_for_one_task = (gas_for_one + agent_fee) * GAS_ADJUSTMENT_NUMERATOR_DEFAULT + / GAS_DENOMINATOR + * GAS_NUMERATOR_DEFAULT + / GAS_DENOMINATOR + + 3; // + 3 atoms sent // create a task app.execute_contract( @@ -1558,7 +1568,12 @@ fn test_no_reschedule_if_lack_balance() { .unwrap(); assert_eq!( task.unwrap().total_deposit[0].amount, - Uint128::from((gas_for_one + agent_fee) * GAS_NUMERATOR_DEFAULT / GAS_DENOMINATOR + extra) + Uint128::from( + (gas_for_one + agent_fee) * GAS_ADJUSTMENT_NUMERATOR_DEFAULT / GAS_DENOMINATOR + * GAS_NUMERATOR_DEFAULT + / GAS_DENOMINATOR + + extra + ) ); app.update_block(add_little_time); @@ -1879,7 +1894,7 @@ fn tick() { proxy_callback_gas: None, slot_granularity_time: None, gas_base_fee: None, - gas_fraction: None, + gas_price: None, }; app.execute_contract( Addr::unchecked(ADMIN), @@ -2073,7 +2088,7 @@ fn tick_task() -> StdResult<()> { gas_action_fee: None, gas_query_fee: None, gas_wasm_query_fee: None, - gas_fraction: None, + gas_price: None, }; app.execute_contract( Addr::unchecked(ADMIN), @@ -3093,7 +3108,10 @@ fn queries_fees() { // Base + action + calling rules + non-wasm query let gas_needed = GAS_BASE_FEE + GAS_ACTION_FEE + GAS_WASM_QUERY_FEE + GAS_QUERY_FEE; let agent_fee = gas_needed * 5 / 100; - let gas_to_amount = (gas_needed + agent_fee) * GAS_NUMERATOR_DEFAULT / GAS_DENOMINATOR; + let gas_to_amount = (gas_needed + agent_fee) * GAS_ADJUSTMENT_NUMERATOR_DEFAULT + / GAS_DENOMINATOR + * GAS_NUMERATOR_DEFAULT + / GAS_DENOMINATOR; let attached_balance = (gas_to_amount + 1) as u128; let task_hash_binary = app @@ -3174,7 +3192,10 @@ fn queries_fees() { // Base + action + calling rules + wasm query let gas_needed = GAS_BASE_FEE + GAS_ACTION_FEE + GAS_WASM_QUERY_FEE + GAS_WASM_QUERY_FEE; let agent_fee = gas_needed * 5 / 100; - let gas_to_amount = (gas_needed + agent_fee) * GAS_NUMERATOR_DEFAULT / GAS_DENOMINATOR; + let gas_to_amount = (gas_needed + agent_fee) * GAS_ADJUSTMENT_NUMERATOR_DEFAULT + / GAS_DENOMINATOR + * GAS_NUMERATOR_DEFAULT + / GAS_DENOMINATOR; let attached_balance = (gas_to_amount + 1) as u128; let task_hash_binary = app @@ -3242,7 +3263,10 @@ fn queries_fees() { let gas_needed = GAS_BASE_FEE + GAS_ACTION_FEE + GAS_WASM_QUERY_FEE + GAS_WASM_QUERY_FEE; let agent_fee = gas_needed * 5 / 100; - let gas_to_amount = (gas_needed + agent_fee) * GAS_NUMERATOR_DEFAULT / GAS_DENOMINATOR; + let gas_to_amount = (gas_needed + agent_fee) * GAS_ADJUSTMENT_NUMERATOR_DEFAULT + / GAS_DENOMINATOR + * GAS_NUMERATOR_DEFAULT + / GAS_DENOMINATOR; let one_proxy_call_amount = (gas_to_amount + 1) as u128; let task_hash_binary = app @@ -3393,7 +3417,10 @@ fn queries_fees_negative() { // Base + action + calling rules + non-wasm query let gas_needed = GAS_BASE_FEE + GAS_ACTION_FEE + GAS_WASM_QUERY_FEE + GAS_QUERY_FEE; let agent_fee = gas_needed * 5 / 100; - let gas_to_amount = (gas_needed + agent_fee) * GAS_NUMERATOR_DEFAULT / GAS_DENOMINATOR; + let gas_to_amount = (gas_needed + agent_fee) * GAS_ADJUSTMENT_NUMERATOR_DEFAULT + / GAS_DENOMINATOR + * GAS_NUMERATOR_DEFAULT + / GAS_DENOMINATOR; let attached_balance = (gas_to_amount + 1 - 1) as u128; // missing 1 amount let err: ContractError = app @@ -3447,7 +3474,10 @@ fn queries_fees_negative() { // Base + action + calling rules + wasm query let gas_needed = GAS_BASE_FEE + GAS_ACTION_FEE + GAS_WASM_QUERY_FEE + GAS_WASM_QUERY_FEE; let agent_fee = gas_needed * 5 / 100; - let gas_to_amount = (gas_needed + agent_fee) * GAS_NUMERATOR_DEFAULT / GAS_DENOMINATOR; + let gas_to_amount = (gas_needed + agent_fee) * GAS_ADJUSTMENT_NUMERATOR_DEFAULT + / GAS_DENOMINATOR + * GAS_NUMERATOR_DEFAULT + / GAS_DENOMINATOR; let attached_balance = (gas_to_amount + 1 - 1) as u128; let err: ContractError = app @@ -3469,3 +3499,130 @@ fn queries_fees_negative() { }) ); } + +#[test] +fn gas_fees_configurable() { + let (mut app, cw_template_contract, _) = proper_instantiate(); + let contract_addr = cw_template_contract.addr(); + + // quick agent register + let msg = ExecuteMsg::RegisterAgent { + payable_account_id: Some(AGENT_BENEFICIARY.to_string()), + }; + app.execute_contract(Addr::unchecked(AGENT0), contract_addr.clone(), &msg, &[]) + .unwrap(); + + let mut initial_config: GetConfigResponse = app + .wrap() + .query_wasm_smart(contract_addr.clone(), &QueryMsg::GetConfig {}) + .unwrap(); + let modified_gas_price = GasPrice { + numerator: 10, + denominator: 1000, + gas_adjustment_numerator: 120, + }; + let update_gas_price_msg = ExecuteMsg::UpdateSettings { + owner_id: None, + slot_granularity_time: None, + paused: None, + agent_fee: None, + gas_base_fee: None, + gas_action_fee: None, + gas_query_fee: None, + gas_wasm_query_fee: None, + gas_price: Some(modified_gas_price.clone()), + proxy_callback_gas: None, + min_tasks_per_agent: None, + agents_eject_threshold: None, + }; + app.execute_contract( + Addr::unchecked(ADMIN), + contract_addr.clone(), + &update_gas_price_msg, + &[], + ) + .unwrap(); + let new_config: GetConfigResponse = app + .wrap() + .query_wasm_smart(contract_addr.clone(), &QueryMsg::GetConfig {}) + .unwrap(); + assert_ne!(initial_config, new_config); + initial_config.gas_price = modified_gas_price.clone(); + assert_eq!(initial_config, new_config); + + app.update_block(add_little_time); + let transfer_to_bob = BankMsg::Send { + to_address: "bob".to_string(), + amount: coins(1, NATIVE_DENOM), + }; + let create_task_msg = ExecuteMsg::CreateTask { + task: TaskRequest { + interval: Interval::Once, + boundary: None, + stop_on_fail: false, + actions: vec![Action { + msg: transfer_to_bob.clone().into(), + gas_limit: None, + }], + queries: None, + transforms: None, + cw20_coins: vec![], + }, + }; + + // Base + action + let gas_needed = GAS_BASE_FEE + GAS_ACTION_FEE; + let agent_fee = gas_needed * 5 / 100; + let gas_to_amount = (gas_needed + agent_fee) * modified_gas_price.gas_adjustment_numerator + / modified_gas_price.denominator + * modified_gas_price.numerator + / modified_gas_price.denominator; + let attached_balance = (gas_to_amount + 1) as u128; + + // making sure new config values is applied + // one off coin + let err: ContractError = app + .execute_contract( + Addr::unchecked(ADMIN), + contract_addr.clone(), + &create_task_msg, + &coins(attached_balance - 1, NATIVE_DENOM), + ) + .unwrap_err() + .downcast() + .unwrap(); + assert_eq!( + err, + ContractError::CoreError(CoreError::NotEnoughNative { + denom: NATIVE_DENOM.to_owned(), + lack: Uint128::new(1) + }) + ); + + // should work + app.execute_contract( + Addr::unchecked(ADMIN), + contract_addr.clone(), + &create_task_msg, + &coins(attached_balance, NATIVE_DENOM), + ) + .unwrap(); + app.update_block(add_little_time); + + // execute proxy_call + let proxy_call_msg = ExecuteMsg::ProxyCall { task_hash: None }; + let res = app + .execute_contract( + Addr::unchecked(AGENT0), + contract_addr.clone(), + &proxy_call_msg, + &vec![], + ) + .unwrap(); + print!("{:#?}", res); + + assert!(res.events.iter().any(|ev| ev + .attributes + .iter() + .any(|attr| attr.key == "method" && attr.value == "remove_task"))); +} diff --git a/contracts/cw-croncat/src/tests/owner.rs b/contracts/cw-croncat/src/tests/owner.rs index cb9f9fdc..80e5721f 100644 --- a/contracts/cw-croncat/src/tests/owner.rs +++ b/contracts/cw-croncat/src/tests/owner.rs @@ -21,7 +21,7 @@ fn update_settings() { gas_action_fee: None, gas_query_fee: None, gas_wasm_query_fee: None, - gas_fraction: None, + gas_price: None, agent_nomination_duration: Some(360), }; let info = MessageInfo { @@ -41,7 +41,7 @@ fn update_settings() { agent_fee: None, min_tasks_per_agent: None, agents_eject_threshold: None, - gas_fraction: None, + gas_price: None, proxy_callback_gas: None, slot_granularity_time: None, gas_base_fee: None, @@ -105,7 +105,7 @@ fn move_balances_auth_checks() { gas_action_fee: None, gas_query_fee: None, gas_wasm_query_fee: None, - gas_fraction: None, + gas_price: None, agent_nomination_duration: Some(360), cw_rules_addr: "todo".to_string(), gas_base_fee: None, @@ -122,7 +122,7 @@ fn move_balances_auth_checks() { agent_fee: None, min_tasks_per_agent: None, agents_eject_threshold: None, - gas_fraction: None, + gas_price: None, proxy_callback_gas: None, slot_granularity_time: None, gas_base_fee: None, @@ -178,7 +178,7 @@ fn move_balances_native() { gas_action_fee: None, gas_query_fee: None, gas_wasm_query_fee: None, - gas_fraction: None, + gas_price: None, agent_nomination_duration: Some(360), cw_rules_addr: "todo".to_string(), gas_base_fee: None, @@ -195,7 +195,7 @@ fn move_balances_native() { agent_fee: None, min_tasks_per_agent: None, agents_eject_threshold: None, - gas_fraction: None, + gas_price: None, proxy_callback_gas: None, slot_granularity_time: None, gas_base_fee: None, diff --git a/contracts/cw-croncat/src/tests/tasks.rs b/contracts/cw-croncat/src/tests/tasks.rs index 0ac06927..a610d6ea 100644 --- a/contracts/cw-croncat/src/tests/tasks.rs +++ b/contracts/cw-croncat/src/tests/tasks.rs @@ -1,5 +1,8 @@ use super::helpers::{ADMIN, ANYONE, NATIVE_DENOM, VERY_RICH}; -use crate::contract::{GAS_ACTION_FEE, GAS_BASE_FEE, GAS_DENOMINATOR, GAS_NUMERATOR_DEFAULT}; +use crate::contract::{ + GAS_ACTION_FEE, GAS_ADJUSTMENT_NUMERATOR_DEFAULT, GAS_BASE_FEE, GAS_DENOMINATOR, + GAS_NUMERATOR_DEFAULT, +}; use crate::tests::helpers::proper_instantiate; use crate::ContractError; use cosmwasm_std::{ @@ -356,7 +359,7 @@ fn check_task_create_fail_cases() -> StdResult<()> { // treasury_id: None, agent_fee: None, agents_eject_threshold: None, - gas_fraction: None, + gas_price: None, proxy_callback_gas: None, slot_granularity_time: None, min_tasks_per_agent: None, @@ -396,7 +399,7 @@ fn check_task_create_fail_cases() -> StdResult<()> { // treasury_id: None, agent_fee: None, agents_eject_threshold: None, - gas_fraction: None, + gas_price: None, proxy_callback_gas: None, slot_granularity_time: None, min_tasks_per_agent: None, @@ -1057,7 +1060,10 @@ fn check_gas_minimum() { // create 1 token off task let gas_for_two = (base_gas + gas_limit) * 2; let enough_for_two = u128::from( - (gas_for_two + gas_for_two * 5 / 100) * GAS_NUMERATOR_DEFAULT / GAS_DENOMINATOR + 3 * 2, + (gas_for_two + gas_for_two * 5 / 100) * GAS_ADJUSTMENT_NUMERATOR_DEFAULT / GAS_DENOMINATOR + * GAS_NUMERATOR_DEFAULT + / GAS_DENOMINATOR + + 3 * 2, ); let res: ContractError = app .execute_contract( @@ -1122,8 +1128,12 @@ fn check_gas_default() { let gas_for_one = base_gas + gas_limit; let gas_for_one_with_fee = gas_for_one + gas_for_one * 5 / 100; - let enough_for_two = - 2 * u128::from(gas_for_one_with_fee * GAS_NUMERATOR_DEFAULT / GAS_DENOMINATOR + 3); + let enough_for_two = 2 * u128::from( + gas_for_one_with_fee * GAS_ADJUSTMENT_NUMERATOR_DEFAULT / GAS_DENOMINATOR + * GAS_NUMERATOR_DEFAULT + / GAS_DENOMINATOR + + 3, + ); let res: ContractError = app .execute_contract( diff --git a/justfile b/justfile index 89074adf..3339d511 100644 --- a/justfile +++ b/justfile @@ -25,8 +25,8 @@ gen: #!/usr/bin/env bash cd typescript yarn --cwd ./typescript build - yarn --cwd ./typescript install --frozen-lockfile yarn --cwd ./typescript codegen + yarn --cwd ./typescript install --frozen-lockfile juno-local: docker kill cosmwasm || true docker volume rm -f junod_data diff --git a/packages/cw-croncat-core/schema/croncat.json b/packages/cw-croncat-core/schema/croncat.json index 94a331c6..da1ff1e4 100644 --- a/packages/cw-croncat-core/schema/croncat.json +++ b/packages/cw-croncat-core/schema/croncat.json @@ -826,10 +826,11 @@ "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", "type": "object" }, - "GasFraction": { + "GasPrice": { "type": "object", "required": [ "denominator", + "gas_adjustment_numerator", "numerator" ], "properties": { @@ -838,6 +839,12 @@ "format": "uint64", "minimum": 0.0 }, + "gas_adjustment_numerator": { + "description": "Note", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, "numerator": { "type": "integer", "format": "uint64", @@ -952,7 +959,7 @@ "cw_rules_addr", "gas_action_fee", "gas_base_fee", - "gas_fraction", + "gas_price", "limit", "min_tasks_per_agent", "native_denom", @@ -1023,8 +1030,8 @@ "format": "uint64", "minimum": 0.0 }, - "gas_fraction": { - "$ref": "#/definitions/GasFraction" + "gas_price": { + "$ref": "#/definitions/GasPrice" }, "limit": { "type": "integer", diff --git a/packages/cw-croncat-core/schema/execute_msg.json b/packages/cw-croncat-core/schema/execute_msg.json index b701e547..a582f8c3 100644 --- a/packages/cw-croncat-core/schema/execute_msg.json +++ b/packages/cw-croncat-core/schema/execute_msg.json @@ -47,10 +47,10 @@ } ] }, - "gas_fraction": { + "gas_price": { "anyOf": [ { - "$ref": "#/definitions/GasFraction" + "$ref": "#/definitions/GasPrice" }, { "type": "null" @@ -935,10 +935,11 @@ "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", "type": "object" }, - "GasFraction": { + "GasPrice": { "type": "object", "required": [ "denominator", + "gas_adjustment_numerator", "numerator" ], "properties": { @@ -947,6 +948,12 @@ "format": "uint64", "minimum": 0.0 }, + "gas_adjustment_numerator": { + "description": "Note", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, "numerator": { "type": "integer", "format": "uint64", diff --git a/packages/cw-croncat-core/schema/instantiate_msg.json b/packages/cw-croncat-core/schema/instantiate_msg.json index ac8a7dd7..ed26bab2 100644 --- a/packages/cw-croncat-core/schema/instantiate_msg.json +++ b/packages/cw-croncat-core/schema/instantiate_msg.json @@ -41,10 +41,10 @@ } ] }, - "gas_fraction": { + "gas_price": { "anyOf": [ { - "$ref": "#/definitions/GasFraction" + "$ref": "#/definitions/GasPrice" }, { "type": "null" @@ -79,10 +79,11 @@ } }, "definitions": { - "GasFraction": { + "GasPrice": { "type": "object", "required": [ "denominator", + "gas_adjustment_numerator", "numerator" ], "properties": { @@ -91,6 +92,12 @@ "format": "uint64", "minimum": 0.0 }, + "gas_adjustment_numerator": { + "description": "Note", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, "numerator": { "type": "integer", "format": "uint64", diff --git a/packages/cw-croncat-core/src/msg.rs b/packages/cw-croncat-core/src/msg.rs index 97d912e0..493154bc 100644 --- a/packages/cw-croncat-core/src/msg.rs +++ b/packages/cw-croncat-core/src/msg.rs @@ -1,7 +1,7 @@ use crate::error::CoreError; use crate::traits::Intervals; use crate::types::{ - Action, AgentStatus, Boundary, BoundaryValidated, GasFraction, GenericBalance, Interval, Task, + Action, AgentStatus, Boundary, BoundaryValidated, GasPrice, GenericBalance, Interval, Task, Transform, }; use crate::types::{Agent, SlotType}; @@ -66,7 +66,7 @@ pub struct InstantiateMsg { pub gas_action_fee: Option, pub gas_query_fee: Option, pub gas_wasm_query_fee: Option, - pub gas_fraction: Option, + pub gas_price: Option, pub agent_nomination_duration: Option, } @@ -82,7 +82,7 @@ pub enum ExecuteMsg { gas_action_fee: Option, gas_query_fee: Option, gas_wasm_query_fee: Option, - gas_fraction: Option, + gas_price: Option, proxy_callback_gas: Option, min_tasks_per_agent: Option, agents_eject_threshold: Option, @@ -482,7 +482,7 @@ pub struct GetConfigResponse { pub cw_rules_addr: Addr, pub agent_fee: u64, - pub gas_fraction: GasFraction, + pub gas_price: GasPrice, pub gas_base_fee: u64, pub gas_action_fee: u64, pub proxy_callback_gas: u32, diff --git a/packages/cw-croncat-core/src/tests/msg.rs b/packages/cw-croncat-core/src/tests/msg.rs index 21cdacd1..441f3e69 100644 --- a/packages/cw-croncat-core/src/tests/msg.rs +++ b/packages/cw-croncat-core/src/tests/msg.rs @@ -9,7 +9,7 @@ use crate::{ TaskRequest, TaskRequestBuilder, TaskResponse, }, types::{ - Action, Agent, AgentStatus, Boundary, BoundaryValidated, GasFraction, GenericBalance, + Action, Agent, AgentStatus, Boundary, BoundaryValidated, GasPrice, GenericBalance, Interval, SlotType, Task, }, }; @@ -65,9 +65,10 @@ fn everything_can_be_de_serialized() { agent_active_indices: vec![(SlotType::Block, 10, 5)], agents_eject_threshold: 5, agent_fee: 5, - gas_fraction: GasFraction { + gas_price: GasPrice { numerator: 1, denominator: 2, + gas_adjustment_numerator: 3, }, proxy_callback_gas: 3, slot_granularity_time: 60_000_000, diff --git a/packages/cw-croncat-core/src/types.rs b/packages/cw-croncat-core/src/types.rs index e521064d..22cb8801 100644 --- a/packages/cw-croncat-core/src/types.rs +++ b/packages/cw-croncat-core/src/types.rs @@ -635,12 +635,12 @@ impl Task { } } -/// Calculate the amount including agent_fee -pub fn calculate_required_amount(amount: u64, agent_fee: u64) -> Result { - amount +/// Calculate the gas amount including agent_fee +pub fn gas_amount_with_agent_fee(gas_amount: u64, agent_fee: u64) -> Result { + gas_amount .checked_mul(agent_fee) .and_then(|n| n.checked_div(100)) - .and_then(|n| n.checked_add(amount)) + .and_then(|n| n.checked_add(gas_amount)) .ok_or(CoreError::InvalidGas {}) } @@ -918,26 +918,30 @@ impl Intervals for Interval { } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -pub struct GasFraction { +pub struct GasPrice { pub numerator: u64, pub denominator: u64, + /// Note + pub gas_adjustment_numerator: u64, } -impl GasFraction { +impl GasPrice { pub fn is_valid(&self) -> bool { - self.denominator != 0 && self.numerator != 0 + self.denominator != 0 && self.numerator != 0 && self.gas_adjustment_numerator != 0 } - pub fn calculate(&self, extra_num: u64, extra_denom: u64) -> Result { - let numerator = self - .numerator - .checked_mul(extra_num) + pub fn calculate(&self, gas_amount: u64) -> Result { + let gas_adjusted = gas_amount + .checked_mul(self.gas_adjustment_numerator) + .and_then(|g| g.checked_div(self.denominator)) .ok_or(CoreError::InvalidGas {})?; - let denominator = self - .denominator - .checked_mul(extra_denom) + + let price = gas_adjusted + .checked_mul(self.numerator) + .and_then(|g| g.checked_div(self.denominator)) .ok_or(CoreError::InvalidGas {})?; - Ok((numerator / denominator) as u128) + + Ok(price as u128) } } diff --git a/typescript/build/contracts/cw-croncat-core/CwCroncatCore.client.js b/typescript/build/contracts/cw-croncat-core/CwCroncatCore.client.js index 59d0ebd6..461fb230 100644 --- a/typescript/build/contracts/cw-croncat-core/CwCroncatCore.client.js +++ b/typescript/build/contracts/cw-croncat-core/CwCroncatCore.client.js @@ -131,14 +131,14 @@ exports.CwCroncatCoreQueryClient = CwCroncatCoreQueryClient; class CwCroncatCoreClient extends CwCroncatCoreQueryClient { constructor(client, sender, contractAddress) { super(client, contractAddress); - this.updateSettings = ({ agentFee, agentsEjectThreshold, gasActionFee, gasBaseFee, gasFraction, gasQueryFee, gasWasmQueryFee, minTasksPerAgent, ownerId, paused, proxyCallbackGas, slotGranularityTime }, fee = "auto", memo, funds) => __awaiter(this, void 0, void 0, function* () { + this.updateSettings = ({ agentFee, agentsEjectThreshold, gasActionFee, gasBaseFee, gasPrice, gasQueryFee, gasWasmQueryFee, minTasksPerAgent, ownerId, paused, proxyCallbackGas, slotGranularityTime }, fee = "auto", memo, funds) => __awaiter(this, void 0, void 0, function* () { return yield this.client.execute(this.sender, this.contractAddress, { update_settings: { agent_fee: agentFee, agents_eject_threshold: agentsEjectThreshold, gas_action_fee: gasActionFee, gas_base_fee: gasBaseFee, - gas_fraction: gasFraction, + gas_price: gasPrice, gas_query_fee: gasQueryFee, gas_wasm_query_fee: gasWasmQueryFee, min_tasks_per_agent: minTasksPerAgent, diff --git a/typescript/contracts/cw-croncat-core/CwCroncatCore.client.ts b/typescript/contracts/cw-croncat-core/CwCroncatCore.client.ts index 2969ef8f..63571744 100644 --- a/typescript/contracts/cw-croncat-core/CwCroncatCore.client.ts +++ b/typescript/contracts/cw-croncat-core/CwCroncatCore.client.ts @@ -6,7 +6,7 @@ import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate"; import { StdFee } from "@cosmjs/amino"; -import { Addr, Uint128, Timestamp, Uint64, SlotType, AgentStatus, CosmosMsgForEmpty, BankMsg, StakingMsg, DistributionMsg, Binary, IbcMsg, WasmMsg, GovMsg, VoteOption, Boundary, Interval, CroncatQuery, Balance, NativeBalance, Status, ValueOrdering, ValueIndex, PathToValue, SmartQueries, Croncat, Agent, GenericBalance, Cw20CoinVerified, Coin, GetBalancesResponse, GetConfigResponse, GasFraction, GetAgentIdsResponse, AgentResponse, AgentTaskResponse, GetSlotHashesResponse, GetSlotIdsResponse, TaskResponse, ActionForEmpty, Empty, IbcTimeout, IbcTimeoutBlock, HasBalanceGte, CheckOwnerOfNft, CheckProposalStatus, GenericQuery, SmartQueryHead, SmartQuery, GetWalletBalancesResponse, Task, BoundaryValidated, Transform, TaskRequest, Cw20Coin, ExecuteMsg, Cw20ReceiveMsg, GetAgentResponse, GetAgentTasksResponse, GetTaskHashResponse, GetTaskResponse, GetTasksByOwnerResponse, GetTasksResponse, GetTasksWithQueriesResponse, TaskWithQueriesResponse, InstantiateMsg, QueryMsg, ValidateIntervalResponse } from "./CwCroncatCore.types"; +import { Addr, Uint128, Timestamp, Uint64, SlotType, AgentStatus, CosmosMsgForEmpty, BankMsg, StakingMsg, DistributionMsg, Binary, IbcMsg, WasmMsg, GovMsg, VoteOption, Boundary, Interval, CroncatQuery, Balance, NativeBalance, Status, ValueOrdering, ValueIndex, PathToValue, SmartQueries, Croncat, Agent, GenericBalance, Cw20CoinVerified, Coin, GetBalancesResponse, GetConfigResponse, GasPrice, GetAgentIdsResponse, AgentResponse, AgentTaskResponse, GetSlotHashesResponse, GetSlotIdsResponse, TaskResponse, ActionForEmpty, Empty, IbcTimeout, IbcTimeoutBlock, HasBalanceGte, CheckOwnerOfNft, CheckProposalStatus, GenericQuery, SmartQueryHead, SmartQuery, GetWalletBalancesResponse, Task, BoundaryValidated, Transform, TaskRequest, Cw20Coin, ExecuteMsg, Cw20ReceiveMsg, GetAgentResponse, GetAgentTasksResponse, GetTaskHashResponse, GetTaskResponse, GetTasksByOwnerResponse, GetTasksResponse, GetTasksWithQueriesResponse, TaskWithQueriesResponse, InstantiateMsg, QueryMsg, ValidateIntervalResponse } from "./CwCroncatCore.types"; export interface CwCroncatCoreReadOnlyInterface { contractAddress: string; getConfig: () => Promise; @@ -236,7 +236,7 @@ export interface CwCroncatCoreInterface extends CwCroncatCoreReadOnlyInterface { agentsEjectThreshold, gasActionFee, gasBaseFee, - gasFraction, + gasPrice, gasQueryFee, gasWasmQueryFee, minTasksPerAgent, @@ -249,7 +249,7 @@ export interface CwCroncatCoreInterface extends CwCroncatCoreReadOnlyInterface { agentsEjectThreshold?: number; gasActionFee?: Uint64; gasBaseFee?: Uint64; - gasFraction?: GasFraction; + gasPrice?: GasPrice; gasQueryFee?: Uint64; gasWasmQueryFee?: Uint64; minTasksPerAgent?: number; @@ -357,7 +357,7 @@ export class CwCroncatCoreClient extends CwCroncatCoreQueryClient implements CwC agentsEjectThreshold, gasActionFee, gasBaseFee, - gasFraction, + gasPrice, gasQueryFee, gasWasmQueryFee, minTasksPerAgent, @@ -370,7 +370,7 @@ export class CwCroncatCoreClient extends CwCroncatCoreQueryClient implements CwC agentsEjectThreshold?: number; gasActionFee?: Uint64; gasBaseFee?: Uint64; - gasFraction?: GasFraction; + gasPrice?: GasPrice; gasQueryFee?: Uint64; gasWasmQueryFee?: Uint64; minTasksPerAgent?: number; @@ -385,7 +385,7 @@ export class CwCroncatCoreClient extends CwCroncatCoreQueryClient implements CwC agents_eject_threshold: agentsEjectThreshold, gas_action_fee: gasActionFee, gas_base_fee: gasBaseFee, - gas_fraction: gasFraction, + gas_price: gasPrice, gas_query_fee: gasQueryFee, gas_wasm_query_fee: gasWasmQueryFee, min_tasks_per_agent: minTasksPerAgent, diff --git a/typescript/contracts/cw-croncat-core/CwCroncatCore.types.ts b/typescript/contracts/cw-croncat-core/CwCroncatCore.types.ts index f8828c4a..0fc4fcec 100644 --- a/typescript/contracts/cw-croncat-core/CwCroncatCore.types.ts +++ b/typescript/contracts/cw-croncat-core/CwCroncatCore.types.ts @@ -249,7 +249,7 @@ export interface GetConfigResponse { cw_rules_addr: Addr; gas_action_fee: number; gas_base_fee: number; - gas_fraction: GasFraction; + gas_price: GasPrice; limit: number; min_tasks_per_agent: number; native_denom: string; @@ -260,8 +260,9 @@ export interface GetConfigResponse { staked_balance: GenericBalance; [k: string]: unknown; } -export interface GasFraction { +export interface GasPrice { denominator: number; + gas_adjustment_numerator: number; numerator: number; [k: string]: unknown; } @@ -421,7 +422,7 @@ export type ExecuteMsg = { agents_eject_threshold?: number | null; gas_action_fee?: Uint64 | null; gas_base_fee?: Uint64 | null; - gas_fraction?: GasFraction | null; + gas_price?: GasPrice | null; gas_query_fee?: Uint64 | null; gas_wasm_query_fee?: Uint64 | null; min_tasks_per_agent?: number | null; @@ -524,7 +525,7 @@ export interface InstantiateMsg { denom: string; gas_action_fee?: Uint64 | null; gas_base_fee?: Uint64 | null; - gas_fraction?: GasFraction | null; + gas_price?: GasPrice | null; gas_query_fee?: Uint64 | null; gas_wasm_query_fee?: Uint64 | null; owner_id?: string | null;