@hypercerts-org/marketplace-sdk 0.0.17 → 0.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- import { BigNumberish, ContractTransactionResponse, Overrides, TypedDataDomain, Provider, Signer } from "ethers";
1
+ import { BigNumberish, ContractTransactionResponse, Overrides, Provider, Signer, TypedDataDomain } from "ethers";
2
2
  import * as api from "./utils/api";
3
- import { Addresses, Maker, Taker, ChainId, CreateMakerInput, CreateMakerAskOutput, CreateMakerBidOutput, CreateMakerCollectionOfferInput, CreateMakerCollectionOfferWithProofInput, MerkleTree, ContractMethods, OrderValidatorCode, BatchTransferItem, SignMerkleTreeOrdersOutput, StrategyType, StrategyInfo } from "./types";
3
+ import { Addresses, BatchTransferItem, ChainId, ContractMethods, CreateMakerAskOutput, CreateMakerBidOutput, CreateMakerCollectionOfferInput, CreateMakerCollectionOfferWithProofInput, CreateMakerInput, Maker, MerkleTree, OrderValidatorCode, SignMerkleTreeOrdersOutput, StrategyInfo, StrategyType, Taker } from "./types";
4
4
  /**
5
5
  * LooksRare
6
6
  * This class provides helpers to interact with the LooksRare V2 contracts
@@ -83,7 +83,7 @@ export declare class HypercertExchangeClient {
83
83
  * Create a taker ask order for collection order.
84
84
  * @see this.createTaker
85
85
  * @see this.createMakerCollectionOffer
86
- * @param makerBid Maker bid that will be used as counterparty for the taker
86
+ * @param maker Maker bid that will be used as counterparty for the taker
87
87
  * @param itemId Token id to use as a counterparty for the collection order
88
88
  * @param recipient Recipient address of the taker (if none, it will use the sender)
89
89
  * @returns Taker object
@@ -93,7 +93,7 @@ export declare class HypercertExchangeClient {
93
93
  * Create a taker ask to fulfill a collection order (maker bid) created with a whitelist of item ids
94
94
  * @see this.createTaker
95
95
  * @see this.createMakerCollectionOfferWithMerkleTree
96
- * @param makerBid Maker bid that will be used as counterparty for the taker
96
+ * @param maker Maker bid that will be used as counterparty for the taker
97
97
  * @param itemId Token id to use as a counterparty for the collection order
98
98
  * @param itemIds List of token ids used during the maker creation
99
99
  * @param recipient Recipient address of the taker (if none, it will use the sender)
@@ -115,11 +115,10 @@ export declare class HypercertExchangeClient {
115
115
  signMultipleMakerOrders(makerOrders: Maker[]): Promise<SignMerkleTreeOrdersOutput>;
116
116
  /**
117
117
  * Execute a trade
118
- * @param makerBid Maker order
118
+ * @param maker Maker order
119
119
  * @param taker Taker order
120
120
  * @param signature Signature of the maker order
121
121
  * @param merkleTree If the maker has been signed with a merkle tree
122
- * @param affiliate Affiliate address if applicable
123
122
  * @returns ContractMethods
124
123
  */
125
124
  executeOrder(maker: Maker, taker: Taker, signature: string, merkleTree?: MerkleTree, overrides?: Overrides): ContractMethods;
@@ -127,7 +126,6 @@ export declare class HypercertExchangeClient {
127
126
  * Execute several orders
128
127
  * @param orders List of orders data
129
128
  * @param isAtomic Should the transaction revert or not if a trade fails
130
- * @param affiliate Affiliate address
131
129
  * @param overrides Call overrides
132
130
  * @returns ContractMethods
133
131
  */
@@ -223,9 +221,38 @@ export declare class HypercertExchangeClient {
223
221
  * @param price Price of the fractions in wei
224
222
  * @param startTime Timestamp in seconds when the order becomes valid
225
223
  * @param endTime Timestamp in seconds when the order becomes invalid
224
+ * @param currency Currency used to buy the fractions (default to WETH)
226
225
  * @param additionalParameters Additional parameters used to support complex orders
227
226
  */
228
- createDirectFractionsSaleMakerAsk({ itemIds, price, startTime, endTime, additionalParameters, }: Omit<CreateMakerInput, "strategyId" | "collectionType" | "collection" | "subsetNonce" | "orderNonce" | "amounts" | "currency">): Promise<CreateMakerAskOutput>;
227
+ createDirectFractionsSaleMakerAsk({ itemIds, price, startTime, endTime, currency, additionalParameters, }: Omit<CreateMakerInput, "strategyId" | "collectionType" | "collection" | "subsetNonce" | "orderNonce" | "amounts">): Promise<CreateMakerAskOutput>;
228
+ /**
229
+ * Create a maker ask to let the buyer decide how much of the fraction they want to buy
230
+ * @param itemIds Token IDs of the fractions to be sold
231
+ * @param price Price of one unit in wei
232
+ * @param startTime Timestamp in seconds when the order becomes valid
233
+ * @param endTime Timestamp in seconds when the order becomes invalid
234
+ * @param currency Currency used to buy the fractions (default to WETH)
235
+ * @param maxUnitAmount Maximum amount of units that can be bought in a single transaction
236
+ * @param minUnitAmount Minimum amount of units that can be bought in a single transaction
237
+ * @param minUnitsToKeep Minimum amount of units that the seller wants to keep
238
+ * @param sellLeftoverFraction Whether or not the seller wants to sell the leftover units
239
+ * @param root Merkle tree root (optional)
240
+ */
241
+ createFractionalSaleMakerAsk({ itemIds, price, startTime, endTime, currency, maxUnitAmount, minUnitAmount, minUnitsToKeep, sellLeftoverFraction, root, }: Omit<CreateMakerInput, "strategyId" | "collectionType" | "collection" | "subsetNonce" | "orderNonce" | "amounts" | "additionalParameters"> & {
242
+ minUnitAmount: BigNumberish;
243
+ maxUnitAmount: BigNumberish;
244
+ minUnitsToKeep: BigNumberish;
245
+ sellLeftoverFraction: boolean;
246
+ root?: string;
247
+ }): Promise<CreateMakerAskOutput>;
248
+ /**
249
+ * Create a taker bid for buying a fraction of an open fractional sale
250
+ * @param maker Maker order
251
+ * @param recipient Recipient address of the taker (if none, it will use the sender)
252
+ * @param unitAmount Amount of units to buy
253
+ * @param pricePerUnit Price per unit in wei
254
+ */
255
+ createFractionalSaleTakerBid(maker: Maker, recipient: string | undefined, unitAmount: BigNumberish, pricePerUnit: BigNumberish): Taker;
229
256
  /**
230
257
  * Register the order with hypercerts marketplace API.
231
258
  * @param order Maker order
package/dist/index.cjs.js CHANGED
@@ -704,6 +704,14 @@ exports.StrategyType = void 0;
704
704
  StrategyType[StrategyType["standard"] = 0] = "standard";
705
705
  StrategyType[StrategyType["collection"] = 1] = "collection";
706
706
  StrategyType[StrategyType["collectionWithMerkleTree"] = 2] = "collectionWithMerkleTree";
707
+ StrategyType[StrategyType["dutchAuction"] = 4] = "dutchAuction";
708
+ StrategyType[StrategyType["itemIdsRange"] = 5] = "itemIdsRange";
709
+ StrategyType[StrategyType["hypercertCollectionOffer"] = 6] = "hypercertCollectionOffer";
710
+ StrategyType[StrategyType["hypercertCollectionOfferWithProof"] = 7] = "hypercertCollectionOfferWithProof";
711
+ StrategyType[StrategyType["hypercertCollectionOfferWithAllowlist"] = 8] = "hypercertCollectionOfferWithAllowlist";
712
+ StrategyType[StrategyType["hypercertDutchAuction"] = 9] = "hypercertDutchAuction";
713
+ StrategyType[StrategyType["hypercertFractionOffer"] = 10] = "hypercertFractionOffer";
714
+ StrategyType[StrategyType["hypercertFractionOfferWithAllowlist"] = 11] = "hypercertFractionOfferWithAllowlist";
707
715
  })(exports.StrategyType || (exports.StrategyType = {}));
708
716
  /** Type for maker order */
709
717
  exports.QuoteType = void 0;
@@ -786,6 +794,12 @@ const getMakerParamsTypes = (strategy) => {
786
794
  if (strategy === exports.StrategyType.collectionWithMerkleTree) {
787
795
  return ["bytes32"]; // Merkle tree root
788
796
  }
797
+ if (strategy === exports.StrategyType.hypercertFractionOffer) {
798
+ return ["uint256", "uint256", "uint256", "bool"]; // minUnitAmount, maxUnitAmount, minUnitsToKeep, sellLeftoverFraction
799
+ }
800
+ if (strategy === exports.StrategyType.hypercertFractionOfferWithAllowlist) {
801
+ return ["uint256", "uint256", "uint256", "bool", "bytes32"]; // minUnitAmount, maxUnitAmount, minUnitsToKeep, sellLeftoverFraction, root
802
+ }
789
803
  return [];
790
804
  };
791
805
  /**
@@ -803,6 +817,12 @@ const getTakerParamsTypes = (strategy) => {
803
817
  if (strategy === exports.StrategyType.collectionWithMerkleTree) {
804
818
  return ["uint256", "bytes32[]"]; // Item id, merkle proof
805
819
  }
820
+ if (strategy === exports.StrategyType.hypercertFractionOffer) {
821
+ return ["uint256", "uint256"]; // unitAmount, pricePerUnit
822
+ }
823
+ if (strategy === exports.StrategyType.hypercertFractionOfferWithAllowlist) {
824
+ return ["uint256", "uint256", "bytes32[]"]; // unitAmount, pricePerUnit, proof
825
+ }
806
826
  return [];
807
827
  };
808
828
  /**
@@ -5024,17 +5044,16 @@ class HypercertExchangeClient {
5024
5044
  * @returns Taker object
5025
5045
  */
5026
5046
  createTaker(maker, recipient = ethers.ZeroAddress, additionalParameters = []) {
5027
- const order = {
5047
+ return {
5028
5048
  recipient: recipient,
5029
5049
  additionalParameters: encodeParams(additionalParameters, getTakerParamsTypes(maker.strategyId)),
5030
5050
  };
5031
- return order;
5032
5051
  }
5033
5052
  /**
5034
5053
  * Create a taker ask order for collection order.
5035
5054
  * @see this.createTaker
5036
5055
  * @see this.createMakerCollectionOffer
5037
- * @param makerBid Maker bid that will be used as counterparty for the taker
5056
+ * @param maker Maker bid that will be used as counterparty for the taker
5038
5057
  * @param itemId Token id to use as a counterparty for the collection order
5039
5058
  * @param recipient Recipient address of the taker (if none, it will use the sender)
5040
5059
  * @returns Taker object
@@ -5052,7 +5071,7 @@ class HypercertExchangeClient {
5052
5071
  * Create a taker ask to fulfill a collection order (maker bid) created with a whitelist of item ids
5053
5072
  * @see this.createTaker
5054
5073
  * @see this.createMakerCollectionOfferWithMerkleTree
5055
- * @param makerBid Maker bid that will be used as counterparty for the taker
5074
+ * @param maker Maker bid that will be used as counterparty for the taker
5056
5075
  * @param itemId Token id to use as a counterparty for the collection order
5057
5076
  * @param itemIds List of token ids used during the maker creation
5058
5077
  * @param recipient Recipient address of the taker (if none, it will use the sender)
@@ -5084,6 +5103,7 @@ class HypercertExchangeClient {
5084
5103
  */
5085
5104
  async signMakerOrder(maker) {
5086
5105
  const signer = this.getSigner();
5106
+ console.log("signing against", this.getTypedDataDomain(), maker);
5087
5107
  return await signMakerOrder(signer, this.getTypedDataDomain(), maker);
5088
5108
  }
5089
5109
  /**
@@ -5101,11 +5121,10 @@ class HypercertExchangeClient {
5101
5121
  }
5102
5122
  /**
5103
5123
  * Execute a trade
5104
- * @param makerBid Maker order
5124
+ * @param maker Maker order
5105
5125
  * @param taker Taker order
5106
5126
  * @param signature Signature of the maker order
5107
5127
  * @param merkleTree If the maker has been signed with a merkle tree
5108
- * @param affiliate Affiliate address if applicable
5109
5128
  * @returns ContractMethods
5110
5129
  */
5111
5130
  executeOrder(maker, taker, signature, merkleTree = defaultMerkleTree, overrides) {
@@ -5117,7 +5136,6 @@ class HypercertExchangeClient {
5117
5136
  * Execute several orders
5118
5137
  * @param orders List of orders data
5119
5138
  * @param isAtomic Should the transaction revert or not if a trade fails
5120
- * @param affiliate Affiliate address
5121
5139
  * @param overrides Call overrides
5122
5140
  * @returns ContractMethods
5123
5141
  */
@@ -5256,9 +5274,10 @@ class HypercertExchangeClient {
5256
5274
  * @param price Price of the fractions in wei
5257
5275
  * @param startTime Timestamp in seconds when the order becomes valid
5258
5276
  * @param endTime Timestamp in seconds when the order becomes invalid
5277
+ * @param currency Currency used to buy the fractions (default to WETH)
5259
5278
  * @param additionalParameters Additional parameters used to support complex orders
5260
5279
  */
5261
- async createDirectFractionsSaleMakerAsk({ itemIds, price, startTime, endTime, additionalParameters = [], }) {
5280
+ async createDirectFractionsSaleMakerAsk({ itemIds, price, startTime, endTime, currency = this.addresses.WETH, additionalParameters = [], }) {
5262
5281
  const address = await this.signer?.getAddress();
5263
5282
  if (!address) {
5264
5283
  throw new Error("No signer address could be determined");
@@ -5275,7 +5294,7 @@ class HypercertExchangeClient {
5275
5294
  collectionType: 2,
5276
5295
  collection: this.addresses.MINTER,
5277
5296
  subsetNonce: 0,
5278
- currency: this.addresses.WETH,
5297
+ currency,
5279
5298
  amounts,
5280
5299
  orderNonce: nonce_counter.toString(),
5281
5300
  // User specified
@@ -5286,6 +5305,70 @@ class HypercertExchangeClient {
5286
5305
  additionalParameters,
5287
5306
  });
5288
5307
  }
5308
+ /**
5309
+ * Create a maker ask to let the buyer decide how much of the fraction they want to buy
5310
+ * @param itemIds Token IDs of the fractions to be sold
5311
+ * @param price Price of one unit in wei
5312
+ * @param startTime Timestamp in seconds when the order becomes valid
5313
+ * @param endTime Timestamp in seconds when the order becomes invalid
5314
+ * @param currency Currency used to buy the fractions (default to WETH)
5315
+ * @param maxUnitAmount Maximum amount of units that can be bought in a single transaction
5316
+ * @param minUnitAmount Minimum amount of units that can be bought in a single transaction
5317
+ * @param minUnitsToKeep Minimum amount of units that the seller wants to keep
5318
+ * @param sellLeftoverFraction Whether or not the seller wants to sell the leftover units
5319
+ * @param root Merkle tree root (optional)
5320
+ */
5321
+ async createFractionalSaleMakerAsk({ itemIds, price, startTime, endTime, currency = this.addresses.WETH, maxUnitAmount, minUnitAmount, minUnitsToKeep, sellLeftoverFraction, root, }) {
5322
+ const address = await this.signer?.getAddress();
5323
+ if (!address) {
5324
+ throw new Error("No signer address could be determined");
5325
+ }
5326
+ const chainId = this.chainId;
5327
+ const { nonce_counter } = await fetchOrderNonce({
5328
+ address,
5329
+ chainId,
5330
+ });
5331
+ const amounts = Array.from({ length: itemIds.length }, () => 1);
5332
+ const sharedArgs = {
5333
+ // Defaults
5334
+ collectionType: 2,
5335
+ collection: this.addresses.MINTER,
5336
+ subsetNonce: 0,
5337
+ currency,
5338
+ amounts,
5339
+ orderNonce: nonce_counter.toString(),
5340
+ // User specified
5341
+ itemIds,
5342
+ price,
5343
+ startTime,
5344
+ endTime,
5345
+ };
5346
+ if (root) {
5347
+ return this.createMakerAsk({
5348
+ ...sharedArgs,
5349
+ strategyId: exports.StrategyType.hypercertFractionOfferWithAllowlist,
5350
+ additionalParameters: [minUnitAmount, maxUnitAmount, minUnitsToKeep, sellLeftoverFraction, root],
5351
+ });
5352
+ }
5353
+ return this.createMakerAsk({
5354
+ ...sharedArgs,
5355
+ strategyId: exports.StrategyType.hypercertFractionOffer,
5356
+ additionalParameters: [minUnitAmount, maxUnitAmount, minUnitsToKeep, sellLeftoverFraction],
5357
+ });
5358
+ }
5359
+ /**
5360
+ * Create a taker bid for buying a fraction of an open fractional sale
5361
+ * @param maker Maker order
5362
+ * @param recipient Recipient address of the taker (if none, it will use the sender)
5363
+ * @param unitAmount Amount of units to buy
5364
+ * @param pricePerUnit Price per unit in wei
5365
+ */
5366
+ createFractionalSaleTakerBid(maker, recipient = ethers.ZeroAddress, unitAmount, pricePerUnit) {
5367
+ return {
5368
+ recipient: recipient,
5369
+ additionalParameters: encodeParams([unitAmount, pricePerUnit], getTakerParamsTypes(maker.strategyId)),
5370
+ };
5371
+ }
5289
5372
  /**
5290
5373
  * Register the order with hypercerts marketplace API.
5291
5374
  * @param order Maker order
package/dist/index.esm.js CHANGED
@@ -702,6 +702,14 @@ var StrategyType;
702
702
  StrategyType[StrategyType["standard"] = 0] = "standard";
703
703
  StrategyType[StrategyType["collection"] = 1] = "collection";
704
704
  StrategyType[StrategyType["collectionWithMerkleTree"] = 2] = "collectionWithMerkleTree";
705
+ StrategyType[StrategyType["dutchAuction"] = 4] = "dutchAuction";
706
+ StrategyType[StrategyType["itemIdsRange"] = 5] = "itemIdsRange";
707
+ StrategyType[StrategyType["hypercertCollectionOffer"] = 6] = "hypercertCollectionOffer";
708
+ StrategyType[StrategyType["hypercertCollectionOfferWithProof"] = 7] = "hypercertCollectionOfferWithProof";
709
+ StrategyType[StrategyType["hypercertCollectionOfferWithAllowlist"] = 8] = "hypercertCollectionOfferWithAllowlist";
710
+ StrategyType[StrategyType["hypercertDutchAuction"] = 9] = "hypercertDutchAuction";
711
+ StrategyType[StrategyType["hypercertFractionOffer"] = 10] = "hypercertFractionOffer";
712
+ StrategyType[StrategyType["hypercertFractionOfferWithAllowlist"] = 11] = "hypercertFractionOfferWithAllowlist";
705
713
  })(StrategyType || (StrategyType = {}));
706
714
  /** Type for maker order */
707
715
  var QuoteType;
@@ -784,6 +792,12 @@ const getMakerParamsTypes = (strategy) => {
784
792
  if (strategy === StrategyType.collectionWithMerkleTree) {
785
793
  return ["bytes32"]; // Merkle tree root
786
794
  }
795
+ if (strategy === StrategyType.hypercertFractionOffer) {
796
+ return ["uint256", "uint256", "uint256", "bool"]; // minUnitAmount, maxUnitAmount, minUnitsToKeep, sellLeftoverFraction
797
+ }
798
+ if (strategy === StrategyType.hypercertFractionOfferWithAllowlist) {
799
+ return ["uint256", "uint256", "uint256", "bool", "bytes32"]; // minUnitAmount, maxUnitAmount, minUnitsToKeep, sellLeftoverFraction, root
800
+ }
787
801
  return [];
788
802
  };
789
803
  /**
@@ -801,6 +815,12 @@ const getTakerParamsTypes = (strategy) => {
801
815
  if (strategy === StrategyType.collectionWithMerkleTree) {
802
816
  return ["uint256", "bytes32[]"]; // Item id, merkle proof
803
817
  }
818
+ if (strategy === StrategyType.hypercertFractionOffer) {
819
+ return ["uint256", "uint256"]; // unitAmount, pricePerUnit
820
+ }
821
+ if (strategy === StrategyType.hypercertFractionOfferWithAllowlist) {
822
+ return ["uint256", "uint256", "bytes32[]"]; // unitAmount, pricePerUnit, proof
823
+ }
804
824
  return [];
805
825
  };
806
826
  /**
@@ -5022,17 +5042,16 @@ class HypercertExchangeClient {
5022
5042
  * @returns Taker object
5023
5043
  */
5024
5044
  createTaker(maker, recipient = ZeroAddress, additionalParameters = []) {
5025
- const order = {
5045
+ return {
5026
5046
  recipient: recipient,
5027
5047
  additionalParameters: encodeParams(additionalParameters, getTakerParamsTypes(maker.strategyId)),
5028
5048
  };
5029
- return order;
5030
5049
  }
5031
5050
  /**
5032
5051
  * Create a taker ask order for collection order.
5033
5052
  * @see this.createTaker
5034
5053
  * @see this.createMakerCollectionOffer
5035
- * @param makerBid Maker bid that will be used as counterparty for the taker
5054
+ * @param maker Maker bid that will be used as counterparty for the taker
5036
5055
  * @param itemId Token id to use as a counterparty for the collection order
5037
5056
  * @param recipient Recipient address of the taker (if none, it will use the sender)
5038
5057
  * @returns Taker object
@@ -5050,7 +5069,7 @@ class HypercertExchangeClient {
5050
5069
  * Create a taker ask to fulfill a collection order (maker bid) created with a whitelist of item ids
5051
5070
  * @see this.createTaker
5052
5071
  * @see this.createMakerCollectionOfferWithMerkleTree
5053
- * @param makerBid Maker bid that will be used as counterparty for the taker
5072
+ * @param maker Maker bid that will be used as counterparty for the taker
5054
5073
  * @param itemId Token id to use as a counterparty for the collection order
5055
5074
  * @param itemIds List of token ids used during the maker creation
5056
5075
  * @param recipient Recipient address of the taker (if none, it will use the sender)
@@ -5082,6 +5101,7 @@ class HypercertExchangeClient {
5082
5101
  */
5083
5102
  async signMakerOrder(maker) {
5084
5103
  const signer = this.getSigner();
5104
+ console.log("signing against", this.getTypedDataDomain(), maker);
5085
5105
  return await signMakerOrder(signer, this.getTypedDataDomain(), maker);
5086
5106
  }
5087
5107
  /**
@@ -5099,11 +5119,10 @@ class HypercertExchangeClient {
5099
5119
  }
5100
5120
  /**
5101
5121
  * Execute a trade
5102
- * @param makerBid Maker order
5122
+ * @param maker Maker order
5103
5123
  * @param taker Taker order
5104
5124
  * @param signature Signature of the maker order
5105
5125
  * @param merkleTree If the maker has been signed with a merkle tree
5106
- * @param affiliate Affiliate address if applicable
5107
5126
  * @returns ContractMethods
5108
5127
  */
5109
5128
  executeOrder(maker, taker, signature, merkleTree = defaultMerkleTree, overrides) {
@@ -5115,7 +5134,6 @@ class HypercertExchangeClient {
5115
5134
  * Execute several orders
5116
5135
  * @param orders List of orders data
5117
5136
  * @param isAtomic Should the transaction revert or not if a trade fails
5118
- * @param affiliate Affiliate address
5119
5137
  * @param overrides Call overrides
5120
5138
  * @returns ContractMethods
5121
5139
  */
@@ -5254,9 +5272,10 @@ class HypercertExchangeClient {
5254
5272
  * @param price Price of the fractions in wei
5255
5273
  * @param startTime Timestamp in seconds when the order becomes valid
5256
5274
  * @param endTime Timestamp in seconds when the order becomes invalid
5275
+ * @param currency Currency used to buy the fractions (default to WETH)
5257
5276
  * @param additionalParameters Additional parameters used to support complex orders
5258
5277
  */
5259
- async createDirectFractionsSaleMakerAsk({ itemIds, price, startTime, endTime, additionalParameters = [], }) {
5278
+ async createDirectFractionsSaleMakerAsk({ itemIds, price, startTime, endTime, currency = this.addresses.WETH, additionalParameters = [], }) {
5260
5279
  const address = await this.signer?.getAddress();
5261
5280
  if (!address) {
5262
5281
  throw new Error("No signer address could be determined");
@@ -5273,7 +5292,7 @@ class HypercertExchangeClient {
5273
5292
  collectionType: 2,
5274
5293
  collection: this.addresses.MINTER,
5275
5294
  subsetNonce: 0,
5276
- currency: this.addresses.WETH,
5295
+ currency,
5277
5296
  amounts,
5278
5297
  orderNonce: nonce_counter.toString(),
5279
5298
  // User specified
@@ -5284,6 +5303,70 @@ class HypercertExchangeClient {
5284
5303
  additionalParameters,
5285
5304
  });
5286
5305
  }
5306
+ /**
5307
+ * Create a maker ask to let the buyer decide how much of the fraction they want to buy
5308
+ * @param itemIds Token IDs of the fractions to be sold
5309
+ * @param price Price of one unit in wei
5310
+ * @param startTime Timestamp in seconds when the order becomes valid
5311
+ * @param endTime Timestamp in seconds when the order becomes invalid
5312
+ * @param currency Currency used to buy the fractions (default to WETH)
5313
+ * @param maxUnitAmount Maximum amount of units that can be bought in a single transaction
5314
+ * @param minUnitAmount Minimum amount of units that can be bought in a single transaction
5315
+ * @param minUnitsToKeep Minimum amount of units that the seller wants to keep
5316
+ * @param sellLeftoverFraction Whether or not the seller wants to sell the leftover units
5317
+ * @param root Merkle tree root (optional)
5318
+ */
5319
+ async createFractionalSaleMakerAsk({ itemIds, price, startTime, endTime, currency = this.addresses.WETH, maxUnitAmount, minUnitAmount, minUnitsToKeep, sellLeftoverFraction, root, }) {
5320
+ const address = await this.signer?.getAddress();
5321
+ if (!address) {
5322
+ throw new Error("No signer address could be determined");
5323
+ }
5324
+ const chainId = this.chainId;
5325
+ const { nonce_counter } = await fetchOrderNonce({
5326
+ address,
5327
+ chainId,
5328
+ });
5329
+ const amounts = Array.from({ length: itemIds.length }, () => 1);
5330
+ const sharedArgs = {
5331
+ // Defaults
5332
+ collectionType: 2,
5333
+ collection: this.addresses.MINTER,
5334
+ subsetNonce: 0,
5335
+ currency,
5336
+ amounts,
5337
+ orderNonce: nonce_counter.toString(),
5338
+ // User specified
5339
+ itemIds,
5340
+ price,
5341
+ startTime,
5342
+ endTime,
5343
+ };
5344
+ if (root) {
5345
+ return this.createMakerAsk({
5346
+ ...sharedArgs,
5347
+ strategyId: StrategyType.hypercertFractionOfferWithAllowlist,
5348
+ additionalParameters: [minUnitAmount, maxUnitAmount, minUnitsToKeep, sellLeftoverFraction, root],
5349
+ });
5350
+ }
5351
+ return this.createMakerAsk({
5352
+ ...sharedArgs,
5353
+ strategyId: StrategyType.hypercertFractionOffer,
5354
+ additionalParameters: [minUnitAmount, maxUnitAmount, minUnitsToKeep, sellLeftoverFraction],
5355
+ });
5356
+ }
5357
+ /**
5358
+ * Create a taker bid for buying a fraction of an open fractional sale
5359
+ * @param maker Maker order
5360
+ * @param recipient Recipient address of the taker (if none, it will use the sender)
5361
+ * @param unitAmount Amount of units to buy
5362
+ * @param pricePerUnit Price per unit in wei
5363
+ */
5364
+ createFractionalSaleTakerBid(maker, recipient = ZeroAddress, unitAmount, pricePerUnit) {
5365
+ return {
5366
+ recipient: recipient,
5367
+ additionalParameters: encodeParams([unitAmount, pricePerUnit], getTakerParamsTypes(maker.strategyId)),
5368
+ };
5369
+ }
5287
5370
  /**
5288
5371
  * Register the order with hypercerts marketplace API.
5289
5372
  * @param order Maker order
package/dist/types.d.ts CHANGED
@@ -33,7 +33,15 @@ export declare enum CollectionType {
33
33
  export declare enum StrategyType {
34
34
  standard = 0,
35
35
  collection = 1,
36
- collectionWithMerkleTree = 2
36
+ collectionWithMerkleTree = 2,
37
+ dutchAuction = 4,
38
+ itemIdsRange = 5,
39
+ hypercertCollectionOffer = 6,
40
+ hypercertCollectionOfferWithProof = 7,
41
+ hypercertCollectionOfferWithAllowlist = 8,
42
+ hypercertDutchAuction = 9,
43
+ hypercertFractionOffer = 10,
44
+ hypercertFractionOfferWithAllowlist = 11
37
45
  }
38
46
  /** Type for maker order */
39
47
  export declare enum QuoteType {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hypercerts-org/marketplace-sdk",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -91,7 +91,7 @@
91
91
  "typescript": "^5.3.3"
92
92
  },
93
93
  "dependencies": {
94
- "@hypercerts-org/sdk": "^1.4.1",
94
+ "@hypercerts-org/sdk": "1.4.2-alpha.2",
95
95
  "@supabase/supabase-js": "^2.39.2",
96
96
  "ethers": "^6.6.2",
97
97
  "merkletreejs": "^0.3.9"