Debt DAO Docs
Search…
⌃K

SpigotedLine.sol

Core functions and methods of SpigotedLine.sol
  • An integration between Spigot.sol and LineOfCredit.sol.
  • It owns the Spigot so it's important that it can properly manage and call Spigot.sol and doesn't lose ownership unless releaseSpigot() successfully executes.
  • Manages a Spigot's configuration based on the health status of a Line of Credit
  • Trades a DAO's Revenue Tokens for Credit Tokens owed to lenders using 0x protocol
  • Stores excess revenue or trade slippage in unused tokens for later use in repayment
  • Allows Borrowers to clawback escrowed tokens if a Line is fully repaid
  • Allows liquidating unused or the Spigot itself if a Line's status is LIQUIDATABLE
  • External calls to - 0x protocol, Spigot.sol
  • Libraries - LineLib.sol, SpigotedLineLib.sol
External Functions
function claimAndRepay(address claimToken, bytes calldata zeroExTradeData)external whileBorrowing nonReentrant returns (uint256)function claimAndTrade(address claimToken, bytes calldata zeroExTradeData)external whileBorrowing nonReentrant returns (uint256)
function unused(address token) external view returns (uint256)
function useAndRepay(uint256 amount) external whileBorrowing returns(bool)
function updateWhitelist(bytes4 func, bool allowed)external returns (bool)
function releaseSpigot(address to) external returns (bool)
function sweep(address to, address token) external nonReentrant returns (uint256)

SpigotedLine Methods

Many of the features of the Spigoted Line of Credit product depend on and call Spigot.sol. Read this in conjunction with methods for that contract, the Glossary and further product information herein.
Function
SpigotedLine Method
claimAndRepay()
Claims Revenue Tokens from the Spigot, trades them for Credit Tokens via a Dex and makes the Credit Tokens available to Lender withdraw.
claimAndTrade()
Claims Revenue Tokens from the Spigot and trades them for Credit Tokens via a Dex. The newly exchanged Credit Tokens are held in 'unusedTokens' ready for a Lender to using useAndRepay() and withdraw(). This feature allows a Borrower to take advantage of an increase in the relative value of the Revenue Token compared to the Credit Token and to in effect use less Revenue Tokens to repay the same amount of debt.
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/borrowed and multiple Revenue Tokens being escrowed to repay the debt.
unused()
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.
useAndRepay()
Allows a Lender or a Borrower to use Credit Tokens (that have already been claimed/traded) from 'unusedTokens' in order to repay debt.
updateWhitelist()
Sets or updates the whitelisted functions that a Borrower [as Operator] is allowed to perform on its Revenue Contracts so that it can still use those contracts whilst providing Revenue Tokens to repay credit. Only callable by an Arbiter.
releaseSpigot()
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).
sweep()
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)"