Skip to content

Commit

Permalink
feat: batching in SortedTroves
Browse files Browse the repository at this point in the history
  • Loading branch information
danielattilasimon committed Apr 4, 2024
1 parent 8f52365 commit 11cd080
Show file tree
Hide file tree
Showing 10 changed files with 960 additions and 262 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 (bool exists, uint256 nextId, uint256 prevId, BatchId batchId);
function batches(BatchId _id) external view returns (uint256 head, uint256 tail);
}
Loading

0 comments on commit 11cd080

Please sign in to comment.