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

Batched nodes in SortedTroves #94

Merged
merged 12 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
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
Loading