-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/pricing-unit-tests
- Loading branch information
Showing
10 changed files
with
668 additions
and
144 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import {Ownable} from "solady/src/auth/Ownable.sol"; | ||
|
||
abstract contract PausableNonReentrant is Ownable { | ||
uint256 private constant _UNLOCKED = 0x1; | ||
uint256 private constant _LOCKED = 0x2; | ||
uint256 private constant _PAUSED = 0x3; | ||
|
||
uint256 private _state = _UNLOCKED; | ||
|
||
event Paused(); | ||
event Unpaused(); | ||
|
||
error IsPaused(); | ||
error IsLocked(); | ||
error NotPaused(); | ||
|
||
modifier pausableNonReentrant() { | ||
assembly { | ||
//If locked or paused, handle revert cases | ||
if gt(sload(_state.slot), _UNLOCKED) { | ||
if gt(sload(_state.slot), _LOCKED) { | ||
//Revert IsPaused | ||
mstore(0, 0x1309a563) | ||
revert(0x1c, 0x04) | ||
} | ||
//Revert IsLocked | ||
mstore(0, 0xcaa30f55) | ||
revert(0x1c, 0x04) | ||
} | ||
sstore(_state.slot, _LOCKED) | ||
} | ||
_; | ||
assembly { | ||
sstore(_state.slot, _UNLOCKED) | ||
} | ||
} | ||
|
||
function pause() external onlyOwner { | ||
assembly { | ||
//If locked, prevent owner from overriding state | ||
if eq(sload(_state.slot), _LOCKED) { | ||
//Revert IsLocked | ||
mstore(0, 0xcaa30f55) | ||
revert(0x1c, 0x04) | ||
} | ||
sstore(_state.slot, _PAUSED) | ||
} | ||
emit Paused(); | ||
} | ||
|
||
function unpause() external onlyOwner { | ||
assembly { | ||
//If not paused, prevent owner from overriding state | ||
if lt(sload(_state.slot), _PAUSED) { | ||
//Revert NotPaused | ||
mstore(0, 0x6cd60201) | ||
revert(0x1c, 0x04) | ||
} | ||
sstore(_state.slot, _UNLOCKED) | ||
} | ||
emit Unpaused(); | ||
} | ||
|
||
function paused() external view returns (bool) { | ||
return _state == _PAUSED; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.