Skip to content

feat: version 3.1 #133

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

Open
wants to merge 65 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 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
e2c1e17
feat: infrared and trader joe adapters
Van0k Mar 12, 2025
7b2cb59
fix: update deps
lekhovitsky Mar 16, 2025
c20148a
feat: infrared + trader joe tests
Van0k Mar 26, 2025
9e56cb6
fix: minor fixes (#157)
lekhovitsky Mar 27, 2025
6c6834c
feat: more validation in infrared adapter + phantom token types
Van0k May 8, 2025
a245c06
Merge branch 'next' into infrared
lekhovitsky May 9, 2025
3fcbb17
fix: proper compilation params + remove compiler warnings
lekhovitsky May 9, 2025
49a907b
fix: change Sky phantom token's type + test fixes
lekhovitsky May 9, 2025
8d3891f
feat: gateways now also follow `IVersion`
lekhovitsky May 9, 2025
5b562cc
fix: change Sky's phantom token type back
lekhovitsky May 9, 2025
9cf6372
feat: discount swapper
Van0k May 16, 2025
8475b4a
feat: mellow withdrawals adapter + phantom token
Van0k May 16, 2025
d9934d7
feat: curve now accepts use256 as constructor parameter
Van0k May 16, 2025
7c7149a
fix: minor fixes
Van0k May 20, 2025
92ec2b1
feat: remove discount swapper
Van0k May 20, 2025
1143464
feat: add fluid dex adapter
Van0k May 22, 2025
ba39751
feat: fluid dex gateway
Van0k May 22, 2025
a4416a5
fix: minor fixes
Van0k May 28, 2025
0a22be9
fix: more small fixes
Van0k May 28, 2025
5a6fb08
fix: trader joe explicit amountOutMin computation
Van0k May 28, 2025
01709d2
feat: add optional referral codes to ERC4626 and StakingRewards adapters
Van0k May 30, 2025
3112f49
fix: separate ERC4626 referral logic into an inheriting contract
Van0k Jun 2, 2025
902b49b
fix: make erc4626 function overriding more consistent
Van0k Jun 3, 2025
217c43b
fix: erc4626 minor cosmetics
Van0k Jun 3, 2025
3a4b695
fix: metadata and comment fixes
lekhovitsky Jun 3, 2025
08e8106
Merge pull request #158 from Gearbox-protocol/infrared
lekhovitsky Jun 3, 2025
1cfee40
fix: check that the received claimed amount in mellow is not less tha…
Van0k Jun 6, 2025
574b1fb
fix: withdraw, redeem and redeemDiff return useSafePrices = true in m…
Van0k Jun 13, 2025
65d664d
fix: 4626 inheritance refactor for better readability
Van0k Jun 13, 2025
6a3c74f
feat: add ERC-4626 zappers (#159)
lekhovitsky Jul 9, 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
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
artifacts
cache
types
forge-out
lib
4 changes: 2 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ jobs:
- name: Run forge unit tests
run: forge test --match-test test_U -vv

- name: Run forge integration tests
run: forge test --match-test _live_ --fork-url ${{ secrets.MAINNET_TESTS_FORK }} --chain-id 1337 -vv
# - name: Run forge integration tests
# run: forge test --match-test _live_ --fork-url ${{ secrets.MAINNET_TESTS_FORK }} --chain-id 1337 -vv

- name: Perform checks
run: |
Expand Down
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
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ artifacts
cache
types
forge-out
lib
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