Custodian
Inherits: ERC721, ContractOffererInterface
State Variables
SP
Starport public immutable SP;
seaport
address public immutable seaport;
Functions
constructor
constructor(Starport SP_, address seaport_);
name
The name of the ERC721 contract
function name() public pure override returns (string memory);
Returns
Name | Type | Description |
---|---|---|
<none> | string | string The name of the contract |
symbol
The symbol of the ERC721 contract
function symbol() public pure override returns (string memory);
Returns
Name | Type | Description |
---|---|---|
<none> | string | string The symbol of the contract |
tokenURI
ERC-721 tokenURI override
function tokenURI(uint256 loanId) public view override returns (string memory);
Parameters
Name | Type | Description |
---|---|---|
loanId | uint256 | The id of the custody token/loan |
Returns
Name | Type | Description |
---|---|---|
<none> | string | string URI of the custody token/loan |
supportsInterface
Helper to determine if an interface is supported by this contract
function supportsInterface(bytes4 interfaceId) public view override (ERC721, ContractOffererInterface) returns (bool);
Parameters
Name | Type | Description |
---|---|---|
interfaceId | bytes4 | The interface to check |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool Returns true if the interface is supported |
onERC1155Received
onERC1155Received handler, if we are able to increment the counter in seaport that means we have not entered into seaport we dont add for ERC-721 as they are able to ignore the on handler call as apart of the spec revert with NotEnteredViaSeaport()
function onERC1155Received(address, address, uint256, uint256, bytes calldata) public virtual returns (bytes4);
mint
Mints a custody token for a loan.
function mint(Starport.Loan calldata loan) external;
Parameters
Name | Type | Description |
---|---|---|
loan | Starport.Loan | The loan to mint a custody token for |
mintWithApprovalSet
Mints a custody token for a loan.
function mintWithApprovalSet(Starport.Loan calldata loan, address approvedTo) external;
Parameters
Name | Type | Description |
---|---|---|
loan | Starport.Loan | The loan to mint a custody token for |
approvedTo | address | The address with pre approvals set |
_validateAndMint
internal helper that validates and mints a custody token for a loan.
function _validateAndMint(Starport.Loan calldata loan) internal returns (uint256 loanId);
Parameters
Name | Type | Description |
---|---|---|
loan | Starport.Loan | The loan to mint a custody token for |
ratifyOrder
Generates the order for this contract offerer
function ratifyOrder(SpentItem[] calldata, ReceivedItem[] calldata, bytes calldata, bytes32[] calldata, uint256)
external
view
onlySeaport
returns (bytes4 ratifyOrderMagicValue);
Returns
Name | Type | Description |
---|---|---|
ratifyOrderMagicValue | bytes4 | The magic value returned by the ratify |
generateOrder
Generates the order for this contract offerer
function generateOrder(address fulfiller, SpentItem[] calldata, SpentItem[] calldata, bytes calldata context)
external
onlySeaport
returns (SpentItem[] memory offer, ReceivedItem[] memory consideration);
Parameters
Name | Type | Description |
---|---|---|
fulfiller | address | The address of the contract fulfiller |
<none> | SpentItem[] | |
<none> | SpentItem[] | |
context | bytes | The context of the order |
Returns
Name | Type | Description |
---|---|---|
offer | SpentItem[] | The items spent by the order |
consideration | ReceivedItem[] | The items received by the order |
custody
If any additional state updates are needed when taking custody of a loan
function custody(Starport.Loan memory loan) external virtual onlyStarport returns (bytes4 selector);
Parameters
Name | Type | Description |
---|---|---|
loan | Starport.Loan | The loan that was just placed into custody |
Returns
Name | Type | Description |
---|---|---|
selector | bytes4 | The function selector of the custody method |
getSeaportMetadata
Returns metadata on how to interact with the offerer contract
function getSeaportMetadata() external pure returns (string memory, Schema[] memory schemas);
Returns
Name | Type | Description |
---|---|---|
<none> | string | string The name of the contract |
schemas | Schema[] | An array of supported schemas |
getBorrower
Fetches the borrower of the loan, first checks to see if we've minted the token for the loan
function getBorrower(Starport.Loan memory loan) public view returns (address);
Parameters
Name | Type | Description |
---|---|---|
loan | Starport.Loan | Loan to get the borrower of |
Returns
Name | Type | Description |
---|---|---|
<none> | address | address The address of the loan borrower(returns the ownerOf the token if any) defaults to loan.borrower |
previewOrder
Previews the order for this contract offerer
function previewOrder(
address caller,
address fulfiller,
SpentItem[] calldata,
SpentItem[] calldata,
bytes calldata context
) public view returns (SpentItem[] memory offer, ReceivedItem[] memory consideration);
Parameters
Name | Type | Description |
---|---|---|
caller | address | The address of the seaport contract |
fulfiller | address | The address of the contract fulfiller |
<none> | SpentItem[] | |
<none> | SpentItem[] | |
context | bytes | The context of the order |
Returns
Name | Type | Description |
---|---|---|
offer | SpentItem[] | The items spent by the order |
consideration | ReceivedItem[] | The items received by the order |
_enableAssetWithSeaport
Enables the collateral deposited to be spent via seaport
function _enableAssetWithSeaport(SpentItem memory offer) internal;
Parameters
Name | Type | Description |
---|---|---|
offer | SpentItem | The item to make available to seaport |
_setOfferApprovalsWithSeaport
Sets approvals for the collateral deposited to be spent via seaport
function _setOfferApprovalsWithSeaport(Starport.Loan memory loan) internal;
Parameters
Name | Type | Description |
---|---|---|
loan | Starport.Loan | The loan being settled |
_transferCollateralAuthorized
transfers out the collateral to the handler address
function _transferCollateralAuthorized(SpentItem memory offer, address authorized) internal;
Parameters
Name | Type | Description |
---|---|---|
offer | SpentItem | The item to send out of the Custodian |
authorized | address | The address handling the asset further |
_moveCollateralToAuthorized
transfers out the collateral of SpentItem to the handler address
function _moveCollateralToAuthorized(SpentItem[] memory offer, address authorized) internal;
Parameters
Name | Type | Description |
---|---|---|
offer | SpentItem[] | The SpentItem array to send out of the Custodian |
authorized | address | The address handling the asset further |
_postSettlementExecute
settle the loan with Starport
function _postSettlementExecute(Starport.Loan memory loan, address fulfiller) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
loan | Starport.Loan | The the loan that is settled |
fulfiller | address | The address executing seaport |
_postRepaymentExecute
settle the loan with Starport
function _postRepaymentExecute(Starport.Loan memory loan, address fulfiller) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
loan | Starport.Loan | The the loan that is settled |
fulfiller | address | The address executing seaport |
_settleLoan
settle the loan with Starport
function _settleLoan(Starport.Loan memory loan) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
loan | Starport.Loan | The the loan to settle |
_beforeApprovalsSetHook
hook to call before the approvals are set
function _beforeApprovalsSetHook(Starport.Loan memory loan) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
loan | Starport.Loan | The loan being settled |
_beforeGetSettlementConsideration
Hook to call before the loan get settlement call
function _beforeGetSettlementConsideration(Starport.Loan memory loan) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
loan | Starport.Loan | The loan being settled |
_afterGetSettlementConsideration
Hook to call after the loan get settlement call
function _afterGetSettlementConsideration(Starport.Loan memory loan) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
loan | Starport.Loan | The loan being settled |
_beforeSettlementHandlerHook
Hook to call before the the loan settlement handler execute call
function _beforeSettlementHandlerHook(Starport.Loan memory loan) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
loan | Starport.Loan | The loan being settled |
_afterSettlementHandlerHook
Hook to call after the the loan settlement handler execute call
function _afterSettlementHandlerHook(Starport.Loan memory loan) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
loan | Starport.Loan | The loan being settled |
_beforeSettleLoanHook
Hook to call before the loan is settled with the Starport
function _beforeSettleLoanHook(Starport.Loan memory loan) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
loan | Starport.Loan | The loan being settled |
_afterSettleLoanHook
Hook to call after the loan is settled with the Starport
function _afterSettleLoanHook(Starport.Loan memory loan) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
loan | Starport.Loan | The loan being settled |
onlyStarport
only allows Starport to execute the function
modifier onlyStarport();
onlySeaport
only allows seaport to execute the function
modifier onlySeaport();
Events
SeaportCompatibleContractDeployed
event SeaportCompatibleContractDeployed();
Errors
CustodianCannotBeAuthorized
error CustodianCannotBeAuthorized();
ImplementInChild
error ImplementInChild();
InvalidAction
error InvalidAction();
InvalidFulfiller
error InvalidFulfiller();
InvalidLoan
error InvalidLoan();
InvalidPostRepayment
error InvalidPostRepayment();
InvalidPostSettlement
error InvalidPostSettlement();
InvalidRepayer
error InvalidRepayer();
NotAuthorized
error NotAuthorized();
NotEnteredViaSeaport
error NotEnteredViaSeaport();
NotSeaport
error NotSeaport();
NotStarport
error NotStarport();
Structs
Command
struct Command {
Actions action;
Starport.Loan loan;
bytes extraData;
}