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

Fixed LI-CF PreLiquidation #1

Merged
merged 192 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
192 commits
Select commit Hold shift + click to select a range
1404b08
feat: initial commit
peyha Aug 29, 2024
9f84b3e
fix: stack too deep
peyha Aug 30, 2024
4536541
fix: handle empty callback
peyha Aug 30, 2024
14637df
fix: correct callback arg
peyha Aug 30, 2024
8db8b63
feat: first tests
peyha Aug 30, 2024
3d40d22
forge install: solmate
peyha Aug 30, 2024
65dd2b9
feat: use solmate erc20 lib
peyha Aug 30, 2024
675ce0d
fix: remove unused arg
peyha Aug 30, 2024
afc0f96
style: adapt linter
peyha Aug 30, 2024
e273bc6
style: rename variable
peyha Aug 30, 2024
282763c
doc: natspec
peyha Aug 30, 2024
b0cc6cc
feat: licence
peyha Aug 30, 2024
738e3d3
style: linter
peyha Aug 30, 2024
c942d2c
fix: variable name
peyha Aug 30, 2024
e36f99d
doc: natspec for accrueInterest
peyha Sep 2, 2024
cbfa384
feat: move isValid attribue to SubscriptionParams
peyha Sep 2, 2024
8f06d8f
chore: run forge fmt
QGarchery Sep 3, 2024
a0a598c
refactor: simplify CI
QGarchery Sep 3, 2024
26ff870
chore: use consistent naming for ci file
QGarchery Sep 3, 2024
e9af672
refactor: use camel case for test names
QGarchery Sep 3, 2024
4cc9e14
refactor: test contract naming
QGarchery Sep 3, 2024
bd87eac
refactor: store IMorpho directly
QGarchery Sep 3, 2024
6982647
refactor: remove borrower and market id from params
QGarchery Sep 3, 2024
968785a
feat: remove auto-unsubscribe in liquidate
peyha Sep 2, 2024
2643e33
fix: callback calls liquidator instead of msg.sender
peyha Sep 2, 2024
5577356
feat: improve SubscriptionParams for gas opti
peyha Sep 3, 2024
a40be1b
feat: implement events
peyha Sep 3, 2024
692849a
fix: setup CI RPC
QGarchery Sep 3, 2024
730cb9d
chore: use createSelectFork
QGarchery Sep 3, 2024
925b873
fix: import ALCHEMY_KEY secret
QGarchery Sep 3, 2024
32c12d9
refactor: remove key length
QGarchery Sep 3, 2024
bdb7078
refactor: remove isValid flag
QGarchery Sep 3, 2024
98acabd
feat: accrue interest on morpho in liquidate
peyha Sep 3, 2024
0735a2d
feat: use public mapping
peyha Sep 3, 2024
2a87359
refactor: use nbSubscription again
QGarchery Sep 3, 2024
30db15d
refactor: only check close factor for validity
QGarchery Sep 3, 2024
f162395
refactor: use computeSubscriptionId
QGarchery Sep 3, 2024
f9d6b45
fix: complete Unsubscribe event
QGarchery Sep 3, 2024
171ed69
feat: require morpho as sender in repay callback
peyha Sep 4, 2024
16655cf
feat: use subscriptionId in Liquidate event
peyha Sep 4, 2024
27e6d3c
feat: remove bad debt parameter from Liquidate
peyha Sep 4, 2024
3ef9ca5
feat: implement constructor to pass morpho address
peyha Sep 4, 2024
aadb464
feat: remove repaidAssets from liquidate
peyha Sep 4, 2024
8e8b5ba
style: forge fmt
peyha Sep 4, 2024
f41c875
fix: trim subscription params
QGarchery Sep 5, 2024
5e23835
Merge pull request #5 from morpho-org/fix/trim-subscription-params
peyha Sep 5, 2024
5ce2b2e
feat: require close factor on borrow shares instead of collateral
peyha Sep 5, 2024
c234e35
refactor: rename slltv into prelltv
peyha Sep 6, 2024
41e3906
fix: close factor require condition
peyha Sep 6, 2024
9f5e68e
feat: change indexed event for Liquidate
peyha Sep 6, 2024
1a03539
refactor: newline
peyha Sep 6, 2024
a3827af
fix: stack too deep
peyha Sep 6, 2024
946f2cc
refactor: increment trick
peyha Sep 6, 2024
76f228e
feat: use marketParams in subscribe for gas opti
peyha Sep 6, 2024
e80f558
feat: factorize market id
peyha Sep 6, 2024
59b1210
feat: replace OZ IERC20 by Solmate ERC20
peyha Sep 6, 2024
3a42f44
feat: use custom errors with solidity 0.8.27
peyha Sep 6, 2024
d7e9229
feat: improve refactor of market id
peyha Sep 6, 2024
7553359
refactor: rename assets into repaidAssets
QGarchery Sep 8, 2024
6a645a6
fix: complete rename of slltv into prelltv
QGarchery Sep 8, 2024
4a67f67
refactor: one slot storage
QGarchery Sep 8, 2024
d2685dc
refactor: add parameter name to errors
QGarchery Sep 8, 2024
073b145
refactor: public to external when not needed
QGarchery Sep 8, 2024
0427c95
refactor: consistent parameter order for events
QGarchery Sep 8, 2024
dd4b492
refactor: a couple of renaming
QGarchery Sep 8, 2024
ac751bc
refactor: remove subscriptionId from errors
QGarchery Sep 9, 2024
b4b76aa
chore: remove subscriptionId from errors in tests
QGarchery Sep 9, 2024
1ff45cd
refactor: improve errors
peyha Sep 9, 2024
8591e9e
Merge branch 'feat/licence' into refactor/single-storage
peyha Sep 9, 2024
f5548d8
style: forge fmt
peyha Sep 9, 2024
faea158
fix: check invalid subscription using boolean array
peyha Sep 9, 2024
e07360c
Merge pull request #6 from morpho-org/refactor/single-storage
peyha Sep 9, 2024
abce0a0
feat: implement ILiquidationProtection
peyha Sep 10, 2024
d1ecbba
feat: implement factory contract
peyha Sep 10, 2024
ca8bdba
refactor: change variable name in test
peyha Sep 10, 2024
97eb391
feat: implement CreateSubscription event
peyha Sep 10, 2024
7fa0cd3
feat: approve morpho at contract creation
peyha Sep 10, 2024
8b1168a
refactor: remove unused arg
peyha Sep 10, 2024
3da07b1
style: rename variable and function
peyha Sep 10, 2024
f3f65ae
feat: implement factory interface
peyha Sep 10, 2024
285338f
refactor: import
peyha Sep 10, 2024
7cfeb90
style: renaming
peyha Sep 11, 2024
9942b46
test: remove fork in test and redeploy contracts from scratch
peyha Sep 11, 2024
e1a4dee
feat: immutable market id
peyha Sep 11, 2024
17f1e59
refactor: remove unused arg
peyha Sep 11, 2024
cdff984
feat: implement mapping in factory
peyha Sep 11, 2024
5e1ca49
feat: deconstruct subscription params for immutability
peyha Sep 11, 2024
91c2c05
feat: deconstruct market params for immutability
peyha Sep 12, 2024
cff7db6
feat: use getPreLiquidationid as pure fn
peyha Sep 12, 2024
c7a4dbb
style: rename LiquidationTooLarge error
peyha Sep 12, 2024
a533cf6
style: rename HealthyPosition error to NotPreLiquidatablePosition
peyha Sep 12, 2024
574546b
style: rename liquidationIncentive
peyha Sep 12, 2024
10ac40d
refactor: little improvements
MathisGD Sep 12, 2024
e48f9cc
Merge branch 'feat/factory' into refactor/small-improvements
peyha Sep 13, 2024
e52f4e0
Merge pull request #11 from morpho-org/refactor/small-improvements
peyha Sep 13, 2024
01fc6ea
style: rename liquidationIncentive
peyha Sep 13, 2024
f3c4c92
style: rename maxBorrow
peyha Sep 13, 2024
abbb45d
style: rename callback
peyha Sep 13, 2024
9c45be1
style: rename liquidate into preliquidate
peyha Sep 13, 2024
f92fc2b
test: implement fuzz test
peyha Sep 13, 2024
ab62aa0
style: rename Liquidate event
peyha Sep 13, 2024
61b0b67
feat: enable ir in foundry config
peyha Sep 13, 2024
1e076fd
style: rename preliquidate
peyha Sep 13, 2024
cefddb0
style: rename maxBorrow
peyha Sep 13, 2024
481b88c
refactor: implement setSubscription
peyha Sep 13, 2024
6adab2d
feat: complete interface
peyha Sep 13, 2024
25b80bf
test: improve factory tests
peyha Sep 13, 2024
16f7f46
refactor: rename liquidationProtection
peyha Sep 13, 2024
404b931
refactor: rename test function
peyha Sep 13, 2024
ea06a08
doc: remove comment
peyha Sep 13, 2024
57318a8
test: improve factory test
peyha Sep 13, 2024
31a0c15
refactor: rename factory mapping
peyha Sep 13, 2024
ac62622
refactor: small improvement
peyha Sep 13, 2024
612cd99
refactor: rename SetSubscribe event
peyha Sep 13, 2024
69865de
doc: natspec
peyha Sep 13, 2024
fd3af59
refactor: rename SubscriptionParams => PreLiquidationParams
peyha Sep 13, 2024
17aa460
feat: remove subscription from PreLiquidation
peyha Sep 13, 2024
76cba25
refactor: remove unused event
peyha Sep 13, 2024
f3ceea2
refactor: renaming
peyha Sep 16, 2024
06afb2b
feat: change getSubscriptionId into public
peyha Sep 16, 2024
9e1b21e
Merge pull request #9 from morpho-org/feat/factory
peyha Sep 16, 2024
1937397
test(preliquidation): improve tests
peyha Sep 16, 2024
dead6a3
doc: remove outdated comment
peyha Sep 17, 2024
830d0ba
doc: remove comment
peyha Sep 17, 2024
a1b4f8e
refactor: remove file
peyha Sep 17, 2024
f95e854
refactor: change event and error
peyha Sep 17, 2024
a0cd90d
refactor: move require
peyha Sep 17, 2024
c9a53bd
doc: remove outdated comment
peyha Sep 17, 2024
b5532a9
refactor: inequality
peyha Sep 17, 2024
eb4e088
fix: require params
peyha Sep 17, 2024
6b9e1bd
refactor: remove arg from InconsistentInput error
peyha Sep 18, 2024
da099a0
feat: implement NonexistentMarket error
peyha Sep 18, 2024
276ed5d
doc: remove comment
peyha Sep 18, 2024
3083486
test: implement callback test
peyha Sep 19, 2024
af51a56
refactor: minor improvements
MathisGD Sep 20, 2024
12b5f82
chore: useless import
MathisGD Sep 20, 2024
4beb752
Merge pull request #18 from morpho-org/refactor/minor-improvements
peyha Sep 20, 2024
374ecdb
feat: implement preliquidation oracle
peyha Sep 20, 2024
ec17452
doc: natspec
peyha Sep 20, 2024
c75e608
refactor: naming
peyha Sep 23, 2024
4f08e8e
doc: wrong title
peyha Sep 23, 2024
6de296d
doc: natspec
peyha Sep 23, 2024
d9b1936
feat: remove MathLib for uint128
peyha Sep 23, 2024
1ba3aaf
refactor: prevent redundant data call
peyha Sep 23, 2024
4f8bf10
refactor: errors
peyha Sep 23, 2024
81f3f78
feat: create2 in factory
peyha Sep 23, 2024
732c171
feat: implementing create2 and UtilsLib
peyha Sep 23, 2024
bb869fc
feat: implement create2 with test
peyha Sep 23, 2024
9a1c56f
feat: remove PreLiquidationAlreadyExist error
peyha Sep 23, 2024
45ab92c
feat: use salt in factory
peyha Sep 23, 2024
c51b45c
refactor: encode struct
peyha Sep 23, 2024
f7d9836
test: redundant pre liquidation
peyha Sep 23, 2024
2dedab6
doc: remove natspec
peyha Sep 23, 2024
dfc6011
refactor: remove constantsLib and hardcode salt
peyha Sep 23, 2024
69d3fc4
feat: error
peyha Sep 23, 2024
90b18ad
test: add revert data
peyha Sep 23, 2024
329b07c
refactor: move UtilsLib to periphery
peyha Sep 23, 2024
5827c73
doc: redundant preliquidation natspec
peyha Sep 23, 2024
c9bfa30
test: isolate create2 test
peyha Sep 23, 2024
4a3a87a
refactor: reorder constant arg
peyha Sep 23, 2024
2ad38b7
doc: natspec improvement
peyha Sep 23, 2024
c809d5b
refactor: remove return variable
peyha Sep 23, 2024
66af3cc
refactor: rename UtilsLib
peyha Sep 23, 2024
b4558b6
doc: lib natspec
peyha Sep 23, 2024
e129848
refactor: factorize immutable getters
QGarchery Sep 23, 2024
5352c32
doc: improve natspec
peyha Sep 24, 2024
a422573
doc: natspec
peyha Sep 24, 2024
7f009ee
doc: natspec
peyha Sep 24, 2024
f2695db
Merge pull request #24 from morpho-org/feat/create2
peyha Sep 24, 2024
aa84ba1
refactor: rename to pre liquidation incentive factor
QGarchery Sep 24, 2024
148db67
refactor: rename getter to remove get prefix
QGarchery Sep 24, 2024
bfcff08
merge: feat/licence
QGarchery Sep 24, 2024
92e975e
feat: solidity version
peyha Sep 24, 2024
5f579a3
style: fmt
peyha Sep 24, 2024
5a7f4be
Merge pull request #27 from morpho-org/refactor/factorize-immutable-g…
QGarchery Sep 24, 2024
0fc011b
doc: preliquidation natspec
peyha Sep 24, 2024
1ca70cf
refactor: event naming
peyha Sep 24, 2024
6c953e2
build: remove api key from ci and improve foundry config
peyha Sep 24, 2024
ff50b6e
doc: move natspec from interface to contract
peyha Sep 24, 2024
66a1573
style: renaming event
peyha Sep 24, 2024
34eba76
refactor: fmt
peyha Sep 24, 2024
9f718c5
refactor: move accrue interest before market
peyha Sep 24, 2024
30d6786
test: implement interest test
peyha Sep 24, 2024
cf57d42
test: improvement
peyha Sep 24, 2024
9d47d95
doc: natspec improvements
peyha Sep 24, 2024
59eb52d
refactor: inline health check
peyha Sep 25, 2024
fbaf3ce
style: format
peyha Sep 25, 2024
ac11183
feat: pre-liquidation incentive factor require
peyha Sep 25, 2024
698ea9c
feat: close factor require
peyha Sep 25, 2024
2178f35
refactor: fetch price before accrue interest
peyha Sep 25, 2024
ccfd8f1
refactor: import
peyha Sep 25, 2024
fc5728d
doc: improvements
peyha Sep 25, 2024
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 .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/morpho-blue"]
path = lib/morpho-blue
url = [email protected]:morpho-org/morpho-blue.git
[submodule "lib/solmate"]
path = lib/solmate
url = https://github.com/transmissions11/solmate
15 changes: 15 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"tabWidth": 2,
"printWidth": 100,

"overrides": [
{
"files": "*.sol",
"options": {
"tabWidth": 4,
"printWidth": 120
}
}
]
}

1 change: 1 addition & 0 deletions lib/morpho-blue
Submodule morpho-blue added at 8e3522
1 change: 1 addition & 0 deletions lib/solmate
Submodule solmate added at 97bdb2
19 changes: 0 additions & 19 deletions script/Counter.s.sol

This file was deleted.

14 changes: 0 additions & 14 deletions src/Counter.sol

This file was deleted.

163 changes: 163 additions & 0 deletions src/LiquidationProtection.sol
QGarchery marked this conversation as resolved.
Show resolved Hide resolved
QGarchery marked this conversation as resolved.
Show resolved Hide resolved
peyha marked this conversation as resolved.
Show resolved Hide resolved
peyha marked this conversation as resolved.
Show resolved Hide resolved
peyha marked this conversation as resolved.
Show resolved Hide resolved
peyha marked this conversation as resolved.
Show resolved Hide resolved
peyha marked this conversation as resolved.
Show resolved Hide resolved
QGarchery marked this conversation as resolved.
Show resolved Hide resolved
QGarchery marked this conversation as resolved.
Show resolved Hide resolved
peyha marked this conversation as resolved.
Show resolved Hide resolved
peyha marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.19;
peyha marked this conversation as resolved.
Show resolved Hide resolved

import {Id, MarketParams, IMorpho, Position, Market} from "../lib/morpho-blue/src/interfaces/IMorpho.sol";
import {IOracle} from "../lib/morpho-blue/src/interfaces/IOracle.sol";
import {UtilsLib} from "../lib/morpho-blue/src/libraries/UtilsLib.sol";
import {MarketParamsLib} from "../lib/morpho-blue/src/libraries/MarketParamsLib.sol";
import {IMorphoLiquidateCallback} from "../lib/morpho-blue/src/interfaces/IMorphoCallbacks.sol";
import "../lib/morpho-blue/src/libraries/ConstantsLib.sol";
import {MathLib} from "../lib/morpho-blue/src/libraries/MathLib.sol";
import {SharesMathLib} from "../lib/morpho-blue/src/libraries/SharesMathLib.sol";
import {SafeTransferLib} from "../lib/solmate/src/utils/SafeTransferLib.sol";
MathisGD marked this conversation as resolved.
Show resolved Hide resolved
import {ERC20} from "../lib/solmate/src/tokens/ERC20.sol";

struct SubscriptionParams {
Id marketId;
address borrower;
uint256 slltv;
uint256 closeFactor;
uint256 liquidationIncentive;
}
MathisGD marked this conversation as resolved.
Show resolved Hide resolved

/// @title Morpho
/// @author Morpho Labs
/// @custom:contact [email protected]
/// @notice The Liquidation Protection Contract for Morpho
contract LiquidationProtection {
using MarketParamsLib for MarketParams;
using UtilsLib for uint256;
using SharesMathLib for uint256;
using MathLib for uint256;
using MathLib for uint128;
using SafeTransferLib for ERC20;

/* IMMUTABLE */
address immutable MORPHO = 0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb;

/* STORAGE */
mapping(uint256 => SubscriptionParams) subscriptions;
mapping(uint256 => bool) isValidSubscriptionId;
uint256 public nbSubscription;
MathisGD marked this conversation as resolved.
Show resolved Hide resolved

// TODO EIP-712 signature
// TODO authorize this contract on morpho
// TODO potential gas opti (keeping marketparams in SubscriptionParams instead of Id?)
peyha marked this conversation as resolved.
Show resolved Hide resolved

function subscribe(SubscriptionParams calldata subscriptionParams) public returns (uint256) {
IMorpho morpho = IMorpho(MORPHO);
MarketParams memory marketParams = morpho.idToMarketParams(subscriptionParams.marketId);

require(msg.sender == subscriptionParams.borrower, "Unauthorized account");
require(subscriptionParams.slltv < marketParams.lltv, "Liquidation threshold higher than market LLTV");
// should close factor be lower than 100% ?
// should there be a max liquidation incentive ?

isValidSubscriptionId[nbSubscription] = true;
subscriptions[nbSubscription] = subscriptionParams;

nbSubscription++;

return nbSubscription - 1;
peyha marked this conversation as resolved.
Show resolved Hide resolved
}

function unsubscribe(uint256 subscriptionId) public {
require(msg.sender == subscriptions[subscriptionId].borrower, "Unauthorized account");

isValidSubscriptionId[subscriptionId] = false;
}

function liquidate(
uint256 subscriptionId,
MarketParams calldata marketParams,
address borrower,
uint256 seizedAssets,
uint256 repaidShares,
bytes calldata data
) public {
require(isValidSubscriptionId[subscriptionId], "Non-valid subscription");
require(subscriptions[subscriptionId].borrower == borrower);
require(Id.unwrap(subscriptions[subscriptionId].marketId) == Id.unwrap(marketParams.id()));
require(UtilsLib.exactlyOneZero(seizedAssets, repaidShares), "Inconsistent input");
uint256 collateralPrice = IOracle(marketParams.oracle).price();
require(
!_isHealthy(marketParams.id(), borrower, collateralPrice, subscriptions[subscriptionId].slltv),
"Position is healthy"
);

IMorpho morpho = IMorpho(MORPHO);
// Compute seizedAssets or repaidShares and repaidAssets
Market memory marketState = morpho.market(marketParams.id());

{
colin-morpho marked this conversation as resolved.
Show resolved Hide resolved
uint256 liquidationIncentive = subscriptions[subscriptionId].liquidationIncentive;
if (seizedAssets > 0) {
uint256 seizedAssetsQuoted = seizedAssets.mulDivUp(collateralPrice, ORACLE_PRICE_SCALE);

repaidShares = seizedAssetsQuoted.wDivUp(liquidationIncentive).toSharesUp(
marketState.totalBorrowAssets,
marketState.totalBorrowShares
);
} else {
colin-morpho marked this conversation as resolved.
Show resolved Hide resolved
seizedAssets = repaidShares
.toAssetsDown(marketState.totalBorrowAssets, marketState.totalBorrowShares)
.wMulDown(liquidationIncentive)
.mulDivDown(ORACLE_PRICE_SCALE, collateralPrice);
}
}
uint256 repaidAssets = repaidShares.toAssetsUp(marketState.totalBorrowAssets, marketState.totalBorrowShares);

// Check if liquidation is ok with close factor
Position memory borrowerPosition = morpho.position(marketParams.id(), borrower);
require(
borrowerPosition.collateral.wMulDown(subscriptions[subscriptionId].closeFactor) > seizedAssets,
"Cannot liquidate more than close factor"
peyha marked this conversation as resolved.
Show resolved Hide resolved
);

bytes memory callbackData = abi.encode(marketParams, seizedAssets, repaidAssets, borrower, msg.sender, data);
morpho.repay(marketParams, 0, repaidShares, borrower, callbackData);

isValidSubscriptionId[subscriptionId] = false;
}

function onMorphoRepay(uint256 assets, bytes calldata callbackData) external {
(
MarketParams memory marketParams,
uint256 seizedAssets,
uint256 repaidAssets,
address borrower,
address liquidator,
bytes memory data
) = abi.decode(callbackData, (MarketParams, uint256, uint256, address, address, bytes));

IMorpho morpho = IMorpho(MORPHO);
morpho.withdrawCollateral(marketParams, seizedAssets, borrower, liquidator);

if (data.length > 0) IMorphoLiquidateCallback(msg.sender).onMorphoLiquidate(assets, data);

ERC20(marketParams.loanToken).safeTransferFrom(liquidator, address(this), repaidAssets);

ERC20(marketParams.loanToken).safeApprove(MORPHO, repaidAssets);
}

function _isHealthy(
Id id,
address borrower,
uint256 collateralPrice,
uint256 ltvThreshold
) internal view returns (bool) {
IMorpho morpho = IMorpho(MORPHO);
Position memory borrowerPosition = morpho.position(id, borrower);
Market memory marketState = morpho.market(id);

uint256 borrowed = uint256(borrowerPosition.borrowShares).toAssetsUp(
marketState.totalBorrowAssets,
marketState.totalBorrowShares
);
uint256 maxBorrow = uint256(borrowerPosition.collateral)
.mulDivDown(collateralPrice, ORACLE_PRICE_SCALE)
.wMulDown(ltvThreshold);

return maxBorrow >= borrowed;
}
}
79 changes: 79 additions & 0 deletions src/interfaces/IERC20.sol
peyha marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.19;

/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);

/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);

/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);

/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);

/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);

/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);

/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);

/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
24 changes: 0 additions & 24 deletions test/Counter.t.sol

This file was deleted.

Loading
Loading