> For the complete documentation index, see [llms.txt](https://docs.kpk.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kpk.io/funds/infrastructure/architecture/onchain-accounting/balance-adapters/aave-safety-module.md).

# Aave Safety Module

Reports an account's stake in the legacy Aave V3 Safety Module across a hardcoded set of stake tokens.

Reports an account's stake in the legacy Aave V3 Safety Module across a hardcoded set of stake tokens. Per stake token it reports locked and unlocked staking legs plus a rewards leg. Aave publishes no onchain registry, so the addresses are compile-time constants.

* **Type:** Plain adapter
* **protocolSubId:** `keccak256("aave-v3-safety-module")` (brand `aave`, ecosystem `aave-v3`)
* **Source:** `AaveV3SafetyModuleBalanceAdapter.sol`

{% hint style="info" %}
Mainnet only. Adding a stake token is a source-code change (new constant and record), not an admin transaction.
{% endhint %}

## Hardcoded stake tokens

| Stake token                             | Address                                      | Staked asset                                          | Reward |
| --------------------------------------- | -------------------------------------------- | ----------------------------------------------------- | ------ |
| stkAAVE                                 | `0x4da27a545c0c5B758a6BA100e3a049001de870f5` | AAVE                                                  | AAVE   |
| stkABPT (Balancer V1 BPT)               | `0xa1116930326D21fB917d5A27F1E9943A9595fb47` | ABPT `0x41A08648C3766F9F9d85598fF102a08f4ef84F84`     | AAVE   |
| stkABPTv2 (Balancer V2 AAVE/wstETH BPT) | `0x9eDA81C21C273a82BE9Bbc19B6A6182212068101` | ABPT\_V2 `0x3de27EFa2F1AA663Ae5D458857e731c129069F29` | AAVE   |
| stkGHO                                  | `0x1a88Df1cFe15Af22B3c4c783D4e6F7F9e0C1885d` | GHO `0x40D16FC0246aD3160Ccc09B8D0D3A2cD28aE6C2f`      | AAVE   |

AAVE = `0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9`, the reward token for every entry.

## Positions returned

Up to three legs per stake token whose staked and reward assets are registered on NAVCalculator:

| Leg              | PositionKind | isDebt  | isLocked | Description                                                                                                                               |
| ---------------- | ------------ | ------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| Locked staking   | `Staking`    | `false` | `true`   | Not withdrawable now: active stake, plus any cooldown still cooling or past its claim window. `amount = previewRedeem(lockedShares)`      |
| Unlocked staking | `Staking`    | `false` | `false`  | Withdrawable now. `amount = previewRedeem(unlockedShares)`. Present only when a cooldown has elapsed and is still inside `UNSTAKE_WINDOW` |
| Rewards          | `Rewards`    | `false` | `false`  | Accrued, unclaimed rewards. `amount = getTotalRewardsBalance(account)`, in AAVE                                                           |

Zero-amount legs are skipped.

## Balance calculation

<figure><img src="https://1699303810-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUsQM4bzcmOPSgkWddkeN%2Fuploads%2FdE3wcIm23UMFS8RkIGUE%2Fadapter-aave-safety-module.png?alt=media&amp;token=b327c831-fa7e-4c92-9a88-3e4bf3e38f70" alt="Flowchart of the Aave Safety Module balance adapter: read calls derive position legs into PositionBalance entries."><figcaption><p>Aave Safety Module adapter: how the underlying balances reported to the NAV Calculator are derived.</p></figcaption></figure>

The staking balance is split by the account's cooldown:

```
(timestamp, amount) = stakeToken.stakersCooldowns(account)
cooldownSeconds     = stakeToken.getCooldownSeconds()
window              = stakeToken.UNSTAKE_WINDOW()

inWindow = now >= timestamp + cooldownSeconds
        && now <= timestamp + cooldownSeconds + window   // cooldown elapsed, still claimable

unlockedShares = inWindow ? <shares the cooldown covers> : 0
lockedShares   = totalShares - unlockedShares

lockedAmount   = stakeToken.previewRedeem(lockedShares)     // isLocked = true
unlockedAmount = stakeToken.previewRedeem(unlockedShares)   // isLocked = false, only if inWindow
rewards        = stakeToken.getTotalRewardsBalance(account) // reward-token (AAVE) units, isLocked = false
```

If the cooldown reads fail or there is no active cooldown, the whole balance is locked and no unlocked leg is emitted.

## Identity

* **positionId:** `abi.encode(address stakeToken)`, the same for all three legs of a stake token
* **positionKind:** `Staking` · `Rewards`

The two staking legs share `positionId` and `positionKind`, and `isLocked` is not part of the reconciliation key, so they reconcile into one coordinate and sum to the total staked; read `isLocked` per leg for the breakdown. The rewards leg is told apart by `positionKind` (`Rewards`). `positionLabels(positionId)` returns `["Safety Module"]`, shown only on the verbose reads.

## Constructor

```solidity
constructor(address navCalculator)
```

| Parameter       | Description                                                                                     |
| --------------- | ----------------------------------------------------------------------------------------------- |
| `navCalculator` | NAVCalculator address (non-zero, must be a contract); used to resolve registered-asset metadata |

Stake-token addresses are not passed; they are in bytecode.

## Registration

Registered as a plain adapter with `addBalanceAdapters([adapter])` (MANAGER-gated); removed with `removeBalanceAdapters`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.kpk.io/funds/infrastructure/architecture/onchain-accounting/balance-adapters/aave-safety-module.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
