Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sequence diamgrams for refinance and settlement #47

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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