@wireio/stake 0.7.3 → 0.9.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/lib/stake.browser.js +390 -795
- package/lib/stake.browser.js.map +1 -1
- package/lib/stake.d.ts +132 -542
- package/lib/stake.js +390 -797
- package/lib/stake.js.map +1 -1
- package/lib/stake.m.js +390 -795
- package/lib/stake.m.js.map +1 -1
- package/package.json +1 -1
- package/src/assets/solana/idl/liqsol_core.json +114 -377
- package/src/assets/solana/idl/validator_leaderboard.json +0 -146
- package/src/assets/solana/types/liqsol_core.ts +114 -377
- package/src/assets/solana/types/validator_leaderboard.ts +0 -146
- package/src/networks/ethereum/clients/opp.client.ts +20 -21
- package/src/networks/ethereum/clients/receipt.client.ts +8 -1
- package/src/networks/ethereum/contract.ts +40 -5
- package/src/networks/ethereum/ethereum.ts +148 -139
- package/src/networks/ethereum/types.ts +1 -2
- package/src/networks/solana/constants.ts +1 -1
- package/src/networks/solana/solana.ts +268 -220
- package/src/staker.ts +1 -1
|
@@ -84,34 +84,33 @@ export class OPPClient {
|
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
87
|
/**
|
|
91
88
|
* Fetches all OPPMessage events and flattens all assertions into a single OPPAssertion[] array.
|
|
92
89
|
*/
|
|
93
90
|
async getMessages(address: string): Promise<OPPAssertion[]> {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
91
|
+
try {
|
|
92
|
+
const oppMessageFilter = this.contract.OPP.filters.OPPMessage();
|
|
93
|
+
const events = await this.contract.OPP.queryFilter(oppMessageFilter, 0, "latest");
|
|
94
|
+
const allAssertions: OPPAssertion[] = [];
|
|
95
|
+
for (const event of events) {
|
|
96
|
+
const assertions = await this.extractAssertionsFromEvent(event);
|
|
97
|
+
allAssertions.push(...assertions);
|
|
98
|
+
}
|
|
101
99
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
100
|
+
// ! Current implementation is not ideal - no current way to filter OPP Messages by a single user
|
|
101
|
+
const normalized = address ? address.toLowerCase() : null;
|
|
102
|
+
const filtered = allAssertions.filter(a =>
|
|
103
|
+
(a.from && a.from.toLowerCase() === normalized) ||
|
|
104
|
+
(a.to && a.to.toLowerCase() === normalized)
|
|
105
|
+
);
|
|
106
|
+
return filtered.reverse();
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
// console.log('Error fetching OPP messages:', error);
|
|
110
|
+
return [];
|
|
111
|
+
}
|
|
109
112
|
}
|
|
110
113
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
114
|
/**
|
|
116
115
|
* Extracts all OPPAssertions from a single OPPMessage event, attaching event metadata to each.
|
|
117
116
|
*/
|
|
@@ -20,7 +20,14 @@ export class ReceiptClient {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
async stakeReceipts(address: string): Promise<preLaunchReceipt[]> {
|
|
23
|
-
|
|
23
|
+
try {
|
|
24
|
+
const receipts = await this.fetchPreLaunchReceipts(address, ReceiptNFTKind.STAKE);
|
|
25
|
+
return receipts;
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
// console.log('Error fetching stake receipts:', err);
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
24
31
|
}
|
|
25
32
|
|
|
26
33
|
async pretokenReceipts(address: string): Promise<preLaunchReceipt[]> {
|
|
@@ -54,6 +54,40 @@ export const ERC1155Abi = ERC1155Artifact.abi;
|
|
|
54
54
|
|
|
55
55
|
// Make sure ContractName in ./types includes all of these keys.
|
|
56
56
|
export const ADDRESSES: AddressBook = {
|
|
57
|
+
/**
|
|
58
|
+
* MAINNET LATEST
|
|
59
|
+
* 1/23/26
|
|
60
|
+
*/
|
|
61
|
+
// LiqEthAuthority: "0xB8fb7dBA2de501c94EAB723fa48679f698a39Aa4",
|
|
62
|
+
// BeaconState: "0x29719E8e76C52F5fD4888DF401579859c305f2DF",
|
|
63
|
+
// WithdrawalQueue: "0xce388339bFDAed9cAF536ea7b4F42123b4D755d4",
|
|
64
|
+
// LiqEthToken: "0x2C0e75e930Fc72ceD0725854C5E7A55566333F3f",
|
|
65
|
+
// Accounting: "0xE31C44d04c7B055afAC9301F55840f030eaF04BC",
|
|
66
|
+
// DepositManager: "0x21b339ED55A0f037f91B88044C808CcfCCBbF9A8",
|
|
67
|
+
// WithdrawalVault: "0x028743bE7E727aA331A1e952575cb00623B95fE2",
|
|
68
|
+
// StakingModule: "0xDe9754Fb58CcD4D74e94DA5682192E4e6eC334b0",
|
|
69
|
+
// YieldOracle: "0x7B7B8894e75b44B6cA7Dc8bE6dED5059621907b2",
|
|
70
|
+
|
|
71
|
+
// OutpostManagerAuthority: "0xeaE32b94c0F858b3600861aAE4Caeee6B6341751",
|
|
72
|
+
// iodata: "0x485Ed153c45189d623Bb37816eD3016A56552273",
|
|
73
|
+
// Base58: "0x8bB3856EC1114B1cE45a78620CF174D90a1Fd4e7",
|
|
74
|
+
// sysio_merkle: "0x5180a926D71c6d94c5c939Fe7Fed14cD7dcAa541",
|
|
75
|
+
// ReceiptNFT: "0x651De616A20b17De1095f9A0694A0e0E68025b78",
|
|
76
|
+
// EthUsdPriceConsumer: "0x2d866f8DB6F6c94997b0027Ba24bc64a03627ddc",
|
|
77
|
+
// Pool: "0xDA268Adcb90c422C2102A5f713182A42A8b9EA0D",
|
|
78
|
+
// OutpostManager: "0x9f279804Cb8539c53709AA37a4C1b30A52A85175",
|
|
79
|
+
// sysio_write: "0x3F8c880efd2c8C3aA1f0CE40b886cc6913eEC1d3",
|
|
80
|
+
// Pretoken: "0xCabF19Fdb7cD063738dd63a418702Ee3642FFc68",
|
|
81
|
+
// BAR: "0x2D8f4D4435509d7b8F93C3Ba93D45447C892f7ED",
|
|
82
|
+
// OPPCommon: "0x1716EEC9f1E0c1aF7BbbA8Fed10652138914f766",
|
|
83
|
+
// OPP: "0x5e1135cF8987268a3e7F68551558Ae92c454429f",
|
|
84
|
+
// Depositor: "0xf4b4ccfD684feB46504D77232FBde23b23d4F774",
|
|
85
|
+
// OPPInbound: "0x088484d45fF93AFabC63810FB0b335792E2B24f3"
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* HOODI TESTNET LATEST
|
|
89
|
+
* 1/23/26
|
|
90
|
+
*/
|
|
57
91
|
// LiqETH contracts
|
|
58
92
|
LiqEthAuthority: "0x3Eb66Bb91F7a022FbABc1619Cb6acce7025Bc41F",
|
|
59
93
|
BeaconState: "0x08F879c6D0964E0A17bF688Af23168f654DF372e",
|
|
@@ -64,7 +98,6 @@ export const ADDRESSES: AddressBook = {
|
|
|
64
98
|
WithdrawalVault: "0xbaBc0D5997283ab9886696A0dEaB8A8093436b48",
|
|
65
99
|
StakingModule: "0x4998fBb6Ca5Ee3Db6c339e2962A34791Af643fEa",
|
|
66
100
|
YieldOracle: "0x61Fe311C57dd9a38Fb7B0c5A8ec521452dB25378",
|
|
67
|
-
|
|
68
101
|
//Outpost contracts
|
|
69
102
|
OutpostManagerAuthority: "0x3B8705Ba1195AF632b3bd9E46F19348BC828FA3D",
|
|
70
103
|
iodata: "0x4aCABbC74a1cA9B0058d9ADAa0E00Af0f4f73212",
|
|
@@ -155,10 +188,6 @@ export const CONTRACTS: Contracts<ContractName> = {
|
|
|
155
188
|
address: ADDRESSES.ReceiptNFT,
|
|
156
189
|
abi: ReceiptNFTArtifact.abi as JsonFragment[],
|
|
157
190
|
},
|
|
158
|
-
MockAggregator: {
|
|
159
|
-
address: ADDRESSES.MockAggregator,
|
|
160
|
-
abi: AggregatorArtifact.abi as JsonFragment[],
|
|
161
|
-
},
|
|
162
191
|
Pool: {
|
|
163
192
|
address: ADDRESSES.Pool,
|
|
164
193
|
abi: PoolArtifact.abi as JsonFragment[],
|
|
@@ -199,8 +228,14 @@ export const CONTRACTS: Contracts<ContractName> = {
|
|
|
199
228
|
address: ADDRESSES.Depositor,
|
|
200
229
|
abi: DepositorArtifact.abi as JsonFragment[],
|
|
201
230
|
},
|
|
231
|
+
|
|
232
|
+
MockAggregator: {
|
|
233
|
+
address: ADDRESSES.MockAggregator,
|
|
234
|
+
abi: AggregatorArtifact.abi as JsonFragment[],
|
|
235
|
+
},
|
|
202
236
|
};
|
|
203
237
|
|
|
238
|
+
|
|
204
239
|
export interface ContractOptions {
|
|
205
240
|
/** RPC endpoint or injected EIP-1193 provider */
|
|
206
241
|
provider?: ethers.providers.Provider;
|
|
@@ -142,10 +142,10 @@ export class EthereumStakingClient implements IStakingClient {
|
|
|
142
142
|
const buyer = await this.signer!.getAddress();
|
|
143
143
|
|
|
144
144
|
// ! Hoodi only - check if the mock aggregator price is stale, and if so, update it before submitting the buy request
|
|
145
|
-
const network = await this.provider.getNetwork();
|
|
146
|
-
const chainId = network.chainId;
|
|
147
|
-
const allowedTestChains = new Set([560048]);
|
|
148
|
-
if (allowedTestChains.has(chainId)) await this.updateMockAggregatorPrice();
|
|
145
|
+
// const network = await this.provider.getNetwork();
|
|
146
|
+
// const chainId = network.chainId;
|
|
147
|
+
// const allowedTestChains = new Set([560048]);
|
|
148
|
+
// if (allowedTestChains.has(chainId)) await this.updateMockAggregatorPrice();
|
|
149
149
|
|
|
150
150
|
let result = await this.pretokenClient.purchasePretokensWithLiqETH(amount, buyer);
|
|
151
151
|
return result && result.txHash ? result.txHash : "Error - no resulting txHash";
|
|
@@ -160,100 +160,109 @@ export class EthereumStakingClient implements IStakingClient {
|
|
|
160
160
|
* tracked = liqETH tracked balance (protocol/accounting view)
|
|
161
161
|
*/
|
|
162
162
|
async getPortfolio(): Promise<Portfolio | null> {
|
|
163
|
-
if (!this.signer) return Promise.resolve(null);
|
|
164
163
|
|
|
165
|
-
|
|
164
|
+
try {
|
|
165
|
+
if (!this.signer) return Promise.resolve(null);
|
|
166
166
|
|
|
167
|
-
|
|
168
|
-
const nativeBalance = await this.provider.getBalance(walletAddress);
|
|
169
|
-
const nativeDecimals = this.network?.nativeCurrency?.decimals ?? 18;
|
|
170
|
-
const nativeSymbol = this.network?.nativeCurrency?.symbol ?? 'ETH';
|
|
167
|
+
const walletAddress = await this.signer!.getAddress();
|
|
171
168
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
169
|
+
// 1) Native ETH balance
|
|
170
|
+
const nativeBalance = await this.provider.getBalance(walletAddress);
|
|
171
|
+
const nativeDecimals = this.network?.nativeCurrency?.decimals ?? 18;
|
|
172
|
+
const nativeSymbol = this.network?.nativeCurrency?.symbol ?? 'ETH';
|
|
175
173
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
let stakeSharesBN = BigNumber.from(0);
|
|
183
|
-
for (let r of stakeReceipts) {
|
|
184
|
-
stakeSharesBN = stakeSharesBN.add(BigNumber.from(r.receipt.shares.amount));
|
|
185
|
-
}
|
|
174
|
+
// 2) liqETH ERC-20 balance (actual)
|
|
175
|
+
const liqBalance: ethers.BigNumber = await this.contract.LiqEthToken.balanceOf(walletAddress);
|
|
176
|
+
const liqSymbol = 'Liq' + (this.network?.nativeCurrency?.symbol ?? 'ETH');
|
|
177
|
+
|
|
178
|
+
// 3) staked liqEth ERC-20 balance (calculate from receipts)
|
|
179
|
+
let stakeReceipts = await this.receiptClient.stakeReceipts(walletAddress);
|
|
186
180
|
|
|
187
|
-
|
|
188
|
-
|
|
181
|
+
let stakeBalanceBN = BigNumber.from(0);
|
|
182
|
+
for (let r of stakeReceipts) {
|
|
183
|
+
stakeBalanceBN = stakeBalanceBN.add(BigNumber.from(r.receipt.principal.amount));
|
|
184
|
+
}
|
|
185
|
+
let stakeSharesBN = BigNumber.from(0);
|
|
186
|
+
for (let r of stakeReceipts) {
|
|
187
|
+
stakeSharesBN = stakeSharesBN.add(BigNumber.from(r.receipt.shares.amount));
|
|
188
|
+
}
|
|
189
189
|
|
|
190
|
+
// 4) WIRE pretoken balance
|
|
191
|
+
const wireBalance: ethers.BigNumber = await this.contract.Pretoken.balanceOf(walletAddress);
|
|
190
192
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
193
|
+
// 5) Calculate staking yield
|
|
194
|
+
let currentIndex = BigInt(0);
|
|
195
|
+
let totalShares = BigInt(0);
|
|
196
|
+
let userShares = BigInt(0);
|
|
197
|
+
const indexScale = BigInt(1e27);
|
|
198
|
+
try {
|
|
199
|
+
// These may throw if not implemented on contract
|
|
200
|
+
const [indexBn, totalSharesBn] = await Promise.all([
|
|
201
|
+
this.contract.Depositor.index().catch(() => BigNumber.from(0)),
|
|
202
|
+
this.contract.Depositor.totalShares().catch(() => BigNumber.from(0)),
|
|
203
|
+
]);
|
|
204
|
+
|
|
205
|
+
const userSharesBn = stakeSharesBN;
|
|
206
|
+
currentIndex = BigInt(indexBn.toString());
|
|
207
|
+
totalShares = BigInt(totalSharesBn.toString());
|
|
208
|
+
userShares = BigInt(userSharesBn.toString());
|
|
209
|
+
} catch (error) {
|
|
210
|
+
console.log('Error fetching staking index/shares:', error);
|
|
211
|
+
}
|
|
202
212
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
213
|
+
// sharesToTokens(userShares, currentIndex) = userShares * currentIndex / indexScale
|
|
214
|
+
let estimatedClaim = BigInt(0);
|
|
215
|
+
let estimatedYield = BigInt(0);
|
|
216
|
+
|
|
217
|
+
// started work on estimating the user's personal APY - not necessary at the moment
|
|
218
|
+
// let estimatedAPY: number | null = null;
|
|
219
|
+
// if (userShares > BigInt(0) && currentIndex > BigInt(0)) {
|
|
220
|
+
// estimatedClaim = (userShares * currentIndex) / indexScale;
|
|
221
|
+
// if (estimatedClaim > stakeBalanceBN.toBigInt()) {
|
|
222
|
+
// estimatedYield = estimatedClaim - stakeBalanceBN.toBigInt();
|
|
223
|
+
// }
|
|
224
|
+
|
|
225
|
+
// estimatedAPY = null;
|
|
226
|
+
// }
|
|
227
|
+
|
|
228
|
+
const portfolio: Portfolio = {
|
|
229
|
+
native: {
|
|
230
|
+
amount: nativeBalance.toBigInt(),
|
|
231
|
+
decimals: nativeDecimals,
|
|
232
|
+
symbol: nativeSymbol,
|
|
233
|
+
},
|
|
234
|
+
liq: {
|
|
235
|
+
amount: liqBalance.toBigInt(),
|
|
236
|
+
decimals: nativeDecimals,
|
|
237
|
+
symbol: liqSymbol,
|
|
238
|
+
},
|
|
239
|
+
staked: {
|
|
240
|
+
amount: stakeBalanceBN.toBigInt(),
|
|
241
|
+
decimals: nativeDecimals,
|
|
242
|
+
symbol: liqSymbol,
|
|
243
|
+
},
|
|
244
|
+
wire: {
|
|
245
|
+
amount: wireBalance.toBigInt(),
|
|
246
|
+
decimals: 18,
|
|
247
|
+
symbol: '$WIRE',
|
|
248
|
+
},
|
|
249
|
+
|
|
250
|
+
yield: {
|
|
251
|
+
currentIndex,
|
|
252
|
+
indexScale,
|
|
253
|
+
totalShares,
|
|
254
|
+
userShares,
|
|
255
|
+
estimatedClaim,
|
|
256
|
+
estimatedYield,
|
|
257
|
+
},
|
|
258
|
+
chainID: this.network.chainId
|
|
259
|
+
}
|
|
260
|
+
return portfolio;
|
|
261
|
+
}
|
|
262
|
+
catch (error) {
|
|
263
|
+
// console.log('Error fetching Ethereum portfolio:', error);
|
|
264
|
+
throw error;
|
|
255
265
|
}
|
|
256
|
-
return portfolio;
|
|
257
266
|
}
|
|
258
267
|
|
|
259
268
|
/**
|
|
@@ -339,7 +348,7 @@ export class EthereumStakingClient implements IStakingClient {
|
|
|
339
348
|
windowAfter?: number;
|
|
340
349
|
}): Promise<TrancheSnapshot> {
|
|
341
350
|
const {
|
|
342
|
-
chainID = EvmChainID.
|
|
351
|
+
chainID = EvmChainID.Ethereum,
|
|
343
352
|
windowBefore,
|
|
344
353
|
windowAfter,
|
|
345
354
|
} = options ?? {};
|
|
@@ -370,14 +379,14 @@ export class EthereumStakingClient implements IStakingClient {
|
|
|
370
379
|
|
|
371
380
|
|
|
372
381
|
// fetch price and timestamp from aggregator
|
|
373
|
-
const [roundId, answer, startedAt, updatedAt, answeredInRound] = await this.contract.MockAggregator.latestRoundData();
|
|
382
|
+
// const [roundId, answer, startedAt, updatedAt, answeredInRound] = await this.contract.MockAggregator.latestRoundData();
|
|
374
383
|
//originally fetched ethPrice from aggregator - pulling from EthUsdPriceConsumer instead - this is where the actual price gets pulled from when purchasing pretokens.
|
|
375
384
|
// let ethPriceUsd: bigint = BigInt(answer.toString());)
|
|
376
385
|
|
|
377
386
|
let ethPriceUsdBn = await this.contract.EthUsdPriceConsumer.getPrice18Decimals();
|
|
378
387
|
let ethPriceUsd: bigint = BigInt(ethPriceUsdBn.toString()) / BigInt(1e10);
|
|
379
388
|
|
|
380
|
-
let nativePriceTimestamp: number = Number(updatedAt);
|
|
389
|
+
// let nativePriceTimestamp: number = Number(updatedAt);
|
|
381
390
|
|
|
382
391
|
const initialTrancheSupply = BigInt(INITIAL_TRANCHE_SUPPLY) * BigInt(1e8);
|
|
383
392
|
|
|
@@ -396,7 +405,7 @@ export class EthereumStakingClient implements IStakingClient {
|
|
|
396
405
|
maxPriceUsd,
|
|
397
406
|
|
|
398
407
|
ethPriceUsd,
|
|
399
|
-
nativePriceTimestamp,
|
|
408
|
+
// nativePriceTimestamp,
|
|
400
409
|
ladderWindowBefore: windowBefore,
|
|
401
410
|
ladderWindowAfter: windowAfter,
|
|
402
411
|
});
|
|
@@ -422,7 +431,7 @@ export class EthereumStakingClient implements IStakingClient {
|
|
|
422
431
|
txCount?: number;
|
|
423
432
|
safetyMultiplier?: number;
|
|
424
433
|
minBufferWei?: bigint;
|
|
425
|
-
balanceOverrideLamports?: bigint;
|
|
434
|
+
balanceOverrideLamports?: bigint;
|
|
426
435
|
}): Promise<bigint> {
|
|
427
436
|
this.ensureUser();
|
|
428
437
|
|
|
@@ -482,49 +491,49 @@ export class EthereumStakingClient implements IStakingClient {
|
|
|
482
491
|
// ---------------------------------------------------------------------
|
|
483
492
|
|
|
484
493
|
// ! This is a temporary measure for Hoodi testnet because there is no aggregator deployed
|
|
485
|
-
private async updateMockAggregatorPrice() {
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
}
|
|
494
|
+
// private async updateMockAggregatorPrice() {
|
|
495
|
+
// const aggregator = this.contract.MockAggregator;
|
|
496
|
+
|
|
497
|
+
// // read latest round & compute age
|
|
498
|
+
// const [roundId, answer, startedAt, updatedAt, answeredInRound] = await aggregator.latestRoundData();
|
|
499
|
+
// const now = (await this.provider.getBlock("latest")).timestamp;
|
|
500
|
+
// const ageSec = Number(now) - Number(updatedAt);
|
|
501
|
+
|
|
502
|
+
// const ONE_HOUR = 1 * 3600;
|
|
503
|
+
// // const ONE_HOUR = 10;
|
|
504
|
+
// if (ageSec > ONE_HOUR) {
|
|
505
|
+
// // safety check - only run in non-production contexts
|
|
506
|
+
// const network = await this.provider.getNetwork();
|
|
507
|
+
// const chainId = network.chainId;
|
|
508
|
+
// const allowedTestChains = new Set([560048]);
|
|
509
|
+
// if (!allowedTestChains.has(chainId)) {
|
|
510
|
+
// console.warn(`MockAggregator is stale (${ageSec}s) but chainId ${chainId} is not a test/local network — skipping update.`);
|
|
511
|
+
// return;
|
|
512
|
+
// }
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
// //fetch the current ETH / USD price
|
|
516
|
+
// const res = await fetch('https://api.coingecko.com/api/v3/simple/price?ids=ethereum&vs_currencies=usd');
|
|
517
|
+
// const data = await res.json();
|
|
518
|
+
// const ethUsd = data.ethereum.usd;
|
|
519
|
+
|
|
520
|
+
// const currentEthPrice = ethers.utils.parseUnits(ethUsd.toString(), 8);
|
|
521
|
+
|
|
522
|
+
// try {
|
|
523
|
+
// //update to be intentionally stale
|
|
524
|
+
// // const alttx = await aggregator.updateStale(currentEthPrice, now - 7200);
|
|
525
|
+
// // const altreceipt = await alttx.wait(1);
|
|
526
|
+
// // console.log('stale update receipt', altreceipt)
|
|
527
|
+
|
|
528
|
+
// //update answer with current timestamp
|
|
529
|
+
// const tx = await aggregator.updateAnswer(currentEthPrice);
|
|
530
|
+
// const txreceipt = await tx.wait(1);
|
|
531
|
+
// // console.log('MockAggregator answer updated - receipt:', txreceipt)
|
|
532
|
+
// } catch (err: any) {
|
|
533
|
+
// console.error('MockAggregator updateAnswer failed', err?.message || err);
|
|
534
|
+
// }
|
|
535
|
+
// } else {
|
|
536
|
+
// console.log(`MockAggregator updated ${ageSec}s ago — no update needed`);
|
|
537
|
+
// }
|
|
538
|
+
// }
|
|
530
539
|
}
|
|
@@ -19,7 +19,6 @@ export const CONTRACT_NAMES = [
|
|
|
19
19
|
"Base58",
|
|
20
20
|
"sysio_merkle",
|
|
21
21
|
"ReceiptNFT",
|
|
22
|
-
"MockAggregator",
|
|
23
22
|
"Pool",
|
|
24
23
|
"OutpostManager",
|
|
25
24
|
"sysio_write",
|
|
@@ -30,7 +29,7 @@ export const CONTRACT_NAMES = [
|
|
|
30
29
|
"Pretoken",
|
|
31
30
|
"OPPInbound",
|
|
32
31
|
"Depositor",
|
|
33
|
-
|
|
32
|
+
"MockAggregator",
|
|
34
33
|
] as const;
|
|
35
34
|
|
|
36
35
|
export type ContractName = typeof CONTRACT_NAMES[number];
|
|
@@ -355,7 +355,7 @@ export const deriveEphemeralStakeAddress = async (
|
|
|
355
355
|
* Constant keys (Chainlink)
|
|
356
356
|
*/
|
|
357
357
|
export const CHAINLINK_FEED = new PublicKey(
|
|
358
|
-
'
|
|
358
|
+
'CH31Xns5z3M1cTAbKW34jcxPPciazARpijcHj9rxtemt',
|
|
359
359
|
);
|
|
360
360
|
export const CHAINLINK_PROGRAM = new PublicKey(
|
|
361
361
|
'HEvSKofvBgfaexv23kMabbYqxasxU3mQ4ibBMEmJWHny',
|