@curvefi/llamalend-api 1.0.21 → 1.0.22-beta.2
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/.github/workflows/publish.yml +1 -0
- package/lib/external-api.d.ts +6 -4
- package/lib/external-api.js +116 -98
- package/lib/index.d.ts +138 -41
- package/lib/index.js +80 -75
- package/lib/lendMarkets/LendMarketTemplate.d.ts +3 -1
- package/lib/lendMarkets/LendMarketTemplate.js +333 -333
- package/lib/lendMarkets/lendMarketConstructor.d.ts +2 -1
- package/lib/lendMarkets/lendMarketConstructor.js +3 -4
- package/lib/llamalend.d.ts +2 -2
- package/lib/llamalend.js +12 -20
- package/lib/mintMarkets/MintMarketTemplate.d.ts +3 -1
- package/lib/mintMarkets/MintMarketTemplate.js +204 -204
- package/lib/mintMarkets/mintMarketConstructor.d.ts +2 -1
- package/lib/mintMarkets/mintMarketConstructor.js +2 -2
- package/lib/st-crvUSD.d.ts +29 -28
- package/lib/st-crvUSD.js +237 -173
- package/lib/utils.d.ts +20 -19
- package/lib/utils.js +290 -256
- package/package.json +14 -14
- package/src/external-api.ts +25 -11
- package/src/index.ts +88 -76
- package/src/lendMarkets/LendMarketTemplate.ts +348 -346
- package/src/lendMarkets/lendMarketConstructor.ts +4 -4
- package/src/llamalend.ts +42 -58
- package/src/mintMarkets/MintMarketTemplate.ts +206 -204
- package/src/mintMarkets/mintMarketConstructor.ts +3 -2
- package/src/st-crvUSD.ts +97 -96
- package/src/utils.ts +85 -82
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { LendMarketTemplate } from "./LendMarketTemplate.js";
|
|
2
|
-
|
|
2
|
+
import type { Llamalend } from "../llamalend.js";
|
|
3
|
+
export declare const getLendMarket: (this: Llamalend, lendMarketId: string) => LendMarketTemplate;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { LendMarketTemplate } from "./LendMarketTemplate.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return new LendMarketTemplate(lendMarketId, marketData);
|
|
2
|
+
export const getLendMarket = function (lendMarketId) {
|
|
3
|
+
const marketData = this.constants.ONE_WAY_MARKETS[lendMarketId];
|
|
4
|
+
return new LendMarketTemplate(lendMarketId, marketData, this);
|
|
6
5
|
};
|
package/lib/llamalend.d.ts
CHANGED
|
@@ -76,6 +76,6 @@ declare class Llamalend implements ILlamalend {
|
|
|
76
76
|
formatUnits(value: BigNumberish, unit?: string | Numeric): string;
|
|
77
77
|
parseUnits(value: string, unit?: string | Numeric): bigint;
|
|
78
78
|
updateFeeData(): Promise<void>;
|
|
79
|
+
_filterHiddenPools(pools: IDict<ILlamma>): Promise<IDict<ILlamma>>;
|
|
79
80
|
}
|
|
80
|
-
export
|
|
81
|
-
export {};
|
|
81
|
+
export { Llamalend };
|
package/lib/llamalend.js
CHANGED
|
@@ -42,7 +42,7 @@ import { LLAMMAS } from "./constants/llammas";
|
|
|
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";
|
|
45
|
-
import { _getMarketsData } from "./external-api.js";
|
|
45
|
+
import { _getHiddenPools, _getMarketsData } from "./external-api.js";
|
|
46
46
|
import { extractDecimals } from "./constants/utils.js";
|
|
47
47
|
export const NETWORK_CONSTANTS = {
|
|
48
48
|
1: {
|
|
@@ -344,12 +344,10 @@ class Llamalend {
|
|
|
344
344
|
});
|
|
345
345
|
this.address = '00000';
|
|
346
346
|
this.crvUsdAddress = COINS_ETHEREUM.crvusd;
|
|
347
|
-
// @ts-ignore
|
|
348
347
|
this.provider = null;
|
|
349
348
|
this.signer = null;
|
|
350
349
|
this.signerAddress = "";
|
|
351
350
|
this.chainId = 1;
|
|
352
|
-
// @ts-ignore
|
|
353
351
|
this.multicallProvider = null;
|
|
354
352
|
this.contracts = {};
|
|
355
353
|
this.feeData = {};
|
|
@@ -379,13 +377,10 @@ class Llamalend {
|
|
|
379
377
|
return __awaiter(this, arguments, void 0, function* (providerType, providerSettings, options = {} // gasPrice in Gwei
|
|
380
378
|
) {
|
|
381
379
|
var _a;
|
|
382
|
-
// @ts-ignore
|
|
383
380
|
this.provider = null;
|
|
384
|
-
// @ts-ignore
|
|
385
381
|
this.signer = null;
|
|
386
382
|
this.signerAddress = "";
|
|
387
383
|
this.chainId = 1;
|
|
388
|
-
// @ts-ignore
|
|
389
384
|
this.multicallProvider = null;
|
|
390
385
|
this.contracts = {};
|
|
391
386
|
this.feeData = {};
|
|
@@ -393,7 +388,7 @@ class Llamalend {
|
|
|
393
388
|
this.options = {};
|
|
394
389
|
this.constants = {
|
|
395
390
|
ONE_WAY_MARKETS: {},
|
|
396
|
-
LLAMMAS:
|
|
391
|
+
LLAMMAS: yield this._filterHiddenPools(LLAMMAS),
|
|
397
392
|
COINS: {},
|
|
398
393
|
DECIMALS: {},
|
|
399
394
|
NETWORK_NAME: 'ethereum',
|
|
@@ -610,24 +605,19 @@ class Llamalend {
|
|
|
610
605
|
const lendingInstance = this;
|
|
611
606
|
lendingInstance.setContract(lendingInstance.constants.ALIASES.gas_oracle, gasOracleABI);
|
|
612
607
|
lendingInstance.setContract(lendingInstance.constants.ALIASES.gas_oracle_blob, gasOracleBlobABI);
|
|
613
|
-
|
|
614
|
-
if (AbstractProvider.prototype.originalEstimate) {
|
|
615
|
-
// @ts-ignore
|
|
608
|
+
if ('originalEstimate' in AbstractProvider.prototype) {
|
|
616
609
|
AbstractProvider.prototype.estimateGas = AbstractProvider.prototype.originalEstimate;
|
|
617
610
|
}
|
|
618
611
|
const originalEstimate = AbstractProvider.prototype.estimateGas;
|
|
619
612
|
const oldEstimate = function (arg) {
|
|
620
613
|
return __awaiter(this, void 0, void 0, function* () {
|
|
621
|
-
// @ts-ignore
|
|
622
614
|
const originalEstimateFunc = originalEstimate.bind(this);
|
|
623
|
-
|
|
624
|
-
return gas;
|
|
615
|
+
return yield originalEstimateFunc(arg);
|
|
625
616
|
});
|
|
626
617
|
};
|
|
627
618
|
//Override
|
|
628
619
|
const newEstimate = function (arg) {
|
|
629
620
|
return __awaiter(this, void 0, void 0, function* () {
|
|
630
|
-
// @ts-ignore
|
|
631
621
|
const L2EstimateGas = originalEstimate.bind(this);
|
|
632
622
|
const L1GasUsed = yield lendingInstance.contracts[lendingInstance.constants.ALIASES.gas_oracle_blob].contract.getL1GasUsed(arg.data);
|
|
633
623
|
const L1Fee = yield lendingInstance.contracts[lendingInstance.constants.ALIASES.gas_oracle_blob].contract.getL1Fee(arg.data);
|
|
@@ -636,15 +626,11 @@ class Llamalend {
|
|
|
636
626
|
return [L2GasUsed, L1GasUsed];
|
|
637
627
|
});
|
|
638
628
|
};
|
|
639
|
-
// @ts-ignore
|
|
640
629
|
AbstractProvider.prototype.estimateGas = newEstimate;
|
|
641
|
-
// @ts-ignore
|
|
642
630
|
AbstractProvider.prototype.originalEstimate = oldEstimate;
|
|
643
631
|
}
|
|
644
632
|
else {
|
|
645
|
-
|
|
646
|
-
if (AbstractProvider.prototype.originalEstimate) {
|
|
647
|
-
// @ts-ignore
|
|
633
|
+
if ('originalEstimate' in AbstractProvider.prototype) {
|
|
648
634
|
AbstractProvider.prototype.estimateGas = AbstractProvider.prototype.originalEstimate;
|
|
649
635
|
}
|
|
650
636
|
}
|
|
@@ -690,5 +676,11 @@ class Llamalend {
|
|
|
690
676
|
}
|
|
691
677
|
});
|
|
692
678
|
}
|
|
679
|
+
_filterHiddenPools(pools) {
|
|
680
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
681
|
+
const hiddenPools = (yield _getHiddenPools())[this.constants.NETWORK_NAME] || [];
|
|
682
|
+
return Object.fromEntries(Object.entries(pools).filter(([id]) => !hiddenPools.includes(id)));
|
|
683
|
+
});
|
|
684
|
+
}
|
|
693
685
|
}
|
|
694
|
-
export
|
|
686
|
+
export { Llamalend };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import memoize from "memoizee";
|
|
2
|
+
import type { Llamalend } from "../llamalend.js";
|
|
2
3
|
import { IDict, TGas } from "../interfaces";
|
|
3
4
|
export declare class MintMarketTemplate {
|
|
5
|
+
private llamalend;
|
|
4
6
|
id: string;
|
|
5
7
|
address: string;
|
|
6
8
|
controller: string;
|
|
@@ -127,7 +129,7 @@ export declare class MintMarketTemplate {
|
|
|
127
129
|
repay: (collateral: number | string, slippage?: number) => Promise<number>;
|
|
128
130
|
};
|
|
129
131
|
};
|
|
130
|
-
constructor(id: string);
|
|
132
|
+
constructor(id: string, llamalend: Llamalend);
|
|
131
133
|
private statsParameters;
|
|
132
134
|
private statsBalances;
|
|
133
135
|
private statsMaxMinBands;
|