pub fn convert_token(
    amount: impl Into<Uint256>,
    rate: impl Into<Uint256>,
    input_decimals: u8,
    output_decimals: u8
) -> StdResult<Uint256>
Expand description

Convert between tokens with different decimals.

Arguments

  • amount - the amount of input token to convert
  • rate - corresponds to the output token decimals. E.g: If we want 1:1 rate and the output token has 6 decimals, then rate = 1_000_000
  • input_decimals - the number of decimals of the input token
  • output_decimals - the number of decimals of the output token