@morpho-org/blue-sdk 1.0.6 → 1.2.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 +2 -2
- package/lib/addresses.d.ts +34 -20
- package/lib/addresses.js +50 -13
- package/lib/chain.d.ts +30 -0
- package/lib/chain.js +288 -0
- package/lib/chain.test.js +22 -0
- package/lib/constants.d.ts +27 -6
- package/lib/constants.js +28 -8
- package/lib/errors.d.ts +18 -7
- package/lib/errors.js +38 -10
- package/lib/helpers/format/format.js +21 -60
- package/lib/helpers/index.d.ts +0 -2
- package/lib/helpers/index.js +0 -2
- package/lib/holding/Holding.d.ts +3 -4
- package/lib/holding/Holding.js +32 -4
- package/lib/index.d.ts +0 -8
- package/lib/index.js +1 -9
- package/lib/market/Market.d.ts +202 -54
- package/lib/market/Market.js +263 -62
- package/lib/market/MarketConfig.d.ts +17 -9
- package/lib/market/MarketConfig.js +39 -21
- package/lib/market/MarketUtils.d.ts +151 -102
- package/lib/market/MarketUtils.js +91 -39
- package/lib/market/MarketUtils.test.js +1 -2
- package/lib/maths/AdaptiveCurveIrmLib.d.ts +5 -4
- package/lib/maths/AdaptiveCurveIrmLib.js +10 -7
- package/lib/maths/MathLib.d.ts +35 -15
- package/lib/maths/MathLib.js +53 -33
- package/lib/maths/SharesMath.d.ts +3 -3
- package/lib/maths/SharesMath.js +2 -3
- package/lib/maths/index.d.ts +0 -1
- package/lib/maths/index.js +0 -1
- package/lib/position/Position.d.ts +5 -26
- package/lib/position/Position.js +28 -35
- package/lib/tests/mocks/markets.d.ts +1 -0
- package/lib/tests/mocks/markets.js +35 -29
- package/lib/token/Token.d.ts +4 -3
- package/lib/token/Token.js +28 -3
- package/lib/token/WrappedToken.js +12 -6
- package/lib/token/index.d.ts +1 -1
- package/lib/token/index.js +1 -1
- package/lib/types.d.ts +1 -0
- package/lib/types.js +3 -4
- package/lib/user/User.js +12 -0
- package/lib/vault/Vault.d.ts +12 -12
- package/lib/vault/Vault.js +102 -18
- package/lib/vault/VaultConfig.js +9 -3
- package/lib/vault/VaultMarketAllocation.d.ts +20 -0
- package/lib/vault/VaultMarketAllocation.js +30 -0
- package/lib/vault/VaultMarketConfig.d.ts +43 -0
- package/lib/vault/VaultMarketConfig.js +43 -0
- package/lib/vault/VaultMarketPublicAllocatorConfig.d.ts +29 -0
- package/lib/vault/VaultMarketPublicAllocatorConfig.js +28 -0
- package/lib/vault/VaultUtils.d.ts +8 -9
- package/lib/vault/VaultUtils.js +2 -3
- package/lib/vault/index.d.ts +3 -1
- package/lib/vault/index.js +3 -1
- package/package.json +3 -6
- package/lib/chain/chain.constants.d.ts +0 -3
- package/lib/chain/chain.constants.js +0 -232
- package/lib/chain/chain.test.js +0 -37
- package/lib/chain/chain.types.d.ts +0 -20
- package/lib/chain/chain.types.js +0 -30
- package/lib/chain/chain.utils.d.ts +0 -14
- package/lib/chain/chain.utils.js +0 -30
- package/lib/chain/index.d.ts +0 -2
- package/lib/chain/index.js +0 -18
- package/lib/ethers/ethers.test.d.ts +0 -1
- package/lib/ethers/ethers.test.js +0 -11
- package/lib/ethers/index.d.ts +0 -2
- package/lib/ethers/index.js +0 -18
- package/lib/ethers/safeGetAddress.d.ts +0 -1
- package/lib/ethers/safeGetAddress.js +0 -6
- package/lib/ethers/safeParseUnits.d.ts +0 -2
- package/lib/ethers/safeParseUnits.js +0 -25
- package/lib/evm.d.ts +0 -36
- package/lib/evm.js +0 -113
- package/lib/helpers/getChecksumedAddress.d.ts +0 -7
- package/lib/helpers/getChecksumedAddress.js +0 -17
- package/lib/helpers/isZeroAddressOrUnset.d.ts +0 -7
- package/lib/helpers/isZeroAddressOrUnset.js +0 -14
- package/lib/maths/MathUtils.d.ts +0 -15
- package/lib/maths/MathUtils.js +0 -33
- package/lib/notifications.d.ts +0 -98
- package/lib/notifications.js +0 -52
- package/lib/signatures/index.d.ts +0 -12
- package/lib/signatures/index.js +0 -39
- package/lib/signatures/manager.d.ts +0 -10
- package/lib/signatures/manager.js +0 -37
- package/lib/signatures/permit.d.ts +0 -21
- package/lib/signatures/permit.js +0 -101
- package/lib/signatures/permit2.d.ts +0 -20
- package/lib/signatures/permit2.js +0 -91
- package/lib/signatures/types.d.ts +0 -13
- package/lib/signatures/types.js +0 -2
- package/lib/signatures/utils.d.ts +0 -6
- package/lib/signatures/utils.js +0 -44
- package/lib/token/ERC20Metadata.d.ts +0 -249
- package/lib/token/ERC20Metadata.js +0 -81
- package/lib/token/TokenNamespace.d.ts +0 -18
- package/lib/token/TokenNamespace.js +0 -55
- package/lib/vault/VaultAllocation.d.ts +0 -38
- package/lib/vault/VaultAllocation.js +0 -18
- /package/lib/{chain/chain.test.d.ts → chain.test.d.ts} +0 -0
package/lib/errors.d.ts
CHANGED
|
@@ -21,11 +21,20 @@ export declare class UnsupportedChainIdError extends Error {
|
|
|
21
21
|
readonly chainId: number;
|
|
22
22
|
constructor(chainId: number);
|
|
23
23
|
}
|
|
24
|
-
export declare
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
export declare namespace BlueErrors {
|
|
25
|
+
class InvalidInterestAccrual extends Error {
|
|
26
|
+
readonly marketId: MarketId;
|
|
27
|
+
readonly timestamp: bigint;
|
|
28
|
+
readonly lastUpdate: bigint;
|
|
29
|
+
constructor(marketId: MarketId, timestamp: bigint, lastUpdate: bigint);
|
|
30
|
+
}
|
|
31
|
+
class InconsistentInput extends Error {
|
|
32
|
+
constructor();
|
|
33
|
+
}
|
|
34
|
+
class InsufficientLiquidity extends Error {
|
|
35
|
+
readonly marketId: MarketId;
|
|
36
|
+
constructor(marketId: MarketId);
|
|
37
|
+
}
|
|
29
38
|
}
|
|
30
39
|
export declare class InvalidSignatureError extends Error {
|
|
31
40
|
readonly hash: string;
|
|
@@ -33,5 +42,7 @@ export declare class InvalidSignatureError extends Error {
|
|
|
33
42
|
readonly recovered: Address;
|
|
34
43
|
constructor(hash: string, signer: Address, recovered: Address);
|
|
35
44
|
}
|
|
36
|
-
export
|
|
37
|
-
|
|
45
|
+
export interface ErrorClass<E extends Error> {
|
|
46
|
+
new (...args: any[]): E;
|
|
47
|
+
}
|
|
48
|
+
export declare function _try<T, E extends Error>(accessor: () => T, ...errorClasses: ErrorClass<E>[]): T | undefined;
|
package/lib/errors.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.InvalidSignatureError = exports.BlueErrors = exports.UnsupportedChainIdError = exports.UnknownVaultConfigError = exports.UnknownMarketConfigError = exports.UnknownTokenPriceError = exports.UnknownTokenError = exports.UnknownDataError = void 0;
|
|
4
|
+
exports._try = _try;
|
|
4
5
|
class UnknownDataError extends Error {
|
|
5
6
|
}
|
|
6
7
|
exports.UnknownDataError = UnknownDataError;
|
|
7
8
|
class UnknownTokenError extends UnknownDataError {
|
|
9
|
+
address;
|
|
8
10
|
constructor(address) {
|
|
9
11
|
super(`unknown token ${address}`);
|
|
10
12
|
this.address = address;
|
|
@@ -12,6 +14,7 @@ class UnknownTokenError extends UnknownDataError {
|
|
|
12
14
|
}
|
|
13
15
|
exports.UnknownTokenError = UnknownTokenError;
|
|
14
16
|
class UnknownTokenPriceError extends UnknownDataError {
|
|
17
|
+
address;
|
|
15
18
|
constructor(address) {
|
|
16
19
|
super(`unknown price of token ${address}`);
|
|
17
20
|
this.address = address;
|
|
@@ -19,6 +22,7 @@ class UnknownTokenPriceError extends UnknownDataError {
|
|
|
19
22
|
}
|
|
20
23
|
exports.UnknownTokenPriceError = UnknownTokenPriceError;
|
|
21
24
|
class UnknownMarketConfigError extends UnknownDataError {
|
|
25
|
+
marketId;
|
|
22
26
|
constructor(marketId) {
|
|
23
27
|
super(`unknown config for market ${marketId}`);
|
|
24
28
|
this.marketId = marketId;
|
|
@@ -26,6 +30,7 @@ class UnknownMarketConfigError extends UnknownDataError {
|
|
|
26
30
|
}
|
|
27
31
|
exports.UnknownMarketConfigError = UnknownMarketConfigError;
|
|
28
32
|
class UnknownVaultConfigError extends UnknownDataError {
|
|
33
|
+
vault;
|
|
29
34
|
constructor(vault) {
|
|
30
35
|
super(`unknown config for vault ${vault}`);
|
|
31
36
|
this.vault = vault;
|
|
@@ -33,22 +38,46 @@ class UnknownVaultConfigError extends UnknownDataError {
|
|
|
33
38
|
}
|
|
34
39
|
exports.UnknownVaultConfigError = UnknownVaultConfigError;
|
|
35
40
|
class UnsupportedChainIdError extends Error {
|
|
41
|
+
chainId;
|
|
36
42
|
constructor(chainId) {
|
|
37
43
|
super(`unsupported chain ${chainId}`);
|
|
38
44
|
this.chainId = chainId;
|
|
39
45
|
}
|
|
40
46
|
}
|
|
41
47
|
exports.UnsupportedChainIdError = UnsupportedChainIdError;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
var BlueErrors;
|
|
49
|
+
(function (BlueErrors) {
|
|
50
|
+
class InvalidInterestAccrual extends Error {
|
|
51
|
+
marketId;
|
|
52
|
+
timestamp;
|
|
53
|
+
lastUpdate;
|
|
54
|
+
constructor(marketId, timestamp, lastUpdate) {
|
|
55
|
+
super(`invalid interest accrual on market ${marketId}: accrual timestamp ${timestamp} can't be prior to last update ${lastUpdate}`);
|
|
56
|
+
this.marketId = marketId;
|
|
57
|
+
this.timestamp = timestamp;
|
|
58
|
+
this.lastUpdate = lastUpdate;
|
|
59
|
+
}
|
|
48
60
|
}
|
|
49
|
-
|
|
50
|
-
|
|
61
|
+
BlueErrors.InvalidInterestAccrual = InvalidInterestAccrual;
|
|
62
|
+
class InconsistentInput extends Error {
|
|
63
|
+
constructor() {
|
|
64
|
+
super(`inconsistent input: assets & shares cannot both be zero`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
BlueErrors.InconsistentInput = InconsistentInput;
|
|
68
|
+
class InsufficientLiquidity extends Error {
|
|
69
|
+
marketId;
|
|
70
|
+
constructor(marketId) {
|
|
71
|
+
super(`insufficient liquidity on market ${marketId}`);
|
|
72
|
+
this.marketId = marketId;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
BlueErrors.InsufficientLiquidity = InsufficientLiquidity;
|
|
76
|
+
})(BlueErrors || (exports.BlueErrors = BlueErrors = {}));
|
|
51
77
|
class InvalidSignatureError extends Error {
|
|
78
|
+
hash;
|
|
79
|
+
signer;
|
|
80
|
+
recovered;
|
|
52
81
|
constructor(hash, signer, recovered) {
|
|
53
82
|
super(`invalid signature for hash ${hash}: expected ${signer}, recovered ${recovered}`);
|
|
54
83
|
this.hash = hash;
|
|
@@ -68,4 +97,3 @@ function _try(accessor, ...errorClasses) {
|
|
|
68
97
|
throw error;
|
|
69
98
|
}
|
|
70
99
|
}
|
|
71
|
-
exports._try = _try;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.format = exports.PercentFormatter = exports.ShortFormatter = exports.CommasFormatter = exports.NumberFormatter = exports.CommonFormatter = exports.HexFormatter = exports.BaseFormatter = void 0;
|
|
4
|
-
const ethers_1 = require("ethers");
|
|
5
4
|
const locale_1 = require("../locale");
|
|
6
5
|
var Format;
|
|
7
6
|
(function (Format) {
|
|
@@ -117,15 +116,15 @@ const _applyOptions = (value, formatOptions) => {
|
|
|
117
116
|
function formatBI(bi, decimals, formatOptions = { format: Format.hex }) {
|
|
118
117
|
if (formatOptions.format === Format.hex)
|
|
119
118
|
return bi.toString(16);
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
119
|
+
if (formatOptions.max != null) {
|
|
120
|
+
const maxBI = BigInt(formatOptions.max.toFixed(decimals).replace(".", ""));
|
|
121
|
+
if (bi > maxBI)
|
|
122
|
+
return `> ${formatBI(maxBI, decimals, formatOptions)}`;
|
|
124
123
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
124
|
+
if (formatOptions.min != null) {
|
|
125
|
+
const minBI = BigInt(formatOptions.min.toFixed(decimals).replace(".", ""));
|
|
126
|
+
if (bi < minBI && bi !== 0n)
|
|
127
|
+
return `< ${formatBI(minBI, decimals, formatOptions)}`;
|
|
129
128
|
}
|
|
130
129
|
let value;
|
|
131
130
|
const isNegative = bi < 0n;
|
|
@@ -154,50 +153,24 @@ function formatBI(bi, decimals, formatOptions = { format: Format.hex }) {
|
|
|
154
153
|
}
|
|
155
154
|
return formattedValue;
|
|
156
155
|
}
|
|
157
|
-
/**
|
|
158
|
-
* returns a string representation of a number, always in a decimal format (avoid the 1.34e-15 format for small numbers)
|
|
159
|
-
* @param number
|
|
160
|
-
*/
|
|
161
|
-
const safeNumberToString = (number) => {
|
|
162
|
-
const str = number.toString();
|
|
163
|
-
const [a, n] = str.split(/[eE]/);
|
|
164
|
-
if (a == null || n == null)
|
|
165
|
-
return str;
|
|
166
|
-
if (n[0] === "+") {
|
|
167
|
-
const [whole, decimal = ""] = a.split(".");
|
|
168
|
-
return whole + decimal + "0".repeat(+n - decimal.length);
|
|
169
|
-
}
|
|
170
|
-
if (n[0] === "-") {
|
|
171
|
-
const isNegative = a[0] === "-";
|
|
172
|
-
return ((isNegative ? "-" : "") +
|
|
173
|
-
"0." +
|
|
174
|
-
"0".repeat(-+n - 1) +
|
|
175
|
-
(isNegative ? a.slice(1) : a).split(".").join(""));
|
|
176
|
-
}
|
|
177
|
-
throw new Error(`Unhandled case: ${str}`);
|
|
178
|
-
};
|
|
179
156
|
class BaseFormatter {
|
|
180
157
|
constructor() { }
|
|
181
158
|
of(value, decimals) {
|
|
182
|
-
let _decimals;
|
|
183
159
|
if (typeof value === "number") {
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
160
|
+
const str = value.toString();
|
|
161
|
+
const [significant] = str.split(/[eE]/);
|
|
162
|
+
const [, digits = ""] = significant.split(".");
|
|
163
|
+
decimals =
|
|
164
|
+
Math.min(100, Math.max(0, Math.floor(-Math.log10(value)))) +
|
|
165
|
+
digits.length;
|
|
166
|
+
value = BigInt(value.toFixed(decimals).replace(".", ""));
|
|
188
167
|
}
|
|
189
|
-
|
|
190
|
-
_decimals = decimals;
|
|
191
|
-
}
|
|
192
|
-
return formatBI(value, _decimals, this._options);
|
|
168
|
+
return formatBI(value, decimals, this._options);
|
|
193
169
|
}
|
|
194
170
|
}
|
|
195
171
|
exports.BaseFormatter = BaseFormatter;
|
|
196
172
|
class HexFormatter extends BaseFormatter {
|
|
197
|
-
|
|
198
|
-
super(...arguments);
|
|
199
|
-
this._options = { format: Format.hex };
|
|
200
|
-
}
|
|
173
|
+
_options = { format: Format.hex };
|
|
201
174
|
}
|
|
202
175
|
exports.HexFormatter = HexFormatter;
|
|
203
176
|
class CommonFormatter extends BaseFormatter {
|
|
@@ -236,24 +209,15 @@ class CommonFormatter extends BaseFormatter {
|
|
|
236
209
|
}
|
|
237
210
|
exports.CommonFormatter = CommonFormatter;
|
|
238
211
|
class NumberFormatter extends CommonFormatter {
|
|
239
|
-
|
|
240
|
-
super(...arguments);
|
|
241
|
-
this._options = { format: Format.number };
|
|
242
|
-
}
|
|
212
|
+
_options = { format: Format.number };
|
|
243
213
|
}
|
|
244
214
|
exports.NumberFormatter = NumberFormatter;
|
|
245
215
|
class CommasFormatter extends CommonFormatter {
|
|
246
|
-
|
|
247
|
-
super(...arguments);
|
|
248
|
-
this._options = { format: Format.commas };
|
|
249
|
-
}
|
|
216
|
+
_options = { format: Format.commas };
|
|
250
217
|
}
|
|
251
218
|
exports.CommasFormatter = CommasFormatter;
|
|
252
219
|
class ShortFormatter extends CommonFormatter {
|
|
253
|
-
|
|
254
|
-
super(...arguments);
|
|
255
|
-
this._options = { format: Format.short };
|
|
256
|
-
}
|
|
220
|
+
_options = { format: Format.short };
|
|
257
221
|
smallValuesWithCommas() {
|
|
258
222
|
this._options.smallValuesWithCommas = true;
|
|
259
223
|
return this;
|
|
@@ -261,10 +225,7 @@ class ShortFormatter extends CommonFormatter {
|
|
|
261
225
|
}
|
|
262
226
|
exports.ShortFormatter = ShortFormatter;
|
|
263
227
|
class PercentFormatter extends CommonFormatter {
|
|
264
|
-
|
|
265
|
-
super(...arguments);
|
|
266
|
-
this._options = { format: Format.percent };
|
|
267
|
-
}
|
|
228
|
+
_options = { format: Format.percent };
|
|
268
229
|
}
|
|
269
230
|
exports.PercentFormatter = PercentFormatter;
|
|
270
231
|
exports.format = {
|
package/lib/helpers/index.d.ts
CHANGED
package/lib/helpers/index.js
CHANGED
|
@@ -14,7 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./getChecksumedAddress"), exports);
|
|
18
|
-
__exportStar(require("./isZeroAddressOrUnset"), exports);
|
|
19
17
|
__exportStar(require("./locale"), exports);
|
|
20
18
|
__exportStar(require("./format"), exports);
|
package/lib/holding/Holding.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { BigNumberish } from "ethers";
|
|
2
1
|
import { Address } from "../types";
|
|
3
2
|
export declare const ERC20_ALLOWANCE_RECIPIENTS: readonly ["morpho", "permit2", "bundler"];
|
|
4
3
|
export declare const PERMIT2_ALLOWANCE_RECIPIENTS: readonly ["morpho", "bundler"];
|
|
@@ -13,14 +12,14 @@ export interface InputHolding {
|
|
|
13
12
|
user: Address;
|
|
14
13
|
token: Address;
|
|
15
14
|
erc20Allowances: {
|
|
16
|
-
[key in Erc20AllowanceRecipient]:
|
|
15
|
+
[key in Erc20AllowanceRecipient]: bigint;
|
|
17
16
|
};
|
|
18
17
|
permit2Allowances: {
|
|
19
18
|
[key in Permit2AllowanceRecipient]: Permit2Allowance;
|
|
20
19
|
};
|
|
21
|
-
erc2612Nonce?:
|
|
20
|
+
erc2612Nonce?: bigint;
|
|
22
21
|
canTransfer?: boolean;
|
|
23
|
-
balance:
|
|
22
|
+
balance: bigint;
|
|
24
23
|
}
|
|
25
24
|
export declare class Holding implements InputHolding {
|
|
26
25
|
/**
|
package/lib/holding/Holding.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Holding = exports.PERMIT2_ALLOWANCE_RECIPIENTS = exports.ERC20_ALLOWANCE_RECIPIENTS = void 0;
|
|
4
|
-
const ethers_1 = require("ethers");
|
|
5
4
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
5
|
const addresses_1 = require("../addresses");
|
|
7
6
|
exports.ERC20_ALLOWANCE_RECIPIENTS = [
|
|
@@ -14,18 +13,47 @@ exports.PERMIT2_ALLOWANCE_RECIPIENTS = [
|
|
|
14
13
|
"bundler",
|
|
15
14
|
];
|
|
16
15
|
class Holding {
|
|
16
|
+
/**
|
|
17
|
+
* The user of this holding.
|
|
18
|
+
*/
|
|
19
|
+
user;
|
|
20
|
+
/**
|
|
21
|
+
* The token in which this holding is denominated.
|
|
22
|
+
*/
|
|
23
|
+
token;
|
|
24
|
+
/**
|
|
25
|
+
* The balance of the user for this token.
|
|
26
|
+
*/
|
|
27
|
+
balance;
|
|
28
|
+
/**
|
|
29
|
+
* Whether the user is allowed to transfer this holding's balance.
|
|
30
|
+
*/
|
|
31
|
+
canTransfer;
|
|
32
|
+
/**
|
|
33
|
+
* ERC20 allowance for this token from the user to the allowance recipient.
|
|
34
|
+
*/
|
|
35
|
+
erc20Allowances;
|
|
36
|
+
/**
|
|
37
|
+
* Permit2 allowance for this token from the user to the allowance recipient.
|
|
38
|
+
*/
|
|
39
|
+
permit2Allowances;
|
|
40
|
+
/**
|
|
41
|
+
* ERC-2612 Permit nonce of the user for this token.
|
|
42
|
+
* `undefined` if the token does not support ERC-2612.
|
|
43
|
+
*/
|
|
44
|
+
erc2612Nonce;
|
|
17
45
|
constructor({ user, token, erc20Allowances, permit2Allowances, balance, erc2612Nonce, canTransfer = true, }) {
|
|
18
46
|
this.user = user;
|
|
19
47
|
this.token = token;
|
|
20
|
-
this.balance =
|
|
48
|
+
this.balance = balance;
|
|
21
49
|
this.canTransfer = token === addresses_1.NATIVE_ADDRESS || canTransfer;
|
|
22
50
|
this.erc20Allowances = (0, morpho_ts_1.fromEntries)((0, morpho_ts_1.entries)(erc20Allowances).map(([address, allowance]) => [
|
|
23
51
|
address,
|
|
24
|
-
|
|
52
|
+
allowance,
|
|
25
53
|
]));
|
|
26
54
|
this.permit2Allowances = permit2Allowances;
|
|
27
55
|
if (erc2612Nonce != null)
|
|
28
|
-
this.erc2612Nonce =
|
|
56
|
+
this.erc2612Nonce = erc2612Nonce;
|
|
29
57
|
}
|
|
30
58
|
}
|
|
31
59
|
exports.Holding = Holding;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export * from "./addresses";
|
|
2
|
-
export * from "./evm";
|
|
3
2
|
export * from "./constants";
|
|
4
3
|
export * from "./errors";
|
|
5
4
|
export * from "./market";
|
|
@@ -7,15 +6,11 @@ export * from "./chain";
|
|
|
7
6
|
export * from "./token";
|
|
8
7
|
export * from "./types";
|
|
9
8
|
export * from "./maths";
|
|
10
|
-
export * from "./notifications";
|
|
11
|
-
export * from "./signatures";
|
|
12
9
|
export * from "./user";
|
|
13
10
|
export * from "./holding";
|
|
14
11
|
export * from "./position";
|
|
15
12
|
export * from "./helpers";
|
|
16
|
-
export * from "./ethers";
|
|
17
13
|
export * from "./vault";
|
|
18
|
-
export * as evm from "./evm";
|
|
19
14
|
export * as constants from "./constants";
|
|
20
15
|
export * as errors from "./errors";
|
|
21
16
|
export * as market from "./market";
|
|
@@ -25,9 +20,6 @@ export * as position from "./position";
|
|
|
25
20
|
export * as holding from "./holding";
|
|
26
21
|
export * as types from "./types";
|
|
27
22
|
export * as maths from "./maths";
|
|
28
|
-
export * as notifications from "./notifications";
|
|
29
|
-
export * as signatures from "./signatures";
|
|
30
23
|
export * as user from "./user";
|
|
31
24
|
export * as helpers from "./helpers";
|
|
32
|
-
export * as ethers from "./ethers";
|
|
33
25
|
export * as vault from "./vault";
|
package/lib/index.js
CHANGED
|
@@ -26,9 +26,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
26
26
|
return result;
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.vault = exports.
|
|
29
|
+
exports.vault = exports.helpers = exports.user = exports.maths = exports.types = exports.holding = exports.position = exports.token = exports.chain = exports.market = exports.errors = exports.constants = void 0;
|
|
30
30
|
__exportStar(require("./addresses"), exports);
|
|
31
|
-
__exportStar(require("./evm"), exports);
|
|
32
31
|
__exportStar(require("./constants"), exports);
|
|
33
32
|
__exportStar(require("./errors"), exports);
|
|
34
33
|
__exportStar(require("./market"), exports);
|
|
@@ -36,15 +35,11 @@ __exportStar(require("./chain"), exports);
|
|
|
36
35
|
__exportStar(require("./token"), exports);
|
|
37
36
|
__exportStar(require("./types"), exports);
|
|
38
37
|
__exportStar(require("./maths"), exports);
|
|
39
|
-
__exportStar(require("./notifications"), exports);
|
|
40
|
-
__exportStar(require("./signatures"), exports);
|
|
41
38
|
__exportStar(require("./user"), exports);
|
|
42
39
|
__exportStar(require("./holding"), exports);
|
|
43
40
|
__exportStar(require("./position"), exports);
|
|
44
41
|
__exportStar(require("./helpers"), exports);
|
|
45
|
-
__exportStar(require("./ethers"), exports);
|
|
46
42
|
__exportStar(require("./vault"), exports);
|
|
47
|
-
exports.evm = __importStar(require("./evm"));
|
|
48
43
|
exports.constants = __importStar(require("./constants"));
|
|
49
44
|
exports.errors = __importStar(require("./errors"));
|
|
50
45
|
exports.market = __importStar(require("./market"));
|
|
@@ -54,9 +49,6 @@ exports.position = __importStar(require("./position"));
|
|
|
54
49
|
exports.holding = __importStar(require("./holding"));
|
|
55
50
|
exports.types = __importStar(require("./types"));
|
|
56
51
|
exports.maths = __importStar(require("./maths"));
|
|
57
|
-
exports.notifications = __importStar(require("./notifications"));
|
|
58
|
-
exports.signatures = __importStar(require("./signatures"));
|
|
59
52
|
exports.user = __importStar(require("./user"));
|
|
60
53
|
exports.helpers = __importStar(require("./helpers"));
|
|
61
|
-
exports.ethers = __importStar(require("./ethers"));
|
|
62
54
|
exports.vault = __importStar(require("./vault"));
|