Entry point

The ExecuteMsg:Runner Entry point

DeFund uses an entry point within your contract to automatically run your dETF contract at each rebalance height, assuming the fund type is set to active. If the fund type is set to passive, at each rebalance height, DeFund will auto-rebalance the fund automatically with one exception: holding types in index funds that are set to a wasm contract address skip auto-rebalance, and are instead treated as a custom rebalance through the contract. DeFund will run this contract at the rebalance period through the ExecuteMsg:Runner explained below.

At each rebalance height (specified in the create-fund command), DeFund will run your contract for you through the entry point Runner in the pub enum, which is the entry point for your dETF contract (see https://docs.cosmwasm.com/docs/1.0/smart-contracts/message/message). It is the only required message in the pub enum ExecuteMsg within a DeFund contract. If you would like to define other messages beyond this, you are of course free to do so.

DeFund Runner Entry point

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
  Runner { },
  // add any other msg's here
  ...,
}
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn execute(
  deps: DepsMut,
  env: Env,
  info: MessageInfo,
  msg: ExecuteMsg,
) -> Result<Response, ContractError> {
  match msg {
    ExecuteMsg::Runner { } => execute_runner(deps, env, info, name),
    // add any other msg's here
    ...,
  }
}

See an entry point example here https://github.com/defund-labs/defund-cosmwasm/blob/2160296583e8105780ca8d4a118a5388e99f3844/examples/odd-number/src/contract.rs#L38

Last updated