Swap Extension

AddrEncapsulate astroport for easy use by Kryptonite.

Config

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct Config {
    pub owner: Addr,
    pub new_owner: Option<Addr>,
}

* = optional

InitMsg

#[cw_serde]
pub struct InstantiateMsg {
    pub owner: Addr,
}
{
  "owner": "sei13xy3940qrar0k82k7fzhjpqaxj0h0tep7cpuxz"
}

ExecuteMsg

UpdatePairConfig

Updates swap pair config , pair address find from astorport.

#[cw_serde]
pub enum ExecuteMsg {
    UpdatePairConfig {
        asset_infos: [AssetInfo; 2],
        pair_address: Addr,
        max_spread: Option<Decimal>,
        to: Option<Addr>,
    },
}
{
  "update_pair_config": {
    "asset_infos": [
      {
        "native_token": {
          "denom": "usei"
        }
      },
      {
        "native_token": {
          "denom": "factory/sei1h3ukufh4lhacftdf6kyxzum4p86rcnel35v4jk/usdt"
        }
      }
    ],
    "pair_address": "sei1pqcgdn5vmf3g9ncs98vtxkydc6su0f9rk3uk73s5ku2xhthr6avswrwnrx"
  }
}

* = optional

ChangeOwner

Change the contract owner.only can issued by current owner.

#[cw_serde]
pub enum ExecuteMsg {
    ChangeOwner {
        new_owner: Addr,
    },
}
{
  "change_owner": {
    "new_owner": "sei...addr..."
  }
}

UpdatePairStatus

Update whether the trading pair pool is available, the default is available, the type is bool.

#[cw_serde]
pub enum ExecuteMsg {
    UpdatePairStatus {
        asset_infos: [AssetInfo; 2],
        is_disabled: bool,
    },
}
{
  "update_pair_status": {
    "asset_infos": [
      {
        "native_token": {
          "denom": "usei"
        }
      },
      {
        "native_token": {
          "denom": "factory/sei1h3ukufh4lhacftdf6kyxzum4p86rcnel35v4jk/usdt"
        }
      }
    ],
    "is_disabled": false
  }
}

UpdatePairMaxSpread

Set the maximum spread for a single pool, and use the default value of sparrow swap if it is not set by default

#[cw_serde]
pub enum ExecuteMsg {
    UpdatePairMaxSpread {
        asset_infos: [AssetInfo; 2],
        max_spread: Decimal,
    },
}
{
  "update_pair_max_spread": {
    "asset_infos": [
      {
        "native_token": {
          "denom": "usei"
        }
      },
      {
        "native_token": {
          "denom": "factory/sei1h3ukufh4lhacftdf6kyxzum4p86rcnel35v4jk/usdt"
        }
      }
    ],
    "max_spread": 123456
  }
}

SetWhitelist

To set those addresses you can call the SwapDenom method.

#[cw_serde]
pub enum ExecuteMsg {
    SetWhitelist {
        caller: Addr,
        is_whitelist: bool,
    },
}
{
  "set_whitelist": {
    "caller": "sei...addr...",
    "is_whitelist": true
  }
}

SwapDenom

Swap for assets of the specified denom type.

#[cw_serde]
pub enum ExecuteMsg {
    SwapDenom {
        from_coin: Coin,
        target_denom: String,
        to_address: Option<String>,
    },
}
{
  "swap_denom": {
    "from_coin": {
      "denom": "usei",
      "amount": "12300"
    },
    "target_denom": "factory/sei1h3ukufh4lhacftdf6kyxzum4p86rcnel35v4jk/usdt"
  }
}

QueryMsg

All query messages are described below. A custom struct is defined for each query response.

QueryConfig

Returns information about global config.

#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
    #[returns(ConfigResponse)]
    QueryConfig {},
}
{
  "query_config": {}
}

ConfigResponse

#[cw_serde]
pub struct ConfigResponse {
    pub owner: Addr,
}
{
  "owner": "sei...addr..."
}

QueryIsSwapWhitelist

Returns whether the address is in the whitelist.

#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
    #[returns(bool)]
    QueryIsSwapWhitelist {
        caller: Addr
    },
}
{
  "query_is_swap_whitelist": {
    "caller": "sei...addr..."
  }
}

Return ture or false.

QueryPairConfig

Returns information about a specific swap pair config.

#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
    #[returns(PairConfigResponse)]
    QueryPairConfig {
        asset_infos: [AssetInfo; 2]
    },
}
{
  "query_pair_config": {
    "asset_infos": [
      {
        "native_token": {
          "denom": "usei"
        }
      },
      {
        "native_token": {
          "denom": "factory/sei1h3ukufh4lhacftdf6kyxzum4p86rcnel35v4jk/usdt"
        }
      }
    ]
  }
}

PairConfigResponse

#[cw_serde]
pub struct PairConfigResponse {
    pub pair_address: Addr,
    pub is_disabled: bool,
    pub max_spread: Option<Decimal>,
    pub to: Option<Addr>,
}
{
  "query_swap_info": {
    "asset_infos": [
      {
        "native_token": {
          "denom": "usei"
        }
      },
      {
        "native_token": {
          "denom": "factory/sei1h3ukufh4lhacftdf6kyxzum4p86rcnel35v4jk/usdt"
        }
      }
    ]
  }
}

QuerySwapInfo

Returns information about a specific swap pair info.

#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
    #[returns(SwapInfoResponse)]
    QuerySwapInfo {
        asset_infos: [AssetInfo; 2]
    },
}
{
  "query_swap_info": {
    "asset_infos": [
      {
        "native_token": {
          "denom": "usei"
        }
      },
      {
        "native_token": {
          "denom": "factory/sei1h3ukufh4lhacftdf6kyxzum4p86rcnel35v4jk/usdt"
        }
      }
    ]
  }
}

SwapInfoResponse

#[cw_serde]
pub struct SwapInfoResponse {
    pub total_amount_in: Uint128,
    pub total_amount_out: Uint128,
}
{
  "total_amount_in": "123456",
  "total_amount_out": "123456"
}

QuerySimulation

Returns information about a specific swap simulation.

#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
    #[returns(SimulationResponse)]
    QuerySimulation {
        asset_infos: [AssetInfo; 2],
        offer_asset: Asset,
    },
}
{
  "query_simulation": {
    "asset_infos": [
      {
        "native_token": {
          "denom": "usei"
        }
      },
      {
        "native_token": {
          "denom": "factory/sei1h3ukufh4lhacftdf6kyxzum4p86rcnel35v4jk/usdt"
        }
      }
    ],
    "offer_asset": {
      "info": {
        "native_token": {
          "denom": "usei"
        }
      },
      "amount": "123456"
    }
  }
}

SimulationResponse

/// This structure holds the parameters that are returned from a swap simulation response
#[cw_serde]
pub struct SimulationResponse {
    /// The amount of ask assets returned by the swap
    pub return_amount: Uint128,
    /// The spread used in the swap operation
    pub spread_amount: Uint128,
    /// The amount of fees charged by the transaction
    pub commission_amount: Uint128,
}
{
  "return_amount": "123456",
  "spread_amount": "123456",
  "commission_amount": "123456"
}

QueryReverseSimulation

Returns information about a specific reverse swap simulation

#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
    #[returns(ReverseSimulationResponse)]
    QueryReverseSimulation {
        asset_infos: [AssetInfo; 2],
        ask_asset: Asset,
    },
}
{
  "query_reverse_simulation": {
    "asset_infos": [
      {
        "native_token": {
          "denom": "usei"
        }
      },
      {
        "native_token": {
          "denom": "factory/sei1h3ukufh4lhacftdf6kyxzum4p86rcnel35v4jk/usdt"
        }
      }
    ],
    "ask_asset": {
      "info": {
        "native_token": {
          "denom": "usei"
        }
      },
      "amount": "123456"
    }
  }
}

ReverseSimulationResponse

/// This structure holds the parameters that are returned from a reverse swap simulation response.
#[cw_serde]
pub struct ReverseSimulationResponse {
    /// The amount of offer assets returned by the reverse swap
    pub offer_amount: Uint128,
    /// The spread used in the swap operation
    pub spread_amount: Uint128,
    /// The amount of fees charged by the transaction
    pub commission_amount: Uint128,
}
{
  "offer_amount": "123456",
  "spread_amount": "123456",
  "commission_amount": "123456"
}

QueryCumulativePrices

Returns information about a specific cumulative prices.

#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
    #[returns(CumulativePricesResponse)]
    QueryCumulativePrices {
        asset_infos: [AssetInfo; 2],
    },
}
{
  "query_cumulative_prices": {
    "asset_infos": [
      {
        "native_token": {
          "denom": "usei"
        }
      },
      {
        "native_token": {
          "denom": "factory/sei1h3ukufh4lhacftdf6kyxzum4p86rcnel35v4jk/usdt"
        }
      }
    ]
  }
}

CumulativePricesResponse

/// This structure is used to return a cumulative prices query response.
#[cw_serde]
pub struct CumulativePricesResponse {
    /// The two assets in the pool to query
    pub assets: [Asset; 2],
    /// The total amount of LP tokens currently issued
    pub total_share: Uint128,
    /// The last value for the token0 cumulative price
    pub price0_cumulative_last: Uint128,
    /// The last value for the token1 cumulative price
    pub price1_cumulative_last: Uint128,
}
{
  "assets": [
    {
      "info": {
        "native_token": {
          "denom": "usei"
        }
      },
      "amount": "123456"
    },
    {
      "info": {
        "native_token": {
          "denom": "factory/sei1h3ukufh4lhacftdf6kyxzum4p86rcnel35v4jk/usdt"
        }
      },
      "amount": "123456"
    }
  ],
  "total_share": "123456",
  "price0_cumulative_last": "123456",
  "price1_cumulative_last": "123456"
}

Last updated