@strkfarm/sdk 2.0.0-dev.43 → 2.0.0-dev.45
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/dist/cli.js +2 -2
- package/dist/cli.mjs +2 -2
- package/dist/index.browser.global.js +26404 -25513
- package/dist/index.browser.mjs +854 -559
- package/dist/index.d.ts +51 -6
- package/dist/index.js +889 -591
- package/dist/index.mjs +859 -562
- package/package.json +72 -14
- package/src/global.ts +219 -230
- package/src/interfaces/common.tsx +10 -0
- package/src/modules/ekubo-pricer.ts +2 -1
- package/src/modules/pricer.ts +27 -15
- package/src/modules/zkLend.ts +3 -2
- package/src/strategies/universal-lst-muliplier-strategy.tsx +294 -20
- package/src/strategies/yoloVault.ts +2 -0
package/dist/index.browser.mjs
CHANGED
|
@@ -145,7 +145,7 @@ var ContractAddr = class _ContractAddr {
|
|
|
145
145
|
// src/dataTypes/mynumber.ts
|
|
146
146
|
import BigNumber2 from "bignumber.js";
|
|
147
147
|
import { ethers } from "ethers";
|
|
148
|
-
var customInspectSymbol =
|
|
148
|
+
var customInspectSymbol = Symbol.for("nodejs.util.inspect.custom");
|
|
149
149
|
BigNumber2.config({
|
|
150
150
|
DECIMAL_PLACES: 18
|
|
151
151
|
});
|
|
@@ -154,16 +154,16 @@ var MyNumber = class _MyNumber {
|
|
|
154
154
|
this.bigNumber = new BigNumber2(bigNumber);
|
|
155
155
|
this.decimals = decimals;
|
|
156
156
|
}
|
|
157
|
-
static fromEther(
|
|
157
|
+
static fromEther(num16, decimals) {
|
|
158
158
|
try {
|
|
159
159
|
return new _MyNumber(
|
|
160
160
|
Number(
|
|
161
|
-
ethers.parseUnits(Number(
|
|
161
|
+
ethers.parseUnits(Number(num16).toFixed(10), decimals)
|
|
162
162
|
).toFixed(6),
|
|
163
163
|
decimals
|
|
164
164
|
);
|
|
165
165
|
} catch (e) {
|
|
166
|
-
console.error("fromEther", e,
|
|
166
|
+
console.error("fromEther", e, num16, decimals);
|
|
167
167
|
throw e;
|
|
168
168
|
}
|
|
169
169
|
}
|
|
@@ -276,283 +276,510 @@ function configureLogger(_config = {}) {
|
|
|
276
276
|
return logger;
|
|
277
277
|
}
|
|
278
278
|
|
|
279
|
+
// src/interfaces/lending.ts
|
|
280
|
+
var MarginType = /* @__PURE__ */ ((MarginType2) => {
|
|
281
|
+
MarginType2["SHARED"] = "shared";
|
|
282
|
+
MarginType2["NONE"] = "none";
|
|
283
|
+
return MarginType2;
|
|
284
|
+
})(MarginType || {});
|
|
285
|
+
var ILending = class {
|
|
286
|
+
constructor(config, metadata) {
|
|
287
|
+
this.tokens = [];
|
|
288
|
+
this.initialised = false;
|
|
289
|
+
this.metadata = metadata;
|
|
290
|
+
this.config = config;
|
|
291
|
+
this.init();
|
|
292
|
+
}
|
|
293
|
+
/** Wait for initialisation */
|
|
294
|
+
waitForInitilisation() {
|
|
295
|
+
return new Promise((resolve, reject) => {
|
|
296
|
+
const interval = setInterval(() => {
|
|
297
|
+
logger.verbose(`Waiting for ${this.metadata.name} to initialise`);
|
|
298
|
+
if (this.initialised) {
|
|
299
|
+
logger.verbose(`${this.metadata.name} initialised`);
|
|
300
|
+
clearInterval(interval);
|
|
301
|
+
resolve();
|
|
302
|
+
}
|
|
303
|
+
}, 1e3);
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
// src/interfaces/common.tsx
|
|
309
|
+
import { BlockTag, RpcProvider } from "starknet";
|
|
310
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
311
|
+
var RiskType = /* @__PURE__ */ ((RiskType2) => {
|
|
312
|
+
RiskType2["MARKET_RISK"] = "Market Risk";
|
|
313
|
+
RiskType2["IMPERMANENT_LOSS"] = "Impermanent Loss Risk";
|
|
314
|
+
RiskType2["LIQUIDATION_RISK"] = "Liquidation Risk";
|
|
315
|
+
RiskType2["LOW_LIQUIDITY_RISK"] = "Low Liquidity Risk";
|
|
316
|
+
RiskType2["SMART_CONTRACT_RISK"] = "Smart Contract Risk";
|
|
317
|
+
RiskType2["ORACLE_RISK"] = "Oracle Risk";
|
|
318
|
+
RiskType2["TECHNICAL_RISK"] = "Technical Risk";
|
|
319
|
+
RiskType2["COUNTERPARTY_RISK"] = "Counterparty Risk";
|
|
320
|
+
RiskType2["DEPEG_RISK"] = "Depeg Risk";
|
|
321
|
+
return RiskType2;
|
|
322
|
+
})(RiskType || {});
|
|
323
|
+
var TokenIndexingType = /* @__PURE__ */ ((TokenIndexingType2) => {
|
|
324
|
+
TokenIndexingType2["PEGGED"] = "pegged";
|
|
325
|
+
TokenIndexingType2["INDEXER"] = "indexer";
|
|
326
|
+
TokenIndexingType2["LST_SCRIPT"] = "lstScript";
|
|
327
|
+
TokenIndexingType2["IGNORE"] = "ignore";
|
|
328
|
+
return TokenIndexingType2;
|
|
329
|
+
})(TokenIndexingType || {});
|
|
330
|
+
var Network = /* @__PURE__ */ ((Network2) => {
|
|
331
|
+
Network2["mainnet"] = "mainnet";
|
|
332
|
+
Network2["sepolia"] = "sepolia";
|
|
333
|
+
Network2["devnet"] = "devnet";
|
|
334
|
+
return Network2;
|
|
335
|
+
})(Network || {});
|
|
336
|
+
var StrategyTag = /* @__PURE__ */ ((StrategyTag3) => {
|
|
337
|
+
StrategyTag3["META_VAULT"] = "Meta Vaults";
|
|
338
|
+
StrategyTag3["LEVERED"] = "Maxx";
|
|
339
|
+
StrategyTag3["AUTOMATED_LP"] = "Ekubo";
|
|
340
|
+
StrategyTag3["BTC"] = "BTC";
|
|
341
|
+
return StrategyTag3;
|
|
342
|
+
})(StrategyTag || {});
|
|
343
|
+
var VaultType = /* @__PURE__ */ ((VaultType2) => {
|
|
344
|
+
VaultType2["LOOPING"] = "Looping";
|
|
345
|
+
VaultType2["META_VAULT"] = "Meta Vault";
|
|
346
|
+
VaultType2["DELTA_NEUTRAL"] = "Delta Neutral";
|
|
347
|
+
VaultType2["AUTOMATED_LP"] = "Automated LP";
|
|
348
|
+
VaultType2["TVA"] = "Troves Value Averaging";
|
|
349
|
+
return VaultType2;
|
|
350
|
+
})(VaultType || {});
|
|
351
|
+
var AuditStatus = /* @__PURE__ */ ((AuditStatus2) => {
|
|
352
|
+
AuditStatus2["AUDITED"] = "Audited";
|
|
353
|
+
AuditStatus2["NOT_AUDITED"] = "Not Audited";
|
|
354
|
+
return AuditStatus2;
|
|
355
|
+
})(AuditStatus || {});
|
|
356
|
+
var SourceCodeType = /* @__PURE__ */ ((SourceCodeType2) => {
|
|
357
|
+
SourceCodeType2["OPEN_SOURCE"] = "Open Source";
|
|
358
|
+
SourceCodeType2["CLOSED_SOURCE"] = "Closed Source";
|
|
359
|
+
return SourceCodeType2;
|
|
360
|
+
})(SourceCodeType || {});
|
|
361
|
+
var AccessControlType = /* @__PURE__ */ ((AccessControlType2) => {
|
|
362
|
+
AccessControlType2["MULTISIG_ACCOUNT"] = "Multisig Account";
|
|
363
|
+
AccessControlType2["STANDARD_ACCOUNT"] = "Standard Account";
|
|
364
|
+
AccessControlType2["ROLE_BASED_ACCESS"] = "Role Based Access";
|
|
365
|
+
return AccessControlType2;
|
|
366
|
+
})(AccessControlType || {});
|
|
367
|
+
var InstantWithdrawalVault = /* @__PURE__ */ ((InstantWithdrawalVault2) => {
|
|
368
|
+
InstantWithdrawalVault2["YES"] = "Yes";
|
|
369
|
+
InstantWithdrawalVault2["NO"] = "No";
|
|
370
|
+
return InstantWithdrawalVault2;
|
|
371
|
+
})(InstantWithdrawalVault || {});
|
|
372
|
+
var FlowChartColors = /* @__PURE__ */ ((FlowChartColors2) => {
|
|
373
|
+
FlowChartColors2["Green"] = "purple";
|
|
374
|
+
FlowChartColors2["Blue"] = "#35484f";
|
|
375
|
+
FlowChartColors2["Purple"] = "#6e53dc";
|
|
376
|
+
return FlowChartColors2;
|
|
377
|
+
})(FlowChartColors || {});
|
|
378
|
+
var StrategyLiveStatus = /* @__PURE__ */ ((StrategyLiveStatus2) => {
|
|
379
|
+
StrategyLiveStatus2["ACTIVE"] = "Active";
|
|
380
|
+
StrategyLiveStatus2["NEW"] = "New";
|
|
381
|
+
StrategyLiveStatus2["COMING_SOON"] = "Coming Soon";
|
|
382
|
+
StrategyLiveStatus2["DEPRECATED"] = "Deprecated";
|
|
383
|
+
StrategyLiveStatus2["RETIRED"] = "Retired";
|
|
384
|
+
StrategyLiveStatus2["HOT"] = "Hot & New \u{1F525}";
|
|
385
|
+
return StrategyLiveStatus2;
|
|
386
|
+
})(StrategyLiveStatus || {});
|
|
387
|
+
function getMainnetConfig(rpcUrl = "https://starknet-mainnet.public.blastapi.io", blockIdentifier = BlockTag.LATEST) {
|
|
388
|
+
return {
|
|
389
|
+
provider: new RpcProvider({
|
|
390
|
+
nodeUrl: rpcUrl,
|
|
391
|
+
blockIdentifier
|
|
392
|
+
// specVersion
|
|
393
|
+
}),
|
|
394
|
+
stage: "production",
|
|
395
|
+
network: "mainnet" /* mainnet */
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
var getStrategyTagDesciption = (tag) => {
|
|
399
|
+
switch (tag) {
|
|
400
|
+
case "Meta Vaults" /* META_VAULT */:
|
|
401
|
+
return "A meta vault is a vault that auto allocates funds to multiple vaults based on optimal yield opportunities";
|
|
402
|
+
case "Maxx" /* LEVERED */:
|
|
403
|
+
return "Looping vaults on Endur LSTs with leveraged borrowing of STRK or BTC to increase yield (2-4x higher yield than simply staking)";
|
|
404
|
+
case "Ekubo" /* AUTOMATED_LP */:
|
|
405
|
+
return "Automated LP vaults on Ekubo that rebalance position automatically, ensuring you earn fees efficiently";
|
|
406
|
+
case "BTC" /* BTC */:
|
|
407
|
+
return "BTC linked vaults";
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
var getAllStrategyTags = () => {
|
|
411
|
+
return Object.values(StrategyTag);
|
|
412
|
+
};
|
|
413
|
+
var getRiskExplaination = (riskType) => {
|
|
414
|
+
switch (riskType) {
|
|
415
|
+
case "Market Risk" /* MARKET_RISK */:
|
|
416
|
+
return "The risk of the market moving against the position.";
|
|
417
|
+
case "Impermanent Loss Risk" /* IMPERMANENT_LOSS */:
|
|
418
|
+
return "The temporary loss of value experienced by liquidity providers in AMMs when asset prices diverge compared to simply holding them.";
|
|
419
|
+
case "Liquidation Risk" /* LIQUIDATION_RISK */:
|
|
420
|
+
return "The risk of losing funds due to the position being liquidated.";
|
|
421
|
+
case "Low Liquidity Risk" /* LOW_LIQUIDITY_RISK */:
|
|
422
|
+
return "The risk of low liquidity in the pool, which can lead to high slippages or reduced in-abilities to quickly exit the position.";
|
|
423
|
+
case "Oracle Risk" /* ORACLE_RISK */:
|
|
424
|
+
return "The risk of the oracle being manipulated or incorrect.";
|
|
425
|
+
case "Smart Contract Risk" /* SMART_CONTRACT_RISK */:
|
|
426
|
+
return "The risk of the smart contract being vulnerable to attacks.";
|
|
427
|
+
case "Technical Risk" /* TECHNICAL_RISK */:
|
|
428
|
+
return "The risk of technical issues e.g. backend failure.";
|
|
429
|
+
case "Counterparty Risk" /* COUNTERPARTY_RISK */:
|
|
430
|
+
return "The risk of the counterparty defaulting e.g. bad debt on lending platforms.";
|
|
431
|
+
case "Depeg Risk" /* DEPEG_RISK */:
|
|
432
|
+
return "The risk of a token losing its peg to the underlying asset, leading to potential losses for holders.";
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
var getRiskColor = (risk) => {
|
|
436
|
+
const value = risk.value;
|
|
437
|
+
if (value <= 2) return "light_green_2";
|
|
438
|
+
if (value < 3) return "yellow";
|
|
439
|
+
return "red";
|
|
440
|
+
};
|
|
441
|
+
var getNoRiskTags = (risks) => {
|
|
442
|
+
const noRisks1 = risks.filter((risk) => risk.value === 0).map((risk) => risk.type);
|
|
443
|
+
const noRisks2 = Object.values(RiskType).filter(
|
|
444
|
+
(risk) => !risks.map((risk2) => risk2.type).includes(risk)
|
|
445
|
+
);
|
|
446
|
+
const mergedUnique = [.../* @__PURE__ */ new Set([...noRisks1, ...noRisks2])];
|
|
447
|
+
return mergedUnique;
|
|
448
|
+
};
|
|
449
|
+
function highlightTextWithLinks(put, highlights) {
|
|
450
|
+
const escapeRegExp = (text) => text.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
451
|
+
const pattern = new RegExp(
|
|
452
|
+
`(${highlights.map((m) => escapeRegExp(m.highlight)).join("|")})`,
|
|
453
|
+
"gi"
|
|
454
|
+
);
|
|
455
|
+
const parts = put.split(pattern);
|
|
456
|
+
return /* @__PURE__ */ jsx(Fragment, { children: parts.map((part, i) => {
|
|
457
|
+
const match = highlights.find((m) => m.highlight.toLowerCase() === part.toLowerCase());
|
|
458
|
+
return match ? /* @__PURE__ */ jsx("a", { href: match.link, target: "_blank", style: { color: "white", background: "rgba(255, 255, 255, 0.04)" }, children: part }, i) : /* @__PURE__ */ jsx("span", { children: part }, i);
|
|
459
|
+
}) });
|
|
460
|
+
}
|
|
461
|
+
var VesuProtocol = {
|
|
462
|
+
name: "Vesu",
|
|
463
|
+
logo: "https://static-assets-8zct.onrender.com/integrations/vesu/logo.png"
|
|
464
|
+
};
|
|
465
|
+
var AvnuProtocol = {
|
|
466
|
+
name: "Avnu",
|
|
467
|
+
logo: "https://static-assets-8zct.onrender.com/integrations/avnu/logo.png"
|
|
468
|
+
};
|
|
469
|
+
var EndurProtocol = {
|
|
470
|
+
name: "Endur",
|
|
471
|
+
logo: "http://endur.fi/logo.png"
|
|
472
|
+
};
|
|
473
|
+
var ExtendedProtocol = {
|
|
474
|
+
name: "Extended",
|
|
475
|
+
logo: "https://static-assets-8zct.onrender.com/integrations/extended/extended.svg"
|
|
476
|
+
};
|
|
477
|
+
var EkuboProtocol = {
|
|
478
|
+
name: "Ekubo",
|
|
479
|
+
logo: "https://app.ekubo.org/favicon.ico"
|
|
480
|
+
};
|
|
481
|
+
var NoneProtocol = {
|
|
482
|
+
name: "-",
|
|
483
|
+
logo: ""
|
|
484
|
+
};
|
|
485
|
+
var VaultProtocol = {
|
|
486
|
+
name: "Vault",
|
|
487
|
+
logo: ""
|
|
488
|
+
};
|
|
489
|
+
var TrovesProtocol = {
|
|
490
|
+
name: "Troves",
|
|
491
|
+
logo: "https://app.troves.fi/favicon.ico"
|
|
492
|
+
};
|
|
493
|
+
var Protocols = {
|
|
494
|
+
NONE: NoneProtocol,
|
|
495
|
+
VESU: VesuProtocol,
|
|
496
|
+
ENDUR: EndurProtocol,
|
|
497
|
+
EXTENDED: ExtendedProtocol,
|
|
498
|
+
EKUBO: EkuboProtocol,
|
|
499
|
+
AVNU: AvnuProtocol,
|
|
500
|
+
VAULT: VaultProtocol,
|
|
501
|
+
TROVES: TrovesProtocol
|
|
502
|
+
};
|
|
503
|
+
var UnwrapLabsCurator = {
|
|
504
|
+
name: "Unwrap Labs",
|
|
505
|
+
logo: "https://assets.troves.fi/integrations/unwraplabs/white.png"
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
// src/interfaces/initializable.ts
|
|
509
|
+
var Initializable = class {
|
|
510
|
+
constructor() {
|
|
511
|
+
this.initialized = false;
|
|
512
|
+
}
|
|
513
|
+
async waitForInitilisation() {
|
|
514
|
+
return new Promise((resolve, reject) => {
|
|
515
|
+
const interval = setInterval(() => {
|
|
516
|
+
if (this.initialized) {
|
|
517
|
+
console.log("Initialised");
|
|
518
|
+
clearInterval(interval);
|
|
519
|
+
resolve();
|
|
520
|
+
}
|
|
521
|
+
}, 1e3);
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
|
|
279
526
|
// src/global.ts
|
|
280
527
|
var FatalError = class extends Error {
|
|
281
528
|
constructor(message, err) {
|
|
282
529
|
super(message);
|
|
283
530
|
logger.error(message);
|
|
284
|
-
if (err)
|
|
531
|
+
if (err)
|
|
532
|
+
logger.error(err.message);
|
|
285
533
|
this.name = "FatalError";
|
|
286
534
|
}
|
|
287
535
|
};
|
|
288
|
-
var defaultTokens = [
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
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
|
-
symbol: "strkBTC",
|
|
529
|
-
logo: "https://assets.troves.fi/integrations/tokens/strkbtc.svg",
|
|
530
|
-
address: ContractAddr.from("0x0787150e306e6eae6e3f79dea881770e8bbff2c1b8eb490f969669ee945b3135"),
|
|
531
|
-
decimals: 8,
|
|
532
|
-
coingeckId: void 0,
|
|
533
|
-
displayDecimals: 6,
|
|
534
|
-
priceCheckAmount: 1e-3,
|
|
535
|
-
// 112000 * 0.0001 = $110.2
|
|
536
|
-
priceProxySymbol: "WBTC"
|
|
537
|
-
},
|
|
538
|
-
{
|
|
539
|
-
name: "xstrkBTC",
|
|
540
|
-
symbol: "xstrkBTC",
|
|
541
|
-
logo: "https://assets.troves.fi/integrations/tokens/xstrkbtc.svg",
|
|
542
|
-
address: ContractAddr.from("0x047751b3532fabca89b0f2e35ca1cb45e5a7b11d5e3d3663dfa1f4406b45fd88"),
|
|
543
|
-
decimals: 8,
|
|
544
|
-
coingeckId: void 0,
|
|
545
|
-
displayDecimals: 6,
|
|
546
|
-
priceCheckAmount: 1e-3,
|
|
547
|
-
priceProxySymbol: "WBTC"
|
|
548
|
-
}
|
|
549
|
-
];
|
|
536
|
+
var defaultTokens = [{
|
|
537
|
+
name: "Starknet",
|
|
538
|
+
symbol: "STRK",
|
|
539
|
+
logo: "https://assets.troves.fi/integrations/tokens/strk.svg",
|
|
540
|
+
address: ContractAddr.from("0x4718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d"),
|
|
541
|
+
decimals: 18,
|
|
542
|
+
coingeckId: "starknet",
|
|
543
|
+
displayDecimals: 2,
|
|
544
|
+
priceCheckAmount: 5e3,
|
|
545
|
+
priceMethod: "Avnu",
|
|
546
|
+
indexingType: "indexer" /* INDEXER */
|
|
547
|
+
}, {
|
|
548
|
+
name: "xSTRK",
|
|
549
|
+
symbol: "xSTRK",
|
|
550
|
+
logo: "https://assets.troves.fi/integrations/tokens/xstrk.svg",
|
|
551
|
+
address: ContractAddr.from("0x028d709c875c0ceac3dce7065bec5328186dc89fe254527084d1689910954b0a"),
|
|
552
|
+
decimals: 18,
|
|
553
|
+
coingeckId: void 0,
|
|
554
|
+
priceCheckAmount: 5e3,
|
|
555
|
+
displayDecimals: 2,
|
|
556
|
+
priceMethod: "Avnu",
|
|
557
|
+
indexingType: "lstScript" /* LST_SCRIPT */
|
|
558
|
+
}, {
|
|
559
|
+
name: "ETH",
|
|
560
|
+
symbol: "ETH",
|
|
561
|
+
logo: "https://assets.troves.fi/integrations/tokens/eth.svg",
|
|
562
|
+
address: ContractAddr.from("0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"),
|
|
563
|
+
decimals: 18,
|
|
564
|
+
coingeckId: void 0,
|
|
565
|
+
priceCheckAmount: 0.1,
|
|
566
|
+
displayDecimals: 6,
|
|
567
|
+
indexingType: "indexer" /* INDEXER */
|
|
568
|
+
}, {
|
|
569
|
+
name: "USDC.e",
|
|
570
|
+
symbol: "USDC.e",
|
|
571
|
+
logo: "https://assets.troves.fi/integrations/tokens/usdc.svg",
|
|
572
|
+
address: ContractAddr.from("0x53c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8"),
|
|
573
|
+
decimals: 6,
|
|
574
|
+
coingeckId: void 0,
|
|
575
|
+
displayDecimals: 2,
|
|
576
|
+
priceCheckAmount: 1e3,
|
|
577
|
+
priceProxySymbol: "USDC",
|
|
578
|
+
indexingType: "pegged" /* PEGGED */
|
|
579
|
+
}, {
|
|
580
|
+
name: "USDC",
|
|
581
|
+
symbol: "USDC",
|
|
582
|
+
logo: "https://assets.troves.fi/integrations/tokens/usdc.svg",
|
|
583
|
+
address: ContractAddr.from("0x033068F6539f8e6e6b131e6B2B814e6c34A5224bC66947c47DaB9dFeE93b35fb"),
|
|
584
|
+
decimals: 6,
|
|
585
|
+
coingeckId: void 0,
|
|
586
|
+
displayDecimals: 2,
|
|
587
|
+
priceCheckAmount: 1e3,
|
|
588
|
+
indexingType: "indexer" /* INDEXER */
|
|
589
|
+
}, {
|
|
590
|
+
name: "USDT",
|
|
591
|
+
symbol: "USDT",
|
|
592
|
+
logo: "https://assets.troves.fi/integrations/tokens/usdt.svg",
|
|
593
|
+
address: ContractAddr.from("0x68f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8"),
|
|
594
|
+
decimals: 6,
|
|
595
|
+
coingeckId: void 0,
|
|
596
|
+
priceCheckAmount: 1e3,
|
|
597
|
+
displayDecimals: 2,
|
|
598
|
+
indexingType: "indexer" /* INDEXER */
|
|
599
|
+
}, {
|
|
600
|
+
name: "WBTC",
|
|
601
|
+
symbol: "WBTC",
|
|
602
|
+
logo: "https://assets.troves.fi/integrations/tokens/wbtc.svg",
|
|
603
|
+
address: ContractAddr.from("0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac"),
|
|
604
|
+
decimals: 8,
|
|
605
|
+
coingeckId: void 0,
|
|
606
|
+
displayDecimals: 6,
|
|
607
|
+
priceCheckAmount: 1e-3,
|
|
608
|
+
// 112000 * 0.0001 = $110.2
|
|
609
|
+
indexingType: "indexer" /* INDEXER */
|
|
610
|
+
}, {
|
|
611
|
+
name: "tBTC",
|
|
612
|
+
symbol: "tBTC",
|
|
613
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/tbtc.svg",
|
|
614
|
+
address: ContractAddr.from("0x4daa17763b286d1e59b97c283c0b8c949994c361e426a28f743c67bdfe9a32f"),
|
|
615
|
+
decimals: 18,
|
|
616
|
+
coingeckId: void 0,
|
|
617
|
+
displayDecimals: 6,
|
|
618
|
+
priceCheckAmount: 1e-3,
|
|
619
|
+
// 112000 * 0.0001 = $110.2
|
|
620
|
+
priceProxySymbol: "WBTC",
|
|
621
|
+
indexingType: "pegged" /* PEGGED */
|
|
622
|
+
}, {
|
|
623
|
+
name: "solvBTC",
|
|
624
|
+
symbol: "solvBTC",
|
|
625
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/solvbtc.svg",
|
|
626
|
+
address: ContractAddr.from("0x0593e034dda23eea82d2ba9a30960ed42cf4a01502cc2351dc9b9881f9931a68"),
|
|
627
|
+
decimals: 18,
|
|
628
|
+
coingeckId: void 0,
|
|
629
|
+
priceProxySymbol: "WBTC",
|
|
630
|
+
displayDecimals: 6,
|
|
631
|
+
priceCheckAmount: 1e-4,
|
|
632
|
+
// 112000 * 0.0001 = $11.2
|
|
633
|
+
indexingType: "pegged" /* PEGGED */
|
|
634
|
+
}, {
|
|
635
|
+
name: "LBTC",
|
|
636
|
+
symbol: "LBTC",
|
|
637
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/lbtc.svg",
|
|
638
|
+
address: ContractAddr.from("0x036834a40984312f7f7de8d31e3f6305b325389eaeea5b1c0664b2fb936461a4"),
|
|
639
|
+
decimals: 8,
|
|
640
|
+
coingeckId: void 0,
|
|
641
|
+
displayDecimals: 6,
|
|
642
|
+
priceProxySymbol: "WBTC",
|
|
643
|
+
priceCheckAmount: 1e-4,
|
|
644
|
+
// 112000 * 0.0001 = $11.2
|
|
645
|
+
indexingType: "pegged" /* PEGGED */
|
|
646
|
+
}, {
|
|
647
|
+
name: "xWBTC",
|
|
648
|
+
symbol: "xWBTC",
|
|
649
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/xwbtc.svg",
|
|
650
|
+
address: ContractAddr.from("0x6a567e68c805323525fe1649adb80b03cddf92c23d2629a6779f54192dffc13"),
|
|
651
|
+
decimals: 8,
|
|
652
|
+
coingeckId: void 0,
|
|
653
|
+
displayDecimals: 6,
|
|
654
|
+
priceCheckAmount: 1e-3,
|
|
655
|
+
// 112000 * 0.0001 = $110.2
|
|
656
|
+
priceMethod: "Avnu",
|
|
657
|
+
indexingType: "lstScript" /* LST_SCRIPT */
|
|
658
|
+
}, {
|
|
659
|
+
name: "xsBTC",
|
|
660
|
+
symbol: "xsBTC",
|
|
661
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/xsbtc_solv.svg",
|
|
662
|
+
address: ContractAddr.from("0x580f3dc564a7b82f21d40d404b3842d490ae7205e6ac07b1b7af2b4a5183dc9"),
|
|
663
|
+
decimals: 18,
|
|
664
|
+
coingeckId: void 0,
|
|
665
|
+
displayDecimals: 6,
|
|
666
|
+
priceCheckAmount: 1e-4,
|
|
667
|
+
// 112000 * 0.0001 = $11.2
|
|
668
|
+
priceMethod: "Avnu",
|
|
669
|
+
indexingType: "lstScript" /* LST_SCRIPT */
|
|
670
|
+
}, {
|
|
671
|
+
name: "xtBTC",
|
|
672
|
+
symbol: "xtBTC",
|
|
673
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/xtbtc.svg",
|
|
674
|
+
address: ContractAddr.from("0x43a35c1425a0125ef8c171f1a75c6f31ef8648edcc8324b55ce1917db3f9b91"),
|
|
675
|
+
decimals: 18,
|
|
676
|
+
coingeckId: void 0,
|
|
677
|
+
displayDecimals: 6,
|
|
678
|
+
priceCheckAmount: 1e-3,
|
|
679
|
+
// 112000 * 0.0001 = $110.2
|
|
680
|
+
priceMethod: "Avnu",
|
|
681
|
+
indexingType: "lstScript" /* LST_SCRIPT */
|
|
682
|
+
}, {
|
|
683
|
+
name: "xLBTC",
|
|
684
|
+
symbol: "xLBTC",
|
|
685
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/xlbtc.svg",
|
|
686
|
+
address: ContractAddr.from("0x07dd3c80de9fcc5545f0cb83678826819c79619ed7992cc06ff81fc67cd2efe0"),
|
|
687
|
+
decimals: 8,
|
|
688
|
+
coingeckId: void 0,
|
|
689
|
+
displayDecimals: 6,
|
|
690
|
+
priceCheckAmount: 1e-4,
|
|
691
|
+
// 112000 * 0.0001 = $11.2
|
|
692
|
+
priceMethod: "Avnu",
|
|
693
|
+
indexingType: "lstScript" /* LST_SCRIPT */
|
|
694
|
+
}, {
|
|
695
|
+
name: "mRe7BTC",
|
|
696
|
+
symbol: "mRe7BTC",
|
|
697
|
+
logo: "https://imagedelivery.net/0xPAQaDtnQhBs8IzYRIlNg/3a62ecee-1e58-45d3-9862-3ce90dff1900/logo",
|
|
698
|
+
address: ContractAddr.from("0x4e4fb1a9ca7e84bae609b9dc0078ad7719e49187ae7e425bb47d131710eddac"),
|
|
699
|
+
decimals: 18,
|
|
700
|
+
coingeckId: void 0,
|
|
701
|
+
displayDecimals: 6,
|
|
702
|
+
priceCheckAmount: 1e-4,
|
|
703
|
+
// 112000 * 0.0001 = $11.2
|
|
704
|
+
dontPrice: true,
|
|
705
|
+
indexingType: "ignore" /* IGNORE */
|
|
706
|
+
}, {
|
|
707
|
+
name: "mRe7YIELD",
|
|
708
|
+
symbol: "mRe7YIELD",
|
|
709
|
+
logo: "https://midas.app/assets/mre7-BcOOHm7i.svg",
|
|
710
|
+
address: ContractAddr.from("0x4be8945e61dc3e19ebadd1579a6bd53b262f51ba89e6f8b0c4bc9a7e3c633fc"),
|
|
711
|
+
decimals: 18,
|
|
712
|
+
coingeckId: void 0,
|
|
713
|
+
displayDecimals: 2,
|
|
714
|
+
priceCheckAmount: 100,
|
|
715
|
+
dontPrice: true,
|
|
716
|
+
indexingType: "ignore" /* IGNORE */
|
|
717
|
+
}, {
|
|
718
|
+
name: "fyeWBTC",
|
|
719
|
+
symbol: "fyeWBTC",
|
|
720
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/wbtc.svg",
|
|
721
|
+
address: ContractAddr.from("0x04dd39de0a588f5e1c7a8377e1bef2c49caaee49a11433429d2c48f587b3a492"),
|
|
722
|
+
decimals: 8,
|
|
723
|
+
coingeckId: void 0,
|
|
724
|
+
displayDecimals: 6,
|
|
725
|
+
priceCheckAmount: 1e-3,
|
|
726
|
+
// 112000 * 0.0001 = $110.2
|
|
727
|
+
dontPrice: true,
|
|
728
|
+
indexingType: "ignore" /* IGNORE */
|
|
729
|
+
}, {
|
|
730
|
+
name: "fyETH",
|
|
731
|
+
symbol: "fyETH",
|
|
732
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/eth.svg",
|
|
733
|
+
address: ContractAddr.from("0x050707bC3b8730022F10530C2c6f6b9467644129C50C2868Ad0036c5e4E9e616"),
|
|
734
|
+
decimals: 18,
|
|
735
|
+
coingeckId: void 0,
|
|
736
|
+
displayDecimals: 4,
|
|
737
|
+
priceCheckAmount: 0.1,
|
|
738
|
+
dontPrice: true,
|
|
739
|
+
indexingType: "ignore" /* IGNORE */
|
|
740
|
+
}, {
|
|
741
|
+
name: "fyeUSDC",
|
|
742
|
+
symbol: "fyeUSDC",
|
|
743
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/usdc.svg",
|
|
744
|
+
address: ContractAddr.from("0x07fdcec0cef01294c9c3d52415215949805c77bae8003702a7928fd6d2c36bc1"),
|
|
745
|
+
decimals: 6,
|
|
746
|
+
coingeckId: void 0,
|
|
747
|
+
displayDecimals: 2,
|
|
748
|
+
priceCheckAmount: 100,
|
|
749
|
+
dontPrice: true,
|
|
750
|
+
indexingType: "ignore" /* IGNORE */
|
|
751
|
+
}, {
|
|
752
|
+
name: "strkBTC",
|
|
753
|
+
symbol: "strkBTC",
|
|
754
|
+
logo: "https://assets.troves.fi/integrations/tokens/strkbtc.svg",
|
|
755
|
+
address: ContractAddr.from("0x0787150e306e6eae6e3f79dea881770e8bbff2c1b8eb490f969669ee945b3135"),
|
|
756
|
+
decimals: 8,
|
|
757
|
+
coingeckId: void 0,
|
|
758
|
+
displayDecimals: 6,
|
|
759
|
+
priceCheckAmount: 1e-3,
|
|
760
|
+
// 112000 * 0.0001 = $110.2
|
|
761
|
+
priceMethod: "Avnu",
|
|
762
|
+
priceProxySymbol: "WBTC",
|
|
763
|
+
indexingType: "pegged" /* PEGGED */
|
|
764
|
+
}, {
|
|
765
|
+
name: "xstrkBTC",
|
|
766
|
+
symbol: "xstrkBTC",
|
|
767
|
+
logo: "https://assets.troves.fi/integrations/tokens/xstrkbtc.svg",
|
|
768
|
+
address: ContractAddr.from("0x047751b3532fabca89b0f2e35ca1cb45e5a7b11d5e3d3663dfa1f4406b45fd88"),
|
|
769
|
+
decimals: 8,
|
|
770
|
+
coingeckId: void 0,
|
|
771
|
+
displayDecimals: 6,
|
|
772
|
+
priceCheckAmount: 1e-3,
|
|
773
|
+
priceMethod: "Avnu",
|
|
774
|
+
indexingType: "lstScript" /* LST_SCRIPT */
|
|
775
|
+
}];
|
|
550
776
|
var tokens = defaultTokens;
|
|
551
777
|
var _Global = class _Global {
|
|
552
778
|
static fatalError(message, err) {
|
|
553
779
|
logger.error(message);
|
|
554
780
|
console.error(message, err);
|
|
555
|
-
if (err)
|
|
781
|
+
if (err)
|
|
782
|
+
console.error(err);
|
|
556
783
|
process.exit(1);
|
|
557
784
|
}
|
|
558
785
|
static httpError(url, err, message) {
|
|
@@ -564,9 +791,7 @@ var _Global = class _Global {
|
|
|
564
791
|
}
|
|
565
792
|
static async getTokens() {
|
|
566
793
|
if (tokens.length) return tokens;
|
|
567
|
-
const data = await axios.get(
|
|
568
|
-
"https://assets.troves.fi/integrations/tokens.json"
|
|
569
|
-
);
|
|
794
|
+
const data = await axios.get("https://assets.troves.fi/integrations/tokens.json");
|
|
570
795
|
const tokensData = data.data.content;
|
|
571
796
|
tokensData.forEach((token) => {
|
|
572
797
|
if (!token.tags.includes("AVNU") || !token.tags.includes("Verified")) {
|
|
@@ -579,7 +804,8 @@ var _Global = class _Global {
|
|
|
579
804
|
decimals: token.decimals,
|
|
580
805
|
logo: token.logoUri,
|
|
581
806
|
coingeckId: token.extensions.coingeckoId,
|
|
582
|
-
displayDecimals: 2
|
|
807
|
+
displayDecimals: 2,
|
|
808
|
+
indexingType: "ignore" /* IGNORE */
|
|
583
809
|
});
|
|
584
810
|
});
|
|
585
811
|
console.log(tokens);
|
|
@@ -590,25 +816,25 @@ var _Global = class _Global {
|
|
|
590
816
|
throw new FatalError(message);
|
|
591
817
|
}
|
|
592
818
|
}
|
|
593
|
-
static async
|
|
819
|
+
static async getTokenInfoFromAddr(addr) {
|
|
594
820
|
if (tokens.length == defaultTokens.length) {
|
|
595
821
|
await _Global.getTokens();
|
|
596
822
|
}
|
|
597
|
-
const token = tokens.find(
|
|
598
|
-
(token2) => token2.name.toLowerCase() === tokenName.toLowerCase()
|
|
599
|
-
);
|
|
823
|
+
const token = tokens.find((token2) => addr.eq(token2.address));
|
|
600
824
|
if (!token) {
|
|
601
|
-
throw new FatalError(`Token not found: ${
|
|
825
|
+
throw new FatalError(`Token not found: ${addr.address}`);
|
|
602
826
|
}
|
|
603
827
|
return token;
|
|
604
828
|
}
|
|
605
|
-
static async
|
|
829
|
+
static async getTokenInfoFromName(tokenName) {
|
|
606
830
|
if (tokens.length == defaultTokens.length) {
|
|
607
831
|
await _Global.getTokens();
|
|
608
832
|
}
|
|
609
|
-
const token = tokens.find(
|
|
833
|
+
const token = tokens.find(
|
|
834
|
+
(token2) => token2.name.toLowerCase() === tokenName.toLowerCase()
|
|
835
|
+
);
|
|
610
836
|
if (!token) {
|
|
611
|
-
throw new FatalError(`Token not found: ${
|
|
837
|
+
throw new FatalError(`Token not found: ${tokenName}`);
|
|
612
838
|
}
|
|
613
839
|
return token;
|
|
614
840
|
}
|
|
@@ -3847,21 +4073,14 @@ var Pricer = class extends PricerBase {
|
|
|
3847
4073
|
}
|
|
3848
4074
|
}
|
|
3849
4075
|
async _getPrice(token) {
|
|
3850
|
-
const
|
|
3851
|
-
|
|
3852
|
-
logger.verbose(`Fetching price of ${token.symbol} using pinned ${pinned}`);
|
|
3853
|
-
try {
|
|
3854
|
-
return await this._tryPriceMethod(token, pinned);
|
|
3855
|
-
} catch (error) {
|
|
3856
|
-
console.warn(`${pinned}: pinned price failed [${token.symbol}]: `, error.message);
|
|
3857
|
-
delete this.methodToUse[token.symbol];
|
|
3858
|
-
}
|
|
3859
|
-
}
|
|
3860
|
-
for (const method of PRICE_METHOD_PRIORITY) {
|
|
4076
|
+
const methodsToTry = this._getMethodsToTry(token);
|
|
4077
|
+
for (const method of methodsToTry) {
|
|
3861
4078
|
logger.verbose(`Fetching price of ${token.symbol} using ${method}`);
|
|
3862
4079
|
try {
|
|
3863
4080
|
const result = await this._tryPriceMethod(token, method);
|
|
3864
|
-
|
|
4081
|
+
if (!token.priceMethod) {
|
|
4082
|
+
this.methodToUse[token.symbol] = method;
|
|
4083
|
+
}
|
|
3865
4084
|
return result;
|
|
3866
4085
|
} catch (error) {
|
|
3867
4086
|
console.warn(`${method}: price err [${token.symbol}]: `, error.message);
|
|
@@ -3869,6 +4088,22 @@ var Pricer = class extends PricerBase {
|
|
|
3869
4088
|
}
|
|
3870
4089
|
throw new FatalError(`Price not found for ${token.symbol}`);
|
|
3871
4090
|
}
|
|
4091
|
+
_getMethodsToTry(token) {
|
|
4092
|
+
const methods = [];
|
|
4093
|
+
if (token.priceMethod) {
|
|
4094
|
+
methods.push(token.priceMethod);
|
|
4095
|
+
}
|
|
4096
|
+
const pinned = this.methodToUse[token.symbol];
|
|
4097
|
+
if (pinned && pinned !== token.priceMethod) {
|
|
4098
|
+
methods.push(pinned);
|
|
4099
|
+
}
|
|
4100
|
+
for (const method of PRICE_METHOD_PRIORITY) {
|
|
4101
|
+
if (!methods.includes(method)) {
|
|
4102
|
+
methods.push(method);
|
|
4103
|
+
}
|
|
4104
|
+
}
|
|
4105
|
+
return methods;
|
|
4106
|
+
}
|
|
3872
4107
|
async _tryPriceMethod(token, method) {
|
|
3873
4108
|
switch (method) {
|
|
3874
4109
|
case "AvnuApi":
|
|
@@ -4068,37 +4303,6 @@ var Pragma = class extends PricerBase {
|
|
|
4068
4303
|
|
|
4069
4304
|
// src/modules/zkLend.ts
|
|
4070
4305
|
import axios5 from "axios";
|
|
4071
|
-
|
|
4072
|
-
// src/interfaces/lending.ts
|
|
4073
|
-
var MarginType = /* @__PURE__ */ ((MarginType2) => {
|
|
4074
|
-
MarginType2["SHARED"] = "shared";
|
|
4075
|
-
MarginType2["NONE"] = "none";
|
|
4076
|
-
return MarginType2;
|
|
4077
|
-
})(MarginType || {});
|
|
4078
|
-
var ILending = class {
|
|
4079
|
-
constructor(config, metadata) {
|
|
4080
|
-
this.tokens = [];
|
|
4081
|
-
this.initialised = false;
|
|
4082
|
-
this.metadata = metadata;
|
|
4083
|
-
this.config = config;
|
|
4084
|
-
this.init();
|
|
4085
|
-
}
|
|
4086
|
-
/** Wait for initialisation */
|
|
4087
|
-
waitForInitilisation() {
|
|
4088
|
-
return new Promise((resolve, reject) => {
|
|
4089
|
-
const interval = setInterval(() => {
|
|
4090
|
-
logger.verbose(`Waiting for ${this.metadata.name} to initialise`);
|
|
4091
|
-
if (this.initialised) {
|
|
4092
|
-
logger.verbose(`${this.metadata.name} initialised`);
|
|
4093
|
-
clearInterval(interval);
|
|
4094
|
-
resolve();
|
|
4095
|
-
}
|
|
4096
|
-
}, 1e3);
|
|
4097
|
-
});
|
|
4098
|
-
}
|
|
4099
|
-
};
|
|
4100
|
-
|
|
4101
|
-
// src/modules/zkLend.ts
|
|
4102
4306
|
var _ZkLend = class _ZkLend extends ILending {
|
|
4103
4307
|
constructor(config, pricer) {
|
|
4104
4308
|
super(config, {
|
|
@@ -4128,7 +4332,8 @@ var _ZkLend = class _ZkLend extends ILending {
|
|
|
4128
4332
|
decimals: pool.token.decimals,
|
|
4129
4333
|
borrowFactor: Web3Number.fromWei(pool.borrow_factor.value, pool.borrow_factor.decimals),
|
|
4130
4334
|
collareralFactor,
|
|
4131
|
-
displayDecimals: 2
|
|
4335
|
+
displayDecimals: 2,
|
|
4336
|
+
indexingType: "ignore" /* IGNORE */
|
|
4132
4337
|
};
|
|
4133
4338
|
this.tokens.push(token);
|
|
4134
4339
|
});
|
|
@@ -4530,7 +4735,8 @@ var EkuboPricer = class extends PricerBase {
|
|
|
4530
4735
|
constructor(config, tokens2) {
|
|
4531
4736
|
super(config, tokens2);
|
|
4532
4737
|
this.EKUBO_PRICE_FETCHER_ADDRESS = "0x04946fb4ad5237d97bbb1256eba2080c4fe1de156da6a7f83e3b4823bb6d7da1";
|
|
4533
|
-
|
|
4738
|
+
// Updating to new USDC_ADDRESS
|
|
4739
|
+
this.USDC_ADDRESS = "0x033068F6539f8e6e6b131e6B2B814e6c34A5224bC66947c47DaB9dFeE93b35fb";
|
|
4534
4740
|
this.USDC_DECIMALS = 6;
|
|
4535
4741
|
this.contract = new Contract3({
|
|
4536
4742
|
abi: ekubo_price_fethcer_abi_default,
|
|
@@ -4538,8 +4744,8 @@ var EkuboPricer = class extends PricerBase {
|
|
|
4538
4744
|
providerOrAccount: config.provider
|
|
4539
4745
|
});
|
|
4540
4746
|
}
|
|
4541
|
-
div2Power128(
|
|
4542
|
-
return Number(
|
|
4747
|
+
div2Power128(num16) {
|
|
4748
|
+
return Number(num16 * BigInt(1e18) / BigInt(2 ** 128)) / 1e18;
|
|
4543
4749
|
}
|
|
4544
4750
|
async getPrice(tokenAddr, blockIdentifier = "latest") {
|
|
4545
4751
|
if (!tokenAddr) {
|
|
@@ -6119,217 +6325,6 @@ var PricerLST = class extends Pricer {
|
|
|
6119
6325
|
}
|
|
6120
6326
|
};
|
|
6121
6327
|
|
|
6122
|
-
// src/interfaces/common.tsx
|
|
6123
|
-
import { BlockTag, RpcProvider as RpcProvider3 } from "starknet";
|
|
6124
|
-
import { Fragment, jsx } from "react/jsx-runtime";
|
|
6125
|
-
var RiskType = /* @__PURE__ */ ((RiskType2) => {
|
|
6126
|
-
RiskType2["MARKET_RISK"] = "Market Risk";
|
|
6127
|
-
RiskType2["IMPERMANENT_LOSS"] = "Impermanent Loss Risk";
|
|
6128
|
-
RiskType2["LIQUIDATION_RISK"] = "Liquidation Risk";
|
|
6129
|
-
RiskType2["LOW_LIQUIDITY_RISK"] = "Low Liquidity Risk";
|
|
6130
|
-
RiskType2["SMART_CONTRACT_RISK"] = "Smart Contract Risk";
|
|
6131
|
-
RiskType2["ORACLE_RISK"] = "Oracle Risk";
|
|
6132
|
-
RiskType2["TECHNICAL_RISK"] = "Technical Risk";
|
|
6133
|
-
RiskType2["COUNTERPARTY_RISK"] = "Counterparty Risk";
|
|
6134
|
-
RiskType2["DEPEG_RISK"] = "Depeg Risk";
|
|
6135
|
-
return RiskType2;
|
|
6136
|
-
})(RiskType || {});
|
|
6137
|
-
var Network = /* @__PURE__ */ ((Network2) => {
|
|
6138
|
-
Network2["mainnet"] = "mainnet";
|
|
6139
|
-
Network2["sepolia"] = "sepolia";
|
|
6140
|
-
Network2["devnet"] = "devnet";
|
|
6141
|
-
return Network2;
|
|
6142
|
-
})(Network || {});
|
|
6143
|
-
var StrategyTag = /* @__PURE__ */ ((StrategyTag3) => {
|
|
6144
|
-
StrategyTag3["META_VAULT"] = "Meta Vaults";
|
|
6145
|
-
StrategyTag3["LEVERED"] = "Maxx";
|
|
6146
|
-
StrategyTag3["AUTOMATED_LP"] = "Ekubo";
|
|
6147
|
-
StrategyTag3["BTC"] = "BTC";
|
|
6148
|
-
return StrategyTag3;
|
|
6149
|
-
})(StrategyTag || {});
|
|
6150
|
-
var VaultType = /* @__PURE__ */ ((VaultType2) => {
|
|
6151
|
-
VaultType2["LOOPING"] = "Looping";
|
|
6152
|
-
VaultType2["META_VAULT"] = "Meta Vault";
|
|
6153
|
-
VaultType2["DELTA_NEUTRAL"] = "Delta Neutral";
|
|
6154
|
-
VaultType2["AUTOMATED_LP"] = "Automated LP";
|
|
6155
|
-
VaultType2["TVA"] = "Troves Value Averaging";
|
|
6156
|
-
return VaultType2;
|
|
6157
|
-
})(VaultType || {});
|
|
6158
|
-
var AuditStatus = /* @__PURE__ */ ((AuditStatus2) => {
|
|
6159
|
-
AuditStatus2["AUDITED"] = "Audited";
|
|
6160
|
-
AuditStatus2["NOT_AUDITED"] = "Not Audited";
|
|
6161
|
-
return AuditStatus2;
|
|
6162
|
-
})(AuditStatus || {});
|
|
6163
|
-
var SourceCodeType = /* @__PURE__ */ ((SourceCodeType2) => {
|
|
6164
|
-
SourceCodeType2["OPEN_SOURCE"] = "Open Source";
|
|
6165
|
-
SourceCodeType2["CLOSED_SOURCE"] = "Closed Source";
|
|
6166
|
-
return SourceCodeType2;
|
|
6167
|
-
})(SourceCodeType || {});
|
|
6168
|
-
var AccessControlType = /* @__PURE__ */ ((AccessControlType2) => {
|
|
6169
|
-
AccessControlType2["MULTISIG_ACCOUNT"] = "Multisig Account";
|
|
6170
|
-
AccessControlType2["STANDARD_ACCOUNT"] = "Standard Account";
|
|
6171
|
-
AccessControlType2["ROLE_BASED_ACCESS"] = "Role Based Access";
|
|
6172
|
-
return AccessControlType2;
|
|
6173
|
-
})(AccessControlType || {});
|
|
6174
|
-
var InstantWithdrawalVault = /* @__PURE__ */ ((InstantWithdrawalVault2) => {
|
|
6175
|
-
InstantWithdrawalVault2["YES"] = "Yes";
|
|
6176
|
-
InstantWithdrawalVault2["NO"] = "No";
|
|
6177
|
-
return InstantWithdrawalVault2;
|
|
6178
|
-
})(InstantWithdrawalVault || {});
|
|
6179
|
-
var FlowChartColors = /* @__PURE__ */ ((FlowChartColors2) => {
|
|
6180
|
-
FlowChartColors2["Green"] = "purple";
|
|
6181
|
-
FlowChartColors2["Blue"] = "#35484f";
|
|
6182
|
-
FlowChartColors2["Purple"] = "#6e53dc";
|
|
6183
|
-
return FlowChartColors2;
|
|
6184
|
-
})(FlowChartColors || {});
|
|
6185
|
-
var StrategyLiveStatus = /* @__PURE__ */ ((StrategyLiveStatus2) => {
|
|
6186
|
-
StrategyLiveStatus2["ACTIVE"] = "Active";
|
|
6187
|
-
StrategyLiveStatus2["NEW"] = "New";
|
|
6188
|
-
StrategyLiveStatus2["COMING_SOON"] = "Coming Soon";
|
|
6189
|
-
StrategyLiveStatus2["DEPRECATED"] = "Deprecated";
|
|
6190
|
-
StrategyLiveStatus2["RETIRED"] = "Retired";
|
|
6191
|
-
StrategyLiveStatus2["HOT"] = "Hot & New \u{1F525}";
|
|
6192
|
-
return StrategyLiveStatus2;
|
|
6193
|
-
})(StrategyLiveStatus || {});
|
|
6194
|
-
function getMainnetConfig(rpcUrl = "https://starknet-mainnet.public.blastapi.io", blockIdentifier = BlockTag.LATEST) {
|
|
6195
|
-
return {
|
|
6196
|
-
provider: new RpcProvider3({
|
|
6197
|
-
nodeUrl: rpcUrl,
|
|
6198
|
-
blockIdentifier
|
|
6199
|
-
// specVersion
|
|
6200
|
-
}),
|
|
6201
|
-
stage: "production",
|
|
6202
|
-
network: "mainnet" /* mainnet */
|
|
6203
|
-
};
|
|
6204
|
-
}
|
|
6205
|
-
var getStrategyTagDesciption = (tag) => {
|
|
6206
|
-
switch (tag) {
|
|
6207
|
-
case "Meta Vaults" /* META_VAULT */:
|
|
6208
|
-
return "A meta vault is a vault that auto allocates funds to multiple vaults based on optimal yield opportunities";
|
|
6209
|
-
case "Maxx" /* LEVERED */:
|
|
6210
|
-
return "Looping vaults on Endur LSTs with leveraged borrowing of STRK or BTC to increase yield (2-4x higher yield than simply staking)";
|
|
6211
|
-
case "Ekubo" /* AUTOMATED_LP */:
|
|
6212
|
-
return "Automated LP vaults on Ekubo that rebalance position automatically, ensuring you earn fees efficiently";
|
|
6213
|
-
case "BTC" /* BTC */:
|
|
6214
|
-
return "BTC linked vaults";
|
|
6215
|
-
}
|
|
6216
|
-
};
|
|
6217
|
-
var getAllStrategyTags = () => {
|
|
6218
|
-
return Object.values(StrategyTag);
|
|
6219
|
-
};
|
|
6220
|
-
var getRiskExplaination = (riskType) => {
|
|
6221
|
-
switch (riskType) {
|
|
6222
|
-
case "Market Risk" /* MARKET_RISK */:
|
|
6223
|
-
return "The risk of the market moving against the position.";
|
|
6224
|
-
case "Impermanent Loss Risk" /* IMPERMANENT_LOSS */:
|
|
6225
|
-
return "The temporary loss of value experienced by liquidity providers in AMMs when asset prices diverge compared to simply holding them.";
|
|
6226
|
-
case "Liquidation Risk" /* LIQUIDATION_RISK */:
|
|
6227
|
-
return "The risk of losing funds due to the position being liquidated.";
|
|
6228
|
-
case "Low Liquidity Risk" /* LOW_LIQUIDITY_RISK */:
|
|
6229
|
-
return "The risk of low liquidity in the pool, which can lead to high slippages or reduced in-abilities to quickly exit the position.";
|
|
6230
|
-
case "Oracle Risk" /* ORACLE_RISK */:
|
|
6231
|
-
return "The risk of the oracle being manipulated or incorrect.";
|
|
6232
|
-
case "Smart Contract Risk" /* SMART_CONTRACT_RISK */:
|
|
6233
|
-
return "The risk of the smart contract being vulnerable to attacks.";
|
|
6234
|
-
case "Technical Risk" /* TECHNICAL_RISK */:
|
|
6235
|
-
return "The risk of technical issues e.g. backend failure.";
|
|
6236
|
-
case "Counterparty Risk" /* COUNTERPARTY_RISK */:
|
|
6237
|
-
return "The risk of the counterparty defaulting e.g. bad debt on lending platforms.";
|
|
6238
|
-
case "Depeg Risk" /* DEPEG_RISK */:
|
|
6239
|
-
return "The risk of a token losing its peg to the underlying asset, leading to potential losses for holders.";
|
|
6240
|
-
}
|
|
6241
|
-
};
|
|
6242
|
-
var getRiskColor = (risk) => {
|
|
6243
|
-
const value = risk.value;
|
|
6244
|
-
if (value <= 2) return "light_green_2";
|
|
6245
|
-
if (value < 3) return "yellow";
|
|
6246
|
-
return "red";
|
|
6247
|
-
};
|
|
6248
|
-
var getNoRiskTags = (risks) => {
|
|
6249
|
-
const noRisks1 = risks.filter((risk) => risk.value === 0).map((risk) => risk.type);
|
|
6250
|
-
const noRisks2 = Object.values(RiskType).filter(
|
|
6251
|
-
(risk) => !risks.map((risk2) => risk2.type).includes(risk)
|
|
6252
|
-
);
|
|
6253
|
-
const mergedUnique = [.../* @__PURE__ */ new Set([...noRisks1, ...noRisks2])];
|
|
6254
|
-
return mergedUnique;
|
|
6255
|
-
};
|
|
6256
|
-
function highlightTextWithLinks(put, highlights) {
|
|
6257
|
-
const escapeRegExp = (text) => text.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
6258
|
-
const pattern = new RegExp(
|
|
6259
|
-
`(${highlights.map((m) => escapeRegExp(m.highlight)).join("|")})`,
|
|
6260
|
-
"gi"
|
|
6261
|
-
);
|
|
6262
|
-
const parts = put.split(pattern);
|
|
6263
|
-
return /* @__PURE__ */ jsx(Fragment, { children: parts.map((part, i) => {
|
|
6264
|
-
const match = highlights.find((m) => m.highlight.toLowerCase() === part.toLowerCase());
|
|
6265
|
-
return match ? /* @__PURE__ */ jsx("a", { href: match.link, target: "_blank", style: { color: "white", background: "rgba(255, 255, 255, 0.04)" }, children: part }, i) : /* @__PURE__ */ jsx("span", { children: part }, i);
|
|
6266
|
-
}) });
|
|
6267
|
-
}
|
|
6268
|
-
var VesuProtocol = {
|
|
6269
|
-
name: "Vesu",
|
|
6270
|
-
logo: "https://static-assets-8zct.onrender.com/integrations/vesu/logo.png"
|
|
6271
|
-
};
|
|
6272
|
-
var AvnuProtocol = {
|
|
6273
|
-
name: "Avnu",
|
|
6274
|
-
logo: "https://static-assets-8zct.onrender.com/integrations/avnu/logo.png"
|
|
6275
|
-
};
|
|
6276
|
-
var EndurProtocol = {
|
|
6277
|
-
name: "Endur",
|
|
6278
|
-
logo: "http://endur.fi/logo.png"
|
|
6279
|
-
};
|
|
6280
|
-
var ExtendedProtocol = {
|
|
6281
|
-
name: "Extended",
|
|
6282
|
-
logo: "https://static-assets-8zct.onrender.com/integrations/extended/extended.svg"
|
|
6283
|
-
};
|
|
6284
|
-
var EkuboProtocol = {
|
|
6285
|
-
name: "Ekubo",
|
|
6286
|
-
logo: "https://app.ekubo.org/favicon.ico"
|
|
6287
|
-
};
|
|
6288
|
-
var NoneProtocol = {
|
|
6289
|
-
name: "-",
|
|
6290
|
-
logo: ""
|
|
6291
|
-
};
|
|
6292
|
-
var VaultProtocol = {
|
|
6293
|
-
name: "Vault",
|
|
6294
|
-
logo: ""
|
|
6295
|
-
};
|
|
6296
|
-
var TrovesProtocol = {
|
|
6297
|
-
name: "Troves",
|
|
6298
|
-
logo: "https://app.troves.fi/favicon.ico"
|
|
6299
|
-
};
|
|
6300
|
-
var Protocols = {
|
|
6301
|
-
NONE: NoneProtocol,
|
|
6302
|
-
VESU: VesuProtocol,
|
|
6303
|
-
ENDUR: EndurProtocol,
|
|
6304
|
-
EXTENDED: ExtendedProtocol,
|
|
6305
|
-
EKUBO: EkuboProtocol,
|
|
6306
|
-
AVNU: AvnuProtocol,
|
|
6307
|
-
VAULT: VaultProtocol,
|
|
6308
|
-
TROVES: TrovesProtocol
|
|
6309
|
-
};
|
|
6310
|
-
var UnwrapLabsCurator = {
|
|
6311
|
-
name: "Unwrap Labs",
|
|
6312
|
-
logo: "https://assets.troves.fi/integrations/unwraplabs/white.png"
|
|
6313
|
-
};
|
|
6314
|
-
|
|
6315
|
-
// src/interfaces/initializable.ts
|
|
6316
|
-
var Initializable = class {
|
|
6317
|
-
constructor() {
|
|
6318
|
-
this.initialized = false;
|
|
6319
|
-
}
|
|
6320
|
-
async waitForInitilisation() {
|
|
6321
|
-
return new Promise((resolve, reject) => {
|
|
6322
|
-
const interval = setInterval(() => {
|
|
6323
|
-
if (this.initialized) {
|
|
6324
|
-
console.log("Initialised");
|
|
6325
|
-
clearInterval(interval);
|
|
6326
|
-
resolve();
|
|
6327
|
-
}
|
|
6328
|
-
}, 1e3);
|
|
6329
|
-
});
|
|
6330
|
-
}
|
|
6331
|
-
};
|
|
6332
|
-
|
|
6333
6328
|
// src/strategies/autoCompounderStrk.ts
|
|
6334
6329
|
import { Contract as Contract6, uint256 as uint2568 } from "starknet";
|
|
6335
6330
|
var AutoCompounderSTRK = class {
|
|
@@ -17866,6 +17861,73 @@ async function binarySearch(lowWei, highWei, callback) {
|
|
|
17866
17861
|
}
|
|
17867
17862
|
return null;
|
|
17868
17863
|
}
|
|
17864
|
+
async function findMaxInputWithSlippage(options) {
|
|
17865
|
+
const {
|
|
17866
|
+
apiGetOutput,
|
|
17867
|
+
maxInput,
|
|
17868
|
+
maxSlippagePercent,
|
|
17869
|
+
tolerance,
|
|
17870
|
+
minInput = 0,
|
|
17871
|
+
referenceAmountMultiplier = 1e-3,
|
|
17872
|
+
referenceRate = 0
|
|
17873
|
+
} = options;
|
|
17874
|
+
let apiCalls = 0;
|
|
17875
|
+
if (!referenceRate && !referenceAmountMultiplier) {
|
|
17876
|
+
throw new Error("One of referenceRate or referenceAmountMultiplier must be provided");
|
|
17877
|
+
}
|
|
17878
|
+
let _referenceRate = referenceRate;
|
|
17879
|
+
if (!_referenceRate) {
|
|
17880
|
+
const smallAmount = maxInput * referenceAmountMultiplier;
|
|
17881
|
+
const referenceOutput = await apiGetOutput(smallAmount);
|
|
17882
|
+
apiCalls++;
|
|
17883
|
+
_referenceRate = referenceOutput / smallAmount;
|
|
17884
|
+
}
|
|
17885
|
+
async function checkSlippage(inputAmount) {
|
|
17886
|
+
const actualOutput = await apiGetOutput(inputAmount);
|
|
17887
|
+
apiCalls++;
|
|
17888
|
+
const expectedOutput = inputAmount * referenceRate;
|
|
17889
|
+
const slippage = (expectedOutput - actualOutput) / expectedOutput;
|
|
17890
|
+
logger.verbose(`findMaxInputWithSlippage::checkSlippage inputAmount: ${inputAmount}, actualOutput: ${actualOutput}, slippage: ${slippage}, maxSlippagePercent: ${maxSlippagePercent}`);
|
|
17891
|
+
return {
|
|
17892
|
+
acceptable: slippage <= maxSlippagePercent,
|
|
17893
|
+
slippage,
|
|
17894
|
+
output: actualOutput
|
|
17895
|
+
};
|
|
17896
|
+
}
|
|
17897
|
+
const maxCheck = await checkSlippage(maxInput);
|
|
17898
|
+
if (maxCheck.acceptable) {
|
|
17899
|
+
return {
|
|
17900
|
+
optimalInput: maxInput,
|
|
17901
|
+
actualOutput: maxCheck.output,
|
|
17902
|
+
actualSlippage: maxCheck.slippage,
|
|
17903
|
+
apiCallsUsed: apiCalls
|
|
17904
|
+
};
|
|
17905
|
+
}
|
|
17906
|
+
let left = minInput;
|
|
17907
|
+
let right = maxInput;
|
|
17908
|
+
let bestInput = minInput;
|
|
17909
|
+
let bestOutput = 0;
|
|
17910
|
+
let bestSlippage = 0;
|
|
17911
|
+
const convergenceThreshold = tolerance * maxInput;
|
|
17912
|
+
while (right - left > convergenceThreshold) {
|
|
17913
|
+
const mid = (left + right) / 2;
|
|
17914
|
+
const midCheck = await checkSlippage(mid);
|
|
17915
|
+
if (midCheck.acceptable) {
|
|
17916
|
+
bestInput = mid;
|
|
17917
|
+
bestOutput = midCheck.output;
|
|
17918
|
+
bestSlippage = midCheck.slippage;
|
|
17919
|
+
left = mid;
|
|
17920
|
+
} else {
|
|
17921
|
+
right = mid;
|
|
17922
|
+
}
|
|
17923
|
+
}
|
|
17924
|
+
return {
|
|
17925
|
+
optimalInput: bestInput,
|
|
17926
|
+
actualOutput: bestOutput,
|
|
17927
|
+
actualSlippage: bestSlippage,
|
|
17928
|
+
apiCallsUsed: apiCalls
|
|
17929
|
+
};
|
|
17930
|
+
}
|
|
17869
17931
|
|
|
17870
17932
|
// src/strategies/ekubo-cl-vault.tsx
|
|
17871
17933
|
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
@@ -18471,8 +18533,8 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
18471
18533
|
upperTick: _EkuboCLVault.i129ToNumber(result.bounds.upper)
|
|
18472
18534
|
};
|
|
18473
18535
|
}
|
|
18474
|
-
static div2Power128(
|
|
18475
|
-
return Number(BigInt(
|
|
18536
|
+
static div2Power128(num16) {
|
|
18537
|
+
return Number(BigInt(num16.toString()) * BigInt(1e18) / BigInt(2 ** 128)) / 1e18;
|
|
18476
18538
|
}
|
|
18477
18539
|
static priceToTick(price, isRoundDown, tickSpacing) {
|
|
18478
18540
|
const value = isRoundDown ? Math.floor(Math.log(price) / Math.log(1.000001)) : Math.ceil(Math.log(price) / Math.log(1.000001));
|
|
@@ -30099,7 +30161,8 @@ var vesuPrimeUSDC = {
|
|
|
30099
30161
|
name: "Vesu Prime USDC",
|
|
30100
30162
|
decimals: 18,
|
|
30101
30163
|
logo: usdc.logo,
|
|
30102
|
-
displayDecimals: 2
|
|
30164
|
+
displayDecimals: 2,
|
|
30165
|
+
indexingType: "ignore" /* IGNORE */
|
|
30103
30166
|
};
|
|
30104
30167
|
var strk = Global.getDefaultTokens().find((t) => t.symbol === "STRK");
|
|
30105
30168
|
function getYoloVaultErc4626Config(mainToken, secondaryToken) {
|
|
@@ -38108,7 +38171,7 @@ var UniversalStrategies = [
|
|
|
38108
38171
|
];
|
|
38109
38172
|
|
|
38110
38173
|
// src/strategies/universal-lst-muliplier-strategy.tsx
|
|
38111
|
-
import { Contract as Contract18, uint256 as uint25623 } from "starknet";
|
|
38174
|
+
import { Contract as Contract18, num as num14, uint256 as uint25623 } from "starknet";
|
|
38112
38175
|
|
|
38113
38176
|
// src/strategies/universal-adapters/adapter-optimizer.ts
|
|
38114
38177
|
var AdapterOptimizer = class {
|
|
@@ -38590,41 +38653,270 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
38590
38653
|
}
|
|
38591
38654
|
async netAPY() {
|
|
38592
38655
|
const unusedBalance = await this.getUnusedBalance();
|
|
38593
|
-
const
|
|
38594
|
-
|
|
38595
|
-
|
|
38656
|
+
const maxNewDeposits = await this.maxNewDeposits({
|
|
38657
|
+
isAPYComputation: true
|
|
38658
|
+
});
|
|
38659
|
+
const lstAPY = await this.getLSTAPR(
|
|
38660
|
+
this.getLSTUnderlyingTokenInfo().address
|
|
38661
|
+
);
|
|
38662
|
+
if (maxNewDeposits * 1.5 < unusedBalance.amount.toNumber()) {
|
|
38596
38663
|
logger.verbose(
|
|
38597
38664
|
`${this.getTag()}::netAPY: unused balance is > max servicable from loan, lstAPY: ${lstAPY}`
|
|
38598
38665
|
);
|
|
38599
|
-
const
|
|
38666
|
+
const { positions, baseAPYs, rewardAPYs } = await this.getVesuAPYs();
|
|
38667
|
+
const unusedBalanceAPY = await this.getUnusedBalanceAPY();
|
|
38668
|
+
baseAPYs.push(...[unusedBalanceAPY.apy]);
|
|
38669
|
+
rewardAPYs.push(0);
|
|
38670
|
+
const weights = positions.map((p, index) => p.usdValue * (index % 2 == 0 ? 1 : -1));
|
|
38671
|
+
weights.push(unusedBalanceAPY.weight);
|
|
38672
|
+
const prevAUM = await this.getPrevAUM();
|
|
38673
|
+
const price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
|
|
38674
|
+
const prevAUMUSD = prevAUM.multipliedBy(price.price);
|
|
38675
|
+
const output = await this.returnNetAPY(baseAPYs, rewardAPYs, weights, prevAUMUSD);
|
|
38600
38676
|
output.splits.push({ apy: lstAPY, id: "lst_apy" });
|
|
38601
38677
|
return output;
|
|
38602
38678
|
} else {
|
|
38603
38679
|
logger.verbose(
|
|
38604
38680
|
`${this.getTag()}::netAPY: we can take more deposits, use theoretical max APY`
|
|
38605
38681
|
);
|
|
38606
|
-
const
|
|
38682
|
+
const { positions, baseAPYs, rewardAPYs } = await this.getVesuAPYs();
|
|
38683
|
+
const weights = positions.map(
|
|
38684
|
+
(p, index) => p.usdValue * (index % 2 == 0 ? 1 : -1)
|
|
38685
|
+
);
|
|
38686
|
+
const aum = weights.reduce((acc, curr) => acc + curr, 0);
|
|
38687
|
+
const output = await this.returnNetAPY(
|
|
38688
|
+
baseAPYs,
|
|
38689
|
+
rewardAPYs,
|
|
38690
|
+
weights,
|
|
38691
|
+
new Web3Number(
|
|
38692
|
+
aum.toFixed(9),
|
|
38693
|
+
this.getLSTUnderlyingTokenInfo().decimals
|
|
38694
|
+
)
|
|
38695
|
+
);
|
|
38607
38696
|
output.splits.push({ apy: lstAPY, id: "lst_apy" });
|
|
38608
38697
|
return output;
|
|
38609
38698
|
}
|
|
38610
38699
|
}
|
|
38611
|
-
async
|
|
38612
|
-
|
|
38613
|
-
|
|
38614
|
-
|
|
38615
|
-
|
|
38700
|
+
async getVesuAPYs() {
|
|
38701
|
+
const vesuAdapters = this.getVesuAdapters();
|
|
38702
|
+
const allVesuPools = await VesuAdapter.getVesuPools();
|
|
38703
|
+
const pools = vesuAdapters.map((vesuAdapter) => {
|
|
38704
|
+
return allVesuPools.pools.find((p) => vesuAdapter.config.poolId.eqString(num14.getHexString(p.id)));
|
|
38705
|
+
});
|
|
38706
|
+
logger.verbose(`${this.metadata.name}::netAPY: vesu-pools: ${JSON.stringify(pools)}`);
|
|
38707
|
+
if (pools.some((p) => !p)) {
|
|
38708
|
+
throw new Error("Pool not found");
|
|
38616
38709
|
}
|
|
38617
|
-
|
|
38710
|
+
const positions = await this.getVesuPositions();
|
|
38711
|
+
logger.verbose(`${this.metadata.name}::netAPY: positions: ${JSON.stringify(positions)}`);
|
|
38712
|
+
const baseAPYs = [];
|
|
38713
|
+
const rewardAPYs = [];
|
|
38714
|
+
for (const [index, pool] of pools.entries()) {
|
|
38715
|
+
const vesuAdapter = vesuAdapters[index];
|
|
38716
|
+
const collateralAsset = pool.assets.find((a) => a.symbol.toLowerCase() === vesuAdapter.config.collateral.symbol.toLowerCase())?.stats;
|
|
38717
|
+
const debtAsset = pool.assets.find((a) => a.symbol.toLowerCase() === vesuAdapter.config.debt.symbol.toLowerCase())?.stats;
|
|
38718
|
+
const supplyApy = Number(collateralAsset.supplyApy.value || 0) / 1e18;
|
|
38719
|
+
const lstAPY = await this.getLSTAPR(vesuAdapter.config.collateral.address);
|
|
38720
|
+
logger.verbose(`${this.metadata.name}::netAPY: ${vesuAdapter.config.collateral.symbol} LST APR from Endur: ${lstAPY}`);
|
|
38721
|
+
baseAPYs.push(...[supplyApy + lstAPY, Number(debtAsset.borrowApr.value) / 1e18]);
|
|
38722
|
+
rewardAPYs.push(...[Number(collateralAsset.defiSpringSupplyApr?.value || "0") / 1e18, 0]);
|
|
38723
|
+
}
|
|
38724
|
+
logger.verbose(`${this.metadata.name}::netAPY: baseAPYs: ${JSON.stringify(baseAPYs)}`);
|
|
38725
|
+
logger.verbose(`${this.metadata.name}::netAPY: rewardAPYs: ${JSON.stringify(rewardAPYs)}`);
|
|
38726
|
+
assert(baseAPYs.length == positions.length, "APYs and positions length mismatch");
|
|
38727
|
+
return {
|
|
38728
|
+
baseAPYs,
|
|
38729
|
+
rewardAPYs,
|
|
38730
|
+
positions
|
|
38731
|
+
};
|
|
38732
|
+
}
|
|
38733
|
+
async returnNetAPY(baseAPYs, rewardAPYs, weights, prevAUMUSD) {
|
|
38734
|
+
if (weights.every((p) => p == 0)) {
|
|
38735
|
+
return {
|
|
38736
|
+
net: 0,
|
|
38737
|
+
splits: [{
|
|
38738
|
+
apy: 0,
|
|
38739
|
+
id: "base"
|
|
38740
|
+
}, {
|
|
38741
|
+
apy: 0,
|
|
38742
|
+
id: "defispring"
|
|
38743
|
+
}]
|
|
38744
|
+
};
|
|
38745
|
+
}
|
|
38746
|
+
const baseAPY = this.computeAPY(baseAPYs, weights, prevAUMUSD);
|
|
38747
|
+
const rewardAPY = this.computeAPY(rewardAPYs, weights, prevAUMUSD);
|
|
38748
|
+
const netAPY = baseAPY + rewardAPY;
|
|
38749
|
+
logger.verbose(`${this.metadata.name}::netAPY: net: ${netAPY}, baseAPY: ${baseAPY}, rewardAPY: ${rewardAPY}`);
|
|
38750
|
+
return {
|
|
38751
|
+
net: netAPY,
|
|
38752
|
+
splits: [{
|
|
38753
|
+
apy: baseAPY,
|
|
38754
|
+
id: "base"
|
|
38755
|
+
}, {
|
|
38756
|
+
apy: rewardAPY,
|
|
38757
|
+
id: "defispring"
|
|
38758
|
+
}]
|
|
38759
|
+
};
|
|
38618
38760
|
}
|
|
38619
38761
|
async getUnusedBalanceAPY() {
|
|
38620
38762
|
const unusedBalance = await this.getUnusedBalance();
|
|
38621
|
-
const
|
|
38763
|
+
const vesuAdapter = this.getVesuSameTokenAdapter();
|
|
38764
|
+
const underlying = vesuAdapter.config.debt;
|
|
38622
38765
|
const lstAPY = await this.getLSTAPR(underlying.address);
|
|
38623
38766
|
return {
|
|
38624
38767
|
apy: lstAPY,
|
|
38625
38768
|
weight: unusedBalance.usdValue
|
|
38626
38769
|
};
|
|
38627
38770
|
}
|
|
38771
|
+
computeAPY(apys, weights, currentAUM) {
|
|
38772
|
+
assert(apys.length === weights.length, "APYs and weights length mismatch");
|
|
38773
|
+
const weightedSum = apys.reduce((acc, apy, i) => acc + apy * weights[i], 0);
|
|
38774
|
+
logger.verbose(`${this.getTag()} computeAPY: apys: ${JSON.stringify(apys)}, weights: ${JSON.stringify(weights)}, weightedSum: ${weightedSum}, currentAUM: ${currentAUM}`);
|
|
38775
|
+
return weightedSum / currentAUM.toNumber();
|
|
38776
|
+
}
|
|
38777
|
+
getVesuAdapters() {
|
|
38778
|
+
const multiply = this.getVesuMultiplyAdapters();
|
|
38779
|
+
return multiply.map((m) => m._vesuAdapter);
|
|
38780
|
+
}
|
|
38781
|
+
async getVesuPositions(blockNumber = "latest") {
|
|
38782
|
+
const adapters = this.getVesuAdapters();
|
|
38783
|
+
const positions = [];
|
|
38784
|
+
for (const adapter of adapters) {
|
|
38785
|
+
positions.push(...await adapter.getPositions(this.config, blockNumber));
|
|
38786
|
+
}
|
|
38787
|
+
return positions;
|
|
38788
|
+
}
|
|
38789
|
+
async getUnusedBalance() {
|
|
38790
|
+
const balance = await new ERC20(this.config).balanceOf(this.asset().address, this.metadata.additionalInfo.vaultAllocator, this.asset().decimals);
|
|
38791
|
+
const price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
|
|
38792
|
+
const usdValue = Number(balance.toFixed(6)) * price.price;
|
|
38793
|
+
return {
|
|
38794
|
+
tokenInfo: this.asset(),
|
|
38795
|
+
amount: balance,
|
|
38796
|
+
usdValue
|
|
38797
|
+
};
|
|
38798
|
+
}
|
|
38799
|
+
async maxNewDeposits(params = { isAPYComputation: false }) {
|
|
38800
|
+
const maxBorrowableAmounts = await this.getMaxBorrowableAmount(params);
|
|
38801
|
+
let numerator = 0;
|
|
38802
|
+
for (let adapter of this.getVesuAdapters()) {
|
|
38803
|
+
const maxBorrowableAmountInfo = maxBorrowableAmounts.maxBorrowables.find(
|
|
38804
|
+
(b) => b.borrowableAsset.address.eq(adapter.config.debt.address)
|
|
38805
|
+
);
|
|
38806
|
+
if (!maxBorrowableAmountInfo || !maxBorrowableAmountInfo?.amount) {
|
|
38807
|
+
throw new Error(
|
|
38808
|
+
`Max borrowable amount not found for adapter: ${adapter.config.debt.symbol}`
|
|
38809
|
+
);
|
|
38810
|
+
}
|
|
38811
|
+
numerator += this.metadata.additionalInfo.targetHealthFactor * maxBorrowableAmountInfo.amount.toNumber() / maxBorrowableAmountInfo.ltv;
|
|
38812
|
+
}
|
|
38813
|
+
return numerator - maxBorrowableAmounts.netMaxBorrowableAmount.toNumber();
|
|
38814
|
+
}
|
|
38815
|
+
async getMaxBorrowableAmount(params = { isAPYComputation: false }) {
|
|
38816
|
+
const vesuAdapters = this.getVesuAdapters();
|
|
38817
|
+
let netMaxBorrowableAmount = Web3Number.fromWei("0", this.getLSTUnderlyingTokenInfo().decimals);
|
|
38818
|
+
const maxBorrowables = [];
|
|
38819
|
+
for (const vesuAdapter of vesuAdapters) {
|
|
38820
|
+
const output = await this.getMaxBorrowableAmountByVesuAdapter(
|
|
38821
|
+
vesuAdapter,
|
|
38822
|
+
params.isAPYComputation
|
|
38823
|
+
);
|
|
38824
|
+
const ltv = await vesuAdapter.getLTVConfig(this.config);
|
|
38825
|
+
maxBorrowables.push({ ...output, ltv, poolId: vesuAdapter.config.poolId });
|
|
38826
|
+
}
|
|
38827
|
+
maxBorrowables.sort((a, b) => b.amount.toNumber() - a.amount.toNumber());
|
|
38828
|
+
netMaxBorrowableAmount = maxBorrowables.reduce(
|
|
38829
|
+
(acc, curr) => acc.plus(curr.amount),
|
|
38830
|
+
Web3Number.fromWei("0", this.getLSTUnderlyingTokenInfo().decimals)
|
|
38831
|
+
);
|
|
38832
|
+
return { netMaxBorrowableAmount, maxBorrowables };
|
|
38833
|
+
}
|
|
38834
|
+
async getMaxSwappableWithMaxSlippage(fromToken, toToken, maxSlippage, maxAmount) {
|
|
38835
|
+
const output = await findMaxInputWithSlippage({
|
|
38836
|
+
apiGetOutput: async (inputAmount) => {
|
|
38837
|
+
const ekuboQuoter = new EkuboQuoter(this.config, this.pricer);
|
|
38838
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
38839
|
+
const quote = await ekuboQuoter.getQuoteExactInput(
|
|
38840
|
+
fromToken.address.address,
|
|
38841
|
+
toToken.address.address,
|
|
38842
|
+
new Web3Number(inputAmount.toFixed(9), fromToken.decimals)
|
|
38843
|
+
);
|
|
38844
|
+
return Web3Number.fromWei(
|
|
38845
|
+
quote.total_calculated.toString(),
|
|
38846
|
+
toToken.decimals
|
|
38847
|
+
).toNumber();
|
|
38848
|
+
},
|
|
38849
|
+
maxInput: maxAmount.toNumber(),
|
|
38850
|
+
maxSlippagePercent: maxSlippage,
|
|
38851
|
+
tolerance: 1e-3,
|
|
38852
|
+
referenceRate: 1
|
|
38853
|
+
});
|
|
38854
|
+
return new Web3Number(output.optimalInput, fromToken.decimals);
|
|
38855
|
+
}
|
|
38856
|
+
async getMaxBorrowableAmountByVesuAdapter(vesuAdapter, isAPYComputation) {
|
|
38857
|
+
const lstAPY = await this.getLSTAPR(
|
|
38858
|
+
this.getLSTUnderlyingTokenInfo().address
|
|
38859
|
+
);
|
|
38860
|
+
const maxInterestRate = lstAPY * 0.8;
|
|
38861
|
+
const { maxDebtToHave: maxBorrowableAmount, currentDebt } = await vesuAdapter.getMaxBorrowableByInterestRate(
|
|
38862
|
+
this.config,
|
|
38863
|
+
vesuAdapter.config.debt,
|
|
38864
|
+
maxInterestRate
|
|
38865
|
+
);
|
|
38866
|
+
const debtCap = await vesuAdapter.getDebtCap(this.config);
|
|
38867
|
+
if (currentDebt.gte(debtCap)) {
|
|
38868
|
+
return {
|
|
38869
|
+
amount: Web3Number.fromWei("0", vesuAdapter.config.debt.decimals),
|
|
38870
|
+
dexSwappableAmount: Web3Number.fromWei(
|
|
38871
|
+
"0",
|
|
38872
|
+
vesuAdapter.config.debt.decimals
|
|
38873
|
+
),
|
|
38874
|
+
maxBorrowableAmount: Web3Number.fromWei(
|
|
38875
|
+
"0",
|
|
38876
|
+
vesuAdapter.config.debt.decimals
|
|
38877
|
+
),
|
|
38878
|
+
borrowableAsset: vesuAdapter.config.debt
|
|
38879
|
+
};
|
|
38880
|
+
}
|
|
38881
|
+
const availableToBorrow = debtCap.minus(currentDebt);
|
|
38882
|
+
const maxBorrowable = maxBorrowableAmount.minimum(availableToBorrow).multipliedBy(0.999);
|
|
38883
|
+
if (vesuAdapter.config.debt.address.eq(
|
|
38884
|
+
this.getLSTUnderlyingTokenInfo().address
|
|
38885
|
+
) || isAPYComputation) {
|
|
38886
|
+
return {
|
|
38887
|
+
amount: maxBorrowable,
|
|
38888
|
+
dexSwappableAmount: maxBorrowable,
|
|
38889
|
+
maxBorrowableAmount: maxBorrowable,
|
|
38890
|
+
borrowableAsset: vesuAdapter.config.debt
|
|
38891
|
+
};
|
|
38892
|
+
}
|
|
38893
|
+
try {
|
|
38894
|
+
const maxSwappable = await this.getMaxSwappableWithMaxSlippage(
|
|
38895
|
+
vesuAdapter.config.debt,
|
|
38896
|
+
this.getLSTUnderlyingTokenInfo(),
|
|
38897
|
+
2e-4,
|
|
38898
|
+
maxBorrowable
|
|
38899
|
+
);
|
|
38900
|
+
return {
|
|
38901
|
+
amount: maxBorrowable.minimum(maxSwappable),
|
|
38902
|
+
dexSwappableAmount: maxSwappable,
|
|
38903
|
+
maxBorrowableAmount: maxBorrowable,
|
|
38904
|
+
borrowableAsset: vesuAdapter.config.debt
|
|
38905
|
+
};
|
|
38906
|
+
} catch (error) {
|
|
38907
|
+
logger.warn(`${this.getTag()}: Failed to get max swappable: ${error}`);
|
|
38908
|
+
const maxSwappable = Web3Number.fromWei(
|
|
38909
|
+
"0",
|
|
38910
|
+
vesuAdapter.config.debt.decimals
|
|
38911
|
+
);
|
|
38912
|
+
return {
|
|
38913
|
+
amount: maxBorrowable.minimum(maxSwappable),
|
|
38914
|
+
dexSwappableAmount: maxSwappable,
|
|
38915
|
+
maxBorrowableAmount: maxBorrowable,
|
|
38916
|
+
borrowableAsset: vesuAdapter.config.debt
|
|
38917
|
+
};
|
|
38918
|
+
}
|
|
38919
|
+
}
|
|
38628
38920
|
async getAUM(unrealizedAUM = false) {
|
|
38629
38921
|
const underlying = this.asset();
|
|
38630
38922
|
assert(underlying.symbol.startsWith("x"), "Underlying is not an LST of Endur");
|
|
@@ -38987,6 +39279,9 @@ var hyperxWBTC = {
|
|
|
38987
39279
|
borrowable_assets: [{
|
|
38988
39280
|
tokenInfo: Global.getDefaultTokens().find((token) => token.symbol === "WBTC"),
|
|
38989
39281
|
poolId: VesuPools.Re7xBTC
|
|
39282
|
+
}, {
|
|
39283
|
+
tokenInfo: Global.getDefaultTokens().find((token) => token.symbol === "WBTC"),
|
|
39284
|
+
poolId: VesuPools.Prime
|
|
38990
39285
|
}],
|
|
38991
39286
|
underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "WBTC"),
|
|
38992
39287
|
quoteAmountToFetchPrice: new Web3Number("0.001", Global.getDefaultTokens().find((token) => token.symbol === "WBTC").decimals),
|
|
@@ -39062,7 +39357,7 @@ function createHyperLSTSettings(lstSymbol, underlyingSymbol) {
|
|
|
39062
39357
|
);
|
|
39063
39358
|
return {
|
|
39064
39359
|
isPaused: false,
|
|
39065
|
-
liveStatus: "Hot & New \u{1F525}" /* HOT */,
|
|
39360
|
+
liveStatus: lstSymbol === "xSTRK" ? "Hot & New \u{1F525}" /* HOT */ : lstSymbol == "xWBTC" || lstSymbol == "xtBTC" ? "Active" /* ACTIVE */ : "Deprecated" /* DEPRECATED */,
|
|
39066
39361
|
isAudited: true,
|
|
39067
39362
|
isInstantWithdrawal: false,
|
|
39068
39363
|
hideHarvestInfo: true,
|
|
@@ -39099,8 +39394,7 @@ var HYPER_LST_SECURITY = {
|
|
|
39099
39394
|
},
|
|
39100
39395
|
accessControl: {
|
|
39101
39396
|
type: "Standard Account" /* STANDARD_ACCOUNT */,
|
|
39102
|
-
addresses: [ContractAddr.from("
|
|
39103
|
-
timeLock: "2 Days"
|
|
39397
|
+
addresses: [ContractAddr.from("0x03495dd1e4838aa06666aac236036d86e81a6553e222fc02e70c2cbc0062e8d0")]
|
|
39104
39398
|
}
|
|
39105
39399
|
};
|
|
39106
39400
|
var HYPER_LST_REDEMPTION_INFO = {
|
|
@@ -39177,7 +39471,7 @@ var HyperLSTStrategies = [
|
|
|
39177
39471
|
];
|
|
39178
39472
|
|
|
39179
39473
|
// src/strategies/token-boosted-xstrk-carry-strategy.tsx
|
|
39180
|
-
import { uint256 as uint25624, num as
|
|
39474
|
+
import { uint256 as uint25624, num as num15 } from "starknet";
|
|
39181
39475
|
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
39182
39476
|
var BoostedxSTRKCarryStrategy = class _BoostedxSTRKCarryStrategy extends SVKStrategy {
|
|
39183
39477
|
constructor(config, pricer, metadata) {
|
|
@@ -39441,7 +39735,7 @@ var BoostedxSTRKCarryStrategy = class _BoostedxSTRKCarryStrategy extends SVKStra
|
|
|
39441
39735
|
);
|
|
39442
39736
|
const allVesuPools = await VesuAdapter.getVesuPools();
|
|
39443
39737
|
const pool = allVesuPools.pools.find(
|
|
39444
|
-
(p) => vesuAdapter.config.poolId.eqString(
|
|
39738
|
+
(p) => vesuAdapter.config.poolId.eqString(num15.getHexString(p.id))
|
|
39445
39739
|
);
|
|
39446
39740
|
if (!pool) {
|
|
39447
39741
|
throw new Error(
|
|
@@ -40456,6 +40750,7 @@ export {
|
|
|
40456
40750
|
StrategyType,
|
|
40457
40751
|
SvkTrovesAdapter,
|
|
40458
40752
|
TRANSFER_SANITIZER,
|
|
40753
|
+
TokenIndexingType,
|
|
40459
40754
|
TokenMarketData,
|
|
40460
40755
|
TokenTransferAdapter,
|
|
40461
40756
|
UNIVERSAL_ADAPTER_IDS,
|