Bank Solidity
IBank
Glossaries:
manager
: a provider of app/service such as Pegaxy game.depositor
: an entity that belongs to provider, such as a player of Pegaxy game.
Deposit flow:
- User (
depositor
) deposits to Bank contract which then recored by provider (manager
).
If user want to withdraw:
- User sends withdraw request to provider.
- Provider verifies the request off-chain.
- If approved, provider returns a signed withdraw request.
- User sends that signed request to Bank contract.
Deposited
event Deposited(uint256 depositId, address token, uint256 tokenIdOrAmount, address owner, string reason, address manager)
Withdrawn
event Withdrawn(address token, uint256 tokenIdOrAmount, address receiver, string txid, address manager, bool minted)
PayThenWithdrawn
event PayThenWithdrawn(address receiver, address erc721, uint256 tokenId, address erc20, uint256 amount, uint256 fee, address taker, string txid)
PayThenWithdrawRequest
struct PayThenWithdrawRequest {
address receiver;
address erc721;
uint256 tokenId;
address erc20;
uint256 amount;
uint256 fee;
address taker;
string txid;
uint256 expiry;
}
WithdrawERC721Request
struct WithdrawERC721Request {
address receiver;
address erc721;
uint256 tokenId;
bool mint;
string txid;
uint256 expiry;
}
WithdrawERC20Request
struct WithdrawERC20Request {
address receiver;
address erc20;
uint256 amount;
string txid;
uint256 expiry;
}
WithdrawERC721
function withdrawERC721(struct IBank.WithdrawERC721Request request, uint8 v, bytes32 r, bytes32 s) external returns (bool)
WithdrawERC20
function withdrawERC20(struct IBank.WithdrawERC20Request request, uint8 v, bytes32 r, bytes32 s) external returns (bool)
ManagerWithdrawERC20
function managerWithdrawERC20(struct IBank.WithdrawERC20Request request, uint8 v, bytes32 r, bytes32 s) external returns (bool)
DepositERC721
function depositERC721(address erc721, uint256 tokenId, address depositer, address manager, string reason) external returns (uint256 depositId)
Used to deposit ERC721 to MiraiBank. The depositer
can be diffrent from msg.sender
.
The manager
is address of app which can update balance of depositer
later.
Parameters:
Name | Type | Description |
---|---|---|
erc721 | address | Address of token contract |
tokenId | uint256 | |
depositer | address | |
manager | address | |
reason | string | Memo |
Return values:
Name | Type | Description |
---|---|---|
depositId | uint256 | ID of deposit |
DepositMoreERC721
function depositMoreERC721(address erc721, uint256 tokenId, address depositer, address manager, string reason) external returns (uint256 depositId)
If depositer
approved for MiraiBank
before, MiraiBank
can call this function to deposit more for depositer
.
Only owner of MiraiBank
can call this function.
Parameters:
Name | Type | Description |
---|---|---|
erc721 | address | Address of token contract |
tokenId | uint256 | |
depositer | address | |
manager | address | |
reason | string | Memo |
Return values:
Name | Type | Description |
---|---|---|
depositId | uint256 | ID of deposit |
DepositERC721Request
struct DepositERC721Request {
address erc721;
uint256 tokenId;
string reason;
uint256 nonce;
uint256 expiry;
}
DepositERC721BySig
function depositERC721BySig(struct IBank.DepositERC721Request request, address manager, uint8 v, bytes32 r, bytes32 s) external returns (uint256)
DepositERC20
function depositERC20(address erc20, uint256 amount, address depositer, address manager, string reason) external payable returns (uint256 depositId)
Used to deposit ERC20 to MiraiBank. The depositer
can be diffrent from msg.sender
.
The manager
is address of app which can update balance of depositer
later.
Parameters:
Name | Type | Description |
---|---|---|
erc20 | address | Address of token, use null adddess to deposit native coin |
amount | uint256 | |
depositer | address | |
manager | address | |
reason | string | Memo |
Return values:
Name | Type | Description |
---|---|---|
depositId | uint256 | ID of deposit |
DepositMoreERC20
function depositMoreERC20(address erc20, uint256 amount, address depositer, address manager, string reason) external returns (uint256 depositId)
If depositer
approved for MiraiBank
before, MiraiBank
can call this function to deposit more for depositer
.
Only owner of MiraiBank
can call this function.
Parameters:
Name | Type | Description |
---|---|---|
erc20 | address | Address of token |
amount | uint256 | |
depositer | address | |
manager | address | |
reason | string | Memo |
Return values:
Name | Type | Description |
---|---|---|
depositId | uint256 | ID of deposit |
DepositERC20Request
struct DepositERC20Request {
address erc20;
uint256 amount;
string reason;
uint256 nonce;
uint256 expiry;
}
Deposit
struct Deposit {
address token;
uint256 amountOrTokenId;
address depositer;
address manager;
}
DepositERC20BySig
function depositERC20BySig(struct IBank.DepositERC20Request request, address manager, uint8 v, bytes32 r, bytes32 s) external returns (uint256)
PayThenWithdrawERC721
function payThenWithdrawERC721(struct IBank.PayThenWithdrawRequest request, uint8 v, bytes32 r, bytes32 s) external payable returns (bool)