WrappedPinakion
Inherits: Initializable
State Variables
balances
mapping(address => uint256) private balances;
allowance
mapping(address => mapping(address => uint256)) public allowance;
totalSupply
Total supply of the token. Equals the total xPinakion deposit into the contract.
uint256 public totalSupply;
name
Name of the token.
string public name;
symbol
Symbol of the token.
string public symbol;
decimals
Number of decimals of the token.
uint8 public decimals;
controller
The token's controller.
address public controller;
xPinakion
Bridged PNK on xDai to be wrapped. This token is upgradeable.
IERC677 public xPinakion;
tokenBridge
xDai Token Bridge. The Token Bridge is upgradeable.
ITokenBridge public tokenBridge;
Functions
onlyController
Verifies that the sender has ability to modify controlled parameters.
modifier onlyController();
initialize
Initializer.
function initialize(string memory _name, string memory _symbol, IERC677 _xPinakion, ITokenBridge _tokenBridge)
public
initializer;
Parameters
Name | Type | Description |
---|---|---|
_name | string | for the wrapped PNK on the home chain. |
_symbol | string | for wrapped PNK ticker on the home chain. |
_xPinakion | IERC677 | the home PNK contract which is already bridged to the foreign PNK contract. |
_tokenBridge | ITokenBridge | the TokenBridge contract. |
changeController
function changeController(address _controller) external onlyController;
Parameters
Name | Type | Description |
---|---|---|
_controller | address | The new controller of the contract |
deposit
Converts bridged PNK (xPinakion) into wrapped PNK which can be staked in KlerosLiquid.
function deposit(uint256 _amount) external;
Parameters
Name | Type | Description |
---|---|---|
_amount | uint256 | The amount of wrapped pinakions to mint. |
onTokenBridged
IERC20 Receiver functionality.
Converts bridged PNK (xPinakion) into wrapped PNK which can be staked in KlerosLiquid.
If the tokenBridge is calling this function, then this contract has already received
the xPinakion tokens. Notice that the Home bridge calls onTokenBridge as a result of
someone invoking relayTokensAndCall()
on the Foreign bridge contract.
function onTokenBridged(address _token, uint256 _amount, bytes calldata _data) external;
Parameters
Name | Type | Description |
---|---|---|
_token | address | The token address the _amount belongs to. |
_amount | uint256 | The amount of wrapped PNK to mint. |
_data | bytes | Calldata containing the address of the recipient. Notice that the address has to be padded to the right 32 bytes. |
withdraw
Converts wrapped PNK back into bridged PNK (xPinakion).
function withdraw(uint256 _amount) external;
Parameters
Name | Type | Description |
---|---|---|
_amount | uint256 | The amount of bridged PNK to withdraw. |
withdrawAndConvertToPNK
Converts wrapped PNK back into PNK using the Token Bridge.
This function is not strictly needed, but it provides a good UX to users who want to get their Mainnet's PNK back. What normally takes 3 transactions, here is done in one go. Notice that the PNK have to be claimed on Mainnet's TokenBridge by the receiver.
function withdrawAndConvertToPNK(uint256 _amount, address _receiver) external;
Parameters
Name | Type | Description |
---|---|---|
_amount | uint256 | The amount of PNK to withdraw. |
_receiver | address | The address which will receive the PNK back in the foreign chain. |
transfer
Moves _amount
tokens from the caller's account to _recipient
.
function transfer(address _recipient, uint256 _amount) public returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_recipient | address | The entity receiving the funds. |
_amount | uint256 | The amount to tranfer in base units. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | True on success. |
transferFrom
Moves _amount
tokens from _sender
to _recipient
using the
allowance mechanism. _amount
is then deducted from the caller's allowance.
function transferFrom(address _sender, address _recipient, uint256 _amount) public returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_sender | address | The entity to take the funds from. |
_recipient | address | The entity receiving the funds. |
_amount | uint256 | The amount to tranfer in base units. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | True on success. |
approve
Approves _spender
to spend _amount
.
function approve(address _spender, uint256 _amount) public returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_spender | address | The entity allowed to spend funds. |
_amount | uint256 | The amount of base units the entity will be allowed to spend. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | True on success. |
increaseAllowance
Increases the _spender
allowance by _addedValue
.
function increaseAllowance(address _spender, uint256 _addedValue) public returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_spender | address | The entity allowed to spend funds. |
_addedValue | uint256 | The amount of extra base units the entity will be allowed to spend. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | True on success. |
decreaseAllowance
Decreases the _spender
allowance by _subtractedValue
.
function decreaseAllowance(address _spender, uint256 _subtractedValue) public returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_spender | address | The entity whose spending allocation will be reduced. |
_subtractedValue | uint256 | The reduction of spending allocation in base units. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | True on success. |
_mint
Internal function that mints an amount of the token and assigns it to an account. This encapsulates the modification of balances such that the proper events are emitted.
function _mint(address _recipient, uint256 _amount) internal;
Parameters
Name | Type | Description |
---|---|---|
_recipient | address | The address which will receive the minted tokens. |
_amount | uint256 | The amount that will be created. |
_burn
Destroys _amount
tokens from the caller. Cannot burn locked tokens.
function _burn(uint256 _amount) internal;
Parameters
Name | Type | Description |
---|---|---|
_amount | uint256 | The quantity of tokens to burn in base units. |
isContract
Internal function to determine if an address is a contract.
function isContract(address _addr) internal view returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_addr | address | The address being queried. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | True if _addr is a contract. |
balanceOf
Gets the balance of the specified address.
function balanceOf(address _owner) public view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_owner | address | The address to query the balance of. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | uint256 value representing the amount owned by the passed address. |
Events
Transfer
Emitted when value
tokens are moved from one account (from
) to another (to
).
Notice that value
may be zero.
event Transfer(address indexed from, address indexed to, uint256 value);
Approval
Emitted when the allowance of a spender
for an owner
is set by
a call to {approve}. value
is the new allowance.
event Approval(address indexed owner, address indexed spender, uint256 value);