@morpho-org/morpho-test 2.0.0-test.1 → 2.0.1
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/LICENSE +21 -0
- package/README.md +30 -24
- package/lib/fixtures/index.d.ts +3 -0
- package/lib/fixtures/index.js +19 -0
- package/lib/fixtures/markets.d.ts +35 -0
- package/lib/fixtures/markets.js +209 -0
- package/lib/fixtures/tokens.d.ts +4 -0
- package/lib/fixtures/tokens.js +17 -0
- package/lib/fixtures/vaults.d.ts +13 -0
- package/lib/fixtures/vaults.js +68 -0
- package/lib/index.d.ts +0 -3
- package/lib/index.js +0 -3
- package/package.json +28 -38
- package/lib/asserts.d.ts +0 -3
- package/lib/asserts.js +0 -13
- package/lib/chai.d.ts +0 -12
- package/lib/chai.js +0 -122
- package/lib/fixtures.d.ts +0 -1
- package/lib/fixtures.js +0 -10
- package/lib/hardhat.d.ts +0 -17
- package/lib/hardhat.js +0 -62
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Morpho Association
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,11 +1,29 @@
|
|
|
1
1
|
# @morpho-org/morpho-test
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
<a href="https://www.npmjs.com/package/@morpho-org/morpho-test">
|
|
4
|
+
<picture>
|
|
5
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/v/@morpho-org/morpho-test?colorA=21262d&colorB=21262d&style=flat">
|
|
6
|
+
<img src="https://img.shields.io/npm/v/@morpho-org/morpho-test?colorA=f6f8fa&colorB=f6f8fa&style=flat" alt="Version">
|
|
7
|
+
</picture>
|
|
8
|
+
</a>
|
|
9
|
+
<a href="https://github.com/morpho-org/morpho-test/blob/main/LICENSE">
|
|
10
|
+
<picture>
|
|
11
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/l/@morpho-org/morpho-test?colorA=21262d&colorB=21262d&style=flat">
|
|
12
|
+
<img src="https://img.shields.io/npm/l/@morpho-org/morpho-test?colorA=f6f8fa&colorB=f6f8fa&style=flat" alt="MIT License">
|
|
13
|
+
</picture>
|
|
14
|
+
</a>
|
|
15
|
+
<a href="https://www.npmjs.com/package/@morpho-org/morpho-test">
|
|
16
|
+
<picture>
|
|
17
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/dm/@morpho-org/morpho-test?colorA=21262d&colorB=21262d&style=flat">
|
|
18
|
+
<img src="https://img.shields.io/npm/dm/@morpho-org/morpho-test?colorA=f6f8fa&colorB=f6f8fa&style=flat" alt="Downloads per month">
|
|
19
|
+
</picture>
|
|
20
|
+
</a>
|
|
21
|
+
<br />
|
|
22
|
+
<br />
|
|
23
|
+
|
|
24
|
+
Framework-agnostic extension of [`@morpho-org/blue-sdk`](../blue-sdk/) that exports test fixtures useful for E2E tests on forks.
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
9
27
|
|
|
10
28
|
```bash
|
|
11
29
|
npm install @morpho-org/morpho-test
|
|
@@ -15,25 +33,13 @@ npm install @morpho-org/morpho-test
|
|
|
15
33
|
yarn add @morpho-org/morpho-test
|
|
16
34
|
```
|
|
17
35
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
## Usage
|
|
36
|
+
## Getting Started
|
|
21
37
|
|
|
22
|
-
|
|
38
|
+
```typescript
|
|
39
|
+
import { ChainId } from "@morpho-org/blue-sdk";
|
|
40
|
+
import { markets } from "@morpho-org/morpho-test";
|
|
23
41
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
```log
|
|
27
|
-
node:internal/modules/esm/utils:211
|
|
28
|
-
throw new ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING_FLAG();
|
|
29
|
-
^
|
|
30
|
-
|
|
31
|
-
TypeError: A dynamic import callback was invoked without --experimental-vm-modules
|
|
42
|
+
const { usdc_wstEth, usdc_idle, eth_wstEth } = markets[ChainId.EthMainnet];
|
|
32
43
|
```
|
|
33
44
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
[downloads-img]: https://img.shields.io/npm/dt/@morpho-org/morpho-test
|
|
37
|
-
[downloads-url]: https://www.npmtrends.com/@morpho-org/morpho-test
|
|
38
|
-
[npm-img]: https://img.shields.io/npm/v/@morpho-org/morpho-test
|
|
39
|
-
[npm-url]: https://www.npmjs.com/package/@morpho-org/morpho-test
|
|
45
|
+
See more on its internal usage for [E2E tests here](../blue-sdk-viem/test/Market.test.ts).
|
|
@@ -0,0 +1,19 @@
|
|
|
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("./markets"), exports);
|
|
18
|
+
__exportStar(require("./vaults"), exports);
|
|
19
|
+
__exportStar(require("./tokens"), exports);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type IMarketParams, MarketParams } from "@morpho-org/blue-sdk";
|
|
2
|
+
export declare const markets: {
|
|
3
|
+
readonly 1: {
|
|
4
|
+
readonly eth_idle: MarketParams;
|
|
5
|
+
readonly eth_wstEth: MarketParams;
|
|
6
|
+
readonly eth_wstEth_2: MarketParams;
|
|
7
|
+
readonly eth_rEth: MarketParams;
|
|
8
|
+
readonly eth_sDai: MarketParams;
|
|
9
|
+
readonly eth_wbtc: MarketParams;
|
|
10
|
+
readonly eth_ezEth: MarketParams;
|
|
11
|
+
readonly eth_apxEth: MarketParams;
|
|
12
|
+
readonly eth_osEth: MarketParams;
|
|
13
|
+
readonly eth_weEth: MarketParams;
|
|
14
|
+
readonly usdt_idle: MarketParams;
|
|
15
|
+
readonly usdt_weth_86: MarketParams;
|
|
16
|
+
readonly usdt_weth_91_5: MarketParams;
|
|
17
|
+
readonly usdt_wbtc: MarketParams;
|
|
18
|
+
readonly usdt_wstEth: MarketParams;
|
|
19
|
+
readonly usdt_sDai: MarketParams;
|
|
20
|
+
readonly usdc_idle: MarketParams;
|
|
21
|
+
readonly usdc_wbtc: MarketParams;
|
|
22
|
+
readonly usdc_wstEth: MarketParams;
|
|
23
|
+
readonly usdc_sDai: MarketParams;
|
|
24
|
+
readonly usdc_wbIB01: MarketParams;
|
|
25
|
+
readonly dai_sUsde: MarketParams;
|
|
26
|
+
readonly crvUsd_stkcvxcrvUSDTWBTCWETH: MarketParams;
|
|
27
|
+
readonly crvUsd_stkcvxcrvUSDCWBTCWETH: MarketParams;
|
|
28
|
+
readonly crvUsd_stkcvxcrvCRVUSDTBTCWSTETH: MarketParams;
|
|
29
|
+
readonly crvUsd_stkcvxTryLSD: MarketParams;
|
|
30
|
+
readonly crvUsd_stkcvxcrvUSDETHCRV: MarketParams;
|
|
31
|
+
readonly crvUsd_stkcvx2BTC: MarketParams;
|
|
32
|
+
readonly usda_re7Eth: MarketParams;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export declare const randomMarket: (params?: Partial<IMarketParams>) => MarketParams;
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.randomMarket = exports.markets = void 0;
|
|
4
|
+
const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
|
+
const test_1 = require("@morpho-org/test");
|
|
6
|
+
const viem_1 = require("viem");
|
|
7
|
+
const { adaptiveCurveIrm, wNative, sDai, usdc, wstEth, wbIB01, usdt, dai } = blue_sdk_1.addresses[blue_sdk_1.ChainId.EthMainnet];
|
|
8
|
+
exports.markets = {
|
|
9
|
+
[blue_sdk_1.ChainId.EthMainnet]: {
|
|
10
|
+
eth_idle: blue_sdk_1.MarketParams.idle(wNative),
|
|
11
|
+
eth_wstEth: new blue_sdk_1.MarketParams({
|
|
12
|
+
loanToken: wNative,
|
|
13
|
+
collateralToken: wstEth,
|
|
14
|
+
oracle: "0x2a01EB9496094dA03c4E364Def50f5aD1280AD72",
|
|
15
|
+
irm: adaptiveCurveIrm,
|
|
16
|
+
lltv: (0, viem_1.parseUnits)("94.5", 16),
|
|
17
|
+
}),
|
|
18
|
+
eth_wstEth_2: new blue_sdk_1.MarketParams({
|
|
19
|
+
loanToken: wNative,
|
|
20
|
+
collateralToken: wstEth,
|
|
21
|
+
oracle: "0xbD60A6770b27E084E8617335ddE769241B0e71D8",
|
|
22
|
+
irm: adaptiveCurveIrm,
|
|
23
|
+
lltv: (0, viem_1.parseUnits)("94.5", 16),
|
|
24
|
+
}),
|
|
25
|
+
eth_rEth: new blue_sdk_1.MarketParams({
|
|
26
|
+
loanToken: wNative,
|
|
27
|
+
collateralToken: "0xae78736Cd615f374D3085123A210448E74Fc6393",
|
|
28
|
+
oracle: "0x1b4A3F92e5Fffd1d35A98751c9FE4472483579bB",
|
|
29
|
+
irm: adaptiveCurveIrm,
|
|
30
|
+
lltv: (0, viem_1.parseUnits)("94.5", 16),
|
|
31
|
+
}),
|
|
32
|
+
eth_sDai: new blue_sdk_1.MarketParams({
|
|
33
|
+
loanToken: wNative,
|
|
34
|
+
collateralToken: sDai,
|
|
35
|
+
oracle: "0x0f9bb760D76af1B5Ca89102084E1963F6698AFda",
|
|
36
|
+
irm: adaptiveCurveIrm,
|
|
37
|
+
lltv: (0, viem_1.parseUnits)("86", 16),
|
|
38
|
+
}),
|
|
39
|
+
eth_wbtc: new blue_sdk_1.MarketParams({
|
|
40
|
+
loanToken: wNative,
|
|
41
|
+
collateralToken: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
|
|
42
|
+
oracle: "0xc29B3Bc033640baE31ca53F8a0Eb892AdF68e663",
|
|
43
|
+
irm: adaptiveCurveIrm,
|
|
44
|
+
lltv: (0, viem_1.parseUnits)("91.5", 16),
|
|
45
|
+
}),
|
|
46
|
+
eth_ezEth: new blue_sdk_1.MarketParams({
|
|
47
|
+
loanToken: wNative,
|
|
48
|
+
collateralToken: "0xbf5495Efe5DB9ce00f80364C8B423567e58d2110",
|
|
49
|
+
oracle: "0x61025e2B0122ac8bE4e37365A4003d87ad888Cc3",
|
|
50
|
+
irm: adaptiveCurveIrm,
|
|
51
|
+
lltv: (0, viem_1.parseUnits)("86", 16),
|
|
52
|
+
}),
|
|
53
|
+
eth_apxEth: new blue_sdk_1.MarketParams({
|
|
54
|
+
loanToken: wNative,
|
|
55
|
+
collateralToken: "0x9Ba021B0a9b958B5E75cE9f6dff97C7eE52cb3E6",
|
|
56
|
+
oracle: "0x037D67A5E6F19d0Fb26A6603d2D4fE9d70eC3258",
|
|
57
|
+
irm: adaptiveCurveIrm,
|
|
58
|
+
lltv: (0, viem_1.parseUnits)("86", 16),
|
|
59
|
+
}),
|
|
60
|
+
eth_osEth: new blue_sdk_1.MarketParams({
|
|
61
|
+
loanToken: wNative,
|
|
62
|
+
collateralToken: "0xf1C9acDc66974dFB6dEcB12aA385b9cD01190E38",
|
|
63
|
+
oracle: "0x224F2F1333b45E34fFCfC3bD01cE43C73A914498",
|
|
64
|
+
irm: adaptiveCurveIrm,
|
|
65
|
+
lltv: (0, viem_1.parseUnits)("86", 16),
|
|
66
|
+
}),
|
|
67
|
+
eth_weEth: new blue_sdk_1.MarketParams({
|
|
68
|
+
loanToken: wNative,
|
|
69
|
+
collateralToken: "0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee",
|
|
70
|
+
oracle: "0x3fa58b74e9a8eA8768eb33c8453e9C2Ed089A40a",
|
|
71
|
+
irm: adaptiveCurveIrm,
|
|
72
|
+
lltv: (0, viem_1.parseUnits)("86", 16),
|
|
73
|
+
}),
|
|
74
|
+
usdt_idle: blue_sdk_1.MarketParams.idle(usdt),
|
|
75
|
+
usdt_weth_86: new blue_sdk_1.MarketParams({
|
|
76
|
+
loanToken: usdt,
|
|
77
|
+
collateralToken: wNative,
|
|
78
|
+
oracle: "0xe9eE579684716c7Bb837224F4c7BeEfA4f1F3d7f",
|
|
79
|
+
irm: adaptiveCurveIrm,
|
|
80
|
+
lltv: (0, viem_1.parseUnits)("86", 16),
|
|
81
|
+
}),
|
|
82
|
+
usdt_weth_91_5: new blue_sdk_1.MarketParams({
|
|
83
|
+
loanToken: usdt,
|
|
84
|
+
collateralToken: wNative,
|
|
85
|
+
oracle: "0xe9eE579684716c7Bb837224F4c7BeEfA4f1F3d7f",
|
|
86
|
+
irm: adaptiveCurveIrm,
|
|
87
|
+
lltv: (0, viem_1.parseUnits)("91.5", 16),
|
|
88
|
+
}),
|
|
89
|
+
usdt_wbtc: new blue_sdk_1.MarketParams({
|
|
90
|
+
loanToken: usdt,
|
|
91
|
+
collateralToken: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
|
|
92
|
+
oracle: "0x008bF4B1cDA0cc9f0e882E0697f036667652E1ef",
|
|
93
|
+
irm: adaptiveCurveIrm,
|
|
94
|
+
lltv: (0, viem_1.parseUnits)("86", 16),
|
|
95
|
+
}),
|
|
96
|
+
usdt_wstEth: new blue_sdk_1.MarketParams({
|
|
97
|
+
loanToken: usdt,
|
|
98
|
+
collateralToken: wstEth,
|
|
99
|
+
oracle: "0x95DB30fAb9A3754e42423000DF27732CB2396992",
|
|
100
|
+
irm: adaptiveCurveIrm,
|
|
101
|
+
lltv: (0, viem_1.parseUnits)("86", 16),
|
|
102
|
+
}),
|
|
103
|
+
usdt_sDai: new blue_sdk_1.MarketParams({
|
|
104
|
+
loanToken: usdt,
|
|
105
|
+
collateralToken: sDai,
|
|
106
|
+
oracle: "0x7538C68d863b28E34b986C1E8daFEDa31D824923",
|
|
107
|
+
irm: adaptiveCurveIrm,
|
|
108
|
+
lltv: (0, viem_1.parseUnits)("94.5", 16),
|
|
109
|
+
}),
|
|
110
|
+
usdc_idle: blue_sdk_1.MarketParams.idle(usdc),
|
|
111
|
+
usdc_wbtc: new blue_sdk_1.MarketParams({
|
|
112
|
+
// USDC(wBTC, 86%, Chainlink, AdaptiveCurve)
|
|
113
|
+
loanToken: usdc,
|
|
114
|
+
collateralToken: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
|
|
115
|
+
oracle: "0xDddd770BADd886dF3864029e4B377B5F6a2B6b83",
|
|
116
|
+
irm: adaptiveCurveIrm,
|
|
117
|
+
lltv: (0, viem_1.parseUnits)("86", 16),
|
|
118
|
+
}),
|
|
119
|
+
usdc_wstEth: new blue_sdk_1.MarketParams({
|
|
120
|
+
// USDC(wstETH, 86%, Chainlink, AdaptiveCurve)
|
|
121
|
+
loanToken: usdc,
|
|
122
|
+
collateralToken: wstEth,
|
|
123
|
+
oracle: "0x48F7E36EB6B826B2dF4B2E630B62Cd25e89E40e2",
|
|
124
|
+
irm: adaptiveCurveIrm,
|
|
125
|
+
lltv: (0, viem_1.parseUnits)("86", 16),
|
|
126
|
+
}),
|
|
127
|
+
usdc_sDai: new blue_sdk_1.MarketParams({
|
|
128
|
+
loanToken: usdc,
|
|
129
|
+
collateralToken: sDai,
|
|
130
|
+
oracle: "0x6CAFE228eC0B0bC2D076577d56D35Fe704318f6d",
|
|
131
|
+
irm: adaptiveCurveIrm,
|
|
132
|
+
lltv: (0, viem_1.parseUnits)("96.5", 16),
|
|
133
|
+
}),
|
|
134
|
+
usdc_wbIB01: new blue_sdk_1.MarketParams({
|
|
135
|
+
// USDC(wbIB01, 96.5%, Chainlink, AdaptiveCurve)
|
|
136
|
+
loanToken: usdc,
|
|
137
|
+
collateralToken: wbIB01,
|
|
138
|
+
oracle: "0x6E8F5b2DF218443E87fe8aA9811E6956716dde88",
|
|
139
|
+
irm: adaptiveCurveIrm,
|
|
140
|
+
lltv: (0, viem_1.parseUnits)("96.5", 16),
|
|
141
|
+
}),
|
|
142
|
+
dai_sUsde: new blue_sdk_1.MarketParams({
|
|
143
|
+
// DAI(sUSDe, 86%, Exchange rate, AdaptiveCurve)
|
|
144
|
+
loanToken: dai,
|
|
145
|
+
collateralToken: "0x9D39A5DE30e57443BfF2A8307A4256c8797A3497",
|
|
146
|
+
oracle: "0x5D916980D5Ae1737a8330Bf24dF812b2911Aae25",
|
|
147
|
+
irm: adaptiveCurveIrm,
|
|
148
|
+
lltv: (0, viem_1.parseUnits)("86", 16),
|
|
149
|
+
}),
|
|
150
|
+
crvUsd_stkcvxcrvUSDTWBTCWETH: new blue_sdk_1.MarketParams({
|
|
151
|
+
loanToken: "0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E",
|
|
152
|
+
collateralToken: "0xb0Ce26C88e4e7DCa51968b6047f44646f5064278",
|
|
153
|
+
oracle: "0x077Af6c2D4A75D4145d141F9e9421864C3940CB3",
|
|
154
|
+
irm: adaptiveCurveIrm,
|
|
155
|
+
lltv: (0, viem_1.parseUnits)("86", 16),
|
|
156
|
+
}),
|
|
157
|
+
crvUsd_stkcvxcrvUSDCWBTCWETH: new blue_sdk_1.MarketParams({
|
|
158
|
+
loanToken: "0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E",
|
|
159
|
+
collateralToken: "0x0ea1a65A2c255f24Ee8D81eA6AaC54Decd9d269e",
|
|
160
|
+
oracle: "0xd2F7C3B2fC97cC7b6AfDd76D163394680EFc35b9",
|
|
161
|
+
irm: adaptiveCurveIrm,
|
|
162
|
+
lltv: (0, viem_1.parseUnits)("86", 16),
|
|
163
|
+
}),
|
|
164
|
+
crvUsd_stkcvxcrvCRVUSDTBTCWSTETH: new blue_sdk_1.MarketParams({
|
|
165
|
+
loanToken: "0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E",
|
|
166
|
+
collateralToken: "0x3ce8Ec9f3d89aD0A2DdbCC3FDB8991BD241Fc82E",
|
|
167
|
+
oracle: "0xa9f7900476F43C45Ebf56cEa669B9c960C176112",
|
|
168
|
+
irm: adaptiveCurveIrm,
|
|
169
|
+
lltv: (0, viem_1.parseUnits)("86", 16),
|
|
170
|
+
}),
|
|
171
|
+
crvUsd_stkcvxTryLSD: new blue_sdk_1.MarketParams({
|
|
172
|
+
loanToken: "0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E",
|
|
173
|
+
collateralToken: "0x6BA072F0d22806F2C52e9792AF47f2D59103BEBE",
|
|
174
|
+
oracle: "0x18B0d7311a97c5377445C80c768ab5201Bb27B5a",
|
|
175
|
+
irm: adaptiveCurveIrm,
|
|
176
|
+
lltv: (0, viem_1.parseUnits)("86", 16),
|
|
177
|
+
}),
|
|
178
|
+
crvUsd_stkcvxcrvUSDETHCRV: new blue_sdk_1.MarketParams({
|
|
179
|
+
loanToken: "0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E",
|
|
180
|
+
collateralToken: "0xAc904BAfBb5FB04Deb2b6198FdCEedE75a78Ce5a",
|
|
181
|
+
oracle: "0xad7e157815df05029125B568E39d5402550d60bb",
|
|
182
|
+
irm: adaptiveCurveIrm,
|
|
183
|
+
lltv: (0, viem_1.parseUnits)("86", 16),
|
|
184
|
+
}),
|
|
185
|
+
crvUsd_stkcvx2BTC: new blue_sdk_1.MarketParams({
|
|
186
|
+
loanToken: "0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E",
|
|
187
|
+
collateralToken: "0x385E12cf4040543Bc8C18e05C1298Be5B04f3f5e",
|
|
188
|
+
oracle: "0x20c4fA59f032bEC6de1905B7201CB88DFD968abA",
|
|
189
|
+
irm: adaptiveCurveIrm,
|
|
190
|
+
lltv: 860000000000000000n,
|
|
191
|
+
}),
|
|
192
|
+
usda_re7Eth: new blue_sdk_1.MarketParams({
|
|
193
|
+
loanToken: "0x0000206329b97DB379d5E1Bf586BbDB969C63274",
|
|
194
|
+
collateralToken: "0x78Fc2c2eD1A4cDb5402365934aE5648aDAd094d0",
|
|
195
|
+
oracle: "0x76052A2A28fDCB8124f4686C63C68355b142de3B",
|
|
196
|
+
irm: adaptiveCurveIrm,
|
|
197
|
+
lltv: (0, viem_1.parseUnits)("86", 16),
|
|
198
|
+
}),
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
const randomMarket = (params = {}) => new blue_sdk_1.MarketParams({
|
|
202
|
+
collateralToken: (0, test_1.randomAddress)(),
|
|
203
|
+
loanToken: (0, test_1.randomAddress)(),
|
|
204
|
+
oracle: (0, test_1.randomAddress)(),
|
|
205
|
+
irm: (0, test_1.randomAddress)(),
|
|
206
|
+
lltv: (0, viem_1.parseEther)("0.80"),
|
|
207
|
+
...params,
|
|
208
|
+
});
|
|
209
|
+
exports.randomMarket = randomMarket;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const withSimplePermit: {
|
|
2
|
+
readonly 1: Set<"0x6B175474E89094C44Da98b954EedeAC495271d0F" | "0x83F20F44975D03b1b09e64809B757c47f942BEeA" | "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0" | "0xf1C9acDc66974dFB6dEcB12aA385b9cD01190E38" | "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48">;
|
|
3
|
+
readonly 8453: Set<"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" | "0x59aaF835D34b1E3dF2170e4872B785f11E2a964b">;
|
|
4
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withSimplePermit = void 0;
|
|
4
|
+
const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
|
+
exports.withSimplePermit = {
|
|
6
|
+
[blue_sdk_1.ChainId.EthMainnet]: new Set([
|
|
7
|
+
blue_sdk_1.addresses[blue_sdk_1.ChainId.EthMainnet].wstEth,
|
|
8
|
+
blue_sdk_1.addresses[blue_sdk_1.ChainId.EthMainnet].sDai,
|
|
9
|
+
blue_sdk_1.addresses[blue_sdk_1.ChainId.EthMainnet].osEth,
|
|
10
|
+
blue_sdk_1.addresses[blue_sdk_1.ChainId.EthMainnet].usdc,
|
|
11
|
+
blue_sdk_1.addresses[blue_sdk_1.ChainId.EthMainnet].dai,
|
|
12
|
+
]),
|
|
13
|
+
[blue_sdk_1.ChainId.BaseMainnet]: new Set([
|
|
14
|
+
blue_sdk_1.addresses[blue_sdk_1.ChainId.BaseMainnet].usdc,
|
|
15
|
+
blue_sdk_1.addresses[blue_sdk_1.ChainId.BaseMainnet].verUsdc,
|
|
16
|
+
]),
|
|
17
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type IVaultConfig, VaultConfig } from "@morpho-org/blue-sdk";
|
|
2
|
+
export declare const vaults: {
|
|
3
|
+
readonly 1: {
|
|
4
|
+
readonly steakUsdc: VaultConfig;
|
|
5
|
+
readonly steakEth: VaultConfig;
|
|
6
|
+
readonly bbUsdc: VaultConfig;
|
|
7
|
+
readonly bbEth: VaultConfig;
|
|
8
|
+
readonly bbUsdt: VaultConfig;
|
|
9
|
+
readonly re7Weth: VaultConfig;
|
|
10
|
+
readonly gDai: VaultConfig;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export declare const randomVault: (config?: Partial<IVaultConfig>) => VaultConfig;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.randomVault = exports.vaults = void 0;
|
|
4
|
+
const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
|
+
const test_1 = require("@morpho-org/test");
|
|
6
|
+
const { wNative, usdc, dai } = blue_sdk_1.addresses[blue_sdk_1.ChainId.EthMainnet];
|
|
7
|
+
exports.vaults = {
|
|
8
|
+
[blue_sdk_1.ChainId.EthMainnet]: {
|
|
9
|
+
steakUsdc: new blue_sdk_1.VaultConfig({
|
|
10
|
+
address: "0xBEEF01735c132Ada46AA9aA4c54623cAA92A64CB",
|
|
11
|
+
decimalsOffset: 12n,
|
|
12
|
+
symbol: "steakUSDC",
|
|
13
|
+
name: "Steakhouse USDC",
|
|
14
|
+
asset: usdc,
|
|
15
|
+
}, blue_sdk_1.ChainId.EthMainnet),
|
|
16
|
+
steakEth: new blue_sdk_1.VaultConfig({
|
|
17
|
+
address: "0xBEEf050ecd6a16c4e7bfFbB52Ebba7846C4b8cD4",
|
|
18
|
+
asset: wNative,
|
|
19
|
+
name: "Steakhouse ETH",
|
|
20
|
+
decimalsOffset: 0,
|
|
21
|
+
symbol: "steakETH",
|
|
22
|
+
}),
|
|
23
|
+
bbUsdc: new blue_sdk_1.VaultConfig({
|
|
24
|
+
address: "0x186514400e52270cef3D80e1c6F8d10A75d47344",
|
|
25
|
+
decimalsOffset: 12n,
|
|
26
|
+
symbol: "bbUSDC",
|
|
27
|
+
name: "BlockAnalytica USDC",
|
|
28
|
+
asset: wNative,
|
|
29
|
+
}, blue_sdk_1.ChainId.EthMainnet),
|
|
30
|
+
bbEth: new blue_sdk_1.VaultConfig({
|
|
31
|
+
address: "0x38989BBA00BDF8181F4082995b3DEAe96163aC5D",
|
|
32
|
+
decimalsOffset: 0n,
|
|
33
|
+
symbol: "bbETH",
|
|
34
|
+
name: "BlockAnalytica ETH",
|
|
35
|
+
asset: wNative,
|
|
36
|
+
}, blue_sdk_1.ChainId.EthMainnet),
|
|
37
|
+
bbUsdt: new blue_sdk_1.VaultConfig({
|
|
38
|
+
address: "0x2C25f6C25770fFEC5959D34B94Bf898865e5D6b1",
|
|
39
|
+
decimalsOffset: 12n,
|
|
40
|
+
symbol: "bbUSDT",
|
|
41
|
+
name: "BlockAnalytica USDT",
|
|
42
|
+
asset: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
|
43
|
+
}, blue_sdk_1.ChainId.EthMainnet),
|
|
44
|
+
re7Weth: new blue_sdk_1.VaultConfig({
|
|
45
|
+
address: "0x78Fc2c2eD1A4cDb5402365934aE5648aDAd094d0",
|
|
46
|
+
decimalsOffset: 0n,
|
|
47
|
+
symbol: "re7WETH",
|
|
48
|
+
name: "Re7 WETH",
|
|
49
|
+
asset: wNative,
|
|
50
|
+
}, blue_sdk_1.ChainId.EthMainnet),
|
|
51
|
+
gDai: new blue_sdk_1.VaultConfig({
|
|
52
|
+
address: "0x500331c9fF24D9d11aee6B07734Aa72343EA74a5",
|
|
53
|
+
decimalsOffset: 0n,
|
|
54
|
+
symbol: "gDAI",
|
|
55
|
+
name: "Gauntlet DAI Core",
|
|
56
|
+
asset: dai,
|
|
57
|
+
}, blue_sdk_1.ChainId.EthMainnet),
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
const randomVault = (config = {}) => new blue_sdk_1.VaultConfig({
|
|
61
|
+
asset: (0, test_1.randomAddress)(),
|
|
62
|
+
decimalsOffset: 0n,
|
|
63
|
+
symbol: "TEST",
|
|
64
|
+
name: "Test vault",
|
|
65
|
+
address: (0, test_1.randomAddress)(),
|
|
66
|
+
...config,
|
|
67
|
+
});
|
|
68
|
+
exports.randomVault = randomVault;
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -14,7 +14,4 @@ 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
|
-
require("./chai");
|
|
18
|
-
__exportStar(require("./asserts"), exports);
|
|
19
17
|
__exportStar(require("./fixtures"), exports);
|
|
20
|
-
__exportStar(require("./hardhat"), exports);
|
package/package.json
CHANGED
|
@@ -1,49 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morpho-org/morpho-test",
|
|
3
|
-
"
|
|
3
|
+
"description": "Framework-agnostic extension of `@morpho-org/blue-sdk` that exports test fixtures useful for E2E tests on forks.",
|
|
4
|
+
"version": "2.0.1",
|
|
5
|
+
"author": "Morpho Association <contact@morpho.org>",
|
|
6
|
+
"contributors": [
|
|
7
|
+
"Rubilmax <rmilon@gmail.com>"
|
|
8
|
+
],
|
|
9
|
+
"repository": "github:morpho-org/sdks",
|
|
10
|
+
"homepage": "https://github.com/morpho-org/sdks",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/morpho-org/sdks/issues",
|
|
13
|
+
"email": "contact@morpho.org"
|
|
14
|
+
},
|
|
4
15
|
"main": "lib/index.js",
|
|
5
16
|
"files": [
|
|
6
17
|
"lib"
|
|
7
18
|
],
|
|
8
|
-
"author": "Morpho Association <contact@morpho.org>",
|
|
9
19
|
"license": "MIT",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"viem": "^2.21.10",
|
|
22
|
+
"@morpho-org/blue-sdk": "^2.1.2",
|
|
23
|
+
"@morpho-org/morpho-ts": "^2.0.0",
|
|
24
|
+
"@morpho-org/test": "^2.0.2"
|
|
14
25
|
},
|
|
15
26
|
"devDependencies": {
|
|
16
|
-
"@
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"@
|
|
20
|
-
"@
|
|
21
|
-
"@
|
|
22
|
-
"@types/node": "^22.1.0",
|
|
23
|
-
"@types/sinon": "^17.0.3",
|
|
24
|
-
"@types/sinon-chai": "^3.2.12",
|
|
25
|
-
"chai": "^4.5.0",
|
|
26
|
-
"chai-as-promised": "^7.1.2",
|
|
27
|
-
"dotenv": "^16.3.1",
|
|
28
|
-
"ethers": "^6.13.2",
|
|
29
|
-
"hardhat": "^2.20.1",
|
|
30
|
-
"mocha": "^10.4.0",
|
|
31
|
-
"sinon": "^19.0.2",
|
|
32
|
-
"sinon-chai": "^3.7.0",
|
|
33
|
-
"typescript": "^5.4.5"
|
|
34
|
-
},
|
|
35
|
-
"peerDependencies": {
|
|
36
|
-
"@nomicfoundation/hardhat-ethers": "^3.0.0",
|
|
37
|
-
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
|
|
38
|
-
"chai": "^4.3.0",
|
|
39
|
-
"chai-as-promised": "^7.1.2",
|
|
40
|
-
"ethers": "^6.0.0",
|
|
41
|
-
"hardhat": "^2.20.0",
|
|
42
|
-
"sinon": "^19.0.2",
|
|
43
|
-
"sinon-chai": "^3.7.0"
|
|
27
|
+
"@types/node": "^22.10.1",
|
|
28
|
+
"typescript": "^5.7.2",
|
|
29
|
+
"viem": "^2.22.2",
|
|
30
|
+
"@morpho-org/blue-sdk": "^2.1.2",
|
|
31
|
+
"@morpho-org/morpho-ts": "^2.0.0",
|
|
32
|
+
"@morpho-org/test": "^2.0.2"
|
|
44
33
|
},
|
|
45
|
-
"
|
|
46
|
-
"
|
|
34
|
+
"scripts": {
|
|
35
|
+
"prepublish": "$npm_execpath build",
|
|
36
|
+
"build": "tsc"
|
|
47
37
|
},
|
|
48
|
-
"
|
|
49
|
-
}
|
|
38
|
+
"types": "lib/index.d.ts"
|
|
39
|
+
}
|
package/lib/asserts.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare const assertApproxEqAbs: (actual: bigint, expected: bigint, tolerance?: bigint, message?: string) => Chai.Assertion;
|
|
2
|
-
export declare const assertApproxEqRel: (actual: bigint, expected: bigint, tolerance?: bigint, message?: string) => Chai.Assertion;
|
|
3
|
-
export declare const assertEq: (actual: bigint, expected: bigint) => Chai.Assertion;
|
package/lib/asserts.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertEq = exports.assertApproxEqRel = exports.assertApproxEqAbs = void 0;
|
|
4
|
-
const chai_1 = require("chai");
|
|
5
|
-
const ethers_1 = require("ethers");
|
|
6
|
-
const assertApproxEqAbs = (actual, expected, tolerance = 0n, message) => (0, chai_1.expect)(actual >= expected ? actual - expected : expected - actual).to.be.lessThanOrEqual(
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
tolerance, message);
|
|
9
|
-
exports.assertApproxEqAbs = assertApproxEqAbs;
|
|
10
|
-
const assertApproxEqRel = (actual, expected, tolerance = 0n, message) => (0, exports.assertApproxEqAbs)(actual, expected, (expected * tolerance) / (0, ethers_1.parseEther)("1"), message);
|
|
11
|
-
exports.assertApproxEqRel = assertApproxEqRel;
|
|
12
|
-
const assertEq = (actual, expected) => (0, exports.assertApproxEqAbs)(actual, expected, 0n);
|
|
13
|
-
exports.assertEq = assertEq;
|
package/lib/chai.d.ts
DELETED
package/lib/chai.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const chai_1 = __importStar(require("chai"));
|
|
30
|
-
const chai_as_promised_1 = __importDefault(require("chai-as-promised"));
|
|
31
|
-
const sinon_chai_1 = __importDefault(require("sinon-chai"));
|
|
32
|
-
chai_1.default.use(sinon_chai_1.default);
|
|
33
|
-
chai_1.default.use(chai_as_promised_1.default);
|
|
34
|
-
// @ts-ignore
|
|
35
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#use_within_json
|
|
36
|
-
BigInt.prototype.toJSON = function () {
|
|
37
|
-
return this.toString();
|
|
38
|
-
};
|
|
39
|
-
const ANY = new String("[any value]");
|
|
40
|
-
const ANYTHING = new String("[any defined value]");
|
|
41
|
-
const NUMBER = new String("[any number]");
|
|
42
|
-
const STRING = new String("[any string]");
|
|
43
|
-
const BIGINT = new String("[any bigint]");
|
|
44
|
-
Object.defineProperty(chai_1.default.expect, "any", {
|
|
45
|
-
get: function () {
|
|
46
|
-
return ANY;
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
Object.defineProperty(chai_1.default.expect, "anything", {
|
|
50
|
-
get: function () {
|
|
51
|
-
return ANYTHING;
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
Object.defineProperty(chai_1.default.expect, "number", {
|
|
55
|
-
get: function () {
|
|
56
|
-
return NUMBER;
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
Object.defineProperty(chai_1.default.expect, "string", {
|
|
60
|
-
get: function () {
|
|
61
|
-
return STRING;
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
Object.defineProperty(chai_1.default.expect, "bigint", {
|
|
65
|
-
get: function () {
|
|
66
|
-
return BIGINT;
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
function customEqual(obj1, obj2) {
|
|
70
|
-
if (Object(obj1) !== obj1 || Object(obj2) !== obj2) {
|
|
71
|
-
return obj1 === obj2;
|
|
72
|
-
}
|
|
73
|
-
const keys1 = Object.keys(obj1);
|
|
74
|
-
const keys2 = Object.keys(obj2);
|
|
75
|
-
if (keys1.length !== keys2.length) {
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
for (let key of keys1) {
|
|
79
|
-
switch (obj2[key]) {
|
|
80
|
-
case ANY: {
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
case ANYTHING: {
|
|
84
|
-
if (obj1[key] == undefined)
|
|
85
|
-
return false;
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
case STRING: {
|
|
89
|
-
if (typeof obj1[key] !== "string")
|
|
90
|
-
return false;
|
|
91
|
-
break;
|
|
92
|
-
}
|
|
93
|
-
case NUMBER: {
|
|
94
|
-
if (typeof obj1[key] !== "number")
|
|
95
|
-
return false;
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
case BIGINT: {
|
|
99
|
-
if (typeof obj1[key] !== "bigint")
|
|
100
|
-
return false;
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
default: {
|
|
104
|
-
if (!customEqual(obj1[key], obj2[key]))
|
|
105
|
-
return false;
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
return true;
|
|
111
|
-
}
|
|
112
|
-
chai_1.Assertion.overwriteMethod("eql", function (_super) {
|
|
113
|
-
return function (arg) {
|
|
114
|
-
if (typeof arg === "object" && typeof this._obj === "object") {
|
|
115
|
-
const result = customEqual(this._obj, arg);
|
|
116
|
-
this.assert(result, "expected #{this} to deeply equal #{exp}", "expected #{this} not to deeply equal #{exp}", arg, this._obj);
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
_super.apply(this, arguments);
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
});
|
package/lib/fixtures.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const createRandomAddress: () => string;
|
package/lib/fixtures.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createRandomAddress = void 0;
|
|
4
|
-
const ethers_1 = require("ethers");
|
|
5
|
-
const createRandomAddress = () => (0, ethers_1.getAddress)("0x" +
|
|
6
|
-
new Array(40)
|
|
7
|
-
.fill(0)
|
|
8
|
-
.map(() => Math.floor(Math.random() * 16).toString(16))
|
|
9
|
-
.join(""));
|
|
10
|
-
exports.createRandomAddress = createRandomAddress;
|
package/lib/hardhat.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Block } from "ethers";
|
|
2
|
-
import sinon from "sinon";
|
|
3
|
-
export declare const mine: (blocks?: number, options?: {
|
|
4
|
-
interval?: number;
|
|
5
|
-
}, emit?: boolean) => Promise<void>;
|
|
6
|
-
export declare const reset: ({ url, blockNumber, }?: {
|
|
7
|
-
url?: string | null;
|
|
8
|
-
blockNumber?: number;
|
|
9
|
-
}) => Promise<void>;
|
|
10
|
-
export declare const resetAfterEach: (forking?: {
|
|
11
|
-
url?: string | null;
|
|
12
|
-
blockNumber?: number;
|
|
13
|
-
}) => void;
|
|
14
|
-
export declare const setUp: (onBefore?: (block: Block) => void) => {
|
|
15
|
-
next: sinon.SinonSpy<any[], any>;
|
|
16
|
-
error: sinon.SinonSpy<any[], any>;
|
|
17
|
-
};
|
package/lib/hardhat.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.setUp = exports.resetAfterEach = exports.reset = exports.mine = void 0;
|
|
7
|
-
const sinon_1 = __importDefault(require("sinon"));
|
|
8
|
-
const hardhat_network_helpers_1 = require("@nomicfoundation/hardhat-network-helpers");
|
|
9
|
-
try {
|
|
10
|
-
import("@nomicfoundation/hardhat-ethers");
|
|
11
|
-
const { ethers } = require("hardhat");
|
|
12
|
-
Object.defineProperty(ethers.provider, "_networkName", {
|
|
13
|
-
value: "mainnet",
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
catch { }
|
|
17
|
-
const mine = async (blocks = 1, options = {}, emit = true) => {
|
|
18
|
-
const { ethers } = require("hardhat");
|
|
19
|
-
await (0, hardhat_network_helpers_1.mine)(blocks, options);
|
|
20
|
-
if (emit)
|
|
21
|
-
await ethers.provider.emit("block", await ethers.provider.getBlockNumber());
|
|
22
|
-
};
|
|
23
|
-
exports.mine = mine;
|
|
24
|
-
const reset = ({ url, blockNumber, } = {}) => {
|
|
25
|
-
if (url === null)
|
|
26
|
-
return (0, hardhat_network_helpers_1.reset)();
|
|
27
|
-
const { config } = require("hardhat");
|
|
28
|
-
url ??= config.networks.hardhat.forking?.url;
|
|
29
|
-
blockNumber ??= config.networks.hardhat.forking?.blockNumber;
|
|
30
|
-
return (0, hardhat_network_helpers_1.reset)(url, blockNumber);
|
|
31
|
-
};
|
|
32
|
-
exports.reset = reset;
|
|
33
|
-
const resetAfterEach = (forking) => {
|
|
34
|
-
afterEach(async () => {
|
|
35
|
-
await (0, exports.reset)(forking);
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
exports.resetAfterEach = resetAfterEach;
|
|
39
|
-
const setUp = (onBefore) => {
|
|
40
|
-
const { network } = require("hardhat");
|
|
41
|
-
let snapshot;
|
|
42
|
-
before(async () => {
|
|
43
|
-
const blockNumber = await network.provider.send("eth_blockNumber");
|
|
44
|
-
const block = await network.provider.send("eth_getBlockByNumber", [
|
|
45
|
-
blockNumber,
|
|
46
|
-
false,
|
|
47
|
-
]);
|
|
48
|
-
await onBefore?.(block);
|
|
49
|
-
snapshot = await (0, hardhat_network_helpers_1.takeSnapshot)();
|
|
50
|
-
});
|
|
51
|
-
const dataObserver = { next: sinon_1.default.spy(), error: sinon_1.default.spy() };
|
|
52
|
-
afterEach(async () => {
|
|
53
|
-
await snapshot.restore();
|
|
54
|
-
dataObserver.next.resetHistory();
|
|
55
|
-
dataObserver.error.resetHistory();
|
|
56
|
-
});
|
|
57
|
-
after(async () => {
|
|
58
|
-
await (0, exports.reset)();
|
|
59
|
-
});
|
|
60
|
-
return dataObserver;
|
|
61
|
-
};
|
|
62
|
-
exports.setUp = setUp;
|