Skip to content

Commit

Permalink
Merge pull request #351 from curvefi/feat/add-mantle-network
Browse files Browse the repository at this point in the history
feat: add mantle network
  • Loading branch information
fedorovdg authored Jun 7, 2024
2 parents 8989889 + dc21c08 commit f2edc6f
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 7 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.58.11",
"version": "2.59.0",
"description": "JavaScript library for curve.fi",
"main": "lib/index.js",
"author": "Macket",
Expand Down
21 changes: 21 additions & 0 deletions src/constants/aliases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,27 @@ export const ALIASES_XLAYER = lowerCaseValues({
"factory_admin": '0x0000000000000000000000000000000000000000',
});

export const ALIASES_MANTLE = lowerCaseValues({
"crv": "0x0000000000000000000000000000000000000000",
"gauge_factory": "0xeF672bD94913CB6f1d2812a6e18c1fFdEd8eFf5c",
"voting_escrow": "0x0000000000000000000000000000000000000000",
"fee_distributor": "0x0000000000000000000000000000000000000000",
"gauge_controller": "0x0000000000000000000000000000000000000000",
"address_provider": "0x0000000000000000000000000000000000000000",
"router": "0x69522fb5337663d3B4dFB0030b881c1A750Adb4f",
"deposit_and_stake": "0x5552b631e2ad801faa129aacf4b701071cc9d1f7",
"stable_calc": "0x0fE38dCC905eC14F6099a83Ac5C93BF2601300CF",
"crypto_calc": '0xd6681e74eEA20d196c15038C580f721EF2aB6320',
"factory": '0x0000000000000000000000000000000000000000',
"crvusd_factory": '0x0000000000000000000000000000000000000000',
"eywa_factory": '0x0000000000000000000000000000000000000000',
"crypto_factory": '0x0000000000000000000000000000000000000000',
"twocrypto_factory": '0x98EE851a00abeE0d95D08cF4CA2BdCE32aeaAF7F',
"tricrypto_factory": '0x0C9D8c7e486e822C29488Ff51BFf0167B4650953',
"stable_ng_factory": '0x5eeE3091f747E60a045a2E715a4c71e600e31F6E',
"factory_admin": '0x0000000000000000000000000000000000000000',
});


const registry_exchange_deprecated = {
'1': '0x99a58482bd75cbab83b27ec03ca68ff489b5788f',
Expand Down
13 changes: 13 additions & 0 deletions src/constants/coins/mantle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { lowerCaseValues } from "../utils.js";
import { IDict } from "../../interfaces.js";


export const COINS_MANTLE: IDict<string> = lowerCaseValues({
crv: '0xcfd1d50ce23c46d3cf6407487b2f8934e96dc8f9',
mnt: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
});

export const cTokensMantle = []; //.map((a) => a.toLowerCase());
export const yTokensMantle = []; //.map((a) => a.toLowerCase());
export const ycTokensMantle = []; //.map((a) => a.toLowerCase());
export const aTokensMantle = []; //.map((a) => a.toLowerCase());
2 changes: 2 additions & 0 deletions src/constants/pools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { POOLS_DATA_BASE } from "./base.js";
import { POOLS_DATA_BSC } from "./bsc.js";
import { POOLS_DATA_FRAXTAL } from "./fraxtal.js";
import { POOLS_DATA_XLAYER } from "./xlayer.js";
import { POOLS_DATA_MANTLE } from "./mantle.js";

export {
POOLS_DATA_ETHEREUM,
Expand All @@ -34,4 +35,5 @@ export {
POOLS_DATA_BSC,
POOLS_DATA_FRAXTAL,
POOLS_DATA_XLAYER,
POOLS_DATA_MANTLE,
};
4 changes: 4 additions & 0 deletions src/constants/pools/mantle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { lowerCasePoolDataAddresses } from "../utils.js";
import { IPoolData, IDict } from "../../interfaces.js";

export const POOLS_DATA_MANTLE: IDict<IPoolData> = lowerCasePoolDataAddresses({});
5 changes: 5 additions & 0 deletions src/constants/tricryptoDeployImplementations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ export const tricryptoDeployImplementations = {
amm_native_transfers_enabled: '0xFAbC421e3368D158d802684A217a83c083c94CeB'.toLowerCase(), //0
implementationIdx: 1,
},
5000: { // MANTLE
amm_native_transfers_disabled: '0x7Ca46A636b02D4aBC66883D7FF164bDE506DC66a'.toLowerCase(), //1
amm_native_transfers_enabled: '0x046207cB759F527b6c10C2D61DBaca45513685CC'.toLowerCase(), //0
implementationIdx: 1,
},
8453: { // BASE
amm_native_transfers_disabled: '0x0c59d36b23f809f8b6C7cb4c8C590a0AC103baEf'.toLowerCase(), //1
amm_native_transfers_enabled: '0xa274c88e09fDF1798a7517096557e6c1bEa1f65A'.toLowerCase(), //0
Expand Down
2 changes: 1 addition & 1 deletion src/constants/volumeNetworks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export interface IVolumeNetworks {
export const volumeNetworks: IVolumeNetworks = {
getVolumes: [1,137,8453, 42161],
getSubgraphData: [10,100,250,1284,42220,43114,1313161554],
getFactoryAPYs: [56,196,252,324,2222],
getFactoryAPYs: [56,196,252,324,2222,5000],
}
25 changes: 22 additions & 3 deletions src/curve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import {
POOLS_DATA_BSC,
POOLS_DATA_FRAXTAL,
POOLS_DATA_XLAYER,
POOLS_DATA_MANTLE,
} from './constants/pools/index.js';
import {
ALIASES_ETHEREUM,
Expand All @@ -80,6 +81,7 @@ import {
ALIASES_BSC,
ALIASES_FRAXTAL,
ALIASES_XLAYER,
ALIASES_MANTLE,
} from "./constants/aliases.js";
import { COINS_ETHEREUM, cTokensEthereum, yTokensEthereum, ycTokensEthereum, aTokensEthereum } from "./constants/coins/ethereum.js";
import { COINS_OPTIMISM, cTokensOptimism, yTokensOptimism, ycTokensOptimism, aTokensOptimism } from "./constants/coins/optimism.js";
Expand All @@ -97,6 +99,7 @@ import { COINS_BASE, cTokensBase, yTokensBase, ycTokensBase, aTokensBase } from
import { COINS_BSC, cTokensBsc, yTokensBsc, ycTokensBsc, aTokensBsc } from "./constants/coins/bsc.js";
import { COINS_FRAXTAL, cTokensFraxtal, yTokensFraxtal, ycTokensFraxtal, aTokensFraxtal } from "./constants/coins/fraxtal.js";
import { COINS_XLAYER, cTokensXLayer, yTokensXLayer, ycTokensXLayer, aTokensXLayer } from "./constants/coins/xlayer.js";
import { COINS_MANTLE, cTokensMantle, yTokensMantle, ycTokensMantle, aTokensMantle } from "./constants/coins/mantle.js";
import { lowerCasePoolDataAddresses, extractDecimals, extractGauges } from "./constants/utils.js";
import { _getAllGauges, _getHiddenPools } from "./external-api.js";
import { L2Networks } from "./constants/L2Networks.js";
Expand Down Expand Up @@ -189,6 +192,12 @@ export const NATIVE_TOKENS: { [index: number]: { symbol: string, wrappedSymbol:
address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
wrappedAddress: '0xc86c7C0eFbd6A49B35E8714C5f59D99De09A225b'.toLowerCase(),
},
5000: { // MANTLE
symbol: 'MNT',
wrappedSymbol: 'WMNT',
address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
wrappedAddress: '0x78c1b0c915c4faa5fffa6cabf0219da63d7f4cb8'.toLowerCase(),
},
8453: { // BASE
symbol: 'ETH',
wrappedSymbol: 'WETH',
Expand Down Expand Up @@ -333,6 +342,16 @@ export const NETWORK_CONSTANTS: { [index: number]: any } = {
ycTokens: ycTokensKava,
aTokens: aTokensKava,
},
5000: {
NAME: 'mantle',
ALIASES: ALIASES_MANTLE,
POOLS_DATA: POOLS_DATA_MANTLE,
COINS: COINS_MANTLE,
cTokens: cTokensMantle,
yTokens: yTokensMantle,
ycTokens: ycTokensMantle,
aTokens: aTokensMantle,
},
8453: {
NAME: 'base',
ALIASES: ALIASES_BASE,
Expand Down Expand Up @@ -664,7 +683,7 @@ class Curve implements ICurve {

this.setContract(this.constants.ALIASES.factory, factoryABI);

if (this.chainId !== 1313161554 && this.chainId !== 252 && this.chainId !== 196) {
if (this.chainId !== 1313161554 && this.chainId !== 252 && this.chainId !== 196 && this.chainId !== 5000) {
const factoryContract = this.contracts[this.constants.ALIASES.factory].contract;
this.constants.ALIASES.factory_admin = (await factoryContract.admin(this.constantOptions) as string).toLowerCase();
this.setContract(this.constants.ALIASES.factory_admin, factoryAdminABI);
Expand Down Expand Up @@ -783,7 +802,7 @@ class Curve implements ICurve {
}

fetchFactoryPools = async (useApi = true): Promise<void> => {
if ([196, 252, 1313161554].includes(this.chainId)) return;
if ([196, 252, 5000, 1313161554].includes(this.chainId)) return;

if (useApi) {
this.constants.FACTORY_POOLS_DATA = lowerCasePoolDataAddresses(await getFactoryPoolsDataFromApi.call(this, "factory"));
Expand Down Expand Up @@ -825,7 +844,7 @@ class Curve implements ICurve {
}

fetchCryptoFactoryPools = async (useApi = true): Promise<void> => {
if (![1, 56, 137, 250, 8453].includes(this.chainId)) return;
if (![1, 56, 137, 250, 5000, 8453].includes(this.chainId)) return;

if (useApi) {
this.constants.CRYPTO_FACTORY_POOLS_DATA = lowerCasePoolDataAddresses(await getFactoryPoolsDataFromApi.call(this, "factory-crypto"));
Expand Down
8 changes: 8 additions & 0 deletions src/factory/constants-crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export const lpTokenBasePoolIdDictFraxtal: IDict<string> = lowerCaseKeys({});

export const lpTokenBasePoolIdDictXLayer: IDict<string> = lowerCaseKeys({});

export const lpTokenBasePoolIdDictMantle: IDict<string> = lowerCaseKeys({});

export const basePoolIdZapDictEthereum: IDict<{ address: string, ABI: any }> = {
'3pool': {
address: "0x97aDC08FA1D849D2C48C5dcC1DaB568B169b0267".toLowerCase(),
Expand Down Expand Up @@ -84,6 +86,8 @@ export const basePoolIdZapDictFraxtal: IDict<{ address: string, ABI: any }> = {}

export const basePoolIdZapDictXLayer: IDict<{ address: string, ABI: any }> = {};

export const basePoolIdZapDictMantle: IDict<{ address: string, ABI: any }> = {};

export const CRYPTO_FACTORY_CONSTANTS: { [index: number]: { lpTokenBasePoolIdDict: IDict<string>, basePoolIdZapDict: IDict<{ address: string, ABI: any }> } } = {
1: { // ETH
lpTokenBasePoolIdDict: lpTokenBasePoolIdDictEthereum,
Expand Down Expand Up @@ -129,6 +133,10 @@ export const CRYPTO_FACTORY_CONSTANTS: { [index: number]: { lpTokenBasePoolIdDic
lpTokenBasePoolIdDict: lpTokenBasePoolIdDictKava,
basePoolIdZapDict: basePoolIdZapDictKava,
},
5000: { // MANTLE
lpTokenBasePoolIdDict: lpTokenBasePoolIdDictMantle,
basePoolIdZapDict: basePoolIdZapDictMantle,
},
8453: { // BASE
lpTokenBasePoolIdDict: lpTokenBasePoolIdDictBase,
basePoolIdZapDict: basePoolIdZapDictBase,
Expand Down
12 changes: 12 additions & 0 deletions src/factory/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,11 @@ export const implementationABIDictXLayer: IDict<any> = lowerCaseKeys({
"0x1764ee18e8B3ccA4787249Ceb249356192594585": MetaStableSwapNGABI,
})

export const implementationABIDictMantle: IDict<any> = lowerCaseKeys({
"0x87FE17697D0f14A222e8bEf386a0860eCffDD617": PlainStableSwapNGABI,
"0x1764ee18e8B3ccA4787249Ceb249356192594585": MetaStableSwapNGABI,
})

export const basePoolIdZapDictEthereum: IDict<{ address: string, ABI: any }> = {
'3pool': {
address: "0xA79828DF1850E8a3A3064576f380D90aECDD3359".toLowerCase(),
Expand Down Expand Up @@ -543,6 +548,8 @@ export const basePoolIdZapDictFraxtal: IDict<{ address: string, ABI: any }> = {}

export const basePoolIdZapDictXLayer: IDict<{ address: string, ABI: any }> = {}

export const basePoolIdZapDictMantle: IDict<{ address: string, ABI: any }> = {}

export const stableNgBasePoolZap: {ABI: any, address: string} = {
ABI: StableNgBasePoolZapABI,
address: '0xe07a16358aa878cbda2d49a88e5106871e0db307'.toLowerCase(),
Expand Down Expand Up @@ -604,6 +611,11 @@ export const FACTORY_CONSTANTS: { [index: number]: { implementationABIDict: IDic
basePoolIdZapDict: basePoolIdZapDictKava,
stableNgBasePoolZap: stableNgBasePoolZap,
},
5000: { //MANTLE
implementationABIDict: implementationABIDictMantle,
basePoolIdZapDict: basePoolIdZapDictMantle,
stableNgBasePoolZap: stableNgBasePoolZap,
},
8453: { // BASE
implementationABIDict: implementationABIDictBase,
basePoolIdZapDict: basePoolIdZapDictBase,
Expand Down
4 changes: 2 additions & 2 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export interface IDict<T> {
[index: string]: T,
}

export type INetworkName = "ethereum" | "bsc" | "optimism" | "xdai" | "polygon" | "x-layer" | "fantom" | "fraxtal" | "zksync" | "moonbeam" | "kava" | "base" | "arbitrum" | "celo" | "avalanche" | "aurora";
export type IChainId = 1 | 10 | 56 | 100 | 137 | 196 | 250 | 252 | 324 | 1284 | 2222 | 8453 | 42161 | 42220 | 43114 | 1313161554;
export type INetworkName = "ethereum" | "bsc" | "optimism" | "xdai" | "polygon" | "x-layer" | "fantom" | "fraxtal" | "zksync" | "moonbeam" | "kava" | "mantle" | "base" | "arbitrum" | "celo" | "avalanche" | "aurora";
export type IChainId = 1 | 10 | 56 | 100 | 137 | 196 | 250 | 252 | 324 | 1284 | 2222 | 5000 | 8453 | 42161 | 42220 | 43114 | 1313161554;
export type IFactoryPoolType = "factory" | "factory-crvusd" | "factory-eywa" | "factory-crypto" | "factory-twocrypto" | "factory-tricrypto" | "factory-stable-ng";
export type IPoolType = "main" | "crypto" | IFactoryPoolType;
export type ISwapType = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
Expand Down
2 changes: 2 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ export const _getUsdRate = async (assetId: string): Promise<number> => {
324: 'zksync',
1284: 'moonbeam',
2222: 'kava',
5000: 'mantle',
8453: 'base',
42220: 'celo',
43114: 'avalanche',
Expand All @@ -466,6 +467,7 @@ export const _getUsdRate = async (assetId: string): Promise<number> => {
324: 'ethereum',
1284: 'moonbeam',
2222: 'kava',
5000: 'mantle',
8453: 'ethereum',
42220: 'celo',
43114: 'avalanche-2',
Expand Down

0 comments on commit f2edc6f

Please sign in to comment.