@mento-protocol/mento-sdk 3.1.0 → 3.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 +22 -1
- package/package.json +16 -16
package/README.md
CHANGED
|
@@ -137,19 +137,34 @@ const balance = await mento.liquidity.getLPTokenBalance(poolAddress, owner)
|
|
|
137
137
|
```typescript
|
|
138
138
|
import { parseUnits } from 'viem'
|
|
139
139
|
|
|
140
|
+
// Find a safe ownerIndex for the account that will submit the transaction
|
|
141
|
+
const ownerIndex = await mento.borrow.findNextAvailableOwnerIndex('USDm', ownerAddress, ownerAddress)
|
|
142
|
+
|
|
140
143
|
// Open a trove (borrow against collateral)
|
|
141
144
|
const openTx = await mento.borrow.buildOpenTroveTransaction('USDm', {
|
|
142
145
|
owner: ownerAddress,
|
|
143
|
-
ownerIndex
|
|
146
|
+
ownerIndex,
|
|
144
147
|
collAmount: parseUnits('10', 18),
|
|
145
148
|
boldAmount: parseUnits('1000', 18),
|
|
146
149
|
annualInterestRate: parseUnits('0.05', 18), // 5%
|
|
147
150
|
maxUpfrontFee: parseUnits('100', 18),
|
|
148
151
|
})
|
|
149
152
|
|
|
153
|
+
// For smart accounts, pass the smart account address as the third argument above.
|
|
154
|
+
|
|
150
155
|
// Get trove data
|
|
151
156
|
const trove = await mento.borrow.getTroveData('USDm', troveId)
|
|
152
157
|
|
|
158
|
+
// Get troves currently owned by an address via the Trove NFT
|
|
159
|
+
const troves = await mento.borrow.getUserTroves('USDm', ownerAddress)
|
|
160
|
+
|
|
161
|
+
// Zombie troves are still-open troves whose debt fell below the branch minimum debt,
|
|
162
|
+
// typically after redemption. They can still hold collateral, and may even have 0 debt.
|
|
163
|
+
if (trove.status === 'zombie') {
|
|
164
|
+
// Reactivate by adjusting the zombie trove, or close it to withdraw remaining collateral.
|
|
165
|
+
const closeTx = await mento.borrow.buildCloseTroveTransaction('USDm', trove.troveId)
|
|
166
|
+
}
|
|
167
|
+
|
|
153
168
|
// Get system parameters
|
|
154
169
|
const params = await mento.borrow.getSystemParams('USDm')
|
|
155
170
|
|
|
@@ -161,6 +176,12 @@ const fee = await mento.borrow.predictOpenTroveUpfrontFee(
|
|
|
161
176
|
)
|
|
162
177
|
```
|
|
163
178
|
|
|
179
|
+
Notes:
|
|
180
|
+
|
|
181
|
+
- `getUserTroves()` reflects current Trove NFT ownership. It includes zombie troves still owned by the address, even though zombie troves are removed from `SortedTroves`.
|
|
182
|
+
- `status === 'zombie'` does not mean liquidated. Zombie troves can still exist with collateral remaining on-chain, including the case where `debt === 0`.
|
|
183
|
+
- Use `buildClaimCollateralTransaction()` for collateral surplus after liquidation. For zombie troves with remaining collateral, use `buildCloseTroveTransaction()` to withdraw it, or `buildAdjustZombieTroveTransaction()` to reactivate the trove.
|
|
184
|
+
|
|
164
185
|
## Supported Chains
|
|
165
186
|
|
|
166
187
|
| Chain | Chain ID | Constant |
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mento-protocol/mento-sdk",
|
|
3
3
|
"description": "Official SDK for interacting with the Mento Protocol",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.2.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Mento Labs",
|
|
7
7
|
"keywords": [
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"lint": "eslint src/**/*.ts tests/**/*.ts",
|
|
46
46
|
"prettier": "prettier --config ./.prettierrc.json --write **/*.{json,md,js,ts,yml}",
|
|
47
47
|
"test": "jest --verbose",
|
|
48
|
-
"test:unit": "jest --verbose --
|
|
49
|
-
"test:integration": "jest --verbose --
|
|
48
|
+
"test:unit": "jest --verbose --testPathPatterns='tests/unit'",
|
|
49
|
+
"test:integration": "jest --verbose --testPathPatterns='tests/integration'",
|
|
50
50
|
"coverage": "jest --coverage",
|
|
51
51
|
"size": "size-limit",
|
|
52
52
|
"cacheRoutes": "ts-node scripts/cacheRoutes/index.ts",
|
|
@@ -57,26 +57,26 @@
|
|
|
57
57
|
"pnpm": ">=9"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@jest/types": "^
|
|
61
|
-
"size-limit": "^
|
|
62
|
-
"@size-limit/preset-small-lib": "^
|
|
60
|
+
"@jest/types": "^30.2.0",
|
|
61
|
+
"size-limit": "^12.0.0",
|
|
62
|
+
"@size-limit/preset-small-lib": "^12.0.0",
|
|
63
63
|
"@tsconfig/recommended": "^1.0.1",
|
|
64
|
-
"@types/jest": "^
|
|
65
|
-
"@types/node": "^
|
|
64
|
+
"@types/jest": "^30.0.0",
|
|
65
|
+
"@types/node": "^25.3.3",
|
|
66
66
|
"@types/yargs-parser": "^21.0.3",
|
|
67
|
-
"@eslint/js": "^
|
|
68
|
-
"eslint": "^
|
|
67
|
+
"@eslint/js": "^10.0.1",
|
|
68
|
+
"eslint": "^10.0.2",
|
|
69
69
|
"eslint-config-prettier": "^10.0.0",
|
|
70
70
|
"typescript-eslint": "^8.0.0",
|
|
71
|
-
"husky": "^
|
|
72
|
-
"jest": "^
|
|
73
|
-
"prettier": "^
|
|
71
|
+
"husky": "^9.1.7",
|
|
72
|
+
"jest": "^30.2.0",
|
|
73
|
+
"prettier": "^3.8.1",
|
|
74
74
|
"ts-jest": "^29.0.5",
|
|
75
75
|
"ts-node": "^10.9.1",
|
|
76
76
|
"tsconfig-paths": "^4.2.0",
|
|
77
|
-
"typescript": "5.
|
|
78
|
-
"yargs-parser": "^
|
|
79
|
-
"dotenv": "^
|
|
77
|
+
"typescript": "5.9.3",
|
|
78
|
+
"yargs-parser": "^22.0.0",
|
|
79
|
+
"dotenv": "^17.3.1"
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
82
|
"viem": "^2.21.44"
|