@morpho-org/midnight-sdk 0.1.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/README.md +252 -0
- package/lib/cjs/abis.d.ts +3170 -0
- package/lib/cjs/abis.js +4073 -0
- package/lib/cjs/api/MidnightApi.d.ts +532 -0
- package/lib/cjs/api/MidnightApi.js +713 -0
- package/lib/cjs/api/helpers.d.ts +20 -0
- package/lib/cjs/api/helpers.js +189 -0
- package/lib/cjs/api/index.d.ts +2 -0
- package/lib/cjs/api/index.js +21 -0
- package/lib/cjs/api/types.d.ts +453 -0
- package/lib/cjs/api/types.js +2 -0
- package/lib/cjs/constants.d.ts +168 -0
- package/lib/cjs/constants.js +187 -0
- package/lib/cjs/errors.d.ts +253 -0
- package/lib/cjs/errors.js +309 -0
- package/lib/cjs/fetch/Market.d.ts +65 -0
- package/lib/cjs/fetch/Market.js +117 -0
- package/lib/cjs/fetch/Offer.d.ts +74 -0
- package/lib/cjs/fetch/Offer.js +119 -0
- package/lib/cjs/fetch/Position.d.ts +85 -0
- package/lib/cjs/fetch/Position.js +148 -0
- package/lib/cjs/fetch/Ratifier.d.ts +38 -0
- package/lib/cjs/fetch/Ratifier.js +57 -0
- package/lib/cjs/fetch/index.d.ts +5 -0
- package/lib/cjs/fetch/index.js +21 -0
- package/lib/cjs/fetch/types.d.ts +57 -0
- package/lib/cjs/fetch/types.js +2 -0
- package/lib/cjs/fetch/utils.d.ts +8 -0
- package/lib/cjs/fetch/utils.js +18 -0
- package/lib/cjs/index.d.ts +18 -0
- package/lib/cjs/index.js +57 -0
- package/lib/cjs/market/Market.d.ts +613 -0
- package/lib/cjs/market/Market.js +503 -0
- package/lib/cjs/market/MarketUtils.d.ts +189 -0
- package/lib/cjs/market/MarketUtils.js +303 -0
- package/lib/cjs/market/Position.d.ts +424 -0
- package/lib/cjs/market/Position.js +425 -0
- package/lib/cjs/market/PositionUtils.d.ts +115 -0
- package/lib/cjs/market/PositionUtils.js +194 -0
- package/lib/cjs/market/index.d.ts +4 -0
- package/lib/cjs/market/index.js +20 -0
- package/lib/cjs/math/ConsumableUnitsLib.d.ts +57 -0
- package/lib/cjs/math/ConsumableUnitsLib.js +77 -0
- package/lib/cjs/math/TakeAmountsLib.d.ts +175 -0
- package/lib/cjs/math/TakeAmountsLib.js +199 -0
- package/lib/cjs/math/TickLib.d.ts +200 -0
- package/lib/cjs/math/TickLib.js +272 -0
- package/lib/cjs/math/index.d.ts +3 -0
- package/lib/cjs/math/index.js +19 -0
- package/lib/cjs/offers/Offer.d.ts +534 -0
- package/lib/cjs/offers/Offer.js +343 -0
- package/lib/cjs/offers/OfferUtils.d.ts +565 -0
- package/lib/cjs/offers/OfferUtils.js +659 -0
- package/lib/cjs/offers/index.d.ts +2 -0
- package/lib/cjs/offers/index.js +18 -0
- package/lib/cjs/package.json +1 -0
- package/lib/cjs/queries/GetPosition.d.ts +55 -0
- package/lib/cjs/queries/GetPosition.js +74 -0
- package/lib/cjs/queries/index.d.ts +1 -0
- package/lib/cjs/queries/index.js +37 -0
- package/lib/cjs/signatures/EcrecoverRatifierUtils.d.ts +733 -0
- package/lib/cjs/signatures/EcrecoverRatifierUtils.js +618 -0
- package/lib/cjs/signatures/Group.d.ts +178 -0
- package/lib/cjs/signatures/Group.js +193 -0
- package/lib/cjs/signatures/GroupUtils.d.ts +191 -0
- package/lib/cjs/signatures/GroupUtils.js +127 -0
- package/lib/cjs/signatures/Payload.d.ts +283 -0
- package/lib/cjs/signatures/Payload.js +570 -0
- package/lib/cjs/signatures/RatifierUtils.d.ts +109 -0
- package/lib/cjs/signatures/RatifierUtils.js +76 -0
- package/lib/cjs/signatures/SetterRatifierUtils.d.ts +243 -0
- package/lib/cjs/signatures/SetterRatifierUtils.js +217 -0
- package/lib/cjs/signatures/Tree.d.ts +241 -0
- package/lib/cjs/signatures/Tree.js +263 -0
- package/lib/cjs/signatures/TreeUtils.d.ts +573 -0
- package/lib/cjs/signatures/TreeUtils.js +461 -0
- package/lib/cjs/signatures/index.d.ts +7 -0
- package/lib/cjs/signatures/index.js +23 -0
- package/lib/esm/abis.d.ts +3170 -0
- package/lib/esm/abis.js +4070 -0
- package/lib/esm/api/MidnightApi.d.ts +532 -0
- package/lib/esm/api/MidnightApi.js +709 -0
- package/lib/esm/api/helpers.d.ts +20 -0
- package/lib/esm/api/helpers.js +180 -0
- package/lib/esm/api/index.d.ts +2 -0
- package/lib/esm/api/index.js +2 -0
- package/lib/esm/api/types.d.ts +453 -0
- package/lib/esm/api/types.js +1 -0
- package/lib/esm/constants.d.ts +168 -0
- package/lib/esm/constants.js +184 -0
- package/lib/esm/errors.d.ts +253 -0
- package/lib/esm/errors.js +291 -0
- package/lib/esm/fetch/Market.d.ts +65 -0
- package/lib/esm/fetch/Market.js +113 -0
- package/lib/esm/fetch/Offer.d.ts +74 -0
- package/lib/esm/fetch/Offer.js +116 -0
- package/lib/esm/fetch/Position.d.ts +85 -0
- package/lib/esm/fetch/Position.js +144 -0
- package/lib/esm/fetch/Ratifier.d.ts +38 -0
- package/lib/esm/fetch/Ratifier.js +54 -0
- package/lib/esm/fetch/index.d.ts +5 -0
- package/lib/esm/fetch/index.js +5 -0
- package/lib/esm/fetch/types.d.ts +57 -0
- package/lib/esm/fetch/types.js +1 -0
- package/lib/esm/fetch/utils.d.ts +8 -0
- package/lib/esm/fetch/utils.js +12 -0
- package/lib/esm/index.d.ts +18 -0
- package/lib/esm/index.js +18 -0
- package/lib/esm/market/Market.d.ts +613 -0
- package/lib/esm/market/Market.js +498 -0
- package/lib/esm/market/MarketUtils.d.ts +189 -0
- package/lib/esm/market/MarketUtils.js +300 -0
- package/lib/esm/market/Position.d.ts +424 -0
- package/lib/esm/market/Position.js +420 -0
- package/lib/esm/market/PositionUtils.d.ts +115 -0
- package/lib/esm/market/PositionUtils.js +191 -0
- package/lib/esm/market/index.d.ts +4 -0
- package/lib/esm/market/index.js +4 -0
- package/lib/esm/math/ConsumableUnitsLib.d.ts +57 -0
- package/lib/esm/math/ConsumableUnitsLib.js +74 -0
- package/lib/esm/math/TakeAmountsLib.d.ts +175 -0
- package/lib/esm/math/TakeAmountsLib.js +196 -0
- package/lib/esm/math/TickLib.d.ts +200 -0
- package/lib/esm/math/TickLib.js +269 -0
- package/lib/esm/math/index.d.ts +3 -0
- package/lib/esm/math/index.js +3 -0
- package/lib/esm/offers/Offer.d.ts +534 -0
- package/lib/esm/offers/Offer.js +339 -0
- package/lib/esm/offers/OfferUtils.d.ts +565 -0
- package/lib/esm/offers/OfferUtils.js +656 -0
- package/lib/esm/offers/index.d.ts +2 -0
- package/lib/esm/offers/index.js +2 -0
- package/lib/esm/package.json +1 -0
- package/lib/esm/queries/GetPosition.d.ts +55 -0
- package/lib/esm/queries/GetPosition.js +71 -0
- package/lib/esm/queries/index.d.ts +1 -0
- package/lib/esm/queries/index.js +1 -0
- package/lib/esm/signatures/EcrecoverRatifierUtils.d.ts +733 -0
- package/lib/esm/signatures/EcrecoverRatifierUtils.js +615 -0
- package/lib/esm/signatures/Group.d.ts +178 -0
- package/lib/esm/signatures/Group.js +189 -0
- package/lib/esm/signatures/GroupUtils.d.ts +191 -0
- package/lib/esm/signatures/GroupUtils.js +124 -0
- package/lib/esm/signatures/Payload.d.ts +283 -0
- package/lib/esm/signatures/Payload.js +564 -0
- package/lib/esm/signatures/RatifierUtils.d.ts +109 -0
- package/lib/esm/signatures/RatifierUtils.js +73 -0
- package/lib/esm/signatures/SetterRatifierUtils.d.ts +243 -0
- package/lib/esm/signatures/SetterRatifierUtils.js +214 -0
- package/lib/esm/signatures/Tree.d.ts +241 -0
- package/lib/esm/signatures/Tree.js +259 -0
- package/lib/esm/signatures/TreeUtils.d.ts +573 -0
- package/lib/esm/signatures/TreeUtils.js +458 -0
- package/lib/esm/signatures/index.d.ts +7 -0
- package/lib/esm/signatures/index.js +7 -0
- package/package.json +69 -0
- package/src/index.ts +19 -0
|
@@ -0,0 +1,659 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OfferUtils = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const constants_js_1 = require("../constants.js");
|
|
6
|
+
const errors_js_1 = require("../errors.js");
|
|
7
|
+
const index_js_1 = require("../market/index.js");
|
|
8
|
+
const Offer_js_1 = require("./Offer.js");
|
|
9
|
+
const comparableHex = (value) => value.toLowerCase();
|
|
10
|
+
const offerHashParams = [
|
|
11
|
+
{ name: "typehash", type: "bytes32" },
|
|
12
|
+
{ name: "marketHash", type: "bytes32" },
|
|
13
|
+
{ name: "buy", type: "bool" },
|
|
14
|
+
{ name: "maker", type: "address" },
|
|
15
|
+
{ name: "start", type: "uint256" },
|
|
16
|
+
{ name: "expiry", type: "uint256" },
|
|
17
|
+
{ name: "tick", type: "uint256" },
|
|
18
|
+
{ name: "group", type: "bytes32" },
|
|
19
|
+
{ name: "callback", type: "address" },
|
|
20
|
+
{ name: "callbackDataHash", type: "bytes32" },
|
|
21
|
+
{ name: "receiverIfMakerIsSeller", type: "address" },
|
|
22
|
+
{ name: "ratifier", type: "address" },
|
|
23
|
+
{ name: "reduceOnly", type: "bool" },
|
|
24
|
+
{ name: "maxUnits", type: "uint256" },
|
|
25
|
+
{ name: "maxAssets", type: "uint256" },
|
|
26
|
+
{ name: "continuousFeeCap", type: "uint256" },
|
|
27
|
+
];
|
|
28
|
+
/**
|
|
29
|
+
* Object-compatible helpers for Midnight offer construction, grouping, and
|
|
30
|
+
* take-side encoding.
|
|
31
|
+
*
|
|
32
|
+
* Make-side apps usually call {@link Offer.create}, then `Group.create` or
|
|
33
|
+
* `Tree.create`. Use these helpers when you need the same validation or ABI
|
|
34
|
+
* conversion without depending on class instances, or when converting API data
|
|
35
|
+
* into the structs consumed by payload and take encoders.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* import { OfferUtils } from "@morpho-org/midnight-sdk";
|
|
40
|
+
*
|
|
41
|
+
* console.log(typeof OfferUtils.getOfferExpiry);
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
var OfferUtils;
|
|
45
|
+
(function (OfferUtils) {
|
|
46
|
+
/**
|
|
47
|
+
* Converts an offer into the tuple object expected by viem ABI encoders.
|
|
48
|
+
*
|
|
49
|
+
* This is the bridge from SDK/domain objects
|
|
50
|
+
* into Merkle leaf hashing, payload items, and take calldata encoding.
|
|
51
|
+
*
|
|
52
|
+
* @param params.offer - Offer class or plain offer input to encode.
|
|
53
|
+
* @param params.group - Optional protocol group id override encoded into the ABI offer.
|
|
54
|
+
* @returns ABI-compatible offer.
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* import { Offer, OfferUtils } from "@morpho-org/midnight-sdk";
|
|
58
|
+
* import { zeroAddress } from "viem";
|
|
59
|
+
*
|
|
60
|
+
* const offer = Offer.create({
|
|
61
|
+
* market: {
|
|
62
|
+
* loanToken: "0x0000000000000000000000000000000000006000",
|
|
63
|
+
* collateralParams: [
|
|
64
|
+
* {
|
|
65
|
+
* token: "0x0000000000000000000000000000000000007000",
|
|
66
|
+
* lltv: 770000000000000000n,
|
|
67
|
+
* maxLif: 1061007957559681697n,
|
|
68
|
+
* oracle: "0x0000000000000000000000000000000000008000",
|
|
69
|
+
* },
|
|
70
|
+
* ],
|
|
71
|
+
* maturity: 54_000n,
|
|
72
|
+
* rcfThreshold: 0n,
|
|
73
|
+
* enterGate: zeroAddress,
|
|
74
|
+
* liquidatorGate: zeroAddress,
|
|
75
|
+
* },
|
|
76
|
+
* buy: true,
|
|
77
|
+
* maker: "0x0000000000000000000000000000000000009000",
|
|
78
|
+
* tick: 5_000n,
|
|
79
|
+
* expiry: 3_600n,
|
|
80
|
+
* ratifier: "0x0000000000000000000000000000000000004000",
|
|
81
|
+
* maxUnits: 100n,
|
|
82
|
+
* });
|
|
83
|
+
* const struct = OfferUtils.toStruct({ offer });
|
|
84
|
+
* console.log(struct.tick);
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
function toStruct(params) {
|
|
88
|
+
const offer = Offer_js_1.Offer.from(params.offer);
|
|
89
|
+
return {
|
|
90
|
+
market: index_js_1.MarketUtils.toStruct(offer.market),
|
|
91
|
+
buy: offer.buy,
|
|
92
|
+
maker: offer.maker,
|
|
93
|
+
start: offer.start,
|
|
94
|
+
expiry: offer.expiry,
|
|
95
|
+
tick: offer.tick,
|
|
96
|
+
group: params.group ?? offer.group,
|
|
97
|
+
callback: offer.callback,
|
|
98
|
+
callbackData: offer.callbackData,
|
|
99
|
+
receiverIfMakerIsSeller: offer.receiverIfMakerIsSeller,
|
|
100
|
+
ratifier: offer.ratifier,
|
|
101
|
+
reduceOnly: offer.reduceOnly,
|
|
102
|
+
maxUnits: offer.maxUnits,
|
|
103
|
+
maxAssets: offer.maxAssets,
|
|
104
|
+
continuousFeeCap: offer.continuousFeeCap,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
OfferUtils.toStruct = toStruct;
|
|
108
|
+
/**
|
|
109
|
+
* Computes the canonical protocol offer hash for an ABI-compatible offer.
|
|
110
|
+
*
|
|
111
|
+
* Use when you already have an `OfferStruct`, for example from
|
|
112
|
+
* `GroupUtils.toStructs`, `TreeUtils.buildDescriptor`, or decoded payload
|
|
113
|
+
* bytes. Use `hash` when you still have a grouped `Offer` or grouped plain
|
|
114
|
+
* offer input, and `groupHash` when deriving a group id from the zero-group
|
|
115
|
+
* hash.
|
|
116
|
+
*
|
|
117
|
+
* @param offerStruct - ABI-compatible offer to hash.
|
|
118
|
+
* @returns Offer hash.
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* import { Offer, OfferUtils } from "@morpho-org/midnight-sdk";
|
|
122
|
+
* import { zeroAddress, zeroHash } from "viem";
|
|
123
|
+
*
|
|
124
|
+
* const offer = Offer.create({
|
|
125
|
+
* market: {
|
|
126
|
+
* loanToken: "0x0000000000000000000000000000000000006000",
|
|
127
|
+
* collateralParams: [
|
|
128
|
+
* {
|
|
129
|
+
* token: "0x0000000000000000000000000000000000007000",
|
|
130
|
+
* lltv: 770000000000000000n,
|
|
131
|
+
* maxLif: 1061007957559681697n,
|
|
132
|
+
* oracle: "0x0000000000000000000000000000000000008000",
|
|
133
|
+
* },
|
|
134
|
+
* ],
|
|
135
|
+
* maturity: 54_000n,
|
|
136
|
+
* rcfThreshold: 0n,
|
|
137
|
+
* enterGate: zeroAddress,
|
|
138
|
+
* liquidatorGate: zeroAddress,
|
|
139
|
+
* },
|
|
140
|
+
* buy: true,
|
|
141
|
+
* maker: "0x0000000000000000000000000000000000009000",
|
|
142
|
+
* tick: 5_000n,
|
|
143
|
+
* expiry: 3_600n,
|
|
144
|
+
* ratifier: "0x0000000000000000000000000000000000004000",
|
|
145
|
+
* maxUnits: 100n,
|
|
146
|
+
* });
|
|
147
|
+
* const hash = OfferUtils.hashStruct(
|
|
148
|
+
* OfferUtils.toStruct({ offer, group: zeroHash }),
|
|
149
|
+
* );
|
|
150
|
+
* console.log(hash);
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
function hashStruct(offerStruct) {
|
|
154
|
+
return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)(offerHashParams, [
|
|
155
|
+
constants_js_1.OFFER_TYPEHASH,
|
|
156
|
+
index_js_1.MarketUtils.hash(offerStruct.market),
|
|
157
|
+
offerStruct.buy,
|
|
158
|
+
offerStruct.maker,
|
|
159
|
+
offerStruct.start,
|
|
160
|
+
offerStruct.expiry,
|
|
161
|
+
offerStruct.tick,
|
|
162
|
+
offerStruct.group,
|
|
163
|
+
offerStruct.callback,
|
|
164
|
+
(0, viem_1.keccak256)(offerStruct.callbackData),
|
|
165
|
+
offerStruct.receiverIfMakerIsSeller,
|
|
166
|
+
offerStruct.ratifier,
|
|
167
|
+
offerStruct.reduceOnly,
|
|
168
|
+
offerStruct.maxUnits,
|
|
169
|
+
offerStruct.maxAssets,
|
|
170
|
+
offerStruct.continuousFeeCap,
|
|
171
|
+
]));
|
|
172
|
+
}
|
|
173
|
+
OfferUtils.hashStruct = hashStruct;
|
|
174
|
+
/**
|
|
175
|
+
* Computes the canonical protocol offer hash from the offer's group id.
|
|
176
|
+
*
|
|
177
|
+
* Use this for final tree leaves and payload offers after a group has been
|
|
178
|
+
* assigned. Use `groupHash` for the zero-group hash that derives a group id.
|
|
179
|
+
*
|
|
180
|
+
* @param offer - Offer with the protocol group id encoded into the hash.
|
|
181
|
+
* @returns Offer hash.
|
|
182
|
+
* @example
|
|
183
|
+
* ```ts
|
|
184
|
+
* import { Offer, OfferUtils } from "@morpho-org/midnight-sdk";
|
|
185
|
+
* import { zeroAddress, zeroHash } from "viem";
|
|
186
|
+
*
|
|
187
|
+
* const offer = Offer.create({
|
|
188
|
+
* market: {
|
|
189
|
+
* loanToken: "0x0000000000000000000000000000000000006000",
|
|
190
|
+
* collateralParams: [
|
|
191
|
+
* {
|
|
192
|
+
* token: "0x0000000000000000000000000000000000007000",
|
|
193
|
+
* lltv: 770000000000000000n,
|
|
194
|
+
* maxLif: 1061007957559681697n,
|
|
195
|
+
* oracle: "0x0000000000000000000000000000000000008000",
|
|
196
|
+
* },
|
|
197
|
+
* ],
|
|
198
|
+
* maturity: 54_000n,
|
|
199
|
+
* rcfThreshold: 0n,
|
|
200
|
+
* enterGate: zeroAddress,
|
|
201
|
+
* liquidatorGate: zeroAddress,
|
|
202
|
+
* },
|
|
203
|
+
* buy: true,
|
|
204
|
+
* maker: "0x0000000000000000000000000000000000009000",
|
|
205
|
+
* tick: 5_000n,
|
|
206
|
+
* group: zeroHash,
|
|
207
|
+
* expiry: 3_600n,
|
|
208
|
+
* ratifier: "0x0000000000000000000000000000000000004000",
|
|
209
|
+
* maxUnits: 100n,
|
|
210
|
+
* });
|
|
211
|
+
* const hash = OfferUtils.hash(offer);
|
|
212
|
+
* console.log(hash);
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
function hash(offer) {
|
|
216
|
+
return hashStruct(toStruct({ offer }));
|
|
217
|
+
}
|
|
218
|
+
OfferUtils.hash = hash;
|
|
219
|
+
/**
|
|
220
|
+
* Computes the offer hash used to derive a content-addressed group id.
|
|
221
|
+
*
|
|
222
|
+
* The encoded group is always the protocol zero hash. Use this only for
|
|
223
|
+
* standalone or grouped-offer id derivation, not for final tree leaves or
|
|
224
|
+
* payload offers.
|
|
225
|
+
*
|
|
226
|
+
* @param offer - Offer to hash without a group id.
|
|
227
|
+
* @returns Offer hash encoded with the protocol zero group id.
|
|
228
|
+
* @example
|
|
229
|
+
* ```ts
|
|
230
|
+
* import { Offer, OfferUtils } from "@morpho-org/midnight-sdk";
|
|
231
|
+
* import { zeroAddress } from "viem";
|
|
232
|
+
*
|
|
233
|
+
* const offer = Offer.create({
|
|
234
|
+
* market: {
|
|
235
|
+
* loanToken: "0x0000000000000000000000000000000000006000",
|
|
236
|
+
* collateralParams: [
|
|
237
|
+
* {
|
|
238
|
+
* token: "0x0000000000000000000000000000000000007000",
|
|
239
|
+
* lltv: 770000000000000000n,
|
|
240
|
+
* maxLif: 1061007957559681697n,
|
|
241
|
+
* oracle: "0x0000000000000000000000000000000000008000",
|
|
242
|
+
* },
|
|
243
|
+
* ],
|
|
244
|
+
* maturity: 54_000n,
|
|
245
|
+
* rcfThreshold: 0n,
|
|
246
|
+
* enterGate: zeroAddress,
|
|
247
|
+
* liquidatorGate: zeroAddress,
|
|
248
|
+
* },
|
|
249
|
+
* buy: true,
|
|
250
|
+
* maker: "0x0000000000000000000000000000000000009000",
|
|
251
|
+
* tick: 5_000n,
|
|
252
|
+
* expiry: 3_600n,
|
|
253
|
+
* ratifier: "0x0000000000000000000000000000000000004000",
|
|
254
|
+
* maxUnits: 100n,
|
|
255
|
+
* });
|
|
256
|
+
* const hash = OfferUtils.groupHash(offer);
|
|
257
|
+
* console.log(hash);
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
260
|
+
function groupHash(offer) {
|
|
261
|
+
return hashStruct(toStruct({ offer, group: viem_1.zeroHash }));
|
|
262
|
+
}
|
|
263
|
+
OfferUtils.groupHash = groupHash;
|
|
264
|
+
/**
|
|
265
|
+
* Validates and normalizes a Midnight offer tick and spacing.
|
|
266
|
+
*
|
|
267
|
+
* Use this for form-level validation before `Offer.create` when you want to
|
|
268
|
+
* surface a tick-specific issue. `Offer.create` calls it internally.
|
|
269
|
+
*
|
|
270
|
+
* @param params.tick - Offer tick to validate.
|
|
271
|
+
* @param params.tickSpacing - Optional market tick spacing; defaults to `DEFAULT_TICK_SPACING`.
|
|
272
|
+
* @returns Normalized tick and tick spacing.
|
|
273
|
+
* @throws {InvalidOfferParameterError} when the tick or spacing cannot be accepted by Midnight.
|
|
274
|
+
* @example
|
|
275
|
+
* ```ts
|
|
276
|
+
* import { OfferUtils } from "@morpho-org/midnight-sdk";
|
|
277
|
+
*
|
|
278
|
+
* const { tick } = OfferUtils.validateOfferTick({ tick: 4n });
|
|
279
|
+
* console.log(tick);
|
|
280
|
+
* ```
|
|
281
|
+
*/
|
|
282
|
+
function validateOfferTick(params) {
|
|
283
|
+
const tick = BigInt(params.tick);
|
|
284
|
+
const tickSpacing = BigInt(params.tickSpacing ?? constants_js_1.DEFAULT_TICK_SPACING);
|
|
285
|
+
if (tick < 0n || tick > constants_js_1.MAX_TICK) {
|
|
286
|
+
throw new errors_js_1.InvalidOfferParameterError({
|
|
287
|
+
parameter: "tick",
|
|
288
|
+
value: tick,
|
|
289
|
+
instruction: `Use a tick between "0" and "${constants_js_1.MAX_TICK}".`,
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
if (tickSpacing <= 0n || constants_js_1.DEFAULT_TICK_SPACING % tickSpacing !== 0n) {
|
|
293
|
+
throw new errors_js_1.InvalidOfferParameterError({
|
|
294
|
+
parameter: "tickSpacing",
|
|
295
|
+
value: tickSpacing,
|
|
296
|
+
instruction: `Use a positive tick spacing that divides "${constants_js_1.DEFAULT_TICK_SPACING}".`,
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
if (tick % tickSpacing !== 0n) {
|
|
300
|
+
throw new errors_js_1.InvalidOfferParameterError({
|
|
301
|
+
parameter: "tick",
|
|
302
|
+
value: tick,
|
|
303
|
+
instruction: `Use a tick aligned to spacing "${tickSpacing}".`,
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
return { tick, tickSpacing };
|
|
307
|
+
}
|
|
308
|
+
OfferUtils.validateOfferTick = validateOfferTick;
|
|
309
|
+
/**
|
|
310
|
+
* Validates and normalizes an offer start/expiry range.
|
|
311
|
+
*
|
|
312
|
+
* Use this before `Offer.create` when a UI edits dates separately from other
|
|
313
|
+
* offer fields. `Offer.create` calls it internally.
|
|
314
|
+
*
|
|
315
|
+
* @param params.start - Optional offer start timestamp; defaults to zero.
|
|
316
|
+
* @param params.expiry - Offer expiry timestamp.
|
|
317
|
+
* @returns Normalized start and expiry timestamps.
|
|
318
|
+
* @throws {InvalidOfferParameterError} when the range is negative or not strictly increasing.
|
|
319
|
+
* @example
|
|
320
|
+
* ```ts
|
|
321
|
+
* import { OfferUtils } from "@morpho-org/midnight-sdk";
|
|
322
|
+
*
|
|
323
|
+
* const range = OfferUtils.validateOfferTimeRange({ start: 0n, expiry: 1n });
|
|
324
|
+
* console.log(range.expiry);
|
|
325
|
+
* ```
|
|
326
|
+
*/
|
|
327
|
+
function validateOfferTimeRange(params) {
|
|
328
|
+
const start = BigInt(params.start ?? 0n);
|
|
329
|
+
const expiry = BigInt(params.expiry);
|
|
330
|
+
if (start < 0n) {
|
|
331
|
+
throw new errors_js_1.InvalidOfferParameterError({
|
|
332
|
+
parameter: "start",
|
|
333
|
+
value: start,
|
|
334
|
+
instruction: "Use a non-negative timestamp.",
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
if (expiry < 0n || expiry <= start) {
|
|
338
|
+
throw new errors_js_1.InvalidOfferParameterError({
|
|
339
|
+
parameter: "expiry",
|
|
340
|
+
value: expiry,
|
|
341
|
+
instruction: `Use an expiry greater than start "${start}".`,
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
return { start, expiry };
|
|
345
|
+
}
|
|
346
|
+
OfferUtils.validateOfferTimeRange = validateOfferTimeRange;
|
|
347
|
+
/**
|
|
348
|
+
* Validates and normalizes mutually exclusive offer caps.
|
|
349
|
+
*
|
|
350
|
+
* Use this before `Offer.create` when a UI lets makers choose between a unit
|
|
351
|
+
* cap and an asset cap. `Offer.create` calls it internally.
|
|
352
|
+
*
|
|
353
|
+
* @param params.maxUnits - Optional unit cap; defaults to zero.
|
|
354
|
+
* @param params.maxAssets - Optional buyer or seller asset cap; defaults to zero.
|
|
355
|
+
* @returns Normalized unit and asset caps.
|
|
356
|
+
* @throws {InvalidOfferParameterError} when caps are negative, both zero, or both non-zero.
|
|
357
|
+
* @example
|
|
358
|
+
* ```ts
|
|
359
|
+
* import { OfferUtils } from "@morpho-org/midnight-sdk";
|
|
360
|
+
*
|
|
361
|
+
* const caps = OfferUtils.validateOfferCaps({ maxAssets: 100n });
|
|
362
|
+
* console.log(caps.maxAssets);
|
|
363
|
+
* ```
|
|
364
|
+
*/
|
|
365
|
+
function validateOfferCaps(params) {
|
|
366
|
+
const maxUnits = BigInt(params.maxUnits ?? 0n);
|
|
367
|
+
const maxAssets = BigInt(params.maxAssets ?? 0n);
|
|
368
|
+
if (maxUnits < 0n) {
|
|
369
|
+
throw new errors_js_1.InvalidOfferParameterError({
|
|
370
|
+
parameter: "maxUnits",
|
|
371
|
+
value: maxUnits,
|
|
372
|
+
instruction: "Use a non-negative cap.",
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
if (maxAssets < 0n) {
|
|
376
|
+
throw new errors_js_1.InvalidOfferParameterError({
|
|
377
|
+
parameter: "maxAssets",
|
|
378
|
+
value: maxAssets,
|
|
379
|
+
instruction: "Use a non-negative cap.",
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
if ((maxAssets === 0n) === (maxUnits === 0n)) {
|
|
383
|
+
throw new errors_js_1.InvalidOfferParameterError({
|
|
384
|
+
parameter: "maxUnits/maxAssets",
|
|
385
|
+
value: `maxUnits=${maxUnits}, maxAssets=${maxAssets}`,
|
|
386
|
+
instruction: "Set exactly one offer cap to a non-zero value.",
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
return { maxUnits, maxAssets };
|
|
390
|
+
}
|
|
391
|
+
OfferUtils.validateOfferCaps = validateOfferCaps;
|
|
392
|
+
/**
|
|
393
|
+
* Validates and normalizes the maximum continuous fee an offer accepts.
|
|
394
|
+
*
|
|
395
|
+
* Use this before `Offer.create` when a maker UI exposes fee tolerance.
|
|
396
|
+
* `Offer.create` calls it internally and defaults omitted values to
|
|
397
|
+
* {@link MAX_CONTINUOUS_FEE}.
|
|
398
|
+
*
|
|
399
|
+
* @param params.continuousFeeCap - Optional maximum market continuous fee accepted by this offer.
|
|
400
|
+
* @returns Normalized continuous fee cap.
|
|
401
|
+
* @throws {InvalidOfferParameterError} when the cap is negative.
|
|
402
|
+
* @example
|
|
403
|
+
* ```ts
|
|
404
|
+
* import { OfferUtils } from "@morpho-org/midnight-sdk";
|
|
405
|
+
*
|
|
406
|
+
* const cap = OfferUtils.validateContinuousFeeCap({});
|
|
407
|
+
* console.log(cap.continuousFeeCap);
|
|
408
|
+
* ```
|
|
409
|
+
*/
|
|
410
|
+
function validateContinuousFeeCap(params) {
|
|
411
|
+
const continuousFeeCap = BigInt(params.continuousFeeCap ?? constants_js_1.MAX_CONTINUOUS_FEE);
|
|
412
|
+
if (continuousFeeCap < 0n) {
|
|
413
|
+
throw new errors_js_1.InvalidOfferParameterError({
|
|
414
|
+
parameter: "continuousFeeCap",
|
|
415
|
+
value: continuousFeeCap,
|
|
416
|
+
instruction: "Use a non-negative continuous fee cap.",
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
return { continuousFeeCap };
|
|
420
|
+
}
|
|
421
|
+
OfferUtils.validateContinuousFeeCap = validateContinuousFeeCap;
|
|
422
|
+
/**
|
|
423
|
+
* Resolves and validates the maker-seller receiver field for an offer side.
|
|
424
|
+
*
|
|
425
|
+
* Use this before `Offer.create` when side-specific receiver defaults must be
|
|
426
|
+
* displayed to a maker. `Offer.create` calls it internally.
|
|
427
|
+
*
|
|
428
|
+
* @param params.buy - Whether the maker buys loan assets.
|
|
429
|
+
* @param params.maker - Maker address used as the default sell-side receiver.
|
|
430
|
+
* @param params.receiverIfMakerIsSeller - Optional receiver used when maker is seller.
|
|
431
|
+
* @returns Receiver address to put on the offer.
|
|
432
|
+
* @throws {InvalidOfferParameterError} when a buy offer sets a non-zero maker-seller receiver.
|
|
433
|
+
* @example
|
|
434
|
+
* ```ts
|
|
435
|
+
* import { OfferUtils } from "@morpho-org/midnight-sdk";
|
|
436
|
+
*
|
|
437
|
+
* const receiver = OfferUtils.resolveReceiverIfMakerIsSeller({
|
|
438
|
+
* buy: true,
|
|
439
|
+
* maker: "0x0000000000000000000000000000000000000001",
|
|
440
|
+
* });
|
|
441
|
+
* console.log(receiver);
|
|
442
|
+
* ```
|
|
443
|
+
*/
|
|
444
|
+
function resolveReceiverIfMakerIsSeller(params) {
|
|
445
|
+
const maker = params.maker;
|
|
446
|
+
const receiverIfMakerIsSeller = params.receiverIfMakerIsSeller ?? (params.buy ? viem_1.zeroAddress : maker);
|
|
447
|
+
if (params.buy && receiverIfMakerIsSeller !== viem_1.zeroAddress) {
|
|
448
|
+
throw new errors_js_1.InvalidOfferParameterError({
|
|
449
|
+
parameter: "receiverIfMakerIsSeller",
|
|
450
|
+
value: receiverIfMakerIsSeller,
|
|
451
|
+
instruction: "Use the zero address for buy offers.",
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
return receiverIfMakerIsSeller;
|
|
455
|
+
}
|
|
456
|
+
OfferUtils.resolveReceiverIfMakerIsSeller = resolveReceiverIfMakerIsSeller;
|
|
457
|
+
/**
|
|
458
|
+
* Validates deterministic make-offer parameters without constructing an offer.
|
|
459
|
+
*
|
|
460
|
+
* Use when an app needs normalized maker input or field-level errors before
|
|
461
|
+
* instantiating an `Offer`. `Offer.create` uses the same validation and then
|
|
462
|
+
* constructs the class instance for grouping and trees.
|
|
463
|
+
*
|
|
464
|
+
* @param params.market - Market params or hydrated market this offer trades.
|
|
465
|
+
* @param params.buy - Whether the maker buys loan assets.
|
|
466
|
+
* @param params.maker - Maker address.
|
|
467
|
+
* @param params.tick - Offer tick.
|
|
468
|
+
* @param params.group - Optional consumption group id for already-grouped offers.
|
|
469
|
+
* @param params.tickSpacing - Optional market tick spacing; defaults to `DEFAULT_TICK_SPACING`.
|
|
470
|
+
* @param params.maxUnits - Optional unit cap; defaults to zero.
|
|
471
|
+
* @param params.maxAssets - Optional buyer or seller asset cap; defaults to zero.
|
|
472
|
+
* @param params.continuousFeeCap - Optional maximum market continuous fee accepted by this offer; defaults to `MAX_CONTINUOUS_FEE`.
|
|
473
|
+
* @param params.start - Optional offer start timestamp; defaults to zero.
|
|
474
|
+
* @param params.expiry - Offer expiry timestamp.
|
|
475
|
+
* @param params.callback - Optional callback address; defaults to the zero address.
|
|
476
|
+
* @param params.callbackData - Optional callback payload; defaults to `0x`.
|
|
477
|
+
* @param params.receiverIfMakerIsSeller - Optional receiver used when maker is seller.
|
|
478
|
+
* @param params.ratifier - Ratifier contract address.
|
|
479
|
+
* @param params.reduceOnly - Optional flag restricting the offer to exposure-reducing execution.
|
|
480
|
+
* @returns Normalized deterministic offer parameters.
|
|
481
|
+
* @throws {InvalidOfferParameterError} when a deterministic offer parameter cannot satisfy protocol rules.
|
|
482
|
+
* @example
|
|
483
|
+
* ```ts
|
|
484
|
+
* import { OfferUtils } from "@morpho-org/midnight-sdk";
|
|
485
|
+
*
|
|
486
|
+
* const params = OfferUtils.validateOfferParams({
|
|
487
|
+
* market: {
|
|
488
|
+
* loanToken: "0x0000000000000000000000000000000000006000",
|
|
489
|
+
* collateralParams: [
|
|
490
|
+
* {
|
|
491
|
+
* token: "0x0000000000000000000000000000000000007000",
|
|
492
|
+
* lltv: 770000000000000000n,
|
|
493
|
+
* maxLif: 1061007957559681697n,
|
|
494
|
+
* oracle: "0x0000000000000000000000000000000000008000",
|
|
495
|
+
* },
|
|
496
|
+
* ],
|
|
497
|
+
* maturity: 54_000n,
|
|
498
|
+
* rcfThreshold: 0n,
|
|
499
|
+
* enterGate: "0x0000000000000000000000000000000000000000",
|
|
500
|
+
* liquidatorGate: "0x0000000000000000000000000000000000000000",
|
|
501
|
+
* },
|
|
502
|
+
* buy: true,
|
|
503
|
+
* maker: "0x0000000000000000000000000000000000009000",
|
|
504
|
+
* tick: 5_000n,
|
|
505
|
+
* expiry: 3_600n,
|
|
506
|
+
* ratifier: "0x0000000000000000000000000000000000004000",
|
|
507
|
+
* maxUnits: 100n,
|
|
508
|
+
* });
|
|
509
|
+
* console.log(params.maxAssets);
|
|
510
|
+
* ```
|
|
511
|
+
*/
|
|
512
|
+
function validateOfferParams(params) {
|
|
513
|
+
const { tick, tickSpacing } = validateOfferTick(params);
|
|
514
|
+
const { start, expiry } = validateOfferTimeRange(params);
|
|
515
|
+
const { maxUnits, maxAssets } = validateOfferCaps(params);
|
|
516
|
+
const { continuousFeeCap } = validateContinuousFeeCap(params);
|
|
517
|
+
const receiverIfMakerIsSeller = resolveReceiverIfMakerIsSeller(params);
|
|
518
|
+
return {
|
|
519
|
+
tick,
|
|
520
|
+
tickSpacing,
|
|
521
|
+
start,
|
|
522
|
+
expiry,
|
|
523
|
+
maxUnits,
|
|
524
|
+
maxAssets,
|
|
525
|
+
continuousFeeCap,
|
|
526
|
+
receiverIfMakerIsSeller,
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
OfferUtils.validateOfferParams = validateOfferParams;
|
|
530
|
+
/**
|
|
531
|
+
* Validates protocol-level mechanics for one Midnight offer consumption group.
|
|
532
|
+
*
|
|
533
|
+
* Use before deriving a content-addressed group id. Grouped offers must share
|
|
534
|
+
* maker, side, loan token, cap mode, and cap value because Midnight tracks one
|
|
535
|
+
* consumed scalar per maker and group. `Group.create` calls this automatically;
|
|
536
|
+
* call it directly only when you need the normalized offers without
|
|
537
|
+
* constructing a `Group`.
|
|
538
|
+
*
|
|
539
|
+
* @param params.offers - Offers to validate as one protocol consumption group.
|
|
540
|
+
* @returns Normalized offers in the same order as the input entries.
|
|
541
|
+
* @throws {InvalidOfferGroupError} when the group violates protocol mechanics.
|
|
542
|
+
* @example
|
|
543
|
+
* ```ts
|
|
544
|
+
* import { Offer, OfferUtils } from "@morpho-org/midnight-sdk";
|
|
545
|
+
* import { zeroAddress } from "viem";
|
|
546
|
+
*
|
|
547
|
+
* const offer = Offer.create({
|
|
548
|
+
* market: {
|
|
549
|
+
* loanToken: "0x0000000000000000000000000000000000006000",
|
|
550
|
+
* collateralParams: [
|
|
551
|
+
* {
|
|
552
|
+
* token: "0x0000000000000000000000000000000000007000",
|
|
553
|
+
* lltv: 770000000000000000n,
|
|
554
|
+
* maxLif: 1061007957559681697n,
|
|
555
|
+
* oracle: "0x0000000000000000000000000000000000008000",
|
|
556
|
+
* },
|
|
557
|
+
* ],
|
|
558
|
+
* maturity: 54_000n,
|
|
559
|
+
* rcfThreshold: 0n,
|
|
560
|
+
* enterGate: zeroAddress,
|
|
561
|
+
* liquidatorGate: zeroAddress,
|
|
562
|
+
* },
|
|
563
|
+
* buy: true,
|
|
564
|
+
* maker: "0x0000000000000000000000000000000000009000",
|
|
565
|
+
* tick: 5_000n,
|
|
566
|
+
* expiry: 3_600n,
|
|
567
|
+
* ratifier: "0x0000000000000000000000000000000000004000",
|
|
568
|
+
* maxUnits: 100n,
|
|
569
|
+
* });
|
|
570
|
+
* const offers = OfferUtils.validateOfferGroup({ offers: [offer] });
|
|
571
|
+
* console.log(offers.length);
|
|
572
|
+
* ```
|
|
573
|
+
*/
|
|
574
|
+
function validateOfferGroup(params) {
|
|
575
|
+
const offerInputs = Array.from(params.offers);
|
|
576
|
+
if (offerInputs.length === 0) {
|
|
577
|
+
throw new errors_js_1.InvalidOfferGroupError("Provide at least one offer in the group.");
|
|
578
|
+
}
|
|
579
|
+
const offers = offerInputs.map((offer) => Offer_js_1.Offer.from(offer));
|
|
580
|
+
const first = offers[0];
|
|
581
|
+
const expectedMaker = comparableHex(first.maker);
|
|
582
|
+
const expectedBuy = first.buy;
|
|
583
|
+
const expectedLoanToken = comparableHex(first.market.loanToken);
|
|
584
|
+
const expectedMaxUnits = first.maxUnits;
|
|
585
|
+
const expectedMaxAssets = first.maxAssets;
|
|
586
|
+
for (const offer of offers) {
|
|
587
|
+
if (comparableHex(offer.maker) !== expectedMaker) {
|
|
588
|
+
throw new errors_js_1.InvalidOfferGroupError("All offers in a group must use the same maker.");
|
|
589
|
+
}
|
|
590
|
+
if (offer.buy !== expectedBuy) {
|
|
591
|
+
throw new errors_js_1.InvalidOfferGroupError("All offers in a group must use the same maker side.");
|
|
592
|
+
}
|
|
593
|
+
if (offer.maxUnits < 0n ||
|
|
594
|
+
offer.maxAssets < 0n ||
|
|
595
|
+
(offer.maxAssets === 0n) === (offer.maxUnits === 0n)) {
|
|
596
|
+
throw new errors_js_1.InvalidOfferGroupError("Every offer must set exactly one non-zero non-negative cap.");
|
|
597
|
+
}
|
|
598
|
+
if (comparableHex(offer.market.loanToken) !== expectedLoanToken) {
|
|
599
|
+
throw new errors_js_1.InvalidOfferGroupError("All offers in a group must use the same loan token.");
|
|
600
|
+
}
|
|
601
|
+
if (offer.maxUnits !== expectedMaxUnits ||
|
|
602
|
+
offer.maxAssets !== expectedMaxAssets) {
|
|
603
|
+
throw new errors_js_1.InvalidOfferGroupError("All offers in a group must use the same cap mode and value.");
|
|
604
|
+
}
|
|
605
|
+
if (offer.buy &&
|
|
606
|
+
comparableHex(offer.receiverIfMakerIsSeller) !==
|
|
607
|
+
comparableHex(viem_1.zeroAddress)) {
|
|
608
|
+
throw new errors_js_1.InvalidOfferGroupError("Buy offers must use the zero address as receiverIfMakerIsSeller.");
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
return [...offers];
|
|
612
|
+
}
|
|
613
|
+
OfferUtils.validateOfferGroup = validateOfferGroup;
|
|
614
|
+
/**
|
|
615
|
+
* Returns an offer expiry timestamp.
|
|
616
|
+
*
|
|
617
|
+
* Use in maker UIs, API response mappers, or quote filters when accepting
|
|
618
|
+
* any plain object matching `IOffer` or an `Offer` instance. This does not validate
|
|
619
|
+
* whether the offer is still live at the current block time.
|
|
620
|
+
*
|
|
621
|
+
* @param offer - Offer to inspect.
|
|
622
|
+
* @returns Offer expiry.
|
|
623
|
+
* @example
|
|
624
|
+
* ```ts
|
|
625
|
+
* import { Offer, OfferUtils } from "@morpho-org/midnight-sdk";
|
|
626
|
+
* import { zeroAddress } from "viem";
|
|
627
|
+
*
|
|
628
|
+
* const offer = Offer.create({
|
|
629
|
+
* market: {
|
|
630
|
+
* loanToken: "0x0000000000000000000000000000000000006000",
|
|
631
|
+
* collateralParams: [
|
|
632
|
+
* {
|
|
633
|
+
* token: "0x0000000000000000000000000000000000007000",
|
|
634
|
+
* lltv: 770000000000000000n,
|
|
635
|
+
* maxLif: 1061007957559681697n,
|
|
636
|
+
* oracle: "0x0000000000000000000000000000000000008000",
|
|
637
|
+
* },
|
|
638
|
+
* ],
|
|
639
|
+
* maturity: 54_000n,
|
|
640
|
+
* rcfThreshold: 0n,
|
|
641
|
+
* enterGate: zeroAddress,
|
|
642
|
+
* liquidatorGate: zeroAddress,
|
|
643
|
+
* },
|
|
644
|
+
* buy: true,
|
|
645
|
+
* maker: "0x0000000000000000000000000000000000009000",
|
|
646
|
+
* tick: 5_000n,
|
|
647
|
+
* expiry: 3_600n,
|
|
648
|
+
* ratifier: "0x0000000000000000000000000000000000004000",
|
|
649
|
+
* maxUnits: 100n,
|
|
650
|
+
* });
|
|
651
|
+
* const expiry = OfferUtils.getOfferExpiry(offer);
|
|
652
|
+
* console.log(expiry);
|
|
653
|
+
* ```
|
|
654
|
+
*/
|
|
655
|
+
function getOfferExpiry(offer) {
|
|
656
|
+
return BigInt(offer.expiry);
|
|
657
|
+
}
|
|
658
|
+
OfferUtils.getOfferExpiry = getOfferExpiry;
|
|
659
|
+
})(OfferUtils || (exports.OfferUtils = OfferUtils = {}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Offer.js"), exports);
|
|
18
|
+
__exportStar(require("./OfferUtils.js"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|