Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cantina #8: gas improvements #10

Merged
merged 4 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/autogen/src/src/Vault.sol/contract.Vault.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Vault
[Git Source](https://github.com/cryptexfinance/tcapv2.0/blob/ad5b125ba88c9449f030a3c9f06292df66a8a2ca/src/Vault.sol)
[Git Source](https://github.com/cryptexfinance/tcapv2.0/blob/c6e2e51d5b945da0fd53c54be302f1db634bd9a7/src/Vault.sol)

**Inherits:**
[IVault](/src/interface/IVault.sol/interface.IVault.md), AccessControl, [Multicall](/src/lib/Multicall.sol/abstract.Multicall.md)
Expand Down Expand Up @@ -212,7 +212,7 @@ Deposits collateral into a pocket using a permit2 signature transfer


```solidity
function depositWithPermit(uint96 pocketId, uint256 amount, IPermit2.PermitTransferFrom memory permit, bytes calldata signature)
function depositWithPermit(uint96 pocketId, uint256 amount, IPermit2.PermitTransferFrom calldata permit, bytes calldata signature)
external
returns (uint256 shares);
```
Expand Down
4 changes: 2 additions & 2 deletions docs/autogen/src/src/interface/IVault.sol/interface.IVault.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IVault
[Git Source](https://github.com/cryptexfinance/tcapv2.0/blob/6bc13f590e0d259edfc7844b2201ce75ef760a67/src/interface/IVault.sol)
[Git Source](https://github.com/cryptexfinance/tcapv2.0/blob/3fb7671f959cafc2399d81b93557d37c7898477b/src/interface/IVault.sol)

**Inherits:**
IAccessControl, [IMulticall](/src/interface/IMulticall.sol/interface.IMulticall.md), [IVersioned](/src/interface/IVersioned.sol/interface.IVersioned.md)
Expand Down Expand Up @@ -144,7 +144,7 @@ Deposits collateral into a pocket using a permit2 signature transfer


```solidity
function depositWithPermit(uint96 pocketId, uint256 collateralAmount, IPermit2.PermitTransferFrom memory permit, bytes calldata signature)
function depositWithPermit(uint96 pocketId, uint256 collateralAmount, IPermit2.PermitTransferFrom calldata permit, bytes calldata signature)
external
returns (uint256 shares);
```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# AaveV3Pocket
[Git Source](https://github.com/cryptexfinance/tcapv2.0/blob/6bc13f590e0d259edfc7844b2201ce75ef760a67/src/pockets/AaveV3Pocket.sol)
[Git Source](https://github.com/cryptexfinance/tcapv2.0/blob/495451d159fb10c010b98bdc7bc685a1a59dc8d3/src/pockets/AaveV3Pocket.sol)

**Inherits:**
[BasePocket](/src/pockets/BasePocket.sol/contract.BasePocket.md), [IAaveV3Pocket](/src/interface/pockets/IAaveV3Pocket.sol/interface.IAaveV3Pocket.md)
Expand All @@ -23,6 +23,13 @@ IPool public immutable POOL;
constructor(address vault_, address underlyingToken_, address overlyingToken_, address aavePool) BasePocket(vault_, underlyingToken_, overlyingToken_);
```

### initialize


```solidity
function initialize() public override initializer;
```

### _onDeposit

*deposits underlying token into Aave v3, aTokens are deposited into this pocket*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# BasePocket
[Git Source](https://github.com/cryptexfinance/tcapv2.0/blob/6bc13f590e0d259edfc7844b2201ce75ef760a67/src/pockets/BasePocket.sol)
[Git Source](https://github.com/cryptexfinance/tcapv2.0/blob/495451d159fb10c010b98bdc7bc685a1a59dc8d3/src/pockets/BasePocket.sol)

**Inherits:**
[IPocket](/src/interface/pockets/IPocket.sol/interface.IPocket.md), Initializable
Expand Down Expand Up @@ -50,7 +50,7 @@ constructor(address vault_, address underlyingToken_, address overlyingToken_);


```solidity
function initialize() public initializer;
function initialize() public virtual initializer;
```

### _getBasePocketStorage
Expand Down
2 changes: 1 addition & 1 deletion src/Vault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ contract Vault is IVault, AccessControl, Multicall {
}

/// @inheritdoc IVault
function depositWithPermit(uint96 pocketId, uint256 amount, IPermit2.PermitTransferFrom memory permit, bytes calldata signature)
function depositWithPermit(uint96 pocketId, uint256 amount, IPermit2.PermitTransferFrom calldata permit, bytes calldata signature)
external
returns (uint256 shares)
{
Expand Down
2 changes: 1 addition & 1 deletion src/interface/IVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ interface IVault is IAccessControl, IMulticall, IVersioned {
/// @param permit The permit data
/// @param signature The signature
/// @return shares The amount of shares minted by the pocket
function depositWithPermit(uint96 pocketId, uint256 collateralAmount, IPermit2.PermitTransferFrom memory permit, bytes calldata signature)
function depositWithPermit(uint96 pocketId, uint256 collateralAmount, IPermit2.PermitTransferFrom calldata permit, bytes calldata signature)
external
returns (uint256 shares);

Expand Down
2 changes: 1 addition & 1 deletion src/lib/Multicall.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ abstract contract Multicall is IMulticall {

if (!success) {
// bubble up the revert reason
assembly {
assembly ("memory-safe") {
revert(add(result, 0x20), mload(result))
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/pockets/AaveV3Pocket.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ contract AaveV3Pocket is BasePocket, IAaveV3Pocket {
POOL = IPool(aavePool);
}

function initialize() public override initializer {
UNDERLYING_TOKEN.approve(address(POOL), type(uint256).max);
}

/// @dev deposits underlying token into Aave v3, aTokens are deposited into this pocket
function _onDeposit(uint256 amountUnderlying) internal override returns (uint256 amountOverlying) {
UNDERLYING_TOKEN.approve(address(POOL), amountUnderlying);
POOL.deposit(address(UNDERLYING_TOKEN), amountUnderlying, address(this), 0);
return amountUnderlying;
}
Expand Down
2 changes: 1 addition & 1 deletion src/pockets/BasePocket.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ contract BasePocket is IPocket, Initializable {
_disableInitializers();
}

function initialize() public initializer {}
function initialize() public virtual initializer {}

function _getBasePocketStorage() private pure returns (BasePocketStorage storage $) {
assembly {
Expand Down
6 changes: 4 additions & 2 deletions test/pockets/AaveV3Pocket.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ abstract contract Uninitialized is Test, TestHelpers, AaveV3PocketDeployer {
abstract contract Initialized is Uninitialized {
function setUp() public virtual override {
super.setUp();
address admin = address(this);
deployAaveV3PocketTransparent(admin, address(this), address(underlyingToken), address(overlyingAToken), POOL_MAINNET);
if (forked) {
address admin = address(this);
deployAaveV3PocketTransparent(admin, address(this), address(underlyingToken), address(overlyingAToken), POOL_MAINNET);
}
}
}

Expand Down