@strkfarm/sdk 2.0.0-staging.70 → 2.0.0-staging.72

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strkfarm/sdk",
3
- "version": "2.0.0-staging.70",
3
+ "version": "2.0.0-staging.72",
4
4
  "description": "STRKFarm TS SDK (Meant for our internal use, but feel free to use it)",
5
5
  "typings": "dist/index.d.ts",
6
6
  "types": "dist/index.d.ts",
package/src/global.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import axios from 'axios';
2
- import { TokenInfo } from './interfaces';
2
+ import { TokenIndexingType, TokenInfo } from './interfaces';
3
3
  import { ContractAddr } from './dataTypes';
4
4
  import { logger } from '@/utils/logger';
5
5
 
@@ -22,7 +22,9 @@ const defaultTokens: TokenInfo[] = [{
22
22
  decimals: 18,
23
23
  coingeckId: 'starknet',
24
24
  displayDecimals: 2,
25
- priceCheckAmount: 1000,
25
+ priceCheckAmount: 5000,
26
+ priceMethod: 'Avnu',
27
+ indexingType: TokenIndexingType.INDEXER,
26
28
  }, {
27
29
  name: 'xSTRK',
28
30
  symbol: 'xSTRK',
@@ -30,8 +32,10 @@ const defaultTokens: TokenInfo[] = [{
30
32
  address: ContractAddr.from('0x028d709c875c0ceac3dce7065bec5328186dc89fe254527084d1689910954b0a'),
31
33
  decimals: 18,
32
34
  coingeckId: undefined,
33
- priceCheckAmount: 1000,
35
+ priceCheckAmount: 5000,
34
36
  displayDecimals: 2,
37
+ priceMethod: 'Avnu',
38
+ indexingType: TokenIndexingType.LST_SCRIPT,
35
39
  }, {
36
40
  name: 'ETH',
37
41
  symbol: 'ETH',
@@ -41,6 +45,7 @@ const defaultTokens: TokenInfo[] = [{
41
45
  coingeckId: undefined,
42
46
  priceCheckAmount: 0.1,
43
47
  displayDecimals: 6,
48
+ indexingType: TokenIndexingType.INDEXER,
44
49
  }, {
45
50
  name: 'USDC.e',
46
51
  symbol: 'USDC.e',
@@ -50,6 +55,8 @@ const defaultTokens: TokenInfo[] = [{
50
55
  coingeckId: undefined,
51
56
  displayDecimals: 2,
52
57
  priceCheckAmount: 1000,
58
+ priceProxySymbol: 'USDC',
59
+ indexingType: TokenIndexingType.PEGGED,
53
60
  }, {
54
61
  name: 'USDC',
55
62
  symbol: 'USDC',
@@ -59,6 +66,7 @@ const defaultTokens: TokenInfo[] = [{
59
66
  coingeckId: undefined,
60
67
  displayDecimals: 2,
61
68
  priceCheckAmount: 1000,
69
+ indexingType: TokenIndexingType.INDEXER,
62
70
  }, {
63
71
  name: 'USDT',
64
72
  symbol: 'USDT',
@@ -68,6 +76,7 @@ const defaultTokens: TokenInfo[] = [{
68
76
  coingeckId: undefined,
69
77
  priceCheckAmount: 1000,
70
78
  displayDecimals: 2,
79
+ indexingType: TokenIndexingType.INDEXER,
71
80
  }, {
72
81
  name: 'WBTC',
73
82
  symbol: 'WBTC',
@@ -77,6 +86,7 @@ const defaultTokens: TokenInfo[] = [{
77
86
  coingeckId: undefined,
78
87
  displayDecimals: 6,
79
88
  priceCheckAmount: 0.001, // 112000 * 0.0001 = $110.2
89
+ indexingType: TokenIndexingType.INDEXER,
80
90
  }, {
81
91
  name: 'tBTC',
82
92
  symbol: 'tBTC',
@@ -86,6 +96,8 @@ const defaultTokens: TokenInfo[] = [{
86
96
  coingeckId: undefined,
87
97
  displayDecimals: 6,
88
98
  priceCheckAmount: 0.001, // 112000 * 0.0001 = $110.2
99
+ priceProxySymbol: 'WBTC',
100
+ indexingType: TokenIndexingType.PEGGED,
89
101
  }, {
90
102
  name: 'solvBTC',
91
103
  symbol: 'solvBTC',
@@ -96,6 +108,7 @@ const defaultTokens: TokenInfo[] = [{
96
108
  priceProxySymbol: 'WBTC',
97
109
  displayDecimals: 6,
98
110
  priceCheckAmount: 0.0001, // 112000 * 0.0001 = $11.2
111
+ indexingType: TokenIndexingType.PEGGED,
99
112
  }, {
100
113
  name: 'LBTC',
101
114
  symbol: 'LBTC',
@@ -106,6 +119,7 @@ const defaultTokens: TokenInfo[] = [{
106
119
  displayDecimals: 6,
107
120
  priceProxySymbol: 'WBTC',
108
121
  priceCheckAmount: 0.0001, // 112000 * 0.0001 = $11.2
122
+ indexingType: TokenIndexingType.PEGGED,
109
123
  }, {
110
124
  name: 'xWBTC',
111
125
  symbol: 'xWBTC',
@@ -114,8 +128,9 @@ const defaultTokens: TokenInfo[] = [{
114
128
  decimals: 8,
115
129
  coingeckId: undefined,
116
130
  displayDecimals: 6,
117
- priceProxySymbol: 'WBTC',
118
131
  priceCheckAmount: 0.001, // 112000 * 0.0001 = $110.2
132
+ priceMethod: 'Avnu',
133
+ indexingType: TokenIndexingType.LST_SCRIPT,
119
134
  }, {
120
135
  name: 'xsBTC',
121
136
  symbol: 'xsBTC',
@@ -124,10 +139,10 @@ const defaultTokens: TokenInfo[] = [{
124
139
  decimals: 18,
125
140
  coingeckId: undefined,
126
141
  displayDecimals: 6,
127
- priceProxySymbol: 'WBTC',
128
142
  priceCheckAmount: 0.0001, // 112000 * 0.0001 = $11.2
143
+ priceMethod: 'Avnu',
144
+ indexingType: TokenIndexingType.LST_SCRIPT,
129
145
  }, {
130
- // todo upgrade proxy tokens once feeds are available
131
146
  name: 'xtBTC',
132
147
  symbol: 'xtBTC',
133
148
  logo: 'https://assets.strkfarm.com/integrations/tokens/xtbtc.svg',
@@ -136,7 +151,8 @@ const defaultTokens: TokenInfo[] = [{
136
151
  coingeckId: undefined,
137
152
  displayDecimals: 6,
138
153
  priceCheckAmount: 0.001, // 112000 * 0.0001 = $110.2
139
- priceProxySymbol: 'WBTC',
154
+ priceMethod: 'Avnu',
155
+ indexingType: TokenIndexingType.LST_SCRIPT,
140
156
  }, {
141
157
  name: 'xLBTC',
142
158
  symbol: 'xLBTC',
@@ -145,8 +161,9 @@ const defaultTokens: TokenInfo[] = [{
145
161
  decimals: 8,
146
162
  coingeckId: undefined,
147
163
  displayDecimals: 6,
148
- priceProxySymbol: 'WBTC',
149
164
  priceCheckAmount: 0.0001, // 112000 * 0.0001 = $11.2
165
+ priceMethod: 'Avnu',
166
+ indexingType: TokenIndexingType.LST_SCRIPT,
150
167
  }, {
151
168
  name: 'mRe7BTC',
152
169
  symbol: 'mRe7BTC',
@@ -157,6 +174,7 @@ const defaultTokens: TokenInfo[] = [{
157
174
  displayDecimals: 6,
158
175
  priceCheckAmount: 0.0001, // 112000 * 0.0001 = $11.2
159
176
  dontPrice: true,
177
+ indexingType: TokenIndexingType.IGNORE,
160
178
  }, {
161
179
  name: 'mRe7YIELD',
162
180
  symbol: 'mRe7YIELD',
@@ -167,6 +185,7 @@ const defaultTokens: TokenInfo[] = [{
167
185
  displayDecimals: 2,
168
186
  priceCheckAmount: 100,
169
187
  dontPrice: true,
188
+ indexingType: TokenIndexingType.IGNORE,
170
189
  }, {
171
190
  name: "fyeWBTC",
172
191
  symbol: "fyeWBTC",
@@ -177,6 +196,7 @@ const defaultTokens: TokenInfo[] = [{
177
196
  displayDecimals: 6,
178
197
  priceCheckAmount: 0.001, // 112000 * 0.0001 = $110.2
179
198
  dontPrice: true,
199
+ indexingType: TokenIndexingType.IGNORE,
180
200
  }, {
181
201
  name: "fyETH",
182
202
  symbol: "fyETH",
@@ -187,6 +207,7 @@ const defaultTokens: TokenInfo[] = [{
187
207
  displayDecimals: 4,
188
208
  priceCheckAmount: 0.1,
189
209
  dontPrice: true,
210
+ indexingType: TokenIndexingType.IGNORE,
190
211
  }, {
191
212
  name: "fyeUSDC",
192
213
  symbol: "fyeUSDC",
@@ -197,6 +218,7 @@ const defaultTokens: TokenInfo[] = [{
197
218
  displayDecimals: 2,
198
219
  priceCheckAmount: 100,
199
220
  dontPrice: true,
221
+ indexingType: TokenIndexingType.IGNORE,
200
222
  }, {
201
223
  name: 'strkBTC',
202
224
  symbol: 'strkBTC',
@@ -206,7 +228,9 @@ const defaultTokens: TokenInfo[] = [{
206
228
  coingeckId: undefined,
207
229
  displayDecimals: 6,
208
230
  priceCheckAmount: 0.001, // 112000 * 0.0001 = $110.2
231
+ priceMethod: 'Avnu',
209
232
  priceProxySymbol: 'WBTC',
233
+ indexingType: TokenIndexingType.PEGGED,
210
234
  }, {
211
235
  name: 'xstrkBTC',
212
236
  symbol: 'xstrkBTC',
@@ -216,8 +240,9 @@ const defaultTokens: TokenInfo[] = [{
216
240
  coingeckId: undefined,
217
241
  displayDecimals: 6,
218
242
  priceCheckAmount: 0.001,
219
- priceProxySymbol: 'WBTC',
220
- },]
243
+ priceMethod: 'Avnu',
244
+ indexingType: TokenIndexingType.LST_SCRIPT,
245
+ }];
221
246
  const tokens: TokenInfo[] = defaultTokens;
222
247
 
223
248
  /** Contains globally useful functions.
@@ -281,7 +306,8 @@ export class Global {
281
306
  decimals: token.decimals,
282
307
  logo: token.logoUri,
283
308
  coingeckId: token.extensions.coingeckoId,
284
- displayDecimals: 2
309
+ displayDecimals: 2,
310
+ indexingType: TokenIndexingType.IGNORE,
285
311
  });
286
312
  });
287
313
  console.log(tokens);
@@ -25,6 +25,14 @@ export interface RiskFactor {
25
25
  reason?: string; // optional reason for the risk factor
26
26
  }
27
27
 
28
+ export type PriceMethod = 'AvnuApi' | 'Coinbase' | 'Coinmarketcap' | 'Ekubo' | 'Avnu';
29
+ export enum TokenIndexingType {
30
+ PEGGED = "pegged",
31
+ INDEXER = "indexer",
32
+ LST_SCRIPT = "lstScript",
33
+ IGNORE = "ignore",
34
+ }
35
+
28
36
  export interface TokenInfo {
29
37
  name: string;
30
38
  symbol: string;
@@ -35,7 +43,9 @@ export interface TokenInfo {
35
43
  displayDecimals: number;
36
44
  priceProxySymbol?: string; // for tokens like illiquid tokens, we use a proxy symbol to get the price
37
45
  priceCheckAmount?: number; // for tokens like BTC, doing 1BTC price check may not be ideal, esp on illiquid netwrks like sn
46
+ priceMethod?: PriceMethod; // preferred price source; tried first, then falls back to other methods
38
47
  dontPrice?: boolean; // a flag that skips pricer to check these tokens.
48
+ indexingType: TokenIndexingType;
39
49
  }
40
50
 
41
51
  export enum Network {
@@ -174,6 +184,10 @@ export interface StrategyApyHistoryUIConfig {
174
184
  noApyHistoryMessage?: string;
175
185
  }
176
186
 
187
+ export interface FeeBps {
188
+ performanceFeeBps: number;
189
+ }
190
+
177
191
  /**
178
192
  * @property risk.riskFactor.factor - The risk factors that are considered for the strategy.
179
193
  * @property risk.riskFactor.factor - The value of the risk factor from 0 to 10, 0 being the lowest and 10 being the highest.
@@ -214,6 +228,7 @@ export interface IStrategyMetadata<T> {
214
228
  };
215
229
  apyMethodology?: string;
216
230
  realizedApyMethodology?: string;
231
+ feeBps?: FeeBps;
217
232
  additionalInfo: T;
218
233
  contractDetails: {
219
234
  address: ContractAddr;
@@ -7,7 +7,8 @@ import { PriceInfo } from "./pricer";
7
7
  export class EkuboPricer extends PricerBase {
8
8
  EKUBO_PRICE_FETCHER_ADDRESS = '0x04946fb4ad5237d97bbb1256eba2080c4fe1de156da6a7f83e3b4823bb6d7da1';
9
9
  readonly contract: Contract;
10
- private readonly USDC_ADDRESS = '0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8';
10
+ // Updating to new USDC_ADDRESS
11
+ private readonly USDC_ADDRESS = '0x033068F6539f8e6e6b131e6B2B814e6c34A5224bC66947c47DaB9dFeE93b35fb';
11
12
  private readonly USDC_DECIMALS = 6;
12
13
 
13
14
  constructor(config: IConfig, tokens: TokenInfo[]) {
@@ -1,6 +1,6 @@
1
1
  import axios from "axios";
2
2
  import { FatalError, Global } from "@/global";
3
- import { TokenInfo } from "@/interfaces/common";
3
+ import { PriceMethod, TokenInfo } from "@/interfaces/common";
4
4
  import { IConfig } from "@/interfaces/common";
5
5
  import { Web3Number } from "@/dataTypes";
6
6
  import { PricerBase } from "./pricerBase";
@@ -14,8 +14,6 @@ export interface PriceInfo {
14
14
  timestamp: Date
15
15
  }
16
16
 
17
- type PriceMethod = 'AvnuApi' | 'Coinbase' | 'Coinmarketcap' | 'Ekubo' | 'Avnu';
18
-
19
17
  const PRICE_METHOD_PRIORITY: PriceMethod[] = [
20
18
  'AvnuApi',
21
19
  'Coinbase',
@@ -164,22 +162,15 @@ export class Pricer extends PricerBase {
164
162
  }
165
163
 
166
164
  async _getPrice(token: TokenInfo): Promise<number> {
167
- const pinned = this.methodToUse[token.symbol];
168
- if (pinned) {
169
- logger.verbose(`Fetching price of ${token.symbol} using pinned ${pinned}`);
170
- try {
171
- return await this._tryPriceMethod(token, pinned);
172
- } catch (error: any) {
173
- console.warn(`${pinned}: pinned price failed [${token.symbol}]: `, error.message);
174
- delete this.methodToUse[token.symbol];
175
- }
176
- }
165
+ const methodsToTry = this._getMethodsToTry(token);
177
166
 
178
- for (const method of PRICE_METHOD_PRIORITY) {
167
+ for (const method of methodsToTry) {
179
168
  logger.verbose(`Fetching price of ${token.symbol} using ${method}`);
180
169
  try {
181
170
  const result = await this._tryPriceMethod(token, method);
182
- this.methodToUse[token.symbol] = method;
171
+ if (!token.priceMethod) {
172
+ this.methodToUse[token.symbol] = method;
173
+ }
183
174
  return result;
184
175
  } catch (error: any) {
185
176
  console.warn(`${method}: price err [${token.symbol}]: `, error.message);
@@ -189,6 +180,27 @@ export class Pricer extends PricerBase {
189
180
  throw new FatalError(`Price not found for ${token.symbol}`);
190
181
  }
191
182
 
183
+ protected _getMethodsToTry(token: TokenInfo): PriceMethod[] {
184
+ const methods: PriceMethod[] = [];
185
+
186
+ if (token.priceMethod) {
187
+ methods.push(token.priceMethod);
188
+ }
189
+
190
+ const pinned = this.methodToUse[token.symbol];
191
+ if (pinned && pinned !== token.priceMethod) {
192
+ methods.push(pinned);
193
+ }
194
+
195
+ for (const method of PRICE_METHOD_PRIORITY) {
196
+ if (!methods.includes(method)) {
197
+ methods.push(method);
198
+ }
199
+ }
200
+
201
+ return methods;
202
+ }
203
+
192
204
  protected async _tryPriceMethod(token: TokenInfo, method: PriceMethod): Promise<number> {
193
205
  switch (method) {
194
206
  case 'AvnuApi':
@@ -2,7 +2,7 @@ import axios from "axios";
2
2
  import BigNumber from "bignumber.js";
3
3
  import { Web3Number } from "@/dataTypes/bignumber.browser";
4
4
  import { FatalError, Global } from "@/global";
5
- import { TokenInfo } from "@/interfaces";
5
+ import { TokenIndexingType, TokenInfo } from "@/interfaces";
6
6
  import { ILending, ILendingPosition, LendingToken, MarginType } from "@/interfaces/lending";
7
7
  import { ContractAddr } from "@/dataTypes/address";
8
8
  import { IConfig } from "@/interfaces";
@@ -42,7 +42,8 @@ export class ZkLend extends ILending implements ILending {
42
42
  decimals: pool.token.decimals,
43
43
  borrowFactor: Web3Number.fromWei(pool.borrow_factor.value, pool.borrow_factor.decimals),
44
44
  collareralFactor,
45
- displayDecimals: 2
45
+ displayDecimals: 2,
46
+ indexingType: TokenIndexingType.IGNORE,
46
47
  }
47
48
  this.tokens.push(token);
48
49
  });
@@ -2443,6 +2443,9 @@ const xSTRKSTRK: IStrategyMetadata<CLVaultStrategySettings> = {
2443
2443
  apyMethodology:
2444
2444
  "APY based on 30-day historical performance, including fees and rewards.",
2445
2445
  realizedApyMethodology: "The realizedAPY is based on past 14 days performance by the vault",
2446
+ feeBps: {
2447
+ performanceFeeBps: 1000,
2448
+ },
2446
2449
  additionalInfo: {
2447
2450
  newBounds: {
2448
2451
  lower: -1,
@@ -2166,6 +2166,9 @@ function getStrategySettings(
2166
2166
  "Current annualized APY in terms of base asset of the LST. There is no additional fee taken by Troves on LST APY. We charge a 10% performance fee on the additional gain which is already accounted in the APY shown.",
2167
2167
  realizedApyMethodology:
2168
2168
  "The realizedAPY is based on past 14 days performance by the vault",
2169
+ feeBps: {
2170
+ performanceFeeBps: 1000,
2171
+ },
2169
2172
  tags: lstSymbol.includes("BTC")
2170
2173
  ? [StrategyTag.BTC, StrategyTag.LEVERED]
2171
2174
  : [StrategyTag.LEVERED],
@@ -1404,6 +1404,9 @@ const createUniversalStrategy = (params: {
1404
1404
  auditUrl: AUDIT_URL,
1405
1405
  protocols: [Protocols.VESU],
1406
1406
  realizedApyMethodology: "The realizedAPY is based on past 14 days performance by the vault",
1407
+ feeBps: {
1408
+ performanceFeeBps: 1000,
1409
+ },
1407
1410
  curator: UnwrapLabsCurator,
1408
1411
  settings: createUniversalSettings(params.tokenSymbol),
1409
1412
  contractDetails: getContractDetails(params.vaultSettings),
@@ -9,6 +9,7 @@ import {
9
9
  RiskFactor,
10
10
  SourceCodeType,
11
11
  StrategyLiveStatus,
12
+ TokenIndexingType,
12
13
  TokenInfo,
13
14
  UnwrapLabsCurator,
14
15
  VaultPosition,
@@ -875,6 +876,7 @@ const vesuPrimeUSDC: TokenInfo = {
875
876
  decimals: 18,
876
877
  logo: usdc.logo,
877
878
  displayDecimals: 2,
879
+ indexingType: TokenIndexingType.IGNORE,
878
880
  };
879
881
 
880
882
  const strk = Global.getDefaultTokens().find((t) => t.symbol === "STRK")!;
@@ -1042,6 +1044,9 @@ export const YoloVaultStrategies: IStrategyMetadata<YoloVaultSettings>[] = yoloV
1042
1044
  },
1043
1045
  apyMethodology:
1044
1046
  "Not a primary yield strategy. Funds earn yield when idle, but the main return comes from BTC price appreciation and your conviction to hold. This vault simply helps you accumulate more BTC.",
1047
+ feeBps: {
1048
+ performanceFeeBps: 1000,
1049
+ },
1045
1050
  additionalInfo: {
1046
1051
  mainToken: yoloConfig.mainToken,
1047
1052
  secondaryToken: yoloConfig.secondaryToken,