Native1155

Git Source

Inherits: INative1155, MultiPool1155, Implementation, Initializable

Author: 0xvv @ Kiln

This contract allows users to stake in any of the vPools with any amount of ETH and track their position

Users are given non transferable shares to track their stake, shares of different pools are not equivalent

Users can interact with the contract using the ERC-1155 style interface, but the contract is not ERC-1155 compliant as it does not support transfers

State Variables

$name

The name of the shares.

Slot: keccak256(bytes("native1155.1.name")) - 1

types.String internal constant $name = types.String.wrap(0xca1397ca23f10c097888f2db1683abfb67f39fdf3f1ac323db83da702196e217);

$symbol

The symbol of the shares.

Slot: keccak256(bytes("native1155.1.symbol")) - 1

types.String internal constant $symbol = types.String.wrap(0x1aafe6fc63278e1251be29ee930745925b8279eab16432ea692c6c0854d3bcf0);

$uriPrefix

The base uri.

Slot: keccak256(bytes("native1155.1.uriPrefix")) - 1

types.String internal constant $uriPrefix = types.String.wrap(0xbfd652c9b61f9a572f0a620571346b2aa3d695d12a83f178e91284c11b7d753c);

Functions

initialize

Initializes the contract with the given parameters.

function initialize(Native1155Configuration calldata args) external init(0);

Parameters

NameTypeDescription
argsNative1155ConfigurationThe arguments to initialize the contract with.

uri

Returns the URI for token type id.

function uri(uint256 id) external view returns (string memory);

Parameters

NameTypeDescription
iduint256The id of the token.

Returns

NameTypeDescription
<none>stringThe URI of the token.

setPrefixUri

Sets the base URI for all tokens.

Ony callable by the admin.

function setPrefixUri(string calldata uri_) external onlyAdmin;

Parameters

NameTypeDescription
uri_string

name

Returns the name of the token.

function name() external view returns (string memory);

Returns

NameTypeDescription
<none>stringThe name of the token.

symbol

Returns the symbol of the token.

function symbol() external view returns (string memory);

Returns

NameTypeDescription
<none>stringThe symbol of the token.

balanceOf

Returns the amount of staking shares of a given pool for an account.

function balanceOf(address account, uint256 id) public view returns (uint256);

Parameters

NameTypeDescription
accountaddressThe address of the account.
iduint256The id of the pool.

Returns

NameTypeDescription
<none>uint256amount of staking shares.

balanceOfBatch

Batch version of balanceOf().

function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory);

Parameters

NameTypeDescription
accountsaddress[]The addresses of the accounts.
idsuint256[]The ids of the pool.

Returns

NameTypeDescription
<none>uint256[]list of amounts of staking shares.

balanceOfUnderlying

Returns the amount of pool shares for an account in a given pool.

function balanceOfUnderlying(address account, uint256 id) public view returns (uint256);

Parameters

NameTypeDescription
accountaddressThe address of the account.
iduint256

Returns

NameTypeDescription
<none>uint256amount of pool shares.

balanceOfUnderlyingBatch

Batch version of balanceOfUnderlying().

function balanceOfUnderlyingBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory);

Parameters

NameTypeDescription
accountsaddress[]The addresses of the accounts.
idsuint256[]The ids of the pool.

Returns

NameTypeDescription
<none>uint256[]list of amounts of pool shares.

stake

Stake the given amounts of ETH in the given pools.

Sum of amounts must be equal to msg.value.

function stake(uint256[] calldata amounts, uint256[] calldata ids) public payable returns (bool);

Parameters

NameTypeDescription
amountsuint256[]List of amount for each pool
idsuint256[]List of pool ids

Returns

NameTypeDescription
<none>boolWhether the staking was successful.

_setUriPrefix

Internal utility to set the URI prefix to use

function _setUriPrefix(string calldata newUriPrefix) internal;

Parameters

NameTypeDescription
newUriPrefixstringThe new uri prefix to set