create_pool_from_prices uses generated ABI
This commit is contained in:
@@ -6,47 +6,7 @@
|
|||||||
|
|
||||||
import { ethers } from 'ethers';
|
import { ethers } from 'ethers';
|
||||||
import { readFile } from 'fs/promises';
|
import { readFile } from 'fs/promises';
|
||||||
|
import IPartyPlannerABI from "../src/contracts/IPartyPlannerABI.ts";
|
||||||
// ============================================================================
|
|
||||||
// LOAD ABIs AND CONFIG
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
// Load chain info and get PartyPlanner address (chain ID 31337 = Anvil)
|
|
||||||
const chainInfoData = JSON.parse(await readFile(new URL('../src/contracts/liqp-deployments.json', import.meta.url), 'utf-8'));
|
|
||||||
const PARTY_PLANNER_ADDRESS = chainInfoData['31337'].v1.PartyPlanner;
|
|
||||||
|
|
||||||
// Minimal ABIs needed for this script
|
|
||||||
const IPartyPlannerABI = [
|
|
||||||
{
|
|
||||||
"type": "function",
|
|
||||||
"name": "newPool",
|
|
||||||
"inputs": [
|
|
||||||
{ "name": "name", "type": "string", "internalType": "string" },
|
|
||||||
{ "name": "symbol", "type": "string", "internalType": "string" },
|
|
||||||
{ "name": "tokens", "type": "address[]", "internalType": "contract IERC20[]" },
|
|
||||||
{ "name": "kappa", "type": "int128", "internalType": "int128" },
|
|
||||||
{ "name": "swapFeePpm", "type": "uint256", "internalType": "uint256" },
|
|
||||||
{ "name": "flashFeePpm", "type": "uint256", "internalType": "uint256" },
|
|
||||||
{ "name": "stable", "type": "bool", "internalType": "bool" },
|
|
||||||
{ "name": "payer", "type": "address", "internalType": "address" },
|
|
||||||
{ "name": "receiver", "type": "address", "internalType": "address" },
|
|
||||||
{ "name": "initialDeposits", "type": "uint256[]", "internalType": "uint256[]" },
|
|
||||||
{ "name": "initialLpAmount", "type": "uint256", "internalType": "uint256" },
|
|
||||||
{ "name": "deadline", "type": "uint256", "internalType": "uint256" }
|
|
||||||
],
|
|
||||||
"outputs": [
|
|
||||||
{ "name": "pool", "type": "address", "internalType": "contract IPartyPool" },
|
|
||||||
{ "name": "lpAmount", "type": "uint256", "internalType": "uint256" }
|
|
||||||
],
|
|
||||||
"stateMutability": "nonpayable"
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
const ERC20ABI = [
|
|
||||||
{ "type": "function", "name": "balanceOf", "stateMutability": "view", "inputs": [{ "name": "account", "type": "address" }], "outputs": [{ "name": "", "type": "uint256" }] },
|
|
||||||
{ "type": "function", "name": "decimals", "stateMutability": "view", "inputs": [], "outputs": [{ "name": "", "type": "uint8" }] },
|
|
||||||
{ "type": "function", "name": "approve", "stateMutability": "nonpayable", "inputs": [{ "name": "spender", "type": "address" }, { "name": "amount", "type": "uint256" }], "outputs": [{ "name": "", "type": "bool" }] }
|
|
||||||
];
|
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// CONFIGURATION
|
// CONFIGURATION
|
||||||
@@ -93,6 +53,22 @@ const DEFAULT_POOL_PARAMS = {
|
|||||||
// Input amount in USD
|
// Input amount in USD
|
||||||
const INPUT_USD_AMOUNT = 100;
|
const INPUT_USD_AMOUNT = 100;
|
||||||
|
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// LOAD ABIs AND CONFIG
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// Load chain info and get PartyPlanner address (chain ID 31337 = Anvil)
|
||||||
|
const chainInfoData = JSON.parse(await readFile(new URL('../src/contracts/liqp-deployments.json', import.meta.url), 'utf-8'));
|
||||||
|
const PARTY_PLANNER_ADDRESS = chainInfoData['31337'].v1.PartyPlanner;
|
||||||
|
|
||||||
|
const ERC20ABI = [
|
||||||
|
{ "type": "function", "name": "balanceOf", "stateMutability": "view", "inputs": [{ "name": "account", "type": "address" }], "outputs": [{ "name": "", "type": "uint256" }] },
|
||||||
|
{ "type": "function", "name": "decimals", "stateMutability": "view", "inputs": [], "outputs": [{ "name": "", "type": "uint8" }] },
|
||||||
|
{ "type": "function", "name": "approve", "stateMutability": "nonpayable", "inputs": [{ "name": "spender", "type": "address" }, { "name": "amount", "type": "uint256" }], "outputs": [{ "name": "", "type": "bool" }] }
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// HELPER FUNCTIONS
|
// HELPER FUNCTIONS
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|||||||
@@ -110,6 +110,85 @@ const IPartyPlannerABI = [
|
|||||||
],
|
],
|
||||||
"stateMutability": "view"
|
"stateMutability": "view"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "function",
|
||||||
|
"name": "newPool",
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "name",
|
||||||
|
"type": "string",
|
||||||
|
"internalType": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "symbol",
|
||||||
|
"type": "string",
|
||||||
|
"internalType": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tokens",
|
||||||
|
"type": "address[]",
|
||||||
|
"internalType": "contract IERC20[]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "kappa",
|
||||||
|
"type": "int128",
|
||||||
|
"internalType": "int128"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "swapFeesPpm",
|
||||||
|
"type": "uint256[]",
|
||||||
|
"internalType": "uint256[]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "flashFeePpm",
|
||||||
|
"type": "uint256",
|
||||||
|
"internalType": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "stable",
|
||||||
|
"type": "bool",
|
||||||
|
"internalType": "bool"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "payer",
|
||||||
|
"type": "address",
|
||||||
|
"internalType": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "receiver",
|
||||||
|
"type": "address",
|
||||||
|
"internalType": "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "initialDeposits",
|
||||||
|
"type": "uint256[]",
|
||||||
|
"internalType": "uint256[]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "initialLpAmount",
|
||||||
|
"type": "uint256",
|
||||||
|
"internalType": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "deadline",
|
||||||
|
"type": "uint256",
|
||||||
|
"internalType": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "pool",
|
||||||
|
"type": "address",
|
||||||
|
"internalType": "contract IPartyPool"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "lpAmount",
|
||||||
|
"type": "uint256",
|
||||||
|
"internalType": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"stateMutability": "nonpayable"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "function",
|
"type": "function",
|
||||||
"name": "newPool",
|
"name": "newPool",
|
||||||
|
|||||||
@@ -324,25 +324,6 @@ const IPartyPoolABI = [
|
|||||||
],
|
],
|
||||||
"stateMutability": "nonpayable"
|
"stateMutability": "nonpayable"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "function",
|
|
||||||
"name": "getToken",
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "uint256",
|
|
||||||
"internalType": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "address",
|
|
||||||
"internalType": "contract IERC20"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"stateMutability": "view"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "function",
|
"type": "function",
|
||||||
"name": "initialMint",
|
"name": "initialMint",
|
||||||
@@ -516,7 +497,7 @@ const IPartyPoolABI = [
|
|||||||
"internalType": "address"
|
"internalType": "address"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "selector",
|
"name": "fundingSelector",
|
||||||
"type": "bytes4",
|
"type": "bytes4",
|
||||||
"internalType": "bytes4"
|
"internalType": "bytes4"
|
||||||
},
|
},
|
||||||
@@ -554,6 +535,11 @@ const IPartyPoolABI = [
|
|||||||
"name": "unwrap",
|
"name": "unwrap",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"internalType": "bool"
|
"internalType": "bool"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "cbData",
|
||||||
|
"type": "bytes",
|
||||||
|
"internalType": "bytes"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -677,6 +663,11 @@ const IPartyPoolABI = [
|
|||||||
"type": "address",
|
"type": "address",
|
||||||
"internalType": "address"
|
"internalType": "address"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "fundingSelector",
|
||||||
|
"type": "bytes4",
|
||||||
|
"internalType": "bytes4"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "receiver",
|
"name": "receiver",
|
||||||
"type": "address",
|
"type": "address",
|
||||||
@@ -706,6 +697,11 @@ const IPartyPoolABI = [
|
|||||||
"name": "unwrap",
|
"name": "unwrap",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"internalType": "bool"
|
"internalType": "bool"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "cbData",
|
||||||
|
"type": "bytes",
|
||||||
|
"internalType": "bytes"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -740,6 +736,25 @@ const IPartyPoolABI = [
|
|||||||
],
|
],
|
||||||
"stateMutability": "view"
|
"stateMutability": "view"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "function",
|
||||||
|
"name": "token",
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "uint256",
|
||||||
|
"internalType": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"type": "address",
|
||||||
|
"internalType": "contract IERC20"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"stateMutability": "view"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "function",
|
"type": "function",
|
||||||
"name": "totalSupply",
|
"name": "totalSupply",
|
||||||
|
|||||||
Reference in New Issue
Block a user