CustomERC20Pricing
Inherits: Ownable, IApplicationEvents, IProtocolERC20Pricing, AppAdministratorOnly, IZeroAddressError
Author: @ShaneDuncan602, @oscarsernarosero, @TJ-Everett
This contract is an example of how one could implement a custom pricing solution. It uses a Chainlink Price Feed to get the token price
State Variables
aave
aaveFeed
algo
algoFeed
doge
dogeFeed
appManagerAddress
Functions
constructor
getTokenPrice
that the price is for the whole token and not of its atomic unit. This means that if an ERC20 with 18 decimals has a price of 2 dollars, then its atomic unit would be 2/10^18 USD. 999_999_999_999_999_999 = 0xDE0B6B3A763FFFF, 1_000_000_000_000_000_000 = DE0B6B3A7640000
Gets the price of a Token. It will return the Token’s specific price. This function is left here to preserve the function signature
Parameters
Name | Type | Description |
---|---|---|
tokenContract | address | is the address of the Token contract |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | price of the Token in weis of dollars. 10^18 => $ 1.00 USD |
getChainlinkDOGEtoUSDFeedPrice
Gets the Chainlink price feed for DOGE in USD. This is an example that works for any decimal denomination.
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | price The current price in USD for this token according to Chainlink aggregation |
getChainlinkAAVEtoUSDFeedPrice
This price feed is actually 8 decimals so it must be converted to 18.
Gets the Chainlink price feed for AAVE in USD.
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | price The current price in USD for this token according to Chainlink aggregation |
getChainlinkALGOtoUSDFeedPrice
This price feed is actually 8 decimals so it must be converted to 18.
Gets the Chainlink price feed for AAVE in USD.
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | price The current price in USD for this token according to Chainlink aggregation |
setAAVEAddress
This function allows appAdminstrators to set the token address
setAAVEFeedAddress
This function allows appAdminstrators to set the Chainlink price feed address
setALGOAddress
This function allows appAdminstrators to set the token address
setALGOFeedAddress
This function allows appAdminstrators to set the Chainlink price feed address
setDOGEAddress
This function allows appAdminstrators to set the token address
setDOGEFeedAddress
This function allows appAdminstrators to set the Chainlink price feed address