Custodian

Git Source

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

NameTypeDescription
<none>stringstring The name of the contract

symbol

The symbol of the ERC721 contract

function symbol() public pure override returns (string memory);

Returns

NameTypeDescription
<none>stringstring The symbol of the contract

tokenURI

ERC-721 tokenURI override

function tokenURI(uint256 loanId) public view override returns (string memory);

Parameters

NameTypeDescription
loanIduint256The id of the custody token/loan

Returns

NameTypeDescription
<none>stringstring 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

NameTypeDescription
interfaceIdbytes4The interface to check

Returns

NameTypeDescription
<none>boolbool 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

NameTypeDescription
loanStarport.LoanThe 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

NameTypeDescription
loanStarport.LoanThe loan to mint a custody token for
approvedToaddressThe 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

NameTypeDescription
loanStarport.LoanThe 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

NameTypeDescription
ratifyOrderMagicValuebytes4The 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

NameTypeDescription
fulfilleraddressThe address of the contract fulfiller
<none>SpentItem[]
<none>SpentItem[]
contextbytesThe context of the order

Returns

NameTypeDescription
offerSpentItem[]The items spent by the order
considerationReceivedItem[]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

NameTypeDescription
loanStarport.LoanThe loan that was just placed into custody

Returns

NameTypeDescription
selectorbytes4The 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

NameTypeDescription
<none>stringstring The name of the contract
schemasSchema[]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

NameTypeDescription
loanStarport.LoanLoan to get the borrower of

Returns

NameTypeDescription
<none>addressaddress 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

NameTypeDescription
calleraddressThe address of the seaport contract
fulfilleraddressThe address of the contract fulfiller
<none>SpentItem[]
<none>SpentItem[]
contextbytesThe context of the order

Returns

NameTypeDescription
offerSpentItem[]The items spent by the order
considerationReceivedItem[]The items received by the order

_enableAssetWithSeaport

Enables the collateral deposited to be spent via seaport

function _enableAssetWithSeaport(SpentItem memory offer) internal;

Parameters

NameTypeDescription
offerSpentItemThe 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

NameTypeDescription
loanStarport.LoanThe loan being settled

_transferCollateralAuthorized

transfers out the collateral to the handler address

function _transferCollateralAuthorized(SpentItem memory offer, address authorized) internal;

Parameters

NameTypeDescription
offerSpentItemThe item to send out of the Custodian
authorizedaddressThe 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

NameTypeDescription
offerSpentItem[]The SpentItem array to send out of the Custodian
authorizedaddressThe address handling the asset further

_postSettlementExecute

settle the loan with Starport

function _postSettlementExecute(Starport.Loan memory loan, address fulfiller) internal virtual;

Parameters

NameTypeDescription
loanStarport.LoanThe the loan that is settled
fulfilleraddressThe address executing seaport

_postRepaymentExecute

settle the loan with Starport

function _postRepaymentExecute(Starport.Loan memory loan, address fulfiller) internal virtual;

Parameters

NameTypeDescription
loanStarport.LoanThe the loan that is settled
fulfilleraddressThe address executing seaport

_settleLoan

settle the loan with Starport

function _settleLoan(Starport.Loan memory loan) internal virtual;

Parameters

NameTypeDescription
loanStarport.LoanThe the loan to settle

_beforeApprovalsSetHook

hook to call before the approvals are set

function _beforeApprovalsSetHook(Starport.Loan memory loan) internal virtual;

Parameters

NameTypeDescription
loanStarport.LoanThe loan being settled

_beforeGetSettlementConsideration

Hook to call before the loan get settlement call

function _beforeGetSettlementConsideration(Starport.Loan memory loan) internal virtual;

Parameters

NameTypeDescription
loanStarport.LoanThe loan being settled

_afterGetSettlementConsideration

Hook to call after the loan get settlement call

function _afterGetSettlementConsideration(Starport.Loan memory loan) internal virtual;

Parameters

NameTypeDescription
loanStarport.LoanThe loan being settled

_beforeSettlementHandlerHook

Hook to call before the the loan settlement handler execute call

function _beforeSettlementHandlerHook(Starport.Loan memory loan) internal virtual;

Parameters

NameTypeDescription
loanStarport.LoanThe loan being settled

_afterSettlementHandlerHook

Hook to call after the the loan settlement handler execute call

function _afterSettlementHandlerHook(Starport.Loan memory loan) internal virtual;

Parameters

NameTypeDescription
loanStarport.LoanThe loan being settled

_beforeSettleLoanHook

Hook to call before the loan is settled with the Starport

function _beforeSettleLoanHook(Starport.Loan memory loan) internal virtual;

Parameters

NameTypeDescription
loanStarport.LoanThe loan being settled

_afterSettleLoanHook

Hook to call after the loan is settled with the Starport

function _afterSettleLoanHook(Starport.Loan memory loan) internal virtual;

Parameters

NameTypeDescription
loanStarport.LoanThe 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;
}