The FiatGateway contract allows buying NFTs from an external fiat payment.
This contract connects to the Freeport contract. It must hold a balance of CERE recognized by Freeport.
This contract uses the SimpleExchange API to buy NFTs.
This contract is operational only when the exchange rate is set to a non-zero value.
Set the exchange rate between fiat (USD) and Freeport currency (CERE).
The rate is given as number of CERE Units (with 10 decimals) per USD cent (1 penny).
Only the rate service with the EXCHANGE_RATE_ORACLE role can change the rate.
Get the current exchange rate in CERE Units (with 10 decimals) per USD cent (1 penny).
Withdraw all CERE from this contract.
Only accounts with DEFAULT_ADMIN_ROLE can withdraw.
Obtain CERE based on a fiat payment.
The amount of fiat is recorded, and exchanged for an amount of CERE.
Only the gateway with PAYMENT_SERVICE role can report successful payments.
buyNftFromUsd(uint256 penniesReceived, address buyer, address seller, uint256 nftId, uint256 expectedPriceOrZero, uint256 nonce)
(public)
Obtain CERE and buy an NFT based on a fiat payment.
CERE tokens are obtained in the same way as buyCereFromUsd.
Then, the tokens are used to buy an NFT in the same transaction. The NFT must be available for sale from the seller in SimpleExchange.
Only the gateway with PAYMENT_SERVICE role can report successful payments.
The parameter expectedPriceOrZero can be used to validate the price that the buyer expects to pay. This prevents a race condition with makeOffer or setExchangeRate. Pass 0 to disable this validation and accept any current price.
Guarantee that a version of Solidity with safe math is used.
An event emitted when the exchange rate was set to a new value.
The rate is given as CERE Units (with 10 decimals) per USD cent (1 penny).