Skip to content

Chore/link upstream history#8

Open
CryptoBetmen wants to merge 101 commits intoaave:mainfrom
K613-Official:chore/link-upstream-history
Open

Chore/link upstream history#8
CryptoBetmen wants to merge 101 commits intoaave:mainfrom
K613-Official:chore/link-upstream-history

Conversation

@CryptoBetmen
Copy link
Copy Markdown

No description provided.

sakulstra and others added 30 commits June 2, 2025 08:59
Aave has historically used half-up / bankers rounding, but the ecosystem has aligned behind 4626, so it makes sense for aave to follow suit.
This(or a variant of this) was recommended by stermi for v3.4.
While we did not include it back then, we decided to include it now.
#mixbytes-5
Co-authored-by: Andrey <kyzia.ru@gmail.com>
fix: round in favor of the protocol
this was recommended by stermi on 3.4 and we preferred to move it to 3.5

v3.3 GHO VToken (`GhoVariableDebtToken`) storage layout:
```
╭-------------------------+--------------------------------------------------------------+------+--------+-------+--------------------------------------------------------------------------------------╮
| Name                    | Type                                                         | Slot | Offset | Bytes | Contract                                                                             |
+=======================================================================================================================================================================================================+
| lastInitializedRevision | uint256                                                      | 0    | 0      | 32    | src/contracts/facilitators/aave/tokens/GhoVariableDebtToken.sol:GhoVariableDebtToken |
|-------------------------+--------------------------------------------------------------+------+--------+-------+--------------------------------------------------------------------------------------|
| initializing            | bool                                                         | 1    | 0      | 1     | src/contracts/facilitators/aave/tokens/GhoVariableDebtToken.sol:GhoVariableDebtToken |
|-------------------------+--------------------------------------------------------------+------+--------+-------+--------------------------------------------------------------------------------------|
| ______gap               | uint256[50]                                                  | 2    | 0      | 1600  | src/contracts/facilitators/aave/tokens/GhoVariableDebtToken.sol:GhoVariableDebtToken |
|-------------------------+--------------------------------------------------------------+------+--------+-------+--------------------------------------------------------------------------------------|
| _nonces                 | mapping(address => uint256)                                  | 52   | 0      | 32    | src/contracts/facilitators/aave/tokens/GhoVariableDebtToken.sol:GhoVariableDebtToken |
|-------------------------+--------------------------------------------------------------+------+--------+-------+--------------------------------------------------------------------------------------|
| _domainSeparator        | bytes32                                                      | 53   | 0      | 32    | src/contracts/facilitators/aave/tokens/GhoVariableDebtToken.sol:GhoVariableDebtToken |
|-------------------------+--------------------------------------------------------------+------+--------+-------+--------------------------------------------------------------------------------------|
| _borrowAllowances       | mapping(address => mapping(address => uint256))              | 54   | 0      | 32    | src/contracts/facilitators/aave/tokens/GhoVariableDebtToken.sol:GhoVariableDebtToken |
|-------------------------+--------------------------------------------------------------+------+--------+-------+--------------------------------------------------------------------------------------|
| _underlyingAsset        | address                                                      | 55   | 0      | 20    | src/contracts/facilitators/aave/tokens/GhoVariableDebtToken.sol:GhoVariableDebtToken |
|-------------------------+--------------------------------------------------------------+------+--------+-------+--------------------------------------------------------------------------------------|
| _userState              | mapping(address => struct IncentivizedERC20.UserState)       | 56   | 0      | 32    | src/contracts/facilitators/aave/tokens/GhoVariableDebtToken.sol:GhoVariableDebtToken |
|-------------------------+--------------------------------------------------------------+------+--------+-------+--------------------------------------------------------------------------------------|
| _allowances             | mapping(address => mapping(address => uint256))              | 57   | 0      | 32    | src/contracts/facilitators/aave/tokens/GhoVariableDebtToken.sol:GhoVariableDebtToken |
|-------------------------+--------------------------------------------------------------+------+--------+-------+--------------------------------------------------------------------------------------|
| _totalSupply            | uint256                                                      | 58   | 0      | 32    | src/contracts/facilitators/aave/tokens/GhoVariableDebtToken.sol:GhoVariableDebtToken |
|-------------------------+--------------------------------------------------------------+------+--------+-------+--------------------------------------------------------------------------------------|
| _name                   | string                                                       | 59   | 0      | 32    | src/contracts/facilitators/aave/tokens/GhoVariableDebtToken.sol:GhoVariableDebtToken |
|-------------------------+--------------------------------------------------------------+------+--------+-------+--------------------------------------------------------------------------------------|
| _symbol                 | string                                                       | 60   | 0      | 32    | src/contracts/facilitators/aave/tokens/GhoVariableDebtToken.sol:GhoVariableDebtToken |
|-------------------------+--------------------------------------------------------------+------+--------+-------+--------------------------------------------------------------------------------------|
| _decimals               | uint8                                                        | 61   | 0      | 1     | src/contracts/facilitators/aave/tokens/GhoVariableDebtToken.sol:GhoVariableDebtToken |
|-------------------------+--------------------------------------------------------------+------+--------+-------+--------------------------------------------------------------------------------------|
| _incentivesController   | contract IAaveIncentivesController                           | 61   | 1      | 20    | src/contracts/facilitators/aave/tokens/GhoVariableDebtToken.sol:GhoVariableDebtToken |
|-------------------------+--------------------------------------------------------------+------+--------+-------+--------------------------------------------------------------------------------------|
| _ghoAToken              | address                                                      | 62   | 0      | 20    | src/contracts/facilitators/aave/tokens/GhoVariableDebtToken.sol:GhoVariableDebtToken |
|-------------------------+--------------------------------------------------------------+------+--------+-------+--------------------------------------------------------------------------------------|
| _discountToken          | contract IERC20                                              | 63   | 0      | 20    | src/contracts/facilitators/aave/tokens/GhoVariableDebtToken.sol:GhoVariableDebtToken |
|-------------------------+--------------------------------------------------------------+------+--------+-------+--------------------------------------------------------------------------------------|
| _discountRateStrategy   | contract IGhoDiscountRateStrategy                            | 64   | 0      | 20    | src/contracts/facilitators/aave/tokens/GhoVariableDebtToken.sol:GhoVariableDebtToken |
|-------------------------+--------------------------------------------------------------+------+--------+-------+--------------------------------------------------------------------------------------|
| _ghoUserState           | mapping(address => struct GhoVariableDebtToken.GhoUserState) | 65   | 0      | 32    | src/contracts/facilitators/aave/tokens/GhoVariableDebtToken.sol:GhoVariableDebtToken |
╰-------------------------+--------------------------------------------------------------+------+--------+-------+--------------------------------------------------------------------------------------╯
```

v3.4 payload upgrade GHO vToken (`VariableDebtTokenMainnetInstanceGHO`) storage layout:
```
╭-----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------------------------------------╮
| Name                              | Type                                                   | Slot | Offset | Bytes | Contract                                                                        |
+======================================================================================================================================================================================================+
| lastInitializedRevision           | uint256                                                | 0    | 0      | 32    | src/VariableDebtTokenMainnetInstanceGHO.sol:VariableDebtTokenMainnetInstanceGHO |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------------------------------------|
| initializing                      | bool                                                   | 1    | 0      | 1     | src/VariableDebtTokenMainnetInstanceGHO.sol:VariableDebtTokenMainnetInstanceGHO |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------------------------------------|
| ______gap                         | uint256[50]                                            | 2    | 0      | 1600  | src/VariableDebtTokenMainnetInstanceGHO.sol:VariableDebtTokenMainnetInstanceGHO |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------------------------------------|
| _nonces                           | mapping(address => uint256)                            | 52   | 0      | 32    | src/VariableDebtTokenMainnetInstanceGHO.sol:VariableDebtTokenMainnetInstanceGHO |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------------------------------------|
| _domainSeparator                  | bytes32                                                | 53   | 0      | 32    | src/VariableDebtTokenMainnetInstanceGHO.sol:VariableDebtTokenMainnetInstanceGHO |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------------------------------------|
| _borrowAllowances                 | mapping(address => mapping(address => uint256))        | 54   | 0      | 32    | src/VariableDebtTokenMainnetInstanceGHO.sol:VariableDebtTokenMainnetInstanceGHO |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------------------------------------|
| _underlyingAsset                  | address                                                | 55   | 0      | 20    | src/VariableDebtTokenMainnetInstanceGHO.sol:VariableDebtTokenMainnetInstanceGHO |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------------------------------------|
| _userState                        | mapping(address => struct IncentivizedERC20.UserState) | 56   | 0      | 32    | src/VariableDebtTokenMainnetInstanceGHO.sol:VariableDebtTokenMainnetInstanceGHO |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------------------------------------|
| _allowances                       | mapping(address => mapping(address => uint256))        | 57   | 0      | 32    | src/VariableDebtTokenMainnetInstanceGHO.sol:VariableDebtTokenMainnetInstanceGHO |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------------------------------------|
| _totalSupply                      | uint256                                                | 58   | 0      | 32    | src/VariableDebtTokenMainnetInstanceGHO.sol:VariableDebtTokenMainnetInstanceGHO |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------------------------------------|
| _name                             | string                                                 | 59   | 0      | 32    | src/VariableDebtTokenMainnetInstanceGHO.sol:VariableDebtTokenMainnetInstanceGHO |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------------------------------------|
| _symbol                           | string                                                 | 60   | 0      | 32    | src/VariableDebtTokenMainnetInstanceGHO.sol:VariableDebtTokenMainnetInstanceGHO |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------------------------------------|
| _decimals                         | uint8                                                  | 61   | 0      | 1     | src/VariableDebtTokenMainnetInstanceGHO.sol:VariableDebtTokenMainnetInstanceGHO |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------------------------------------|
| __deprecated_incentivesController | contract IAaveIncentivesController                     | 61   | 1      | 20    | src/VariableDebtTokenMainnetInstanceGHO.sol:VariableDebtTokenMainnetInstanceGHO |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------------------------------------|
| _deprecated_ghoAToken             | address                                                | 62   | 0      | 20    | src/VariableDebtTokenMainnetInstanceGHO.sol:VariableDebtTokenMainnetInstanceGHO |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------------------------------------|
| _deprecated_discountToken         | address                                                | 63   | 0      | 20    | src/VariableDebtTokenMainnetInstanceGHO.sol:VariableDebtTokenMainnetInstanceGHO |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------------------------------------|
| _deprecated_discountRateStrategy  | address                                                | 64   | 0      | 20    | src/VariableDebtTokenMainnetInstanceGHO.sol:VariableDebtTokenMainnetInstanceGHO |
╰-----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------------------------------------╯
```

v3.5 GHO vToken (`VariableDebtToken`) storage layout:
```
╭-----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------------------------------╮
| Name                              | Type                                                   | Slot | Offset | Bytes | Contract                                                                    |
+==================================================================================================================================================================================================+
| lastInitializedRevision           | uint256                                                | 0    | 0      | 32    | src/contracts/protocol/tokenization/VariableDebtToken.sol:VariableDebtToken |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------------------------------|
| initializing                      | bool                                                   | 1    | 0      | 1     | src/contracts/protocol/tokenization/VariableDebtToken.sol:VariableDebtToken |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------------------------------|
| ______gap                         | uint256[50]                                            | 2    | 0      | 1600  | src/contracts/protocol/tokenization/VariableDebtToken.sol:VariableDebtToken |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------------------------------|
| _nonces                           | mapping(address => uint256)                            | 52   | 0      | 32    | src/contracts/protocol/tokenization/VariableDebtToken.sol:VariableDebtToken |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------------------------------|
| _domainSeparator                  | bytes32                                                | 53   | 0      | 32    | src/contracts/protocol/tokenization/VariableDebtToken.sol:VariableDebtToken |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------------------------------|
| _borrowAllowances                 | mapping(address => mapping(address => uint256))        | 54   | 0      | 32    | src/contracts/protocol/tokenization/VariableDebtToken.sol:VariableDebtToken |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------------------------------|
| _underlyingAsset                  | address                                                | 55   | 0      | 20    | src/contracts/protocol/tokenization/VariableDebtToken.sol:VariableDebtToken |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------------------------------|
| _userState                        | mapping(address => struct IncentivizedERC20.UserState) | 56   | 0      | 32    | src/contracts/protocol/tokenization/VariableDebtToken.sol:VariableDebtToken |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------------------------------|
| _allowances                       | mapping(address => mapping(address => uint256))        | 57   | 0      | 32    | src/contracts/protocol/tokenization/VariableDebtToken.sol:VariableDebtToken |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------------------------------|
| _totalSupply                      | uint256                                                | 58   | 0      | 32    | src/contracts/protocol/tokenization/VariableDebtToken.sol:VariableDebtToken |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------------------------------|
| _name                             | string                                                 | 59   | 0      | 32    | src/contracts/protocol/tokenization/VariableDebtToken.sol:VariableDebtToken |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------------------------------|
| _symbol                           | string                                                 | 60   | 0      | 32    | src/contracts/protocol/tokenization/VariableDebtToken.sol:VariableDebtToken |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------------------------------|
| _decimals                         | uint8                                                  | 61   | 0      | 1     | src/contracts/protocol/tokenization/VariableDebtToken.sol:VariableDebtToken |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------------------------------|
| __deprecated_incentivesController | contract IAaveIncentivesController                     | 61   | 1      | 20    | src/contracts/protocol/tokenization/VariableDebtToken.sol:VariableDebtToken |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------------------------------|
| __unusedGap                       | uint256[3]                                             | 62   | 0      | 96    | src/contracts/protocol/tokenization/VariableDebtToken.sol:VariableDebtToken |
|-----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------------------------------|
| __deprecated_ghoUserState         | bytes32                                                | 65   | 0      | 32    | src/contracts/protocol/tokenization/VariableDebtToken.sol:VariableDebtToken |
╰-----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------------------------------╯
```
This instance of the v token is intended to be used with vGHO as long as stkAAVE is not upgraded to remove the discount hook.
…tions in base currency

Rounding up the debt usd amount, so that liquidations can also happen on very small amounts.
Fixes an edge case in liquidation:
When the liquidated collateral cannot cover the liquidation protocol fee, there is a chance that due to rounding the txn reverts. This pr fixes the edge case by rounding up, so on L377, the fee will be lowered accordingly, resulting a non reverting transferOnLiquidation.

stermi 65
certora 12
The protocol switches between scaled and upscaled balance back and forth - sometimes unnecessarily.
Therefore, this pr changes the pool operations to consistently work with the scaled balance where possible.
 
---------

Co-authored-by: TepNik <tepelin.nikita@gmail.com>
Co-authored-by: Nikita <32309387+TepNik@users.noreply.github.com>
Co-authored-by: Pavel <56404416+pavelvm5@users.noreply.github.com>
Co-authored-by: Andrey <kyzia.ru@gmail.com>
Historically transferFrom etc have consumed ther users input as allowance.
That has never really been accurate, as the users input might not actually be transferrable due to rounding, to account for that we improved the logic to consumer "up to the raw scaled up transfer amount".
liquidation protocol fee is rounded up, not down (in practice is still a bit arbitrary as it rounds multiple times, but the explicit part is now up)

add totalSupply to the docs
Certora managed to prove an occasion where the supply of 1 wei could reduce a users hf to to precision loss on avgLt calculation. While this is an extreme adge case on very small amounts, it makes sense to just not lose the precision if possible.

Moving the hf check on borrow at the end, reduces code duplication and makes the operation more equivalent to e.g. withdraw.
sakulstra and others added 29 commits December 8, 2025 12:41
Event emission in the case of setting ltv while no longer being frozen was missing.
foundry improved a lot in regards to verification, so catapulta-verify is no longer strictly necessary.
People can still install it and use it for verification, but there is no need to install by default.
The default usage on makefile was removed some releases ago and dependency was a leftover.
avara asked to make the ui-pdp backwards compatible with 3.5 to support horizon
- Add K613ArbitrumMarketInput contract for Arbitrum Sepolia configuration
- Add DeployArbitrumSepoliaMarket deployment script
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
feat: add K613 Arbitrum Sepolia market deployment contracts
While this contract was intended to be used to split revenue on whitelabel instances, in practice, for various reasons it was never used.
Therefore it is now removed from the codebase.
Co-authored-by: eboado <ebdmrr@gmail.com>
---------

Co-authored-by: Andrey <kyzia.ru@gmail.com>
Enables trusted publishing on this repo, so get rid of tokens.
Updating node to 22, as on npm <11 --provenance does not work automatically.
- `isUsingAsCollateralOrBorrowing` is no longer used
- `SafeMath` was only used in some mocks, which is unnecessary in modern solidity
- improve coverage on math utils

Incorporates:
- https://github.com/aave-dao/aave-v3-origin/pull/143/changes via 
775043f
- aave-dao#46 added missing reports, fixed readme(as this pr was wrong) and aligned all report names.
Merge pull request #2 from K613-Official/feature/k613-arbitrum-market
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2742a7dbe5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +73 to +77
uint128 unbacked;
//the outstanding debt borrowed against this asset in isolation mode
uint128 isolationModeTotalDebt;
//the amount of underlying accounted for by the protocol
uint128 virtualUnderlyingBalance;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve ReserveData storage layout across upgrades

This change repurposes the slot at ReserveData.accruedToTreasury's pair from virtualUnderlyingBalance to unbacked, and moves virtualUnderlyingBalance into the slot that was __deprecatedVirtualUnderlyingBalance in the previous revision. On a proxy upgrade from the parent commit, existing reserve state is reinterpreted (current virtual balance becomes unbacked, while virtualUnderlyingBalance reads stale/zero deprecated data), which corrupts reserve accounting and can break flows that subtract virtual balance (for example flash-loan/withdraw paths on virtual-accounting reserves). A dedicated state migration (or preserving the prior field order) is needed before activating this layout.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants