ITellerInterface.sol
1 pragma solidity >=0.6.0; 2 pragma experimental ABIEncoderV2; 3 import "../../../interfaces/IERC20_2.sol"; 4 5 6 interface ITellerInterface { 7 enum CommitmentCollateralType { 8 NONE, 9 ERC20, 10 ERC721, 11 ERC1155, 12 ERC721_ANY_ID, 13 ERC1155_ANY_ID 14 } 15 struct Commitment { 16 uint256 maxPrincipal; 17 uint32 expiration; 18 uint32 maxDuration; 19 uint16 minInterestRate; 20 address collateralTokenAddress; 21 uint256 collateralTokenId; 22 uint256 maxPrincipalPerCollateralAmount; 23 CommitmentCollateralType collateralTokenType; 24 address lender; 25 uint256 marketId; 26 address principalTokenAddress; 27 } 28 29 struct CommitmentV2 { 30 uint256 maxPrincipal; 31 uint32 expiration; 32 uint32 maxDuration; 33 uint16[] minInterestRate; 34 address[] collateralTokenAddress; 35 uint256[] collateralTokenId; //we use this for the MerkleRootHash for type ERC721_MERKLE_PROOF 36 uint256[] maxPrincipalPerCollateralAmount; 37 CommitmentCollateralType[] collateralTokenType; 38 address lender; 39 uint256 marketId; 40 address principalTokenAddress; 41 } 42 43 /** 44 * @notice Information on the terms of a loan request 45 * @param paymentCycleAmount Value of tokens expected to be repaid every payment cycle. 46 * @param paymentCycle Duration, in seconds, of how often a payment must be made. 47 * @param APR Annual percentage rating to be applied on repayments. (10000 == 100%) 48 */ 49 struct Terms { 50 uint256 paymentCycleAmount; 51 uint32 paymentCycle; 52 uint16 APR; 53 } 54 55 /** 56 * @notice Details about the loan. 57 * @param lendingToken The token address for the loan. 58 * @param principal The amount of tokens initially lent out. 59 * @param totalRepaid Payment struct that represents the total principal and interest amount repaid. 60 * @param timestamp Timestamp, in seconds, of when the bid was submitted by the borrower. 61 * @param acceptedTimestamp Timestamp, in seconds, of when the bid was accepted by the lender. 62 * @param lastRepaidTimestamp Timestamp, in seconds, of when the last payment was made 63 * @param loanDuration The duration of the loan. 64 */ 65 struct LoanDetails { 66 IERC20_2 lendingToken; 67 uint256 principal; 68 Payment totalRepaid; 69 uint32 timestamp; 70 uint32 acceptedTimestamp; 71 uint32 lastRepaidTimestamp; 72 uint32 loanDuration; 73 } 74 75 enum BidState { 76 NONEXISTENT, 77 PENDING, 78 CANCELED, 79 ACCEPTED, 80 PAID, 81 LIQUIDATED, 82 CLOSE 83 } 84 85 /** 86 * @notice Details about a loan request. 87 * @param borrower Account address who is requesting a loan. 88 * @param receiver Account address who will receive the loan amount. 89 * @param lender Account address who accepted and funded the loan request. 90 * @param marketplaceId ID of the marketplace the bid was submitted to. 91 * @param metadataURI ID of off chain metadata to find additional information of the loan request. 92 * @param loanDetails Struct of the specific loan details. 93 * @param terms Struct of the loan request terms. 94 * @param state Represents the current state of the loan. 95 */ 96 97 enum PaymentType { 98 EMI, 99 Bullet 100 } 101 102 enum PaymentCycleType { 103 Seconds, 104 Monthly 105 } 106 107 /** 108 * @notice Represents a total amount for a payment. 109 * @param principal Amount that counts towards the principal. 110 * @param interest Amount that counts toward interest. 111 */ 112 struct Payment { 113 uint256 principal; 114 uint256 interest; 115 } 116 117 struct Bid { 118 address borrower; 119 address receiver; 120 address lender; // if this is the LenderManager address, we use that .owner() as source of truth 121 uint256 marketplaceId; 122 bytes32 _metadataURI; // DEPRECATED 123 LoanDetails loanDetails; 124 Terms terms; 125 BidState state; 126 PaymentType paymentType; 127 } 128 129 function createCommitment(Commitment calldata _commitment, address[] calldata _borrowerAddressList) external returns (uint256 commitmentId_); 130 function withdraw(uint256 _bidId) external; 131 function acceptCommitment( 132 uint256 _commitmentId, 133 uint256 _principalAmount, 134 uint256 _collateralAmount, 135 uint256 _collateralTokenId,//0 for erc20's 136 address _collateralTokenAddress, 137 uint16 _interestRate, 138 uint32 _loanDuration 139 ) external returns (uint256 _bidId); 140 function repayLoanFull(uint256 _bidId) external; 141 142 function bids(uint256) external view returns (Bid memory); 143 function commitments(uint256) external view returns (CommitmentV2 memory); 144 }