We represent the protocol smart contract functionality using the OpenAPI spec, where writes map to
POST
and reads to GET
. For simplicity, we sometimes refer to the user positions as “tokens”, even though they are not represented as tokens/ERC20s.
Functions
The exchanger contract implements the following functions:- Callable by anyone
exchangeToCredits(uint256 amount)
: called by the Based app end-user to exchange the supported stablecoin to Based Credits in a 1:1 ratioexchangeFromCredits(uint256 amount, address recipient)
: called by the Based app end-user as part of the withdrawal process from the app to exchange Based Credits to the supported stablecoin and send them to the intended withdrawal address
- Callable by ADMIN role
sweep(address token, uint256 amount)
: moves the given amount of the given ERC-20 token to the treasury address (can be used to both manage risk (the supported stablecoin/Based Credits in the smart contract) and to withdraw any tokens mistakenly sent to the contract)pause()
: pauses all day-to-day (non-admin and non-treasury) functionsunpause()
: unpauses (undoes thepause()
)
- Callable TREASURY role only
changeTreasury(address newTreasury)
: changes the treasury and “super-admin” address, revoking all roles of the old treasury and adding the DEFAULT_ADMIN_ROLE and ADMIN_ROLE to the newTreasuryaddAdmin(address newAdmin)
: adds a new adminremoveAdmin(address adminToRemove)
: removes an existing admin
transfer()
or transferFrom()
instruction, depending on the counterparty wallet type.
Roles
DEFAULT_ADMIN_ROLE
: (“treasury”) the “superadmin” of the contract and the recipient of sweeped funds. This can be only one address at a time.ADMIN_ROLE
: (“admin”) day-to-day admin of the contract that can be invoked quickly if needed.
Events
Events are emitted for any write function.pause()
and unpause()
event emissions are inherited from OZ’s Pausable.