@strkfarm/sdk 2.0.0-staging.69 → 2.0.0-staging.70
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/index.browser.global.js +148 -48
- package/dist/index.browser.mjs +164 -63
- package/dist/index.d.ts +29 -3
- package/dist/index.js +166 -63
- package/dist/index.mjs +165 -63
- package/package.json +1 -1
- package/src/global.ts +5 -0
- package/src/interfaces/common.tsx +1 -0
- package/src/modules/index.ts +1 -0
- package/src/modules/pricer-avnu-api.ts +114 -0
- package/src/modules/pricer.ts +63 -45
- package/src/node/pricer-redis.ts +1 -0
- package/src/strategies/ekubo-cl-vault.tsx +4 -1
- package/src/strategies/universal-strategy.tsx +4 -1
- package/src/strategies/yoloVault.ts +4 -1
package/dist/index.browser.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/modules/pricer.ts
|
|
2
|
-
import
|
|
2
|
+
import axios3 from "axios";
|
|
3
3
|
|
|
4
4
|
// src/global.ts
|
|
5
5
|
import axios from "axios";
|
|
@@ -423,8 +423,9 @@ var defaultTokens = [{
|
|
|
423
423
|
decimals: 18,
|
|
424
424
|
coingeckId: void 0,
|
|
425
425
|
displayDecimals: 6,
|
|
426
|
-
priceCheckAmount: 1e-4
|
|
426
|
+
priceCheckAmount: 1e-4,
|
|
427
427
|
// 112000 * 0.0001 = $11.2
|
|
428
|
+
dontPrice: true
|
|
428
429
|
}, {
|
|
429
430
|
name: "mRe7YIELD",
|
|
430
431
|
symbol: "mRe7YIELD",
|
|
@@ -433,7 +434,8 @@ var defaultTokens = [{
|
|
|
433
434
|
decimals: 18,
|
|
434
435
|
coingeckId: void 0,
|
|
435
436
|
displayDecimals: 2,
|
|
436
|
-
priceCheckAmount: 100
|
|
437
|
+
priceCheckAmount: 100,
|
|
438
|
+
dontPrice: true
|
|
437
439
|
}, {
|
|
438
440
|
name: "fyeWBTC",
|
|
439
441
|
symbol: "fyeWBTC",
|
|
@@ -442,8 +444,9 @@ var defaultTokens = [{
|
|
|
442
444
|
decimals: 8,
|
|
443
445
|
coingeckId: void 0,
|
|
444
446
|
displayDecimals: 6,
|
|
445
|
-
priceCheckAmount: 1e-3
|
|
447
|
+
priceCheckAmount: 1e-3,
|
|
446
448
|
// 112000 * 0.0001 = $110.2
|
|
449
|
+
dontPrice: true
|
|
447
450
|
}, {
|
|
448
451
|
name: "fyETH",
|
|
449
452
|
symbol: "fyETH",
|
|
@@ -452,7 +455,8 @@ var defaultTokens = [{
|
|
|
452
455
|
decimals: 18,
|
|
453
456
|
coingeckId: void 0,
|
|
454
457
|
displayDecimals: 4,
|
|
455
|
-
priceCheckAmount: 0.1
|
|
458
|
+
priceCheckAmount: 0.1,
|
|
459
|
+
dontPrice: true
|
|
456
460
|
}, {
|
|
457
461
|
name: "fyeUSDC",
|
|
458
462
|
symbol: "fyeUSDC",
|
|
@@ -461,7 +465,8 @@ var defaultTokens = [{
|
|
|
461
465
|
decimals: 6,
|
|
462
466
|
coingeckId: void 0,
|
|
463
467
|
displayDecimals: 2,
|
|
464
|
-
priceCheckAmount: 100
|
|
468
|
+
priceCheckAmount: 100,
|
|
469
|
+
dontPrice: true
|
|
465
470
|
}, {
|
|
466
471
|
name: "strkBTC",
|
|
467
472
|
symbol: "strkBTC",
|
|
@@ -752,7 +757,96 @@ var AvnuWrapper = class _AvnuWrapper {
|
|
|
752
757
|
}
|
|
753
758
|
};
|
|
754
759
|
|
|
760
|
+
// src/modules/pricer-avnu-api.ts
|
|
761
|
+
import axios2 from "axios";
|
|
762
|
+
var AVNU_TOKENS_API = "https://starknet.impulse.avnu.fi/v3/tokens";
|
|
763
|
+
var PricerAvnuApi = class extends PricerBase {
|
|
764
|
+
constructor(config, tokens2) {
|
|
765
|
+
super(config, tokens2);
|
|
766
|
+
this.prices = {};
|
|
767
|
+
this.refreshInterval = 15e3;
|
|
768
|
+
this.staleTime = 5 * 60 * 1e3;
|
|
769
|
+
this.pollTimer = null;
|
|
770
|
+
this.loading = false;
|
|
771
|
+
}
|
|
772
|
+
start() {
|
|
773
|
+
this._loadPrices();
|
|
774
|
+
this.pollTimer = setInterval(() => {
|
|
775
|
+
this._loadPrices();
|
|
776
|
+
}, this.refreshInterval);
|
|
777
|
+
}
|
|
778
|
+
stop() {
|
|
779
|
+
if (this.pollTimer) {
|
|
780
|
+
clearInterval(this.pollTimer);
|
|
781
|
+
this.pollTimer = null;
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
isStale(timestamp) {
|
|
785
|
+
return Date.now() - timestamp.getTime() > this.staleTime;
|
|
786
|
+
}
|
|
787
|
+
hasPrice(tokenSymbol) {
|
|
788
|
+
const info = this.prices[tokenSymbol];
|
|
789
|
+
return !!info && !this.isStale(info.timestamp);
|
|
790
|
+
}
|
|
791
|
+
async getPrice(tokenSymbol) {
|
|
792
|
+
const info = this.prices[tokenSymbol];
|
|
793
|
+
if (!info) {
|
|
794
|
+
throw new Error(`AvnuApi: price of ${tokenSymbol} not found`);
|
|
795
|
+
}
|
|
796
|
+
if (this.isStale(info.timestamp)) {
|
|
797
|
+
throw new Error(`AvnuApi: price of ${tokenSymbol} is stale`);
|
|
798
|
+
}
|
|
799
|
+
return info;
|
|
800
|
+
}
|
|
801
|
+
async _loadPrices() {
|
|
802
|
+
if (this.loading) {
|
|
803
|
+
return;
|
|
804
|
+
}
|
|
805
|
+
this.loading = true;
|
|
806
|
+
const timestamp = /* @__PURE__ */ new Date();
|
|
807
|
+
try {
|
|
808
|
+
const result = await axios2.get(AVNU_TOKENS_API);
|
|
809
|
+
const priceByAddress = /* @__PURE__ */ new Map();
|
|
810
|
+
for (const entry of result.data) {
|
|
811
|
+
const usd = entry.starknet?.usd;
|
|
812
|
+
if (usd != null && usd > 0) {
|
|
813
|
+
priceByAddress.set(ContractAddr.standardise(entry.address), usd);
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
for (const token of this.tokens) {
|
|
817
|
+
if (token.symbol === "USDT" || token.symbol === "USDC") {
|
|
818
|
+
this.prices[token.symbol] = { price: 1, timestamp };
|
|
819
|
+
continue;
|
|
820
|
+
}
|
|
821
|
+
const targetToken = token.priceProxySymbol ? this.tokens.find((t) => t.symbol === token.priceProxySymbol) : token;
|
|
822
|
+
if (!targetToken) {
|
|
823
|
+
continue;
|
|
824
|
+
}
|
|
825
|
+
const addr = targetToken.address.address;
|
|
826
|
+
const price = priceByAddress.get(addr);
|
|
827
|
+
if (price != null) {
|
|
828
|
+
this.prices[token.symbol] = { price, timestamp };
|
|
829
|
+
logger.verbose(
|
|
830
|
+
`AvnuApi: ${token.symbol} -> $${price}`
|
|
831
|
+
);
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
} catch (error) {
|
|
835
|
+
logger.warn(`AvnuApi: failed to fetch tokens: ${error?.message ?? error}`);
|
|
836
|
+
} finally {
|
|
837
|
+
this.loading = false;
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
};
|
|
841
|
+
|
|
755
842
|
// src/modules/pricer.ts
|
|
843
|
+
var PRICE_METHOD_PRIORITY = [
|
|
844
|
+
"AvnuApi",
|
|
845
|
+
"Coinbase",
|
|
846
|
+
"Coinmarketcap",
|
|
847
|
+
"Ekubo",
|
|
848
|
+
"Avnu"
|
|
849
|
+
];
|
|
756
850
|
var Pricer = class extends PricerBase {
|
|
757
851
|
// e.g. ETH/USDC
|
|
758
852
|
constructor(config, tokens2, refreshInterval = 3e4, staleTime = 6e4) {
|
|
@@ -771,6 +865,7 @@ var Pricer = class extends PricerBase {
|
|
|
771
865
|
this.EKUBO_API = "https://prod-api-quoter.ekubo.org/23448594291968334/{{AMOUNT}}/{{TOKEN_ADDRESS}}/0x033068F6539f8e6e6b131e6B2B814e6c34A5224bC66947c47DaB9dFeE93b35fb";
|
|
772
866
|
this.refreshInterval = refreshInterval;
|
|
773
867
|
this.staleTime = staleTime;
|
|
868
|
+
this.avnuApiPricer = new PricerAvnuApi(config, tokens2);
|
|
774
869
|
}
|
|
775
870
|
isReady() {
|
|
776
871
|
const allPricesExist = Object.keys(this.prices).length === this.tokens.length;
|
|
@@ -800,6 +895,7 @@ var Pricer = class extends PricerBase {
|
|
|
800
895
|
});
|
|
801
896
|
}
|
|
802
897
|
start() {
|
|
898
|
+
this.avnuApiPricer.start();
|
|
803
899
|
this._loadPrices();
|
|
804
900
|
setInterval(() => {
|
|
805
901
|
this._loadPrices();
|
|
@@ -824,6 +920,9 @@ var Pricer = class extends PricerBase {
|
|
|
824
920
|
let retry = 0;
|
|
825
921
|
while (retry < MAX_RETRIES) {
|
|
826
922
|
try {
|
|
923
|
+
if (token.dontPrice) {
|
|
924
|
+
return;
|
|
925
|
+
}
|
|
827
926
|
if (token.symbol === "USDT" || token.symbol === "USDC") {
|
|
828
927
|
this.prices[token.symbol] = {
|
|
829
928
|
price: 1,
|
|
@@ -866,60 +965,61 @@ var Pricer = class extends PricerBase {
|
|
|
866
965
|
});
|
|
867
966
|
if (this.isReady() && this.config.heartbeatUrl) {
|
|
868
967
|
console.log(`sending beat`);
|
|
869
|
-
|
|
968
|
+
axios3.get(this.config.heartbeatUrl).catch((err) => {
|
|
870
969
|
console.error("Pricer: Heartbeat err", err);
|
|
871
970
|
});
|
|
872
971
|
}
|
|
873
972
|
}
|
|
874
|
-
async _getPrice(token
|
|
875
|
-
const
|
|
876
|
-
|
|
877
|
-
|
|
973
|
+
async _getPrice(token) {
|
|
974
|
+
const pinned = this.methodToUse[token.symbol];
|
|
975
|
+
if (pinned) {
|
|
976
|
+
logger.verbose(`Fetching price of ${token.symbol} using pinned ${pinned}`);
|
|
977
|
+
try {
|
|
978
|
+
return await this._tryPriceMethod(token, pinned);
|
|
979
|
+
} catch (error) {
|
|
980
|
+
console.warn(`${pinned}: pinned price failed [${token.symbol}]: `, error.message);
|
|
981
|
+
delete this.methodToUse[token.symbol];
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
for (const method of PRICE_METHOD_PRIORITY) {
|
|
985
|
+
logger.verbose(`Fetching price of ${token.symbol} using ${method}`);
|
|
986
|
+
try {
|
|
987
|
+
const result = await this._tryPriceMethod(token, method);
|
|
988
|
+
this.methodToUse[token.symbol] = method;
|
|
989
|
+
return result;
|
|
990
|
+
} catch (error) {
|
|
991
|
+
console.warn(`${method}: price err [${token.symbol}]: `, error.message);
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
throw new FatalError(`Price not found for ${token.symbol}`);
|
|
995
|
+
}
|
|
996
|
+
async _tryPriceMethod(token, method) {
|
|
997
|
+
switch (method) {
|
|
998
|
+
case "AvnuApi":
|
|
999
|
+
return await this._getPriceAvnuApi(token);
|
|
878
1000
|
case "Coinbase":
|
|
879
|
-
|
|
880
|
-
// const result = await this._getPriceCoinbase(token);
|
|
881
|
-
// this.methodToUse[token.symbol] = 'Coinbase';
|
|
882
|
-
// return result;
|
|
883
|
-
// } catch (error: any) {
|
|
884
|
-
// console.warn(`Coinbase: price err: message [${token.symbol}]: `, error.message);
|
|
885
|
-
// // do nothing, try next
|
|
886
|
-
// }
|
|
1001
|
+
return await this._getPriceCoinbase(token);
|
|
887
1002
|
case "Coinmarketcap":
|
|
888
|
-
|
|
889
|
-
const result = await this._getPriceCoinMarketCap(token);
|
|
890
|
-
this.methodToUse[token.symbol] = "Coinmarketcap";
|
|
891
|
-
return result;
|
|
892
|
-
} catch (error) {
|
|
893
|
-
console.warn(`CoinMarketCap: price err [${token.symbol}]: `, Object.keys(error));
|
|
894
|
-
console.warn(`CoinMarketCap: price err [${token.symbol}]: `, error.message);
|
|
895
|
-
}
|
|
1003
|
+
return await this._getPriceCoinMarketCap(token);
|
|
896
1004
|
case "Ekubo":
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
} catch (error) {
|
|
902
|
-
console.warn(`Ekubo: price err [${token.symbol}]: `, error.message);
|
|
903
|
-
console.warn(`Ekubo: price err [${token.symbol}]: `, Object.keys(error));
|
|
904
|
-
}
|
|
1005
|
+
return await this._getPriceEkubo(
|
|
1006
|
+
token,
|
|
1007
|
+
new Web3Number(token.priceCheckAmount ? token.priceCheckAmount : 1, token.decimals)
|
|
1008
|
+
);
|
|
905
1009
|
case "Avnu":
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
} catch (error) {
|
|
911
|
-
console.warn(`Avnu: price err [${token.symbol}]: `, error.message);
|
|
912
|
-
console.warn(`Avnu: price err [${token.symbol}]: `, Object.keys(error));
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
if (defaultMethod == "all") {
|
|
916
|
-
return await this._getPrice(token, "Coinbase");
|
|
1010
|
+
return await this._getAvnuPrice(
|
|
1011
|
+
token,
|
|
1012
|
+
new Web3Number(token.priceCheckAmount ? token.priceCheckAmount : 1, token.decimals)
|
|
1013
|
+
);
|
|
917
1014
|
}
|
|
918
|
-
|
|
1015
|
+
}
|
|
1016
|
+
async _getPriceAvnuApi(token) {
|
|
1017
|
+
const priceInfo = await this.avnuApiPricer.getPrice(token.symbol);
|
|
1018
|
+
return priceInfo.price;
|
|
919
1019
|
}
|
|
920
1020
|
async _getPriceCoinbase(token) {
|
|
921
1021
|
const url = this.PRICE_API.replace("{{PRICER_KEY}}", `${token.symbol}-USD`);
|
|
922
|
-
const result = await
|
|
1022
|
+
const result = await axios3.get(url);
|
|
923
1023
|
const data = result.data;
|
|
924
1024
|
return Number(data.data.amount);
|
|
925
1025
|
}
|
|
@@ -945,7 +1045,7 @@ var Pricer = class extends PricerBase {
|
|
|
945
1045
|
async _getPriceEkubo(token, amountIn = new Web3Number(1, token.decimals), retry = 0) {
|
|
946
1046
|
logger.verbose(`Getting price of ${token.symbol} using Ekubo, amountIn: ${amountIn.toWei()}`);
|
|
947
1047
|
const url = this.EKUBO_API.replace("{{TOKEN_ADDRESS}}", token.address.toString()).replace("{{AMOUNT}}", amountIn.toWei());
|
|
948
|
-
const result = await
|
|
1048
|
+
const result = await axios3.get(url);
|
|
949
1049
|
const data = result.data;
|
|
950
1050
|
const multiplier = 1 / amountIn.toNumber();
|
|
951
1051
|
const outputUSDC = Number(Web3Number.fromWei(data.total_calculated, 6).toFixed(6)) * multiplier;
|
|
@@ -1091,7 +1191,7 @@ var Pragma = class extends PricerBase {
|
|
|
1091
1191
|
};
|
|
1092
1192
|
|
|
1093
1193
|
// src/modules/zkLend.ts
|
|
1094
|
-
import
|
|
1194
|
+
import axios4 from "axios";
|
|
1095
1195
|
|
|
1096
1196
|
// src/interfaces/lending.ts
|
|
1097
1197
|
var MarginType = /* @__PURE__ */ ((MarginType2) => {
|
|
@@ -1135,7 +1235,7 @@ var _ZkLend = class _ZkLend extends ILending {
|
|
|
1135
1235
|
async init() {
|
|
1136
1236
|
try {
|
|
1137
1237
|
logger.verbose(`Initialising ${this.metadata.name}`);
|
|
1138
|
-
const result = await
|
|
1238
|
+
const result = await axios4.get(_ZkLend.POOLS_URL);
|
|
1139
1239
|
const data = result.data;
|
|
1140
1240
|
const savedTokens = await Global.getTokens();
|
|
1141
1241
|
data.forEach((pool) => {
|
|
@@ -1227,7 +1327,7 @@ var _ZkLend = class _ZkLend extends ILending {
|
|
|
1227
1327
|
*/
|
|
1228
1328
|
async getPositions(user) {
|
|
1229
1329
|
const url = this.POSITION_URL.replace("{{USER_ADDR}}", user.address);
|
|
1230
|
-
const result = await
|
|
1330
|
+
const result = await axios4.get(url);
|
|
1231
1331
|
const data = result.data;
|
|
1232
1332
|
const lendingPosition = [];
|
|
1233
1333
|
logger.verbose(`${this.metadata.name}:: Positions: ${JSON.stringify(data)}`);
|
|
@@ -1260,7 +1360,7 @@ _ZkLend.POOLS_URL = "https://app.zklend.com/api/pools";
|
|
|
1260
1360
|
var ZkLend = _ZkLend;
|
|
1261
1361
|
|
|
1262
1362
|
// src/modules/pricer-from-api.ts
|
|
1263
|
-
import
|
|
1363
|
+
import axios5 from "axios";
|
|
1264
1364
|
|
|
1265
1365
|
// src/modules/apollo-client-config.ts
|
|
1266
1366
|
import { ApolloClient, InMemoryCache } from "@apollo/client";
|
|
@@ -1642,7 +1742,7 @@ var PricerFromApi = class extends PricerBase {
|
|
|
1642
1742
|
const MAX_RETRIES = 5;
|
|
1643
1743
|
for (retry = 1; retry < MAX_RETRIES + 1; retry++) {
|
|
1644
1744
|
try {
|
|
1645
|
-
const priceInfo = await
|
|
1745
|
+
const priceInfo = await axios5.get(
|
|
1646
1746
|
`https://api.coinbase.com/v2/prices/${tokenSymbol}-USDT/spot`
|
|
1647
1747
|
);
|
|
1648
1748
|
if (!priceInfo) {
|
|
@@ -2926,7 +3026,7 @@ var ERC20 = class {
|
|
|
2926
3026
|
};
|
|
2927
3027
|
|
|
2928
3028
|
// src/modules/ekubo-quoter.ts
|
|
2929
|
-
import
|
|
3029
|
+
import axios6 from "axios";
|
|
2930
3030
|
var EkuboQuoter = class {
|
|
2931
3031
|
// e.g. ETH/USDC'
|
|
2932
3032
|
constructor(config) {
|
|
@@ -2944,7 +3044,7 @@ var EkuboQuoter = class {
|
|
|
2944
3044
|
let _fromToken = amount.gt(0) ? fromToken : toToken;
|
|
2945
3045
|
let _toToken = amount.gt(0) ? toToken : fromToken;
|
|
2946
3046
|
try {
|
|
2947
|
-
const quote = await
|
|
3047
|
+
const quote = await axios6.get(this.ENDPOINT.replace("{{AMOUNT}}", amount.toWei()).replace("{{TOKEN_FROM_ADDRESS}}", _fromToken).replace("{{TOKEN_TO_ADDRESS}}", _toToken));
|
|
2948
3048
|
console.log(`Ekubo quote from ${_fromToken} to ${_toToken} for ${amount.toString()}: ${JSON.stringify(quote.data)}`);
|
|
2949
3049
|
return quote.data;
|
|
2950
3050
|
} catch (error) {
|
|
@@ -2990,7 +3090,7 @@ var EkuboQuoter = class {
|
|
|
2990
3090
|
};
|
|
2991
3091
|
|
|
2992
3092
|
// src/modules/pricer-lst.ts
|
|
2993
|
-
import
|
|
3093
|
+
import axios7 from "axios";
|
|
2994
3094
|
var PricerLST = class extends Pricer {
|
|
2995
3095
|
// e.g. xSTRK/STRK
|
|
2996
3096
|
constructor(config, tokenMaps) {
|
|
@@ -3026,7 +3126,7 @@ var PricerLST = class extends Pricer {
|
|
|
3026
3126
|
async _getPriceEkubo(token, amountIn = new Web3Number(1, token.decimals), retry = 0) {
|
|
3027
3127
|
const underlying = this.getUnderlying(token);
|
|
3028
3128
|
const url = this.EKUBO_API.replace("{{TOKEN_ADDRESS}}", token.address.toString()).replace("{{AMOUNT}}", amountIn.toWei()).replace("{{UNDERLYING_ADDRESS}}", underlying.address.toString());
|
|
3029
|
-
const result = await
|
|
3129
|
+
const result = await axios7.get(url);
|
|
3030
3130
|
const data = result.data;
|
|
3031
3131
|
const multiplier = 1 / amountIn.toNumber();
|
|
3032
3132
|
const outputUnderlying = Number(Web3Number.fromWei(data.total_calculated, underlying.decimals).toFixed(6)) * multiplier;
|
|
@@ -4997,9 +5097,9 @@ var BaseStrategy = class extends CacheClass {
|
|
|
4997
5097
|
};
|
|
4998
5098
|
|
|
4999
5099
|
// src/node/headless.browser.ts
|
|
5000
|
-
import
|
|
5100
|
+
import axios8 from "axios";
|
|
5001
5101
|
async function getAPIUsingHeadlessBrowser(url) {
|
|
5002
|
-
const res = await
|
|
5102
|
+
const res = await axios8.get(url);
|
|
5003
5103
|
return res.data;
|
|
5004
5104
|
}
|
|
5005
5105
|
|
|
@@ -16928,7 +17028,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16928
17028
|
const token0Usd = Number(amount0.toFixed(13)) * P0.price;
|
|
16929
17029
|
const token1Usd = Number(amount1.toFixed(13)) * P1.price;
|
|
16930
17030
|
const totalUsdValue = token0Usd + token1Usd;
|
|
16931
|
-
if (totalUsdValue === 0 || token0Usd === 0 || token1Usd === 0 || amount0.eq(0) || amount1.eq(0)) {
|
|
17031
|
+
if ((totalUsdValue === 0 || token0Usd === 0 || token1Usd === 0 || amount0.eq(0) || amount1.eq(0)) && this.metadata.settings?.liveStatus === "Active" /* ACTIVE */) {
|
|
16932
17032
|
logger.warn(
|
|
16933
17033
|
`${this.metadata.name}:getTVL - Zero value detected: usdValue=${totalUsdValue}, amount0=${amount0.toString()}, amount1=${amount1.toString()}, token0Price=${P0.price}, token1Price=${P1.price}, token0Usd=${token0Usd}, token1Usd=${token1Usd}`
|
|
16934
17034
|
);
|
|
@@ -29052,7 +29152,7 @@ var YoLoVault = class extends BaseStrategy {
|
|
|
29052
29152
|
sDec
|
|
29053
29153
|
).multipliedBy(secondaryTokenPrice.price);
|
|
29054
29154
|
const totalUsdValue = primaryTokenUsd.plus(secondaryTokenUsd).toNumber();
|
|
29055
|
-
if (totalUsdValue === 0 || primaryTokenAmount.eq(0) || secondaryTokenAmount.eq(0)) {
|
|
29155
|
+
if ((totalUsdValue === 0 || primaryTokenAmount.eq(0) || secondaryTokenAmount.eq(0)) && this.metadata.settings?.liveStatus === "Active" /* ACTIVE */) {
|
|
29056
29156
|
logger.warn(
|
|
29057
29157
|
`${this.metadata.name}:getTVL - Zero value detected: usdValue=${totalUsdValue}, primaryTokenAmount=${primaryTokenAmount.toString()}, secondaryTokenAmount=${secondaryTokenAmount.toString()}, primaryTokenPrice=${primaryTokenPrice.price}, secondaryTokenPrice=${secondaryTokenPrice.price}, primaryTokenUsd=${primaryTokenUsd.toNumber()}, secondaryTokenUsd=${secondaryTokenUsd.toNumber()}`
|
|
29058
29158
|
);
|
|
@@ -32411,7 +32511,7 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
32411
32511
|
this.metadata.depositTokens[0].symbol
|
|
32412
32512
|
);
|
|
32413
32513
|
const usdValue = Number(amount.toFixed(6)) * price.price;
|
|
32414
|
-
if (usdValue === 0 || amount.eq(0)) {
|
|
32514
|
+
if ((usdValue === 0 || amount.eq(0)) && this.metadata.settings?.liveStatus === "Active" /* ACTIVE */) {
|
|
32415
32515
|
logger.warn(
|
|
32416
32516
|
`${this.metadata.name}:getTVL - Zero value detected: usdValue=${usdValue}, amount=${amount.toString()}, price=${price.price}`
|
|
32417
32517
|
);
|
|
@@ -35182,6 +35282,7 @@ export {
|
|
|
35182
35282
|
PRICE_ROUTER,
|
|
35183
35283
|
Pragma,
|
|
35184
35284
|
Pricer,
|
|
35285
|
+
PricerAvnuApi,
|
|
35185
35286
|
PricerFromApi,
|
|
35186
35287
|
PricerLST,
|
|
35187
35288
|
Protocols,
|
package/dist/index.d.ts
CHANGED
|
@@ -109,6 +109,7 @@ interface TokenInfo {
|
|
|
109
109
|
displayDecimals: number;
|
|
110
110
|
priceProxySymbol?: string;
|
|
111
111
|
priceCheckAmount?: number;
|
|
112
|
+
dontPrice?: boolean;
|
|
112
113
|
}
|
|
113
114
|
declare enum Network {
|
|
114
115
|
mainnet = "mainnet",
|
|
@@ -426,18 +427,41 @@ declare abstract class PricerBase {
|
|
|
426
427
|
getPrice(tokenSymbol: string, blockNumber?: BlockIdentifier): Promise<PriceInfo>;
|
|
427
428
|
}
|
|
428
429
|
|
|
430
|
+
/**
|
|
431
|
+
* Polls Avnu impulse tokens API and keeps USD prices in memory for configured tokens.
|
|
432
|
+
* Price timestamp is set when each poll request completes.
|
|
433
|
+
*/
|
|
434
|
+
declare class PricerAvnuApi extends PricerBase {
|
|
435
|
+
protected prices: {
|
|
436
|
+
[key: string]: PriceInfo;
|
|
437
|
+
};
|
|
438
|
+
readonly refreshInterval = 15000;
|
|
439
|
+
readonly staleTime: number;
|
|
440
|
+
private pollTimer;
|
|
441
|
+
private loading;
|
|
442
|
+
constructor(config: IConfig, tokens: TokenInfo[]);
|
|
443
|
+
start(): void;
|
|
444
|
+
stop(): void;
|
|
445
|
+
isStale(timestamp: Date): boolean;
|
|
446
|
+
hasPrice(tokenSymbol: string): boolean;
|
|
447
|
+
getPrice(tokenSymbol: string): Promise<PriceInfo>;
|
|
448
|
+
protected _loadPrices(): Promise<void>;
|
|
449
|
+
}
|
|
450
|
+
|
|
429
451
|
interface PriceInfo {
|
|
430
452
|
price: number;
|
|
431
453
|
timestamp: Date;
|
|
432
454
|
}
|
|
455
|
+
type PriceMethod = 'AvnuApi' | 'Coinbase' | 'Coinmarketcap' | 'Ekubo' | 'Avnu';
|
|
433
456
|
declare class Pricer extends PricerBase {
|
|
434
457
|
protected prices: {
|
|
435
458
|
[key: string]: PriceInfo;
|
|
436
459
|
};
|
|
437
460
|
refreshInterval: number;
|
|
438
461
|
staleTime: number;
|
|
462
|
+
protected readonly avnuApiPricer: PricerAvnuApi;
|
|
439
463
|
protected methodToUse: {
|
|
440
|
-
[tokenSymbol: string]:
|
|
464
|
+
[tokenSymbol: string]: PriceMethod;
|
|
441
465
|
};
|
|
442
466
|
/**
|
|
443
467
|
* TOKENA and TOKENB are the two token names to get price of TokenA in terms of TokenB
|
|
@@ -452,7 +476,9 @@ declare class Pricer extends PricerBase {
|
|
|
452
476
|
assertNotStale(timestamp: Date, tokenName: string): void;
|
|
453
477
|
getPrice(tokenSymbol: string, blockNumber?: BlockIdentifier): Promise<PriceInfo>;
|
|
454
478
|
protected _loadPrices(onUpdate?: (tokenSymbol: string) => void): void;
|
|
455
|
-
_getPrice(token: TokenInfo
|
|
479
|
+
_getPrice(token: TokenInfo): Promise<number>;
|
|
480
|
+
protected _tryPriceMethod(token: TokenInfo, method: PriceMethod): Promise<number>;
|
|
481
|
+
_getPriceAvnuApi(token: TokenInfo): Promise<number>;
|
|
456
482
|
_getPriceCoinbase(token: TokenInfo): Promise<number>;
|
|
457
483
|
_getPriceCoinMarketCap(token: TokenInfo): Promise<number>;
|
|
458
484
|
_getAvnuPrice(token: TokenInfo, amountIn?: Web3Number, retry?: number): Promise<number>;
|
|
@@ -2384,4 +2410,4 @@ declare class PasswordJsonCryptoUtil {
|
|
|
2384
2410
|
decrypt(encryptedData: string, password: string): any;
|
|
2385
2411
|
}
|
|
2386
2412
|
|
|
2387
|
-
export { APYType, AUMTypes, AVNU_EXCHANGE, AVNU_MIDDLEWARE, type AccessControlInfo, AccessControlType, type AccountInfo, type AdapterLeafType, type AllAccountsStore, type AmountInfo, type AmountsInfo, type ApproveCallParams, AuditStatus, AutoCompounderSTRK, type AvnuSwapCallParams, AvnuWrapper, BaseAdapter, type BaseAdapterConfig, BaseStrategy, type CLVaultStrategySettings, CommonAdapter, type CommonAdapterConfig, ContractAddr, type DecreaseLeverParams, Deployer, type DualActionAmount, type DualTokenInfo, ERC20, type EkuboBounds, EkuboCLVault, EkuboCLVaultStrategies, type EkuboPoolKey, EkuboPricer, type EkuboQuote, EkuboQuoter, type EkuboRouteNode, type EkuboSplit, type FAQ, FactoryStrategyType, FatalError, type FilterOption, type FlashloanCallParams, FlowChartColors, type GenerateCallFn, Global, HyperLSTStrategies, type HyperLSTStrategySettings, type IConfig, type ICurator, type IInvestmentFlow, ILending, type ILendingMetadata, type ILendingPosition, type IProtocol, type IStrategyMetadata, type IncreaseLeverParams, Initializable, type InputModeFromAction, InstantWithdrawalVault, LSTAPRService, LSTPriceType, type LSTStats, type LeafAdapterFn, type LeafData, type LendingToken, type ManageCall, MarginType, MyNumber, type NetAPYDetails, type NetAPYSplit, Network, PRICE_ROUTER, PasswordJsonCryptoUtil, type PositionAPY, type PositionInfo, Pragma, type PriceInfo, Pricer, PricerFromApi, PricerLST, PricerRedis, Protocols, type RedemptionInfo, type RequiredFields, type RequiredKeys, type RequiredStoreConfig, type RiskFactor, RiskType, type Route, type RouteNode, SIMPLE_SANITIZER, SIMPLE_SANITIZER_V2, SIMPLE_SANITIZER_VESU_V1_DELEGATIONS, type SecurityMetadata, SenseiStrategies, SenseiVault, type SenseiVaultSettings, type SingleActionAmount, type SingleTokenInfo, type SourceCodeInfo, SourceCodeType, StandardMerkleTree, type StandardMerkleTreeData, Store, type StoreConfig, type StrategyAlert, type StrategyApyHistoryUIConfig, type StrategyCapabilities, type StrategyFilterMetadata, type StrategyInputMode, StrategyLiveStatus, type StrategyMetadata, type StrategyRegistryEntry, type StrategySettings, StrategyTag, StrategyType, type SupportedPosition, type Swap, type SwapInfo, TelegramGroupNotif, TelegramNotif, type TokenAmount, type TokenInfo, UNIVERSAL_ADAPTERS, UNIVERSAL_MANAGE_IDS, UniversalLstMultiplierStrategy, type UniversalManageCall, UniversalStrategies, UniversalStrategy, type UniversalStrategySettings, UnwrapLabsCurator, type UserPositionCard, type UserPositionCardSubValueColor, type UserPositionCardsInput, type UserYoloInfo, VESU_SINGLETON, VESU_V2_MODIFY_POSITION_SANITIZER, type VaultPosition, VaultType, VesuAdapter, type VesuAdapterConfig, type VesuAmount, VesuAmountDenomination, VesuAmountType, type VesuDefiSpringRewardsCallParams, type VesuModifyDelegationCallParams, type VesuModifyPositionCallParams, type VesuMultiplyCallParams, VesuPoolMetadata, VesuPools, VesuRebalance, type VesuRebalanceSettings, VesuRebalanceStrategies, Web3Number, YoLoVault, type YoloSettings, type YoloSpendingLevel, type YoloVaultSettings, type YoloVaultStatus, YoloVaultStrategies, ZkLend, assert, buildStrategyRegistry, createEkuboCLStrategy, createHyperLSTStrategy, createSenseiStrategy, createStrategy, createUniversalStrategy, createVesuRebalanceStrategy, createYoloVaultStrategy, detectCapabilities, extensionMap, getAPIUsingHeadlessBrowser, getAllStrategyMetadata, getAllStrategyTags, getContractDetails, getDefaultStoreConfig, getFilterMetadata, getLiveStrategies, getMainnetConfig, getNoRiskTags, getRiskColor, getRiskExplaination, getStrategiesByType, getStrategyTagDesciption, getStrategyTypeFromMetadata, getTrovesEndpoint, getVesuSingletonAddress, highlightTextWithLinks, type i257, isDualTokenStrategy, logger, toAmountsInfo, toBigInt };
|
|
2413
|
+
export { APYType, AUMTypes, AVNU_EXCHANGE, AVNU_MIDDLEWARE, type AccessControlInfo, AccessControlType, type AccountInfo, type AdapterLeafType, type AllAccountsStore, type AmountInfo, type AmountsInfo, type ApproveCallParams, AuditStatus, AutoCompounderSTRK, type AvnuSwapCallParams, AvnuWrapper, BaseAdapter, type BaseAdapterConfig, BaseStrategy, type CLVaultStrategySettings, CommonAdapter, type CommonAdapterConfig, ContractAddr, type DecreaseLeverParams, Deployer, type DualActionAmount, type DualTokenInfo, ERC20, type EkuboBounds, EkuboCLVault, EkuboCLVaultStrategies, type EkuboPoolKey, EkuboPricer, type EkuboQuote, EkuboQuoter, type EkuboRouteNode, type EkuboSplit, type FAQ, FactoryStrategyType, FatalError, type FilterOption, type FlashloanCallParams, FlowChartColors, type GenerateCallFn, Global, HyperLSTStrategies, type HyperLSTStrategySettings, type IConfig, type ICurator, type IInvestmentFlow, ILending, type ILendingMetadata, type ILendingPosition, type IProtocol, type IStrategyMetadata, type IncreaseLeverParams, Initializable, type InputModeFromAction, InstantWithdrawalVault, LSTAPRService, LSTPriceType, type LSTStats, type LeafAdapterFn, type LeafData, type LendingToken, type ManageCall, MarginType, MyNumber, type NetAPYDetails, type NetAPYSplit, Network, PRICE_ROUTER, PasswordJsonCryptoUtil, type PositionAPY, type PositionInfo, Pragma, type PriceInfo, Pricer, PricerAvnuApi, PricerFromApi, PricerLST, PricerRedis, Protocols, type RedemptionInfo, type RequiredFields, type RequiredKeys, type RequiredStoreConfig, type RiskFactor, RiskType, type Route, type RouteNode, SIMPLE_SANITIZER, SIMPLE_SANITIZER_V2, SIMPLE_SANITIZER_VESU_V1_DELEGATIONS, type SecurityMetadata, SenseiStrategies, SenseiVault, type SenseiVaultSettings, type SingleActionAmount, type SingleTokenInfo, type SourceCodeInfo, SourceCodeType, StandardMerkleTree, type StandardMerkleTreeData, Store, type StoreConfig, type StrategyAlert, type StrategyApyHistoryUIConfig, type StrategyCapabilities, type StrategyFilterMetadata, type StrategyInputMode, StrategyLiveStatus, type StrategyMetadata, type StrategyRegistryEntry, type StrategySettings, StrategyTag, StrategyType, type SupportedPosition, type Swap, type SwapInfo, TelegramGroupNotif, TelegramNotif, type TokenAmount, type TokenInfo, UNIVERSAL_ADAPTERS, UNIVERSAL_MANAGE_IDS, UniversalLstMultiplierStrategy, type UniversalManageCall, UniversalStrategies, UniversalStrategy, type UniversalStrategySettings, UnwrapLabsCurator, type UserPositionCard, type UserPositionCardSubValueColor, type UserPositionCardsInput, type UserYoloInfo, VESU_SINGLETON, VESU_V2_MODIFY_POSITION_SANITIZER, type VaultPosition, VaultType, VesuAdapter, type VesuAdapterConfig, type VesuAmount, VesuAmountDenomination, VesuAmountType, type VesuDefiSpringRewardsCallParams, type VesuModifyDelegationCallParams, type VesuModifyPositionCallParams, type VesuMultiplyCallParams, VesuPoolMetadata, VesuPools, VesuRebalance, type VesuRebalanceSettings, VesuRebalanceStrategies, Web3Number, YoLoVault, type YoloSettings, type YoloSpendingLevel, type YoloVaultSettings, type YoloVaultStatus, YoloVaultStrategies, ZkLend, assert, buildStrategyRegistry, createEkuboCLStrategy, createHyperLSTStrategy, createSenseiStrategy, createStrategy, createUniversalStrategy, createVesuRebalanceStrategy, createYoloVaultStrategy, detectCapabilities, extensionMap, getAPIUsingHeadlessBrowser, getAllStrategyMetadata, getAllStrategyTags, getContractDetails, getDefaultStoreConfig, getFilterMetadata, getLiveStrategies, getMainnetConfig, getNoRiskTags, getRiskColor, getRiskExplaination, getStrategiesByType, getStrategyTagDesciption, getStrategyTypeFromMetadata, getTrovesEndpoint, getVesuSingletonAddress, highlightTextWithLinks, type i257, isDualTokenStrategy, logger, toAmountsInfo, toBigInt };
|