Tokens
Functions Outline
useUSDCToken()
: Returns a USDC token instance with predefined properties such as address and decimals. This function utilizes the useUSDCAddress
hook to dynamically fetch the USDC token address.
export function useUSDCToken() {
const USDC_ADDRESS = useUSDCAddress();
return duplicateTokenByAddressMap(USDC_ADDRESS, 6, "USDC", "USDC");
}
useCollateralToken()
: Creates and returns a collateral token instance. It fetches the token's address, symbol, and decimals using the respective hooks. It returns a TokenMap
object generated by duplicateTokenByAddressMap
export function useCollateralToken() {
const COLLATERAL_ADDRESS = useCollateralAddress();
const COLLATERAL_SYMBOL = useCollateralSymbol();
const COLLATERAL_DECIMALS = useCollateralDecimal();
return duplicateTokenByAddressMap(
COLLATERAL_ADDRESS,
6,
COLLATERAL_SYMBOL,
COLLATERAL_SYMBOL,
COLLATERAL_DECIMALS
);
}
useTokenShorthand()
: Provides a shorthand mapping for tokens.
export function useTokenShorthand() {
const USDC_TOKEN = useUSDCToken();
const v3_ids = useV3Ids();
const tmpStruct = v3_ids?.reduce((acc, id) => {
acc[id] = USDC_TOKEN[id]?.address;
return acc;
}, {});
return {
USDC: tmpStruct,
};
}
Last updated