SimpleRouter
SimpleRouter
SimpleRouter
instances pull (push) liquidity directly from (to) the reserve
Maker contracts using this router must make sure that the reserve approves the router for all asset that will be pulled (outbound tokens) Thus a maker contract using a vault that is not an EOA must make sure this vault has approval capacities.
pull
function __pull__(contract IERC20 token, address reserve, address maker, uint256 amount, bool strict) internal virtual returns (uint256 pulled)
transfers an amount of tokens from the reserve to the maker.
requires approval from reserve
for this
to transfer token
.
Parameters
Name | Type | Description |
---|---|---|
token | contract IERC20 | Token to be transferred |
reserve | address | The address of the reserve, where the tokens will be transferred from |
maker | address | Address of the maker, where the tokens will be transferred to |
amount | uint256 | The amount of tokens to be transferred |
strict | bool | wether the caller maker contract wishes to pull at most amount . |
Return Values
Name | Type | Description |
---|---|---|
pulled | uint256 | The amount pulled if successful (will be equal to amount ); otherwise, 0. |
push
function __push__(contract IERC20 token, address reserve, address maker, uint256 amount) internal virtual returns (uint256)
router-dependent implementation of the push
function
transfers an amount of tokens from the maker to the reserve.
requires approval from maker
for this
to transfer token
.
will revert if transfer fails
Parameters
Name | Type | Description |
---|---|---|
token | contract IERC20 | Token to be transferred |
reserve | address | The address of the reserve, where the tokens will be transferred to |
maker | address | Address of the maker, where the tokens will be transferred from |
amount | uint256 | The amount of tokens to be transferred |
reserveBalance
function reserveBalance(contract IERC20 token, address reserve) external view returns (uint256)
returns the amount of token
s that can be made available for pulling by the maker contract
when this router is pulling from a lender, this must return the amount of asset that can be withdrawn from reserve
Parameters
Name | Type | Description |
---|---|---|
token | contract IERC20 | is the asset one wishes to know the balance of |
reserve | address | is the address identifying the location of the assets |
checkList
function __checkList__(contract IERC20 token, address reserve) internal view virtual
router-dependent implementation of the checkList
function
verifies all required approval involving this
router (either as a spender or owner)
checkList
returns normally if all needed approval are strictly positive. It reverts otherwise with a reason.
Parameters
Name | Type | Description |
---|---|---|
token | contract IERC20 | is the asset whose approval must be checked |
reserve | address | the reserve that requires asset pulling/pushing |