Contract | Function Name | Modifiers | Description | Called When? | Called Why? | Call Does What? | Risks of Calling | Calls (sequential order DESC) | Called By | Function Signature |
---|---|---|---|---|---|---|---|---|---|---|
Spigot.sol | getOwnerTokens(address token) | view | Returns the amount of Revenue Tokens held by Spigot that the Owner can withdraw. |
| ||||||
Spigot.sol | getOperatorTokens(address token) | view | Returns the amount of Revenue Tokens held by Spigot that the Operator can withdraw. |
| ||||||
Spigot.sol | isWhitelisted(bytes4 functionSignature) | view | Returns if the function has been whitelisted across Revenue Contracts for the Operator to call in operate() | |||||||
Spigot.sol | getSetting(address revenueContract) | view | Returns the config for a Revenue Contract: - uint8 ownerSplit - % of revenue that goes to Owner. 0 decimals - bytes4 claimFunction - function selector on Revenue Contract to claim revenue - bytes4 transferOwnerFunction - function selector on Revenue Contract to relinquish ownership from Spigot | |||||||
Spigot.sol | owner() | view | Returns the address of the current Spigot Owner. |
| ||||||
Spigot.sol | operator() | view | Returns the address of the current Spigot Operator. |
| ||||||
Spigot.sol | claimRevenue(address revenueContract, bytes calldata claimData) | ANYONE | Claims Revenue Tokens earned by one or more Revenue Contracts and updates amount claimable by Owner and Operator.
If push payments: When revenue is sent directly to the Spigot without us doing anything. We must calculate how many have been sent to us and disburse. (push payments = | |||||||
Spigot.sol | addSpigot(address revenueContract, SpigotSettings memory setting) | onlyOwner | Attach a new Revenue Contract to a Spigot. MUST include revenue split + valid | Could add a malicious Revenue Contract and/or config that causes funds to be stolen from Spigot. | ||||||
Spigot.sol | updateWhitelistedFunction(bytes4 func, bool isAllowed) | onlyOwner | Allows the Owner to update Spigot whitelist of functions Operator can call on Revenue Contracts. This allows Operator to perform managerial tasks on its Revenue Contracts so they continue generating revenue while they are collateralized in the Spigot to repay debt. | Could add a malicious function on Revenue Contract that causes funds to be stolen from Spigot. | ||||||
Spigot.sol | claimOwnerTokens(address token, uint256 amount) | onlyOwner | Owner withdraws their share of Revenue Tokens that have already been claimed via claimRevenue() | |||||||
Spigot.sol | updateOwnerSplit(address revenueContract, uint8 split) | onlyOwner | Changes the revenue split between the Operator and the Owner based upon programmed conditions or otherwise if the Owner and Operator wish to change the split. | |||||||
Spigot.sol | updateOwner(address newOwner) | onlyOwner | Puts a new Owner in control the Spigot. | |||||||
Spigot.sol | removeSpigot(address revenueContract) | onlyOwner | - Calls | |||||||
Spigot.sol | claimOperatorTokens(address token, uint256 amount) | onlyOperator | - Operator withdraws their share of Revenue Tokens that have already been claimed via claimRevenue() | |||||||
Spigot.sol | operate(address revenueContract, bytes calldata msgData) | onlyOperator | - Allows an Operator to call the whitelisted functions on its Revenue Contracts attached to the Spigot and carry on its business as usual activities. | |||||||
Spigot.sol | updateOperator(address newOperator) | onlyOperator | - Puts a new Operator address in place to interact with the Revenue Contracts if ever this were needed. | |||||||
Line Of Credit.sol | nextInQ() | view | - Retrieves the next id in FIFO Lender repayment queue. - Returns null if no positions currently have debt (no reason to prioritize any Lender so no queue so no “next in queue”) - Returns the next position id in queue and the most up to date financial data on that position as of that block. | |||||||
Line Of Credit.sol | interestAccrued(bytes32 id) | view | - | |||||||
Line Of Credit.sol | counts() | view | - Returns tuple of current amount of open positions on Line vs total amount of elements in | |||||||
Line Of Credit.sol | init() | ANYONE | - Checks if all Line modules have been initialized properly. Namely checks that Spigot and Escrow contracts marked as collateral are actually owned by the line. - All modules are required to pass back an OK signal. If, and only if, all modules pass the check then the Line sets its status to ACTIVE and lenders and borrowers can start transacting on the contract. | |||||||
Line Of Credit.sol | accrueInterest() | ANYONE | - Accrues interest across all positions currently open on the Line and updates state. | - Borrower can repeatedly call to cause rounding down when calculating interest. According to our math, the gas costs of such an attack is mitigated due to pure gas price costs even for 1 position. This attack vector becomes more expensive the more Lenders so most feasible when only 1 Lender. | ||||||
Line Of Credit.sol | healthcheck() | ANYONE | - Checks all covenants programmed into Line contract and returns the current health status of the Line. - If borrower has broken covenants then status will be LIQUIDATABLE, otherwise it will usually be ACTIVE. | |||||||
Line Of Credit.sol | depositAndRepay(uint256 amount) | ANYONEwhileBorrowing | - Takes funds from callers wallet to repay Borrower’s debt. MUST repay next position in payment queue. - Can be called by anyone not just Borrower. | - ANYONE can repay so you might accidentally repay someone else’s debt | ||||||
Line Of Credit.sol | updateOutstandingDebt() | ANYONE | - Total debt owed by Borrower across all positions. Returns a tuple of (totalPrincipal, totalInterest). - Denominated in USD and 8 decimals. - Updates state with new interest accrued. | |||||||
Line Of Credit.sol | addCredit(uint128 dRate, uint128 fRate, uint256 amount, address token, address lender) | mutualConsentonlyLenderOrBorrowerwhileActive |
| - Could approve malicious token that can steal your funds (ass borrower or lender) - Create proposal with wrong terms (e.g. interest rate = 0%) that counterparty immediately accepts to exploit your fat finger mistake. - May add volatile token which could cause borrower to be liquidated while borrowing if price moves against them - | ||||||
Line Of Credit.sol | increaseCredit(bytes32 id, uint256 amount) | mutualConsentonlyLenderOrBorrowerwhileActive | Must have gone through | |||||||
Line Of Credit.sol | setRates(bytes32 id, uint128 dRate, uint128 fRate) | mutualConsentonlyLenderOrBorrower | Allows Borrower and Lender to agree to change the drawn rate and/or facility rate on an existing position. | |||||||
Line Of Credit.sol | mutualConsent(address signerOne, address signerTwo) | mutualConsent | Internal util function that allows for arbitrary 2/2 multisigs with dynamic participants on any function in our contract. Requires 2 different addresses to be signers and the exact same | |||||||
Line Of Credit.sol | borrow(bytes32 id, uint256 amount) | onlyBorrowerwhileActive | Must have gone through | |||||||
Line Of Credit.sol | depositAndClose() | onlyBorrowerwhileBorrowing | Takes funds from Borrower’s wallet to fully repay all outstanding debt and interest on position and then closes position permanently. MUST repay and close next position in payment queue | |||||||
Line Of Credit.sol | close(bytes32 id) | onlyBorrower | Allows Borrower to close any position with no outsanding debt. Takes funds from Borrower’s wallet to repay accrued facility fee and then closes position permanently. | |||||||
Line Of Credit.sol | declareInsolvent() | onlyArbiter | If the borrower is incapable of repaying the loan, there needs to be an attempt to make the lender whole | Called when the arbiter has determined that the borrower is incapable of repaying their loan. | Updates the Line’s status to | |||||
Line Of Credit.sol | revokeConsent(bytes calldata proposalData) | onlyLenderOrBorrower | If either a Borrower or Lender to create a proposed position (or update an existing position) and then changes their mind (e.g. params are wrong / unfavorable) they can revoke their proposal. This means the other party cannot complete the other half of | Either a Borrower or Lender wants to remove their proposal to create or update a position with specific terms on a Line Of Credit. | Checks that caller is owner of the proposal being revoked and then completely deletes the proposal in storage. | |||||
Line Of Credit.sol | withdraw(bytes32 id, uint256 amount) | onlyLender | ||||||||
Spigoted Line .sol | unused(address token) | view | Returns the amount of Credit Tokens that have been bought with Revenue Tokens from the Spigot and which haven't yet been withdrawn by a Lender or otherwise used by the Borrower to repay. The system ensures that the first Credit Token in the repayment queue is the one being bought. A Line can have multiple Credit Tokens being lent out and borrowed plus multiple Revenue Tokens being escrowed to repay the debt. This variable holds all of these excess tokens | |||||||
Spigoted Line .sol | updateOwnerSplit(address revenueContract) | ANYONE | Checks current status of Line and current owner split of Revenue Contract on Line’s Spigot. Based on status will update owner split if necessary.
if Line status is ACTIVE AND owner split isnt the Line’s | |||||||
Spigoted Line .sol | claimAndRepay() | onlyArbiter | Claims Revenue Tokens from the Spigot as Owner, trades them for Credit Tokens via a DEX and repays debt on next Lender in repayment queue.
Stores any bought Credit Tokens in excess of debt obligation + any leftover Revenue Tokens from trade into the Line’s | Similar to | ||||||
Spigoted Line .sol | claimAndTrade() | onlyArbiter | Claims Revenue Tokens from the Spigot as Owner, trades them for Credit Tokens via a DEX and immediately stores any bought Credit Tokens + any leftover Revenue Tokens from trade into the Line’s | Can be called at any time, but should be called only after | The “claim” in the function name can be misleading, and refers to fetching revenue from the Spigot, as opposed to “claiming” revenue from the revenue contract. The credit token first in-line (ie the token of the “active” position) is selected by default as the target token for the trade. The transfer and trading happens in the SpigotedLineLib’s | |||||
Spigoted Line .sol | enableSpigot(address revenueContract, ISpigotSettings calldata settings) | onlyArbiter | Calls | Could add a malicious Revenue Contract and/or config that causes funds to be stolen from Spigot. | ||||||
Spigoted Line .sol | updateWhitelist(address revenueContract, bytes4 operatorFunc) | onlyArbiter | Sets or updates the whitelisted functions that a Borrower (or whoever is Spigot’s Operator) can call on Revenue Contracts so they continue generating revenue while they are collateralized in the Spigot to repay debt. Only callable by an Arbiter. | Called any time. | The only way the borrower (ie the operator of the Line of Credit) can interact with privileged functions on their protocol ( revenue contract ) is via the | |||||
Spigoted Line .sol | addSpigot(address revenueContract, ISpigot.Setting calldata setting) | onlyArbiter | Enables automatic repayment of the loan by diverting revenue from the Borrower’s revenue generating contract/s. | Called before or after the borrower and lender have called addCredit(). Revenue cannot be used to repay the loan until a revenue stream has been added to the Line via this function. | Does not add a Spigot Contract (as it was already deployed with the line). Instead, can be thought of as “addRevenueStream” as it adds a revenue stream (contract) to the spigot settings struct. The settings are passed in with the original calldata when called on SpigotedLine, which passes the data to functions of the same name on the Spigot and then the SpigotLib. Settings include the revenue contract’s address, owners split, claim function selector, and transfer function selector. | Risk is that you add you revenue contract with incorrect claim transfer ownership selectors making it impossible to claim revenue | ||||
Spigoted Line .sol | useAndRepay(address token, uint256 amount) | onlyLenderOrBorrowerwhileBorrowing | Allows the Borrower or next Lender in repayment queue to use Credit Tokens stored in Line’s | |||||||
Spigoted Line .sol | releaseSpigot() | onlyArbiterOrBorrower | Transfers ownership of the entire Spigot from the Line of Credit to either the Borrower (if a Line of Credit has been been fully repaid) or to the Arbiter (if the Line of Credit is liquidatable). | |||||||
Spigoted Line .sol | sweep() | onlyArbiterOrBorrower | After a loan has been repaid, sends any remaining Revenue Tokens or Credit Tokens from a Spigot to the Borrower. In case of a Borrower default however (loan status = liquidatable), this function serves as a liquidation mechanism that is called in an effort to increase the Lenders' recovery rate and reduce the "loss given default (LGD)” | |||||||
Secured Line.sol | rollover(address newLine) | onlyBorrower | Helper function to allow Borrower to easily transfer settings and collateral from this line to a new line. Useful after ttl has expired and want to renew Line with minimal effort. Transfers Spigot and Escrow ownership to newLine. Arbiter functions on this Line will no longer work. The new, uninitialized Line deployed by borrower | |||||||
Secured Line.sol | liquidate() | onlyArbiter | Forcefully take collateral from Escrow and repay debt for lender. The current implementation just sends "liquidated" tokens to Arbiter to sell off how the deem fit and then manually repay with DepositAndRepay. | |||||||
Escrow.sol | enableCollateral(address token) | onlyArbiter | Called before a borrower can deposit a token as collateral | Prevents the use of malicious 4626 tokens and ensures deposited tokens have a valid price feed on the oracle. | Updates the mapping in the EscrowState struct (address → bool) to enable the token. Checks that the token is not native Eth, has the correct decimals, and that an oracle price feed is available. | |||||
Line Factory.sol | deploySpigot(address owner, address borrower, address operator) | ANYONE | Deploys a new Spigot with provided config and starts tracking it in the Debt DAO subgraph. | |||||||
Line Factory.sol | deployEscrow(uint32 minCRatio, address owner, address borrower) | ANYONE | Deploys a new Escrow with provided config and starts tracking it in the Debt DAO subgraph. | |||||||
Line Factory.sol | deploySecuredLine(address borrower, uint256 TTL) | ANYONE | Deploys a new Line of Credit using the arbiter, oracle, | |||||||
Line Factory.sol | deploySecuredLineWithConfig(CoreLineParams calldata coreParams) | ANYONE | Deploys a new Line of Credit using the arbiter, oracle for this LineFactory and the provided borrower, term length, | misconfigured | ||||||
Line Factory.sol | deploySecuredLineWithModules(
CoreLineParams calldata coreParams,
address mSpigot,
address mEscrow
) | ANYONE | Deploys a new Line of Credit using existing Spigot and Escrow contracts that have already been configured. | misconfigured | ||||||
Line Factory.sol | rolloverSecuredLine(address oldLine, address borrower, uint256 TTL) | ANYONE | Takes debt terms for an existing Line of Credit, copies them and deploys a new Line of Credit for a new (or same) borrower and term length. After this call succeeds, Borrower can call | |||||||
#
[](https://www.notion.so/71b1953b5f044fb08c26fb9505b29424)
[](https://www.notion.so/365b30675e2f451b822c1c12927753e3)
[](https://www.notion.so/4a4f648af0df4630889448f882b9011b)
[](https://www.notion.so/9f2b1ee0932543438b119bbb7df66db4)
[](https://www.notion.so/c59cb5a1b1e64811b457ed570d4e01ae)
[](https://www.notion.so/58338bf5a88b473b851e597c43abb32a)
[](https://www.notion.so/13003a53fb504ebcbb8e959306054cb7)
[](https://www.notion.so/cdc95a983cbc49a683f9bfb5b9774d63)
[](https://www.notion.so/0d3518395bfb4571baf87087eb2d88dc)
[](https://www.notion.so/5798f6f5893d422a9bbe6e5f33408029) | ||||||||||