@morpho-org/blue-sdk 1.2.1 → 1.2.3
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 +48 -40
- package/lib/addresses.d.ts +1 -0
- package/lib/addresses.js +1 -0
- package/lib/helpers/format/format.test.js +1 -3
- package/lib/helpers/locale.js +1 -1
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[![npm package][npm-img]][npm-url]
|
|
4
4
|
[![Downloads][downloads-img]][downloads-url]
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
Framework-agnostic SDK foundational to Morpho Blue's offchain ecosystem, useful to fetch and interact with Morpho Blue and MetaMorpho.
|
|
7
7
|
|
|
8
8
|
## Install
|
|
9
9
|
|
|
@@ -19,77 +19,85 @@ yarn add @morpho-org/blue-sdk
|
|
|
19
19
|
|
|
20
20
|
## Getting Started
|
|
21
21
|
|
|
22
|
-
###
|
|
22
|
+
### Instance of the immutable configuration of a specific market
|
|
23
23
|
|
|
24
|
-
Leverage the [`MarketConfig`](./src/market/MarketConfig.ts) class to
|
|
24
|
+
Leverage the [`MarketConfig`](./src/market/MarketConfig.ts) class to manipulate a given market's immutable configuration:
|
|
25
25
|
|
|
26
26
|
```typescript
|
|
27
27
|
import { MarketConfig } from "@morpho-org/blue-sdk";
|
|
28
28
|
|
|
29
|
-
const config = MarketConfig
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
const config = new MarketConfig({
|
|
30
|
+
loanToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
|
|
31
|
+
collateralToken: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0", // wstETH
|
|
32
|
+
oracle: "0x2a01EB9496094dA03c4E364Def50f5aD1280AD72",
|
|
33
|
+
irm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC", // AdaptiveCurveIrm
|
|
34
|
+
lltv: 94_5000000000000000n, // 94.5%
|
|
35
|
+
});
|
|
33
36
|
|
|
34
|
-
|
|
37
|
+
config.liquidationIncentiveFactor; // e.g. 1_090000000000000000n (109%).
|
|
35
38
|
```
|
|
36
39
|
|
|
37
|
-
###
|
|
40
|
+
### Instance of a specific market
|
|
38
41
|
|
|
39
|
-
Leverage the [`Market`](./src/market/Market.ts) class to
|
|
42
|
+
Leverage the [`Market`](./src/market/Market.ts) class to manipulate a specific market:
|
|
40
43
|
|
|
41
44
|
```typescript
|
|
42
45
|
import { Market } from "@morpho-org/blue-sdk";
|
|
43
46
|
import { Time } from "@morpho-org/morpho-ts";
|
|
44
47
|
|
|
45
|
-
const market = Market
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
//
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
const market = new Market({
|
|
49
|
+
config: new MarketConfig({
|
|
50
|
+
loanToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
|
|
51
|
+
collateralToken: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0", // wstETH
|
|
52
|
+
oracle: "0x2a01EB9496094dA03c4E364Def50f5aD1280AD72",
|
|
53
|
+
irm: "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC", // AdaptiveCurveIrm
|
|
54
|
+
lltv: 94_5000000000000000n, // 94.5%
|
|
55
|
+
}),
|
|
56
|
+
totalSupplyAssets: 1000_000000000000000000n,
|
|
57
|
+
totalBorrowAssets: 920_000000000000000000n,
|
|
58
|
+
totalSupplyShares: 1000_000000000000000000000000n,
|
|
59
|
+
totalBorrowShares: 920_000000000000000000000000n,
|
|
60
|
+
lastUpdate: 1721000000n,
|
|
61
|
+
fee: 0n,
|
|
62
|
+
price: 1_100000000000000000000000000000000000n,
|
|
63
|
+
rateAtTarget: 94850992095n
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
market.utilization; // e.g. 92_0000000000000000n (92%).
|
|
67
|
+
market.liquidity; // e.g. 80_000000000000000000n (in loan assets).
|
|
68
|
+
market.apyAtTarget; // e.g. 3_0000000000000000n (3%).
|
|
59
69
|
|
|
60
70
|
const accruedMarket = market.accrueInterest(Time.timestamp()); // Accrue interest to the latest's timestamp.
|
|
61
71
|
|
|
62
72
|
accruedMarket.toSupplyAssets(shares); // Convert supply shares to assets.
|
|
63
73
|
```
|
|
64
74
|
|
|
65
|
-
###
|
|
75
|
+
### Instance of the position of a specific user on a specific market
|
|
66
76
|
|
|
67
|
-
Leverage the [`Position`](./src/position/Position.ts) class to
|
|
77
|
+
Leverage the [`Position`](./src/position/Position.ts) class to manipulate the position of a user on a given market:
|
|
68
78
|
|
|
69
79
|
```typescript
|
|
70
80
|
import { Position } from "@morpho-org/blue-sdk";
|
|
71
81
|
import { Time } from "@morpho-org/morpho-ts";
|
|
72
82
|
|
|
73
|
-
const position = AccrualPosition
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
83
|
+
const position = new AccrualPosition(
|
|
84
|
+
new Position({
|
|
85
|
+
user,
|
|
86
|
+
marketId: market.id,
|
|
87
|
+
supplyShares: 0n,
|
|
88
|
+
borrowShares: 20_000000000000000000000000n,
|
|
89
|
+
collateral: 27_000000000000000000n
|
|
90
|
+
}),
|
|
91
|
+
market
|
|
77
92
|
);
|
|
78
93
|
|
|
79
|
-
//
|
|
80
|
-
// const position = AccrualPosition.fetchFromConfig(
|
|
81
|
-
// "0x7f65e7326F22963e2039734dDfF61958D5d284Ca",
|
|
82
|
-
// config,
|
|
83
|
-
// provider // Ethers provider.
|
|
84
|
-
// );
|
|
85
|
-
|
|
86
|
-
position.borrowAssets; // e.g. 23_000000n (in loan assets).
|
|
94
|
+
position.borrowAssets; // e.g. 20_000000000000000000n (in loan assets).
|
|
87
95
|
position.isHealthy; // e.g. true.
|
|
88
|
-
position.maxBorrowableAssets; // e.g.
|
|
96
|
+
position.maxBorrowableAssets; // e.g. 2100_000000000000000000n (in loan assets).
|
|
89
97
|
|
|
90
98
|
const accruedPosition = position.accrueInterest(Time.timestamp()); // Accrue interest to the latest's timestamp.
|
|
91
99
|
|
|
92
|
-
position.borrowAssets; // e.g.
|
|
100
|
+
position.borrowAssets; // e.g. 20_400000000000000000n (in loan assets).
|
|
93
101
|
```
|
|
94
102
|
|
|
95
103
|
[downloads-img]: https://img.shields.io/npm/dt/@morpho-org/blue-sdk
|
package/lib/addresses.d.ts
CHANGED
|
@@ -78,6 +78,7 @@ export declare const addresses: {
|
|
|
78
78
|
readonly adaptiveCurveIrm: "0x46415998764C29aB2a25CbeA6254146D50D22687";
|
|
79
79
|
readonly publicAllocator: "0xA090dD1a701408Df1d4d0B85b716c87565f90467";
|
|
80
80
|
readonly aaveV3Bundler: "0xcAe2929baBc60Be34818EaA5F40bF69265677108";
|
|
81
|
+
readonly compoundV3Bundler: "0x1f8076e2EB6f10b12e6886f30D4909A91969F7dA";
|
|
81
82
|
readonly usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
82
83
|
readonly cbEth: "0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22";
|
|
83
84
|
readonly verUsdc: "0x59aaF835D34b1E3dF2170e4872B785f11E2a964b";
|
package/lib/addresses.js
CHANGED
|
@@ -88,6 +88,7 @@ exports.addresses = {
|
|
|
88
88
|
adaptiveCurveIrm: "0x46415998764C29aB2a25CbeA6254146D50D22687",
|
|
89
89
|
publicAllocator: "0xA090dD1a701408Df1d4d0B85b716c87565f90467",
|
|
90
90
|
aaveV3Bundler: "0xcAe2929baBc60Be34818EaA5F40bF69265677108",
|
|
91
|
+
compoundV3Bundler: "0x1f8076e2EB6f10b12e6886f30D4909A91969F7dA",
|
|
91
92
|
/* Tokens */
|
|
92
93
|
usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
93
94
|
cbEth: "0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22",
|
|
@@ -137,9 +137,7 @@ describe("format", () => {
|
|
|
137
137
|
expect(format_1.format.short
|
|
138
138
|
.smallValuesWithCommas()
|
|
139
139
|
.locale("fr-FR")
|
|
140
|
-
.of(bigint, decimals + 1)
|
|
141
|
-
// the correct space in fr-FR is narrow no-break space (U+202F)
|
|
142
|
-
).toEqual("1\u202F234,56789");
|
|
140
|
+
.of(bigint, decimals + 1)).toEqual("1\u202F234,56789");
|
|
143
141
|
});
|
|
144
142
|
});
|
|
145
143
|
});
|
package/lib/helpers/locale.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morpho-org/blue-sdk",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"author": "Morpho Association <contact@morpho.org>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -13,14 +13,15 @@
|
|
|
13
13
|
"test": "jest"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@morpho-org/morpho-ts": "1.0.
|
|
16
|
+
"@morpho-org/morpho-ts": "1.0.6",
|
|
17
17
|
"keccak256": "^1.0.6"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@morpho-org/morpho-test": "1.0.
|
|
20
|
+
"@morpho-org/morpho-test": "1.0.6",
|
|
21
21
|
"@types/jest": "^29.5.12",
|
|
22
|
-
"
|
|
23
|
-
"
|
|
22
|
+
"@types/node": "^20.12.8",
|
|
23
|
+
"jest": "^29.7.0",
|
|
24
|
+
"ts-jest": "^29.2.2",
|
|
24
25
|
"typescript": "^5.4.5"
|
|
25
26
|
},
|
|
26
27
|
"publishConfig": {
|
|
@@ -45,5 +46,5 @@
|
|
|
45
46
|
],
|
|
46
47
|
"preset": "ts-jest"
|
|
47
48
|
},
|
|
48
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "0c32ea00c8b60b6f408b6d05329261ce4eb3f94c"
|
|
49
50
|
}
|