# Staking

## Stake any amount of ETH

{% hint style="info" %}
*Used to stake any amount of ETH into the pool.*
{% endhint %}

This can only be executed by calling a smart contract method:

```bash
cast send $INTEGRATION_CONTRACT_ADDRESS "stake()" --value $AMOUNT_TO_STAKE_IN_ETH
```

***

## Get the amount of shares from integration contract by wallet

{% hint style="info" %}
*Used to find the amount of shares for a given wallet from the integration contract*
{% endhint %}

**Using the smart contract view methods**

```bash
cast call $INTEGRATION_CONTRACT_ADDRESS "balanceOf(address)(uint256)" $USER_ADDRESS
```

***

## Get the current value of a user's staked position

{% hint style="info" %}
Allows you to obtain the value (in ETH) of the users current staked position
{% endhint %}

For example, consider the scenario where a user staked 12 ETH several months ago. Every time they visit your app, you want to showcase the current value of the staked position accounting for the accrued value from staking rewards over time.&#x20;

You can simply query the smart contract with the users wallet.

**Using the smart contract view methods**

```bash
cast call $INTEGRATION_CONTRACT_ADDRESS "balanceOfUnderlying(address)(uint256)" $USER_ADDRESS
```

**Using TheGraph queries**

<details>

<summary>Query</summary>

```graphql
{
  erc20(id:"INTEGRATION_CONTRACT_ADDRESS") {
    totalSupply
    totalUnderlyingSupply
    balances(where:{staker:"USER_ADDRESS"}) {
    	sharesBalance
    }
  }
}
```

**Example query**

```graphql
{
  "data": {
    "erc20": {
      "totalSupply": "23608675969602594618589",
      "totalUnderlyingSupply": "23752224529858293552006",
      "balances": [
        {
          "sharesBalance": "499892147748515755"
        }
      ]
    }
  }
}
```

</details>

<details>

<summary>Results</summary>

```graphql
{
  "data": {
    "erc20": {
      "totalSupply": "23608675969602594618589",
      "totalUnderlyingSupply": "23752224529858293552006",
      "balances": [
        {
          "sharesBalance": "499892147748515755"
        }
      ]
    }
  }
}
```

</details>

<details>

<summary>Calculate value</summary>

* underlyingBalanceValue = ((sharesBalance  \*  totalUnderlyingSupply) / totalSupply)

</details>

***

## Retrieving all the deposit actions of a user

TheGraph queries

{% tabs %}
{% tab title="Liquid20C, Liquid20A & Native20" %}

```graphql
{
  erc20(id:"INTEGRATION_CONTRACT_ADDRESS") {
    deposits(where:{staker:"USER_ADDRESS"},orderBy:createdAt,orderDirection:desc) {
      hash
      depositAmount
      mintedShares
    }
  }
}
```

```json
{
  "data": {
    "erc20": [
      {
        "deposits": [
          {
            "hash": "0xb644b754d59c3693fa12a8be796bbc31db2f922964b581603c5e020b5aebd591",
            "depositAmount": "10000000000",
            "mintedShares": "9981371152"
          },
          {
            "hash": "0xd2aa2b95f27f38e57a1cf4064110f1c5771252249b16fcf55c4d6aa74bc7340e",
            "depositAmount": "10000000000",
            "mintedShares": "9982062545"
          },
          {
            "hash": "0xf640ef3b91de25f76792debb41f2f26f0886a79f3fccb4fffff372487dac22fa",
            "depositAmount": "100000000000",
            "mintedShares": "99821696059"
          },
          {
            "hash": "0xaa212b98a0c44f57ebedc50337c24853739f07164a7681a1eb6b2fc1753e8f91",
            "depositAmount": "100000000000",
            "mintedShares": "99822049624"
          },
          {
            "hash": "0xad2ad5026fda650861ea6ab0e278e39150812fa74a623879cbb3263dd157b07c",
            "depositAmount": "100000000000",
            "mintedShares": "99822049624"
          },
          {
            "hash": "0x8a5f98769d52b05bd37ef66db8976981d67e50f7401269cf2ffd2801d583ddc1",
            "depositAmount": "100000000000",
            "mintedShares": "99822049623"
          }
        ]
      }
    ]
  }
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kiln.fi/v1/kiln-products/onchain/pooled-staking/how-to-integrate/staking-interactions/staking.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
