Skip to content

Commit

Permalink
Add Fraxtal
Browse files Browse the repository at this point in the history
  • Loading branch information
MirthFutures committed Mar 27, 2024
1 parent f80e6e1 commit cdff27f
Show file tree
Hide file tree
Showing 14 changed files with 125 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/address-book/address-book/fraxtal/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { beefyfinance } from './platforms/beefyfinance';
import { tokens } from './tokens/tokens';
import { convertSymbolTokenMapToAddressTokenMap } from '../../util/convertSymbolTokenMapToAddressTokenMap';
import Chain from '../../types/chain';
import { ConstInterface } from '../../types/const';

const _fraxtal = {
platforms: {
beefyfinance,
},
tokens,
tokenAddressMap: convertSymbolTokenMapToAddressTokenMap(tokens),
} as const;

export const fraxtal: ConstInterface<typeof _fraxtal, Chain> = _fraxtal;
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const devMultisig = '0x6eA680acb92497F6dbe64d93d8a00a6d20106616';
const treasuryMultisig = '0x944819832B287bFb85BB94a163480516a33E819d';

export const beefyfinance = {
devMultisig: devMultisig,
treasuryMultisig: treasuryMultisig,
strategyOwner: '0x73F97432Adb2a1c39d0E1a6e554c7d4BbDaFC316',
vaultOwner: '0xC35a456138dE0634357eb47Ba5E74AFE9faE9a98',
keeper: '0x4fED5491693007f0CD49f4614FFC38Ab6A04B619',
treasurer: treasuryMultisig,
launchpoolOwner: devMultisig,
rewardPool: '0x0000000000000000000000000000000000000000',
treasury: treasuryMultisig,
beefyFeeRecipient: '0x02Ae4716B9D5d48Db1445814b0eDE39f5c28264B',
multicall: '0x2840463Ea288c26B66E24f92E8C704e1aB6b095c',
bifiMaxiStrategy: '0x0000000000000000000000000000000000000000', // Not used
voter: '0x5e1caC103F943Cd84A1E92dAde4145664ebf692A',
beefyFeeConfig: '0xfc69704cC3cAac545cC7577009Ea4AA04F1a61Eb',
vaultFactory: '0x91BB303E972995EbE5f593BCddBb6F5Ef49Dbcbd', // todo
} as const;
25 changes: 25 additions & 0 deletions packages/address-book/address-book/fraxtal/tokens/tokens.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ConstRecord } from '../../../types/const';
import Token from '../../../types/token';

const frxETH = {
name: 'Frax Wrapped Ether',
address: '0xFC00000000000000000000000000000000000006',
symbol: 'frxETH',
oracleId: 'frxETH',
decimals: 18,
chainId: 252,
website: 'https://app.frax.finance/frxeth/mint',
description:
'frxETH acts as a stablecoin loosely pegged to ETH, so that 1 frxETH always represents 1 ETH and the amount of frxETH in circulation matches the amount of ETH in the Frax ETH system. When ETH is sent to the frxETHMinter, an equivalent amount of frxETH is minted. Holding frxETH on its own is not eligible for staking yield and should be thought of as analogous as holding ETH.',
bridge: 'fraxtal-canonical',
logoURI: '',
documentation: 'https://docs.frax.finance/frax-ether/frxeth-and-sfrxeth',
} as const;

const _tokens = {
frxETH,
wfrxETH: frxETH,
WNATIVE: frxETH,
} as const;

export const tokens: ConstRecord<typeof _tokens, Token> = _tokens;
6 changes: 6 additions & 0 deletions packages/address-book/address-book/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import { base } from './base';
import { gnosis } from './gnosis';
import { linea } from './linea';
import { mantle } from './mantle';
import { fraxtal } from './fraxtal';

import Chain from '../types/chain';
import { ChainId } from '../types/chainid';
import { ConstRecord } from '../types/const';
Expand Down Expand Up @@ -55,6 +57,7 @@ const _addressBook: {
readonly gnosis: Chain;
readonly linea: Chain;
readonly mantle: Chain;
readonly fraxtal: Chain;
} = {
polygon,
bsc,
Expand All @@ -81,6 +84,7 @@ const _addressBook: {
gnosis,
linea,
mantle,
fraxtal,
} as const;

const _addressBookByChainId: {
Expand Down Expand Up @@ -109,6 +113,7 @@ const _addressBookByChainId: {
readonly '100': Chain;
readonly '59144': Chain;
readonly '5000': Chain;
readonly '252': Chain;
} = {
[ChainId.polygon]: polygon,
[ChainId.bsc]: bsc,
Expand All @@ -135,6 +140,7 @@ const _addressBookByChainId: {
[ChainId.gnosis]: gnosis,
[ChainId.linea]: linea,
[ChainId.mantle]: mantle,
[ChainId.fraxtal]: fraxtal,
} as const;

export const addressBook: ConstRecord<typeof _addressBook, Chain> = _addressBook;
Expand Down
1 change: 1 addition & 0 deletions packages/address-book/types/chainid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ export enum ChainId {
gnosis = 100,
linea = 59144,
mantle = 5000,
fraxtal = 252,
}
1 change: 1 addition & 0 deletions packages/address-book/util/chainIdMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const chainIdMap = {
gnosis: 100,
linea: 59144,
mantle: 5000,
fraxtal: 252,
};

export default chainIdMap;
25 changes: 25 additions & 0 deletions src/api/rpc/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
GNOSIS_RPC,
LINEA_RPC,
MANTLE_RPC,
FRAXTAL_RPC,
} from '../../constants';
import { ChainId } from '../../../packages/address-book/address-book';

Expand Down Expand Up @@ -644,6 +645,29 @@ const mantleChain = {
},
} as const satisfies Chain;

const fraxtalChain = {
id: 252,
name: 'Fraxtal',
network: 'fraxtal',
nativeCurrency: {
decimals: 18,
name: 'Frax Staked Ether',
symbol: 'frxETH',
},
rpcUrls: {
public: { http: [FRAXTAL_RPC] },
default: { http: [FRAXTAL_RPC] },
},
blockExplorers: {
default: { name: 'Fraxtal Explorer', url: 'https://fraxscan.com/' },
},
contracts: {
multicall3: {
address: '0xca11bde05977b3631167028862be2a173976ca11',
},
},
} as const satisfies Chain;

//build a map from chainId to chain object
export const getChain: Partial<Record<ChainId, Chain>> = {
[ChainId.avax]: avalancheChain,
Expand Down Expand Up @@ -671,4 +695,5 @@ export const getChain: Partial<Record<ChainId, Chain>> = {
[ChainId.gnosis]: gnosisChain,
[ChainId.linea]: lineaChain,
[ChainId.mantle]: mantleChain,
[ChainId.fraxtal]: fraxtalChain,
} as const;
1 change: 1 addition & 0 deletions src/api/rpc/rpcs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ const rpcs: Record<ChainId, string[]> = {
'https://rpc.ankr.com/mantle',
'https://1rpc.io/mantle',
],
[ChainId.fraxtal]: ['https://rpc.frax.com'],
};

export const getChainRpcs = (chainId: ChainId): string[] => rpcs[chainId] ?? [];
1 change: 1 addition & 0 deletions src/api/zap/swap/blocked-tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,4 +604,5 @@ export const blockedTokensByChain: Record<ApiChain, Set<string>> = {
gnosis: new Set([]),
linea: new Set([]),
mantle: new Set([]),
fraxtal: new Set([]),
};
9 changes: 9 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const BASE_RPC = process.env.BASE_RPC || 'https://mainnet.base.org';
const GNOSIS_RPC = process.env.GNOSIS_RPC || 'https://gnosis.publicnode.com';
const LINEA_RPC = process.env.LINEA_RPC || 'https://rpc.linea.build';
const MANTLE_RPC = process.env.MANTLE_RPC || 'https://rpc.mantle.xyz';
const FRAXTAL_RPC = process.env.FRAXTAL_RPC || 'https://rpc.frax.com';

const BSC_CHAIN_ID = ChainId.bsc;
const HECO_CHAIN_ID = ChainId.heco;
Expand All @@ -90,6 +91,7 @@ const BASE_CHAIN_ID = ChainId.base;
const GNOSIS_CHAIN_ID = ChainId.gnosis;
const LINEA_CHAIN_ID = ChainId.linea;
const MANTLE_CHAIN_ID = ChainId.mantle;
const FRAXTAL_CHAIN_ID = ChainId.fraxtal;

const DFYN_LPF = 0.003;
const SUSHI_LPF = 0.003;
Expand Down Expand Up @@ -137,6 +139,7 @@ const MULTICHAIN_RPC: Record<ChainId, string> = {
[ChainId.gnosis]: GNOSIS_RPC,
[ChainId.linea]: LINEA_RPC,
[ChainId.mantle]: MANTLE_RPC,
[ChainId.fraxtal]: FRAXTAL_RPC,
};

const BSC_VAULTS_ENDPOINT =
Expand Down Expand Up @@ -189,6 +192,8 @@ const LINEA_VAULTS_ENDPOINT =
'https://raw.githubusercontent.com/beefyfinance/beefy-v2/prod/src/config/vault/linea.json';
const MANTLE_VAULTS_ENDPOINT =
'https://raw.githubusercontent.com/beefyfinance/beefy-v2/prod/src/config/vault/mantle.json';
const FRAXTAL_VAULTS_ENDPOINT =
'https://raw.githubusercontent.com/beefyfinance/beefy-v2/prod/src/config/vault/fraxtal.json';

const MULTICHAIN_ENDPOINTS: Partial<Record<ApiChain, string>> = {
bsc: BSC_VAULTS_ENDPOINT,
Expand Down Expand Up @@ -216,6 +221,7 @@ const MULTICHAIN_ENDPOINTS: Partial<Record<ApiChain, string>> = {
gnosis: GNOSIS_VAULTS_ENDPOINT,
linea: LINEA_VAULTS_ENDPOINT,
mantle: MANTLE_VAULTS_ENDPOINT,
fraxtal: FRAXTAL_VAULTS_ENDPOINT,
} as const;

const EXCLUDED_IDS_FROM_TVL = ['venus-wbnb'];
Expand Down Expand Up @@ -298,6 +304,9 @@ export {
MANTLE_RPC,
MANTLE_CHAIN_ID,
MANTLE_VAULTS_ENDPOINT,
FRAXTAL_RPC,
FRAXTAL_CHAIN_ID,
//FRAXTAL_VAULTS_ENDPOINT,
BASE_HPY,
MINUTELY_HPY,
HOURLY_HPY,
Expand Down
8 changes: 8 additions & 0 deletions src/utils/ethersHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ import {
LINEA_CHAIN_ID,
MANTLE_RPC,
MANTLE_CHAIN_ID,
FRAXTAL_RPC,
FRAXTAL_CHAIN_ID,
} from '../constants';

console.log(addressBookByChainId[ChainId.fantom].platforms.beefyfinance.multicall);
Expand Down Expand Up @@ -82,6 +84,7 @@ const MULTICALLS: Record<ChainId, Pick<BeefyFinance, 'multicall'>['multicall']>
[ChainId.gnosis]: addressBookByChainId[ChainId.gnosis].platforms.beefyfinance.multicall,
[ChainId.linea]: addressBookByChainId[ChainId.linea].platforms.beefyfinance.multicall,
[ChainId.mantle]: addressBookByChainId[ChainId.mantle].platforms.beefyfinance.multicall,
[ChainId.fraxtal]: addressBookByChainId[ChainId.fraxtal].platforms.beefyfinance.multicall,
};

const clients: Record<keyof typeof ChainId, ethers.providers.JsonRpcProvider[]> = {
Expand Down Expand Up @@ -110,6 +113,7 @@ const clients: Record<keyof typeof ChainId, ethers.providers.JsonRpcProvider[]>
gnosis: [],
linea: [],
mantle: [],
fraxtal: [],
};
BSC_RPC_ENDPOINTS.forEach(endpoint => {
clients.bsc.push(new ethers.providers.JsonRpcProvider(endpoint));
Expand Down Expand Up @@ -138,6 +142,7 @@ clients.base.push(new ethers.providers.JsonRpcProvider(BASE_RPC));
clients.gnosis.push(new ethers.providers.JsonRpcProvider(GNOSIS_RPC));
clients.linea.push(new ethers.providers.JsonRpcProvider(LINEA_RPC));
clients.mantle.push(new ethers.providers.JsonRpcProvider(MANTLE_RPC));
clients.fraxtal.push(new ethers.providers.JsonRpcProvider(FRAXTAL_RPC));

export const chainRandomClients = {
bscRandomClient: () => clients.bsc[~~(clients.bsc.length * Math.random())],
Expand Down Expand Up @@ -165,6 +170,7 @@ export const chainRandomClients = {
gnosisRandomClient: () => clients.gnosis[~~(clients.gnosis.length * Math.random())],
lineaRandomClient: () => clients.linea[~~(clients.linea.length * Math.random())],
mantleRandomClient: () => clients.mantle[~~(clients.mantle.length * Math.random())],
fraxtalRandomClient: () => clients.fraxtal[~~(clients.fraxtal.length * Math.random())],
};

export const _ethersFactory = (chainId: ChainId) => {
Expand Down Expand Up @@ -219,6 +225,8 @@ export const _ethersFactory = (chainId: ChainId) => {
return chainRandomClients.lineaRandomClient();
case MANTLE_CHAIN_ID:
return chainRandomClients.mantleRandomClient();
case FRAXTAL_CHAIN_ID:
return chainRandomClients.fraxtalRandomClient();
}
};

Expand Down
1 change: 1 addition & 0 deletions src/utils/fetchAmmPrices.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const MULTICALLS = {
100: '0x07f1ad98b725Af45485646aC431b7757f50C598A',
59144: '0xe103ab2f922aa1a56EC058AbfDA2CeEa1e95bCd7',
5000: '0xee59DE6E749cc6cF6ebD30878D8B4222C4aea37C',
252: '0x9C18deE5290925f596fbEfee2f6745b640f3A4C6',
};

const BATCH_SIZE = 128;
Expand Down
3 changes: 3 additions & 0 deletions src/utils/web3.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ module.exports = {
get mantleWeb3() {
return chainRandomClients.mantleRandomClient();
},
get fraxtalWeb3() {
return chainRandomClients.fraxtalRandomClient();
},

web3Factory: _web3Factory,

Expand Down
9 changes: 9 additions & 0 deletions src/utils/web3Helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ import {
LINEA_CHAIN_ID,
MANTLE_RPC,
MANTLE_CHAIN_ID,
FRAXTAL_RPC,
FRAXTAL_CHAIN_ID,
} from '../constants';

const MULTICALLS: Record<ChainId, Pick<BeefyFinance, 'multicall'>['multicall']> = {
Expand Down Expand Up @@ -82,6 +84,7 @@ const MULTICALLS: Record<ChainId, Pick<BeefyFinance, 'multicall'>['multicall']>
[ChainId.gnosis]: addressBookByChainId[ChainId.gnosis].platforms.beefyfinance.multicall,
[ChainId.linea]: addressBookByChainId[ChainId.linea].platforms.beefyfinance.multicall,
[ChainId.mantle]: addressBookByChainId[ChainId.mantle].platforms.beefyfinance.multicall,
[ChainId.fraxtal]: addressBookByChainId[ChainId.fraxtal].platforms.beefyfinance.multicall,
};

export const MULTICALL_V3: Partial<Readonly<Record<ChainId, string>>> = {
Expand Down Expand Up @@ -110,6 +113,7 @@ export const MULTICALL_V3: Partial<Readonly<Record<ChainId, string>>> = {
[ChainId.gnosis]: '0xcA11bde05977b3631167028862bE2a173976CA11',
[ChainId.linea]: '0xcA11bde05977b3631167028862bE2a173976CA11',
[ChainId.mantle]: '0xcA11bde05977b3631167028862bE2a173976CA11',
[ChainId.fraxtal]: '0xcA11bde05977b3631167028862bE2a173976CA11',
};

const clients: Record<keyof typeof ChainId, Web3[]> = {
Expand Down Expand Up @@ -138,6 +142,7 @@ const clients: Record<keyof typeof ChainId, Web3[]> = {
gnosis: [],
linea: [],
mantle: [],
fraxtal: [],
};
BSC_RPC_ENDPOINTS.forEach(endpoint => {
clients.bsc.push(new Web3(endpoint));
Expand Down Expand Up @@ -166,6 +171,7 @@ clients.base.push(new Web3(BASE_RPC));
clients.gnosis.push(new Web3(GNOSIS_RPC));
clients.linea.push(new Web3(LINEA_RPC));
clients.mantle.push(new Web3(MANTLE_RPC));
clients.fraxtal.push(new Web3(FRAXTAL_RPC));

export const chainRandomClients = {
bscRandomClient: () => clients.bsc[~~(clients.bsc.length * Math.random())],
Expand Down Expand Up @@ -193,6 +199,7 @@ export const chainRandomClients = {
gnosisRandomClient: () => clients.gnosis[~~(clients.gnosis.length * Math.random())],
lineaRandomClient: () => clients.linea[~~(clients.linea.length * Math.random())],
mantleRandomClient: () => clients.mantle[~~(clients.mantle.length * Math.random())],
fraxtalRandomClient: () => clients.fraxtal[~~(clients.fraxtal.length * Math.random())],
};

export const _web3Factory = (chainId: ChainId) => {
Expand Down Expand Up @@ -247,6 +254,8 @@ export const _web3Factory = (chainId: ChainId) => {
return chainRandomClients.lineaRandomClient();
case MANTLE_CHAIN_ID:
return chainRandomClients.mantleRandomClient();
case FRAXTAL_CHAIN_ID:
return chainRandomClients.fraxtalRandomClient();
}
};

Expand Down

0 comments on commit cdff27f

Please sign in to comment.