@curvefi/llamalend-api 1.0.38 → 1.0.40

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.
@@ -1,2 +1,2 @@
1
- import { IDict, ILlamma } from "../interfaces";
1
+ import { IDict, ILlamma } from "../interfaces.js";
2
2
  export declare const LLAMMAS: IDict<ILlamma>;
@@ -1,6 +1,6 @@
1
1
  import MonetaryPolicyABI from './abis/crvUSD/MonetaryPolicy.json' with { type: 'json' };
2
2
  import MonetaryPolicy2ABI from './abis/crvUSD/MonetaryPolicy2.json' with { type: 'json' };
3
- import { lowerCaseLlammasAddresses } from "./utils";
3
+ import { lowerCaseLlammasAddresses } from "./utils.js";
4
4
  export const LLAMMAS = lowerCaseLlammasAddresses({
5
5
  sfrxeth: {
6
6
  amm_address: '0x136e783846ef68C8Bd00a3369F787dF8d683a696',
@@ -1,4 +1,4 @@
1
- import { IDict, ILlamma } from "../interfaces";
1
+ import { IDict, ILlamma } from "../interfaces.js";
2
2
  export declare const lowerCaseValues: (dict: IDict<string>) => IDict<string>;
3
3
  export declare const lowerCaseLlammasAddresses: (llammas: IDict<ILlamma>) => IDict<ILlamma>;
4
4
  export declare const extractDecimals: (llammas: IDict<ILlamma>) => IDict<number>;
@@ -1,6 +1,6 @@
1
1
  import memoize from "memoizee";
2
2
  import type { Llamalend } from "./llamalend.js";
3
- import { IDict, IExtendedPoolDataFromApi, IMarketData, INetworkName, IQuoteOdos, IPoolType } from "./interfaces";
3
+ import { IDict, IExtendedPoolDataFromApi, IMarketData, INetworkName, IQuoteOdos, IPoolType } from "./interfaces.js";
4
4
  export declare const uncached_getAllPoolsFromApi: (network: INetworkName) => Promise<Record<IPoolType, IExtendedPoolDataFromApi>>;
5
5
  export declare const createUsdPricesDict: (allTypesExtendedPoolData: IExtendedPoolDataFromApi[]) => IDict<number>;
6
6
  type UserCollateral = {
package/lib/llamalend.js CHANGED
@@ -38,7 +38,7 @@ import LeverageZapCrvUSDABI from "./constants/abis/crvUSD/LeverageZap.json" with
38
38
  import DeleverageZapABI from "./constants/abis/crvUSD/DeleverageZap.json" with { type: 'json' };
39
39
  import { ALIASES_ETHEREUM, ALIASES_OPTIMISM, ALIASES_POLYGON, ALIASES_FANTOM, ALIASES_AVALANCHE, ALIASES_ARBITRUM, ALIASES_XDAI, ALIASES_MOONBEAM, ALIASES_AURORA, ALIASES_KAVA, ALIASES_CELO, ALIASES_ZKSYNC, ALIASES_BASE, ALIASES_BSC, ALIASES_FRAXTAL, ALIASES_SONIC, } from "./constants/aliases.js";
40
40
  import { COINS_ETHEREUM, COINS_OPTIMISM, COINS_POLYGON, COINS_FANTOM, COINS_AVALANCHE, COINS_ARBITRUM, COINS_XDAI, COINS_MOONBEAM, COINS_AURORA, COINS_KAVA, COINS_CELO, COINS_ZKSYNC, COINS_BASE, COINS_BSC, COINS_FRAXTAL, COINS_SONIC, } from "./constants/coins.js";
41
- import { LLAMMAS } from "./constants/llammas";
41
+ import { LLAMMAS } from "./constants/llammas.js";
42
42
  import { L2Networks } from "./constants/L2Networks.js";
43
43
  import { createCall, handleMultiCallResponse } from "./utils.js";
44
44
  import { cacheKey, cacheStats } from "./cache/index.js";
@@ -1,6 +1,6 @@
1
1
  import memoize from "memoizee";
2
2
  import type { Llamalend } from "../llamalend.js";
3
- import { IDict, ILlamma, TGas } from "../interfaces";
3
+ import { IDict, ILlamma, TGas } from "../interfaces.js";
4
4
  import { ILeverageV2 } from "./interfaces/leverage.js";
5
5
  export declare class MintMarketTemplate {
6
6
  private llamalend;
@@ -9,9 +9,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import memoize from "memoizee";
11
11
  import BigNumber from "bignumber.js";
12
- import { _getAddress, parseUnits, BN, toBN, fromBN, getBalances, ensureAllowance, hasAllowance, ensureAllowanceEstimateGas, isEth, _cutZeros, formatUnits, smartNumber, MAX_ALLOWANCE, MAX_ACTIVE_BAND, _mulBy1_3, DIGas, } from "../utils";
12
+ import { _getAddress, parseUnits, BN, toBN, fromBN, getBalances, ensureAllowance, hasAllowance, ensureAllowanceEstimateGas, isEth, _cutZeros, formatUnits, smartNumber, MAX_ALLOWANCE, MAX_ACTIVE_BAND, _mulBy1_3, DIGas, } from "../utils.js";
13
13
  import { _getUserCollateralCrvUsd, _getUserCollateralCrvUsdFull } from "../external-api.js";
14
- import { LeverageV2Module } from "./modules";
14
+ import { LeverageV2Module } from "./modules/index.js";
15
15
  export class MintMarketTemplate {
16
16
  constructor(id, llammaData, llamalend) {
17
17
  var _a;
@@ -1,4 +1,4 @@
1
- import { IDict, TAmount, TGas } from "../../interfaces";
1
+ import { IDict, TAmount, TGas } from "../../interfaces.js";
2
2
  export interface ILeverageV2 {
3
3
  hasLeverage: () => boolean;
4
4
  maxLeverage: (N: number) => Promise<string>;
@@ -1,3 +1,3 @@
1
- import { MintMarketTemplate } from "./MintMarketTemplate";
1
+ import { MintMarketTemplate } from "./MintMarketTemplate.js";
2
2
  import type { Llamalend } from "../llamalend.js";
3
3
  export declare const getMintMarket: (this: Llamalend, mintMarketId: string) => MintMarketTemplate;
@@ -1,4 +1,4 @@
1
- import { MintMarketTemplate } from "./MintMarketTemplate";
1
+ import { MintMarketTemplate } from "./MintMarketTemplate.js";
2
2
  export const getMintMarket = function (mintMarketId) {
3
3
  if (!(mintMarketId in this.mintMarkets)) {
4
4
  const llammaData = this.constants.LLAMMAS[mintMarketId];
package/lib/utils.js CHANGED
@@ -333,13 +333,13 @@ export const _getUsdRate = function (assetId) {
333
333
  const url = [nativeTokenName, 'ethereum', 'bitcoin', 'link', 'curve-dao-token', 'stasis-eurs'].includes(assetId.toLowerCase()) ?
334
334
  `https://api.coingecko.com/api/v3/simple/price?ids=${assetId}&vs_currencies=usd` :
335
335
  `https://api.coingecko.com/api/v3/simple/token_price/${chainName}?contract_addresses=${assetId}&vs_currencies=usd`;
336
- const response = yield fetch(url);
337
- const data = yield response.json();
338
336
  try {
337
+ const response = yield fetch(url);
338
+ const data = yield response.json();
339
339
  _usdRatesCache[assetId] = { 'rate': (_c = data[assetId]['usd']) !== null && _c !== void 0 ? _c : 0, 'time': Date.now() };
340
340
  }
341
- catch ( // TODO pay attention!
342
- _d) { // TODO pay attention!
341
+ catch (_d) {
342
+ // coingecko often fails due to 429 (rate limit) errors, due to missing CORS headers we get no details
343
343
  _usdRatesCache[assetId] = { 'rate': 0, 'time': Date.now() };
344
344
  }
345
345
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/llamalend-api",
3
- "version": "1.0.38",
3
+ "version": "1.0.40",
4
4
  "description": "JavaScript library for Curve Lending",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",
@@ -1,7 +1,7 @@
1
- import { IDict, ILlamma } from "../interfaces";
1
+ import { IDict, ILlamma } from "../interfaces.js";
2
2
  import MonetaryPolicyABI from './abis/crvUSD/MonetaryPolicy.json' with {type: 'json'};
3
3
  import MonetaryPolicy2ABI from './abis/crvUSD/MonetaryPolicy2.json' with {type: 'json'};
4
- import { lowerCaseLlammasAddresses } from "./utils";
4
+ import { lowerCaseLlammasAddresses } from "./utils.js";
5
5
 
6
6
 
7
7
  export const LLAMMAS: IDict<ILlamma> = lowerCaseLlammasAddresses({
@@ -1,4 +1,4 @@
1
- import {IDict, ILlamma} from "../interfaces";
1
+ import {IDict, ILlamma} from "../interfaces.js";
2
2
 
3
3
  export const lowerCaseValues = (dict: IDict<string>): IDict<string> =>
4
4
  Object.fromEntries(Object.entries(dict).map((entry) => [entry[0], entry[1].toLowerCase()]))
@@ -30,4 +30,3 @@ export const extractDecimals = (llammas: IDict<ILlamma>): IDict<number> => {
30
30
 
31
31
  return DECIMALS
32
32
  }
33
-
@@ -9,7 +9,7 @@ import {
9
9
  IQuoteOdos,
10
10
  IResponseApi,
11
11
  IPoolType,
12
- } from "./interfaces";
12
+ } from "./interfaces.js";
13
13
 
14
14
  const uncached_getPoolsFromApi = async (network: INetworkName, poolType: IPoolType): Promise<IExtendedPoolDataFromApi> => {
15
15
  const api = "https://api.curve.finance/api";
package/src/llamalend.ts CHANGED
@@ -75,7 +75,7 @@ import {
75
75
  COINS_FRAXTAL,
76
76
  COINS_SONIC,
77
77
  } from "./constants/coins.js";
78
- import {LLAMMAS} from "./constants/llammas";
78
+ import {LLAMMAS} from "./constants/llammas.js";
79
79
  import {L2Networks} from "./constants/L2Networks.js";
80
80
  import {createCall, handleMultiCallResponse} from "./utils.js";
81
81
  import {cacheKey, cacheStats} from "./cache/index.js";
@@ -814,4 +814,4 @@ class Llamalend implements ILlamalend {
814
814
  }
815
815
  }
816
816
 
817
- export { Llamalend };
817
+ export { Llamalend };
@@ -19,11 +19,11 @@ import {
19
19
  MAX_ACTIVE_BAND,
20
20
  _mulBy1_3,
21
21
  DIGas,
22
- } from "../utils";
23
- import {IDict, ILlamma, TGas} from "../interfaces";
22
+ } from "../utils.js";
23
+ import {IDict, ILlamma, TGas} from "../interfaces.js";
24
24
  import {_getUserCollateralCrvUsd, _getUserCollateralCrvUsdFull} from "../external-api.js";
25
25
  import { ILeverageV2 } from "./interfaces/leverage.js";
26
- import { LeverageV2Module } from "./modules";
26
+ import { LeverageV2Module } from "./modules/index.js";
27
27
 
28
28
 
29
29
  export class MintMarketTemplate {
@@ -1,4 +1,4 @@
1
- import {IDict, TAmount, TGas} from "../../interfaces";
1
+ import {IDict, TAmount, TGas} from "../../interfaces.js";
2
2
 
3
3
  export interface ILeverageV2 {
4
4
  hasLeverage: () => boolean,
@@ -101,4 +101,4 @@ export interface ILeverageV2 {
101
101
  repayApprove: (userCollateral: TAmount, userBorrowed: TAmount) => Promise<TGas>,
102
102
  repay: (stateCollateral: TAmount, userCollateral: TAmount, userBorrowed: TAmount, slippage?: number) => Promise<number>,
103
103
  }
104
- }
104
+ }
@@ -1,4 +1,4 @@
1
- import { MintMarketTemplate} from "./MintMarketTemplate";
1
+ import { MintMarketTemplate} from "./MintMarketTemplate.js";
2
2
  import type { Llamalend } from "../llamalend.js";
3
3
 
4
4
  export const getMintMarket = function (this: Llamalend, mintMarketId: string): MintMarketTemplate {
package/src/utils.ts CHANGED
@@ -361,11 +361,12 @@ export const _getUsdRate = async function (this: Llamalend, assetId: string): Pr
361
361
  const url = [nativeTokenName, 'ethereum', 'bitcoin', 'link', 'curve-dao-token', 'stasis-eurs'].includes(assetId.toLowerCase()) ?
362
362
  `https://api.coingecko.com/api/v3/simple/price?ids=${assetId}&vs_currencies=usd` :
363
363
  `https://api.coingecko.com/api/v3/simple/token_price/${chainName}?contract_addresses=${assetId}&vs_currencies=usd`
364
- const response = await fetch(url);
365
- const data = await response.json() as Record<string, { usd: number }>;
366
364
  try {
365
+ const response = await fetch(url);
366
+ const data = await response.json() as Record<string, { usd: number }>;
367
367
  _usdRatesCache[assetId] = {'rate': data[assetId]['usd'] ?? 0, 'time': Date.now()};
368
- } catch { // TODO pay attention!
368
+ } catch {
369
+ // coingecko often fails due to 429 (rate limit) errors, due to missing CORS headers we get no details
369
370
  _usdRatesCache[assetId] = {'rate': 0, 'time': Date.now()};
370
371
  }
371
372
  }