Skip to content

Commit

Permalink
Merge pull request #94 from liquity/batch-delegation
Browse files Browse the repository at this point in the history
Batched nodes in SortedTroves
  • Loading branch information
danielattilasimon committed Apr 11, 2024
2 parents 0e2cb37 + 0a89944 commit 7edba5d
Show file tree
Hide file tree
Showing 12 changed files with 994 additions and 275 deletions.
36 changes: 19 additions & 17 deletions contracts/src/Interfaces/ISortedTroves.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,46 @@
pragma solidity 0.8.18;

import "./ITroveManager.sol";
import {BatchId, BATCH_ID_ZERO} from "../Types/BatchId.sol";

// TODO
//type Id is uint256;
//type Value is uint256;


// Common interface for the SortedTroves Doubly Linked List.
interface ISortedTroves {
function borrowerOperationsAddress() external view returns (address);
function troveManager() external view returns (ITroveManager);
// -- Mutating functions (permissioned) --

function setParams(uint256 _size, address _TroveManagerAddress, address _borrowerOperationsAddress) external;
function setAddresses(address _troveManagerAddress, address _borrowerOperationsAddress) external;

function insert(uint256 _id, uint256 _value, uint256 _prevId, uint256 _nextId) external;
function insert(uint256 _id, uint256 _annualInterestRate, uint256 _prevId, uint256 _nextId) external;
function insertIntoBatch(uint256 _troveId, BatchId _batchId, uint256 _annualInterestRate, uint256 _prevId, uint256 _nextId) external;

function remove(uint256 _id) external;
function removeFromBatch(uint256 _id) external;

function reInsert(uint256 _id, uint256 _newValue, uint256 _prevId, uint256 _nextId) external;
function reInsert(uint256 _id, uint256 _newAnnualInterestRate, uint256 _prevId, uint256 _nextId) external;
function reInsertBatch(BatchId _id, uint256 _newAnnualInterestRate, uint256 _prevId, uint256 _nextId) external;

function contains(uint256 _id) external view returns (bool);
// -- View functions --

function isFull() external view returns (bool);
function contains(uint256 _id) external view returns (bool);
function isBatchedNode(uint256 _id) external view returns (bool);

function isEmpty() external view returns (bool);

function getSize() external view returns (uint256);

function getMaxSize() external view returns (uint256);

function getFirst() external view returns (uint256);

function getLast() external view returns (uint256);

function getNext(uint256 _id) external view returns (uint256);

function getPrev(uint256 _id) external view returns (uint256);

function validInsertPosition(uint256 _value, uint256 _prevId, uint256 _nextId) external view returns (bool);
function validInsertPosition(uint256 _annualInterestRate, uint256 _prevId, uint256 _nextId) external view returns (bool);
function findInsertPosition(uint256 _annualInterestRate, uint256 _prevId, uint256 _nextId) external view returns (uint256, uint256);

function findInsertPosition(uint256 _value, uint256 _prevId, uint256 _nextId) external view returns (uint256, uint256);
// Public state variable getters
function borrowerOperationsAddress() external view returns (address);
function troveManager() external view returns (ITroveManager);
function size() external view returns (uint256);
function nodes(uint256 _id) external view returns (uint256 nextId, uint256 prevId, BatchId batchId, bool exists);
function batches(BatchId _id) external view returns (uint256 head, uint256 tail);
}
Loading

0 comments on commit 7edba5d

Please sign in to comment.