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

feat: version 3.1 #133

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
32bd8da
fix: new configs
Van0k Jun 6, 2024
37baf61
feat: core-v3 next changes
Van0k Jun 11, 2024
2a6b0b5
feat: zircuit adapter + phantom token changes
Van0k Jun 11, 2024
f5f51bc
feat: zircuit adapter + phantom tokens
Van0k Jun 14, 2024
fdbdd91
feat: serialization + allowed pool lists
Van0k Jun 17, 2024
a3e17e5
fix: adapter allowed pool set tests
Van0k Jun 18, 2024
10c234d
fix: cleanup + standard serialisation
0xmikko Jun 20, 2024
242a6ad
fix: warning fixes
Van0k Jun 21, 2024
3abe8b2
feat: tokensToEnable/tokensToDisable removed from adapters
Van0k Jun 27, 2024
3cbf8bf
fix: more consistent useSafePrices returned values from adapters
Van0k Jun 28, 2024
c91fafa
fix: remove redundant masks from adapter tests
Van0k Jun 28, 2024
ce6933d
fix: events in interfaces fixed
0xmikko Jul 6, 2024
9c69860
feat: bump core-v3
lekhovitsky Jul 7, 2024
da748ea
fix: remove `unchecked` around loops
lekhovitsky Jul 7, 2024
29c967b
feat: slightly rework phantom token withdrawals
lekhovitsky Jul 8, 2024
e0759af
fix: minor project cleanup (#132)
lekhovitsky Jul 17, 2024
5e5d8eb
Merge remote-tracking branch 'origin/main' into next
lekhovitsky Jul 17, 2024
056e521
feat: move `ZapperRegister` to `test/`
lekhovitsky Jul 17, 2024
e2fcd9a
feat: minor fixes (#135)
lekhovitsky Jul 24, 2024
d427a3a
chore: update copyright notice
lekhovitsky Aug 9, 2024
27a9b7f
feat: update tests for v3.1 (#142)
Van0k Oct 2, 2024
3d50468
fix: update core-v3 commit
Van0k Oct 2, 2024
7dde79c
feat: sky adapters v3.1 (#144)
Van0k Oct 24, 2024
5e237b0
feat: mellow and pendle adapters for v3.1 (#138)
Van0k Oct 24, 2024
35705c3
fix: replace Tokens enum with uint256
Van0k Nov 27, 2024
ab72e90
chore: bump sdk-gov
Van0k Nov 28, 2024
3968a9d
feat: equalizer adapter (#147)
Van0k Dec 20, 2024
9531e8a
fix: usdc test config (#148)
Van0k Dec 21, 2024
0d9636a
fix: minor changes in interfaces and contract types
lekhovitsky Jan 8, 2025
be5bdf8
feat: Balancer V3 Router adapter for v3.1 (#150)
Van0k Feb 5, 2025
f79aa66
fix: small balancer v3 fixes
Van0k Feb 5, 2025
1449dc8
fix: add missing `serialize()` and other nits
lekhovitsky Feb 10, 2025
f6d3a3e
feat: balancer v3 router gateway (#151)
Van0k Feb 14, 2025
16c0b7d
feat: balancer v3 gateway fixes (#153)
Van0k Feb 15, 2025
57e535e
fix: add `receive` to balancer v3 gateway (#156)
Van0k Feb 18, 2025
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
26 changes: 19 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
/node_modules
/forge-out
.DS_Store
cache
# Dependencies
node_modules/

# Compiler files
cache/
out/

# Ignores development broadcast logs
!/broadcast
/broadcast/*/31337/
/broadcast/**/dry-run/

# Docs
docs/

# Dotenv file
.env
npm-root
types
dist

# Logs
*.log
20 changes: 17 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/@gearbox-protocol/sdk-gov"]
path = lib/@gearbox-protocol/sdk-gov
url = https://github.com/Gearbox-protocol/sdk-gov
[submodule "lib/@gearbox-protocol/core-v3"]
path = lib/@gearbox-protocol/core-v3
url = https://github.com/Gearbox-protocol/core-v3
branch = next
[submodule "lib/@gearbox-protocol/oracles-v3"]
path = lib/@gearbox-protocol/oracles-v3
url = https://github.com/Gearbox-protocol/oracles-v3
branch = next
[submodule "lib/@1inch/solidity-utils"]
path = lib/@1inch/solidity-utils
url = https://github.com/1inch/solidity-utils
[submodule "lib/@1inch/farming"]
path = lib/@1inch/farming
url = https://github.com/1inch/farming
6 changes: 2 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
"[solidity]": {
"editor.defaultFormatter": "JuanBlanco.solidity"
},

"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.tabSize": 4,
"eslint.validate": ["javascript", "typescript"],
"files.eol": "\n",
"solidity.formatter": "forge",
"solidity.packageDefaultDependenciesContractsDirectory": "contracts",
"solidity.packageDefaultDependenciesDirectory": "node_modules",
"solidity.compileUsingRemoteVersion": "v0.8.17"
"solidity.packageDefaultDependenciesDirectory": "lib",
"solidity.compileUsingRemoteVersion": "v0.8.23"
}
9 changes: 9 additions & 0 deletions config_scripts/crvusdMainnetScript.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {
crvusdConfigMainnet,
PoolV3CoreConfigurator,
} from "@gearbox-protocol/sdk-gov";

const poolCfg = PoolV3CoreConfigurator.new(crvusdConfigMainnet);
console.error(poolCfg.toString());

console.log(poolCfg.deployConfig());
9 changes: 9 additions & 0 deletions config_scripts/test_daiMainnetScript.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {
PoolV3CoreConfigurator,
testDaiConfigMainnet,
} from "@gearbox-protocol/sdk-gov";

const poolCfg = PoolV3CoreConfigurator.new(testDaiConfigMainnet);
console.error(poolCfg.toString());

console.log(poolCfg.deployConfig());
9 changes: 9 additions & 0 deletions config_scripts/test_wethMainnetScript.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {
PoolV3CoreConfigurator,
testWethConfigMainnet,
} from "@gearbox-protocol/sdk-gov";

const poolCfg = PoolV3CoreConfigurator.new(testWethConfigMainnet);
console.error(poolCfg.toString());

console.log(poolCfg.deployConfig());
9 changes: 9 additions & 0 deletions config_scripts/usdceArbitrumScript.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {
PoolV3CoreConfigurator,
usdceConfigArbitrum,
} from "@gearbox-protocol/sdk-gov";

const poolCfg = PoolV3CoreConfigurator.new(usdceConfigArbitrum);
console.error(poolCfg.toString());

console.log(poolCfg.deployConfig());
48 changes: 8 additions & 40 deletions contracts/adapters/AbstractAdapter.sol
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
// SPDX-License-Identifier: GPL-2.0-or-later
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2023.
pragma solidity ^0.8.17;
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.23;

import {IAdapter} from "@gearbox-protocol/core-v2/contracts/interfaces/IAdapter.sol";
import {IAdapter} from "@gearbox-protocol/core-v3/contracts/interfaces/base/IAdapter.sol";
import {ICreditManagerV3} from "@gearbox-protocol/core-v3/contracts/interfaces/ICreditManagerV3.sol";
import {PoolV3} from "@gearbox-protocol/core-v3/contracts/pool/PoolV3.sol";
import {CallerNotCreditFacadeException} from "@gearbox-protocol/core-v3/contracts/interfaces/IExceptions.sol";
import {ACLTrait} from "@gearbox-protocol/core-v3/contracts/traits/ACLTrait.sol";
import {SanityCheckTrait} from "@gearbox-protocol/core-v3/contracts/traits/SanityCheckTrait.sol";

/// @title Abstract adapter
/// @dev Inheriting adapters MUST use provided internal functions to perform all operations with credit accounts
abstract contract AbstractAdapter is IAdapter, ACLTrait {
abstract contract AbstractAdapter is IAdapter, ACLTrait, SanityCheckTrait {
/// @notice Credit manager the adapter is connected to
address public immutable override creditManager;

/// @notice Address provider contract
address public immutable override addressProvider;

/// @notice Address of the contract the adapter is interacting with
address public immutable override targetContract;

/// @notice Constructor
/// @param _creditManager Credit manager to connect the adapter to
/// @param _targetContract Address of the adapted contract
constructor(address _creditManager, address _targetContract)
ACLTrait(ICreditManagerV3(_creditManager).addressProvider())
ACLTrait(PoolV3(ICreditManagerV3(_creditManager).pool()).acl())
nonZeroAddress(_targetContract)
{
creditManager = _creditManager;
addressProvider = ICreditManagerV3(_creditManager).addressProvider();
targetContract = _targetContract;
}

Expand Down Expand Up @@ -72,43 +70,13 @@ abstract contract AbstractAdapter is IAdapter, ACLTrait {
return ICreditManagerV3(creditManager).execute(callData);
}

/// @dev Executes a swap operation without input token approval
/// Reverts if active credit account is not set or any of passed tokens is not registered as collateral
/// @param tokenIn Input token that credit account spends in the call
/// @param tokenOut Output token that credit account receives after the call
/// @param callData Data to call the target contract with
/// @param disableTokenIn Whether `tokenIn` should be disabled after the call
/// (for operations that spend the entire account's balance of the input token)
/// @return tokensToEnable Bit mask of tokens that should be enabled after the call
/// @return tokensToDisable Bit mask of tokens that should be disabled after the call
/// @return result Call result
function _executeSwapNoApprove(address tokenIn, address tokenOut, bytes memory callData, bool disableTokenIn)
internal
returns (uint256 tokensToEnable, uint256 tokensToDisable, bytes memory result)
{
tokensToEnable = _getMaskOrRevert(tokenOut);
uint256 tokenInMask = _getMaskOrRevert(tokenIn);
if (disableTokenIn) tokensToDisable = tokenInMask;
result = _execute(callData);
}

/// @dev Executes a swap operation with maximum input token approval, and revokes approval after the call
/// Reverts if active credit account is not set or any of passed tokens is not registered as collateral
/// @param tokenIn Input token that credit account spends in the call
/// @param tokenOut Output token that credit account receives after the call
/// @param callData Data to call the target contract with
/// @param disableTokenIn Whether `tokenIn` should be disabled after the call
/// (for operations that spend the entire account's balance of the input token)
/// @return tokensToEnable Bit mask of tokens that should be enabled after the call
/// @return tokensToDisable Bit mask of tokens that should be disabled after the call
/// @return result Call result
/// @custom:expects Credit manager reverts when trying to approve non-collateral token
function _executeSwapSafeApprove(address tokenIn, address tokenOut, bytes memory callData, bool disableTokenIn)
internal
returns (uint256 tokensToEnable, uint256 tokensToDisable, bytes memory result)
{
tokensToEnable = _getMaskOrRevert(tokenOut);
if (disableTokenIn) tokensToDisable = _getMaskOrRevert(tokenIn);
function _executeSwapSafeApprove(address tokenIn, bytes memory callData) internal returns (bytes memory result) {
_approveToken(tokenIn, type(uint256).max);
result = _execute(callData);
_approveToken(tokenIn, 1);
Expand Down
165 changes: 0 additions & 165 deletions contracts/adapters/aave/AaveV2_LendingPoolAdapter.sol

This file was deleted.

Loading
Loading