@dydxfoundation/governance
Version:
dYdX governance smart contracts
80 lines (79 loc) • 4.54 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@urql/core");
const config_1 = require("./config");
const ClaimsProxyService_1 = __importDefault(require("./services/ClaimsProxyService"));
const DydxGovernance_1 = __importDefault(require("./services/DydxGovernance"));
const DydxToken_1 = __importDefault(require("./services/DydxToken"));
const GovernanceDelegationTokenService_1 = __importDefault(require("./services/GovernanceDelegationTokenService"));
const LiquidityModule_1 = __importDefault(require("./services/LiquidityModule"));
const MerkleDistributor_1 = __importDefault(require("./services/MerkleDistributor"));
const SafetyModule_1 = __importDefault(require("./services/SafetyModule"));
const txBuilder_1 = __importDefault(require("./txBuilder"));
const types_1 = require("./types");
require("isomorphic-unfetch");
const helpers_1 = require("./utils/helpers");
class TxBuilder extends txBuilder_1.default {
constructor({ network, hardhatGovernanceAddresses = {
DYDX_GOVERNANCE: '',
DYDX_GOVERNANCE_EXECUTOR_SHORT: '',
DYDX_GOVERNANCE_EXECUTOR_LONG: '',
DYDX_GOVERNANCE_EXECUTOR_MERKLE_PAUSER: '',
DYDX_GOVERNANCE_PRIORITY_EXECUTOR_STARKWARE: '',
DYDX_GOVERNANCE_STRATEGY: '',
}, hardhatTokenAddresses = {
TOKEN_ADDRESS: '',
}, hardhatTreasuryAddresses = {
REWARDS_TREASURY_ADDRESS: '',
REWARDS_TREASURY_VESTER_ADDRESS: '',
COMMUNITY_TREASURY_ADDRESS: '',
COMMUNITY_TREASURY_VESTER_ADDRESS: '',
}, hardhatSafetyModuleAddresses = {
SAFETY_MODULE_ADDRESS: '',
}, hardhatLiquidityModuleAddresses = {
LIQUIDITY_MODULE_ADDRESS: '',
}, hardhatMerkleDistributorAddresses = {
MERKLE_DISTRIBUTOR_ADDRESS: '',
}, hardhatClaimsProxyAddresses = {
CLAIMS_PROXY_ADDRESS: '',
}, hardhatMulticallAddresses = {
MULTICALL_ADDRESS: '',
}, injectedProvider, defaultProviderKeys, }) {
super(network, injectedProvider, defaultProviderKeys);
let subgraphClient;
switch (network) {
case types_1.Network.ropsten:
subgraphClient = (0, core_1.createClient)({
url: config_1.ROPSTEN_SUBGRAPH_URL,
});
break;
case types_1.Network.main:
subgraphClient = (0, core_1.createClient)({
url: config_1.MAINNET_SUBGRAPH_URL,
});
break;
case types_1.Network.hardhat:
console.log('No subgraph functionality on hardhat network (all subgraph calls should be mocked).');
subgraphClient = {
query: () => {
throw new Error('All subgraph queries must be mocked on hardhat network');
},
};
break;
default: {
throw new Error(`No subgraph functionality on network ${network}.`);
}
}
this.governanceDelegationTokenService = new GovernanceDelegationTokenService_1.default(this.configuration);
this.dydxGovernanceService = new DydxGovernance_1.default(this.configuration, this.erc20Service, this.governanceDelegationTokenService, subgraphClient, (0, helpers_1.getGovernanceTokens)(network, hardhatTokenAddresses, hardhatSafetyModuleAddresses), hardhatGovernanceAddresses);
this.safetyModuleService = new SafetyModule_1.default(this.configuration, this.erc20Service, hardhatSafetyModuleAddresses);
this.liquidityModuleService = new LiquidityModule_1.default(this.configuration, this.erc20Service, hardhatLiquidityModuleAddresses);
this.merkleDistributorService = new MerkleDistributor_1.default(this.configuration, this.erc20Service, hardhatMerkleDistributorAddresses);
this.claimsProxyService = new ClaimsProxyService_1.default(this.configuration, this.safetyModuleService, this.liquidityModuleService, this.merkleDistributorService, hardhatClaimsProxyAddresses, hardhatTokenAddresses, hardhatTreasuryAddresses);
this.dydxTokenService = new DydxToken_1.default(this.configuration, this.erc20Service, this.safetyModuleService, this.liquidityModuleService, this.merkleDistributorService, hardhatTokenAddresses, hardhatTreasuryAddresses, hardhatMulticallAddresses);
}
}
exports.default = TxBuilder;