WrappedPinakion

Git Source

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

NameTypeDescription
_namestringfor the wrapped PNK on the home chain.
_symbolstringfor wrapped PNK ticker on the home chain.
_xPinakionIERC677the home PNK contract which is already bridged to the foreign PNK contract.
_tokenBridgeITokenBridgethe TokenBridge contract.

changeController

function changeController(address _controller) external onlyController;

Parameters

NameTypeDescription
_controlleraddressThe 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

NameTypeDescription
_amountuint256The 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

NameTypeDescription
_tokenaddressThe token address the _amount belongs to.
_amountuint256The amount of wrapped PNK to mint.
_databytesCalldata 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

NameTypeDescription
_amountuint256The 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

NameTypeDescription
_amountuint256The amount of PNK to withdraw.
_receiveraddressThe 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

NameTypeDescription
_recipientaddressThe entity receiving the funds.
_amountuint256The amount to tranfer in base units.

Returns

NameTypeDescription
<none>boolTrue 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

NameTypeDescription
_senderaddressThe entity to take the funds from.
_recipientaddressThe entity receiving the funds.
_amountuint256The amount to tranfer in base units.

Returns

NameTypeDescription
<none>boolTrue on success.

approve

Approves _spender to spend _amount.

function approve(address _spender, uint256 _amount) public returns (bool);

Parameters

NameTypeDescription
_spenderaddressThe entity allowed to spend funds.
_amountuint256The amount of base units the entity will be allowed to spend.

Returns

NameTypeDescription
<none>boolTrue on success.

increaseAllowance

Increases the _spender allowance by _addedValue.

function increaseAllowance(address _spender, uint256 _addedValue) public returns (bool);

Parameters

NameTypeDescription
_spenderaddressThe entity allowed to spend funds.
_addedValueuint256The amount of extra base units the entity will be allowed to spend.

Returns

NameTypeDescription
<none>boolTrue on success.

decreaseAllowance

Decreases the _spender allowance by _subtractedValue.

function decreaseAllowance(address _spender, uint256 _subtractedValue) public returns (bool);

Parameters

NameTypeDescription
_spenderaddressThe entity whose spending allocation will be reduced.
_subtractedValueuint256The reduction of spending allocation in base units.

Returns

NameTypeDescription
<none>boolTrue 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

NameTypeDescription
_recipientaddressThe address which will receive the minted tokens.
_amountuint256The amount that will be created.

_burn

Destroys _amount tokens from the caller. Cannot burn locked tokens.

function _burn(uint256 _amount) internal;

Parameters

NameTypeDescription
_amountuint256The 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

NameTypeDescription
_addraddressThe address being queried.

Returns

NameTypeDescription
<none>boolTrue if _addr is a contract.

balanceOf

Gets the balance of the specified address.

function balanceOf(address _owner) public view returns (uint256);

Parameters

NameTypeDescription
_owneraddressThe address to query the balance of.

Returns

NameTypeDescription
<none>uint256uint256 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);