Pricing Contracts
Purpose
The purpose of the pricing contracts is to serve as token-price data sources for ecosystem applications. The token pricers can be found in 2 different categories:
Developers may choose to adapt their preferred third-party solution for token pricing:
Configured pricing modules are required for the following rules:
- Account Max Value by Risk.
- Account Max Value by Access Level.
- Account Max Transaction Value by Risk Score.
Configuration
To set up the pricer contracts:
-
Make sure you have deployed your ERC20 and your ERC721 pricer contracts, or that your third party solutions are ready to communicate with your application.
-
Connect the pricer-contract set to your appManager. For this, only an account with the role of ruleAdministrator will be able to call the following functions in the appManager Handler:
Pass the addresses for your pricer contracts respectively, and you’re done!
ERC20 Example
- Cast command example to set the ERC20 pricer contract:
- Cast command example to set the ERC721 pricer contract:
This set of contracts can be reset at any time by an ruleAdministrator. Simply follow the same steps mentioned above with the new addresses.
Price Format
- Price is in wei of US Dollars: 1 dollar is represented by 1 _ 10^18, and 1 cent is represented 1 _ 10^16 in these contracts. This is done to have precision over the price, and to account for the possibility of tokens with extremely low prices.
- The price is given for a whole token:
- For Fungible Tokens: just like regular market data outlets, the price will be given for a whole token without decimals. e.g 1 ETH.
- For Non-Fungible-Tokens: even in the case of a fractionalized NFT, the price is still given for the whole token and not for its fractions.
Examples:
ERC20s
Let’s say we have the ERC20 called Frankenstein which has 18 decimals (1 Frankenstein = 1 * 10^18 wei of a Frankenstein). Let’s imagine that each Frankenstein is worth exactly $0.55 US Dollars (55 ¢). In this case, the price for the token will be 55 * 10^16.
ERC721s
Let’s say we have the NFT collection called FrankensteinNFT. Let’s imagine that the FrankensteinNFT with Id 222 is worth exactly $500.00 US Dollars. In this case, the price for the token will be 500 * 10^18.