Function fadroma::math::convert_token
source · [−]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 convertrate
- 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_000input_decimals
- the number of decimals of the input tokenoutput_decimals
- the number of decimals of the output token