Skip to content

Commit

Permalink
fix: deployGaugeMirror
Browse files Browse the repository at this point in the history
  • Loading branch information
Macket committed Sep 12, 2024
1 parent 952f8b1 commit 96ba288
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/factory/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { ethers, Contract, Typed } from "ethers";
import { curve } from "../curve.js";
import { curve, NETWORK_CONSTANTS } from "../curve.js";
import { getPool } from "../pools/index.js";
import { parseUnits, BN, mulBy1_3, getPoolIdBySwapAddress, DIGas, smartNumber } from '../utils.js';
import CurveLpTokenV5ABI from "../constants/abis/curve_lp_token_v5.json" assert { type: 'json' };
import Plain2ETHOracleABIABI from "../constants/abis/factory-v2/Plain2ETHOracle.json" assert { type: 'json' };
import rootGaugeFactoryABI from '../constants/abis/gauge_factory/root_gauge_factory.json' assert { type: 'json' };
import { tricryptoDeployImplementations } from "../constants/tricryptoDeployImplementations.js";


Expand Down Expand Up @@ -871,7 +872,7 @@ const _deployGauge = async (pool: string, factory: string, estimateGas: boolean)

const _deployGaugeSidechain = async (pool: string, salt: string, estimateGas: boolean): Promise<ethers.ContractTransactionResponse | number | number[]> => {
if (curve.chainId === 1) throw Error("There is no deployGaugeSidechain method on ethereum network");
const contract = curve.contracts[curve.constants.ALIASES.gauge_factory].contract;
const contract = curve.contracts[curve.constants.ALIASES.child_gauge_factory].contract;
const _salt = ethers.encodeBytes32String(salt)
const gas = await contract.deploy_gauge.estimateGas(pool, Typed.bytes32(_salt), curve.signerAddress, curve.constantOptions);
if (estimateGas) return smartNumber(gas);
Expand All @@ -883,7 +884,9 @@ const _deployGaugeSidechain = async (pool: string, salt: string, estimateGas: bo

const _deployGaugeMirror = async (chainId: number, salt: string, estimateGas: boolean): Promise<ethers.ContractTransactionResponse | number | number[]> => {
if (curve.chainId !== 1) throw Error("There is no deployGaugeMirror method on sidechain network");
const contract = chainId === 252 ? curve.contracts[curve.constants.ALIASES.gauge_factory_fraxtal].contract : curve.contracts[curve.constants.ALIASES.gauge_factory].contract;
const rootGaugeFactory = NETWORK_CONSTANTS[chainId].root_gauge_factory;
curve.setContract(rootGaugeFactory, rootGaugeFactoryABI);
const contract = curve.contracts[rootGaugeFactory].contract;
const _salt = ethers.encodeBytes32String(salt)
const gas = await contract.deploy_gauge.estimateGas(chainId, Typed.bytes32(_salt), curve.constantOptions);
if (estimateGas) return smartNumber(gas);
Expand Down Expand Up @@ -922,7 +925,9 @@ export const getDeployedGaugeMirrorAddressByTx = async (tx: ethers.ContractTrans

export const getDeployedGaugeMirrorAddress = async (chainId: number): Promise<string> => {
if (curve.chainId !== 1) throw Error("There is no getDeployedGaugeMirrorAddress method on sidechain network");
const contract = curve.contracts[curve.constants.ALIASES.gauge_factory].contract;
const rootGaugeFactory = NETWORK_CONSTANTS[chainId].root_gauge_factory;
curve.setContract(rootGaugeFactory, rootGaugeFactoryABI);
const contract = curve.contracts[rootGaugeFactory].contract;
const gaugeCount = await contract.get_gauge_count(chainId);
const currentIndex: number = Number(gaugeCount) - 1;

Expand Down

0 comments on commit 96ba288

Please sign in to comment.