The X7RDiscountAuthority contract has three interfaces defined for interacting with three different types of NFTs: IERC721, ILiquidityMaxiNFT, and IMagisterNFT. The contract also has three variables (ecoMaxiNFT, liqMaxiNFT, and magisterNFT) that are used to store the addresses of contracts that implement these interfaces.
The X7RDiscountAuthority contract has three functions for setting the addresses of these NFT contracts: setEcosystemMaxiNFT, setLiquidityMaxiNFT, and setMagisterNFT. These functions can only be called by the contract's owner, and they emit events to record the change in the NFT contract address.
Finally, the X7RDiscountAuthority contract has a discountRatio function that returns the discount ratio for a given user (specified by the swapper parameter). The function checks the user's balance of each of the three NFT types and applies a discount based on the balances. If the user has a balance of liqMaxiNFT or magisterNFT NFTs, a 25% discount is applied. If the user has a balance of ecoMaxiNFT NFTs, a 10% discount is applied. If the user has no balance of any of these NFTs, no discount is applied.
function setEcosystemMaxiNFT(address tokenAddress) external onlyOwner {
require(address(ecoMaxiNFT) != tokenAddress);
address oldTokenAddress = address(ecoMaxiNFT);
ecoMaxiNFT = IERC721(tokenAddress);
emit EcosystemMaxiNFTSet(oldTokenAddress, tokenAddress);
}
The setEcosystemMaxiNFT function is used to set the address of the contract that implements the IERC721 interface for the ecoMaxiNFT NFTs. The function has one input parameter, tokenAddress, which is the address of the contract to be set.
The function first checks that the tokenAddress is not the same as the current contract address stored in ecoMaxiNFT. This is done using the require function, which will revert the transaction and revert any changes made to the contract state if the condition is not met.
If the tokenAddress is different from the current contract address, the function sets the ecoMaxiNFT variable to the new contract address using the IERC721 interface. It also emits an event, , to record the change in the contract address.
