Skip to content

Commit

Permalink
add sequence diamgrams for refinance and settlement
Browse files Browse the repository at this point in the history
  • Loading branch information
androolloyd committed Nov 3, 2023
1 parent 90411a2 commit ad7cf11
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
42 changes: 42 additions & 0 deletions mermaid/refinance.mmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
sequenceDiagram
title Starport Refinance Sequence Diagram
participant F as Fulfiller
participant R as Refinancer
participant L as Lender
participant R as Recaller


F->>LoanManager: refinance
LoanManager->>Pricing: isValidRefinance
Pricing->>LoanManager: (SpentItem[] ConsiderPayment, SpentItem[] CarryPayment, AdditionalTransfer[] AT)

LoanManager->>LoanManager: settle loan

loop Transfer 1->n ConsiderPayment items
R->>L: Move ConsiderPayment to Lender
end
opt CarryPayment length > 0
R->>Originator: Move CarryPayment to Originator
end

opt F is not Refinancer and F is not approved
loop Validate 1->n Caveats
LoanManager->>CaveatEnforcer: validate
end
end
opt AdditionalTransferItems length > 0
LoanManager->>LoanManager: validateAdditionalTransfers
loop 1->n
alt From is Borrower
B->>AdditionalTransferRecipient: AdditionalTransferItem from Borrower -> AdditionalTransferRecipient
else From is Lender
L->>AdditionalTransferRecipient: AdditionalTransferItem from Lender -> AdditionalTransferRecipient
else From is F
F->>AdditionalTransferRecipient: AdditionalTransferItem from Fulfiller -> AdditionalTransferRecipient
end
end
end

opt Lender is contract
LoanManager->>L: onERC721Received
end
35 changes: 35 additions & 0 deletions mermaid/settlement.mmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
sequenceDiagram
title Starport Settlement Sequence Diagram
participant F as Fulfiller

F->>Seaport: fulfillAdvancedOrder/matchAdvancedOrder
Seaport->>Custodian: generateOrder
Custodian->>SettlementHook: isActive
SettlementHook->>Custodian: (true/false)
alt Action is Repayment and SettlementHook is Active
Custodian->>Custodian: _beforeApprovalsSetHook
Custodian->>Custodian: _setOfferApprovalsWithSeaport
Custodian->>Pricing: getPaymentConsideration
Pricing->>Custodian: (SpentItem[] payment, SpentItem[] carry)
Custodian->>LoanManager: settle loan
else Action Settlement and Custodian->>SettlementHook: isActive is false
Custodian->>Custodian: _beforeGetSettlement
Custodian->>SettlementHandler: getSettlement
SettlementHandler->>Custodian: (ReceivedItem[] consideration, address authorized)
Custodian->>Custodian: _afterGetSettlement
alt authorized is address(0) || authorized is Fulfiller
Custodian->>Custodian: _beforeApprovalsSetHook
Custodian->>Custodian: _setOfferApprovalsWithSeaport
else authorized is loan handler || authorized is loan issuer
Custodian->>Custodian: _moveCollateralToAuthorized
Custodian->>Custodian: _beforeSettlementHandlerHook
alt authorized is loan handler
Custodian->>SettlementHandler: execute
Custodian->>Custodian: _afterSettlementHandlerHook
end
end
Custodian->>LoanManager: settle loan
opt Lender is contract
LoanManager->>Lender: onLoanSettledHook
end
end

0 comments on commit ad7cf11

Please sign in to comment.