@curvefi/llamalend-api 1.0.21 → 1.0.22-beta.1
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 +5 -4
- package/lib/external-api.js +110 -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 +1 -2
- package/lib/llamalend.js +4 -18
- 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 +16 -12
- package/src/index.ts +88 -76
- package/src/lendMarkets/LendMarketTemplate.ts +348 -346
- package/src/lendMarkets/lendMarketConstructor.ts +4 -4
- package/src/llamalend.ts +35 -56
- 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,7 +1,7 @@
|
|
|
1
1
|
import { LendMarketTemplate} from "./LendMarketTemplate.js";
|
|
2
|
-
import {
|
|
2
|
+
import type { Llamalend } from "../llamalend.js";
|
|
3
3
|
|
|
4
|
-
export const getLendMarket = (lendMarketId: string): LendMarketTemplate
|
|
5
|
-
const marketData =
|
|
6
|
-
return new LendMarketTemplate(lendMarketId, marketData)
|
|
4
|
+
export const getLendMarket = function (this: Llamalend, lendMarketId: string): LendMarketTemplate {
|
|
5
|
+
const marketData = this.constants.ONE_WAY_MARKETS[lendMarketId];
|
|
6
|
+
return new LendMarketTemplate(lendMarketId, marketData, this)
|
|
7
7
|
}
|
package/src/llamalend.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { ethers,
|
|
2
|
-
Contract, Networkish, BigNumberish, Numeric, AbstractProvider } from "ethers";
|
|
1
|
+
import { type TransactionRequest, ethers, Contract, Networkish, BigNumberish, Numeric, AbstractProvider } from "ethers";
|
|
3
2
|
import { Provider as MulticallProvider, Contract as MulticallContract, Call } from '@curvefi/ethcall';
|
|
4
3
|
import {
|
|
5
4
|
IChainId,
|
|
@@ -14,21 +13,21 @@ import {
|
|
|
14
13
|
} from "./interfaces.js";
|
|
15
14
|
// OneWayMarket ABIs
|
|
16
15
|
import OneWayLendingFactoryABI from "./constants/abis/OneWayLendingFactoryABI.json" assert { type: 'json' };
|
|
17
|
-
import ERC20ABI from './constants/abis/ERC20.json' assert {
|
|
18
|
-
import ERC4626ABI from './constants/abis/ERC4626.json' assert {
|
|
19
|
-
import LlammaABI from './constants/abis/Llamma.json' assert {
|
|
20
|
-
import ControllerABI from './constants/abis/Controller.json' assert {
|
|
21
|
-
import MonetaryPolicyABI from './constants/abis/MonetaryPolicy.json' assert {
|
|
22
|
-
import VaultABI from './constants/abis/Vault.json' assert {
|
|
23
|
-
import GaugeABI from './constants/abis/GaugeV5.json' assert {
|
|
24
|
-
import SidechainGaugeABI from './constants/abis/SidechainGauge.json' assert {
|
|
25
|
-
import GaugeControllerABI from './constants/abis/GaugeController.json' assert {
|
|
26
|
-
import GaugeFactoryMainnetABI from './constants/abis/GaugeFactoryMainnet.json' assert {
|
|
27
|
-
import GaugeFactorySidechainABI from './constants/abis/GaugeFactorySidechain.json' assert {
|
|
28
|
-
import MinterABI from './constants/abis/Minter.json' assert {
|
|
29
|
-
import LeverageZapABI from './constants/abis/LeverageZap.json' assert {
|
|
30
|
-
import gasOracleABI from './constants/abis/gas_oracle_optimism.json' assert {
|
|
31
|
-
import gasOracleBlobABI from './constants/abis/gas_oracle_optimism_blob.json' assert {
|
|
16
|
+
import ERC20ABI from './constants/abis/ERC20.json' assert {type: 'json'};
|
|
17
|
+
import ERC4626ABI from './constants/abis/ERC4626.json' assert {type: 'json'};
|
|
18
|
+
import LlammaABI from './constants/abis/Llamma.json' assert {type: 'json'};
|
|
19
|
+
import ControllerABI from './constants/abis/Controller.json' assert {type: 'json'};
|
|
20
|
+
import MonetaryPolicyABI from './constants/abis/MonetaryPolicy.json' assert {type: 'json'};
|
|
21
|
+
import VaultABI from './constants/abis/Vault.json' assert {type: 'json'};
|
|
22
|
+
import GaugeABI from './constants/abis/GaugeV5.json' assert {type: 'json'};
|
|
23
|
+
import SidechainGaugeABI from './constants/abis/SidechainGauge.json' assert {type: 'json'};
|
|
24
|
+
import GaugeControllerABI from './constants/abis/GaugeController.json' assert {type: 'json'};
|
|
25
|
+
import GaugeFactoryMainnetABI from './constants/abis/GaugeFactoryMainnet.json' assert {type: 'json'};
|
|
26
|
+
import GaugeFactorySidechainABI from './constants/abis/GaugeFactorySidechain.json' assert {type: 'json'};
|
|
27
|
+
import MinterABI from './constants/abis/Minter.json' assert {type: 'json'};
|
|
28
|
+
import LeverageZapABI from './constants/abis/LeverageZap.json' assert {type: 'json'};
|
|
29
|
+
import gasOracleABI from './constants/abis/gas_oracle_optimism.json' assert {type: 'json'};
|
|
30
|
+
import gasOracleBlobABI from './constants/abis/gas_oracle_optimism_blob.json' assert {type: 'json'};
|
|
32
31
|
// crvUSD ABIs
|
|
33
32
|
import llammaABI from "./constants/abis/crvUSD/llamma.json" assert { type: 'json'};
|
|
34
33
|
import controllerABI from "./constants/abis/crvUSD/controller.json" assert { type: 'json'};
|
|
@@ -76,12 +75,12 @@ import {
|
|
|
76
75
|
COINS_FRAXTAL,
|
|
77
76
|
COINS_SONIC,
|
|
78
77
|
} from "./constants/coins.js";
|
|
79
|
-
import {
|
|
80
|
-
import {
|
|
81
|
-
import {
|
|
78
|
+
import {LLAMMAS} from "./constants/llammas";
|
|
79
|
+
import {L2Networks} from "./constants/L2Networks.js";
|
|
80
|
+
import {createCall, handleMultiCallResponse} from "./utils.js";
|
|
82
81
|
import {cacheKey, cacheStats} from "./cache/index.js";
|
|
83
82
|
import {_getMarketsData} from "./external-api.js";
|
|
84
|
-
import {
|
|
83
|
+
import {extractDecimals} from "./constants/utils.js";
|
|
85
84
|
|
|
86
85
|
export const NETWORK_CONSTANTS: { [index: number]: any } = {
|
|
87
86
|
1: {
|
|
@@ -199,13 +198,11 @@ class Llamalend implements ILlamalend {
|
|
|
199
198
|
constructor() {
|
|
200
199
|
this.address = '00000'
|
|
201
200
|
this.crvUsdAddress = COINS_ETHEREUM.crvusd;
|
|
202
|
-
|
|
203
|
-
this.provider = null;
|
|
201
|
+
this.provider = null as unknown as ethers.BrowserProvider | ethers.JsonRpcProvider;
|
|
204
202
|
this.signer = null;
|
|
205
203
|
this.signerAddress = "";
|
|
206
204
|
this.chainId = 1;
|
|
207
|
-
|
|
208
|
-
this.multicallProvider = null;
|
|
205
|
+
this.multicallProvider = null as unknown as MulticallProvider;
|
|
209
206
|
this.contracts = {};
|
|
210
207
|
this.feeData = {}
|
|
211
208
|
this.constantOptions = { gasLimit: 12000000 }
|
|
@@ -236,14 +233,11 @@ class Llamalend implements ILlamalend {
|
|
|
236
233
|
providerSettings: { url?: string, privateKey?: string, batchMaxCount? : number } | { externalProvider: ethers.Eip1193Provider } | { network?: Networkish, apiKey?: string },
|
|
237
234
|
options: { gasPrice?: number, maxFeePerGas?: number, maxPriorityFeePerGas?: number, chainId?: number } = {} // gasPrice in Gwei
|
|
238
235
|
): Promise<void> {
|
|
239
|
-
|
|
240
|
-
this.
|
|
241
|
-
// @ts-ignore
|
|
242
|
-
this.signer = null;
|
|
236
|
+
this.provider = null as unknown as ethers.BrowserProvider | ethers.JsonRpcProvider;
|
|
237
|
+
this.signer = null as unknown as ethers.Signer;
|
|
243
238
|
this.signerAddress = "";
|
|
244
239
|
this.chainId = 1;
|
|
245
|
-
|
|
246
|
-
this.multicallProvider = null;
|
|
240
|
+
this.multicallProvider = null as unknown as MulticallProvider;
|
|
247
241
|
this.contracts = {};
|
|
248
242
|
this.feeData = {}
|
|
249
243
|
this.constantOptions = { gasLimit: 12000000 }
|
|
@@ -491,47 +485,32 @@ class Llamalend implements ILlamalend {
|
|
|
491
485
|
lendingInstance.setContract(lendingInstance.constants.ALIASES.gas_oracle, gasOracleABI);
|
|
492
486
|
lendingInstance.setContract(lendingInstance.constants.ALIASES.gas_oracle_blob, gasOracleBlobABI);
|
|
493
487
|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
// @ts-ignore
|
|
497
|
-
AbstractProvider.prototype.estimateGas = AbstractProvider.prototype.originalEstimate;
|
|
488
|
+
if('originalEstimate' in AbstractProvider.prototype) {
|
|
489
|
+
AbstractProvider.prototype.estimateGas = AbstractProvider.prototype.originalEstimate as (_tx: TransactionRequest) => Promise<bigint>;
|
|
498
490
|
}
|
|
499
491
|
|
|
500
492
|
const originalEstimate = AbstractProvider.prototype.estimateGas;
|
|
501
493
|
|
|
502
|
-
const oldEstimate = async function(arg: any) {
|
|
503
|
-
// @ts-ignore
|
|
494
|
+
const oldEstimate = async function(this: any, arg: any) {
|
|
504
495
|
const originalEstimateFunc = originalEstimate.bind(this);
|
|
505
|
-
|
|
506
|
-
const gas = await originalEstimateFunc(arg);
|
|
507
|
-
|
|
508
|
-
return gas;
|
|
496
|
+
return await originalEstimateFunc(arg);
|
|
509
497
|
}
|
|
510
498
|
|
|
511
499
|
//Override
|
|
512
|
-
const newEstimate = async function(arg: any) {
|
|
513
|
-
// @ts-ignore
|
|
500
|
+
const newEstimate = async function(this: any, arg: any) {
|
|
514
501
|
const L2EstimateGas = originalEstimate.bind(this);
|
|
515
|
-
|
|
516
502
|
const L1GasUsed = await lendingInstance.contracts[lendingInstance.constants.ALIASES.gas_oracle_blob].contract.getL1GasUsed(arg.data);
|
|
517
503
|
const L1Fee = await lendingInstance.contracts[lendingInstance.constants.ALIASES.gas_oracle_blob].contract.getL1Fee(arg.data);
|
|
518
|
-
|
|
519
504
|
lendingInstance.L1WeightedGasPrice = Number(L1Fee)/Number(L1GasUsed);
|
|
520
|
-
|
|
521
505
|
const L2GasUsed = await L2EstimateGas(arg);
|
|
522
|
-
|
|
523
506
|
return [L2GasUsed,L1GasUsed];
|
|
524
507
|
}
|
|
525
508
|
|
|
526
|
-
|
|
527
|
-
AbstractProvider.prototype.
|
|
528
|
-
// @ts-ignore
|
|
529
|
-
AbstractProvider.prototype.originalEstimate = oldEstimate;
|
|
509
|
+
AbstractProvider.prototype.estimateGas = newEstimate as any;
|
|
510
|
+
(AbstractProvider.prototype as any).originalEstimate = oldEstimate;
|
|
530
511
|
} else {
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
// @ts-ignore
|
|
534
|
-
AbstractProvider.prototype.estimateGas = AbstractProvider.prototype.originalEstimate;
|
|
512
|
+
if('originalEstimate' in AbstractProvider.prototype) {
|
|
513
|
+
AbstractProvider.prototype.estimateGas = AbstractProvider.prototype.originalEstimate as (_tx: TransactionRequest) => Promise<bigint>;
|
|
535
514
|
}
|
|
536
515
|
}
|
|
537
516
|
}
|
|
@@ -820,4 +799,4 @@ class Llamalend implements ILlamalend {
|
|
|
820
799
|
}
|
|
821
800
|
}
|
|
822
801
|
|
|
823
|
-
export
|
|
802
|
+
export { Llamalend };
|