Address Provider
Different modules of the fMint protocol are connected through the Address Provider contract. Each protocol part is registered on the provider and other modules obtain the contract address here.
You need the Address Provider ABI and address to be able to access the contract, make changes of the references and obtain addresses of known modules.
// setup environment
var adrProviderAbi = JSON.parse('[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newAddress","type":"address"}],"name":"CollateralPoolChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newAddress","type":"address"}],"name":"DebtPoolChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newAddress","type":"address"}],"name":"MinterChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newAddress","type":"address"}],"name":"PriceOracleChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newAddress","type":"address"}],"name":"RewardDistributionChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newAddress","type":"address"}],"name":"RewardTokenChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newAddress","type":"address"}],"name":"TokenRegistryChanged","type":"event"},{"constant":true,"inputs":[],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"initialize","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"_id","type":"bytes32"}],"name":"getAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getPriceOracleProxy","outputs":[{"internalType":"contract IPriceOracleProxy","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_addr","type":"address"}],"name":"setPriceOracleProxy","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getTokenRegistry","outputs":[{"internalType":"contract IFantomMintTokenRegistry","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_addr","type":"address"}],"name":"setTokenRegistry","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getRewardDistribution","outputs":[{"internalType":"contract IFantomMintRewardManager","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_addr","type":"address"}],"name":"setRewardDistribution","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getRewardToken","outputs":[{"internalType":"contract ERC20","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_addr","type":"address"}],"name":"setRewardToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getFantomMint","outputs":[{"internalType":"contract IFantomMintBalanceGuard","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_addr","type":"address"}],"name":"setFantomMint","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getCollateralPool","outputs":[{"internalType":"contract IFantomDeFiTokenStorage","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_addr","type":"address"}],"name":"setCollateralPool","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getDebtPool","outputs":[{"internalType":"contract IFantomDeFiTokenStorage","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_addr","type":"address"}],"name":"setDebtPool","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]');
var adrProviderAddress = "0xcb20a1a22976764b882c2f03f0c8523f3df54b10";
// instantiate the contract
var adrProvider = web3.ftm.contract(adrProviderAbi).at(adrProviderAddress);
You can use a general
getAddress
call to get an address of known fMint protocol module, or you can use a single-purpose call for each fMint module. Please consider the best way of using the provider based on your specific use case. The code below demonstrates both ways of doing so.// use general call with identifier
> adrProvider.getAddress.call("price_oracle_proxy");
"0xb4120a75d22d800a61bdfad65be3786a20db10b7"
// use a module specific call
> adrProvider.getRewardToken.call();
"0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83"
The Address Provider registers the following modules. An internal identifier of each module is listed.
- Core fMint Contract
fantom_mint
- Collateral Pool Contract
collateral_pool
- Debt Pool Contract
debt_pool
- Price Oracle Proxy Contract
price_oracle_proxy
- Reward Distribution Contract
reward_distribution
- Reward ERC20 Token Contract
erc20_reward_token
- Token Registry Contract
token_registry
Please check the AddressProvider contract source code for all the details about modules and their references.
Address of any module of the fMint protocol can be changed through the Address Provider contract. To change a module address please use a module specific update function.
Please make sure to use maximum caution when changing fMint module address. All the fMint modules may be affected by the change. Also, changing the Collateral or Debt pool may directly affect users' positions and their funds invested in the protocol.
// update module address
adrProvider.setDebtPool("0xb4120a75d22d800a61bdfad65be3786a20db10b7");
Please consult the AddressProvider source code for the ful list of available update functions and their meaning.
Last modified 2yr ago