# Contracts

## StZETA

StZETA serves as the fundamental contract, functioning as a liquid staking pool. This contract handles deposits and withdrawals, mints and burns liquid tokens, delegates funds to node operators, applies fees, and distributes rewards.The StZETA contract introduces stZETA, an ERC20 token, which indicates an account's proportion of the total ZETA tokens within the Zearn system. Being a non-rebasable token, the quantity of tokens in the user's wallet remains unchanged. However, its value may fluctuate over time as the volume of ZETA tokens within the protocol isn't static. It's worth noting that stZETA will be incorporated into a range of DeFi applications across ZetaChain.

## View Methods

### **symbol()**

Provides the token's symbol, typically a condensed form of its name.

```solidity
function symbol() returns (string)
```

### **decimals()**

Provides the number of decimals required to represent a token amount accurately.

```solidity
function decimals() returns (uint8)
```

### **totalSupply()**

Provides the total number of tokens currently in circulation.

```solidity
function totalSupply() returns (uint256)
```

### **balanceOf()**

Indicates the quantity of tokens held by the account

```solidity
function balanceOf(address _account) returns (uint256)
```

### **getTotalStakeAcrossAllValidators()**

Provides the aggregate of delegated ZETA across all validators.

```solidity
function getTotalStakeAcrossAllValidators() public view override returns (uint256)
```

**Returns:**

<table><thead><tr><th width="157">Name</th><th width="193">Type</th><th>Description</th></tr></thead><tbody><tr><td>total</td><td>uint256</td><td>The total delegated ZETA across all validators</td></tr></tbody></table>

### **getTotalPooledZETA()**

Provides the summed total of pooled ZETA

```solidity
function getTotalPooledMatic() public view override returns (uint256)
```

**Returns:**

<table><thead><tr><th width="158">Name</th><th width="191">Type</th><th>Description</th></tr></thead><tbody><tr><td>total</td><td>uint2560</td><td>The total pooled ZETA inside the protocol</td></tr></tbody></table>

**convertZETATostZETA()**

Provides the ZETA value for any given stZETA amount input into the function.

```solidity
function convertStMaticToMatic(uint256 _amountInZETA) public view
        override
        returns (
            uint256 amountInstZETA,
            uint256 totalstZETASupply,
            uint256 totalPooledZETA
        )
```

**Parameters:**

<table><thead><tr><th width="176.33333333333331">Name</th><th width="174">Type</th><th>Description</th></tr></thead><tbody><tr><td>_amountInZETA</td><td>uint256</td><td>Amount of ZETA to be converted to stZETA</td></tr></tbody></table>

**Returns**

| Name              | Type    | Description                       |
| ----------------- | ------- | --------------------------------- |
| amountInstZETA    | uint256 | Amount of stZETA after conversion |
| totalstZETASupply | uint256 | Total stZETA in the contract      |
| totalPooledZETA   | uint256 | Total ZETA in the staking pool    |

## Methods

### **transfer()**

Transfers amount tokens from the account of the initiator to the to account.

```solidity
function transfer(address to, uint256 amount) returns (bool)
```

{% hint style="info" %}
**NOTE**

Requirements:

* `to` should not be assigned the zero address.
* the caller should maintain a minimum balance of `amount`.
* the contract ought to be active, not paused.
  {% endhint %}

**Parameters**

<table><thead><tr><th width="191.33333333333331">Name</th><th width="201">Type</th><th>Description</th></tr></thead><tbody><tr><td>to</td><td>address</td><td>Address of tokens recipient</td></tr><tr><td>amount</td><td>uint256</td><td>Amount of tokens to transfer</td></tr></tbody></table>

**Returns:**

A boolean value that shows if the operation was successful.

### **allowance()**

This is the number of tokens that the spender is permitted to spend on behalf of owner using transferFrom. It's initially set to zero.

```solidity
function allowance(address owner, address spender) returns (uint256)
```

{% hint style="info" %}
**NOTE**

This value changes when `approve` or `transferFrom` is called.
{% endhint %}

**Parameters**

<table><thead><tr><th width="190.33333333333331">Name</th><th width="216">Type</th><th>Description</th></tr></thead><tbody><tr><td>owner</td><td>address</td><td>Address of owner</td></tr><tr><td>spender</td><td>address</td><td>Address of spender</td></tr></tbody></table>

### **approve()**

Establishes amount as the allocation for spender in relation to the caller's tokens.

```solidity
function approve(address spender, uint256 amount) returns (bool)
```

{% hint style="info" %}
**NOTE**

Requirements:

* `spender` cannot be the zero address.
* the contract must not be paused.
  {% endhint %}

**Parameters:**

<table><thead><tr><th width="182.33333333333331">Name</th><th width="221">Type</th><th>Description</th></tr></thead><tbody><tr><td>spender</td><td>address</td><td>Address of spender</td></tr><tr><td>amount</td><td>uint256</td><td>Amount of tokens</td></tr></tbody></table>

**Returns:**

A boolean value that shows if the operation was successful.

### transferFrom()

Transfers amount tokens from the from to the to via the allowance process. This amount is subsequently reduced from the caller's allowance.

```solidity
function transferFrom(address from, address to, uint256 amount) returns (bool)
```

{% hint style="info" %}
**NOTE**

Requirements:

* `from` and `to` cannot be the zero addresses.
* `from` must have a balance of at least `amount`.
* the caller must have allowance for `from`(sender)'s tokens of at least `amount`.
* the contract must not be paused.
  {% endhint %}

**Parameters:**

<table><thead><tr><th width="183.33333333333331">Name</th><th width="235">Type</th><th>Description</th></tr></thead><tbody><tr><td>from</td><td>address</td><td>Address of spender</td></tr><tr><td>to</td><td>address</td><td>Address of recipient</td></tr><tr><td>amount</td><td>uint256</td><td>Amount of tokens</td></tr></tbody></table>

**Returns:**

A boolean value that shows if the operation was successful.

### **increaseAllowance()**

Increments the allowance provided to the spender by the caller by an addedValue, in a precise and atomic manner.

```solidity
function increaseAllowance(address spender, uint256 addedValue) returns (bool)
```

{% hint style="info" %}
**NOTE**

Requirements:

* `spender` cannot be the the zero address.
* the contract must not be paused.
  {% endhint %}

**Parameters:**

<table><thead><tr><th width="187.33333333333331">Name</th><th width="238">Type</th><th>Description</th></tr></thead><tbody><tr><td>spender</td><td>address</td><td>Address of spender</td></tr><tr><td>addedValue</td><td>uint256</td><td>Amount of tokens to increase allowance</td></tr></tbody></table>

**Returns:**

A boolean value that shows if the operation was successful.

### **decreaseAllowance()**

Reduces the allowance given to spender by the caller by subtractedValue in a single operation.

```solidity
function decreaseAllowance(address spender, uint256 subtractedValue) returns (bool)
```

{% hint style="info" %}
**NOTE**

Requirements:

* `spender` cannot be the the zero address.
* `spender` must have allowance for the caller of at least `subtractedValue`.
* the contract must not be paused.
  {% endhint %}

**Parameters:**

<table><thead><tr><th width="191.33333333333331">Name</th><th width="208">Type</th><th>Description</th></tr></thead><tbody><tr><td>spender</td><td>address</td><td>Address of spender</td></tr><tr><td>subtractedValue</td><td>uint256</td><td>Amount of tokens to decrease allowance</td></tr></tbody></table>

**Returns:**

A boolean value that shows if the operation was successful.

### **submit()**

Transfer ZETA to the stZETA contract, which then generates stZETA for the sender.

```solidity
 function submit() external payable returns (uint256)
```

**Parameters:**

<table data-header-hidden><thead><tr><th width="187.33333333333331">Name</th><th width="207">Type</th><th>Description</th></tr></thead><tbody><tr><td></td><td>{ value: unit256 }</td><td>Amount to submit in ZETA</td></tr></tbody></table>

### calculatePendingBufferedTokens()

Calculate the total amount stored in all the NFTs owned by stZETA contract

```solidity
function calculatePendingBufferedTokens() 
        public
        view
        returns (uint256 pendingBufferedTokens)
```

**Returns:**

<table><thead><tr><th width="225.33333333333331">Name</th><th width="164">Type</th><th>Description</th></tr></thead><tbody><tr><td>pendingBufferedTokens</td><td>uint256</td><td>The total pending buffered tokens</td></tr></tbody></table>

## NodeOperatorsRegistry

Coming soon

###
