Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
f608f86
feat: add Liquidation Threshold in Core Pool on BNB
Debugger022 Jul 9, 2025
294f79e
fix: minor fix
Debugger022 Jul 10, 2025
fae7c2a
fix: fix test
Debugger022 Jul 15, 2025
e139b03
fix: fix test for liquidation threshold setter
Debugger022 Jul 15, 2025
7ba7bac
fix: spelling correction
Debugger022 Jul 18, 2025
624c961
test: add tests for borrow and user liquidation state
Debugger022 Jul 18, 2025
10d7785
test: add liquidation functionality test for Liquidator contract
Debugger022 Jul 19, 2025
b04a893
test: add test for XVS rewards claiming functionality
Debugger022 Jul 19, 2025
cb5a5db
feat: add market liquidation incentive and update liquidity calculations
Debugger022 Jul 23, 2025
a6d1926
refactor: add liquidation threshold and incentive params to Market st…
Debugger022 Jul 25, 2025
f16a9b5
feat!: migrate markets and Comptroller to Solidity 0.8.25
kkirka Jul 25, 2025
caeea51
refactor: update references to Market with new params
Debugger022 Jul 28, 2025
cf0354b
feat: add function to calculate health factor of an account
Debugger022 Jul 28, 2025
da9ef57
refactor: getter function for account health factors
Debugger022 Jul 28, 2025
8a38506
feat: add Toxic liquidation check in liquidate hook
Debugger022 Jul 28, 2025
ff22d54
feat: add dynamic liquidation incentive per asset
Debugger022 Jul 28, 2025
c4786ce
feat: update Liquidator contract to use dynamic liquidation incentive
Debugger022 Jul 28, 2025
1e8f708
refactor: update calculate SeizeTokens params
Debugger022 Jul 28, 2025
f7e3f53
fix: minor fix
Debugger022 Jul 28, 2025
91316bb
fix: lint
Debugger022 Jul 28, 2025
dc16c67
feat: add external Liquidation Manager contract
Debugger022 Jul 29, 2025
b526832
feat: setter for Liquidation Manager
Debugger022 Jul 29, 2025
348fbb3
feat: using Liquidation Manager functions
Debugger022 Jul 29, 2025
7eeeaa2
fix: fix comptroller unit tests
Debugger022 Jul 30, 2025
69f820e
refactor: update markets return params
Debugger022 Jul 30, 2025
4ea3457
fix: fix VAI tests
Debugger022 Jul 30, 2025
626f13a
Merge branch 'feat/solidity-0.8' into feat/VEN-3321
Debugger022 Jul 30, 2025
7b4fa89
feat: update solidity version of Liquidation manager
Debugger022 Jul 30, 2025
7e5a754
fix: minor fixes
Debugger022 Jul 30, 2025
9833f7b
refactor: update setter to include liquidation threshold
Debugger022 Jul 30, 2025
a5e7c7c
fix: setCollateralFactor and used constants
Debugger022 Jul 30, 2025
66ef1b5
test: fix comptroller tests
Debugger022 Jul 31, 2025
be83b61
test: fix tests
Debugger022 Jul 31, 2025
c90aa01
test: fix fork tests
Debugger022 Aug 1, 2025
1837cc7
feat: added natspec comments
Debugger022 Aug 4, 2025
4e8fa35
refactor: rename some functions and remove _setCollateralFactor
Debugger022 Aug 4, 2025
6dbb217
test: refactor tests to call updated functions
Debugger022 Aug 4, 2025
24aca7f
refactor: update treasury percent calculation
Debugger022 Aug 4, 2025
a06802b
refactor: consistent return statements
Debugger022 Aug 4, 2025
f65e34d
refactor: refactored struct and other calculations
Debugger022 Aug 4, 2025
b0705ce
refactor: remove healthFactorThreshold and liquidationIncentiveAvg
Debugger022 Aug 4, 2025
5868274
refactor: update close factor and dynamic incentive calculation
Debugger022 Aug 4, 2025
17be54c
feat: move calculation of seize tokens logic to comptrollerLens
Debugger022 Aug 4, 2025
c23fe60
refactor: rename averageLT to liquidationThresholdAvg
Debugger022 Aug 4, 2025
9955fb2
feat: Introduced weight function to replicate both CF and LT
Debugger022 Aug 5, 2025
2cf8104
refactor: fix health factor computation
Debugger022 Aug 5, 2025
ab6d0ae
refactor: consistent external function names
Debugger022 Aug 5, 2025
57e92f4
fix: remove comment
Debugger022 Aug 5, 2025
8b37991
refactor: move functions to FacetBase
Debugger022 Aug 5, 2025
6868164
refactor: deprecate old attributes
Debugger022 Aug 5, 2025
d653b5f
refactor: using revert
Debugger022 Aug 5, 2025
de84582
refactor: remove close factor settter and update liquidation incentiv…
Debugger022 Aug 5, 2025
5c84b79
refactor: update dynamic incentive calculation
Debugger022 Aug 5, 2025
800f8b6
feat: using reverts with custom errors
Debugger022 Aug 6, 2025
fe5c158
feat: optimized account position calculation
Debugger022 Aug 6, 2025
022a11d
feat: introduced baseCloseFactor and targetHealthFactor
Debugger022 Aug 6, 2025
7860cd6
feat: using baseCloseFactor to avoid zero incentive condition
Debugger022 Aug 6, 2025
56c25c2
refactor: update getHypotheticalHealthSnapshot to return shortfall too
Debugger022 Aug 7, 2025
0510348
feat: add baseCloseFactor, target HF and toggle mappings for dynamic …
Debugger022 Aug 7, 2025
f2f1034
refactor: remove baseCloseFactor and targetHealthFactor from comptroller
Debugger022 Aug 7, 2025
f091f37
feat: added events
Debugger022 Aug 7, 2025
107ead8
refactor: use generic ActionNotPaused error
Debugger022 Aug 7, 2025
3025a69
fix: update vTokenBalance after redeem
Debugger022 Aug 7, 2025
50a256f
refactor: remove setLiquidationIncentive and its alias
Debugger022 Aug 7, 2025
61ed23f
fix: remove setLiquidationIncentive and closeFactor references
Debugger022 Aug 7, 2025
a7b4206
fix: minor fix
Debugger022 Aug 7, 2025
e2f29c0
Revert "feat: using reverts with custom errors"
Debugger022 Aug 8, 2025
2fc0c2e
fix: stack too deep
Debugger022 Aug 8, 2025
13605fd
Merge branch 'feat/solidity-0.8' into feat/VEN-3321
Debugger022 Aug 8, 2025
0f6be8f
refactor: adjust baseCloseFactor to be dynamic
Debugger022 Aug 8, 2025
02dc4e7
refactor: remove unused constants and events
Debugger022 Aug 11, 2025
dfdf581
feat: optimization by reducing getHealthSnapshot calls
Debugger022 Aug 12, 2025
a17ef99
refactor: using weight in _calculateAccountPosition internally
Debugger022 Aug 12, 2025
3c6248c
refactor: update initialization of access control
Debugger022 Aug 12, 2025
b13414e
test: fix tests
Debugger022 Aug 12, 2025
768e5d2
feat: add dynamicLiquidationIncentive in AccountSnapshot struct
Debugger022 Aug 13, 2025
dd31a2c
refactor: extract non-risk fields from AccountSnapshot into new struct
Debugger022 Aug 13, 2025
5f0b4f8
refactor: revert VBNB changes
Debugger022 Aug 13, 2025
53b7562
fix: fix liquidator tests
Debugger022 Aug 14, 2025
9bc16b4
fix: fix VAI tests
Debugger022 Aug 18, 2025
ee861ff
refactor: fork tests
Debugger022 Aug 26, 2025
9ed3422
feat: update shares calculation in liquiator
Debugger022 Aug 28, 2025
c5aa0db
refactor: add liquidateCalculateSeizeTokens getter function
Debugger022 Aug 28, 2025
eb0c632
fix: fix setup and tests
Debugger022 Aug 28, 2025
151b14b
fix: fix unit tests
Debugger022 Aug 29, 2025
2339b40
Merge branch 'feat/VEN-3343' into feat/VEN-3321
Debugger022 Sep 3, 2025
0eee583
refactor: using WeightFunction in account snapshot calculation
Debugger022 Sep 3, 2025
26436f4
feat: add pool-level market liquidation incentive setter
Debugger022 Sep 3, 2025
13ec325
feat: add getter for VAISeizeTokens
Debugger022 Sep 3, 2025
bfac079
test: fix unit and fork tests
Debugger022 Sep 4, 2025
c3ce6f4
test: fix emode test
Debugger022 Sep 5, 2025
79ead60
Merge branch 'feat/VEN-3343' into feat/VEN-3321
Debugger022 Sep 5, 2025
6b30587
fix: minor fix
Debugger022 Sep 5, 2025
9d0d46b
refactor: moved getDynamicLiquidationIncentive to Market facet
Debugger022 Sep 8, 2025
78d3bf8
feat: reduced VBep20Delegate size
Debugger022 Sep 9, 2025
6254eaa
feat: add Liquidation Manager deployment script
Debugger022 Sep 9, 2025
fb48338
feat: add deployments for bsctestnet
Debugger022 Sep 9, 2025
1bd7262
feat: update repayAmount logic
Debugger022 Nov 3, 2025
d8edaa0
Merge branch 'feat/VEN-2985' into feat/VEN-3321
Debugger022 Nov 11, 2025
6758363
fix: minor fixes
Debugger022 Nov 11, 2025
c21100f
refactor: upgrade comptroller storage to ComptrollerV19Storage
Debugger022 Nov 13, 2025
bd5d35f
test: add fork test for dynamic liquidation mechanism
Debugger022 Nov 17, 2025
4c541a4
refactor: update liquidation calculations to use 1e18 for precision
Debugger022 Nov 18, 2025
4605b3b
Merge branch 'feat/VPD-233' into feat/VEN-3321
Debugger022 Nov 20, 2025
0297580
refactor: minor fixes
Debugger022 Nov 21, 2025
9ce8a5a
test: update TokenRedeemer test
Debugger022 Nov 26, 2025
1560cc2
test: add tests for liquidation scenario
Debugger022 Dec 1, 2025
5ad06f6
Merge branch 'develop' into feat/VEN-3321
Debugger022 Dec 2, 2025
1659da4
fix: lint
Debugger022 Dec 2, 2025
8b972e1
feat: updating deployment files
Debugger022 Dec 2, 2025
da82294
fix: minor fixes
Debugger022 Dec 2, 2025
f9d6dc0
feat: update bsctestnet deployment files
Debugger022 Dec 3, 2025
b29d11a
feat: update liquidationManager deployment
Debugger022 Dec 3, 2025
44b4d88
feat: updating deployment files
Debugger022 Dec 3, 2025
2361f5e
refactor: rename borrows to totalBorrows and update related logic
Debugger022 Dec 15, 2025
fff566c
refactor: update dynamic liquidation mechanism with respect to e-mode
Debugger022 Dec 15, 2025
9072738
refactor: remove liquidateVAICalculateSeizeTokens unused variant
Debugger022 Dec 15, 2025
545cd00
Merge branch 'develop' into feat/VEN-3321
Debugger022 Dec 15, 2025
b008927
fix: lint and prettier
Debugger022 Dec 16, 2025
f83afff
feat: updating deployment files
Debugger022 Dec 16, 2025
7dd2804
refactor: update tests for new liquidation changes
Debugger022 Dec 16, 2025
6fa0386
refactor: update fork tests for dynamic liquidation mechanism
Debugger022 Dec 16, 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
1 change: 1 addition & 0 deletions contracts/Comptroller/ComptrollerInterface.sol
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ interface ComptrollerInterface {

function getDynamicLiquidationIncentive(
address market,
address borrower,
uint256 liquidationThresholdAvg,
uint256 healthFactor
) external view returns (uint256);
Expand Down
53 changes: 53 additions & 0 deletions contracts/Comptroller/Diamond/facets/FacetBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,20 @@ contract FacetBase is IFacetBase, ComptrollerV19Storage, ExponentialNoError, Com
return xvs;
}

/**
* @notice Get the Effective Liquidation Incentive for a given account and market
* @dev The incentive is determined by the pool entered by the account and the specified vToken via
* `getLiquidationParams()`. If the pool is inactive, or if the vToken is not configured in the
* account's pool and `allowCorePoolFallback` is enabled, the core pool (poolId = 0) values are used
* @param account The account whose pool is used to determine the market's risk parameters
* @param vToken The address of the vToken market
* @return The liquidation Incentive for the vToken, scaled by 1e18
*/
function getEffectiveLiquidationIncentive(address account, address vToken) external view returns (uint256) {
(, , uint256 li) = getLiquidationParams(userPoolId[account], vToken);
return li;
}

/**
* @notice Returns the unique market index for the given poolId and vToken pair
* @dev Computes a unique key for a (poolId, market) pair used in the `_poolMarkets` mapping
Expand Down Expand Up @@ -312,4 +326,43 @@ contract FacetBase is IFacetBase, ComptrollerV19Storage, ExponentialNoError, Com

return (uint256(err), liquidity, shortfall);
}


/**
* @notice Returns only the core risk parameters (CF, LI, LT) for a vToken in a specific pool.
* @dev If the pool is inactive, or if the vToken is not configured in the given pool and
* `allowCorePoolFallback` is enabled, falls back to the core pool (poolId = 0) values.
* @return collateralFactorMantissa The max borrowable percentage of collateral, in mantissa.
* @return liquidationThresholdMantissa The threshold at which liquidation is triggered, in mantissa.
* @return maxLiquidationIncentiveMantissa The max liquidation incentive allowed for this market, in mantissa.
*/
function getLiquidationParams(
uint96 poolId,
address vToken
)
internal
view
returns (
uint256 collateralFactorMantissa,
uint256 liquidationThresholdMantissa,
uint256 maxLiquidationIncentiveMantissa
)
{
PoolData storage pool = pools[poolId];
Market storage market;

if (poolId == corePoolId || !pool.isActive) {
market = getCorePoolMarket(vToken);
} else {
PoolMarketId poolKey = getPoolMarketIndex(poolId, vToken);
Market storage poolMarket = _poolMarkets[poolKey];
market = (!poolMarket.isListed && pool.allowCorePoolFallback) ? getCorePoolMarket(vToken) : poolMarket;
}

return (
market.collateralFactorMantissa,
market.liquidationThresholdMantissa,
market.maxLiquidationIncentiveMantissa
);
}
}
61 changes: 6 additions & 55 deletions contracts/Comptroller/Diamond/facets/MarketFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -467,22 +467,24 @@ contract MarketFacet is IMarketFacet, FacetBase {
* @dev Calculates incentive based on provided health factor and liquidation threshold average,
* without reading borrower's account state from storage
* @param vToken The address of the vToken to be seized
* @param borrower The address of the borrower

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can expand the comment to include why the borrower parameter is needed

* @param liquidationThresholdAvg The average liquidation threshold for the borrower
* @param healthFactor The health factor of the borrower
* @return incentive The dynamic liquidation incentive for the borrower, scaled by 1e18
*/
function getDynamicLiquidationIncentive(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variant of getDynamicLiquidationIncentive (the one that doesn’t take the borrower address) is currently used only in the Liquidator contract, but we need to account for eMode groups there as well. The only cases where eMode can safely be ignored are vBNB and VAI.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

address vToken,
address borrower,
uint256 liquidationThresholdAvg,
uint256 healthFactor
) external view returns (uint256 incentive) {
Market storage market = getCorePoolMarket(vToken);
uint256 effectiveLiquidationIncentive = this.getEffectiveLiquidationIncentive(borrower,vToken);

incentive = liquidationManager.calculateDynamicLiquidationIncentive(
vToken,
healthFactor,
liquidationThresholdAvg,
market.maxLiquidationIncentiveMantissa
effectiveLiquidationIncentive
);
}

Expand All @@ -498,7 +500,7 @@ contract MarketFacet is IMarketFacet, FacetBase {
address borrower,
address vToken
) external view returns (uint256 incentive) {
Market storage market = getCorePoolMarket(vToken);
uint256 effectiveLiquidationIncentive = this.getEffectiveLiquidationIncentive(borrower,vToken);
(
uint256 err,
ComptrollerLensInterface.AccountSnapshot memory snapshot

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not required, but it might be cleaner to define AccountSnapshot outside the interface and import it directly, rather than referencing it through the interface.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can keep AccountSnapshot as it is for now .

Expand All @@ -517,7 +519,7 @@ contract MarketFacet is IMarketFacet, FacetBase {
vToken,
snapshot.healthFactor,
snapshot.liquidationThresholdAvg,
market.maxLiquidationIncentiveMantissa
effectiveLiquidationIncentive
);
}

Expand Down Expand Up @@ -575,20 +577,6 @@ contract MarketFacet is IMarketFacet, FacetBase {
else revert InvalidWeightingStrategy(weightingStrategy);
}

/**
* @notice Get the Effective Liquidation Incentive for a given account and market
* @dev The incentive is determined by the pool entered by the account and the specified vToken via
* `getLiquidationParams()`. If the pool is inactive, or if the vToken is not configured in the
* account's pool and `allowCorePoolFallback` is enabled, the core pool (poolId = 0) values are used
* @param account The account whose pool is used to determine the market's risk parameters
* @param vToken The address of the vToken market
* @return The liquidation Incentive for the vToken, scaled by 1e18
*/
function getEffectiveLiquidationIncentive(address account, address vToken) external view returns (uint256) {
(, , uint256 li) = getLiquidationParams(userPoolId[account], vToken);
return li;
}

/**
* @notice Returns the full list of vTokens for a given pool ID.
* @param poolId The ID of the pool whose vTokens are being queried.
Expand Down Expand Up @@ -786,41 +774,4 @@ contract MarketFacet is IMarketFacet, FacetBase {
emit PoolMarketInitialized(poolId, vToken);
}

/**
* @notice Returns only the core risk parameters (CF, LI, LT) for a vToken in a specific pool.
* @dev If the pool is inactive, or if the vToken is not configured in the given pool and
* `allowCorePoolFallback` is enabled, falls back to the core pool (poolId = 0) values.
* @return collateralFactorMantissa The max borrowable percentage of collateral, in mantissa.
* @return liquidationThresholdMantissa The threshold at which liquidation is triggered, in mantissa.
* @return maxLiquidationIncentiveMantissa The max liquidation incentive allowed for this market, in mantissa.
*/
function getLiquidationParams(
uint96 poolId,
address vToken
)
internal
view
returns (
uint256 collateralFactorMantissa,
uint256 liquidationThresholdMantissa,
uint256 maxLiquidationIncentiveMantissa
)
{
PoolData storage pool = pools[poolId];
Market storage market;

if (poolId == corePoolId || !pool.isActive) {
market = getCorePoolMarket(vToken);
} else {
PoolMarketId poolKey = getPoolMarketIndex(poolId, vToken);
Market storage poolMarket = _poolMarkets[poolKey];
market = (!poolMarket.isListed && pool.allowCorePoolFallback) ? getCorePoolMarket(vToken) : poolMarket;
}

return (
market.collateralFactorMantissa,
market.liquidationThresholdMantissa,
market.maxLiquidationIncentiveMantissa
);
}
}
4 changes: 2 additions & 2 deletions contracts/Comptroller/Diamond/facets/PolicyFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,14 @@ contract PolicyFacet is IPolicyFacet, XVSRewardsHelper {
return uint256(Error.INSUFFICIENT_SHORTFALL);
}

Market storage marketCollateral = getCorePoolMarket(vTokenCollateral);
uint256 effectiveLiquidationIncentive = this.getEffectiveLiquidationIncentive(borrower, vTokenCollateral);
uint256 closeFactor = liquidationManager.calculateDynamicCloseFactor(
vTokenBorrowed,
borrowBalance,
snapshot.liquidationThresholdAvg,
snapshot.totalCollateral,
snapshot.dynamicLiquidationIncentiveMantissa,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we calculating snapshot.dynamicLiquidationIncentiveMantissa when building the snapshot?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The liquidateBorrowAllowed function is externally called by liquidateBorrow function which can only be called from liquidator contract by the liquidator. In this function, we calculate the snapshot.dynamicLiquidationIncentiveMantissa internally .

marketCollateral.maxLiquidationIncentiveMantissa
effectiveLiquidationIncentive
);

// The liquidator may not repay more than what is allowed by the closeFactor
Expand Down
104 changes: 53 additions & 51 deletions contracts/Comptroller/Diamond/facets/SetterFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -618,57 +618,6 @@ contract SetterFacet is ISetterFacet, FacetBase {
xvsVToken = xvsVToken_;
}

/**
* @notice This function is used to set the liquidation manager address which is responsible for managing
* liquidations in the protocol.
* @dev Allows the contract admin to set the liquidation manager address used by the Comptroller
* @param liquidationManager_ The new liquidation manager address
*/
function __setLiquidationManager(
address liquidationManager_
) internal compareAddress(address(liquidationManager), liquidationManager_) {
ensureNonzeroAddress(liquidationManager_);
emit NewLiquidationManager(liquidationManager, LiquidationManager(liquidationManager_));
liquidationManager = LiquidationManager(liquidationManager_);
}

/**
* @notice Set the max liquidation incentive for a market
* @param poolId The ID of the pool.
* @param vToken The market to set the max liquidation incentive for
* @param newMaxLiquidationIncentive The new max liquidation incentive, scaled by 1e18
* @return uint256 0=success, otherwise reverted
*/
function __setMarketMaxLiquidationIncentive(
uint96 poolId,
address vToken,
uint256 newMaxLiquidationIncentive
)
internal
compareValue(
_poolMarkets[getPoolMarketIndex(poolId, vToken)].maxLiquidationIncentiveMantissa,
newMaxLiquidationIncentive
)
returns (uint256)
{
// Check if pool exists
if (poolId > lastPoolId) revert PoolDoesNotExist(poolId);

Market storage market = _poolMarkets[getPoolMarketIndex(poolId, vToken)];
ensureListed(market);

require(newMaxLiquidationIncentive >= mantissaOne, "incentive < mantissaOne");
// Emit event with old incentive, new incentive
emit NewMarketLiquidationIncentive(
poolId,
vToken,
market.maxLiquidationIncentiveMantissa,
newMaxLiquidationIncentive
);
// Set liquidation incentive to new incentive
market.maxLiquidationIncentiveMantissa = newMaxLiquidationIncentive;
return uint256(Error.NO_ERROR);
}

/**
* @notice Adds/Removes an account to the flash loan whitelist
Expand Down Expand Up @@ -810,6 +759,59 @@ contract SetterFacet is ISetterFacet, FacetBase {
m.isBorrowAllowed = borrowAllowed;
}


/**
* @notice This function is used to set the liquidation manager address which is responsible for managing
* liquidations in the protocol.
* @dev Allows the contract admin to set the liquidation manager address used by the Comptroller
* @param liquidationManager_ The new liquidation manager address
*/
function __setLiquidationManager(
address liquidationManager_
) internal compareAddress(address(liquidationManager), liquidationManager_) {
ensureNonzeroAddress(liquidationManager_);
emit NewLiquidationManager(liquidationManager, LiquidationManager(liquidationManager_));
liquidationManager = LiquidationManager(liquidationManager_);
}

/**
* @notice Set the max liquidation incentive for a market
* @param poolId The ID of the pool.
* @param vToken The market to set the max liquidation incentive for
* @param newMaxLiquidationIncentive The new max liquidation incentive, scaled by 1e18
* @return uint256 0=success, otherwise reverted
*/
function __setMarketMaxLiquidationIncentive(
uint96 poolId,
address vToken,
uint256 newMaxLiquidationIncentive
)
internal
compareValue(
_poolMarkets[getPoolMarketIndex(poolId, vToken)].maxLiquidationIncentiveMantissa,
newMaxLiquidationIncentive
)
returns (uint256)
{
// Check if pool exists
if (poolId > lastPoolId) revert PoolDoesNotExist(poolId);

Market storage market = _poolMarkets[getPoolMarketIndex(poolId, vToken)];
ensureListed(market);

require(newMaxLiquidationIncentive >= mantissaOne, "incentive < mantissaOne");
// Emit event with old incentive, new incentive
emit NewMarketLiquidationIncentive(
poolId,
vToken,
market.maxLiquidationIncentiveMantissa,
newMaxLiquidationIncentive
);
// Set liquidation incentive to new incentive
market.maxLiquidationIncentiveMantissa = newMaxLiquidationIncentive;
return uint256(Error.NO_ERROR);
}

/**
* @dev Updates the valid price oracle. Used by _setPriceOracle and setPriceOracle
* @param newOracle The new price oracle to be set
Expand Down
2 changes: 2 additions & 0 deletions contracts/Comptroller/Diamond/interfaces/IFacetBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ interface IFacetBase {
*/
function getXVSAddress() external view returns (address);

function getEffectiveLiquidationIncentive(address account, address vToken) external view returns (uint256);

function getPoolMarketIndex(uint96 poolId, address vToken) external pure returns (PoolMarketId);

function corePoolId() external pure returns (uint96);
Expand Down
2 changes: 1 addition & 1 deletion contracts/Comptroller/Diamond/interfaces/IMarketFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ interface IMarketFacet {

function getDynamicLiquidationIncentive(
address vToken,
address borrower,
uint256 liquidationThresholdAvg,
uint256 healthFactor
) external view returns (uint256);
Expand All @@ -115,7 +116,6 @@ interface IMarketFacet {
WeightFunction weightingStrategy
) external view returns (uint256);

function getEffectiveLiquidationIncentive(address account, address vToken) external view returns (uint256);

function getPoolVTokens(uint96 poolId) external view returns (address[] memory);
}
1 change: 1 addition & 0 deletions contracts/InterfacesV8.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ interface IComptroller {

function getDynamicLiquidationIncentive(
address vToken,
address borrower,
uint256 liquidationThresholdAvg,
uint256 healthFactor
) external view returns (uint256);
Expand Down
5 changes: 2 additions & 3 deletions contracts/Lens/ComptrollerLens.sol
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,11 @@ contract ComptrollerLens is ComptrollerLensInterface, ComptrollerErrorReporter,
VToken asset = assets[i];

// Read the balances and exchange rate from the vToken
(vars.err, vars.vTokenBalance, vars.borrowBalance, vars.exchangeRateMantissa) = asset.getAccountSnapshot(
(errorCode, vars.vTokenBalance, vars.borrowBalance, vars.exchangeRateMantissa) = asset.getAccountSnapshot(
account
);

if (vars.err != 0) {
errorCode = vars.err;
if (errorCode != 0) {
return (errorCode, snapshot);
}

Expand Down
3 changes: 3 additions & 0 deletions contracts/Liquidator/Liquidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,14 @@ contract Liquidator is Ownable2StepUpgradeable, ReentrancyGuardUpgradeable, Liqu
address(vTokenCollateral),
repayAmount
);

uint256 totalIncentive = comptroller.getDynamicLiquidationIncentive(
address(vTokenCollateral),
borrower,
snapshot.liquidationThresholdAvg,
snapshot.healthFactor
);

snapshot.dynamicLiquidationIncentiveMantissa = totalIncentive;

_checkForceVAILiquidate(vToken, borrower);
Expand Down
2 changes: 0 additions & 2 deletions contracts/Tokens/VTokens/legacy/ComptrollerInterface.sol
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ contract ComptrollerInterface {
/*** Liquidity/Liquidation Calculations ***/

function liquidateCalculateSeizeTokens(
address borrower,
address vTokenBorrowed,
address vTokenCollateral,
uint repayAmount
Expand All @@ -103,7 +102,6 @@ contract ComptrollerInterface {
function setMintedVAIOf(address owner, uint amount) external returns (uint);

function liquidateVAICalculateSeizeTokens(
address borrower,
address vTokenCollateral,
uint repayAmount
) external view returns (uint, uint);
Expand Down
Loading