@opensea/seaport-js 1.0.0 → 1.0.1-beta.0
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.
- package/lib/abi/ERC1155.d.ts +29 -29
- package/lib/abi/ERC20.d.ts +29 -29
- package/lib/abi/ERC721.d.ts +29 -29
- package/lib/abi/Seaport.d.ts +112 -112
- package/lib/constants.d.ts +49 -49
- package/lib/index.d.ts +2 -2
- package/lib/index.esm.mjs +2 -0
- package/lib/index.esm.mjs.map +1 -0
- package/lib/index.js +2 -6
- package/lib/index.js.map +1 -1
- package/lib/index.modern.mjs +2 -0
- package/lib/index.modern.mjs.map +1 -0
- package/lib/index.umd.js +2 -0
- package/lib/index.umd.js.map +1 -0
- package/lib/seaport.d.ts +181 -181
- package/lib/types.d.ts +207 -207
- package/lib/utils/approval.d.ts +9 -9
- package/lib/utils/balance.d.ts +4 -4
- package/lib/utils/balanceAndApprovalCheck.d.ts +108 -108
- package/lib/utils/criteria.d.ts +13 -14
- package/lib/utils/fulfill.d.ts +84 -84
- package/lib/utils/gcd.d.ts +3 -3
- package/lib/utils/item.d.ts +30 -29
- package/lib/utils/match.d.ts +49 -49
- package/lib/utils/merkletree.d.ts +11 -11
- package/lib/utils/order.d.ts +37 -37
- package/lib/utils/usecase.d.ts +4 -4
- package/package.json +4 -2
- package/lib/abi/ERC1155.js +0 -319
- package/lib/abi/ERC1155.js.map +0 -1
- package/lib/abi/ERC20.js +0 -317
- package/lib/abi/ERC20.js.map +0 -1
- package/lib/abi/ERC721.js +0 -337
- package/lib/abi/ERC721.js.map +0 -1
- package/lib/abi/Seaport.js +0 -2585
- package/lib/abi/Seaport.js.map +0 -1
- package/lib/constants.js +0 -73
- package/lib/constants.js.map +0 -1
- package/lib/seaport.js +0 -720
- package/lib/seaport.js.map +0 -1
- package/lib/typechain/ERC1155.d.ts +0 -189
- package/lib/typechain/ERC1155.js +0 -3
- package/lib/typechain/ERC1155.js.map +0 -1
- package/lib/typechain/ERC20.d.ts +0 -209
- package/lib/typechain/ERC20.js +0 -3
- package/lib/typechain/ERC20.js.map +0 -1
- package/lib/typechain/ERC721.d.ts +0 -220
- package/lib/typechain/ERC721.js +0 -3
- package/lib/typechain/ERC721.js.map +0 -1
- package/lib/typechain/Seaport.d.ts +0 -686
- package/lib/typechain/Seaport.js +0 -3
- package/lib/typechain/Seaport.js.map +0 -1
- package/lib/typechain/common.d.ts +0 -21
- package/lib/typechain/common.js +0 -3
- package/lib/typechain/common.js.map +0 -1
- package/lib/types.js +0 -3
- package/lib/types.js.map +0 -1
- package/lib/utils/approval.js +0 -108
- package/lib/utils/approval.js.map +0 -1
- package/lib/utils/balance.js +0 -86
- package/lib/utils/balance.js.map +0 -1
- package/lib/utils/balanceAndApprovalCheck.js +0 -322
- package/lib/utils/balanceAndApprovalCheck.js.map +0 -1
- package/lib/utils/criteria.js +0 -91
- package/lib/utils/criteria.js.map +0 -1
- package/lib/utils/fulfill.js +0 -573
- package/lib/utils/fulfill.js.map +0 -1
- package/lib/utils/gcd.js +0 -25
- package/lib/utils/gcd.js.map +0 -1
- package/lib/utils/item.js +0 -136
- package/lib/utils/item.js.map +0 -1
- package/lib/utils/match.js +0 -56
- package/lib/utils/match.js.map +0 -1
- package/lib/utils/merkletree.js +0 -32
- package/lib/utils/merkletree.js.map +0 -1
- package/lib/utils/order.js +0 -224
- package/lib/utils/order.js.map +0 -1
- package/lib/utils/usecase.js +0 -158
- package/lib/utils/usecase.js.map +0 -1
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
import { providers as multicallProviders } from "@0xsequence/multicall";
|
|
2
|
-
import { BigNumber } from "ethers";
|
|
3
|
-
import { ItemType } from "../constants";
|
|
4
|
-
import type { InputCriteria, Item, OrderParameters } from "../types";
|
|
5
|
-
import { getSummedTokenAndIdentifierAmounts, TimeBasedItemParams } from "./item";
|
|
6
|
-
export declare type BalancesAndApprovals = {
|
|
7
|
-
token: string;
|
|
8
|
-
identifierOrCriteria: string;
|
|
9
|
-
balance: BigNumber;
|
|
10
|
-
approvedAmount: BigNumber;
|
|
11
|
-
itemType: ItemType;
|
|
12
|
-
}[];
|
|
13
|
-
export declare type InsufficientBalances = {
|
|
14
|
-
token: string;
|
|
15
|
-
identifierOrCriteria: string;
|
|
16
|
-
requiredAmount: BigNumber;
|
|
17
|
-
amountHave: BigNumber;
|
|
18
|
-
itemType: ItemType;
|
|
19
|
-
}[];
|
|
20
|
-
export declare type InsufficientApprovals = {
|
|
21
|
-
token: string;
|
|
22
|
-
identifierOrCriteria: string;
|
|
23
|
-
approvedAmount: BigNumber;
|
|
24
|
-
requiredApprovedAmount: BigNumber;
|
|
25
|
-
operator: string;
|
|
26
|
-
itemType: ItemType;
|
|
27
|
-
}[];
|
|
28
|
-
export declare const getBalancesAndApprovals: ({ owner, items, criterias, operator, multicallProvider, }: {
|
|
29
|
-
owner: string;
|
|
30
|
-
items: Item[];
|
|
31
|
-
criterias: InputCriteria[];
|
|
32
|
-
operator: string;
|
|
33
|
-
multicallProvider: multicallProviders.MulticallProvider;
|
|
34
|
-
}) => Promise<BalancesAndApprovals>;
|
|
35
|
-
export declare const getInsufficientBalanceAndApprovalAmounts: ({ balancesAndApprovals, tokenAndIdentifierAmounts, operator, }: {
|
|
36
|
-
balancesAndApprovals: BalancesAndApprovals;
|
|
37
|
-
tokenAndIdentifierAmounts: ReturnType<typeof getSummedTokenAndIdentifierAmounts>;
|
|
38
|
-
operator: string;
|
|
39
|
-
}) => {
|
|
40
|
-
insufficientBalances: InsufficientBalances;
|
|
41
|
-
insufficientApprovals: InsufficientApprovals;
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* 1. The offerer should have sufficient balance of all offered items.
|
|
45
|
-
* 2. If the order does not indicate proxy utilization, the offerer should have sufficient approvals set
|
|
46
|
-
* for the Seaport contract for all offered ERC20, ERC721, and ERC1155 items.
|
|
47
|
-
* 3. If the order does indicate proxy utilization, the offerer should have sufficient approvals set
|
|
48
|
-
* for their respective proxy contract for all offered ERC20, ERC721, and ERC1155 items.
|
|
49
|
-
*/
|
|
50
|
-
export declare const validateOfferBalancesAndApprovals: ({ offer, criterias, balancesAndApprovals, timeBasedItemParams, throwOnInsufficientBalances, throwOnInsufficientApprovals, operator, }: {
|
|
51
|
-
balancesAndApprovals: BalancesAndApprovals;
|
|
52
|
-
timeBasedItemParams?: TimeBasedItemParams | undefined;
|
|
53
|
-
throwOnInsufficientBalances?: boolean | undefined;
|
|
54
|
-
throwOnInsufficientApprovals?: boolean | undefined;
|
|
55
|
-
operator: string;
|
|
56
|
-
} & Pick<OrderParameters, "offer"> & {
|
|
57
|
-
criterias: InputCriteria[];
|
|
58
|
-
}) => InsufficientApprovals;
|
|
59
|
-
/**
|
|
60
|
-
* When fulfilling a basic order, the following requirements need to be checked to ensure that the order will be fulfillable:
|
|
61
|
-
* 1. Offer checks need to be performed to ensure that the offerer still has sufficient balance and approvals
|
|
62
|
-
* 2. The fulfiller should have sufficient balance of all consideration items except for those with an
|
|
63
|
-
* item type that matches the order's offered item type — by way of example, if the fulfilled order offers
|
|
64
|
-
* an ERC20 item and requires an ERC721 item to the offerer and the same ERC20 item to another recipient,
|
|
65
|
-
* the fulfiller needs to own the ERC721 item but does not need to own the ERC20 item as it will be sourced from the offerer.
|
|
66
|
-
* 3. If the fulfiller does not elect to utilize a proxy, they need to have sufficient approvals set for the
|
|
67
|
-
* Seaport contract for all ERC20, ERC721, and ERC1155 consideration items on the fulfilled order except
|
|
68
|
-
* for ERC20 items with an item type that matches the order's offered item type.
|
|
69
|
-
* 4. If the fulfiller does elect to utilize a proxy, they need to have sufficient approvals set for their
|
|
70
|
-
* respective proxy contract for all ERC20, ERC721, and ERC1155 consideration items on the fulfilled order
|
|
71
|
-
* except for ERC20 items with an item type that matches the order's offered item type.
|
|
72
|
-
* 5. If the fulfilled order specifies Ether (or other native tokens) as consideration items, the fulfiller must
|
|
73
|
-
* be able to supply the sum total of those items as msg.value.
|
|
74
|
-
*
|
|
75
|
-
* @returns the list of insufficient owner and proxy approvals
|
|
76
|
-
*/
|
|
77
|
-
export declare const validateBasicFulfillBalancesAndApprovals: ({ offer, consideration, offererBalancesAndApprovals, fulfillerBalancesAndApprovals, timeBasedItemParams, offererOperator, fulfillerOperator, }: {
|
|
78
|
-
offererBalancesAndApprovals: BalancesAndApprovals;
|
|
79
|
-
fulfillerBalancesAndApprovals: BalancesAndApprovals;
|
|
80
|
-
timeBasedItemParams: TimeBasedItemParams;
|
|
81
|
-
offererOperator: string;
|
|
82
|
-
fulfillerOperator: string;
|
|
83
|
-
} & Pick<OrderParameters, "offer" | "consideration">) => InsufficientApprovals;
|
|
84
|
-
/**
|
|
85
|
-
* When fulfilling a standard order, the following requirements need to be checked to ensure that the order will be fulfillable:
|
|
86
|
-
* 1. Offer checks need to be performed to ensure that the offerer still has sufficient balance and approvals
|
|
87
|
-
* 2. The fulfiller should have sufficient balance of all consideration items after receiving all offered items
|
|
88
|
-
* — by way of example, if the fulfilled order offers an ERC20 item and requires an ERC721 item to the offerer
|
|
89
|
-
* and the same ERC20 item to another recipient with an amount less than or equal to the offered amount,
|
|
90
|
-
* the fulfiller does not need to own the ERC20 item as it will first be received from the offerer.
|
|
91
|
-
* 3. If the fulfiller does not elect to utilize a proxy, they need to have sufficient approvals set for the
|
|
92
|
-
* Seaport contract for all ERC20, ERC721, and ERC1155 consideration items on the fulfilled order.
|
|
93
|
-
* 4. If the fulfiller does elect to utilize a proxy, they need to have sufficient approvals set for their
|
|
94
|
-
* respective proxy contract for all ERC20, ERC721, and ERC1155 consideration items on the fulfilled order.
|
|
95
|
-
* 5. If the fulfilled order specifies Ether (or other native tokens) as consideration items, the fulfiller must
|
|
96
|
-
* be able to supply the sum total of those items as msg.value.
|
|
97
|
-
*
|
|
98
|
-
* @returns the list of insufficient owner and proxy approvals
|
|
99
|
-
*/
|
|
100
|
-
export declare const validateStandardFulfillBalancesAndApprovals: ({ offer, consideration, offerCriteria, considerationCriteria, offererBalancesAndApprovals, fulfillerBalancesAndApprovals, timeBasedItemParams, offererOperator, fulfillerOperator, }: Pick<OrderParameters, "offer" | "consideration"> & {
|
|
101
|
-
offerCriteria: InputCriteria[];
|
|
102
|
-
considerationCriteria: InputCriteria[];
|
|
103
|
-
offererBalancesAndApprovals: BalancesAndApprovals;
|
|
104
|
-
fulfillerBalancesAndApprovals: BalancesAndApprovals;
|
|
105
|
-
timeBasedItemParams: TimeBasedItemParams;
|
|
106
|
-
offererOperator: string;
|
|
107
|
-
fulfillerOperator: string;
|
|
108
|
-
}) => InsufficientApprovals;
|
|
1
|
+
import { providers as multicallProviders } from "@0xsequence/multicall";
|
|
2
|
+
import { BigNumber } from "ethers";
|
|
3
|
+
import { ItemType } from "../constants";
|
|
4
|
+
import type { InputCriteria, Item, OrderParameters } from "../types";
|
|
5
|
+
import { getSummedTokenAndIdentifierAmounts, TimeBasedItemParams } from "./item";
|
|
6
|
+
export declare type BalancesAndApprovals = {
|
|
7
|
+
token: string;
|
|
8
|
+
identifierOrCriteria: string;
|
|
9
|
+
balance: BigNumber;
|
|
10
|
+
approvedAmount: BigNumber;
|
|
11
|
+
itemType: ItemType;
|
|
12
|
+
}[];
|
|
13
|
+
export declare type InsufficientBalances = {
|
|
14
|
+
token: string;
|
|
15
|
+
identifierOrCriteria: string;
|
|
16
|
+
requiredAmount: BigNumber;
|
|
17
|
+
amountHave: BigNumber;
|
|
18
|
+
itemType: ItemType;
|
|
19
|
+
}[];
|
|
20
|
+
export declare type InsufficientApprovals = {
|
|
21
|
+
token: string;
|
|
22
|
+
identifierOrCriteria: string;
|
|
23
|
+
approvedAmount: BigNumber;
|
|
24
|
+
requiredApprovedAmount: BigNumber;
|
|
25
|
+
operator: string;
|
|
26
|
+
itemType: ItemType;
|
|
27
|
+
}[];
|
|
28
|
+
export declare const getBalancesAndApprovals: ({ owner, items, criterias, operator, multicallProvider, }: {
|
|
29
|
+
owner: string;
|
|
30
|
+
items: Item[];
|
|
31
|
+
criterias: InputCriteria[];
|
|
32
|
+
operator: string;
|
|
33
|
+
multicallProvider: multicallProviders.MulticallProvider;
|
|
34
|
+
}) => Promise<BalancesAndApprovals>;
|
|
35
|
+
export declare const getInsufficientBalanceAndApprovalAmounts: ({ balancesAndApprovals, tokenAndIdentifierAmounts, operator, }: {
|
|
36
|
+
balancesAndApprovals: BalancesAndApprovals;
|
|
37
|
+
tokenAndIdentifierAmounts: ReturnType<typeof getSummedTokenAndIdentifierAmounts>;
|
|
38
|
+
operator: string;
|
|
39
|
+
}) => {
|
|
40
|
+
insufficientBalances: InsufficientBalances;
|
|
41
|
+
insufficientApprovals: InsufficientApprovals;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* 1. The offerer should have sufficient balance of all offered items.
|
|
45
|
+
* 2. If the order does not indicate proxy utilization, the offerer should have sufficient approvals set
|
|
46
|
+
* for the Seaport contract for all offered ERC20, ERC721, and ERC1155 items.
|
|
47
|
+
* 3. If the order does indicate proxy utilization, the offerer should have sufficient approvals set
|
|
48
|
+
* for their respective proxy contract for all offered ERC20, ERC721, and ERC1155 items.
|
|
49
|
+
*/
|
|
50
|
+
export declare const validateOfferBalancesAndApprovals: ({ offer, criterias, balancesAndApprovals, timeBasedItemParams, throwOnInsufficientBalances, throwOnInsufficientApprovals, operator, }: {
|
|
51
|
+
balancesAndApprovals: BalancesAndApprovals;
|
|
52
|
+
timeBasedItemParams?: TimeBasedItemParams | undefined;
|
|
53
|
+
throwOnInsufficientBalances?: boolean | undefined;
|
|
54
|
+
throwOnInsufficientApprovals?: boolean | undefined;
|
|
55
|
+
operator: string;
|
|
56
|
+
} & Pick<OrderParameters, "offer"> & {
|
|
57
|
+
criterias: InputCriteria[];
|
|
58
|
+
}) => InsufficientApprovals;
|
|
59
|
+
/**
|
|
60
|
+
* When fulfilling a basic order, the following requirements need to be checked to ensure that the order will be fulfillable:
|
|
61
|
+
* 1. Offer checks need to be performed to ensure that the offerer still has sufficient balance and approvals
|
|
62
|
+
* 2. The fulfiller should have sufficient balance of all consideration items except for those with an
|
|
63
|
+
* item type that matches the order's offered item type — by way of example, if the fulfilled order offers
|
|
64
|
+
* an ERC20 item and requires an ERC721 item to the offerer and the same ERC20 item to another recipient,
|
|
65
|
+
* the fulfiller needs to own the ERC721 item but does not need to own the ERC20 item as it will be sourced from the offerer.
|
|
66
|
+
* 3. If the fulfiller does not elect to utilize a proxy, they need to have sufficient approvals set for the
|
|
67
|
+
* Seaport contract for all ERC20, ERC721, and ERC1155 consideration items on the fulfilled order except
|
|
68
|
+
* for ERC20 items with an item type that matches the order's offered item type.
|
|
69
|
+
* 4. If the fulfiller does elect to utilize a proxy, they need to have sufficient approvals set for their
|
|
70
|
+
* respective proxy contract for all ERC20, ERC721, and ERC1155 consideration items on the fulfilled order
|
|
71
|
+
* except for ERC20 items with an item type that matches the order's offered item type.
|
|
72
|
+
* 5. If the fulfilled order specifies Ether (or other native tokens) as consideration items, the fulfiller must
|
|
73
|
+
* be able to supply the sum total of those items as msg.value.
|
|
74
|
+
*
|
|
75
|
+
* @returns the list of insufficient owner and proxy approvals
|
|
76
|
+
*/
|
|
77
|
+
export declare const validateBasicFulfillBalancesAndApprovals: ({ offer, consideration, offererBalancesAndApprovals, fulfillerBalancesAndApprovals, timeBasedItemParams, offererOperator, fulfillerOperator, }: {
|
|
78
|
+
offererBalancesAndApprovals: BalancesAndApprovals;
|
|
79
|
+
fulfillerBalancesAndApprovals: BalancesAndApprovals;
|
|
80
|
+
timeBasedItemParams: TimeBasedItemParams;
|
|
81
|
+
offererOperator: string;
|
|
82
|
+
fulfillerOperator: string;
|
|
83
|
+
} & Pick<OrderParameters, "offer" | "consideration">) => InsufficientApprovals;
|
|
84
|
+
/**
|
|
85
|
+
* When fulfilling a standard order, the following requirements need to be checked to ensure that the order will be fulfillable:
|
|
86
|
+
* 1. Offer checks need to be performed to ensure that the offerer still has sufficient balance and approvals
|
|
87
|
+
* 2. The fulfiller should have sufficient balance of all consideration items after receiving all offered items
|
|
88
|
+
* — by way of example, if the fulfilled order offers an ERC20 item and requires an ERC721 item to the offerer
|
|
89
|
+
* and the same ERC20 item to another recipient with an amount less than or equal to the offered amount,
|
|
90
|
+
* the fulfiller does not need to own the ERC20 item as it will first be received from the offerer.
|
|
91
|
+
* 3. If the fulfiller does not elect to utilize a proxy, they need to have sufficient approvals set for the
|
|
92
|
+
* Seaport contract for all ERC20, ERC721, and ERC1155 consideration items on the fulfilled order.
|
|
93
|
+
* 4. If the fulfiller does elect to utilize a proxy, they need to have sufficient approvals set for their
|
|
94
|
+
* respective proxy contract for all ERC20, ERC721, and ERC1155 consideration items on the fulfilled order.
|
|
95
|
+
* 5. If the fulfilled order specifies Ether (or other native tokens) as consideration items, the fulfiller must
|
|
96
|
+
* be able to supply the sum total of those items as msg.value.
|
|
97
|
+
*
|
|
98
|
+
* @returns the list of insufficient owner and proxy approvals
|
|
99
|
+
*/
|
|
100
|
+
export declare const validateStandardFulfillBalancesAndApprovals: ({ offer, consideration, offerCriteria, considerationCriteria, offererBalancesAndApprovals, fulfillerBalancesAndApprovals, timeBasedItemParams, offererOperator, fulfillerOperator, }: Pick<OrderParameters, "offer" | "consideration"> & {
|
|
101
|
+
offerCriteria: InputCriteria[];
|
|
102
|
+
considerationCriteria: InputCriteria[];
|
|
103
|
+
offererBalancesAndApprovals: BalancesAndApprovals;
|
|
104
|
+
fulfillerBalancesAndApprovals: BalancesAndApprovals;
|
|
105
|
+
timeBasedItemParams: TimeBasedItemParams;
|
|
106
|
+
offererOperator: string;
|
|
107
|
+
fulfillerOperator: string;
|
|
108
|
+
}) => InsufficientApprovals;
|
package/lib/utils/criteria.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { Side } from "../constants";
|
|
2
|
-
import { InputCriteria,
|
|
3
|
-
export declare const generateCriteriaResolvers: ({ orders, offerCriterias, considerationCriterias, }: {
|
|
4
|
-
orders: Order[];
|
|
5
|
-
offerCriterias?: InputCriteria[][] | undefined;
|
|
6
|
-
considerationCriterias?: InputCriteria[][] | undefined;
|
|
7
|
-
}) => {
|
|
8
|
-
orderIndex: number;
|
|
9
|
-
index: number;
|
|
10
|
-
side: Side;
|
|
11
|
-
identifier: string;
|
|
12
|
-
criteriaProof: string[];
|
|
13
|
-
}[];
|
|
14
|
-
export declare const getItemToCriteriaMap: (items: Item[], criterias: InputCriteria[]) => Map<Item, InputCriteria>;
|
|
1
|
+
import { Side } from "../constants";
|
|
2
|
+
import { InputCriteria, Order } from "../types";
|
|
3
|
+
export declare const generateCriteriaResolvers: ({ orders, offerCriterias, considerationCriterias, }: {
|
|
4
|
+
orders: Order[];
|
|
5
|
+
offerCriterias?: InputCriteria[][] | undefined;
|
|
6
|
+
considerationCriterias?: InputCriteria[][] | undefined;
|
|
7
|
+
}) => {
|
|
8
|
+
orderIndex: number;
|
|
9
|
+
index: number;
|
|
10
|
+
side: Side;
|
|
11
|
+
identifier: string;
|
|
12
|
+
criteriaProof: string[];
|
|
13
|
+
}[];
|
package/lib/utils/fulfill.d.ts
CHANGED
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
import { BigNumber, BigNumberish, providers } from "ethers";
|
|
2
|
-
import type { Seaport as SeaportContract, Seaport, FulfillmentComponentStruct } from "../typechain/Seaport";
|
|
3
|
-
import type { ConsiderationItem, ExchangeAction, InputCriteria, Order, OrderParameters, OrderStatus, OrderUseCase, ContractMethodReturnType } from "../types";
|
|
4
|
-
import { BalancesAndApprovals } from "./balanceAndApprovalCheck";
|
|
5
|
-
import { TimeBasedItemParams } from "./item";
|
|
6
|
-
/**
|
|
7
|
-
* We should use basic fulfill order if the order adheres to the following criteria:
|
|
8
|
-
* 1. The order should not be partially filled.
|
|
9
|
-
* 2. The order only contains a single offer item and contains at least one consideration item
|
|
10
|
-
* 3. The order does not offer an item with Ether (or other native tokens) as its item type.
|
|
11
|
-
* 4. The order only contains a single ERC721 or ERC1155 item and that item is not criteria-based
|
|
12
|
-
* 5. All other items have the same Native or ERC20 item type and token
|
|
13
|
-
* 6. All items have the same startAmount and endAmount
|
|
14
|
-
* 7. First consideration item must contain the offerer as the recipient
|
|
15
|
-
* 8. If the order has multiple consideration items and all consideration items other than the
|
|
16
|
-
* first consideration item have the same item type as the offered item, the offered item
|
|
17
|
-
* amount is not less than the sum of all consideration item amounts excluding the
|
|
18
|
-
* first consideration item amount
|
|
19
|
-
* 9. The token on native currency items needs to be set to the null address and the identifier on
|
|
20
|
-
* currencies needs to be zero, and the amounts on the 721 item need to be 1
|
|
21
|
-
*/
|
|
22
|
-
export declare const shouldUseBasicFulfill: ({ offer, consideration, offerer }: OrderParameters, totalFilled: OrderStatus["totalFilled"]) => boolean;
|
|
23
|
-
export declare function fulfillBasicOrder({ order, seaportContract, offererBalancesAndApprovals, fulfillerBalancesAndApprovals, timeBasedItemParams, offererOperator, fulfillerOperator, signer, tips, conduitKey, }: {
|
|
24
|
-
order: Order;
|
|
25
|
-
seaportContract: Seaport;
|
|
26
|
-
offererBalancesAndApprovals: BalancesAndApprovals;
|
|
27
|
-
fulfillerBalancesAndApprovals: BalancesAndApprovals;
|
|
28
|
-
timeBasedItemParams: TimeBasedItemParams;
|
|
29
|
-
offererOperator: string;
|
|
30
|
-
fulfillerOperator: string;
|
|
31
|
-
signer: providers.JsonRpcSigner;
|
|
32
|
-
tips?: ConsiderationItem[];
|
|
33
|
-
conduitKey: string;
|
|
34
|
-
}): Promise<OrderUseCase<ExchangeAction<ContractMethodReturnType<SeaportContract, "fulfillBasicOrder">>>>;
|
|
35
|
-
export declare function fulfillStandardOrder({ order, unitsToFill, totalSize, totalFilled, offerCriteria, considerationCriteria, tips, extraData, seaportContract, offererBalancesAndApprovals, fulfillerBalancesAndApprovals, offererOperator, fulfillerOperator, timeBasedItemParams, conduitKey, recipientAddress, signer, }: {
|
|
36
|
-
order: Order;
|
|
37
|
-
unitsToFill?: BigNumberish;
|
|
38
|
-
totalFilled: BigNumber;
|
|
39
|
-
totalSize: BigNumber;
|
|
40
|
-
offerCriteria: InputCriteria[];
|
|
41
|
-
considerationCriteria: InputCriteria[];
|
|
42
|
-
tips?: ConsiderationItem[];
|
|
43
|
-
extraData?: string;
|
|
44
|
-
seaportContract: Seaport;
|
|
45
|
-
offererBalancesAndApprovals: BalancesAndApprovals;
|
|
46
|
-
fulfillerBalancesAndApprovals: BalancesAndApprovals;
|
|
47
|
-
offererOperator: string;
|
|
48
|
-
fulfillerOperator: string;
|
|
49
|
-
conduitKey: string;
|
|
50
|
-
recipientAddress: string;
|
|
51
|
-
timeBasedItemParams: TimeBasedItemParams;
|
|
52
|
-
signer: providers.JsonRpcSigner;
|
|
53
|
-
}): Promise<OrderUseCase<ExchangeAction<ContractMethodReturnType<SeaportContract, "fulfillAdvancedOrder" | "fulfillOrder">>>>;
|
|
54
|
-
export declare function validateAndSanitizeFromOrderStatus(order: Order, orderStatus: OrderStatus): Order;
|
|
55
|
-
export declare type FulfillOrdersMetadata = {
|
|
56
|
-
order: Order;
|
|
57
|
-
unitsToFill?: BigNumberish;
|
|
58
|
-
orderStatus: OrderStatus;
|
|
59
|
-
offerCriteria: InputCriteria[];
|
|
60
|
-
considerationCriteria: InputCriteria[];
|
|
61
|
-
tips: ConsiderationItem[];
|
|
62
|
-
extraData: string;
|
|
63
|
-
offererBalancesAndApprovals: BalancesAndApprovals;
|
|
64
|
-
offererOperator: string;
|
|
65
|
-
}[];
|
|
66
|
-
export declare function fulfillAvailableOrders({ ordersMetadata, seaportContract, fulfillerBalancesAndApprovals, fulfillerOperator, currentBlockTimestamp, ascendingAmountTimestampBuffer, conduitKey, signer, recipientAddress, }: {
|
|
67
|
-
ordersMetadata: FulfillOrdersMetadata;
|
|
68
|
-
seaportContract: Seaport;
|
|
69
|
-
fulfillerBalancesAndApprovals: BalancesAndApprovals;
|
|
70
|
-
fulfillerOperator: string;
|
|
71
|
-
currentBlockTimestamp: number;
|
|
72
|
-
ascendingAmountTimestampBuffer: number;
|
|
73
|
-
conduitKey: string;
|
|
74
|
-
signer: providers.JsonRpcSigner;
|
|
75
|
-
recipientAddress: string;
|
|
76
|
-
}): Promise<OrderUseCase<ExchangeAction<ContractMethodReturnType<SeaportContract, "fulfillAvailableAdvancedOrders">>>>;
|
|
77
|
-
export declare function generateFulfillOrdersFulfillments(ordersMetadata: FulfillOrdersMetadata): {
|
|
78
|
-
offerFulfillments: FulfillmentComponentStruct[];
|
|
79
|
-
considerationFulfillments: FulfillmentComponentStruct[];
|
|
80
|
-
};
|
|
81
|
-
export declare const getAdvancedOrderNumeratorDenominator: (order: Order, unitsToFill?: BigNumberish | undefined) => {
|
|
82
|
-
numerator: BigNumber;
|
|
83
|
-
denominator: BigNumber;
|
|
84
|
-
};
|
|
1
|
+
import { BigNumber, BigNumberish, providers } from "ethers";
|
|
2
|
+
import type { Seaport as SeaportContract, Seaport, FulfillmentComponentStruct } from "../typechain/Seaport";
|
|
3
|
+
import type { ConsiderationItem, ExchangeAction, InputCriteria, Order, OrderParameters, OrderStatus, OrderUseCase, ContractMethodReturnType } from "../types";
|
|
4
|
+
import { BalancesAndApprovals } from "./balanceAndApprovalCheck";
|
|
5
|
+
import { TimeBasedItemParams } from "./item";
|
|
6
|
+
/**
|
|
7
|
+
* We should use basic fulfill order if the order adheres to the following criteria:
|
|
8
|
+
* 1. The order should not be partially filled.
|
|
9
|
+
* 2. The order only contains a single offer item and contains at least one consideration item
|
|
10
|
+
* 3. The order does not offer an item with Ether (or other native tokens) as its item type.
|
|
11
|
+
* 4. The order only contains a single ERC721 or ERC1155 item and that item is not criteria-based
|
|
12
|
+
* 5. All other items have the same Native or ERC20 item type and token
|
|
13
|
+
* 6. All items have the same startAmount and endAmount
|
|
14
|
+
* 7. First consideration item must contain the offerer as the recipient
|
|
15
|
+
* 8. If the order has multiple consideration items and all consideration items other than the
|
|
16
|
+
* first consideration item have the same item type as the offered item, the offered item
|
|
17
|
+
* amount is not less than the sum of all consideration item amounts excluding the
|
|
18
|
+
* first consideration item amount
|
|
19
|
+
* 9. The token on native currency items needs to be set to the null address and the identifier on
|
|
20
|
+
* currencies needs to be zero, and the amounts on the 721 item need to be 1
|
|
21
|
+
*/
|
|
22
|
+
export declare const shouldUseBasicFulfill: ({ offer, consideration, offerer }: OrderParameters, totalFilled: OrderStatus["totalFilled"]) => boolean;
|
|
23
|
+
export declare function fulfillBasicOrder({ order, seaportContract, offererBalancesAndApprovals, fulfillerBalancesAndApprovals, timeBasedItemParams, offererOperator, fulfillerOperator, signer, tips, conduitKey, }: {
|
|
24
|
+
order: Order;
|
|
25
|
+
seaportContract: Seaport;
|
|
26
|
+
offererBalancesAndApprovals: BalancesAndApprovals;
|
|
27
|
+
fulfillerBalancesAndApprovals: BalancesAndApprovals;
|
|
28
|
+
timeBasedItemParams: TimeBasedItemParams;
|
|
29
|
+
offererOperator: string;
|
|
30
|
+
fulfillerOperator: string;
|
|
31
|
+
signer: providers.JsonRpcSigner;
|
|
32
|
+
tips?: ConsiderationItem[];
|
|
33
|
+
conduitKey: string;
|
|
34
|
+
}): Promise<OrderUseCase<ExchangeAction<ContractMethodReturnType<SeaportContract, "fulfillBasicOrder">>>>;
|
|
35
|
+
export declare function fulfillStandardOrder({ order, unitsToFill, totalSize, totalFilled, offerCriteria, considerationCriteria, tips, extraData, seaportContract, offererBalancesAndApprovals, fulfillerBalancesAndApprovals, offererOperator, fulfillerOperator, timeBasedItemParams, conduitKey, recipientAddress, signer, }: {
|
|
36
|
+
order: Order;
|
|
37
|
+
unitsToFill?: BigNumberish;
|
|
38
|
+
totalFilled: BigNumber;
|
|
39
|
+
totalSize: BigNumber;
|
|
40
|
+
offerCriteria: InputCriteria[];
|
|
41
|
+
considerationCriteria: InputCriteria[];
|
|
42
|
+
tips?: ConsiderationItem[];
|
|
43
|
+
extraData?: string;
|
|
44
|
+
seaportContract: Seaport;
|
|
45
|
+
offererBalancesAndApprovals: BalancesAndApprovals;
|
|
46
|
+
fulfillerBalancesAndApprovals: BalancesAndApprovals;
|
|
47
|
+
offererOperator: string;
|
|
48
|
+
fulfillerOperator: string;
|
|
49
|
+
conduitKey: string;
|
|
50
|
+
recipientAddress: string;
|
|
51
|
+
timeBasedItemParams: TimeBasedItemParams;
|
|
52
|
+
signer: providers.JsonRpcSigner;
|
|
53
|
+
}): Promise<OrderUseCase<ExchangeAction<ContractMethodReturnType<SeaportContract, "fulfillAdvancedOrder" | "fulfillOrder">>>>;
|
|
54
|
+
export declare function validateAndSanitizeFromOrderStatus(order: Order, orderStatus: OrderStatus): Order;
|
|
55
|
+
export declare type FulfillOrdersMetadata = {
|
|
56
|
+
order: Order;
|
|
57
|
+
unitsToFill?: BigNumberish;
|
|
58
|
+
orderStatus: OrderStatus;
|
|
59
|
+
offerCriteria: InputCriteria[];
|
|
60
|
+
considerationCriteria: InputCriteria[];
|
|
61
|
+
tips: ConsiderationItem[];
|
|
62
|
+
extraData: string;
|
|
63
|
+
offererBalancesAndApprovals: BalancesAndApprovals;
|
|
64
|
+
offererOperator: string;
|
|
65
|
+
}[];
|
|
66
|
+
export declare function fulfillAvailableOrders({ ordersMetadata, seaportContract, fulfillerBalancesAndApprovals, fulfillerOperator, currentBlockTimestamp, ascendingAmountTimestampBuffer, conduitKey, signer, recipientAddress, }: {
|
|
67
|
+
ordersMetadata: FulfillOrdersMetadata;
|
|
68
|
+
seaportContract: Seaport;
|
|
69
|
+
fulfillerBalancesAndApprovals: BalancesAndApprovals;
|
|
70
|
+
fulfillerOperator: string;
|
|
71
|
+
currentBlockTimestamp: number;
|
|
72
|
+
ascendingAmountTimestampBuffer: number;
|
|
73
|
+
conduitKey: string;
|
|
74
|
+
signer: providers.JsonRpcSigner;
|
|
75
|
+
recipientAddress: string;
|
|
76
|
+
}): Promise<OrderUseCase<ExchangeAction<ContractMethodReturnType<SeaportContract, "fulfillAvailableAdvancedOrders">>>>;
|
|
77
|
+
export declare function generateFulfillOrdersFulfillments(ordersMetadata: FulfillOrdersMetadata): {
|
|
78
|
+
offerFulfillments: FulfillmentComponentStruct[];
|
|
79
|
+
considerationFulfillments: FulfillmentComponentStruct[];
|
|
80
|
+
};
|
|
81
|
+
export declare const getAdvancedOrderNumeratorDenominator: (order: Order, unitsToFill?: BigNumberish | undefined) => {
|
|
82
|
+
numerator: BigNumber;
|
|
83
|
+
denominator: BigNumber;
|
|
84
|
+
};
|
package/lib/utils/gcd.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { BigNumber, BigNumberish } from "ethers";
|
|
2
|
-
export declare const gcd: (a: BigNumberish, b: BigNumberish) => BigNumber;
|
|
3
|
-
export declare const findGcd: (elements: BigNumberish[]) => BigNumber;
|
|
1
|
+
import { BigNumber, BigNumberish } from "ethers";
|
|
2
|
+
export declare const gcd: (a: BigNumberish, b: BigNumberish) => BigNumber;
|
|
3
|
+
export declare const findGcd: (elements: BigNumberish[]) => BigNumber;
|
package/lib/utils/item.d.ts
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
import { BigNumber } from "ethers";
|
|
2
|
-
import type { InputCriteria, Item, Order, OrderParameters } from "../types";
|
|
3
|
-
export declare const isCurrencyItem: ({ itemType }: Item) => boolean;
|
|
4
|
-
export declare const isNativeCurrencyItem: ({ itemType }: Item) => boolean;
|
|
5
|
-
export declare const isErc20Item: (itemType: Item["itemType"]) => boolean;
|
|
6
|
-
export declare const isErc721Item: (itemType: Item["itemType"]) => boolean;
|
|
7
|
-
export declare const isErc1155Item: (itemType: Item["itemType"]) => boolean;
|
|
8
|
-
export declare const isCriteriaItem: (itemType: Item["itemType"]) => boolean;
|
|
9
|
-
export declare type TimeBasedItemParams = {
|
|
10
|
-
isConsiderationItem?: boolean;
|
|
11
|
-
currentBlockTimestamp: number;
|
|
12
|
-
ascendingAmountTimestampBuffer: number;
|
|
13
|
-
} & Pick<OrderParameters, "startTime" | "endTime">;
|
|
14
|
-
export declare const getPresentItemAmount: ({ startAmount, endAmount, timeBasedItemParams, }: Pick<Item, "startAmount" | "endAmount"> & {
|
|
15
|
-
timeBasedItemParams?: TimeBasedItemParams | undefined;
|
|
16
|
-
}) => BigNumber;
|
|
17
|
-
export declare const getSummedTokenAndIdentifierAmounts: ({ items, criterias, timeBasedItemParams, }: {
|
|
18
|
-
items: Item[];
|
|
19
|
-
criterias: InputCriteria[];
|
|
20
|
-
timeBasedItemParams?: TimeBasedItemParams | undefined;
|
|
21
|
-
}) => Record<string, Record<string, BigNumber>>;
|
|
22
|
-
/**
|
|
23
|
-
* Returns the maximum size of units possible for the order
|
|
24
|
-
* If any of the items on a partially fillable order specify a different "startAmount" and "endAmount
|
|
25
|
-
* (e.g. they are ascending-amount or descending-amount items), the fraction will be applied to both amounts
|
|
26
|
-
* prior to determining the current price. This ensures that cleanly divisible amounts can be chosen when
|
|
27
|
-
* constructing the order without a dependency on the time when the order is ultimately fulfilled.
|
|
28
|
-
*/
|
|
29
|
-
export declare const getMaximumSizeForOrder: ({ parameters: { offer, consideration }, }: Order) => BigNumber;
|
|
1
|
+
import { BigNumber } from "ethers";
|
|
2
|
+
import type { InputCriteria, Item, Order, OrderParameters } from "../types";
|
|
3
|
+
export declare const isCurrencyItem: ({ itemType }: Item) => boolean;
|
|
4
|
+
export declare const isNativeCurrencyItem: ({ itemType }: Item) => boolean;
|
|
5
|
+
export declare const isErc20Item: (itemType: Item["itemType"]) => boolean;
|
|
6
|
+
export declare const isErc721Item: (itemType: Item["itemType"]) => boolean;
|
|
7
|
+
export declare const isErc1155Item: (itemType: Item["itemType"]) => boolean;
|
|
8
|
+
export declare const isCriteriaItem: (itemType: Item["itemType"]) => boolean;
|
|
9
|
+
export declare type TimeBasedItemParams = {
|
|
10
|
+
isConsiderationItem?: boolean;
|
|
11
|
+
currentBlockTimestamp: number;
|
|
12
|
+
ascendingAmountTimestampBuffer: number;
|
|
13
|
+
} & Pick<OrderParameters, "startTime" | "endTime">;
|
|
14
|
+
export declare const getPresentItemAmount: ({ startAmount, endAmount, timeBasedItemParams, }: Pick<Item, "startAmount" | "endAmount"> & {
|
|
15
|
+
timeBasedItemParams?: TimeBasedItemParams | undefined;
|
|
16
|
+
}) => BigNumber;
|
|
17
|
+
export declare const getSummedTokenAndIdentifierAmounts: ({ items, criterias, timeBasedItemParams, }: {
|
|
18
|
+
items: Item[];
|
|
19
|
+
criterias: InputCriteria[];
|
|
20
|
+
timeBasedItemParams?: TimeBasedItemParams | undefined;
|
|
21
|
+
}) => Record<string, Record<string, BigNumber>>;
|
|
22
|
+
/**
|
|
23
|
+
* Returns the maximum size of units possible for the order
|
|
24
|
+
* If any of the items on a partially fillable order specify a different "startAmount" and "endAmount
|
|
25
|
+
* (e.g. they are ascending-amount or descending-amount items), the fraction will be applied to both amounts
|
|
26
|
+
* prior to determining the current price. This ensures that cleanly divisible amounts can be chosen when
|
|
27
|
+
* constructing the order without a dependency on the time when the order is ultimately fulfilled.
|
|
28
|
+
*/
|
|
29
|
+
export declare const getMaximumSizeForOrder: ({ parameters: { offer, consideration }, }: Order) => BigNumber;
|
|
30
|
+
export declare const getItemToCriteriaMap: (items: Item[], criterias: InputCriteria[]) => Map<Item, InputCriteria>;
|
package/lib/utils/match.d.ts
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
/** Giant TODO for match orders
|
|
2
|
-
# Match orders
|
|
1
|
+
/** Giant TODO for match orders
|
|
2
|
+
# Match orders
|
|
3
3
|
|
|
4
|
-
- Format: list of fulfillments
|
|
5
|
-
- Each fulfillment represents a single transfer or “execution”
|
|
6
|
-
- Each fulfillment specifies an array of offer “components” corresponding to offer items to spend as well as an array of consideration “components” corresponding to consideration items to receive
|
|
7
|
-
- every offer component and consideration component contains an index of the order it is from as well as an index of the item in the respective offer or consideration array on that order
|
|
8
|
-
- the “from” address will be the offerer of whatever offer items are being spent
|
|
9
|
-
- the “to” address will be the recipient of whatever consideration items are being received
|
|
10
|
-
- the “One rule” to follow for the whole set of fulfillments:
|
|
11
|
-
- All consideration items must be fully accounted for after adjusting for partial fills and ascending/descending amounts
|
|
12
|
-
- the “Four rules” to follow for each distinct fulfillment:
|
|
13
|
-
1. you need at least one offer component and at least one consideration component for each fulfillment; otherwise you don’t know what the “from” or “to” address should be
|
|
14
|
-
2. the offer item corresponding to the first offer component has to match the consideration item corresponding to the first consideration component (with the exception of the amount); otherwise you’re not sending the item that the recipient is expecting
|
|
15
|
-
3. any additional offer items need to match the original offer items (with the exception of the amount) and the same *the offerer*; otherwise you’re composing different items or different origins.
|
|
16
|
-
1. This implies that ERC721 fulfillments will always have a single offer component (even if that corresponding offer item is present in multiple fulfillments, i.e. criteria-based partial fills)
|
|
4
|
+
- Format: list of fulfillments
|
|
5
|
+
- Each fulfillment represents a single transfer or “execution”
|
|
6
|
+
- Each fulfillment specifies an array of offer “components” corresponding to offer items to spend as well as an array of consideration “components” corresponding to consideration items to receive
|
|
7
|
+
- every offer component and consideration component contains an index of the order it is from as well as an index of the item in the respective offer or consideration array on that order
|
|
8
|
+
- the “from” address will be the offerer of whatever offer items are being spent
|
|
9
|
+
- the “to” address will be the recipient of whatever consideration items are being received
|
|
10
|
+
- the “One rule” to follow for the whole set of fulfillments:
|
|
11
|
+
- All consideration items must be fully accounted for after adjusting for partial fills and ascending/descending amounts
|
|
12
|
+
- the “Four rules” to follow for each distinct fulfillment:
|
|
13
|
+
1. you need at least one offer component and at least one consideration component for each fulfillment; otherwise you don’t know what the “from” or “to” address should be
|
|
14
|
+
2. the offer item corresponding to the first offer component has to match the consideration item corresponding to the first consideration component (with the exception of the amount); otherwise you’re not sending the item that the recipient is expecting
|
|
15
|
+
3. any additional offer items need to match the original offer items (with the exception of the amount) and the same *the offerer*; otherwise you’re composing different items or different origins.
|
|
16
|
+
1. This implies that ERC721 fulfillments will always have a single offer component (even if that corresponding offer item is present in multiple fulfillments, i.e. criteria-based partial fills)
|
|
17
17
|
|
|
18
|
-
Example: Bulk purchase
|
|
18
|
+
Example: Bulk purchase
|
|
19
19
|
|
|
20
|
-
- Five distinct sellers create orders to sell ERC721 NFTs for ETH.
|
|
21
|
-
- single offer item on each order: the NFT
|
|
22
|
-
- two consideration items on each order: 10 ETH to the offerer and 1 ETH to OpenSea
|
|
23
|
-
- order index 1 through 5
|
|
24
|
-
- To fulfill this, fulfiller creates a *sixth* order to buy all 5 NFTs for ETH
|
|
25
|
-
- single offer item: 55 ETH or `(10 + 1) * 5`
|
|
26
|
-
- five consideration items: all five NFTs
|
|
27
|
-
- order index 0 (by convention)
|
|
28
|
-
- This order requires exactly 11 transfers or executions (assuming 5 distinct sellers), translating to 11 fulfillments:
|
|
29
|
-
- 5 transfers of 10 ETH each from order 0 offerer (i.e. fulfiller) to order 1-5 offerers
|
|
30
|
-
- These fulfillments will have a single offer component and single consideration component (offer component: order 0 index 0 and consideration component: orders 1-5 index 0)
|
|
31
|
-
- 5 transfers of 1 NFT each from order 1-5 offers to order 0 offerer (i.e. fulfiller)
|
|
32
|
-
- These fulfillments will have a single offer component and single fulfillment component (offer component: orders 1-5 index 0 and consideration component order 0 index 0-4)
|
|
33
|
-
- 1 transfer of 5 ETH from order 0 offerer (i.e. fulfiller) to OpenSea
|
|
34
|
-
- This fulfillment will have a single offer component mapping to order index 0 + item index 0, but *five* consideration components mapping to order index 1-5 + item index 1
|
|
20
|
+
- Five distinct sellers create orders to sell ERC721 NFTs for ETH.
|
|
21
|
+
- single offer item on each order: the NFT
|
|
22
|
+
- two consideration items on each order: 10 ETH to the offerer and 1 ETH to OpenSea
|
|
23
|
+
- order index 1 through 5
|
|
24
|
+
- To fulfill this, fulfiller creates a *sixth* order to buy all 5 NFTs for ETH
|
|
25
|
+
- single offer item: 55 ETH or `(10 + 1) * 5`
|
|
26
|
+
- five consideration items: all five NFTs
|
|
27
|
+
- order index 0 (by convention)
|
|
28
|
+
- This order requires exactly 11 transfers or executions (assuming 5 distinct sellers), translating to 11 fulfillments:
|
|
29
|
+
- 5 transfers of 10 ETH each from order 0 offerer (i.e. fulfiller) to order 1-5 offerers
|
|
30
|
+
- These fulfillments will have a single offer component and single consideration component (offer component: order 0 index 0 and consideration component: orders 1-5 index 0)
|
|
31
|
+
- 5 transfers of 1 NFT each from order 1-5 offers to order 0 offerer (i.e. fulfiller)
|
|
32
|
+
- These fulfillments will have a single offer component and single fulfillment component (offer component: orders 1-5 index 0 and consideration component order 0 index 0-4)
|
|
33
|
+
- 1 transfer of 5 ETH from order 0 offerer (i.e. fulfiller) to OpenSea
|
|
34
|
+
- This fulfillment will have a single offer component mapping to order index 0 + item index 0, but *five* consideration components mapping to order index 1-5 + item index 1
|
|
35
35
|
|
|
36
|
-
The algorithm (broad-strokes first pass)
|
|
36
|
+
The algorithm (broad-strokes first pass)
|
|
37
37
|
|
|
38
|
-
1. Take all the orders you want to fulfill and retrieve the latest amounts for those orders based on amount filled, amount *desired* to fill, and ascending/descending amounts (include sufficient buffer on those)
|
|
39
|
-
2. “flatten” those orders into:
|
|
40
|
-
- all the offer items (and include the order index, item index, and offerer alongside the item)
|
|
41
|
-
- all the consideration items (and include the order index and item index alongside the item; the recipient is already on the consideration items)
|
|
42
|
-
3. Aggregate those items by type + token + identifier + (offerer / recipient), summing up all the amounts (we do need to track the original amounts as well here)
|
|
43
|
-
4. Quickly check to see if there are any aggregated offer items with the same type + token + identifier + offerer as an aggregated consideration item’s type + token + identifier + recipient (i.e. offerer == recipient) — if so, create a fulfillment for those and decrement both (no execution / transfer will be created for these fulfillments)
|
|
44
|
-
5. Retrieve all approvals and balances for each aggregated offer item; increment / decrement them as we go and ensure they never go below zero
|
|
45
|
-
6. Search for fulfillments that can already be performed before the fulfiller’s order has even been created; if any exist, generate those fulfillments first (the goal is to reduce the number of items on the fulfiller’s order).
|
|
46
|
-
- To generate a fulfillment, subtract whatever is lower between the aggregated offer and aggregated consideration it is being matched with from both and register the fulfillment.
|
|
47
|
-
- There will likely be some combination that optimizes for total number of transfers; see if these can be optimized.
|
|
48
|
-
- By way of example, say a fulfiller is accepting offers to sell multiple NFTs at once, and the aggregate fees owed to OpenSea are exactly 1 WETH and it so happens that one of the NFTS has an offer for exactly 1 WETH — that offerer should pay the fees for all the orders being fulfilled in a single transaction.
|
|
49
|
-
- Repeat this process until the fulfillments cannot be compressed any further.
|
|
50
|
-
7. Then, create the mirror order with an offer item for each remaining (aggregated) consideration item and a consideration item for each remaining (aggregated) offer item; check for sufficient approval on each derived offer item
|
|
51
|
-
8. Run the same sequence as from in step 6, but include the last order as well
|
|
52
|
-
9. Ensure that all consideration items have been met!
|
|
53
|
-
*/
|
|
54
|
-
export {};
|
|
38
|
+
1. Take all the orders you want to fulfill and retrieve the latest amounts for those orders based on amount filled, amount *desired* to fill, and ascending/descending amounts (include sufficient buffer on those)
|
|
39
|
+
2. “flatten” those orders into:
|
|
40
|
+
- all the offer items (and include the order index, item index, and offerer alongside the item)
|
|
41
|
+
- all the consideration items (and include the order index and item index alongside the item; the recipient is already on the consideration items)
|
|
42
|
+
3. Aggregate those items by type + token + identifier + (offerer / recipient), summing up all the amounts (we do need to track the original amounts as well here)
|
|
43
|
+
4. Quickly check to see if there are any aggregated offer items with the same type + token + identifier + offerer as an aggregated consideration item’s type + token + identifier + recipient (i.e. offerer == recipient) — if so, create a fulfillment for those and decrement both (no execution / transfer will be created for these fulfillments)
|
|
44
|
+
5. Retrieve all approvals and balances for each aggregated offer item; increment / decrement them as we go and ensure they never go below zero
|
|
45
|
+
6. Search for fulfillments that can already be performed before the fulfiller’s order has even been created; if any exist, generate those fulfillments first (the goal is to reduce the number of items on the fulfiller’s order).
|
|
46
|
+
- To generate a fulfillment, subtract whatever is lower between the aggregated offer and aggregated consideration it is being matched with from both and register the fulfillment.
|
|
47
|
+
- There will likely be some combination that optimizes for total number of transfers; see if these can be optimized.
|
|
48
|
+
- By way of example, say a fulfiller is accepting offers to sell multiple NFTs at once, and the aggregate fees owed to OpenSea are exactly 1 WETH and it so happens that one of the NFTS has an offer for exactly 1 WETH — that offerer should pay the fees for all the orders being fulfilled in a single transaction.
|
|
49
|
+
- Repeat this process until the fulfillments cannot be compressed any further.
|
|
50
|
+
7. Then, create the mirror order with an offer item for each remaining (aggregated) consideration item and a consideration item for each remaining (aggregated) offer item; check for sufficient approval on each derived offer item
|
|
51
|
+
8. Run the same sequence as from in step 6, but include the last order as well
|
|
52
|
+
9. Ensure that all consideration items have been met!
|
|
53
|
+
*/
|
|
54
|
+
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import MerkleTreeJS from "merkletreejs";
|
|
2
|
-
/**
|
|
3
|
-
* Simple wrapper over the MerkleTree in merkletreejs.
|
|
4
|
-
* Handles hashing identifiers to be compatible with Seaport.
|
|
5
|
-
*/
|
|
6
|
-
export declare class MerkleTree {
|
|
7
|
-
tree: MerkleTreeJS;
|
|
8
|
-
constructor(identifiers: string[]);
|
|
9
|
-
getProof(identifier: string): string[];
|
|
10
|
-
getRoot(): string;
|
|
11
|
-
}
|
|
1
|
+
import MerkleTreeJS from "merkletreejs";
|
|
2
|
+
/**
|
|
3
|
+
* Simple wrapper over the MerkleTree in merkletreejs.
|
|
4
|
+
* Handles hashing identifiers to be compatible with Seaport.
|
|
5
|
+
*/
|
|
6
|
+
export declare class MerkleTree {
|
|
7
|
+
tree: MerkleTreeJS;
|
|
8
|
+
constructor(identifiers: string[]);
|
|
9
|
+
getProof(identifier: string): string[];
|
|
10
|
+
getRoot(): string;
|
|
11
|
+
}
|