diff --git a/contracts/covenant/src/contract.rs b/contracts/covenant/src/contract.rs index 885cae13..065c2299 100644 --- a/contracts/covenant/src/contract.rs +++ b/contracts/covenant/src/contract.rs @@ -2,12 +2,11 @@ use cosmwasm_std::entry_point; use cosmwasm_std::{ to_binary, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdResult, - SubMsg, Uint128, WasmMsg, + SubMsg, WasmMsg, }; use cw2::set_contract_version; use cw_utils::parse_reply_instantiate_data; -use neutron_sdk::bindings::msg::IbcFee; use crate::{ error::ContractError, @@ -16,7 +15,7 @@ use crate::{ CLOCK_CODE, COVENANT_CLOCK_ADDR, COVENANT_DEPOSITOR_ADDR, COVENANT_HOLDER_ADDR, COVENANT_LP_ADDR, COVENANT_LS_ADDR, DEPOSITOR_CODE, HOLDER_CODE, IBC_FEE, IBC_TIMEOUT, LP_CODE, LS_CODE, POOL_ADDRESS, PRESET_CLOCK_FIELDS, PRESET_DEPOSITOR_FIELDS, - PRESET_HOLDER_FIELDS, PRESET_LP_FIELDS, PRESET_LS_FIELDS, + PRESET_HOLDER_FIELDS, PRESET_LP_FIELDS, PRESET_LS_FIELDS, TIMEOUTS, }, }; @@ -47,33 +46,15 @@ pub fn instantiate( CLOCK_CODE.save(deps.storage, &msg.preset_clock_fields.clock_code)?; POOL_ADDRESS.save(deps.storage, &msg.pool_address)?; - PRESET_CLOCK_FIELDS.save(deps.storage, &msg.preset_clock_fields)?; PRESET_LP_FIELDS.save(deps.storage, &msg.preset_lp_fields)?; PRESET_LS_FIELDS.save(deps.storage, &msg.preset_ls_fields)?; PRESET_DEPOSITOR_FIELDS.save(deps.storage, &msg.preset_depositor_fields)?; PRESET_HOLDER_FIELDS.save(deps.storage, &msg.preset_holder_fields)?; - - let ibc_timeout = if let Some(timeout) = msg.ibc_msg_transfer_timeout_timestamp { - timeout - } else { - DEFAULT_TIMEOUT_SECONDS - }; - // 10 seconds - IBC_TIMEOUT.save(deps.storage, &ibc_timeout)?; + TIMEOUTS.save(deps.storage, &msg.timeouts)?; IBC_FEE.save( deps.storage, - &IbcFee { - recv_fee: vec![], - ack_fee: vec![cosmwasm_std::Coin { - denom: "untrn".to_string(), - amount: Uint128::new(1000u128), - }], - timeout_fee: vec![cosmwasm_std::Coin { - denom: "untrn".to_string(), - amount: Uint128::new(1000u128), - }], - }, + &msg.preset_ibc_fee.to_ibc_fee(), )?; let clock_instantiate_tx = CosmosMsg::Wasm(WasmMsg::Instantiate { @@ -199,14 +180,15 @@ pub fn handle_lp_reply(deps: DepsMut, env: Env, msg: Reply) -> Result Result Result, - // pub preset_ibc_fee: Option, + pub preset_ibc_fee: PresetIbcFee, + pub timeouts: Timeouts, +} + +#[cw_serde] +pub struct Timeouts { + pub ica_timeout: Uint64, + pub ibc_transfer_timeout: Uint64, } #[cw_serde] pub struct PresetIbcFee { - pub ack_fee: Coin, - pub timeout_fee: Coin, + pub ack_fee: Uint128, + pub timeout_fee: Uint128, } impl PresetIbcFee { @@ -31,8 +40,14 @@ impl PresetIbcFee { IbcFee { // must be empty recv_fee: vec![], - ack_fee: vec![self.ack_fee], - timeout_fee: vec![self.timeout_fee], + ack_fee: vec![cosmwasm_std::Coin { + denom: NEUTRON_DENOM.to_string(), + amount: self.ack_fee, + }], + timeout_fee: vec![cosmwasm_std::Coin { + denom: NEUTRON_DENOM.to_string(), + amount: self.timeout_fee, + }], } } } diff --git a/contracts/covenant/src/state.rs b/contracts/covenant/src/state.rs index 14285c37..4016906c 100644 --- a/contracts/covenant/src/state.rs +++ b/contracts/covenant/src/state.rs @@ -2,6 +2,8 @@ use cosmwasm_std::Addr; use cw_storage_plus::Item; use neutron_sdk::bindings::msg::IbcFee; +use crate::msg::Timeouts; + pub const LS_CODE: Item = Item::new("ls_code"); pub const LP_CODE: Item = Item::new("lp_code"); pub const DEPOSITOR_CODE: Item = Item::new("depositor_code"); @@ -11,6 +13,7 @@ pub const HOLDER_CODE: Item = Item::new("holder_code"); pub const POOL_ADDRESS: Item = Item::new("pool_address"); pub const IBC_TIMEOUT: Item = Item::new("ibc_timeout"); pub const IBC_FEE: Item = Item::new("ibc_fee"); +pub const TIMEOUTS: Item = Item::new("timeouts"); pub const PRESET_LS_FIELDS: Item = Item::new("preset_ls_fields"); pub const PRESET_LP_FIELDS: Item = Item::new("preset_lp_fields"); diff --git a/contracts/covenant/src/suite_test/suite.rs b/contracts/covenant/src/suite_test/suite.rs index 3a765db4..d5e96e71 100644 --- a/contracts/covenant/src/suite_test/suite.rs +++ b/contracts/covenant/src/suite_test/suite.rs @@ -1,8 +1,8 @@ -use cosmwasm_std::{Addr, Empty, Uint64}; +use cosmwasm_std::{Addr, Empty, Uint64, Uint128}; use covenant_lp::msg::AssetData; use cw_multi_test::{App, Contract, ContractWrapper, Executor}; -use crate::msg::{InstantiateMsg, QueryMsg}; +use crate::msg::{InstantiateMsg, QueryMsg, PresetIbcFee, Timeouts}; pub const CREATOR_ADDR: &str = "admin"; pub const TODO: &str = "replace"; @@ -99,16 +99,14 @@ impl Default for SuiteBuilder { label: "covenant_contract".to_string(), pool_address: TODO.to_string(), ibc_msg_transfer_timeout_timestamp: None, - // preset_ibc_fee: PresetIbcFee { - // ack_fee: cosmwasm_std::Coin { - // denom: NEUTRON_DENOM.to_string(), - // amount: Uint128::new(1000u128), - // }, - // timeout_fee: cosmwasm_std::Coin { - // denom: NEUTRON_DENOM.to_string(), - // amount: Uint128::new(1000u128), - // }, - // }, + preset_ibc_fee: PresetIbcFee { + ack_fee: Uint128::new(1000), + timeout_fee: Uint128::new(1000), + }, + timeouts: Timeouts { + ica_timeout: Uint64::new(18000), // 5 hours + ibc_transfer_timeout: Uint64::new(120), // 2 minutes + }, }, } } diff --git a/contracts/depositor/src/contract.rs b/contracts/depositor/src/contract.rs index 38789575..519623da 100644 --- a/contracts/depositor/src/contract.rs +++ b/contracts/depositor/src/contract.rs @@ -3,7 +3,6 @@ use std::fmt::Error; use cosmos_sdk_proto::cosmos::base::v1beta1::Coin; use cosmos_sdk_proto::ibc::applications::transfer::v1::MsgTransfer; -use cosmos_sdk_proto::ibc::core::client::v1::Height; #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ @@ -17,7 +16,7 @@ use neutron_sdk::interchain_queries::v045::new_register_transfers_query_msg; use prost::Message; -use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, OpenAckVersion, QueryMsg}; +use crate::{msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, OpenAckVersion, QueryMsg}, state::{IBC_TRANSFER_TIMEOUT, ICA_TIMEOUT}}; use neutron_sdk::{ bindings::{ msg::{MsgSubmitTxResponse, NeutronMsg}, @@ -33,7 +32,7 @@ use crate::state::{ save_reply_payload, save_sudo_payload, AcknowledgementResult, ContractState, SudoPayload, ACKNOWLEDGEMENT_RESULTS, AUTOPILOT_FORMAT, CLOCK_ADDRESS, CONTRACT_STATE, GAIA_NEUTRON_IBC_TRANSFER_CHANNEL_ID, GAIA_STRIDE_IBC_TRANSFER_CHANNEL_ID, IBC_FEE, - IBC_PORT_ID, IBC_TIMEOUT, ICA_ADDRESS, INTERCHAIN_ACCOUNTS, LS_ADDRESS, NATIVE_ATOM_RECEIVER, + IBC_PORT_ID, ICA_ADDRESS, INTERCHAIN_ACCOUNTS, LS_ADDRESS, NATIVE_ATOM_RECEIVER, NEUTRON_GAIA_CONNECTION_ID, STRIDE_ATOM_RECEIVER, SUDO_PAYLOAD_REPLY_ID, }; @@ -71,10 +70,11 @@ pub fn instantiate( .save(deps.storage, &msg.gaia_stride_ibc_transfer_channel_id)?; LS_ADDRESS.save(deps.storage, &msg.ls_address)?; AUTOPILOT_FORMAT.save(deps.storage, &msg.autopilot_format)?; - IBC_TIMEOUT.save(deps.storage, &msg.ibc_timeout)?; GAIA_STRIDE_IBC_TRANSFER_CHANNEL_ID .save(deps.storage, &msg.gaia_stride_ibc_transfer_channel_id)?; IBC_FEE.save(deps.storage, &msg.ibc_fee)?; + IBC_TRANSFER_TIMEOUT.save(deps.storage, &msg.ibc_transfer_timeout)?; + ICA_TIMEOUT.save(deps.storage, &msg.ica_timeout)?; Ok(Response::default().add_attribute("method", "depositor_instantiate")) } @@ -127,7 +127,7 @@ fn try_tick(deps: ExecuteDeps, env: Env, info: MessageInfo) -> NeutronResult NeutronResult> { @@ -158,8 +158,9 @@ fn try_liquid_stake( let stride_receiver = STRIDE_ATOM_RECEIVER.load(deps.storage)?; let gaia_stride_channel: String = GAIA_STRIDE_IBC_TRANSFER_CHANNEL_ID.load(deps.storage)?; - let timeout = IBC_TIMEOUT.load(deps.storage)?; - + let ibc_transfer_timeout = IBC_TRANSFER_TIMEOUT.load(deps.storage)?; + let ica_timeout = ICA_TIMEOUT.load(deps.storage)?; + let amount = stride_receiver.amount.to_string(); let st_ica = stride_ica_addr; @@ -168,11 +169,10 @@ fn try_liquid_stake( amount, }; - // let autopilot_receiver = AUTOPILOT_FORMAT - // .load(deps.storage)? - // .replace("{st_ica}", &st_ica); - // AUTOPILOT_FORMAT.save(deps.storage, &autopilot_receiver)?; - let autopilot_receiver = format!("{{\"autopilot\": {{\"receiver\": \"{st_ica}\",\"stakeibc\": {{\"stride_address\": \"{st_ica}\",\"action\": \"LiquidStake\"}}}}}}"); + let autopilot_receiver = AUTOPILOT_FORMAT + .load(deps.storage)? + .replace("{st_ica}", &st_ica); + AUTOPILOT_FORMAT.save(deps.storage, &autopilot_receiver)?; let stride_msg = MsgTransfer { source_port: "transfer".to_string(), @@ -180,11 +180,8 @@ fn try_liquid_stake( token: Some(coin), sender: address, receiver: autopilot_receiver, - timeout_height: Some(Height { - revision_number: 3, - revision_height: 1000, - }), - timeout_timestamp: 0, + timeout_height: None, + timeout_timestamp: env.block.time.plus_seconds(ibc_transfer_timeout.u64()).nanos(), }; // Serialize the Transfer message @@ -204,7 +201,7 @@ fn try_liquid_stake( INTERCHAIN_ACCOUNT_ID.to_string(), vec![protobuf], "".to_string(), - timeout, + ica_timeout.u64(), fee, ); @@ -219,8 +216,6 @@ fn try_liquid_stake( }, )?; - // CONTRACT_STATE.save(deps.storage, &ContractState::LiquidStaked)?; - Ok(Response::default() .add_attribute("method", "try_liquid_stake") // .add_attribute("stride_submit_msg_hex", encode_hex(protobuf.value.as_slice())) @@ -234,7 +229,7 @@ fn try_liquid_stake( fn try_receive_atom_from_ica( deps: ExecuteDeps, - _env: Env, + env: Env, _info: MessageInfo, _gaia_account_address: String, ) -> NeutronResult> { @@ -247,7 +242,8 @@ fn try_receive_atom_from_ica( let source_channel = GAIA_NEUTRON_IBC_TRANSFER_CHANNEL_ID.load(deps.storage)?; let lp_receiver = NATIVE_ATOM_RECEIVER.load(deps.storage)?; let amount = lp_receiver.amount.to_string(); - let timeout = IBC_TIMEOUT.load(deps.storage)?; + let ibc_transfer_timeout = IBC_TRANSFER_TIMEOUT.load(deps.storage)?; + let ica_timeout = ICA_TIMEOUT.load(deps.storage)?; let fee = IBC_FEE.load(deps.storage)?; let coin = Coin { @@ -261,11 +257,8 @@ fn try_receive_atom_from_ica( token: Some(coin), sender: address.clone(), receiver: lp_receiver.address, - timeout_height: Some(Height { - revision_number: 2, - revision_height: 1300, - }), - timeout_timestamp: 0, + timeout_height: None, + timeout_timestamp: env.block.time.plus_seconds(ibc_transfer_timeout.u64()).nanos(), }; // Serialize the Transfer message @@ -285,7 +278,7 @@ fn try_receive_atom_from_ica( INTERCHAIN_ACCOUNT_ID.to_string(), vec![protobuf], address, - timeout, + ica_timeout.u64(), fee, ); @@ -489,8 +482,9 @@ pub fn migrate(deps: DepsMut, _env: Env, msg: MigrateMsg) -> StdResult gaia_stride_ibc_transfer_channel_id, ls_address, autopilot_format, - ibc_timeout, ibc_fee, + ibc_transfer_timeout, + ica_timeout, } => { if let Some(clock_addr) = clock_addr { CLOCK_ADDRESS.save(deps.storage, &deps.api.addr_validate(&clock_addr)?)?; @@ -527,8 +521,12 @@ pub fn migrate(deps: DepsMut, _env: Env, msg: MigrateMsg) -> StdResult AUTOPILOT_FORMAT.save(deps.storage, &autopilot_f)?; } - if let Some(timeout) = ibc_timeout { - IBC_TIMEOUT.save(deps.storage, &timeout)?; + if let Some(timeout) = ibc_transfer_timeout { + IBC_TRANSFER_TIMEOUT.save(deps.storage, &timeout)?; + } + + if let Some(timeout) = ica_timeout { + ICA_TIMEOUT.save(deps.storage, &timeout)?; } if let Some(fee) = ibc_fee { diff --git a/contracts/depositor/src/msg.rs b/contracts/depositor/src/msg.rs index fdacf6cf..aef343c0 100644 --- a/contracts/depositor/src/msg.rs +++ b/contracts/depositor/src/msg.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::{cw_serde, QueryResponses}; -use cosmwasm_std::{Addr, Binary}; +use cosmwasm_std::{Addr, Binary, Uint64}; use covenant_clock_derive::clocked; use neutron_sdk::bindings::{msg::IbcFee, query::QueryInterchainAccountAddressResponse}; @@ -15,8 +15,9 @@ pub struct InstantiateMsg { pub gaia_stride_ibc_transfer_channel_id: String, pub ls_address: String, pub autopilot_format: String, - pub ibc_timeout: u64, pub ibc_fee: IbcFee, + pub ibc_transfer_timeout: Uint64, + pub ica_timeout: Uint64, } #[cw_serde] @@ -52,8 +53,9 @@ impl PresetDepositorFields { clock_address: String, ls_address: String, lp_address: String, - ibc_timeout: u64, ibc_fee: IbcFee, + ibc_transfer_timeout: Uint64, + ica_timeout: Uint64, ) -> InstantiateMsg { InstantiateMsg { st_atom_receiver: self @@ -66,8 +68,9 @@ impl PresetDepositorFields { gaia_stride_ibc_transfer_channel_id: self.gaia_stride_ibc_transfer_channel_id, ls_address, autopilot_format: self.autopilot_format, - ibc_timeout, ibc_fee, + ibc_transfer_timeout, + ica_timeout, } } } @@ -130,8 +133,9 @@ pub enum MigrateMsg { gaia_stride_ibc_transfer_channel_id: Option, ls_address: Option, autopilot_format: Option, - ibc_timeout: Option, ibc_fee: Option, + ibc_transfer_timeout: Option, + ica_timeout: Option, }, UpdateCodeId { data: Option, diff --git a/contracts/depositor/src/state.rs b/contracts/depositor/src/state.rs index fbad5a2c..c4b48668 100644 --- a/contracts/depositor/src/state.rs +++ b/contracts/depositor/src/state.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::cw_serde; -use cosmwasm_std::{from_binary, to_vec, Addr, Binary, Order, StdResult, Storage}; +use cosmwasm_std::{from_binary, to_vec, Addr, Binary, Order, StdResult, Storage, Uint64}; use cw_storage_plus::{Item, Map}; use neutron_sdk::bindings::msg::IbcFee; @@ -23,7 +23,8 @@ pub const GAIA_STRIDE_IBC_TRANSFER_CHANNEL_ID: Item = Item::new("gs_ibc_ pub const NEUTRON_GAIA_CONNECTION_ID: Item = Item::new("ng_conn_id"); pub const ICA_ADDRESS: Item = Item::new("ica_address"); -pub const IBC_TIMEOUT: Item = Item::new("ibc_timeout"); +pub const IBC_TRANSFER_TIMEOUT: Item = Item::new("ibc_transfer_timeout"); +pub const ICA_TIMEOUT: Item = Item::new("ica_timeout"); pub const IBC_FEE: Item = Item::new("ibc_fee"); // ICA diff --git a/contracts/depositor/src/suite_test/suite.rs b/contracts/depositor/src/suite_test/suite.rs index 83b911c6..2f58b1d8 100644 --- a/contracts/depositor/src/suite_test/suite.rs +++ b/contracts/depositor/src/suite_test/suite.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{testing::MockApi, Addr, Empty, MemoryStorage, Uint128}; +use cosmwasm_std::{testing::MockApi, Addr, Empty, MemoryStorage, Uint128, Uint64}; use cw_multi_test::{ App, BankKeeper, BasicAppBuilder, Contract, ContractWrapper, Executor, FailingModule, WasmKeeper, @@ -68,7 +68,6 @@ impl Default for SuiteBuilder { gaia_stride_ibc_transfer_channel_id: "channel-3".to_string(), ls_address: "TODO".to_string(), autopilot_format: "{{\"autopilot\": {{\"receiver\": \"{st_ica}\",\"stakeibc\": {{\"stride_address\": \"{st_ica}\",\"action\": \"LiquidStake\"}}}}}}".to_string(), - ibc_timeout: 100000, ibc_fee: IbcFee { recv_fee: vec![], // must be empty ack_fee: vec![cosmwasm_std::Coin { @@ -80,6 +79,8 @@ impl Default for SuiteBuilder { amount: Uint128::new(1000u128), }], }, + ica_timeout: Uint64::new(18000), // 5 hours + ibc_transfer_timeout: Uint64::new(120), // 2 minutes }, } } diff --git a/contracts/ls/src/contract.rs b/contracts/ls/src/contract.rs index 50b8504e..baf33256 100644 --- a/contracts/ls/src/contract.rs +++ b/contracts/ls/src/contract.rs @@ -2,7 +2,6 @@ use std::fmt::Error; use cosmos_sdk_proto::cosmos::base::v1beta1::Coin; use cosmos_sdk_proto::ibc::applications::transfer::v1::MsgTransfer; -use cosmos_sdk_proto::ibc::core::client::v1::Height; use cosmos_sdk_proto::traits::Message; #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; @@ -19,9 +18,9 @@ use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, OpenAckVersion, QueryMs use crate::state::{ add_error_to_queue, read_errors_from_queue, read_reply_payload, read_sudo_payload, save_reply_payload, save_sudo_payload, AcknowledgementResult, ContractState, SudoPayload, - ACKNOWLEDGEMENT_RESULTS, CLOCK_ADDRESS, CONTRACT_STATE, IBC_FEE, IBC_PORT_ID, IBC_TIMEOUT, + ACKNOWLEDGEMENT_RESULTS, CLOCK_ADDRESS, CONTRACT_STATE, IBC_FEE, IBC_PORT_ID, ICA_ADDRESS, INTERCHAIN_ACCOUNTS, LP_ADDRESS, LS_DENOM, NEUTRON_STRIDE_IBC_CONNECTION_ID, - STRIDE_NEUTRON_IBC_TRANSFER_CHANNEL_ID, SUDO_PAYLOAD_REPLY_ID, + STRIDE_NEUTRON_IBC_TRANSFER_CHANNEL_ID, SUDO_PAYLOAD_REPLY_ID, IBC_TRANSFER_TIMEOUT, ICA_TIMEOUT, }; use neutron_sdk::{ bindings::{ @@ -61,7 +60,8 @@ pub fn instantiate( LP_ADDRESS.save(deps.storage, &msg.lp_address)?; NEUTRON_STRIDE_IBC_CONNECTION_ID.save(deps.storage, &msg.neutron_stride_ibc_connection_id)?; LS_DENOM.save(deps.storage, &msg.ls_denom)?; - IBC_TIMEOUT.save(deps.storage, &msg.ibc_timeout)?; + IBC_TRANSFER_TIMEOUT.save(deps.storage, &msg.ibc_transfer_timeout)?; + ICA_TIMEOUT.save(deps.storage, &msg.ica_timeout)?; IBC_FEE.save(deps.storage, &msg.ibc_fee)?; Ok(Response::default().add_attribute("method", "instantiate")) @@ -114,7 +114,7 @@ fn try_register_stride_ica(deps: DepsMut, env: Env) -> NeutronResult NeutronResult> { @@ -128,7 +128,8 @@ fn try_execute_transfer( let source_channel = STRIDE_NEUTRON_IBC_TRANSFER_CHANNEL_ID.load(deps.storage)?; let lp_receiver = LP_ADDRESS.load(deps.storage)?; let denom = LS_DENOM.load(deps.storage)?; - let timeout = IBC_TIMEOUT.load(deps.storage)?; + let ibc_transfer_timeout = IBC_TRANSFER_TIMEOUT.load(deps.storage)?; + let ica_timeout = ICA_TIMEOUT.load(deps.storage)?; let coin = Coin { denom, @@ -141,11 +142,8 @@ fn try_execute_transfer( token: Some(coin), sender: address, receiver: lp_receiver.clone(), - timeout_height: Some(Height { - revision_number: 3, - revision_height: 1500, - }), - timeout_timestamp: 0, + timeout_height: None, + timeout_timestamp: env.block.time.plus_seconds(ibc_transfer_timeout.u64()).nanos(), }; // Serialize the Transfer message @@ -165,7 +163,7 @@ fn try_execute_transfer( INTERCHAIN_ACCOUNT_ID.to_string(), vec![protobuf], lp_receiver, - timeout, + ica_timeout.u64(), fee, ); @@ -318,8 +316,9 @@ pub fn migrate(deps: DepsMut, _env: Env, msg: MigrateMsg) -> StdResult lp_address, neutron_stride_ibc_connection_id, ls_denom, - ibc_timeout, ibc_fee, + ibc_transfer_timeout, + ica_timeout, } => { if let Some(clock_addr) = clock_addr { CLOCK_ADDRESS.save(deps.storage, &deps.api.addr_validate(&clock_addr)?)?; @@ -345,8 +344,12 @@ pub fn migrate(deps: DepsMut, _env: Env, msg: MigrateMsg) -> StdResult LS_DENOM.save(deps.storage, &ls_denom)?; } - if let Some(timeout) = ibc_timeout { - IBC_TIMEOUT.save(deps.storage, &timeout)?; + if let Some(timeout) = ibc_transfer_timeout { + IBC_TRANSFER_TIMEOUT.save(deps.storage, &timeout)?; + } + + if let Some(timeout) = ica_timeout { + ICA_TIMEOUT.save(deps.storage, &timeout)?; } if let Some(fee) = ibc_fee { diff --git a/contracts/ls/src/msg.rs b/contracts/ls/src/msg.rs index 2cfd6360..87c8855f 100644 --- a/contracts/ls/src/msg.rs +++ b/contracts/ls/src/msg.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::{cw_serde, QueryResponses}; -use cosmwasm_std::{Addr, Binary, Uint128}; +use cosmwasm_std::{Addr, Binary, Uint128, Uint64}; use covenant_clock_derive::clocked; use neutron_sdk::bindings::msg::IbcFee; @@ -12,8 +12,9 @@ pub struct InstantiateMsg { pub neutron_stride_ibc_connection_id: String, pub lp_address: String, pub ls_denom: String, - pub ibc_timeout: u64, pub ibc_fee: IbcFee, + pub ica_timeout: Uint64, + pub ibc_transfer_timeout: Uint64, } #[cw_serde] @@ -30,8 +31,9 @@ impl PresetLsFields { self, clock_address: String, lp_address: String, - ibc_timeout: u64, ibc_fee: IbcFee, + ica_timeout: Uint64, + ibc_transfer_timeout: Uint64, ) -> InstantiateMsg { InstantiateMsg { clock_address, @@ -39,8 +41,9 @@ impl PresetLsFields { neutron_stride_ibc_connection_id: self.neutron_stride_ibc_connection_id, lp_address, ls_denom: self.ls_denom, - ibc_timeout, ibc_fee, + ica_timeout, + ibc_transfer_timeout, } } } @@ -78,8 +81,9 @@ pub enum MigrateMsg { lp_address: Option, neutron_stride_ibc_connection_id: Option, ls_denom: Option, - ibc_timeout: Option, ibc_fee: Option, + ibc_transfer_timeout: Option, + ica_timeout: Option, }, UpdateCodeId { data: Option, diff --git a/contracts/ls/src/state.rs b/contracts/ls/src/state.rs index 37b74c8a..a79d1b95 100644 --- a/contracts/ls/src/state.rs +++ b/contracts/ls/src/state.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{from_binary, to_vec, Addr, Binary, Order, StdResult, Storage}; +use cosmwasm_std::{from_binary, to_vec, Addr, Binary, Order, StdResult, Storage, Uint128, Uint64}; use cw_storage_plus::{Item, Map}; use neutron_sdk::bindings::msg::IbcFee; use schemars::JsonSchema; @@ -18,7 +18,8 @@ pub const LS_DENOM: Item = Item::new("ls_denom"); pub const INTERCHAIN_ACCOUNTS: Map> = Map::new("interchain_accounts"); pub const IBC_PORT_ID: Item = Item::new("ibc_port_id"); -pub const IBC_TIMEOUT: Item = Item::new("ibc_timeout"); +pub const IBC_TRANSFER_TIMEOUT: Item = Item::new("ibc_transfer_timeout"); +pub const ICA_TIMEOUT: Item = Item::new("ica_timeout"); pub const IBC_FEE: Item = Item::new("ibc_fee"); #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] diff --git a/stride-covenant/tests/interchaintest/ics_test.go b/stride-covenant/tests/interchaintest/ics_test.go index 6c9754f2..fcd73b16 100644 --- a/stride-covenant/tests/interchaintest/ics_test.go +++ b/stride-covenant/tests/interchaintest/ics_test.go @@ -1019,21 +1019,26 @@ func TestICS(t *testing.T) { Label: "covenant-holder", Withdrawer: neutronUser.Bech32Address(neutron.Config().Bech32Prefix), } - // presetIbcFee := PresetIbcFee{ - // AckFee: CwCoin{Amount: 1000, Denom: "untrn"}, - // TimeoutFee: CwCoin{Amount: 1000, Denom: "untrn"}, - // } + presetIbcFee := PresetIbcFee{ + AckFee: "1000", + TimeoutFee: "1000", + } + + timeouts := Timeouts{ + IcaTimeout: "30", // 30sec + IbcTransferTimeout: "45", // 45sec + } covenantMsg := CovenantInstantiateMsg{ - Label: "stride-covenant", - PresetClock: clockMsg, - PresetLs: lsMsg, - PresetDepositor: depositorMsg, - PresetLp: lpMsg, - PresetHolder: holderMsg, - PoolAddress: stableswapAddress, - IbcMsgTransferTimeoutTimestamp: 10000000000, - // PresetIbcFee: presetIbcFee, + Label: "stride-covenant", + PresetClock: clockMsg, + PresetLs: lsMsg, + PresetDepositor: depositorMsg, + PresetLp: lpMsg, + PresetHolder: holderMsg, + PoolAddress: stableswapAddress, + Timeouts: timeouts, + PresetIbcFee: presetIbcFee, } str, err := json.Marshal(covenantMsg) diff --git a/stride-covenant/tests/interchaintest/types.go b/stride-covenant/tests/interchaintest/types.go index 13d9c595..52d32e76 100644 --- a/stride-covenant/tests/interchaintest/types.go +++ b/stride-covenant/tests/interchaintest/types.go @@ -15,20 +15,25 @@ type PresetLsFields struct { } type CovenantInstantiateMsg struct { - Label string `json:"label"` - PresetClock PresetClockFields `json:"preset_clock_fields"` - PresetLs PresetLsFields `json:"preset_ls_fields"` - PresetDepositor PresetDepositorFields `json:"preset_depositor_fields"` - PresetLp PresetLpFields `json:"preset_lp_fields"` - PresetHolder PresetHolderFields `json:"preset_holder_fields"` - PoolAddress string `json:"pool_address"` - IbcMsgTransferTimeoutTimestamp uint64 `json:"ibc_msg_transfer_timeout_timestamp"` - // PresetIbcFee PresetIbcFee `json:"preset_ibc_fee"` + Label string `json:"label"` + PresetClock PresetClockFields `json:"preset_clock_fields"` + PresetLs PresetLsFields `json:"preset_ls_fields"` + PresetDepositor PresetDepositorFields `json:"preset_depositor_fields"` + PresetLp PresetLpFields `json:"preset_lp_fields"` + PresetHolder PresetHolderFields `json:"preset_holder_fields"` + PoolAddress string `json:"pool_address"` + PresetIbcFee PresetIbcFee `json:"preset_ibc_fee"` + Timeouts Timeouts `json:"timeouts"` +} + +type Timeouts struct { + IcaTimeout string `json:"ica_timeout"` + IbcTransferTimeout string `json:"ibc_transfer_timeout"` } type PresetIbcFee struct { - AckFee CwCoin `json:"ack_fee"` - TimeoutFee CwCoin `json:"timeout_fee"` + AckFee string `json:"ack_fee"` + TimeoutFee string `json:"timeout_fee"` } type PresetClockFields struct {