diff --git a/docs/mermaid/origination.mmd b/docs/mermaid/origination.mmd index bddb08d1..51cc7961 100644 --- a/docs/mermaid/origination.mmd +++ b/docs/mermaid/origination.mmd @@ -2,18 +2,21 @@ sequenceDiagram title Starport Origination Sequence Diagram - Box green Orignation + Box blue Parties + participant AdditionalTransferRecipient participant Fulfiller + end + + Box green Orignation participant Starport participant CaveatEnforcer end - Box blue Assets - participant Lender + Box rgb(112,100,0) Assets participant Borrower participant Custodian + participant Lender participant FeeRecipient - participant AdditionalTransferRecipient end Fulfiller->>Starport: originate @@ -60,8 +63,4 @@ sequenceDiagram Fulfiller->>AdditionalTransferRecipient: AdditionalTransferItem from Fulfiller => AdditionalTransferRecipient end end - end - - opt Lender is contract - Starport->>Lender: onLoanOpened end \ No newline at end of file diff --git a/docs/mermaid/origination.svg b/docs/mermaid/origination.svg index eb4ec3ca..87c92b23 100644 --- a/docs/mermaid/origination.svg +++ b/docs/mermaid/origination.svg @@ -1 +1 @@ -AdditionalTransferRecipientFeeRecipientCustodianCaveatEnforcerLoanManagerBorrowerLenderFulfillerAdditionalTransferRecipientFeeRecipientCustodianCaveatEnforcerLoanManagerBorrowerLenderFulfillerloop[1->n]opt[F is not Borrower]loop[1->n]opt[F is not Lender]loop[Transfer 1->n collateral items]opt[Custodian is not default]loop[Transfer 1->n debt items]loop[Transfer 1->n fee items]opt[FeeItems length > 0]loop[Transfer 1->n debt items]alt[Fees Disabled][Fees Enabled]alt[From is Borrower][From is Lender][From is F]loop[1->n]opt[AdditionalTransferItems length > 0]opt[Lender is contract]originatevalidatevalidateMove Collateral to Custodiancustody (optional)Move debt to borrowercompute feeRakeMove Fee to FeeRecipientMove debt to BorrowerAdditionalTransferItem from Borrower => AdditionalTransferRecipientAdditionalTransferItem from Lender => AdditionalTransferRecipientAdditionalTransferItem from Fulfiller => AdditionalTransferRecipientonERC721ReceivedStarport Origination Sequence Diagram \ No newline at end of file +AssetsOrignationPartiesFeeRecipientLenderCustodianBorrowerCaveatEnforcerStarportFulfillerAdditionalTransferRecipientFeeRecipientLenderCustodianBorrowerCaveatEnforcerStarportFulfillerAdditionalTransferRecipientloop[1->n]opt[Fulfiller is notBorrower]loop[1->n]opt[Fulfiller is notLender]loop[Transfer 1->ncollateral items]opt[Custodian is not default]loop[Transfer 1->n debt items]loop[Transfer 1->n fee items]opt[FeeItems length > 0]loop[Transfer 1->n debt items]alt[Fees Disabled][Fees Enabled]alt[From is Borrower][From is Lender][From is F]loop[1->n]opt[AdditionalTransferItems length > 0]originatevalidatevalidatetransfer collateralcustody (optional)transfer debtMove Fee to FeeRecipientMove debt to Borrower - FeeAdditionalTransferItem from Borrower => AdditionalTransferRecipientAdditionalTransferItem from Lender => AdditionalTransferRecipientAdditionalTransferItem from Fulfiller => AdditionalTransferRecipientStarport Origination Sequence Diagram \ No newline at end of file diff --git a/docs/mermaid/refinance.mmd b/docs/mermaid/refinance.mmd index b522f4f5..fe9bb263 100644 --- a/docs/mermaid/refinance.mmd +++ b/docs/mermaid/refinance.mmd @@ -1,16 +1,32 @@ sequenceDiagram title Starport Refinance Sequence Diagram + + + + Box blue + participant AdditionalTransferRecipient participant F as Fulfiller - participant R as Refinancer - participant L as Lender - participant R as Recaller + end + Box green + participant Starport + participant Pricing + participant Settlement + participant CaveatEnforcer + end + Box rgb(112,100,0) + participant B as Borrower + participant R as New Lender + participant L as Original Lender + participant Originator as Original Originator + end F->>Starport: refinance Starport->>Pricing: getRefinanceConsideration Pricing->>Starport: (SpentItem[] ConsiderPayment, SpentItem[] CarryPayment, AdditionalTransfer[] AT) - Starport->>Starport: settle loan + Starport->>Starport: _settleLoan + Starport->>Settlement: postRepayment loop Transfer 1->n ConsiderPayment items R->>L: Move ConsiderPayment to Lender @@ -30,13 +46,10 @@ sequenceDiagram alt From is Borrower B->>AdditionalTransferRecipient: AdditionalTransferItem from Borrower -> AdditionalTransferRecipient else From is Lender - L->>AdditionalTransferRecipient: AdditionalTransferItem from Lender -> AdditionalTransferRecipient + R->>AdditionalTransferRecipient: AdditionalTransferItem from Refinancer -> AdditionalTransferRecipient else From is F F->>AdditionalTransferRecipient: AdditionalTransferItem from Fulfiller -> AdditionalTransferRecipient end end end - - opt Lender is contract - Starport->>L: onERC721Received - end \ No newline at end of file + Starport->>Starport: _issueLoan \ No newline at end of file diff --git a/docs/mermaid/refinance.svg b/docs/mermaid/refinance.svg new file mode 100644 index 00000000..298ed7dd --- /dev/null +++ b/docs/mermaid/refinance.svg @@ -0,0 +1 @@ +Original OriginatorOriginal LenderNew LenderBorrowerCaveatEnforcerSettlementPricingStarportFulfillerAdditionalTransferRecipientOriginal OriginatorOriginal LenderNew LenderBorrowerCaveatEnforcerSettlementPricingStarportFulfillerAdditionalTransferRecipientloop[Transfer 1->n ConsiderPaymentitems]opt[CarryPayment length > 0]loop[Validate 1->n Caveats]opt[F is not Refinancer and F is not approved]alt[From is Borrower][From is Lender][From is F]loop[1->n]opt[AdditionalTransferItems length > 0]refinancegetRefinanceConsideration(SpentItem[] ConsiderPayment, SpentItem[] CarryPayment, AdditionalTransfer[] AT)_settleLoanpostRepaymentMove ConsiderPayment to LenderMove CarryPayment to OriginatorvalidatevalidateAdditionalTransfersAdditionalTransferItem from Borrower -> AdditionalTransferRecipientAdditionalTransferItem from Refinancer -> AdditionalTransferRecipientAdditionalTransferItem from Fulfiller -> AdditionalTransferRecipient_issueLoanStarport Refinance Sequence Diagram \ No newline at end of file diff --git a/docs/mermaid/settlement.mmd b/docs/mermaid/settlement.mmd index 91403e42..6b7ed04b 100644 --- a/docs/mermaid/settlement.mmd +++ b/docs/mermaid/settlement.mmd @@ -1,35 +1,36 @@ sequenceDiagram title Starport Settlement Sequence Diagram + Box green participant F as Fulfiller - + participant Seaport + end + Box rgb(112, 100, 0) + participant Custodian + participant Status + participant Pricing + participant Settlement + participant Starport + participant Authorized + end F->>Seaport: fulfillAdvancedOrder/matchAdvancedOrder Seaport->>Custodian: generateOrder Custodian->>Status: isActive Status->>Custodian: (true/false) alt Action is Repayment and Status is Active - Custodian->>Custodian: _beforeApprovalsSetHook - Custodian->>Custodian: _setOfferApprovalsWithSeaport Custodian->>Pricing: getPaymentConsideration Pricing->>Custodian: (SpentItem[] payment, SpentItem[] carry) Custodian->>Starport: settle loan + Custodian->>Settlement: postRepayment else Action Settlement and Custodian->>Status: isActive is false - Custodian->>Custodian: _beforeGetSettlement - Custodian->>SettlementHandler: getSettlement - SettlementHandler->>Custodian: (ReceivedItem[] consideration, address authorized) - Custodian->>Custodian: _afterGetSettlement + Custodian->>Settlement: getSettlement + Settlement->>Custodian: (ReceivedItem[] consideration, address authorized) 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 + Custodian->>Authorized: transfer 1->n collateral end Custodian->>Starport: settle loan - opt Lender is contract - Starport->>Lender: onLoanSettledHook - end + Custodian->>Settlement: postSettlement + end diff --git a/docs/mermaid/settlement.svg b/docs/mermaid/settlement.svg new file mode 100644 index 00000000..16f61f47 --- /dev/null +++ b/docs/mermaid/settlement.svg @@ -0,0 +1 @@ +AuthorizedStarportSettlementPricingStatusCustodianSeaportFulfillerAuthorizedStarportSettlementPricingStatusCustodianSeaportFulfilleralt[authorized is address(0) || authorized is Fulfiller][authorized is loan handler || authorized is loan issuer]alt[Action is Repayment and Status is Active][Action Settlement and Custodian->>Status: isActive is false]fulfillAdvancedOrder/matchAdvancedOrdergenerateOrderisActive(true/false)getPaymentConsideration(SpentItem[] payment, SpentItem[] carry)settle loanpostRepaymentgetSettlement(ReceivedItem[] consideration, address authorized)_setOfferApprovalsWithSeaport_moveCollateralToAuthorizedtransfer 1->n collateralsettle loanpostSettlementStarport Settlement Sequence Diagram \ No newline at end of file