@curvefi/llamalend-api 2.0.5 → 2.0.7

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.
@@ -50,4 +50,9 @@ jobs:
50
50
  cache: npm
51
51
  - run: npm ci
52
52
  - run: npm run build
53
- - run: npm publish
53
+ - name: Publish main as latest
54
+ if: github.ref_name == 'main'
55
+ run: npm publish --tag latest
56
+ - name: Publish v1 branch as legacy
57
+ if: github.ref_name == 'v1'
58
+ run: npm publish --tag legacy
@@ -130,18 +130,19 @@ This document tracks feature support across market versions.
130
130
 
131
131
  ## Stats Module (`market.stats`)
132
132
 
133
- | Method | v1 | v2 | Logic Unchanged | Parameters Unchanged | Return Type Unchanged |
134
- |--------|----|----|-----------------|----------------------|-----------------------|
135
- | parameters() | ✅ | ✅ | ✅ | ✅ | ✅ |
136
- | rates() | ✅ | ✅ | ✅ | ✅ | ✅ |
137
- | futureRates() | ✅ | ✅ | ✅ | ✅ | ✅ |
138
- | balances() | ✅ | ✅ | ✅ | ✅ | ✅ |
139
- | bandsInfo() | ✅ | ✅ | ✅ | ✅ | ✅ |
140
- | bandBalances() | ✅ | ✅ | ✅ | ✅ | ✅ |
141
- | bandsBalances() | ✅ | ✅ | ✅ | ✅ | ✅ |
142
- | totalDebt() | ✅ | ✅ | ✅ | ✅ | ✅ |
143
- | ammBalances() | ✅ | ✅ | ✅ | ✅ | ✅ |
133
+ | Method | v1 | v2 | Logic Unchanged | Parameters Unchanged | Return Type Unchanged |
134
+ |-------------------|----|----|-----------------|----------------------|-----------------------|
135
+ | parameters() | ✅ | ✅ | ✅ | ✅ | ✅ |
136
+ | rates() | ✅ | ✅ | ✅ | ✅ | ✅ |
137
+ | futureRates() | ✅ | ✅ | ✅ | ✅ | ✅ |
138
+ | balances() | ✅ | ✅ | ✅ | ✅ | ✅ |
139
+ | bandsInfo() | ✅ | ✅ | ✅ | ✅ | ✅ |
140
+ | bandBalances() | ✅ | ✅ | ✅ | ✅ | ✅ |
141
+ | bandsBalances() | ✅ | ✅ | ✅ | ✅ | ✅ |
142
+ | totalDebt() | ✅ | ✅ | ✅ | ✅ | ✅ |
143
+ | ammBalances() | ✅ | ✅ | ✅ | ✅ | ✅ |
144
144
  | capAndAvailable() | ✅ | ✅ | ❌ | ✅ | ❌ |
145
+ | oracleAddress() | ✅ | ✅ | ✅ | ✅ | ✅ |
145
146
 
146
147
  ### Update for `capAndAvailable` method
147
148
 
@@ -79,6 +79,7 @@ export class LendMarketTemplate {
79
79
  ammBalances: stats.statsAmmBalances.bind(stats),
80
80
  capAndAvailable: stats.statsCapAndAvailable.bind(stats),
81
81
  adminPercentage: stats.statsAdminPercentage.bind(stats),
82
+ oracleAddress: stats.oracleAddress.bind(stats),
82
83
  };
83
84
  this.wallet = {
84
85
  balances: wallet.balances.bind(wallet),
@@ -49,4 +49,5 @@ export interface IStatsV1 {
49
49
  availableForBorrow: string;
50
50
  }>;
51
51
  adminPercentage: () => Promise<string>;
52
+ oracleAddress: () => Promise<string>;
52
53
  }
@@ -49,4 +49,5 @@ export interface IStatsV2 {
49
49
  availableForBorrow: string;
50
50
  }>;
51
51
  adminPercentage: () => Promise<string>;
52
+ oracleAddress: () => Promise<string>;
52
53
  }
@@ -85,4 +85,5 @@ export declare class StatsBaseModule {
85
85
  availableForBorrow: string;
86
86
  }>;
87
87
  statsAdminPercentage: () => Promise<string>;
88
+ oracleAddress: (() => Promise<string>) & memoize.Memoized<() => Promise<string>>;
88
89
  }
@@ -122,6 +122,11 @@ export class StatsBaseModule {
122
122
  const _adminPercentage = yield this._fetchAdminPercentage();
123
123
  return formatUnits(_adminPercentage * BigInt(100));
124
124
  });
125
+ this.oracleAddress = memoize(() => __awaiter(this, void 0, void 0, function* () {
126
+ return yield this.llamalend.contracts[this.market.addresses.amm].contract.price_oracle_contract(this.llamalend.constantOptions);
127
+ }), {
128
+ promise: true,
129
+ });
125
130
  this.market = market;
126
131
  this.llamalend = market.getLlamalend();
127
132
  }
@@ -187,6 +187,7 @@ export declare class MintMarketTemplate {
187
187
  stablecoin: string;
188
188
  collateral: string;
189
189
  }>>;
190
+ oracleAddress: (() => Promise<string>) & memoize.Memoized<() => Promise<string>>;
190
191
  oraclePrice(): Promise<string>;
191
192
  oraclePriceBand(): Promise<number>;
192
193
  price(): Promise<string>;
@@ -106,6 +106,12 @@ export class MintMarketTemplate {
106
106
  promise: true,
107
107
  maxAge: 60 * 1000, // 1m
108
108
  });
109
+ this.oracleAddress = memoize(() => __awaiter(this, void 0, void 0, function* () {
110
+ const _address = yield this.llamalend.contracts[this.address].contract.price_oracle_contract(this.llamalend.constantOptions);
111
+ return _address;
112
+ }), {
113
+ promise: true,
114
+ });
109
115
  this.basePrice = memoize(() => __awaiter(this, void 0, void 0, function* () {
110
116
  const _price = yield this.llamalend.contracts[this.address].contract.get_base_price(this.llamalend.constantOptions);
111
117
  return formatUnits(_price);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/llamalend-api",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "description": "JavaScript library for Curve Lending",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",
@@ -177,6 +177,7 @@ export class LendMarketTemplate<V extends 'v1' | 'v2' = 'v1' | 'v2'> {
177
177
  ammBalances: stats.statsAmmBalances.bind(stats),
178
178
  capAndAvailable: stats.statsCapAndAvailable.bind(stats),
179
179
  adminPercentage: stats.statsAdminPercentage.bind(stats),
180
+ oracleAddress: stats.oracleAddress.bind(stats),
180
181
  } as StatsForVersion<V>
181
182
 
182
183
  this.wallet = {
@@ -19,4 +19,5 @@ export interface IStatsV1 {
19
19
  ammBalances: (isGetter?: boolean, useAPI?: boolean) => Promise<{ borrowed: string, collateral: string }>,
20
20
  capAndAvailable: (isGetter?: boolean, useAPI?: boolean) => Promise<{ borrowCap: string, available: string, totalAssets: string, availableForBorrow: string }>,
21
21
  adminPercentage: () => Promise<string>,
22
+ oracleAddress: () => Promise<string>,
22
23
  }
@@ -19,4 +19,5 @@ export interface IStatsV2 {
19
19
  ammBalances: (isGetter?: boolean, useAPI?: boolean) => Promise<{ borrowed: string, collateral: string }>,
20
20
  capAndAvailable: (isGetter?: boolean, useAPI?: boolean) => Promise<{ borrowCap: string, available: string, totalAssets: string, availableForBorrow: string }>,
21
21
  adminPercentage: () => Promise<string>,
22
+ oracleAddress: () => Promise<string>,
22
23
  }
@@ -311,4 +311,10 @@ export class StatsBaseModule {
311
311
  const _adminPercentage = await this._fetchAdminPercentage();
312
312
  return formatUnits(_adminPercentage * BigInt(100));
313
313
  }
314
+
315
+ public oracleAddress = memoize(async (): Promise<string> => {
316
+ return await this.llamalend.contracts[this.market.addresses.amm].contract.price_oracle_contract(this.llamalend.constantOptions) as string;
317
+ },{
318
+ promise: true,
319
+ });
314
320
  }
@@ -592,6 +592,14 @@ export class MintMarketTemplate {
592
592
  return res
593
593
  }
594
594
 
595
+ public oracleAddress = memoize(async (): Promise<string> => {
596
+ const _address = await this.llamalend.contracts[this.address].contract.price_oracle_contract(this.llamalend.constantOptions) as string;
597
+ return _address;
598
+ },
599
+ {
600
+ promise: true,
601
+ });
602
+
595
603
  public async oraclePrice(): Promise<string> {
596
604
  const _price = await this.llamalend.contracts[this.address].contract.price_oracle(this.llamalend.constantOptions) as bigint;
597
605
  return formatUnits(_price);