Skip to content

Commit abc0183

Browse files
authored
fix(FlashMintLeveraged): Avoid transaction revertion due to tether quirks (#213)
* fix: Fix failing approveSetToken in FlashMintLeveraged because of tether not returnign bool from approve function * fix: Replace approve with safeApprove to avoid tether issues * test: Adjust flashmint integration test to use eth3x * test: Fix ethereum integration test for flashmint leveraged
1 parent 0512491 commit abc0183

File tree

6 files changed

+91
-103
lines changed

6 files changed

+91
-103
lines changed

contracts/exchangeIssuance/DEXAdapter.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ library DEXAdapter {
462462
);
463463
}
464464
else {
465-
IERC20(_from).approve(_pool, _amountIn);
465+
_safeApprove(IERC20(_from), _pool, _amountIn);
466466
amountOut = pool.exchange(
467467
_i,
468468
_j,

contracts/exchangeIssuance/FlashMintLeveraged.sol

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2022 Index Cooperative
2+
Copyright 2025 Index Cooperative
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -765,7 +765,7 @@ contract FlashMintLeveraged is ReentrancyGuard, IFlashLoanRecipient{
765765
)
766766
internal
767767
{
768-
IERC20(_collateralToken).transfer(_originalSender, _collateralRemaining);
768+
IERC20(_collateralToken).safeTransfer(_originalSender, _collateralRemaining);
769769
}
770770

771771
/**
@@ -803,7 +803,7 @@ contract FlashMintLeveraged is ReentrancyGuard, IFlashLoanRecipient{
803803
_minAmountOutputToken,
804804
_swapData
805805
);
806-
_outputToken.transfer(_originalSender, outputTokenAmount);
806+
_outputToken.safeTransfer(_originalSender, outputTokenAmount);
807807
return outputTokenAmount;
808808
}
809809

@@ -972,7 +972,7 @@ contract FlashMintLeveraged is ReentrancyGuard, IFlashLoanRecipient{
972972
_transferShortfallFromSender(_collateralToken, _collateralTokenShortfall, _originalSender);
973973
return _collateralTokenShortfall;
974974
} else {
975-
_inputToken.transferFrom(_originalSender, address(this), _maxAmountInputToken);
975+
_inputToken.safeTransferFrom(_originalSender, address(this), _maxAmountInputToken);
976976
uint256 amountInputToken = _swapInputForCollateralToken(
977977
_collateralToken,
978978
_collateralTokenShortfall,
@@ -981,7 +981,7 @@ contract FlashMintLeveraged is ReentrancyGuard, IFlashLoanRecipient{
981981
_swapData
982982
);
983983
if(amountInputToken < _maxAmountInputToken){
984-
_inputToken.transfer(_originalSender, _maxAmountInputToken.sub(amountInputToken));
984+
_inputToken.safeTransfer(_originalSender, _maxAmountInputToken.sub(amountInputToken));
985985
}
986986
return amountInputToken;
987987
}
@@ -1212,9 +1212,9 @@ contract FlashMintLeveraged is ReentrancyGuard, IFlashLoanRecipient{
12121212
{
12131213
uint256 allowance = _token.allowance(address(this), address(LENDING_POOL));
12141214
if (allowance > 0) {
1215-
_token.approve(address(LENDING_POOL), 0);
1215+
_safeApprove(_token, address(LENDING_POOL), 0);
12161216
}
1217-
_token.approve(address(LENDING_POOL), MAX_UINT256);
1217+
_safeApprove(_token, address(LENDING_POOL), MAX_UINT256);
12181218
}
12191219

12201220
/**

test/integration/ethereum/addresses.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ export const PRODUCTION_ADDRESSES = {
99
dsEth: "0x341c05c0E9b33C0E38d64de76516b2Ce970bB3BE",
1010
weth: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
1111
icEth: "0x7C07F7aBe10CE8e33DC6C5aD68FE033085256A84",
12+
eth3x: "0x23C3e5B3d001e17054603269EDFC703603AdeFd8",
1213
icReth: "0xe8888Cdbc0A5958C29e7D91DAE44897c7e64F9BC",
1314
rETH: "0xae78736Cd615f374D3085123A210448E74Fc6393",
1415
aEthrETH: "0xCc9EE9483f662091a1de4795249E24aC0aC2630f",
16+
aWeth: "0x4d5F47FA6A74757f35C14fD3a6Ef8E3C9BC514E8",
1517
aSTETH: "0x1982b2F5814301d4e9a8b0201555376e62F82428",
1618
ETH2xFli: "0xAa6E8127831c9DE45ae56bB1b0d4D4Da6e5665BD",
1719
cEther: "0x4ddc2d193948926d02f9b1fe9e1daa0718270ed5",
@@ -102,13 +104,15 @@ export const PRODUCTION_ADDRESSES = {
102104
setFork: {
103105
controller: "0xD2463675a099101E36D85278494268261a66603A",
104106
debtIssuanceModuleV2: "0xa0a98EB7Af028BE00d04e46e1316808A62a8fd59",
107+
debtIssuanceModuleV2_A1: "0x04b59f9f09750c044d7cfbc177561e409085f0f3",
105108
notionalTradeModule: "0x600d9950c6ecAef98Cc42fa207E92397A6c43416",
106109
integrationRegistry: "0xb9083dee5e8273E54B9DB4c31bA9d4aB7C6B28d3",
107110
auctionModuleV1: "0x59D55D53a715b3B4581c52098BCb4075C2941DBa",
108111
tradeModule: "0xFaAB3F8f3678f68AA0d307B66e71b636F82C28BF",
109112
airdropModule: "0x09b9e7c7e2daf40fCb286fE6b863e517d5d5c40F",
110113
aaveV3LeverageStrategyExtension: "0x7d3f7EDD04916F3Cb2bC6740224c636B9AE43200",
111114
aaveV3LeverageModule: "0x71E932715F5987077ADC5A7aA245f38841E0DcBe",
115+
aaveV3LeverageModule_A1: "0x9d08CCeD85A68Bf8A19374ED4B5753aE3Be9F74f",
112116
constantPriceAdapter: "0x13c33656570092555Bf27Bdf53Ce24482B85D992",
113117
linearPriceAdapter: "0x237F7BBe0b358415bE84AB6d279D4338C0d026bB",
114118
setTokenCreator: "0x2758BF6Af0EC63f1710d3d7890e1C263a247B75E",

test/integration/ethereum/flashMintDex.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ const swapDataWethToUsdc = {
8585
};
8686

8787
if (process.env.INTEGRATIONTEST) {
88-
describe.only("FlashMintDex - Integration Test", async () => {
88+
describe("FlashMintDex - Integration Test", async () => {
8989
let owner: Account;
9090
let deployer: DeployHelper;
9191
let legacySetTokenCreator: SetTokenCreator;

0 commit comments

Comments
 (0)