Skip to content

Commit 94f232c

Browse files
committed
feat: added wnative flag
1 parent 4734c13 commit 94f232c

File tree

9 files changed

+42
-15
lines changed

9 files changed

+42
-15
lines changed

script/strategies/kandel/deployers/ArbitrumKandelSeederDeployer.s.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ contract ArbitrumKandelSeederDeployer is Deployer {
3434
deployERC4626Kandel: true,
3535
deployKandel: true,
3636
testBase: IERC20(fork.get("WETH.e")),
37-
testQuote: IERC20(fork.get("DAI.e"))
37+
testQuote: IERC20(fork.get("DAI.e")),
38+
wnative: address(0)
3839
});
3940

4041
// Pass the struct to innerRun

script/strategies/kandel/deployers/KandelSeederDeployer.s.sol

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ contract KandelSeederDeployer is Deployer, Test2 {
3333
bool deployAaveKandel = true;
3434
bool deployERC4626Kandel = true;
3535
bool deployKandel = true;
36+
address wnative = vm.envAddress("WETH");
3637

3738
try vm.envBool("DEPLOY_AAVE_KANDEL") returns (bool deployAaveKandel_) {
3839
deployAaveKandel = deployAaveKandel_;
@@ -57,7 +58,8 @@ contract KandelSeederDeployer is Deployer, Test2 {
5758
deployERC4626Kandel: deployERC4626Kandel,
5859
deployKandel: deployKandel,
5960
testBase: IERC20(envAddressOrName("TEST_BASE")),
60-
testQuote: IERC20(envAddressOrName("TEST_QUOTE"))
61+
testQuote: IERC20(envAddressOrName("TEST_QUOTE")),
62+
wnative: wnative
6163
});
6264

6365
innerRun(params);
@@ -75,6 +77,7 @@ contract KandelSeederDeployer is Deployer, Test2 {
7577
bool deployKandel;
7678
IERC20 testBase;
7779
IERC20 testQuote;
80+
address wnative;
7881
}
7982

8083
function innerRun(DeploymentParams memory params)
@@ -113,7 +116,7 @@ contract KandelSeederDeployer is Deployer, Test2 {
113116
// We therefore ensure that this happens.
114117
uint64 nonce = vm.getNonce(broadcaster());
115118
broadcast();
116-
aaveSeeder = new AaveKandelSeeder(params.mgv, params.addressesProvider, params.aaveKandelGasreq);
119+
aaveSeeder = new AaveKandelSeeder(params.mgv, params.addressesProvider, params.aaveKandelGasreq, params.wnative);
117120
// Bug workaround: See comment above `nonce` further up
118121
if (nonce == vm.getNonce(broadcaster())) {
119122
vm.setNonce(broadcaster(), nonce + 1);

script/strategies/kandel/deployers/MumbaiKandelSeederDeployer.s.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ contract MumbaiKandelSeederDeployer is Deployer {
3434
deployERC4626Kandel: true,
3535
deployKandel: true,
3636
testBase: IERC20(fork.get("CRV.T/AAVEv3")), // make sure to use an AAVE faucet
37-
testQuote: IERC20(fork.get("WBTC.T/AAVEv3")) // make sure to use an AAVE faucet
37+
testQuote: IERC20(fork.get("WBTC.T/AAVEv3")), // make sure to use an AAVE faucet,
38+
wnative: address(0)
3839
});
3940

4041
// Pass the struct to innerRun

script/strategies/kandel/deployers/PolygonKandelSeederDeployer.s.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ contract PolygonKandelSeederDeployer is Deployer {
3434
deployERC4626Kandel: true,
3535
deployKandel: true,
3636
testBase: IERC20(fork.get("WETH.e")),
37-
testQuote: IERC20(fork.get("DAI.e"))
37+
testQuote: IERC20(fork.get("DAI.e")),
38+
wnative: address(0)
3839
});
3940

4041
// Pass the struct to innerRun

src/strategies/offer_maker/market_making/kandel/AaveKandel.sol

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,27 @@ contract AaveKandel is GeometricKandel {
2222
///@notice Indication that this is first puller (returned from __lastLook__) so posthook should deposit liquidity on AAVE
2323
bytes32 internal constant IS_FIRST_PULLER = "IS_FIRST_PULLER";
2424

25+
///@notice the address of the WETH9 token.
26+
address internal immutable wnative;
27+
2528
///@notice Constructor
2629
///@param mgv The Mangrove deployment.
2730
///@param olKeyBaseQuote The OLKey for the outbound_tkn base and inbound_tkn quote offer list Kandel will act on, the flipped OLKey is used for the opposite offer list.
2831
///@param gasreq the gas required by the strat to execute
2932
///@param routerParams routing policy parameters for this contract
30-
constructor(IMangrove mgv, OLKey memory olKeyBaseQuote, uint gasreq, RouterParams memory routerParams)
31-
GeometricKandel(mgv, olKeyBaseQuote, routerParams)
32-
{
33+
///@param wnative_ the address of the WETH9 token.
34+
constructor(
35+
IMangrove mgv,
36+
OLKey memory olKeyBaseQuote,
37+
uint gasreq,
38+
RouterParams memory routerParams,
39+
address wnative_
40+
) GeometricKandel(mgv, olKeyBaseQuote, routerParams) {
3341
// one makes sure it is not possible to deploy an AAVE kandel on aTokens
3442
// allowing Kandel to deposit aUSDC for instance would conflict with other Kandel instances bound to the same router
3543
// and trading on USDC.
3644
// The code in isOverlying verifies that neither base nor quote are official AAVE overlyings.
45+
wnative = wnative_;
3746
require(
3847
!isOverlying(olKeyBaseQuote.outbound_tkn) && !isOverlying(olKeyBaseQuote.inbound_tkn),
3948
"AaveKandel/cannotTradeAToken"
@@ -47,6 +56,7 @@ contract AaveKandel is GeometricKandel {
4756
/// @param token the token to verify.
4857
/// @return true if overlying; otherwise, false.
4958
function isOverlying(address token) internal view returns (bool) {
59+
if (token == wnative) return false;
5060
try IAToken(token).UNDERLYING_ASSET_ADDRESS() returns (address) {
5161
return true;
5262
} catch {}

src/strategies/offer_maker/market_making/kandel/AaveKandelSeeder.sol

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,21 @@ contract AaveKandelSeeder is AbstractKandelSeeder {
2828
///@notice the Aave router.
2929
AavePooledRouter public immutable AAVE_ROUTER;
3030

31+
///@notice the address of the WETH9 token.
32+
address internal immutable wnative;
33+
3134
///@notice constructor for `AaveKandelSeeder`. Initializes an `AavePooledRouter` with this seeder as manager.
3235
///@param mgv The Mangrove deployment.
3336
///@param addressesProvider address of AAVE's address provider
3437
///@param aaveKandelGasreq the total gasreq to use for executing a kandel offer
35-
constructor(IMangrove mgv, IPoolAddressesProvider addressesProvider, uint aaveKandelGasreq)
38+
///@param wnative_ the address of the WETH9 token.
39+
constructor(IMangrove mgv, IPoolAddressesProvider addressesProvider, uint aaveKandelGasreq, address wnative_)
3640
AbstractKandelSeeder(mgv, aaveKandelGasreq)
3741
{
3842
AavePooledRouter router = new AavePooledRouter(addressesProvider);
3943
AAVE_ROUTER = router;
4044
router.setAaveManager(msg.sender);
45+
wnative = wnative_;
4146
}
4247

4348
///@inheritdoc AbstractKandelSeeder
@@ -59,7 +64,8 @@ contract AaveKandelSeeder is AbstractKandelSeeder {
5964
routerImplementation: AAVE_ROUTER, // using aave pooled router to source liquidity
6065
fundOwner: owner,
6166
strict: liquiditySharing
62-
})
67+
}),
68+
wnative
6369
);
6470
// Allowing newly deployed Kandel to bind to the AaveRouter
6571
AAVE_ROUTER.bind(address(kandel));

test/strategies/kandel/AaveKandel.t.sol

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ contract AaveKandelTest is CoreKandelTest {
6666
mgv: IMangrove($(mgv)),
6767
olKeyBaseQuote: olKey,
6868
gasreq: kandel_gasreq,
69-
routerParams: Direct.RouterParams({routerImplementation: router, fundOwner: id, strict: strict})
69+
routerParams: Direct.RouterParams({routerImplementation: router, fundOwner: id, strict: strict}),
70+
wnative_: address(0)
7071
});
7172

7273
router.bind(address(aaveKandel_));
@@ -368,7 +369,8 @@ contract AaveKandelTest is CoreKandelTest {
368369
mgv: IMangrove($(mgv)),
369370
gasreq: 700_000,
370371
olKeyBaseQuote: OLKey(address(aToken), address(quote), 1),
371-
routerParams: Direct.RouterParams({routerImplementation: router, fundOwner: address(0), strict: false})
372+
routerParams: Direct.RouterParams({routerImplementation: router, fundOwner: address(0), strict: false}),
373+
wnative_: address(0)
372374
});
373375
}
374376

@@ -380,7 +382,8 @@ contract AaveKandelTest is CoreKandelTest {
380382
mgv: IMangrove($(mgv)),
381383
gasreq: 700_000,
382384
olKeyBaseQuote: OLKey(address(base), address(aToken), 1),
383-
routerParams: Direct.RouterParams({routerImplementation: router, fundOwner: address(0), strict: false})
385+
routerParams: Direct.RouterParams({routerImplementation: router, fundOwner: address(0), strict: false}),
386+
wnative_: address(0)
384387
});
385388
}
386389
}

test/strategies/kandel/Kandel.gasreq.t.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ abstract contract AaveKandelGasreqBaseTest is CoreKandelGasreqBaseTest {
235235
mgv: mgv,
236236
olKeyBaseQuote: olKey,
237237
gasreq: 1_000_000,
238-
routerParams: Direct.RouterParams({routerImplementation: router, fundOwner: address(this), strict: false})
238+
routerParams: Direct.RouterParams({routerImplementation: router, fundOwner: address(this), strict: false}),
239+
wnative_: address(0)
239240
});
240241
router.bind(address(aaveKandel));
241242
return aaveKandel;

test/strategies/kandel/KandelSeeder.t.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ contract KandelSeederTest is StratTest {
7979
AaveKandelSeeder aaveKandelSeeder = new AaveKandelSeeder({
8080
mgv: IMangrove($(mgv)),
8181
addressesProvider: IPoolAddressesProvider(fork.get("AaveAddressProvider")),
82-
aaveKandelGasreq: 628_000
82+
aaveKandelGasreq: 628_000,
83+
wnative_: address(0)
8384
});
8485
aaveSeeder = aaveKandelSeeder;
8586
aaveRouter = aaveKandelSeeder.AAVE_ROUTER();

0 commit comments

Comments
 (0)