Skip to content

Commit

Permalink
Merge pull request #408 from curvefi/fix/curve-lite-constants
Browse files Browse the repository at this point in the history
feat: add getNetworkConstants
  • Loading branch information
fedorovdg authored Nov 12, 2024
2 parents 1f1b350 + 4c85e05 commit dae4559
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 43 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@curvefi/api",
"version": "2.65.1",
"version": "2.65.2",
"description": "JavaScript library for curve.fi",
"main": "lib/index.js",
"author": "Macket",
Expand Down
31 changes: 7 additions & 24 deletions src/curve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { getFactoryPoolData } from "./factory/factory.js";
import { getFactoryPoolsDataFromApi } from "./factory/factory-api.js";
import { getCryptoFactoryPoolData } from "./factory/factory-crypto.js";
import { getTricryptoFactoryPoolData } from "./factory/factory-tricrypto.js";
import {IPoolData, IDict, ICurve, INetworkName, IChainId, IFactoryPoolType, Abi} from "./interfaces";
import {IPoolData, IDict, ICurve, INetworkName, IChainId, IFactoryPoolType, Abi, INetworkConstants} from "./interfaces";
import ERC20Abi from './constants/abis/ERC20.json' assert { type: 'json' };
import cERC20Abi from './constants/abis/cERC20.json' assert { type: 'json' };
import yERC20Abi from './constants/abis/yERC20.json' assert { type: 'json' };
Expand Down Expand Up @@ -98,28 +98,7 @@ class Curve implements ICurve {
constantOptions: { gasLimit?: number };
options: { gasPrice?: number | bigint, maxFeePerGas?: number | bigint, maxPriorityFeePerGas?: number | bigint };
L1WeightedGasPrice?: number;
constants: {
NATIVE_TOKEN: { symbol: string, wrappedSymbol: string, address: string, wrappedAddress: string },
NETWORK_NAME: INetworkName,
ALIASES: IDict<string>,
POOLS_DATA: IDict<IPoolData>,
STABLE_FACTORY_CONSTANTS: { implementationABIDict?: IDict<any>, basePoolIdZapDict?: IDict<{ address: string, ABI: any }>, stableNgBasePoolZap?: string }
CRYPTO_FACTORY_CONSTANTS: { lpTokenBasePoolIdDict?: IDict<string>, basePoolIdZapDict?: IDict<{ address: string, ABI: any }>, tricryptoDeployImplementations?: IDict<string | number> }
FACTORY_POOLS_DATA: IDict<IPoolData>,
CRVUSD_FACTORY_POOLS_DATA: IDict<IPoolData>,
EYWA_FACTORY_POOLS_DATA: IDict<IPoolData>,
CRYPTO_FACTORY_POOLS_DATA: IDict<IPoolData>,
TWOCRYPTO_FACTORY_POOLS_DATA: IDict<IPoolData>
TRICRYPTO_FACTORY_POOLS_DATA: IDict<IPoolData>,
STABLE_NG_FACTORY_POOLS_DATA: IDict<IPoolData>,
BASE_POOLS: IDict<number>
LLAMMAS_DATA: IDict<IPoolData>,
COINS: IDict<string>,
DECIMALS: IDict<number>,
GAUGES: string[],
FACTORY_GAUGE_IMPLEMENTATIONS: IDict<IFactoryPoolType>,
ZERO_ADDRESS: string,
};
constants: INetworkConstants;

constructor() {
// @ts-ignore
Expand All @@ -135,7 +114,7 @@ class Curve implements ICurve {
this.feeData = {}
this.constantOptions = { gasLimit: 12000000 }
this.options = {};
this.constants ={
this.constants = {
NATIVE_TOKEN: NETWORK_CONSTANTS[1].NATIVE_COIN,
NETWORK_NAME: 'ethereum',
ALIASES: {},
Expand Down Expand Up @@ -814,6 +793,10 @@ class Curve implements ICurve {
feeData.maxPriorityFeePerGas;
}
}

getNetworkConstants = (): INetworkConstants => {
return this.constants
}
}

export const curve = new Curve();
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ const curve = {
hasDepositAndStake,
hasRouter,
getCurveLiteNetworks,
constants: _curve.constants,
getNetworkConstants: _curve.getNetworkConstants,
factory: {
fetchPools: _curve.fetchFactoryPools,
fetchNewPools: _curve.fetchNewFactoryPools,
Expand Down
41 changes: 24 additions & 17 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,29 @@ export interface IPoolData {
gauge_status?: Record<string, boolean> | null,
}

export interface INetworkConstants {
NATIVE_TOKEN: { symbol: string, wrappedSymbol: string, address: string, wrappedAddress: string },
NETWORK_NAME: INetworkName,
ALIASES: IDict<string>,
POOLS_DATA: IDict<IPoolData>,
STABLE_FACTORY_CONSTANTS: { implementationABIDict?: IDict<any>, basePoolIdZapDict?: IDict<{ address: string, ABI: any }>, stableNgBasePoolZap?: string }
CRYPTO_FACTORY_CONSTANTS: { lpTokenBasePoolIdDict?: IDict<string>, basePoolIdZapDict?: IDict<{ address: string, ABI: any }>, tricryptoDeployImplementations?: IDict<string | number> }
FACTORY_POOLS_DATA: IDict<IPoolData>,
STABLE_NG_FACTORY_POOLS_DATA: IDict<IPoolData>,
CRVUSD_FACTORY_POOLS_DATA: IDict<IPoolData>,
CRYPTO_FACTORY_POOLS_DATA: IDict<IPoolData>,
TWOCRYPTO_FACTORY_POOLS_DATA: IDict<IPoolData>,
TRICRYPTO_FACTORY_POOLS_DATA: IDict<IPoolData>,
EYWA_FACTORY_POOLS_DATA: IDict<IPoolData>,
BASE_POOLS: IDict<number>,
LLAMMAS_DATA: IDict<IPoolData>,
COINS: IDict<string>,
DECIMALS: IDict<number>,
GAUGES: string[],
FACTORY_GAUGE_IMPLEMENTATIONS: any,
ZERO_ADDRESS: string,
}

export interface ICurve {
provider: ethers.BrowserProvider | ethers.JsonRpcProvider,
multicallProvider: MulticallProvider,
Expand All @@ -63,23 +86,7 @@ export interface ICurve {
feeData: { gasPrice?: number, maxFeePerGas?: number, maxPriorityFeePerGas?: number },
constantOptions: { gasLimit?: number },
options: { gasPrice?: number | bigint, maxFeePerGas?: number | bigint, maxPriorityFeePerGas?: number | bigint },
constants: {
NATIVE_TOKEN: { symbol: string, wrappedSymbol: string, address: string, wrappedAddress: string },
NETWORK_NAME: INetworkName,
ALIASES: IDict<string>,
POOLS_DATA: IDict<IPoolData>,
STABLE_FACTORY_CONSTANTS: { implementationABIDict?: IDict<any>, basePoolIdZapDict?: IDict<{ address: string, ABI: any }>, stableNgBasePoolZap?: string }
CRYPTO_FACTORY_CONSTANTS: { lpTokenBasePoolIdDict?: IDict<string>, basePoolIdZapDict?: IDict<{ address: string, ABI: any }>, tricryptoDeployImplementations?: IDict<string | number> }
FACTORY_POOLS_DATA: IDict<IPoolData>,
CRVUSD_FACTORY_POOLS_DATA: IDict<IPoolData>,
CRYPTO_FACTORY_POOLS_DATA: IDict<IPoolData>,
TRICRYPTO_FACTORY_POOLS_DATA: IDict<IPoolData>,
BASE_POOLS: IDict<number>,
LLAMMAS_DATA: IDict<IPoolData>,
COINS: IDict<string>,
DECIMALS: IDict<number>,
GAUGES: string[],
};
constants: INetworkConstants,
setContract: (address: string | undefined, abi: any) => void,
}

Expand Down

0 comments on commit dae4559

Please sign in to comment.