@blockchangers/uniswap-testnet-deployer
v1.0.1
Published
Simple Uniswap testnet deployment.
Downloads
21
Maintainers
Readme
DeFi-tools 🧩
Simple testnet deployer for Uniswap
Use it 🍩
const Deployer = require('@blockchangers/uniswap-testnet-deployer').Deployer;
const deployer = new Deployer(WALLET)
const tokenExchanges = await deployer.setup()
or
import { Deployer } from '@blockchangers/uniswap-testnet-deployer';
const deployer = new Deployer(WALLET)
const tokenExchanges = await deployer.setup()
Returns
async setup(tokens?: Token[]): Promise<TokenExchange[]>
export type TokenExchange = {
tokenAddress: string,
exchangeAddress: string
}
Example JS setup 🤞
const ethers = require('ethers');
const ganache = require('ganache-cli');
const UniswapTestnetDeployer = require('@blockchangers/uniswap-testnet-deployer');
const MNEMONIC = 'popular stock metal artefact nasty venture oblige horror face glory predict coach';
const provider = new ethers.providers.Web3Provider(
ganache.provider({
"mnemonic": MNEMONIC,
"gasLimit": 8000000,
"default_balance_ether": 100000000,
"verbose": true,
"vmErrorsOnRPCResponse": true
})
);
(async () => {
const WALLET = ethers.Wallet.fromMnemonic(MNEMONIC).connect(provider)
const ADDRESS = await WALLET.getAddress()
const deployer = new UniswapTestnetDeployer.Deployer(WALLET)
const tokenExchanges = await deployer.setup()
console.log("### First setup ###")
console.log(tokenExchanges)
// With custom tokens
const TOKENS = [
{
name: "MyToken",
symbol: "MYT",
amount: 50000,
depositAmount: 200,
valueInEther: 516
},
{
name: "Blockchanger TOKEN",
symbol: "BCT",
amount: 100000,
depositAmount: 5000,
valueInEther: 15
},
];
const tokenExchanges2 = await deployer.setup(TOKENS)
console.log("### Second setup ###")
console.log(tokenExchanges2)
const anExchange = new ethers.Contract(tokenExchanges2[0].exchangeAddress, UniswapTestnetDeployer.exchangeAbi, WALLET);
const anToken = new ethers.Contract(tokenExchanges2[0].tokenAddress, UniswapTestnetDeployer.tokenAbi, WALLET);
const oneEthToTokenPrice = await anExchange.getEthToTokenInputPrice(ethers.utils.parseEther("1"))
const symbol = await anToken.symbol()
console.log("1 ETH of", symbol, "equals", ethers.utils.formatEther(oneEthToTokenPrice.toString()))
})().catch(err => {
console.error(err);
})
Default tokens
export const DEFAULT_TOKENS: Token[] = [
{
name: "MakerDAO",
symbol: "MKR",
amount: 50000,
depositAmount: 200,
valueInEther: 516
},
{
name: "Basic Attention Token",
symbol: "BAT",
amount: 200000,
depositAmount: 5000,
valueInEther: 15
},
{
name: "Dai",
symbol: "DAI",
amount: 100000,
depositAmount: 25000,
valueInEther: 140
},
{
name: "Binance",
symbol: "BNB",
amount: 700000,
depositAmount: 14000,
valueInEther: 50
},
{
name: "ChainLink",
symbol: "LINK",
amount: 19000000,
depositAmount: 120000,
valueInEther: 100
}
]