@varla/sdk 1.2.1 → 1.10.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 +42 -0
- package/dist/abi/full/VarlaCore.d.ts +15 -0
- package/dist/abi/full/VarlaCore.d.ts.map +1 -1
- package/dist/abi/full/VarlaCore.js +19 -0
- package/dist/generated.d.ts +15 -0
- package/dist/generated.d.ts.map +1 -1
- package/dist/views/accessManager.d.ts.map +1 -1
- package/dist/views/accessManager.js +7 -0
- package/dist/views/adapters.d.ts.map +1 -1
- package/dist/views/adapters.js +1 -0
- package/dist/views/admin.d.ts.map +1 -1
- package/dist/views/admin.js +3 -0
- package/dist/views/core.d.ts +184 -0
- package/dist/views/core.d.ts.map +1 -1
- package/dist/views/core.js +220 -0
- package/dist/views/liquidators.d.ts.map +1 -1
- package/dist/views/liquidators.js +3 -0
- package/dist/views/oracle.d.ts +154 -1
- package/dist/views/oracle.d.ts.map +1 -1
- package/dist/views/oracle.js +136 -0
- package/dist/views/pool.d.ts +46 -0
- package/dist/views/pool.d.ts.map +1 -1
- package/dist/views/pool.js +33 -0
- package/dist/views/system.d.ts.map +1 -1
- package/dist/views/system.js +1 -0
- package/package.json +17 -1
package/dist/views/oracle.js
CHANGED
|
@@ -8,6 +8,7 @@ import { abis } from "../generated.js";
|
|
|
8
8
|
* - `getConfiguredPositionsCount()`
|
|
9
9
|
* - `getConfiguredPositionAt(i)` via multicall
|
|
10
10
|
*/
|
|
11
|
+
// wraps: VarlaOracle.getConfiguredPositionsCount,VarlaOracle.getConfiguredPositionAt
|
|
11
12
|
export async function readOracleRegistry(params) {
|
|
12
13
|
const { oracle, client } = params;
|
|
13
14
|
const chunkSize = params.chunkSize ?? 256;
|
|
@@ -46,6 +47,7 @@ export async function readOracleRegistry(params) {
|
|
|
46
47
|
* - frontends that want lazy loading
|
|
47
48
|
* - indexers that want checkpointing
|
|
48
49
|
*/
|
|
50
|
+
// wraps: VarlaOracle.getConfiguredPositionsCount,VarlaOracle.getConfiguredPositionAt
|
|
49
51
|
export async function readOracleRegistryPage(params) {
|
|
50
52
|
const chunkSize = params.chunkSize ?? 256;
|
|
51
53
|
if (!Number.isInteger(params.start) || params.start < 0) {
|
|
@@ -90,6 +92,7 @@ export async function readOracleRegistryPage(params) {
|
|
|
90
92
|
/**
|
|
91
93
|
* Reads key global oracle config values used by UIs and monitoring.
|
|
92
94
|
*/
|
|
95
|
+
// wraps: VarlaOracle.maxStaleness,VarlaOracle.liquidationGracePeriod,VarlaOracle.defaultEarlyClosureWindow
|
|
93
96
|
export async function readOracleConfig(params) {
|
|
94
97
|
const [maxStaleness, liquidationGracePeriod, defaultEarlyClosureWindow] = await Promise.all([
|
|
95
98
|
params.oracle.read.maxStaleness(),
|
|
@@ -98,6 +101,134 @@ export async function readOracleConfig(params) {
|
|
|
98
101
|
]);
|
|
99
102
|
return { maxStaleness, liquidationGracePeriod, defaultEarlyClosureWindow };
|
|
100
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Higher-level UX helper: is this position usable right now?
|
|
106
|
+
*/
|
|
107
|
+
// wraps: VarlaOracle.isConfigured,VarlaOracle.isResolved,VarlaOracle.isDepositAllowed,VarlaOracle.isValidCollateral,VarlaOracle.isPriceStale
|
|
108
|
+
export async function readOracleCollateralStatus(params) {
|
|
109
|
+
const pid = params.positionId;
|
|
110
|
+
const [isConfigured, isResolved, isDepositAllowed, isValidCollateral, isPriceStale] = await Promise.all([
|
|
111
|
+
params.oracle.read.isConfigured([pid]),
|
|
112
|
+
params.oracle.read.isResolved([pid]),
|
|
113
|
+
params.oracle.read.isDepositAllowed([pid]),
|
|
114
|
+
params.oracle.read.isValidCollateral([pid]),
|
|
115
|
+
params.oracle.read.isPriceStale([pid]),
|
|
116
|
+
]);
|
|
117
|
+
return {
|
|
118
|
+
positionId: pid,
|
|
119
|
+
isConfigured,
|
|
120
|
+
isResolved,
|
|
121
|
+
isDepositAllowed,
|
|
122
|
+
isValidCollateral,
|
|
123
|
+
isPriceStale,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
// wraps: VarlaOracle.tryGetPrice
|
|
127
|
+
export async function readTryGetPrice(params) {
|
|
128
|
+
const raw = await params.oracle.read.tryGetPrice([params.positionId]);
|
|
129
|
+
const r = raw;
|
|
130
|
+
const ok = r.ok ?? r[0];
|
|
131
|
+
const priceE8 = r.price ?? r.priceE8 ?? r[1];
|
|
132
|
+
if (typeof ok !== "boolean" || typeof priceE8 !== "bigint") {
|
|
133
|
+
throw new Error("Unexpected tryGetPrice() return shape");
|
|
134
|
+
}
|
|
135
|
+
return { positionId: params.positionId, ok, priceE8 };
|
|
136
|
+
}
|
|
137
|
+
// wraps: VarlaOracle.getPriceData
|
|
138
|
+
export async function readOraclePriceData(params) {
|
|
139
|
+
const raw = await params.oracle.read.getPriceData([params.positionId]);
|
|
140
|
+
const r = raw;
|
|
141
|
+
const priceE8 = r.price ?? r[0];
|
|
142
|
+
const twapE8 = r.twap ?? r[1];
|
|
143
|
+
const liquidity = r.liquidity ?? r[2];
|
|
144
|
+
const lastUpdated = r.lastUpdated ?? r[3];
|
|
145
|
+
const isValid = r.isValid ?? r[4];
|
|
146
|
+
const riskTierRaw = r.riskTier ?? r[5];
|
|
147
|
+
if (typeof priceE8 !== "bigint" ||
|
|
148
|
+
typeof twapE8 !== "bigint" ||
|
|
149
|
+
typeof liquidity !== "bigint" ||
|
|
150
|
+
typeof lastUpdated !== "bigint" ||
|
|
151
|
+
typeof isValid !== "boolean" ||
|
|
152
|
+
(typeof riskTierRaw !== "number" && typeof riskTierRaw !== "bigint")) {
|
|
153
|
+
throw new Error("Unexpected getPriceData() return shape");
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
positionId: params.positionId,
|
|
157
|
+
priceE8,
|
|
158
|
+
twapE8,
|
|
159
|
+
liquidity,
|
|
160
|
+
lastUpdated,
|
|
161
|
+
isValid,
|
|
162
|
+
riskTier: Number(riskTierRaw),
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
// wraps: VarlaOracle.updater,VarlaOracle.collateralDecimals
|
|
166
|
+
export async function readOracleBasics(params) {
|
|
167
|
+
const [updater, collateralDecimalsRaw] = await Promise.all([
|
|
168
|
+
params.oracle.read.updater(),
|
|
169
|
+
params.oracle.read.collateralDecimals(),
|
|
170
|
+
]);
|
|
171
|
+
const collateralDecimals = typeof collateralDecimalsRaw === "bigint"
|
|
172
|
+
? Number(collateralDecimalsRaw)
|
|
173
|
+
: collateralDecimalsRaw;
|
|
174
|
+
if (!Number.isInteger(collateralDecimals) || collateralDecimals < 0) {
|
|
175
|
+
throw new Error(`Invalid collateralDecimals: ${String(collateralDecimalsRaw)}`);
|
|
176
|
+
}
|
|
177
|
+
return { updater, collateralDecimals };
|
|
178
|
+
}
|
|
179
|
+
// wraps: VarlaOracle.getEarlyClosureWindow,VarlaOracle.getEarlyClosureFactor,VarlaOracle.lastRecoveryFromStale,VarlaOracle.getLastUpdated
|
|
180
|
+
export async function readOracleTiming(params) {
|
|
181
|
+
const pid = params.positionId;
|
|
182
|
+
const [earlyClosureWindow, earlyClosureFactorWad, lastRecoveryFromStale, lastUpdated] = await Promise.all([
|
|
183
|
+
params.oracle.read.getEarlyClosureWindow([pid]),
|
|
184
|
+
params.oracle.read.getEarlyClosureFactor([pid]),
|
|
185
|
+
params.oracle.read.lastRecoveryFromStale([pid]),
|
|
186
|
+
params.oracle.read.getLastUpdated([pid]),
|
|
187
|
+
]);
|
|
188
|
+
return {
|
|
189
|
+
positionId: pid,
|
|
190
|
+
earlyClosureWindow,
|
|
191
|
+
earlyClosureFactorWad,
|
|
192
|
+
lastRecoveryFromStale,
|
|
193
|
+
lastUpdated,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
// wraps: VarlaOracle.getConfiguredPositions
|
|
197
|
+
export async function readConfiguredPositionIds(params) {
|
|
198
|
+
const ids = await params.oracle.read.getConfiguredPositions();
|
|
199
|
+
return [...ids];
|
|
200
|
+
}
|
|
201
|
+
// wraps: VarlaOracle.getNegRiskMarketPositionIds
|
|
202
|
+
export async function readNegRiskMarketPositionIds(params) {
|
|
203
|
+
const ids = await params.oracle.read.getNegRiskMarketPositionIds([params.marketId]);
|
|
204
|
+
return [...ids];
|
|
205
|
+
}
|
|
206
|
+
// wraps: VarlaOracle.getRiskTier
|
|
207
|
+
export async function readRiskTier(params) {
|
|
208
|
+
const v = await params.oracle.read.getRiskTier([params.positionId]);
|
|
209
|
+
const riskTier = typeof v === "bigint" ? Number(v) : v;
|
|
210
|
+
return { positionId: params.positionId, riskTier };
|
|
211
|
+
}
|
|
212
|
+
// wraps: VarlaOracle.getSpotPrice
|
|
213
|
+
export async function readSpotPrice(params) {
|
|
214
|
+
const spotPriceE8 = await params.oracle.read.getSpotPrice([params.positionId]);
|
|
215
|
+
return { positionId: params.positionId, spotPriceE8 };
|
|
216
|
+
}
|
|
217
|
+
// wraps: VarlaOracle.getTWAP
|
|
218
|
+
export async function readTwap(params) {
|
|
219
|
+
const twapE8 = await params.oracle.read.getTWAP([params.positionId]);
|
|
220
|
+
return { positionId: params.positionId, twapE8 };
|
|
221
|
+
}
|
|
222
|
+
// wraps: VarlaOracle.getPrice
|
|
223
|
+
export async function readPrice(params) {
|
|
224
|
+
const priceE8 = await params.oracle.read.getPrice([params.positionId]);
|
|
225
|
+
return { positionId: params.positionId, priceE8 };
|
|
226
|
+
}
|
|
227
|
+
// wraps: VarlaOracle.getLiquidity
|
|
228
|
+
export async function readLiquidity(params) {
|
|
229
|
+
const liquidity = await params.oracle.read.getLiquidity([params.positionId]);
|
|
230
|
+
return { positionId: params.positionId, liquidity };
|
|
231
|
+
}
|
|
101
232
|
function normalizePositionSnapshot(raw, positionId) {
|
|
102
233
|
const r = raw;
|
|
103
234
|
const priceOk = r.priceOk ?? r[0];
|
|
@@ -127,6 +258,7 @@ function normalizePositionSnapshot(raw, positionId) {
|
|
|
127
258
|
/**
|
|
128
259
|
* Normalized wrapper over `VarlaOracle.getPositionSnapshot(positionId)`.
|
|
129
260
|
*/
|
|
261
|
+
// wraps: VarlaOracle.getPositionSnapshot
|
|
130
262
|
export async function readPositionSnapshot(params) {
|
|
131
263
|
const raw = await params.oracle.read.getPositionSnapshot([params.positionId]);
|
|
132
264
|
return normalizePositionSnapshot(raw, params.positionId);
|
|
@@ -134,6 +266,7 @@ export async function readPositionSnapshot(params) {
|
|
|
134
266
|
/**
|
|
135
267
|
* Multicall-chunked `getPositionSnapshot` for many ids.
|
|
136
268
|
*/
|
|
269
|
+
// wraps: VarlaOracle.getPositionSnapshot
|
|
137
270
|
export async function readManyPositionSnapshots(params) {
|
|
138
271
|
const chunkSize = params.chunkSize ?? 256;
|
|
139
272
|
if (params.positionIds.length === 0)
|
|
@@ -165,6 +298,7 @@ export async function readManyPositionSnapshots(params) {
|
|
|
165
298
|
* This is intentionally split out from `getPositionSnapshot`, since snapshot focuses on
|
|
166
299
|
* pricing/tier/factor, while this focuses on market identity + registry wiring.
|
|
167
300
|
*/
|
|
301
|
+
// wraps: VarlaOracle.getConditionId,VarlaOracle.getResolutionTime,VarlaOracle.getOppositePositionId,VarlaOracle.isNegRisk,VarlaOracle.getNegRiskMarketId,VarlaOracle.isManuallyInvalidated
|
|
168
302
|
export async function readOraclePositionMeta(params) {
|
|
169
303
|
const pid = params.positionId;
|
|
170
304
|
const [conditionId, resolutionTime, oppositePositionId, isNegRisk, negRiskMarketId, isManuallyInvalidated,] = await Promise.all([
|
|
@@ -190,6 +324,7 @@ export async function readOraclePositionMeta(params) {
|
|
|
190
324
|
*
|
|
191
325
|
* Returns results aligned to the input `positionIds` order.
|
|
192
326
|
*/
|
|
327
|
+
// wraps: VarlaOracle.getConditionId,VarlaOracle.getResolutionTime,VarlaOracle.getOppositePositionId,VarlaOracle.isNegRisk,VarlaOracle.getNegRiskMarketId,VarlaOracle.isManuallyInvalidated
|
|
193
328
|
export async function readManyOraclePositionMeta(params) {
|
|
194
329
|
const chunkSize = params.chunkSize ?? 256;
|
|
195
330
|
if (params.positionIds.length === 0)
|
|
@@ -280,6 +415,7 @@ export async function readManyOraclePositionMeta(params) {
|
|
|
280
415
|
/**
|
|
281
416
|
* Convenience wrapper for callers that already have an oracle registry list.
|
|
282
417
|
*/
|
|
418
|
+
// wraps: VarlaOracle.getPositionSnapshot,VarlaOracle.getConditionId,VarlaOracle.getResolutionTime,VarlaOracle.getOppositePositionId,VarlaOracle.isNegRisk,VarlaOracle.getNegRiskMarketId,VarlaOracle.isManuallyInvalidated
|
|
283
419
|
export async function hydrateOraclePositionIds(params) {
|
|
284
420
|
const chunkSize = params.chunkSize ?? 256;
|
|
285
421
|
const [snapshots, meta] = await Promise.all([
|
package/dist/views/pool.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
1
2
|
export type ReadPoolSnapshot = {
|
|
2
3
|
totalAssets: bigint;
|
|
3
4
|
totalBorrowed: bigint;
|
|
@@ -7,6 +8,11 @@ export type ReadPoolSnapshot = {
|
|
|
7
8
|
supplyAPY: bigint;
|
|
8
9
|
borrowIndex: bigint;
|
|
9
10
|
};
|
|
11
|
+
export type ReadPoolDebtState = {
|
|
12
|
+
totalBorrowed: bigint;
|
|
13
|
+
currentBorrowIndex: bigint;
|
|
14
|
+
borrowRate: bigint;
|
|
15
|
+
};
|
|
10
16
|
export declare function readPoolSnapshot(params: {
|
|
11
17
|
pool: {
|
|
12
18
|
read: {
|
|
@@ -48,4 +54,44 @@ export declare function readPoolAccounting(params: {
|
|
|
48
54
|
};
|
|
49
55
|
};
|
|
50
56
|
}): Promise<ReadPoolAccounting>;
|
|
57
|
+
export type ReadPoolRates = {
|
|
58
|
+
utilization: bigint;
|
|
59
|
+
borrowRate: bigint;
|
|
60
|
+
supplyAPY: bigint;
|
|
61
|
+
availableLiquidity: bigint;
|
|
62
|
+
maxBorrow: bigint;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Reads pool “rates” and near-term capacity in one convenience call.
|
|
66
|
+
*/
|
|
67
|
+
export declare function readPoolRates(params: {
|
|
68
|
+
pool: {
|
|
69
|
+
read: {
|
|
70
|
+
getUtilization: () => Promise<bigint>;
|
|
71
|
+
getInterestRate: () => Promise<bigint>;
|
|
72
|
+
getSupplyAPY: () => Promise<bigint>;
|
|
73
|
+
getAvailableLiquidity: () => Promise<bigint>;
|
|
74
|
+
maxBorrow: () => Promise<bigint>;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
}): Promise<ReadPoolRates>;
|
|
78
|
+
/**
|
|
79
|
+
* Pool debt/index primitives commonly used by UIs.
|
|
80
|
+
*/
|
|
81
|
+
export declare function readPoolDebtState(params: {
|
|
82
|
+
pool: {
|
|
83
|
+
read: {
|
|
84
|
+
getTotalBorrowed: () => Promise<bigint>;
|
|
85
|
+
getCurrentBorrowIndex: () => Promise<bigint>;
|
|
86
|
+
borrowRate: () => Promise<bigint>;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
}): Promise<ReadPoolDebtState>;
|
|
90
|
+
export declare function readPoolCoreAddress(params: {
|
|
91
|
+
pool: {
|
|
92
|
+
read: {
|
|
93
|
+
varlaCore: () => Promise<Address>;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
}): Promise<Address>;
|
|
51
97
|
//# sourceMappingURL=pool.d.ts.map
|
package/dist/views/pool.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../src/views/pool.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,wBAAsB,gBAAgB,CAAC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,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;SAClC,CAAC;KACH,CAAC;CACH,GAAG,OAAO,CAAC,aAAa,CAAC,CAUzB;AAED;;GAEG;AAEH,wBAAsB,iBAAiB,CAAC,MAAM,EAAE;IAC9C,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,gBAAgB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;YACxC,qBAAqB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;YAC7C,UAAU,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;SACnC,CAAC;KACH,CAAC;CACH,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAO7B;AAGD,wBAAsB,mBAAmB,CAAC,MAAM,EAAE;IAChD,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,SAAS,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;SACnC,CAAC;KACH,CAAC;CACH,GAAG,OAAO,CAAC,OAAO,CAAC,CAEnB"}
|
package/dist/views/pool.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// Note: explicit .js extension is required for Node ESM resolution.
|
|
2
|
+
// wraps: VarlaPool.getPoolStats
|
|
2
3
|
export async function readPoolSnapshot(params) {
|
|
3
4
|
const raw = await params.pool.read.getPoolStats();
|
|
4
5
|
const r = raw;
|
|
@@ -33,6 +34,7 @@ export async function readPoolSnapshot(params) {
|
|
|
33
34
|
/**
|
|
34
35
|
* Reads depositCap/borrowCap (useful for frontends + monitoring).
|
|
35
36
|
*/
|
|
37
|
+
// wraps: VarlaPool.depositCap,VarlaPool.borrowCap
|
|
36
38
|
export async function readPoolCaps(params) {
|
|
37
39
|
const [depositCap, borrowCap] = await Promise.all([
|
|
38
40
|
params.pool.read.depositCap(),
|
|
@@ -43,6 +45,7 @@ export async function readPoolCaps(params) {
|
|
|
43
45
|
/**
|
|
44
46
|
* Reads accounting/index variables that are commonly required in analytics.
|
|
45
47
|
*/
|
|
48
|
+
// wraps: VarlaPool.reserveBalance,VarlaPool.scaledTotalBorrowed,VarlaPool.borrowIndex,VarlaPool.lastUpdateTimestamp
|
|
46
49
|
export async function readPoolAccounting(params) {
|
|
47
50
|
const [reserveBalance, scaledTotalBorrowed, borrowIndex, lastUpdateTimestamp] = await Promise.all([
|
|
48
51
|
params.pool.read.reserveBalance(),
|
|
@@ -57,3 +60,33 @@ export async function readPoolAccounting(params) {
|
|
|
57
60
|
lastUpdateTimestamp: BigInt(lastUpdateTimestamp),
|
|
58
61
|
};
|
|
59
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Reads pool “rates” and near-term capacity in one convenience call.
|
|
65
|
+
*/
|
|
66
|
+
// wraps: VarlaPool.getUtilization,VarlaPool.getInterestRate,VarlaPool.getSupplyAPY,VarlaPool.getAvailableLiquidity,VarlaPool.maxBorrow
|
|
67
|
+
export async function readPoolRates(params) {
|
|
68
|
+
const [utilization, borrowRate, supplyAPY, availableLiquidity, maxBorrow] = await Promise.all([
|
|
69
|
+
params.pool.read.getUtilization(),
|
|
70
|
+
params.pool.read.getInterestRate(),
|
|
71
|
+
params.pool.read.getSupplyAPY(),
|
|
72
|
+
params.pool.read.getAvailableLiquidity(),
|
|
73
|
+
params.pool.read.maxBorrow(),
|
|
74
|
+
]);
|
|
75
|
+
return { utilization, borrowRate, supplyAPY, availableLiquidity, maxBorrow };
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Pool debt/index primitives commonly used by UIs.
|
|
79
|
+
*/
|
|
80
|
+
// wraps: VarlaPool.getTotalBorrowed,VarlaPool.getCurrentBorrowIndex,VarlaPool.borrowRate
|
|
81
|
+
export async function readPoolDebtState(params) {
|
|
82
|
+
const [totalBorrowed, currentBorrowIndex, borrowRate] = await Promise.all([
|
|
83
|
+
params.pool.read.getTotalBorrowed(),
|
|
84
|
+
params.pool.read.getCurrentBorrowIndex(),
|
|
85
|
+
params.pool.read.borrowRate(),
|
|
86
|
+
]);
|
|
87
|
+
return { totalBorrowed, currentBorrowIndex, borrowRate };
|
|
88
|
+
}
|
|
89
|
+
// wraps: VarlaPool.varlaCore
|
|
90
|
+
export async function readPoolCoreAddress(params) {
|
|
91
|
+
return params.pool.read.varlaCore();
|
|
92
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../src/views/system.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAC7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAMpF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,gBAAgB,CAAC;IACvB,QAAQ,EAAE,YAAY,CAAC;IACvB,cAAc,EAAE,kBAAkB,CAAC;IACnC,OAAO,EAAE,oBAAoB,CAAC;IAC9B,eAAe,EAAE,qBAAqB,CAAC;IACvC,MAAM,EAAE,gBAAgB,CAAC;CAC1B,CAAC;AAEF;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../src/views/system.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAC7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAMpF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,gBAAgB,CAAC;IACvB,QAAQ,EAAE,YAAY,CAAC;IACvB,cAAc,EAAE,kBAAkB,CAAC;IACnC,OAAO,EAAE,oBAAoB,CAAC;IAC9B,eAAe,EAAE,qBAAqB,CAAC;IACvC,MAAM,EAAE,gBAAgB,CAAC;CAC1B,CAAC;AAEF;;;;;;GAMG;AAEH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE;IAC/C,IAAI,EAAE,GAAG,CAAC;IACV,IAAI,EAAE,GAAG,CAAC;IACV,MAAM,EAAE,GAAG,CAAC;CACb,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAW9B"}
|
package/dist/views/system.js
CHANGED
|
@@ -9,6 +9,7 @@ import { readPoolAccounting, readPoolCaps, readPoolSnapshot } from "./pool.js";
|
|
|
9
9
|
* - no registry enumeration
|
|
10
10
|
* - just the config + accounting primitives needed by frontends and monitoring
|
|
11
11
|
*/
|
|
12
|
+
// wraps: VarlaPool.getPoolStats,VarlaPool.depositCap,VarlaPool.borrowCap,VarlaPool.reserveBalance,VarlaPool.scaledTotalBorrowed,VarlaPool.borrowIndex,VarlaPool.lastUpdateTimestamp,VarlaCore.getDefaultLtvConfig,VarlaCore.getLiquidationConfig,VarlaOracle.maxStaleness,VarlaOracle.liquidationGracePeriod,VarlaOracle.defaultEarlyClosureWindow
|
|
12
13
|
export async function readSystemSnapshot(params) {
|
|
13
14
|
const [pool, poolCaps, poolAccounting, coreLtv, coreLiquidation, oracle] = await Promise.all([
|
|
14
15
|
readPoolSnapshot({ pool: params.pool }),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varla/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -17,6 +17,14 @@
|
|
|
17
17
|
"types": "./dist/contracts.d.ts",
|
|
18
18
|
"default": "./dist/contracts.js"
|
|
19
19
|
},
|
|
20
|
+
"./views": {
|
|
21
|
+
"types": "./dist/views/index.d.ts",
|
|
22
|
+
"default": "./dist/views/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./events": {
|
|
25
|
+
"types": "./dist/events/index.d.ts",
|
|
26
|
+
"default": "./dist/events/index.js"
|
|
27
|
+
},
|
|
20
28
|
"./abi": {
|
|
21
29
|
"types": "./dist/abi.d.ts",
|
|
22
30
|
"default": "./dist/abi.js"
|
|
@@ -28,6 +36,14 @@
|
|
|
28
36
|
"./types": {
|
|
29
37
|
"types": "./dist/types.d.ts",
|
|
30
38
|
"default": "./dist/types.js"
|
|
39
|
+
},
|
|
40
|
+
"./batch": {
|
|
41
|
+
"types": "./dist/batch.d.ts",
|
|
42
|
+
"default": "./dist/batch.js"
|
|
43
|
+
},
|
|
44
|
+
"./format": {
|
|
45
|
+
"types": "./dist/format.d.ts",
|
|
46
|
+
"default": "./dist/format.js"
|
|
31
47
|
}
|
|
32
48
|
},
|
|
33
49
|
"publishConfig": {
|