mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
update
This commit is contained in:
parent
252a273491
commit
5d18e917ba
|
@ -1,95 +1,95 @@
|
||||||
// const TROVE_MANAGER_ADDRESS = "0xA39739EF8b0231DbFA0DcdA07d7e29faAbCf4bb2";
|
const TROVE_MANAGER_ADDRESS = "0xA39739EF8b0231DbFA0DcdA07d7e29faAbCf4bb2";
|
||||||
// const TROVE_MANAGER_ABI = [
|
const TROVE_MANAGER_ABI = [
|
||||||
// "function getTroveColl(address _borrower) external view returns (uint)",
|
"function getTroveColl(address _borrower) external view returns (uint)",
|
||||||
// "function getTroveDebt(address _borrower) external view returns (uint)",
|
"function getTroveDebt(address _borrower) external view returns (uint)",
|
||||||
// "function getTroveStatus(address _borrower) external view returns (uint)",
|
"function getTroveStatus(address _borrower) external view returns (uint)",
|
||||||
// "function redeemCollateral(uint _LUSDAmount, address _firstRedemptionHint, address _upperPartialRedemptionHint, address _lowerPartialRedemptionHint, uint _partialRedemptionHintNICR, uint _maxIterations, uint _maxFee) external returns (uint)",
|
"function redeemCollateral(uint _LUSDAmount, address _firstRedemptionHint, address _upperPartialRedemptionHint, address _lowerPartialRedemptionHint, uint _partialRedemptionHintNICR, uint _maxIterations, uint _maxFee) external returns (uint)",
|
||||||
// "function getNominalICR(address _borrower) external view returns (uint)",
|
"function getNominalICR(address _borrower) external view returns (uint)",
|
||||||
// "function liquidate(address _borrower) external",
|
"function liquidate(address _borrower) external",
|
||||||
// "function liquidateTroves(uint _n) external",
|
"function liquidateTroves(uint _n) external",
|
||||||
// ];
|
];
|
||||||
|
|
||||||
// const BORROWER_OPERATIONS_ADDRESS =
|
const BORROWER_OPERATIONS_ADDRESS =
|
||||||
// "0x24179CD81c9e782A4096035f7eC97fB8B783e007";
|
"0x24179CD81c9e782A4096035f7eC97fB8B783e007";
|
||||||
// const BORROWER_OPERATIONS_ABI = [
|
const BORROWER_OPERATIONS_ABI = [
|
||||||
// "function openTrove(uint256 _maxFee, uint256 _LUSDAmount, address _upperHint, address _lowerHint) external payable",
|
"function openTrove(uint256 _maxFee, uint256 _LUSDAmount, address _upperHint, address _lowerHint) external payable",
|
||||||
// "function closeTrove() external",
|
"function closeTrove() external",
|
||||||
// ];
|
];
|
||||||
|
|
||||||
// const LUSD_TOKEN_ADDRESS = "0x5f98805A4E8be255a32880FDeC7F6728C6568bA0";
|
const LUSD_TOKEN_ADDRESS = "0x5f98805A4E8be255a32880FDeC7F6728C6568bA0";
|
||||||
// const LUSD_TOKEN_ABI = [
|
const LUSD_TOKEN_ABI = [
|
||||||
// "function transfer(address _to, uint256 _value) public returns (bool success)",
|
"function transfer(address _to, uint256 _value) public returns (bool success)",
|
||||||
// "function balanceOf(address account) external view returns (uint256)",
|
"function balanceOf(address account) external view returns (uint256)",
|
||||||
// "function approve(address spender, uint256 amount) external returns (bool)",
|
"function approve(address spender, uint256 amount) external returns (bool)",
|
||||||
// ];
|
];
|
||||||
|
|
||||||
// const ACTIVE_POOL_ADDRESS = "0xDf9Eb223bAFBE5c5271415C75aeCD68C21fE3D7F";
|
const ACTIVE_POOL_ADDRESS = "0xDf9Eb223bAFBE5c5271415C75aeCD68C21fE3D7F";
|
||||||
// const ACTIVE_POOL_ABI = ["function getLUSDDebt() external view returns (uint)"];
|
const ACTIVE_POOL_ABI = ["function getLUSDDebt() external view returns (uint)"];
|
||||||
|
|
||||||
// const PRICE_FEED_ADDRESS = "0x4c517D4e2C851CA76d7eC94B805269Df0f2201De";
|
const PRICE_FEED_ADDRESS = "0x4c517D4e2C851CA76d7eC94B805269Df0f2201De";
|
||||||
// const PRICE_FEED_ABI = ["function fetchPrice() external returns (uint)"];
|
const PRICE_FEED_ABI = ["function fetchPrice() external returns (uint)"];
|
||||||
|
|
||||||
// const HINT_HELPERS_ADDRESS = "0xE84251b93D9524E0d2e621Ba7dc7cb3579F997C0";
|
const HINT_HELPERS_ADDRESS = "0xE84251b93D9524E0d2e621Ba7dc7cb3579F997C0";
|
||||||
// const HINT_HELPERS_ABI = [
|
const HINT_HELPERS_ABI = [
|
||||||
// "function getRedemptionHints(uint _LUSDamount, uint _price, uint _maxIterations) external view returns (address firstRedemptionHint, uint partialRedemptionHintNICR, uint truncatedLUSDamount)",
|
"function getRedemptionHints(uint _LUSDamount, uint _price, uint _maxIterations) external view returns (address firstRedemptionHint, uint partialRedemptionHintNICR, uint truncatedLUSDamount)",
|
||||||
// "function getApproxHint(uint _CR, uint _numTrials, uint _inputRandomSeed) view returns (address hintAddress, uint diff, uint latestRandomSeed)",
|
"function getApproxHint(uint _CR, uint _numTrials, uint _inputRandomSeed) view returns (address hintAddress, uint diff, uint latestRandomSeed)",
|
||||||
// "function computeNominalCR(uint _coll, uint _debt) external pure returns (uint)",
|
"function computeNominalCR(uint _coll, uint _debt) external pure returns (uint)",
|
||||||
// ];
|
];
|
||||||
|
|
||||||
// const SORTED_TROVES_ADDRESS = "0x8FdD3fbFEb32b28fb73555518f8b361bCeA741A6";
|
const SORTED_TROVES_ADDRESS = "0x8FdD3fbFEb32b28fb73555518f8b361bCeA741A6";
|
||||||
// const SORTED_TROVES_ABI = [
|
const SORTED_TROVES_ABI = [
|
||||||
// "function findInsertPosition(uint256 _ICR, address _prevId, address _nextId) external view returns (address, address)",
|
"function findInsertPosition(uint256 _ICR, address _prevId, address _nextId) external view returns (address, address)",
|
||||||
// "function getLast() external view returns (address)",
|
"function getLast() external view returns (address)",
|
||||||
// ];
|
];
|
||||||
|
|
||||||
// const STABILITY_POOL_ADDRESS = "0x66017D22b0f8556afDd19FC67041899Eb65a21bb";
|
const STABILITY_POOL_ADDRESS = "0x66017D22b0f8556afDd19FC67041899Eb65a21bb";
|
||||||
// const STABILITY_POOL_ABI = [
|
const STABILITY_POOL_ABI = [
|
||||||
// "function getCompoundedLUSDDeposit(address _depositor) external view returns (uint)",
|
"function getCompoundedLUSDDeposit(address _depositor) external view returns (uint)",
|
||||||
// "function getDepositorETHGain(address _depositor) external view returns (uint)",
|
"function getDepositorETHGain(address _depositor) external view returns (uint)",
|
||||||
// "function getDepositorLQTYGain(address _depositor) external view returns (uint)",
|
"function getDepositorLQTYGain(address _depositor) external view returns (uint)",
|
||||||
// ];
|
];
|
||||||
|
|
||||||
// const STAKING_ADDRESS = "0x4f9Fbb3f1E99B56e0Fe2892e623Ed36A76Fc605d";
|
const STAKING_ADDRESS = "0x4f9Fbb3f1E99B56e0Fe2892e623Ed36A76Fc605d";
|
||||||
// const STAKING_ABI = [
|
const STAKING_ABI = [
|
||||||
// "function stake(uint _LQTYamount) external",
|
"function stake(uint _LQTYamount) external",
|
||||||
// "function unstake(uint _LQTYamount) external",
|
"function unstake(uint _LQTYamount) external",
|
||||||
// "function getPendingETHGain(address _user) external view returns (uint)",
|
"function getPendingETHGain(address _user) external view returns (uint)",
|
||||||
// "function getPendingLUSDGain(address _user) external view returns (uint)",
|
"function getPendingLUSDGain(address _user) external view returns (uint)",
|
||||||
// ];
|
];
|
||||||
|
|
||||||
// const LQTY_TOKEN_ADDRESS = "0x6DEA81C8171D0bA574754EF6F8b412F2Ed88c54D";
|
const LQTY_TOKEN_ADDRESS = "0x6DEA81C8171D0bA574754EF6F8b412F2Ed88c54D";
|
||||||
// const LQTY_TOKEN_ABI = [
|
const LQTY_TOKEN_ABI = [
|
||||||
// "function balanceOf(address account) external view returns (uint256)",
|
"function balanceOf(address account) external view returns (uint256)",
|
||||||
// "function transfer(address _to, uint256 _value) public returns (bool success)",
|
"function transfer(address _to, uint256 _value) public returns (bool success)",
|
||||||
// "function approve(address spender, uint256 amount) external returns (bool)",
|
"function approve(address spender, uint256 amount) external returns (bool)",
|
||||||
// ];
|
];
|
||||||
|
|
||||||
// const COLL_SURPLUS_ADDRESS = "0x3D32e8b97Ed5881324241Cf03b2DA5E2EBcE5521";
|
const COLL_SURPLUS_ADDRESS = "0x3D32e8b97Ed5881324241Cf03b2DA5E2EBcE5521";
|
||||||
// const COLL_SURPLUS_ABI = [
|
const COLL_SURPLUS_ABI = [
|
||||||
// "function getCollateral(address _account) external view returns (uint)",
|
"function getCollateral(address _account) external view returns (uint)",
|
||||||
// ];
|
];
|
||||||
|
|
||||||
// module.exports = {
|
module.exports = {
|
||||||
// TROVE_MANAGER_ADDRESS,
|
TROVE_MANAGER_ADDRESS,
|
||||||
// TROVE_MANAGER_ABI,
|
TROVE_MANAGER_ABI,
|
||||||
// BORROWER_OPERATIONS_ADDRESS,
|
BORROWER_OPERATIONS_ADDRESS,
|
||||||
// BORROWER_OPERATIONS_ABI,
|
BORROWER_OPERATIONS_ABI,
|
||||||
// LUSD_TOKEN_ADDRESS,
|
LUSD_TOKEN_ADDRESS,
|
||||||
// LUSD_TOKEN_ABI,
|
LUSD_TOKEN_ABI,
|
||||||
// STABILITY_POOL_ADDRESS,
|
STABILITY_POOL_ADDRESS,
|
||||||
// STABILITY_POOL_ABI,
|
STABILITY_POOL_ABI,
|
||||||
// ACTIVE_POOL_ADDRESS,
|
ACTIVE_POOL_ADDRESS,
|
||||||
// ACTIVE_POOL_ABI,
|
ACTIVE_POOL_ABI,
|
||||||
// PRICE_FEED_ADDRESS,
|
PRICE_FEED_ADDRESS,
|
||||||
// PRICE_FEED_ABI,
|
PRICE_FEED_ABI,
|
||||||
// HINT_HELPERS_ADDRESS,
|
HINT_HELPERS_ADDRESS,
|
||||||
// HINT_HELPERS_ABI,
|
HINT_HELPERS_ABI,
|
||||||
// SORTED_TROVES_ADDRESS,
|
SORTED_TROVES_ADDRESS,
|
||||||
// SORTED_TROVES_ABI,
|
SORTED_TROVES_ABI,
|
||||||
// STAKING_ADDRESS,
|
STAKING_ADDRESS,
|
||||||
// STAKING_ABI,
|
STAKING_ABI,
|
||||||
// LQTY_TOKEN_ADDRESS,
|
LQTY_TOKEN_ADDRESS,
|
||||||
// LQTY_TOKEN_ABI,
|
LQTY_TOKEN_ABI,
|
||||||
// COLL_SURPLUS_ADDRESS,
|
COLL_SURPLUS_ADDRESS,
|
||||||
// COLL_SURPLUS_ABI,
|
COLL_SURPLUS_ABI,
|
||||||
// };
|
};
|
||||||
|
|
|
@ -1,343 +1,343 @@
|
||||||
// import hre from "hardhat";
|
import hre from "hardhat";
|
||||||
// import { ethers } from "hardhat";
|
import { ethers } from "hardhat";
|
||||||
// import hardhatConfig from "../../../hardhat.config";
|
import hardhatConfig from "../../../hardhat.config";
|
||||||
|
|
||||||
// // Instadapp deployment and testing helpers
|
// Instadapp deployment and testing helpers
|
||||||
// import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnableConnector.js"
|
import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnableConnector.js"
|
||||||
// import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2"
|
import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2"
|
||||||
// import { encodeSpells } from "../../../scripts/tests/encodeSpells.js"
|
import { encodeSpells } from "../../../scripts/tests/encodeSpells.js"
|
||||||
// import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"
|
import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"
|
||||||
|
|
||||||
// // Instadapp instadappAddresses/ABIs
|
// Instadapp instadappAddresses/ABIs
|
||||||
// import { instadappAddresses } from "../../../scripts/important/addresses";
|
import { instadappAddresses } from "../../../scripts/important/addresses";
|
||||||
// import { instadappAbi } from "../../../scripts/constant/abis";
|
import { instadappAbi } from "../../../scripts/constant/abis";
|
||||||
|
|
||||||
// // Instadapp Liquity Connector artifacts
|
// Instadapp Liquity Connector artifacts
|
||||||
// import { ConnectV2Liquity__factory, ConnectV2Basic__factory } from "../../../typechain";
|
import { ConnectV2Liquity__factory, ConnectV2Basic__factory } from "../../../typechain";
|
||||||
|
|
||||||
// // Instadapp uses a fake address to represent native ETH
|
// Instadapp uses a fake address to represent native ETH
|
||||||
// import { constants } from "../../../scripts/constant/constant.js";
|
import { constants } from "../../../scripts/constant/constant.js";
|
||||||
// import type { Signer, Contract } from "ethers";
|
import type { Signer, Contract } from "ethers";
|
||||||
|
|
||||||
|
|
||||||
// const LIQUITY_CONNECTOR = "LIQUITY-v1-TEST";
|
const LIQUITY_CONNECTOR = "LIQUITY-v1-TEST";
|
||||||
// const LUSD_GAS_COMPENSATION = hre.ethers.utils.parseUnits("200", 18); // 200 LUSD gas compensation repaid after loan repayment
|
const LUSD_GAS_COMPENSATION = hre.ethers.utils.parseUnits("200", 18); // 200 LUSD gas compensation repaid after loan repayment
|
||||||
// const LIQUIDATABLE_TROVES_BLOCK_NUMBER = 12478159; // Deterministic block number for tests to run against, if you change this, tests will break.
|
const LIQUIDATABLE_TROVES_BLOCK_NUMBER = 12478159; // Deterministic block number for tests to run against, if you change this, tests will break.
|
||||||
// const JUSTIN_SUN_ADDRESS = "0x903d12bf2c57a29f32365917c706ce0e1a84cce3"; // LQTY whale address
|
const JUSTIN_SUN_ADDRESS = "0x903d12bf2c57a29f32365917c706ce0e1a84cce3"; // LQTY whale address
|
||||||
// const LIQUIDATABLE_TROVE_ADDRESS = "0xafbeb4cb97f3b08ec2fe07ef0dac15d37013a347"; // Trove which is liquidatable at blockNumber: LIQUIDATABLE_TROVES_BLOCK_NUMBER
|
const LIQUIDATABLE_TROVE_ADDRESS = "0xafbeb4cb97f3b08ec2fe07ef0dac15d37013a347"; // Trove which is liquidatable at blockNumber: LIQUIDATABLE_TROVES_BLOCK_NUMBER
|
||||||
// // const MAX_GAS = hardhatConfig.networks.hardhat.blockGasLimit; // Maximum gas limit (12000000)
|
// const MAX_GAS = hardhatConfig.networks.hardhat.blockGasLimit; // Maximum gas limit (12000000)
|
||||||
// const INSTADAPP_BASIC_V1_CONNECTOR = "Basic-v1";
|
const INSTADAPP_BASIC_V1_CONNECTOR = "Basic-v1";
|
||||||
|
|
||||||
// const openTroveSpell = async (
|
const openTroveSpell = async (
|
||||||
// dsa: any,
|
dsa: any,
|
||||||
// signer: Signer,
|
signer: Signer,
|
||||||
// depositAmount: any,
|
depositAmount: any,
|
||||||
// borrowAmount: any,
|
borrowAmount: any,
|
||||||
// upperHint: any,
|
upperHint: any,
|
||||||
// lowerHint: any,
|
lowerHint: any,
|
||||||
// maxFeePercentage: any
|
maxFeePercentage: any
|
||||||
// ) => {
|
) => {
|
||||||
// let address = await signer.getAddress();
|
let address = await signer.getAddress();
|
||||||
|
|
||||||
// const openTroveSpell = {
|
const openTroveSpell = {
|
||||||
// connector: LIQUITY_CONNECTOR,
|
connector: LIQUITY_CONNECTOR,
|
||||||
// method: "open",
|
method: "open",
|
||||||
// args: [
|
args: [
|
||||||
// depositAmount,
|
depositAmount,
|
||||||
// maxFeePercentage,
|
maxFeePercentage,
|
||||||
// borrowAmount,
|
borrowAmount,
|
||||||
// upperHint,
|
upperHint,
|
||||||
// lowerHint,
|
lowerHint,
|
||||||
// [0, 0],
|
[0, 0],
|
||||||
// [0, 0],
|
[0, 0],
|
||||||
// ],
|
],
|
||||||
// };
|
};
|
||||||
|
|
||||||
// return await dsa
|
return await dsa
|
||||||
// .connect(signer)
|
.connect(signer)
|
||||||
// .cast(...encodeSpells([openTroveSpell]), address, {
|
.cast(...encodeSpells([openTroveSpell]), address, {
|
||||||
// value: depositAmount,
|
value: depositAmount,
|
||||||
// });
|
});
|
||||||
// };
|
};
|
||||||
|
|
||||||
// const createDsaTrove = async (
|
const createDsaTrove = async (
|
||||||
// dsa: any,
|
dsa: any,
|
||||||
// signer: any,
|
signer: any,
|
||||||
// liquity: any,
|
liquity: any,
|
||||||
// depositAmount = hre.ethers.utils.parseEther("5"),
|
depositAmount = hre.ethers.utils.parseEther("5"),
|
||||||
// borrowAmount = hre.ethers.utils.parseUnits("2000", 18)
|
borrowAmount = hre.ethers.utils.parseUnits("2000", 18)
|
||||||
// ) => {
|
) => {
|
||||||
// const maxFeePercentage = hre.ethers.utils.parseUnits("0.5", 18); // 0.5% max fee
|
const maxFeePercentage = hre.ethers.utils.parseUnits("0.5", 18); // 0.5% max fee
|
||||||
// const { upperHint, lowerHint } = await getTroveInsertionHints(
|
const { upperHint, lowerHint } = await getTroveInsertionHints(
|
||||||
// depositAmount,
|
depositAmount,
|
||||||
// borrowAmount,
|
borrowAmount,
|
||||||
// liquity
|
liquity
|
||||||
// );
|
);
|
||||||
// return await openTroveSpell(
|
return await openTroveSpell(
|
||||||
// dsa,
|
dsa,
|
||||||
// signer,
|
signer,
|
||||||
// depositAmount,
|
depositAmount,
|
||||||
// borrowAmount,
|
borrowAmount,
|
||||||
// upperHint,
|
upperHint,
|
||||||
// lowerHint,
|
lowerHint,
|
||||||
// maxFeePercentage
|
maxFeePercentage
|
||||||
// );
|
);
|
||||||
// };
|
};
|
||||||
|
|
||||||
// const sendToken = async (token: any, amount: any, from: any, to: any) => {
|
const sendToken = async (token: any, amount: any, from: any, to: any) => {
|
||||||
// await hre.network.provider.request({
|
await hre.network.provider.request({
|
||||||
// method: "hardhat_impersonateAccount",
|
method: "hardhat_impersonateAccount",
|
||||||
// params: [from],
|
params: [from],
|
||||||
// });
|
});
|
||||||
// const signer = hre.ethers.provider.getSigner(from);
|
const signer = hre.ethers.provider.getSigner(from);
|
||||||
|
|
||||||
// return await token.connect(signer).transfer(to, amount, {
|
return await token.connect(signer).transfer(to, amount, {
|
||||||
// gasPrice: 0,
|
gasPrice: 0,
|
||||||
// });
|
});
|
||||||
// };
|
};
|
||||||
|
|
||||||
// const resetInitialState = async (walletAddress: any, contracts: any, isDebug = false) => {
|
const resetInitialState = async (walletAddress: any, contracts: any, isDebug = false) => {
|
||||||
// const liquity = await deployAndConnect(contracts, isDebug);
|
const liquity = await deployAndConnect(contracts, isDebug);
|
||||||
// const dsa = await buildDSAv2(walletAddress);
|
const dsa = await buildDSAv2(walletAddress);
|
||||||
|
|
||||||
// return [liquity, dsa];
|
return [liquity, dsa];
|
||||||
// };
|
};
|
||||||
|
|
||||||
// const resetHardhatBlockNumber = async (blockNumber: number) => {
|
const resetHardhatBlockNumber = async (blockNumber: number) => {
|
||||||
// return await hre.network.provider.request({
|
return await hre.network.provider.request({
|
||||||
// method: "hardhat_reset",
|
method: "hardhat_reset",
|
||||||
// params: [
|
params: [
|
||||||
// {
|
{
|
||||||
// forking: {
|
forking: {
|
||||||
// // @ts-ignore
|
// @ts-ignore
|
||||||
// jsonRpcUrl: hre.config.networks.hardhat.forking.url,
|
jsonRpcUrl: hre.config.networks.hardhat.forking.url,
|
||||||
// blockNumber,
|
blockNumber,
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// ],
|
],
|
||||||
// });
|
});
|
||||||
// };
|
};
|
||||||
|
|
||||||
// const deployAndConnect = async (contracts: any, isDebug = false) => {
|
const deployAndConnect = async (contracts: any, isDebug = false) => {
|
||||||
// // Pin Liquity tests to a particular block number to create deterministic state (Ether price etc.)
|
// Pin Liquity tests to a particular block number to create deterministic state (Ether price etc.)
|
||||||
// await resetHardhatBlockNumber(LIQUIDATABLE_TROVES_BLOCK_NUMBER);
|
await resetHardhatBlockNumber(LIQUIDATABLE_TROVES_BLOCK_NUMBER);
|
||||||
// let liquity = {
|
let liquity = {
|
||||||
// troveManager: Contract,
|
troveManager: Contract,
|
||||||
// borrowerOperations: null,
|
borrowerOperations: null,
|
||||||
// stabilityPool: null,
|
stabilityPool: null,
|
||||||
// lusdToken: null,
|
lusdToken: null,
|
||||||
// lqtyToken: null,
|
lqtyToken: null,
|
||||||
// activePool: null,
|
activePool: null,
|
||||||
// priceFeed: null,
|
priceFeed: null,
|
||||||
// hintHelpers: null,
|
hintHelpers: null,
|
||||||
// sortedTroves: null,
|
sortedTroves: null,
|
||||||
// staking: null,
|
staking: null,
|
||||||
// collSurplus: null,
|
collSurplus: null,
|
||||||
// };
|
};
|
||||||
|
|
||||||
// const masterSigner = await getMasterSigner();
|
const masterSigner = await getMasterSigner();
|
||||||
// const instaConnectorsV2 = await ethers.getContractAt(
|
const instaConnectorsV2 = await ethers.getContractAt(
|
||||||
// instadappAbi.core.connectorsV2,
|
instadappAbi.core.connectorsV2,
|
||||||
// instadappAddresses.core.connectorsV2
|
instadappAddresses.core.connectorsV2
|
||||||
// );
|
);
|
||||||
// const connector = await deployAndEnableConnector({
|
const connector = await deployAndEnableConnector({
|
||||||
// connectorName: LIQUITY_CONNECTOR,
|
connectorName: LIQUITY_CONNECTOR,
|
||||||
// contractArtifact: ConnectV2Liquity__factory,
|
contractArtifact: ConnectV2Liquity__factory,
|
||||||
// signer: masterSigner,
|
signer: masterSigner,
|
||||||
// connectors: instaConnectorsV2,
|
connectors: instaConnectorsV2,
|
||||||
// });
|
});
|
||||||
// isDebug &&
|
isDebug &&
|
||||||
// console.log(`${LIQUITY_CONNECTOR} Connector address`, connector.address);
|
console.log(`${LIQUITY_CONNECTOR} Connector address`, connector.address);
|
||||||
|
|
||||||
// const basicConnector = await deployAndEnableConnector({
|
const basicConnector = await deployAndEnableConnector({
|
||||||
// connectorName: "Basic-v1",
|
connectorName: "Basic-v1",
|
||||||
// contractArtifact: ConnectV2Basic__factory,
|
contractArtifact: ConnectV2Basic__factory,
|
||||||
// signer: masterSigner,
|
signer: masterSigner,
|
||||||
// connectors: instaConnectorsV2,
|
connectors: instaConnectorsV2,
|
||||||
// });
|
});
|
||||||
// isDebug && console.log("Basic-v1 Connector address", basicConnector.address);
|
isDebug && console.log("Basic-v1 Connector address", basicConnector.address);
|
||||||
|
|
||||||
// liquity.troveManager = new ethers.Contract(
|
liquity.troveManager = new ethers.Contract(
|
||||||
// contracts.TROVE_MANAGER_ADDRESS,
|
contracts.TROVE_MANAGER_ADDRESS,
|
||||||
// contracts.TROVE_MANAGER_ABI,
|
contracts.TROVE_MANAGER_ABI,
|
||||||
// ethers.provider
|
ethers.provider
|
||||||
// );
|
);
|
||||||
|
|
||||||
// liquity.borrowerOperations = new ethers.Contract(
|
liquity.borrowerOperations = new ethers.Contract(
|
||||||
// contracts.BORROWER_OPERATIONS_ADDRESS,
|
contracts.BORROWER_OPERATIONS_ADDRESS,
|
||||||
// contracts.BORROWER_OPERATIONS_ABI,
|
contracts.BORROWER_OPERATIONS_ABI,
|
||||||
// ethers.provider
|
ethers.provider
|
||||||
// );
|
);
|
||||||
|
|
||||||
// liquity.stabilityPool = new ethers.Contract(
|
liquity.stabilityPool = new ethers.Contract(
|
||||||
// contracts.STABILITY_POOL_ADDRESS,
|
contracts.STABILITY_POOL_ADDRESS,
|
||||||
// contracts.STABILITY_POOL_ABI,
|
contracts.STABILITY_POOL_ABI,
|
||||||
// ethers.provider
|
ethers.provider
|
||||||
// );
|
);
|
||||||
|
|
||||||
// liquity.lusdToken = new ethers.Contract(
|
liquity.lusdToken = new ethers.Contract(
|
||||||
// contracts.LUSD_TOKEN_ADDRESS,
|
contracts.LUSD_TOKEN_ADDRESS,
|
||||||
// contracts.LUSD_TOKEN_ABI,
|
contracts.LUSD_TOKEN_ABI,
|
||||||
// ethers.provider
|
ethers.provider
|
||||||
// );
|
);
|
||||||
|
|
||||||
// liquity.lqtyToken = new ethers.Contract(
|
liquity.lqtyToken = new ethers.Contract(
|
||||||
// contracts.LQTY_TOKEN_ADDRESS,
|
contracts.LQTY_TOKEN_ADDRESS,
|
||||||
// contracts.LQTY_TOKEN_ABI,
|
contracts.LQTY_TOKEN_ABI,
|
||||||
// ethers.provider
|
ethers.provider
|
||||||
// );
|
);
|
||||||
|
|
||||||
// liquity.activePool = new ethers.Contract(
|
liquity.activePool = new ethers.Contract(
|
||||||
// contracts.ACTIVE_POOL_ADDRESS,
|
contracts.ACTIVE_POOL_ADDRESS,
|
||||||
// contracts.ACTIVE_POOL_ABI,
|
contracts.ACTIVE_POOL_ABI,
|
||||||
// ethers.provider
|
ethers.provider
|
||||||
// );
|
);
|
||||||
|
|
||||||
// liquity.priceFeed = new ethers.Contract(
|
liquity.priceFeed = new ethers.Contract(
|
||||||
// contracts.PRICE_FEED_ADDRESS,
|
contracts.PRICE_FEED_ADDRESS,
|
||||||
// contracts.PRICE_FEED_ABI,
|
contracts.PRICE_FEED_ABI,
|
||||||
// ethers.provider
|
ethers.provider
|
||||||
// );
|
);
|
||||||
|
|
||||||
// liquity.hintHelpers = new ethers.Contract(
|
liquity.hintHelpers = new ethers.Contract(
|
||||||
// contracts.HINT_HELPERS_ADDRESS,
|
contracts.HINT_HELPERS_ADDRESS,
|
||||||
// contracts.HINT_HELPERS_ABI,
|
contracts.HINT_HELPERS_ABI,
|
||||||
// ethers.provider
|
ethers.provider
|
||||||
// );
|
);
|
||||||
|
|
||||||
// liquity.sortedTroves = new ethers.Contract(
|
liquity.sortedTroves = new ethers.Contract(
|
||||||
// contracts.SORTED_TROVES_ADDRESS,
|
contracts.SORTED_TROVES_ADDRESS,
|
||||||
// contracts.SORTED_TROVES_ABI,
|
contracts.SORTED_TROVES_ABI,
|
||||||
// ethers.provider
|
ethers.provider
|
||||||
// );
|
);
|
||||||
|
|
||||||
// liquity.staking = new ethers.Contract(
|
liquity.staking = new ethers.Contract(
|
||||||
// contracts.STAKING_ADDRESS,
|
contracts.STAKING_ADDRESS,
|
||||||
// contracts.STAKING_ABI,
|
contracts.STAKING_ABI,
|
||||||
// ethers.provider
|
ethers.provider
|
||||||
// );
|
);
|
||||||
// liquity.collSurplus = new ethers.Contract(
|
liquity.collSurplus = new ethers.Contract(
|
||||||
// contracts.COLL_SURPLUS_ADDRESS,
|
contracts.COLL_SURPLUS_ADDRESS,
|
||||||
// contracts.COLL_SURPLUS_ABI,
|
contracts.COLL_SURPLUS_ABI,
|
||||||
// ethers.provider
|
ethers.provider
|
||||||
// );
|
);
|
||||||
|
|
||||||
// return liquity;
|
return liquity;
|
||||||
// };
|
};
|
||||||
|
|
||||||
// const getTroveInsertionHints = async (depositAmount, borrowAmount, liquity: any) => {
|
const getTroveInsertionHints = async (depositAmount, borrowAmount, liquity: any) => {
|
||||||
// const nominalCR = await liquity.hintHelpers.computeNominalCR(
|
const nominalCR = await liquity.hintHelpers.computeNominalCR(
|
||||||
// depositAmount,
|
depositAmount,
|
||||||
// borrowAmount
|
borrowAmount
|
||||||
// );
|
);
|
||||||
|
|
||||||
// const {
|
const {
|
||||||
// hintAddress,
|
hintAddress,
|
||||||
// latestRandomSeed,
|
latestRandomSeed,
|
||||||
// } = await liquity.hintHelpers.getApproxHint(nominalCR, 50, 1298379, {
|
} = await liquity.hintHelpers.getApproxHint(nominalCR, 50, 1298379, {
|
||||||
// gasLimit: MAX_GAS,
|
gasLimit: MAX_GAS,
|
||||||
// });
|
});
|
||||||
// randomSeed = latestRandomSeed;
|
randomSeed = latestRandomSeed;
|
||||||
|
|
||||||
// const {
|
const {
|
||||||
// 0: upperHint,
|
0: upperHint,
|
||||||
// 1: lowerHint,
|
1: lowerHint,
|
||||||
// } = await liquity.sortedTroves.findInsertPosition(
|
} = await liquity.sortedTroves.findInsertPosition(
|
||||||
// nominalCR,
|
nominalCR,
|
||||||
// hintAddress,
|
hintAddress,
|
||||||
// hintAddress,
|
hintAddress,
|
||||||
// {
|
{
|
||||||
// gasLimit: MAX_GAS,
|
gasLimit: MAX_GAS,
|
||||||
// }
|
}
|
||||||
// );
|
);
|
||||||
|
|
||||||
// return {
|
return {
|
||||||
// upperHint,
|
upperHint,
|
||||||
// lowerHint,
|
lowerHint,
|
||||||
// };
|
};
|
||||||
// };
|
};
|
||||||
|
|
||||||
// let randomSeed = 4223;
|
let randomSeed = 4223;
|
||||||
|
|
||||||
// const getRedemptionHints = async (amount, liquity) => {
|
const getRedemptionHints = async (amount, liquity) => {
|
||||||
// const ethPrice = await liquity.priceFeed.callStatic.fetchPrice();
|
const ethPrice = await liquity.priceFeed.callStatic.fetchPrice();
|
||||||
// const [
|
const [
|
||||||
// firstRedemptionHint,
|
firstRedemptionHint,
|
||||||
// partialRedemptionHintNicr,
|
partialRedemptionHintNicr,
|
||||||
// ] = await liquity.hintHelpers.getRedemptionHints(amount, ethPrice, 0);
|
] = await liquity.hintHelpers.getRedemptionHints(amount, ethPrice, 0);
|
||||||
|
|
||||||
// const {
|
const {
|
||||||
// hintAddress,
|
hintAddress,
|
||||||
// latestRandomSeed,
|
latestRandomSeed,
|
||||||
// } = await liquity.hintHelpers.getApproxHint(
|
} = await liquity.hintHelpers.getApproxHint(
|
||||||
// partialRedemptionHintNicr,
|
partialRedemptionHintNicr,
|
||||||
// 50,
|
50,
|
||||||
// randomSeed,
|
randomSeed,
|
||||||
// {
|
{
|
||||||
// gasLimit: MAX_GAS,
|
gasLimit: MAX_GAS,
|
||||||
// }
|
}
|
||||||
// );
|
);
|
||||||
// randomSeed = latestRandomSeed;
|
randomSeed = latestRandomSeed;
|
||||||
|
|
||||||
// const {
|
const {
|
||||||
// 0: upperHint,
|
0: upperHint,
|
||||||
// 1: lowerHint,
|
1: lowerHint,
|
||||||
// } = await liquity.sortedTroves.findInsertPosition(
|
} = await liquity.sortedTroves.findInsertPosition(
|
||||||
// partialRedemptionHintNicr,
|
partialRedemptionHintNicr,
|
||||||
// hintAddress,
|
hintAddress,
|
||||||
// hintAddress,
|
hintAddress,
|
||||||
// {
|
{
|
||||||
// gasLimit: MAX_GAS,
|
gasLimit: MAX_GAS,
|
||||||
// }
|
}
|
||||||
// );
|
);
|
||||||
|
|
||||||
// return {
|
return {
|
||||||
// partialRedemptionHintNicr,
|
partialRedemptionHintNicr,
|
||||||
// firstRedemptionHint,
|
firstRedemptionHint,
|
||||||
// upperHint,
|
upperHint,
|
||||||
// lowerHint,
|
lowerHint,
|
||||||
// };
|
};
|
||||||
// };
|
};
|
||||||
|
|
||||||
// const redeem = async (amount, from, wallet, liquity) => {
|
const redeem = async (amount, from, wallet, liquity) => {
|
||||||
// await sendToken(liquity.lusdToken, amount, from, wallet.address);
|
await sendToken(liquity.lusdToken, amount, from, wallet.address);
|
||||||
// const {
|
const {
|
||||||
// partialRedemptionHintNicr,
|
partialRedemptionHintNicr,
|
||||||
// firstRedemptionHint,
|
firstRedemptionHint,
|
||||||
// upperHint,
|
upperHint,
|
||||||
// lowerHint,
|
lowerHint,
|
||||||
// } = await getRedemptionHints(amount, liquity);
|
} = await getRedemptionHints(amount, liquity);
|
||||||
// const maxFeePercentage = ethers.utils.parseUnits("0.5", 18); // 0.5% max fee
|
const maxFeePercentage = ethers.utils.parseUnits("0.5", 18); // 0.5% max fee
|
||||||
|
|
||||||
// return await liquity.troveManager
|
return await liquity.troveManager
|
||||||
// .connect(wallet)
|
.connect(wallet)
|
||||||
// .redeemCollateral(
|
.redeemCollateral(
|
||||||
// amount,
|
amount,
|
||||||
// firstRedemptionHint,
|
firstRedemptionHint,
|
||||||
// upperHint,
|
upperHint,
|
||||||
// lowerHint,
|
lowerHint,
|
||||||
// partialRedemptionHintNicr,
|
partialRedemptionHintNicr,
|
||||||
// 0,
|
0,
|
||||||
// maxFeePercentage,
|
maxFeePercentage,
|
||||||
// {
|
{
|
||||||
// gasLimit: MAX_GAS, // permit max gas
|
gasLimit: MAX_GAS, // permit max gas
|
||||||
// }
|
}
|
||||||
// );
|
);
|
||||||
// };
|
};
|
||||||
|
|
||||||
// module.exports = {
|
module.exports = {
|
||||||
// deployAndConnect,
|
deployAndConnect,
|
||||||
// resetInitialState,
|
resetInitialState,
|
||||||
// createDsaTrove,
|
createDsaTrove,
|
||||||
// sendToken,
|
sendToken,
|
||||||
// getTroveInsertionHints,
|
getTroveInsertionHints,
|
||||||
// getRedemptionHints,
|
getRedemptionHints,
|
||||||
// redeem,
|
redeem,
|
||||||
// LIQUITY_CONNECTOR,
|
LIQUITY_CONNECTOR,
|
||||||
// LUSD_GAS_COMPENSATION,
|
LUSD_GAS_COMPENSATION,
|
||||||
// JUSTIN_SUN_ADDRESS,
|
JUSTIN_SUN_ADDRESS,
|
||||||
// LIQUIDATABLE_TROVE_ADDRESS,
|
LIQUIDATABLE_TROVE_ADDRESS,
|
||||||
// MAX_GAS,
|
MAX_GAS,
|
||||||
// INSTADAPP_BASIC_V1_CONNECTOR,
|
INSTADAPP_BASIC_V1_CONNECTOR,
|
||||||
// ETH_ADDRESS,
|
ETH_ADDRESS,
|
||||||
// };
|
};
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user