@moonwell-fi/moonwell-sdk 0.20.5 → 0.21.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/CHANGELOG.md +14 -0
- package/_cjs/actions/core/markets/getMarketSnapshots.js +1 -83
- package/_cjs/actions/core/markets/getMarketSnapshots.js.map +1 -1
- package/_cjs/actions/core/user-positions/getUserPositionSnapshots.js +1 -59
- package/_cjs/actions/core/user-positions/getUserPositionSnapshots.js.map +1 -1
- package/_cjs/actions/governance/getCirculatingSupplySnapshots.js +1 -49
- package/_cjs/actions/governance/getCirculatingSupplySnapshots.js.map +1 -1
- package/_cjs/actions/governance/getStakingSnapshots.js +1 -41
- package/_cjs/actions/governance/getStakingSnapshots.js.map +1 -1
- package/_cjs/actions/governance/proposals/common.js +1 -1
- package/_cjs/actions/governance/proposals/common.js.map +1 -1
- package/_cjs/environments/definitions/governance.js +0 -7
- package/_cjs/environments/definitions/governance.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_esm/actions/core/markets/getMarketSnapshots.js +1 -83
- package/_esm/actions/core/markets/getMarketSnapshots.js.map +1 -1
- package/_esm/actions/core/user-positions/getUserPositionSnapshots.js +3 -62
- package/_esm/actions/core/user-positions/getUserPositionSnapshots.js.map +1 -1
- package/_esm/actions/governance/getCirculatingSupplySnapshots.js +2 -50
- package/_esm/actions/governance/getCirculatingSupplySnapshots.js.map +1 -1
- package/_esm/actions/governance/getStakingSnapshots.js +1 -41
- package/_esm/actions/governance/getStakingSnapshots.js.map +1 -1
- package/_esm/actions/governance/proposals/common.js +12 -1
- package/_esm/actions/governance/proposals/common.js.map +1 -1
- package/_esm/actions/lunar-indexer-client.js +1 -1
- package/_esm/environments/definitions/governance.js +0 -7
- package/_esm/environments/definitions/governance.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_types/actions/core/markets/getMarketSnapshots.d.ts.map +1 -1
- package/_types/actions/core/user-positions/getUserPositionSnapshots.d.ts +1 -2
- package/_types/actions/core/user-positions/getUserPositionSnapshots.d.ts.map +1 -1
- package/_types/actions/governance/getCirculatingSupplySnapshots.d.ts.map +1 -1
- package/_types/actions/governance/getStakingSnapshots.d.ts.map +1 -1
- package/_types/actions/governance/proposals/common.d.ts.map +1 -1
- package/_types/actions/lunar-indexer-client.d.ts +1 -1
- package/_types/environments/definitions/governance.d.ts +0 -7
- package/_types/environments/definitions/governance.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/actions/core/markets/getMarketSnapshots.ts +1 -118
- package/actions/core/user-positions/getUserPositionSnapshots.ts +2 -91
- package/actions/governance/getCirculatingSupplySnapshots.ts +3 -72
- package/actions/governance/getStakingSnapshots.ts +1 -59
- package/actions/governance/proposals/common.ts +12 -1
- package/actions/lunar-indexer-client.ts +1 -1
- package/environments/definitions/governance.ts +0 -7
- package/errors/version.ts +1 -1
- package/package.json +2 -2
|
@@ -11,7 +11,6 @@ import { buildMarketId } from "../../../common/lunar-indexer-helpers.js";
|
|
|
11
11
|
import type { NetworkParameterType } from "../../../common/types.js";
|
|
12
12
|
import type { Chain, Environment } from "../../../environments/index.js";
|
|
13
13
|
import type { MarketSnapshot } from "../../../types/market.js";
|
|
14
|
-
import { postWithRetry } from "../../axiosWithRetry.js";
|
|
15
14
|
import {
|
|
16
15
|
DEFAULT_LUNAR_TIMEOUT_MS,
|
|
17
16
|
createLunarIndexerClient,
|
|
@@ -141,23 +140,7 @@ async function fetchCoreMarketSnapshots(
|
|
|
141
140
|
endTime?: number,
|
|
142
141
|
): Promise<MarketSnapshot[]> {
|
|
143
142
|
if (!environment.lunarIndexerUrl) {
|
|
144
|
-
|
|
145
|
-
try {
|
|
146
|
-
return await fetchCoreMarketSnapshotsFromPonder(
|
|
147
|
-
marketAddress,
|
|
148
|
-
environment,
|
|
149
|
-
);
|
|
150
|
-
} catch (error) {
|
|
151
|
-
console.warn(
|
|
152
|
-
`[getMarketSnapshots] Ponder failed for chain ${environment.chainId}:`,
|
|
153
|
-
error,
|
|
154
|
-
);
|
|
155
|
-
environment.onError?.(error, {
|
|
156
|
-
source: "market-snapshots-ponder",
|
|
157
|
-
chainId: environment.chainId,
|
|
158
|
-
});
|
|
159
|
-
return [];
|
|
160
|
-
}
|
|
143
|
+
return [];
|
|
161
144
|
}
|
|
162
145
|
try {
|
|
163
146
|
return await fetchCoreMarketSnapshotsFromLunar(
|
|
@@ -180,106 +163,6 @@ async function fetchCoreMarketSnapshots(
|
|
|
180
163
|
}
|
|
181
164
|
}
|
|
182
165
|
|
|
183
|
-
async function fetchCoreMarketSnapshotsFromPonder(
|
|
184
|
-
marketAddress: string,
|
|
185
|
-
environment: Environment,
|
|
186
|
-
): Promise<MarketSnapshot[]> {
|
|
187
|
-
if (!environment.indexerUrl) return [];
|
|
188
|
-
|
|
189
|
-
interface MarketDailyData {
|
|
190
|
-
totalBorrows: number;
|
|
191
|
-
totalBorrowsUSD: number;
|
|
192
|
-
totalSupplies: number;
|
|
193
|
-
totalSuppliesUSD: number;
|
|
194
|
-
totalLiquidity: number;
|
|
195
|
-
totalLiquidityUSD: number;
|
|
196
|
-
baseSupplyApy: number;
|
|
197
|
-
baseBorrowApy: number;
|
|
198
|
-
timestamp: number;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
const dailyData: MarketDailyData[] = [];
|
|
202
|
-
let hasNextPage = true;
|
|
203
|
-
let endCursor: string | undefined;
|
|
204
|
-
|
|
205
|
-
while (hasNextPage) {
|
|
206
|
-
const result = await postWithRetry<{
|
|
207
|
-
data: {
|
|
208
|
-
marketDailySnapshots: {
|
|
209
|
-
items: MarketDailyData[];
|
|
210
|
-
pageInfo: { hasNextPage: boolean; endCursor: string };
|
|
211
|
-
};
|
|
212
|
-
};
|
|
213
|
-
}>(environment.indexerUrl, {
|
|
214
|
-
query: `
|
|
215
|
-
query {
|
|
216
|
-
marketDailySnapshots (
|
|
217
|
-
limit: 1000,
|
|
218
|
-
orderBy: "timestamp"
|
|
219
|
-
orderDirection: "desc"
|
|
220
|
-
where: {marketAddress: "${marketAddress.toLowerCase()}", chainId: ${environment.chainId}}
|
|
221
|
-
${endCursor ? `after: "${endCursor}"` : ""}
|
|
222
|
-
) {
|
|
223
|
-
items {
|
|
224
|
-
totalBorrows
|
|
225
|
-
totalBorrowsUSD
|
|
226
|
-
totalSupplies
|
|
227
|
-
totalSuppliesUSD
|
|
228
|
-
totalLiquidity
|
|
229
|
-
totalLiquidityUSD
|
|
230
|
-
baseSupplyApy
|
|
231
|
-
baseBorrowApy
|
|
232
|
-
timestamp
|
|
233
|
-
}
|
|
234
|
-
pageInfo {
|
|
235
|
-
hasNextPage
|
|
236
|
-
endCursor
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
`,
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
dailyData.push(
|
|
244
|
-
...result.data.data.marketDailySnapshots.items.filter(
|
|
245
|
-
(f: { timestamp: number }) => isStartOfDay(f.timestamp),
|
|
246
|
-
),
|
|
247
|
-
);
|
|
248
|
-
hasNextPage = result.data.data.marketDailySnapshots.pageInfo.hasNextPage;
|
|
249
|
-
endCursor = result.data.data.marketDailySnapshots.pageInfo.endCursor;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
if (dailyData.length === 0) return [];
|
|
253
|
-
|
|
254
|
-
return dailyData.map((point) => {
|
|
255
|
-
const supplied = Number(point.totalSupplies);
|
|
256
|
-
const borrow = Number(point.totalBorrows);
|
|
257
|
-
const borrowUsd = Number(point.totalBorrowsUSD);
|
|
258
|
-
const suppliedUsd = Number(point.totalSuppliesUSD);
|
|
259
|
-
const liquidity = Math.max(point.totalLiquidity, 0);
|
|
260
|
-
const liquidityUsd = Math.max(point.totalLiquidityUSD, 0);
|
|
261
|
-
const price = suppliedUsd / supplied;
|
|
262
|
-
|
|
263
|
-
return {
|
|
264
|
-
marketId: marketAddress.toLowerCase(),
|
|
265
|
-
chainId: environment.chainId,
|
|
266
|
-
timestamp: point.timestamp * 1000,
|
|
267
|
-
totalSupply: supplied,
|
|
268
|
-
totalSupplyUsd: suppliedUsd,
|
|
269
|
-
totalBorrows: borrow,
|
|
270
|
-
totalBorrowsUsd: borrowUsd,
|
|
271
|
-
totalLiquidity: liquidity,
|
|
272
|
-
totalLiquidityUsd: liquidityUsd,
|
|
273
|
-
totalReallocatableLiquidity: 0,
|
|
274
|
-
totalReallocatableLiquidityUsd: 0,
|
|
275
|
-
baseSupplyApy: point.baseSupplyApy,
|
|
276
|
-
baseBorrowApy: point.baseBorrowApy,
|
|
277
|
-
collateralTokenPrice: price,
|
|
278
|
-
loanTokenPrice: price,
|
|
279
|
-
};
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
|
|
283
166
|
async function fetchCoreMarketSnapshotsFromLunar(
|
|
284
167
|
marketAddress: string,
|
|
285
168
|
environment: Environment,
|
|
@@ -5,13 +5,11 @@ import {
|
|
|
5
5
|
applyGranularity,
|
|
6
6
|
calculateTimeRange,
|
|
7
7
|
getEnvironmentFromArgs,
|
|
8
|
-
isStartOfDay,
|
|
9
8
|
toApiGranularity,
|
|
10
9
|
} from "../../../common/index.js";
|
|
11
10
|
import type { NetworkParameterType } from "../../../common/types.js";
|
|
12
11
|
import type { Chain, Environment } from "../../../environments/index.js";
|
|
13
12
|
import type { UserPositionSnapshot } from "../../../types/userPosition.js";
|
|
14
|
-
import { postWithRetry } from "../../axiosWithRetry.js";
|
|
15
13
|
import {
|
|
16
14
|
DEFAULT_LUNAR_TIMEOUT_MS,
|
|
17
15
|
createLunarIndexerClient,
|
|
@@ -54,8 +52,7 @@ export type GetUserPositionSnapshotsReturnType = Promise<
|
|
|
54
52
|
* @remarks
|
|
55
53
|
* - Default behavior (no time parameters): Returns 365 days of history
|
|
56
54
|
* - Parameter priority: Custom timestamps > period > default (365 days)
|
|
57
|
-
* -
|
|
58
|
-
* - Snapshots are filtered to start-of-day for "1d" granularity
|
|
55
|
+
* - Environments without a Lunar Indexer configured return an empty array
|
|
59
56
|
*/
|
|
60
57
|
export async function getUserPositionSnapshots<
|
|
61
58
|
environments,
|
|
@@ -89,23 +86,7 @@ async function fetchUserPositionSnapshots(
|
|
|
89
86
|
granularity?: "6h" | "1d",
|
|
90
87
|
): Promise<UserPositionSnapshot[]> {
|
|
91
88
|
if (!environment.lunarIndexerUrl) {
|
|
92
|
-
|
|
93
|
-
try {
|
|
94
|
-
return await fetchUserPositionSnapshotsFromPonder(
|
|
95
|
-
userAddress,
|
|
96
|
-
environment,
|
|
97
|
-
);
|
|
98
|
-
} catch (error) {
|
|
99
|
-
console.warn(
|
|
100
|
-
`[getUserPositionSnapshots] Ponder failed for chain ${environment.chainId}:`,
|
|
101
|
-
error,
|
|
102
|
-
);
|
|
103
|
-
environment.onError?.(error, {
|
|
104
|
-
source: "user-position-snapshots-ponder",
|
|
105
|
-
chainId: environment.chainId,
|
|
106
|
-
});
|
|
107
|
-
return [];
|
|
108
|
-
}
|
|
89
|
+
return [];
|
|
109
90
|
}
|
|
110
91
|
try {
|
|
111
92
|
return await fetchUserPositionSnapshotsFromLunar(
|
|
@@ -186,73 +167,3 @@ async function fetchUserPositionSnapshotsFromLunar(
|
|
|
186
167
|
resolvedGranularity,
|
|
187
168
|
);
|
|
188
169
|
}
|
|
189
|
-
|
|
190
|
-
async function fetchUserPositionSnapshotsFromPonder(
|
|
191
|
-
userAddress: Address,
|
|
192
|
-
environment: Environment,
|
|
193
|
-
): Promise<UserPositionSnapshot[]> {
|
|
194
|
-
if (!environment.indexerUrl) return [];
|
|
195
|
-
|
|
196
|
-
interface UserDailyData {
|
|
197
|
-
totalBorrowsUSD: string;
|
|
198
|
-
totalSuppliesUSD: string;
|
|
199
|
-
totalCollateralUSD: string;
|
|
200
|
-
timestamp: number;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
const dailyData: UserDailyData[] = [];
|
|
204
|
-
let hasNextPage = true;
|
|
205
|
-
let endCursor: string | undefined;
|
|
206
|
-
|
|
207
|
-
while (hasNextPage) {
|
|
208
|
-
const result = await postWithRetry<{
|
|
209
|
-
data: {
|
|
210
|
-
accountDailySnapshots: {
|
|
211
|
-
items: UserDailyData[];
|
|
212
|
-
pageInfo: { hasNextPage: boolean; endCursor: string };
|
|
213
|
-
};
|
|
214
|
-
};
|
|
215
|
-
}>(environment.indexerUrl, {
|
|
216
|
-
query: `
|
|
217
|
-
query {
|
|
218
|
-
accountDailySnapshots(
|
|
219
|
-
limit: 365,
|
|
220
|
-
orderDirection: "desc",
|
|
221
|
-
orderBy: "timestamp",
|
|
222
|
-
where: { accountAddress: "${userAddress.toLowerCase()}", chainId: ${environment.chainId} }
|
|
223
|
-
${endCursor ? `after: "${endCursor}"` : ""}
|
|
224
|
-
) {
|
|
225
|
-
items {
|
|
226
|
-
timestamp,
|
|
227
|
-
totalBorrowsUSD,
|
|
228
|
-
totalSuppliesUSD,
|
|
229
|
-
totalCollateralUSD,
|
|
230
|
-
}
|
|
231
|
-
pageInfo {
|
|
232
|
-
hasNextPage
|
|
233
|
-
endCursor
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
`,
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
dailyData.push(
|
|
241
|
-
...result.data.data.accountDailySnapshots.items.filter(
|
|
242
|
-
(f: { timestamp: number }) => isStartOfDay(f.timestamp),
|
|
243
|
-
),
|
|
244
|
-
);
|
|
245
|
-
hasNextPage = result.data.data.accountDailySnapshots.pageInfo.hasNextPage;
|
|
246
|
-
endCursor = result.data.data.accountDailySnapshots.pageInfo.endCursor;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
if (dailyData.length === 0) return [];
|
|
250
|
-
|
|
251
|
-
return dailyData.map((point) => ({
|
|
252
|
-
chainId: environment.chainId,
|
|
253
|
-
timestamp: point.timestamp * 1000,
|
|
254
|
-
totalSupplyUsd: Number(point.totalSuppliesUSD),
|
|
255
|
-
totalBorrowsUsd: Number(point.totalBorrowsUSD),
|
|
256
|
-
totalCollateralUsd: Number(point.totalCollateralUSD),
|
|
257
|
-
}));
|
|
258
|
-
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { MoonwellClient } from "../../client/createMoonwellClient.js";
|
|
2
2
|
import { getEnvironmentFromArgs } from "../../common/index.js";
|
|
3
3
|
import type { OptionalNetworkParameterType } from "../../common/types.js";
|
|
4
|
-
import type { Chain
|
|
4
|
+
import type { Chain } from "../../environments/index.js";
|
|
5
5
|
import type { CirculatingSupplySnapshot } from "../../types/circulatingSupply.js";
|
|
6
|
-
import { getWithRetry
|
|
6
|
+
import { getWithRetry } from "../axiosWithRetry.js";
|
|
7
7
|
|
|
8
8
|
export type GetCirculatingSupplySnapshotsParameters<
|
|
9
9
|
environments,
|
|
@@ -74,9 +74,7 @@ export async function getCirculatingSupplySnapshots<
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
if (!environment.lunarIndexerUrl) {
|
|
77
|
-
return
|
|
78
|
-
? fetchCirculatingSupplyFromPonder(environment)
|
|
79
|
-
: [];
|
|
77
|
+
return [];
|
|
80
78
|
}
|
|
81
79
|
|
|
82
80
|
try {
|
|
@@ -112,70 +110,3 @@ export async function getCirculatingSupplySnapshots<
|
|
|
112
110
|
return [];
|
|
113
111
|
}
|
|
114
112
|
}
|
|
115
|
-
|
|
116
|
-
async function fetchCirculatingSupplyFromPonder(
|
|
117
|
-
environment: Environment,
|
|
118
|
-
): Promise<CirculatingSupplySnapshot[]> {
|
|
119
|
-
if (!environment.indexerUrl) return [];
|
|
120
|
-
try {
|
|
121
|
-
const response = await postWithRetry<{
|
|
122
|
-
data: {
|
|
123
|
-
circulatingSupplyDailySnapshots: {
|
|
124
|
-
items: {
|
|
125
|
-
chainId: number;
|
|
126
|
-
tokenAddress: string;
|
|
127
|
-
circulatingSupply: number;
|
|
128
|
-
timestamp: number;
|
|
129
|
-
}[];
|
|
130
|
-
};
|
|
131
|
-
};
|
|
132
|
-
}>(environment.indexerUrl, {
|
|
133
|
-
query: `
|
|
134
|
-
{
|
|
135
|
-
circulatingSupplyDailySnapshots(
|
|
136
|
-
where: { chainId: ${environment.chainId} }
|
|
137
|
-
orderBy: "timestamp"
|
|
138
|
-
orderDirection: "desc"
|
|
139
|
-
limit: 1000
|
|
140
|
-
) {
|
|
141
|
-
items {
|
|
142
|
-
chainId
|
|
143
|
-
tokenAddress
|
|
144
|
-
circulatingSupply
|
|
145
|
-
timestamp
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
`,
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
if (
|
|
153
|
-
response.status === 200 &&
|
|
154
|
-
response.data?.data?.circulatingSupplyDailySnapshots
|
|
155
|
-
) {
|
|
156
|
-
return response.data.data.circulatingSupplyDailySnapshots.items.flatMap(
|
|
157
|
-
(item) => {
|
|
158
|
-
const token = Object.values(environment.config.tokens).find(
|
|
159
|
-
(t) => t.address.toLowerCase() === item.tokenAddress.toLowerCase(),
|
|
160
|
-
);
|
|
161
|
-
if (!token) return [];
|
|
162
|
-
return [
|
|
163
|
-
{
|
|
164
|
-
chainId: item.chainId,
|
|
165
|
-
token,
|
|
166
|
-
circulatingSupply: item.circulatingSupply,
|
|
167
|
-
timestamp: item.timestamp,
|
|
168
|
-
},
|
|
169
|
-
];
|
|
170
|
-
},
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
return [];
|
|
174
|
-
} catch (ex) {
|
|
175
|
-
console.error(
|
|
176
|
-
"An error occurred while fetching getCirculatingSupplySnapshots...",
|
|
177
|
-
ex,
|
|
178
|
-
);
|
|
179
|
-
return [];
|
|
180
|
-
}
|
|
181
|
-
}
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
import type { NetworkParameterType } from "../../common/types.js";
|
|
10
10
|
import type { Chain } from "../../environments/index.js";
|
|
11
11
|
import type { StakingSnapshot } from "../../types/staking.js";
|
|
12
|
-
import { postWithRetry } from "../axiosWithRetry.js";
|
|
13
12
|
import {
|
|
14
13
|
DEFAULT_LUNAR_TIMEOUT_MS,
|
|
15
14
|
createLunarIndexerClient,
|
|
@@ -47,18 +46,7 @@ export async function getStakingSnapshots<
|
|
|
47
46
|
} = (args ?? {}) as GetStakingSnapshotsParameters<environments, undefined>;
|
|
48
47
|
|
|
49
48
|
if (!environment.lunarIndexerUrl) {
|
|
50
|
-
|
|
51
|
-
period,
|
|
52
|
-
customStartTime,
|
|
53
|
-
customEndTime,
|
|
54
|
-
);
|
|
55
|
-
return environment.indexerUrl
|
|
56
|
-
? fetchStakingSnapshotsFromPonder(
|
|
57
|
-
environment.chainId,
|
|
58
|
-
environment.indexerUrl,
|
|
59
|
-
startTime,
|
|
60
|
-
)
|
|
61
|
-
: [];
|
|
49
|
+
return [];
|
|
62
50
|
}
|
|
63
51
|
|
|
64
52
|
try {
|
|
@@ -122,49 +110,3 @@ async function fetchStakingSnapshotsFromLunar(
|
|
|
122
110
|
allSnapshots.sort((a, b) => a.timestamp - b.timestamp);
|
|
123
111
|
return applyGranularity(allSnapshots, granularity);
|
|
124
112
|
}
|
|
125
|
-
|
|
126
|
-
async function fetchStakingSnapshotsFromPonder(
|
|
127
|
-
chainId: number,
|
|
128
|
-
indexerUrl: string,
|
|
129
|
-
startTime?: number,
|
|
130
|
-
): Promise<StakingSnapshot[]> {
|
|
131
|
-
try {
|
|
132
|
-
const response = await postWithRetry<{
|
|
133
|
-
data: {
|
|
134
|
-
stakingDailySnapshots: {
|
|
135
|
-
items: StakingSnapshot[];
|
|
136
|
-
};
|
|
137
|
-
};
|
|
138
|
-
}>(indexerUrl, {
|
|
139
|
-
query: `
|
|
140
|
-
query {
|
|
141
|
-
stakingDailySnapshots(
|
|
142
|
-
limit: 365,
|
|
143
|
-
orderBy: "timestamp"
|
|
144
|
-
orderDirection: "desc"
|
|
145
|
-
where: {chainId: ${chainId}}
|
|
146
|
-
) {
|
|
147
|
-
items {
|
|
148
|
-
chainId
|
|
149
|
-
totalStaked
|
|
150
|
-
totalStakedUSD
|
|
151
|
-
timestamp
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
`,
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
if (response.status === 200 && response.data?.data?.stakingDailySnapshots) {
|
|
159
|
-
const items = response.data.data.stakingDailySnapshots.items;
|
|
160
|
-
return startTime
|
|
161
|
-
? items.filter((item) => item.timestamp >= startTime)
|
|
162
|
-
: items;
|
|
163
|
-
} else {
|
|
164
|
-
return [];
|
|
165
|
-
}
|
|
166
|
-
} catch (ex) {
|
|
167
|
-
console.error("An error occured while fetching getStakingSnapshots...", ex);
|
|
168
|
-
return [];
|
|
169
|
-
}
|
|
170
|
-
}
|
|
@@ -497,7 +497,18 @@ export const getProposalsOnChainData = async (
|
|
|
497
497
|
let eta = 0;
|
|
498
498
|
|
|
499
499
|
if (proposalData) {
|
|
500
|
-
|
|
500
|
+
// The eta lives at a different tuple index per governor: the legacy
|
|
501
|
+
// single-chain governor's `proposals()` returns
|
|
502
|
+
// (id, proposer, eta, startTimestamp, endTimestamp, ...) so eta is at
|
|
503
|
+
// index 2, whereas the multichain governor's returns
|
|
504
|
+
// (proposer, voteSnapshotTimestamp, votingStartTime, votingEndTime,
|
|
505
|
+
// crossChainVoteCollectionEndTimestamp, ...) so its execution-available
|
|
506
|
+
// timestamp is at index 4. Reading index 4 for a legacy Moonriver
|
|
507
|
+
// proposal picked up `endTimestamp` (the voting-end time, already in the
|
|
508
|
+
// past once voting closes), which made the timeline flip straight to
|
|
509
|
+
// "Timelock Ready to Execute" and surfaced the Execute button before the
|
|
510
|
+
// timelock had actually elapsed (MOO-611).
|
|
511
|
+
const onChainEta = Number(proposalData[isMultichain ? 4 : 2]);
|
|
501
512
|
if (onChainEta === 0 && isMultichain && p.votingEndTime) {
|
|
502
513
|
eta = p.votingEndTime + 86400; // 1 day
|
|
503
514
|
} else {
|
|
@@ -244,7 +244,7 @@ export class LunarIndexerError extends Error {
|
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
/**
|
|
247
|
-
* Determine if an error should trigger fallback to
|
|
247
|
+
* Determine if an error should trigger fallback to on-chain data
|
|
248
248
|
*/
|
|
249
249
|
export function shouldFallback(error: unknown): boolean {
|
|
250
250
|
if (axios.isAxiosError(error)) {
|
|
@@ -19,13 +19,6 @@ function createGovernanceTokensConfig<T extends GovernanceTokensType>(
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export const GovernanceTokensConfig = createGovernanceTokensConfig({
|
|
22
|
-
WELL_TESTNET: {
|
|
23
|
-
id: "WELL_TESTNET",
|
|
24
|
-
symbol: "WELL",
|
|
25
|
-
name: "WELL (Testnet)",
|
|
26
|
-
chainIds: [] as number[],
|
|
27
|
-
testnet: true,
|
|
28
|
-
},
|
|
29
22
|
WELL: {
|
|
30
23
|
id: "WELL",
|
|
31
24
|
symbol: "WELL",
|
package/errors/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '0.
|
|
1
|
+
export const version = '0.21.0'
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonwell-fi/moonwell-sdk",
|
|
3
3
|
"description": "TypeScript Interface for Moonwell",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.21.0",
|
|
5
5
|
"main": "./_cjs/index.js",
|
|
6
6
|
"module": "./_esm/index.js",
|
|
7
7
|
"types": "./_types/index.d.ts",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"@rhinestone/module-sdk": "0.2.7",
|
|
77
77
|
"@types/lodash": "^4.17.9",
|
|
78
78
|
"@types/node": "^22.13.10",
|
|
79
|
-
"axios": "^1.
|
|
79
|
+
"axios": "^1.18.1",
|
|
80
80
|
"dayjs": "^1.11.20",
|
|
81
81
|
"lodash": "^4.17.21",
|
|
82
82
|
"viem": "^2.26.2"
|