MatchingEngine
Inherits: MorphoInternal
Author: Morpho Labs
Abstract contract with functions to promote or demote users to/from peer-to-peer.
Functions
_promoteSuppliers
Promotes suppliers on the underlying
market.
function _promoteSuppliers(address underlying, uint256 amount, uint256 maxIterations)
internal
returns (uint256, uint256);
Parameters
Name | Type | Description |
---|---|---|
underlying | address | The address of the underlying market on which to promote suppliers. |
amount | uint256 | The amount of underlying to promote. |
maxIterations | uint256 | The maximum number of iterations allowed during the matching process. |
_promoteBorrowers
Promotes borrowers on the underlying
market.
function _promoteBorrowers(address underlying, uint256 amount, uint256 maxIterations)
internal
returns (uint256, uint256);
Parameters
Name | Type | Description |
---|---|---|
underlying | address | The address of the underlying market on which to promote borrowers. |
amount | uint256 | The amount of underlying to promote. |
maxIterations | uint256 | The maximum number of iterations allowed during the matching process. |
_demoteSuppliers
Demotes suppliers on the underlying
market.
function _demoteSuppliers(address underlying, uint256 amount, uint256 maxIterations)
internal
returns (uint256 demoted);
Parameters
Name | Type | Description |
---|---|---|
underlying | address | The address of the underlying market on which to demote suppliers. |
amount | uint256 | The amount of underlying to demote. |
maxIterations | uint256 | The maximum number of iterations allowed during the matching process. |
_demoteBorrowers
Demotes borrowers on the underlying
market.
function _demoteBorrowers(address underlying, uint256 amount, uint256 maxIterations)
internal
returns (uint256 demoted);
Parameters
Name | Type | Description |
---|---|---|
underlying | address | The address of the underlying market on which to demote borrowers. |
amount | uint256 | The amount of underlying to demote. |
maxIterations | uint256 | The maximum number of iterations allowed during the matching process. |
_promoteOrDemote
Promotes or demotes users.
function _promoteOrDemote(
LogarithmicBuckets.Buckets storage poolBuckets,
LogarithmicBuckets.Buckets storage p2pBuckets,
Types.MatchingEngineVars memory vars
) internal returns (uint256 processed, uint256 iterationsDone);
Parameters
Name | Type | Description |
---|---|---|
poolBuckets | LogarithmicBuckets.Buckets | The pool buckets. |
p2pBuckets | LogarithmicBuckets.Buckets | |
vars | Types.MatchingEngineVars | The required matching engine variables to perform the matching process. |
_promote
Promotes a given amount in peer-to-peer.
function _promote(uint256 poolBalance, uint256 p2pBalance, Types.MarketSideIndexes256 memory indexes, uint256 remaining)
internal
pure
returns (uint256 newPoolBalance, uint256 newP2PBalance, uint256 newRemaining);
Parameters
Name | Type | Description |
---|---|---|
poolBalance | uint256 | The scaled balance of the user on the pool. |
p2pBalance | uint256 | The scaled balance of the user in peer-to-peer. |
indexes | Types.MarketSideIndexes256 | The indexes of the market. |
remaining | uint256 | The remaining amount to promote. |
_demote
Demotes a given amount in peer-to-peer.
function _demote(uint256 poolBalance, uint256 p2pBalance, Types.MarketSideIndexes256 memory indexes, uint256 remaining)
internal
pure
returns (uint256 newPoolBalance, uint256 newP2PBalance, uint256 newRemaining);
Parameters
Name | Type | Description |
---|---|---|
poolBalance | uint256 | The scaled balance of the user on the pool. |
p2pBalance | uint256 | The scaled balance of the user in peer-to-peer. |
indexes | Types.MarketSideIndexes256 | The indexes of the market. |
remaining | uint256 | The remaining amount to demote. |