@curvefi/llamalend-api 2.2.1 → 2.2.3

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.
@@ -25,14 +25,14 @@ export const ALIASES_ARBITRUM = lowerCaseValues({
25
25
  export const ALIASES_OPTIMISM = lowerCaseValues({
26
26
  "crv": "0x0994206dfE8De6Ec6920FF4D779B0d950605Fb53",
27
27
  "one_way_factory": "0x5EA8f3D674C70b020586933A0a5b250734798BeF",
28
- "one_way_factory_v2": "0xb0cEE7943A9B840ca2670d4B9f705B9b578ed1af",
28
+ "one_way_factory_v2": "0x5F94073E3f51c1FFf92ffc6b4B06b7Af193B3640",
29
29
  "gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
30
30
  "gauge_factory_old": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
31
31
  "gauge_factory": "0x871fBD4E01012e2E8457346059e8C189d664DbA4",
32
32
  "old_gauge_end_index": "4",
33
33
  "leverage_zap_deprecated": "0xBFab8ebc836E1c4D81837798FC076D219C9a1855", // odos v3
34
34
  "leverage_zap_v2": "0xE94d1fBF399c27CCBf0185b2Dd11Bf0FA0f0D95C",
35
- "leverage_zap_v2_llv2": "0x29837e7a58436D91cC25Cf487dBed0EBF3865c00",
35
+ "leverage_zap_v2_llv2": "0x4b10E1774521c077a2887806fa60C56CeFa94cCC",
36
36
  "leverage_markets_start_id": "0",
37
37
  "gas_oracle": '0xc0d3C0d3C0d3c0D3C0D3C0d3C0d3C0D3C0D3000f',
38
38
  "gas_oracle_blob": '0x420000000000000000000000000000000000000f',
@@ -50,5 +50,6 @@ export declare class LendMarketTemplate<V extends 'v1' | 'v2' = 'v1' | 'v2'> {
50
50
  leverageZapV2: ILeverageZapV2;
51
51
  constructor(id: string, marketData: IOneWayMarket, llamalend: Llamalend);
52
52
  getLlamalend(): Llamalend;
53
+ getZapAddress(): string;
53
54
  }
54
55
  export {};
@@ -25,6 +25,10 @@ const versionModules = {
25
25
  LeverageZapV2: LeverageV2ZapV2Module,
26
26
  },
27
27
  };
28
+ const ZAP_ALIAS_BY_VERSION = {
29
+ v1: 'leverage_zap_v2',
30
+ v2: 'leverage_zap_v2_llv2',
31
+ };
28
32
  export class LendMarketTemplate {
29
33
  constructor(id, marketData, llamalend) {
30
34
  this.swapDataCache = {};
@@ -318,4 +322,7 @@ export class LendMarketTemplate {
318
322
  getLlamalend() {
319
323
  return this.llamalend;
320
324
  }
325
+ getZapAddress() {
326
+ return this.llamalend.constants.ALIASES[ZAP_ALIAS_BY_VERSION[this.version]];
327
+ }
321
328
  }
@@ -83,7 +83,7 @@ export const getFactoryMarketDataV2 = (llamalend) => __awaiter(void 0, void 0, v
83
83
  const collateral_tokens = [];
84
84
  const borrowed_tokens = [];
85
85
  const monetary_policies = [];
86
- const gauges = [];
86
+ const gauges = new Array(Number(markets_count)).fill(llamalend.constants.ZERO_ADDRESS);
87
87
  for (let i = 0; i < markets_count; i++) {
88
88
  const marketData = res[i];
89
89
  vaults.push(marketData[0].toLowerCase());
@@ -93,7 +93,12 @@ export const getFactoryMarketDataV2 = (llamalend) => __awaiter(void 0, void 0, v
93
93
  borrowed_tokens.push(marketData[4].toLowerCase());
94
94
  monetary_policies.push(marketData[6].toLowerCase());
95
95
  names.push(''); // new factory does not give names, it's generated at the market creation level
96
- gauges.push(llamalend.constants.ZERO_ADDRESS);
96
+ }
97
+ // Fetch gauges for non-mainnet chains. Mainnet will use the new approach of fetching gauges from the new factory.
98
+ const gaugeFactoryAddress = llamalend.constants.ALIASES.gauge_factory;
99
+ if (llamalend.chainId !== 1 && gaugeFactoryAddress && gaugeFactoryAddress !== llamalend.constants.ZERO_ADDRESS) {
100
+ const gaugeFactory = llamalend.contracts[gaugeFactoryAddress];
101
+ (yield llamalend.multicallProvider.all(vaults.map((vault) => createCall(gaugeFactory, "get_gauge_from_lp_token", [vault])))).forEach((gauge, i) => { gauges[i] = gauge.toLowerCase(); });
97
102
  }
98
103
  return {
99
104
  names,
@@ -344,4 +344,5 @@ export declare class MintMarketTemplate {
344
344
  currentLeverage(userAddress?: string): Promise<string>;
345
345
  currentPnL(userAddress?: string): Promise<Record<string, string>>;
346
346
  getLlamalend(): Llamalend;
347
+ getZapAddress(): string;
347
348
  }
@@ -1866,4 +1866,7 @@ export class MintMarketTemplate {
1866
1866
  getLlamalend() {
1867
1867
  return this.llamalend;
1868
1868
  }
1869
+ getZapAddress() {
1870
+ return this.leverageZap;
1871
+ }
1869
1872
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/llamalend-api",
3
- "version": "2.2.1",
3
+ "version": "2.2.3",
4
4
  "description": "JavaScript library for Curve Lending",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",
@@ -29,14 +29,14 @@ export const ALIASES_ARBITRUM = lowerCaseValues({
29
29
  export const ALIASES_OPTIMISM = lowerCaseValues({
30
30
  "crv": "0x0994206dfE8De6Ec6920FF4D779B0d950605Fb53",
31
31
  "one_way_factory": "0x5EA8f3D674C70b020586933A0a5b250734798BeF",
32
- "one_way_factory_v2": "0xb0cEE7943A9B840ca2670d4B9f705B9b578ed1af",
32
+ "one_way_factory_v2": "0x5F94073E3f51c1FFf92ffc6b4B06b7Af193B3640",
33
33
  "gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
34
34
  "gauge_factory_old": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
35
35
  "gauge_factory": "0x871fBD4E01012e2E8457346059e8C189d664DbA4",
36
36
  "old_gauge_end_index": "4",
37
37
  "leverage_zap_deprecated": "0xBFab8ebc836E1c4D81837798FC076D219C9a1855", // odos v3
38
38
  "leverage_zap_v2": "0xE94d1fBF399c27CCBf0185b2Dd11Bf0FA0f0D95C",
39
- "leverage_zap_v2_llv2": "0x29837e7a58436D91cC25Cf487dBed0EBF3865c00",
39
+ "leverage_zap_v2_llv2": "0x4b10E1774521c077a2887806fa60C56CeFa94cCC",
40
40
  "leverage_markets_start_id": "0",
41
41
  "gas_oracle": '0xc0d3C0d3C0d3c0D3C0D3C0d3C0d3C0D3C0D3000f',
42
42
  "gas_oracle_blob": '0x420000000000000000000000000000000000000f',
@@ -77,6 +77,11 @@ const versionModules: { v1: V1ModuleConstructors; v2: V2ModuleConstructors } = {
77
77
  },
78
78
  };
79
79
 
80
+ const ZAP_ALIAS_BY_VERSION: Record<'v1' | 'v2', string> = {
81
+ v1: 'leverage_zap_v2',
82
+ v2: 'leverage_zap_v2_llv2',
83
+ };
84
+
80
85
  export class LendMarketTemplate<V extends 'v1' | 'v2' = 'v1' | 'v2'> {
81
86
  private llamalend: Llamalend;
82
87
  id: string;
@@ -449,4 +454,8 @@ export class LendMarketTemplate<V extends 'v1' | 'v2' = 'v1' | 'v2'> {
449
454
  public getLlamalend(): Llamalend {
450
455
  return this.llamalend;
451
456
  }
457
+
458
+ public getZapAddress(): string {
459
+ return this.llamalend.constants.ALIASES[ZAP_ALIAS_BY_VERSION[this.version]];
460
+ }
452
461
  }
@@ -95,7 +95,7 @@ export const getFactoryMarketDataV2 = async (llamalend: Llamalend) => {
95
95
  const collateral_tokens: string[] = [];
96
96
  const borrowed_tokens: string[] = [];
97
97
  const monetary_policies: string[] = [];
98
- const gauges: string[] = [];
98
+ const gauges: string[] = new Array(Number(markets_count)).fill(llamalend.constants.ZERO_ADDRESS);
99
99
 
100
100
  for (let i = 0; i < markets_count; i++) {
101
101
  const marketData = res[i] as any;
@@ -107,7 +107,15 @@ export const getFactoryMarketDataV2 = async (llamalend: Llamalend) => {
107
107
  borrowed_tokens.push(marketData[4].toLowerCase());
108
108
  monetary_policies.push(marketData[6].toLowerCase());
109
109
  names.push(''); // new factory does not give names, it's generated at the market creation level
110
- gauges.push(llamalend.constants.ZERO_ADDRESS);
110
+ }
111
+
112
+ // Fetch gauges for non-mainnet chains. Mainnet will use the new approach of fetching gauges from the new factory.
113
+ const gaugeFactoryAddress = llamalend.constants.ALIASES.gauge_factory;
114
+ if (llamalend.chainId !== 1 && gaugeFactoryAddress && gaugeFactoryAddress !== llamalend.constants.ZERO_ADDRESS) {
115
+ const gaugeFactory = llamalend.contracts[gaugeFactoryAddress];
116
+ (await llamalend.multicallProvider.all(
117
+ vaults.map((vault: string) => createCall(gaugeFactory, "get_gauge_from_lp_token", [vault]))
118
+ ) as string[]).forEach((gauge, i) => { gauges[i] = gauge.toLowerCase(); });
111
119
  }
112
120
 
113
121
  return {
@@ -2013,4 +2013,8 @@ export class MintMarketTemplate {
2013
2013
  public getLlamalend(): Llamalend {
2014
2014
  return this.llamalend;
2015
2015
  }
2016
+
2017
+ public getZapAddress(): string {
2018
+ return this.leverageZap;
2019
+ }
2016
2020
  }