Common User Flow Sequence Diagrams
LineOfCredit + Spigot + Escrow = SecuredLine
classDiagram
direction RL
SecuredLine <|-- EscrowedLine
SecuredLine <|-- SpigotedLine
EscrowedLine <|-- LineOfCredit
SpigotedLine <|-- LineOfCredit
SecuredLine ..> LineLib
Escrow *.. EscrowState : Struct
Credit ..* LineOfCredit: Struct
class EscrowedLine {
<<EscrowedLine.sol>>
+IEscrow escrow
-_init()
-_healthcheck()
-_liquidate()
-_canDeclareInsolvent()
-_rollover()
}
class LineOfCredit {
<<LineOfCredit.sol>>
-uint256 count
+uint256 deadline
+address borrower
+address arbiter
+IOracle oracle
+InterestRateCredit interestRate
+bytes32[] ids
+mapping[bytes32 ->Credit] credits
+LineLib.STATUS status
-_init()
-_healthcheck()
_canDeclareInsolvent()
-_updateOutstandingDebt()
-_accrue()
-_updateStatus()
-_createCredit()
-_repay()
-_close()
-_sortIntoQ()
+ [ anyone ] init()
+ [ anyone ] depositAndRepay()
+ [ anyone ] healthcheck()
+ [ anyone ] stepQ()
+ [ anyone ] updateOutstandingDebt()
+ [ anyone ] counts()
+ [ anyone ] accruteInterest()
+ [ anyone ] available()
+ [ anyone ] interestAccrued()
+ [ anyone ] nextInQ()
+ [ lender ] withdraw()
+ [ borrower | Lender ] addCredit()
+ [ borrower | Lender ] setRates()
+ [ borrower | lender ] close()
+ [ borrower ] depositAndClose()
+ [ borrower ] increaseCredit()
+ [ borrower ] borrow()
+ [ arbiter ] declareInsolvent()
}
class SecuredLine {
<<SecuredLine.sol>>
-_init() Linelib.STATUS
-_healthcheck() LineLib.STATUS
-_canDeclareInsolvent() bool
+ [ borrower ] rollover() bool
+ [ arbiter ] liquidate() uint256
}
class SpigotedLine {
<<SpigotedLine.sol>>
-uint8 MAX_SPLIT
-mapping[address->uint256] unusedTokens
+ISpigot spigot
+uint8 defaultRevenueSplit
+address swapTarget
-_init()
-_canDeclareInsolvent()
_claimAndTrade()
+ [ anyone ] tradeable()
+ [ anyone ] unused()
+ [ anyone ] updateOwnerSplit()
+ [ arbiter ] claimAndRepay()
+ [ arbiter ] claimAndTrade()
+ [ arbiter ] addSpigot()
+ [ arbiter ] updateWhitelist()
+ [ arbiter | borrower] releaseSpigot()
+ [ arbiter | borrower ] sweep()
+ [ borrower | lender ] useAndRepay()
}
class Escrow {
<<Escrow.sol>>
+uint32 minimumCollateralRatio
+address oracle
+address borrower
-EscrowState state
+ [ anyone ] line()
+ [ anyone ]isLiquidatable()
+ [ anyone ] addCollateral()
+ [ anyone ] getCollateralRatio()
+ [ anyone ] getCollateralValue()
+ [ arbiter ] enableCollateral()
+ [ borrower ] releaseCollateral()
+ [ LineOfCredit ] updateLine()
+ [ LineOfCredit ] liquidate()
}
class EscrowState {
<<EscrowLib.sol>>
-address line
-address[] collateralTokens
-mapping[address->bool] enabled
-mapping[address->IEscrow] deposited
}
class LineFactory {
<<LineFactory.sol>>
IModuleFactory factory
uint8 defaultRevenueSplit
uint8 MAX_SPLIT
uint32 defaultMinCRatio
+address arbiter
+address oracle
+address swapTarget
+ [ anyone ] deployEscrow()
+ [ anyone ] deploySpigot()
+ [ anyone ] deploySecuredLine()
+ [ anyone ] deploySecuredLineWithConfig()
+ [ anyone ] deploySecuredLineWithModules()
+ [ anyone ] rolloverSecuredLine()
}
class ModuleFactory {
<<ModuleFactory.sol>>
+ [ anyone ] deploySpigot()
+ [ anyone ] deployEscrow()
}
InterestRateCredit *.. LineOfCredit: interestRate
class InterestRateCredit {
<<InterestRateCredit.sol>>
-uint256 ONE_YEAR
-uint256 BASE_DENOMINATOR
-uint256 INTEREST_DENOMINATOR
-address lineContract
+mapping[bytes32->Rate] rates
-_accrueInterest()
-_calculateInterestOwed()
+ [ LineOfCredit ] accrueInterest()
+ [ LineOfCredit ] setRate()
}
class Rate {
<<IInterestRateCredit.sol>>
uint128 dRate
uint128 fRate
uint256 lastAccrued
}
Rate .. InterestRateCredit: Struct
class Credit {
<<ILineOfCredit.sol>>
+uint256 deposit
+uint256 principal
+uint256 interestAccrued
+uint256 interestRepaid
+uint8 decimals
+address token
+address lender
bool isOpen
}
class LineLib {
<<LineLib.sol>>
+address WETH
-_safeTransferFunds()
+ [ anyone ] sendOutTokenOrETH()
+ [ anyone ] receiveTokenOrETH()
+ [ anyone ] getBalance()
}
EscrowLib <|-- Escrow
class EscrowLib {
<<EscrowLib.sol>>
uint256 MAX_INT
-_getLatestCollateralRatio()
-_getCollateralValue()
+ [ anyone ] addCollateral()
+ [ anyone ] getCollateralRatio()
+ [ anyone ] getCollateralValue()
+ [ anyone ] isLiquidatable()
+ [ arbiter ] enableCollateral()
+ [ borrower ] releaseCollateral()
+ [ LineOfCredit ] liquidate()
+ [ LineOfCredit ] updateLine()
}
class Oracle {
<<Oracle.sol>>
FeedRegistryInterface registry
int256 NULL_PRICE
uint8 PRICE_DECIMALS
uint256 MAX_PRICE_LATENCY
+ [ anyone ] getLatestAnswer()
+ [ anyone ] _getLatestAnswer()
}
class Spigot {
<<Spigot.sol>>
SpigotState state
+ [ anyone ] owner()
+ [ anyone ] operator()
+ [ anyone ] claimRevenue()
+ [ anyone ] getOwnerTokens()
+ [ anyone ] getOperatorTokens()
+ [ anyone ] isWhitelisted()
+ [ anyone ] getSetting()
+ [ owner [LineOfCredit] ] claimOwnerTokens()
+ [ owner [LineOfCredit] ] addspigot()
+ [ owner [LineOfcredit] ] removeSpigot()
+ [ owner [LineOfcredit] ] updateOwnerSplit()
+ [ owner [LineOfcredit] ] updateOwner()
+ [ owner [LineOfcredit] ] updateWhitelistedFunction()
+ [ operator [Borrower] ] claimOperatorTokens()
+ [ operator [Borrower] ] operate()
+ [ operator | owner ] updateOperator()
}
class SpigotState {
<<ISpigot.sol>>
uint8 ownerSplit
bytes4 claimFunction
bytes4 transferOwnerFunction
}
Spigot *.. SpigotState : Struct
class CreditLib {
<<CreditLib.sol>>
+ [ anyone ] computeId()
+ [ anyone ] getOutstandingDebt()
+ [ anyone ] calculateValue()
+ [ anyone ] create()
+ [ anyone ] repay()
+ [ anyone ] withdraw()
+ [ anyone ] accrue()
}
CreditLib <|-- LineOfCredit
EscrowLib <|-- CreditLib
class CreditListLib {
<<CreditListLib.sol>>
+removePosition()
+stepQ()
}
CreditListLib <|-- LineOfCredit
class LineFactoryLib {
<<LineFactoryLib.sol>>
+transferModulesToLine()
+deploySecuredLine()
}
LineFactory --|> LineFactoryLib
LineLib <|-- LineOfCredit
LineLib <|-- EscrowLib
LineLib <|-- SpigotedLineLib
class MutualConsent {
<<MutualConstent.sol>>
MAX_DATA_LENGTH_BYTES
MIN_DATA_LENGTH_BYTES
+revokeConsent()
-_mutualConsent()
-_getNonCaller()
}
LineOfCredit <|-- MutualConsent
class SpigotedLineLib {
<<SpigotedLineLib.sol>>
MAX_SPLIT
+claimAndTrade()
+trade()
+rollover()
+canDeclareInsolvent()
+updateSplit()
+releaseSpigot()
+sweep()
}
SpigotedLineLib <|-- SecuredLine
SpigotedLineLib <|-- SpigotedLine
Pools
classDiagram
class DebtDAOPool {
>>Interfaces>>
ERC4626
ERC3156
ERC2612
>>Pool State>>
name 'Debt DAO Pool - Credit Coop DAI'
symbol 'ddpDAI-CCOOP'
ASSET DAI
Fees performance, deposit, withdraw, flash, collector, referral
}
class SecuredLine {
>>Interfaces>>
ILineOfCredit
ISecuredLine
>>State>>
credits - lender, token, deposit, principal, interestAccrued, interestRepaid, isOpen
deadline
Spigot
}
PoolDepositor --> PoolDelegate : trusts
PoolDelegate : Professional Credit Investor
PoolDepositor: Yield Farmers
PoolDepositor: Normies
PoolDepositor --> DebtDAOPool : deposits
PoolDelegate --> DebtDAOPool : owns
<<Actor>> PoolDelegate
<<Actor>> PoolDepositor
DebtDAOPool --> SecuredLine: invests
DebtDAOPool --> SecuredLine: borrows
DebtDAOPool --> SecuredLine: repays
Spigot --> DebtDAOPool: rev_recipient
DebtDAOPool --> Spigot: revenue
PoolDelegate --> SecuredLine: repays
Spigot --> SecuredLine: repays
Ecosystem Participants
Collector --> DebtDAOPool: collect_interest()
DebtDAOPool --> Collector: revenue
Referrer --> PoolDepositor: refers
DebtDAOPool --> Referrer: revenue
Snitch --> PoolDelegate: snitches on
Snitch --> DebtDAOPool: impair()/divest_vault()/emergency_repay()
DebtDAOPool --> Snitch: snitch rewards
DebtDAOPool --> PoolDelegate: liquidate first_loss_pool
Snitch --> Snitch: mev_auction_battles
Borrower
flowchart
A[Borrow] --> B[Earn revenue]
B --> C{TTL Expires}
C-->|YES| D[Arbiter Liquidates]
C-->|NO| E{Principal Repaid}
E-->|NO| B
E-->|YES| F[Close]
CRM API