Class: HypercertExchangeClient
HypercertExchangeClient.HypercertExchangeClient
HypercertExchange This class provides helpers to interact with the HypercertExchange V2 contracts
Constructors
constructor
• new HypercertExchangeClient(chainId
, provider
, signer?
, override?
)
HypercertExchange protocol main class
Parameters
Name | Type | Description |
---|---|---|
chainId | ChainId | Current app chain id |
provider | Provider | Ethers provider |
signer? | Signer | Ethers signer |
override? | Addresses | Overrides contract addresses for hardhat setup |
Properties
addresses
• Readonly
addresses: Addresses
Mapping of Hypercert protocol addresses for the current chain
api
• Readonly
api: __module
chainId
• Readonly
chainId: ChainId
Current app chain ID
provider
• Readonly
provider: Provider
Ethers provider. If you want a batch functionality, use JsonRpcProvider.
See
signer
• Optional
Readonly
signer: Signer
Ethers signer
See
Methods
approveAllCollectionItems
▸ approveAllCollectionItems(collectionAddress
, approved?
, overrides?
): Promise
<ContractTransactionResponse
>
Approve all the items of a collection, to eventually be traded on HypercertExchange The spender is the TransferManager.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
collectionAddress | string | undefined | Address of the collection to be approved. |
approved | boolean | true | true to approve, false to revoke the approval (default to true) |
overrides? | Overrides | undefined | - |
Returns
Promise
<ContractTransactionResponse
>
ContractTransaction
approveErc20
▸ approveErc20(tokenAddress
, amount?
, overrides?
): Promise
<ContractTransactionResponse
>
Approve an ERC20 to be used as a currency on HypercertExchange. The spender is the HypercertExchangeProtocol contract.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
tokenAddress | string | undefined | Address of the ERC20 to approve |
amount | bigint | MaxUint256 | Amount to be approved (default to MaxUint256) |
overrides? | Overrides | undefined | - |
Returns
Promise
<ContractTransactionResponse
>
ContractTransaction
cancelAllOrders
▸ cancelAllOrders(bid
, ask
, overrides?
): ContractMethods
Cancell all maker bid and/or ask orders for the current user
Parameters
Name | Type | Description |
---|---|---|
bid | boolean | Cancel all bids |
ask | boolean | Cancel all asks |
overrides? | Overrides | - |
Returns
ContractMethods
cancelOrders
▸ cancelOrders(nonces
, overrides?
): ContractMethods
Cancel a list of specific orders
Parameters
Name | Type | Description |
---|---|---|
nonces | BigNumberish [] | List of nonces to be cancelled |
overrides? | Overrides | - |
Returns
ContractMethods
cancelSubsetOrders
▸ cancelSubsetOrders(nonces
, overrides?
): ContractMethods
Cancel a list of specific subset orders
Parameters
Name | Type | Description |
---|---|---|
nonces | BigNumberish [] | List of nonces to be cancelled |
overrides? | Overrides | - |
Returns
ContractMethods
createDirectFractionsSaleMakerAsk
▸ createDirectFractionsSaleMakerAsk(«destructured»
): Promise
<CreateMakerAskOutput
>
Create a maker ask for a collection or singular offer of fractions
Parameters
Name | Type |
---|---|
«destructured» | Omit <CreateMakerInput , "subsetNonce" | "orderNonce" | "strategyId" | "collectionType" | "collection" | "amounts" > |
Returns
Promise
<CreateMakerAskOutput
>
createFractionalSaleMakerAsk
▸ createFractionalSaleMakerAsk(«destructured»
): Promise
<CreateMakerAskOutput
>
Create a maker ask to let the buyer decide how much of the fraction they want to buy
Parameters
Name | Type |
---|---|
«destructured» | Omit <CreateMakerInput , "subsetNonce" | "orderNonce" | "strategyId" | "collectionType" | "collection" | "amounts" | "additionalParameters" > & { maxUnitAmount : BigNumberish ; minUnitAmount : BigNumberish ; minUnitsToKeep : BigNumberish ; root? : string ; sellLeftoverFraction : boolean } |
Returns
Promise
<CreateMakerAskOutput
>
createFractionalSaleTakerBid
▸ createFractionalSaleTakerBid(maker
, recipient?
, unitAmount
, pricePerUnit
): Taker
Create a taker bid for buying a fraction of an open fractional sale
Parameters
Name | Type | Default value | Description |
---|---|---|---|
maker | Maker | undefined | Maker order |
recipient | string | ZeroAddress | Recipient address of the taker (if none, it will use the sender) |
unitAmount | BigNumberish | undefined | Amount of units to buy |
pricePerUnit | BigNumberish | undefined | Price per unit in wei |
Returns
createMakerAsk
▸ createMakerAsk(CreateMakerInput
): Promise
<CreateMakerAskOutput
>
Create a maker ask object ready to be signed
Parameters
Name | Type |
---|---|
CreateMakerInput | CreateMakerInput |
Returns
Promise
<CreateMakerAskOutput
>
the maker object, isTransferManagerApproved, and isTransferManagerApproved
createMakerBid
▸ createMakerBid(CreateMakerInput
): Promise
<CreateMakerBidOutput
>
Create a maker bid object ready to be signed
Parameters
Name | Type |
---|---|
CreateMakerInput | CreateMakerInput |
Returns
Promise
<CreateMakerBidOutput
>
the maker object, isCurrencyApproved, and isBalanceSufficient
createMakerCollectionOffer
▸ createMakerCollectionOffer(orderInputs
): Promise
<CreateMakerBidOutput
>
Create a maker bid for collection offer.
Parameters
Name | Type | Description |
---|---|---|
orderInputs | CreateMakerCollectionOfferInput | Order data |
Returns
Promise
<CreateMakerBidOutput
>
CreateMakerBidOutput
See
this.createMakerBid
createMakerCollectionOfferWithProof
▸ createMakerCollectionOfferWithProof(orderInputs
): Promise
<CreateMakerBidOutput
>
Create a maker bid for collection, with a list of item id that can be used for the taker order
Parameters
Name | Type | Description |
---|---|---|
orderInputs | CreateMakerCollectionOfferWithProofInput | Order data |
Returns
Promise
<CreateMakerBidOutput
>
CreateMakerBidOutput
See
this.createMakerBid
createTaker
▸ createTaker(maker
, recipient?
, additionalParameters?
): Taker
Create a taker ask ready to be executed against a maker bid
Parameters
Name | Type | Default value | Description |
---|---|---|---|
maker | Maker | undefined | Maker order that will be used as counterparty for the taker |
recipient | string | ZeroAddress | Recipient address of the taker (if none, it will use the sender) |
additionalParameters | any [] | [] | Additional parameters used to support complex orders |
Returns
Taker object
createTakerCollectionOffer
▸ createTakerCollectionOffer(maker
, itemId
, recipient?
): Taker
Create a taker ask order for collection order.
Parameters
Name | Type | Description |
---|---|---|
maker | Maker | Maker bid that will be used as counterparty for the taker |
itemId | BigNumberish | Token id to use as a counterparty for the collection order |
recipient? | string | Recipient address of the taker (if none, it will use the sender) |
Returns
Taker object
See
- this.createTaker
- this.createMakerCollectionOffer
createTakerCollectionOfferWithProof
▸ createTakerCollectionOfferWithProof(maker
, itemId
, itemIds
, recipient?
): Taker
Create a taker ask to fulfill a collection order (maker bid) created with a whitelist of item ids
Parameters
Name | Type | Description |
---|---|---|
maker | Maker | Maker bid that will be used as counterparty for the taker |
itemId | BigNumberish | Token id to use as a counterparty for the collection order |
itemIds | BigNumberish [] | List of token ids used during the maker creation |
recipient? | string | Recipient address of the taker (if none, it will use the sender) |
Returns
Taker object
See
- this.createTaker
- this.createMakerCollectionOfferWithMerkleTree
executeMultipleOrders
▸ executeMultipleOrders(orders
, isAtomic
, overrides?
): Object
Execute several orders
Parameters
Name | Type | Description |
---|---|---|
orders | { maker : Maker ; merkleTree? : MerkleTree ; signature : string ; taker : Taker }[] | List of orders data |
isAtomic | boolean | Should the transaction revert or not if a trade fails |
overrides? | Overrides | Call overrides |
Returns
Object
ContractMethods
Name | Type |
---|---|
call | (additionalOverrides? : PayableOverrides ) => any |
callStatic | (additionalOverrides? : PayableOverrides ) => any |
estimateGas | (additionalOverrides? : PayableOverrides ) => any |
executeOrder
▸ executeOrder(maker
, taker
, signature
, merkleTree?
, overrides?
): ContractMethods
Execute a trade
Parameters
Name | Type | Default value | Description |
---|---|---|---|
maker | Maker | undefined | Maker order |
taker | Taker | undefined | Taker order |
signature | string | undefined | Signature of the maker order |
merkleTree | MerkleTree | defaultMerkleTree | If the maker has been signed with a merkle tree |
overrides? | Overrides | undefined | - |
Returns
ContractMethods
getSigner
▸ Private
getSigner(): Signer
Return the signer it it's set, throw an exception otherwise
Returns
Signer
Signer
getTypedDataDomain
▸ getTypedDataDomain(): TypedDataDomain
Retrieve EIP-712 domain
Returns
TypedDataDomain
TypedDataDomain
grantTransferManagerApproval
▸ grantTransferManagerApproval(operators?
, overrides?
): ContractMethods
Grant a list of operators the rights to transfer user's assets using the transfer manager
Parameters
Name | Type | Description |
---|---|---|
operators | string [] | List of operators (default to the exchange address) |
overrides? | Overrides | - |
Returns
ContractMethods
Default Value
Exchange address
isTimestampValid
▸ Private
isTimestampValid(timestamp
): boolean
Validate a timestamp format (seconds)
Parameters
Name | Type |
---|---|
timestamp | BigNumberish |
Returns
boolean
boolean
isTransferManagerApproved
▸ isTransferManagerApproved(operator?
, overrides?
): Promise
<boolean
>
Check whether or not an operator has been approved by the user
Parameters
Name | Type | Description |
---|---|---|
operator | string | Operator address (default to the exchange address) |
overrides? | Overrides | - |
Returns
Promise
<boolean
>
true if the operator is approved, false otherwise
registerOrder
▸ registerOrder(«destructured»
): Promise
<{ success
: boolean
}>
Register the order with hypercerts marketplace API.
Parameters
Name | Type |
---|---|
«destructured» | Object |
› order | Maker |
› signature | string |
Returns
Promise
<{ success
: boolean
}>
revokeTransferManagerApproval
▸ revokeTransferManagerApproval(operators?
, overrides?
): ContractMethods
Revoke a list of operators the rights to transfer user's assets using the transfer manager
Parameters
Name | Type | Description |
---|---|---|
operators | string [] | List of operators |
overrides? | Overrides | - |
Returns
ContractMethods
Default Value
Exchange address
signMakerOrder
▸ signMakerOrder(maker
): Promise
<string
>
Sign a maker order using the signer provided in the constructor
Parameters
Name | Type | Description |
---|---|---|
maker | Maker | Order to be signed by the user |
Returns
Promise
<string
>
Signature
signMultipleMakerOrders
▸ signMultipleMakerOrders(makerOrders
): Promise
<SignMerkleTreeOrdersOutput
>
Sign multiple maker orders with a single signature /!\ Use this function for UI implementation only
Parameters
Name | Type | Description |
---|---|---|
makerOrders | Maker [] | Array of maker orders |
Returns
Promise
<SignMerkleTreeOrdersOutput
>
Signature, proofs, and Merkletree object
strategyInfo
▸ strategyInfo(strategyId
, overrides?
): Promise
<StrategyInfo
>
Retrieve strategy info
Parameters
Name | Type | Description |
---|---|---|
strategyId | StrategyType | use the enum StrategyType |
overrides? | Overrides | - |
Returns
Promise
<StrategyInfo
>
StrategyInfo
transferItemsAcrossCollection
▸ transferItemsAcrossCollection(to
, collectionItems
, overrides?
): Promise
<ContractMethods
>
Transfer a list of items across different collections
Parameters
Name | Type | Description |
---|---|---|
to | string | Recipient address |
collectionItems | BatchTransferItem [] | Each object in the array represent a list of items for a specific collection |
overrides? | Overrides | - |
Returns
Promise
<ContractMethods
>
ContractMethods
verifyMakerOrders
▸ verifyMakerOrders(makerOrders
, signatures
, merkleTrees?
, overrides?
): Promise
<OrderValidatorCode
[][]>
Verify if a set of orders can be executed (i.e are valid)
Parameters
Name | Type | Description |
---|---|---|
makerOrders | Maker [] | List of maker orders |
signatures | string [] | List of signatures |
merkleTrees? | MerkleTree [] | List of merkle trees (optional) |
overrides? | Overrides | - |
Returns
Promise
<OrderValidatorCode
[][]>
A list of OrderValidatorCode for each order (code 0 being valid)