@curvefi/llamalend-api 1.0.2 → 1.0.4
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/lib/constants/abis/crvUSD/controller_v2.json +979 -0
- package/lib/constants/aliases.js +7 -7
- package/lib/interfaces.d.ts +2 -2
- package/lib/lendMarkets/LendMarketTemplate.js +27 -6
- package/lib/llamalend.js +65 -38
- package/lib/mintMarkets/MintMarketTemplate.js +1 -1
- package/lib/utils.js +2 -2
- package/package.json +1 -1
- package/src/constants/abis/crvUSD/controller_v2.json +979 -0
- package/src/constants/aliases.ts +7 -7
- package/src/interfaces.ts +2 -2
- package/src/lendMarkets/LendMarketTemplate.ts +27 -2
- package/src/llamalend.ts +34 -4
- package/src/mintMarkets/MintMarketTemplate.ts +1 -1
- package/src/utils.ts +2 -2
package/src/constants/aliases.ts
CHANGED
|
@@ -125,17 +125,17 @@ export const ALIASES_FRAXTAL = lowerCaseValues({
|
|
|
125
125
|
"crv": "0x331B9182088e2A7d6D3Fe4742AbA1fB231aEcc56",
|
|
126
126
|
"one_way_factory": "0xf3c9bdAB17B7016fBE3B77D17b1602A7db93ac66",
|
|
127
127
|
"gauge_controller": "0x0000000000000000000000000000000000000000", // <--- TODO CHANGE
|
|
128
|
-
"
|
|
128
|
+
"gauge_factory_old": "0xeF672bD94913CB6f1d2812a6e18c1fFdEd8eFf5c",
|
|
129
|
+
"gauge_factory": "0x0b8d6b6cefc7aa1c2852442e518443b1b22e1c52",
|
|
129
130
|
"leverage_zap": "0x37c5ab57AF7100Bdc9B668d766e193CCbF6614FD", // odos
|
|
130
131
|
"leverage_markets_start_id": "0",
|
|
131
132
|
});
|
|
132
133
|
|
|
133
134
|
export const ALIASES_SONIC = lowerCaseValues({
|
|
134
|
-
"crv": "
|
|
135
|
-
"one_way_factory": "
|
|
135
|
+
"crv": "0x5Af79133999f7908953E94b7A5CF367740Ebee35",
|
|
136
|
+
"one_way_factory": "0x30d1859dad5a52ae03b6e259d1b48c4b12933993",
|
|
136
137
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
137
|
-
"gauge_factory": "
|
|
138
|
-
|
|
139
|
-
"
|
|
140
|
-
"leverage_markets_start_id": "9",
|
|
138
|
+
"gauge_factory": "0xf3A431008396df8A8b2DF492C913706BDB0874ef",
|
|
139
|
+
"leverage_zap": "0x5552b631e2aD801fAa129Aacf4B701071cC9D1f7", // odos
|
|
140
|
+
"leverage_markets_start_id": "0",
|
|
141
141
|
});
|
package/src/interfaces.ts
CHANGED
|
@@ -5,8 +5,8 @@ export interface IDict<T> {
|
|
|
5
5
|
[index: string]: T,
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
export type INetworkName = "ethereum" | "optimism" | "bsc" | "xdai" | "polygon" | "x-layer" | "fantom" | "fraxtal" | "zksync" | "moonbeam" | "kava" | "mantle" | "base" | "arbitrum" | "celo" | "avalanche" | "aurora";
|
|
9
|
-
export type IChainId = 1 | 10 | 56 | 100 | 137 | 196 | 250 | 252 | 324 | 1284 | 2222 | 5000 | 8453 | 42161 | 42220 | 43114 | 1313161554;
|
|
8
|
+
export type INetworkName = "ethereum" | "optimism" | "bsc" | "xdai" | "polygon" | 'sonic' | "x-layer" | "fantom" | "fraxtal" | "zksync" | "moonbeam" | "kava" | "mantle" | "base" | "arbitrum" | "celo" | "avalanche" | "aurora";
|
|
9
|
+
export type IChainId = 1 | 10 | 56 | 100 | 137 | 146 | 196 | 250 | 252 | 324 | 1284 | 2222 | 5000 | 8453 | 42161 | 42220 | 43114 | 1313161554;
|
|
10
10
|
export type IPoolFactory = "main" | "crypto" | "factory" | "factory-crvusd" | "factory-crypto" | "factory-twocrypto" | "factory-tricrypto" | "factory-stable-ng";
|
|
11
11
|
export interface ICurveContract {
|
|
12
12
|
contract: Contract,
|
|
@@ -723,7 +723,32 @@ export class LendMarketTemplate {
|
|
|
723
723
|
|
|
724
724
|
private async _vaultClaimCrv(estimateGas: boolean): Promise<string | TGas> {
|
|
725
725
|
if (this.vaultRewardsOnly()) throw Error(`${this.name} has Rewards-Only Gauge. Use claimRewards instead`);
|
|
726
|
-
|
|
726
|
+
|
|
727
|
+
let isOldFactory = false;
|
|
728
|
+
let contract;
|
|
729
|
+
|
|
730
|
+
if (llamalend.chainId !== 1) {
|
|
731
|
+
if (llamalend.constants.ALIASES.gauge_factory_old && llamalend.constants.ALIASES.gauge_factory_old !== llamalend.constants.ZERO_ADDRESS) {
|
|
732
|
+
const oldFactoryContract = llamalend.contracts[llamalend.constants.ALIASES.gauge_factory_old].contract;
|
|
733
|
+
const lpToken = await llamalend.contracts[this.addresses.gauge].contract.lp_token();
|
|
734
|
+
const gaugeAddress = await oldFactoryContract.get_gauge_from_lp_token(lpToken);
|
|
735
|
+
|
|
736
|
+
isOldFactory = gaugeAddress.toLowerCase() === this.addresses.gauge.toLowerCase();
|
|
737
|
+
|
|
738
|
+
if (isOldFactory) {
|
|
739
|
+
contract = oldFactoryContract;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
if (!isOldFactory) {
|
|
745
|
+
contract = llamalend.contracts[llamalend.constants.ALIASES.minter].contract
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
if(!contract) {
|
|
749
|
+
throw Error(`${this.name} couldn't match gauge factory`);
|
|
750
|
+
}
|
|
751
|
+
|
|
727
752
|
const gas = await contract.mint.estimateGas(this.addresses.gauge, llamalend.constantOptions);
|
|
728
753
|
if (estimateGas) return smartNumber(gas);
|
|
729
754
|
|
|
@@ -1010,7 +1035,7 @@ export class LendMarketTemplate {
|
|
|
1010
1035
|
private statsBandsInfo = memoize(async (): Promise<{ activeBand: number, maxBand: number, minBand: number, liquidationBand: number | null }> => {
|
|
1011
1036
|
const ammContract = llamalend.contracts[this.addresses.amm].multicallContract;
|
|
1012
1037
|
const calls = [
|
|
1013
|
-
ammContract.
|
|
1038
|
+
ammContract.active_band_with_skip(),
|
|
1014
1039
|
ammContract.max_band(),
|
|
1015
1040
|
ammContract.min_band(),
|
|
1016
1041
|
]
|
package/src/llamalend.ts
CHANGED
|
@@ -32,6 +32,7 @@ import gasOracleBlobABI from './constants/abis/gas_oracle_optimism_blob.json' as
|
|
|
32
32
|
// crvUSD ABIs
|
|
33
33
|
import llammaABI from "./constants/abis/crvUSD/llamma.json" assert { type: 'json'};
|
|
34
34
|
import controllerABI from "./constants/abis/crvUSD/controller.json" assert { type: 'json'};
|
|
35
|
+
import controllerV2ABI from "./constants/abis/crvUSD/controller_v2.json";
|
|
35
36
|
import PegKeeper from "./constants/abis/crvUSD/PegKeeper.json" assert { type: 'json'};
|
|
36
37
|
import FactoryABI from "./constants/abis/crvUSD/Factory.json" assert { type: 'json'};
|
|
37
38
|
import MonetaryPolicy2ABI from "./constants/abis/crvUSD/MonetaryPolicy2.json" assert { type: 'json'};
|
|
@@ -352,8 +353,18 @@ class Llamalend implements ILlamalend {
|
|
|
352
353
|
this.setContract(this.constants.ALIASES.minter, MinterABI);
|
|
353
354
|
this.setContract(this.constants.ALIASES.gauge_factory, GaugeFactoryMainnetABI);
|
|
354
355
|
} else {
|
|
355
|
-
this.constants.ALIASES.
|
|
356
|
-
|
|
356
|
+
if(this.constants.ALIASES.gauge_factory_old && this.constants.ALIASES.gauge_factory_old !== this.constants.ZERO_ADDRESS) {
|
|
357
|
+
// set old gauge factory
|
|
358
|
+
this.constants.ALIASES.minter_old = this.constants.ALIASES.gauge_factory_old;
|
|
359
|
+
this.setContract(this.constants.ALIASES.gauge_factory_old, GaugeFactorySidechainABI);
|
|
360
|
+
|
|
361
|
+
// set new gauge factory
|
|
362
|
+
this.constants.ALIASES.minter = this.constants.ALIASES.gauge_factory;
|
|
363
|
+
this.setContract(this.constants.ALIASES.gauge_factory, GaugeFactorySidechainABI);
|
|
364
|
+
} else {
|
|
365
|
+
this.constants.ALIASES.minter = this.constants.ALIASES.gauge_factory;
|
|
366
|
+
this.setContract(this.constants.ALIASES.gauge_factory, GaugeFactorySidechainABI);
|
|
367
|
+
}
|
|
357
368
|
}
|
|
358
369
|
|
|
359
370
|
// crvUSD contracts
|
|
@@ -415,10 +426,29 @@ class Llamalend implements ILlamalend {
|
|
|
415
426
|
return x;
|
|
416
427
|
});
|
|
417
428
|
|
|
429
|
+
calls = [];
|
|
430
|
+
|
|
431
|
+
for(const amm of amms) {
|
|
432
|
+
this.setContract(amm, llammaABI);
|
|
433
|
+
calls.push(
|
|
434
|
+
this.contracts[amm].multicallContract.A()
|
|
435
|
+
)
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
const AParams = (await this.multicallProvider.all(calls)).map((x) => {
|
|
439
|
+
return Number(x)
|
|
440
|
+
});
|
|
441
|
+
|
|
418
442
|
for (let i = 0; i < collaterals.length; i++) {
|
|
419
443
|
const is_eth = collaterals[i] === this.constants.WETH;
|
|
420
444
|
const [collateral_symbol, collateral_decimals] = res.splice(0, 2) as [string, number];
|
|
421
|
-
|
|
445
|
+
|
|
446
|
+
if (i >= collaterals.length - 3) {
|
|
447
|
+
this.setContract(controllers[i], controllerV2ABI);
|
|
448
|
+
} else {
|
|
449
|
+
this.setContract(controllers[i], controllerABI);
|
|
450
|
+
}
|
|
451
|
+
|
|
422
452
|
this.setContract(controllers[i], controllerABI);
|
|
423
453
|
const monetary_policy_address = (await this.contracts[controllers[i]].contract.monetary_policy(this.constantOptions)).toLowerCase();
|
|
424
454
|
this.setContract(monetary_policy_address, MonetaryPolicy2ABI);
|
|
@@ -438,7 +468,7 @@ class Llamalend implements ILlamalend {
|
|
|
438
468
|
min_bands: 4,
|
|
439
469
|
max_bands: 50,
|
|
440
470
|
default_bands: 10,
|
|
441
|
-
A:
|
|
471
|
+
A: AParams[i],
|
|
442
472
|
monetary_policy_abi: MonetaryPolicy2ABI,
|
|
443
473
|
}
|
|
444
474
|
}
|
|
@@ -281,7 +281,7 @@ export class MintMarketTemplate {
|
|
|
281
281
|
});
|
|
282
282
|
|
|
283
283
|
private statsActiveBand = memoize(async (): Promise<number> => {
|
|
284
|
-
return (await llamalend.contracts[this.address].contract.
|
|
284
|
+
return (await llamalend.contracts[this.address].contract.active_band_with_skip()).toNumber()
|
|
285
285
|
},
|
|
286
286
|
{
|
|
287
287
|
promise: true,
|
package/src/utils.ts
CHANGED
|
@@ -295,7 +295,7 @@ export const _getUsdRate = async (assetId: string): Promise<number> => {
|
|
|
295
295
|
56: "binance-smart-chain",
|
|
296
296
|
100: 'xdai',
|
|
297
297
|
137: 'polygon-pos',
|
|
298
|
-
|
|
298
|
+
146: 'sonic',
|
|
299
299
|
196: 'x-layer',
|
|
300
300
|
250: 'fantom',
|
|
301
301
|
252: 'fraxtal',
|
|
@@ -316,7 +316,7 @@ export const _getUsdRate = async (assetId: string): Promise<number> => {
|
|
|
316
316
|
56: 'binancecoin',
|
|
317
317
|
100: 'xdai',
|
|
318
318
|
137: 'matic-network',
|
|
319
|
-
|
|
319
|
+
146: 'sonic-3',
|
|
320
320
|
196: 'okb',
|
|
321
321
|
250: 'fantom',
|
|
322
322
|
252: 'frax-ether',
|