Skip to content

Commit

Permalink
Merge pull request aave-dao#15 from bgd-labs/sync/cantina-preparations
Browse files Browse the repository at this point in the history
Cantina preparations
  • Loading branch information
eboadom authored May 3, 2024
2 parents f6e114a + 17d05a5 commit a4f5f40
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ update:; forge update

# Build & test
test :; forge test -vvv --no-match-contract DeploymentsGasLimits
test-contract :; forge test --match-contract ${filter} -vvv
test-watch :; forge test --watch -vvv --no-match-contract DeploymentsGasLimits
coverage :; forge coverage --report lcov && \
lcov --remove ./lcov.info -o ./lcov.info.p \
Expand Down Expand Up @@ -34,4 +35,4 @@ coverage :; forge coverage --report lcov && \
download :; cast etherscan-source --chain ${chain} -d src/etherscan/${chain}_${address} ${address}
git-diff :
@mkdir -p diffs
@printf '%s\n%s\n%s\n' "\`\`\`diff" "$$(git diff --no-index --diff-algorithm=patience --ignore-space-at-eol ${before} ${after})" "\`\`\`" > diffs/${out}.md
@printf '%s\n%s\n%s\n' "\`\`\`diff" "$$(git diff --no-index --diff-algorithm=patience --ignore-space-at-eol ${before} ${after})" "\`\`\`" > diffs/${out}.md
7 changes: 6 additions & 1 deletion docs/Aave-v3.1-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ This new feature doesn’t create any incompatibility with Aave v3 integrations,

Given its implications and criticality, virtual accounting can be considered the major feature of Aave 3.1.

_Important_. Virtual balance doesn't fix the imprecision caused by other components of the protocol, its objective is to add stricter validations, reducing any type of vector to the minimum.
**Misc considerations & acknowledged limitations**

- Virtual balance doesn't fix the imprecision caused by other components of the protocol, its objective is to add stricter validations, reducing any type of attack vector to the minimum.
- An extra "soft" protection has been added on borrowing actions (flash loan and borrow): the amount borrowed of underlying should not be higher than the aToken supply. The idea behind is to add more defenses on inflation scenarios, even if we are aware total protection is not achieved (e.g. against certain edge iteration vectors).
Not using `accruedToTreasury` in the calculation is intentional.
- The addition of virtual accounting can create a situation over time that more liquidity will be available in the aToken contract than what the the virtual balance allows to withdraw/borrow. This is intended by design.

<br>

Expand Down
32 changes: 32 additions & 0 deletions tests/template/BaseTest.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

import {TestnetProcedures, IERC20, IAToken} from '../utils/TestnetProcedures.sol';

// Base test to setup the initial config: deploying the protocol contracts and setting them up locally on foundry
// command to test: make test-contract filter=BaseTest
contract BaseTest is TestnetProcedures {
function setUp() public {
// this method deploys all the protocol contract and does the inital setup.
// -> the deployed contracts could be accessed via the ContractsReport struct internal variable `contracts`. Ex `contracts.poolProxy`
// -> the assets listed could be accessed via the TokenList struct internal variable `tokenList`
// -> the internal variable `poolAdmin` has the poolAdmin role of the protocol and holds all the admin access.
initTestEnvironment();

// initL2TestEnvironment(); -> deploys the protocol contracts as on an L2 (ex. we deploy L2Pool instead of Pool)
// initTestEnvironment(true); -> mints the listed assets to users: alice, bob, carol (can be accessed by the same variable name)
}

// add your code below
function test_default() public {
uint256 supplyAmount = 0.2e8;
uint256 underlyingBalanceBefore = IERC20(tokenList.wbtc).balanceOf(alice);
(address aWBTC, , ) = contracts.protocolDataProvider.getReserveTokensAddresses(tokenList.wbtc);

vm.prank(alice);
contracts.poolProxy.supply(tokenList.wbtc, supplyAmount, alice, 0);

assertEq(IERC20(tokenList.wbtc).balanceOf(alice), underlyingBalanceBefore - supplyAmount);
assertEq(IAToken(aWBTC).scaledBalanceOf(alice), supplyAmount);
}
}

0 comments on commit a4f5f40

Please sign in to comment.