mirror of
				https://github.com/Instadapp/dsa-connectors.git
				synced 2024-07-29 22:37:00 +00:00 
			
		
		
		
	fixed tests
This commit is contained in:
		
							parent
							
								
									4a572090bc
								
							
						
					
					
						commit
						d9233e3b93
					
				|  | @ -1,4 +1,4 @@ | ||||||
| export const addresses: Record<string, any> = { | export default { | ||||||
|   mainnet: { |   mainnet: { | ||||||
|     connectors: { |     connectors: { | ||||||
|       basic: "0xe5398f279175962E56fE4c5E0b62dc7208EF36c6", |       basic: "0xe5398f279175962E56fE4c5E0b62dc7208EF36c6", | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| import hre from "hardhat"; | import hre from "hardhat"; | ||||||
| import { expect } from "chai"; | import { expect } from "chai"; | ||||||
| import { abis } from "../../../scripts/constant/abis"; | import { abis } from "../../../scripts/constant/abis"; | ||||||
| import { addresses } from "../../../scripts/constant/addresses"; | import addresses from "../../../scripts/constant/addresses"; | ||||||
| import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnableConnector"; | import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnableConnector"; | ||||||
| import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"; | import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"; | ||||||
| import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2"; | import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2"; | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| import { expect } from "chai"; | import { expect } from "chai"; | ||||||
| import hre from "hardhat"; | import hre from "hardhat"; | ||||||
| import { abis } from "../../../scripts/constant/abis"; | import { abis } from "../../../scripts/constant/abis"; | ||||||
| import { addresses } from "../../../scripts/constant/addresses"; | import addresses from "../../../scripts/constant/addresses"; | ||||||
| import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnableConnector"; | import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnableConnector"; | ||||||
| import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"; | import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"; | ||||||
| import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2"; | import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2"; | ||||||
|  |  | ||||||
|  | @ -7,7 +7,7 @@ import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnable | ||||||
| import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2" | import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2" | ||||||
| import { encodeSpells } from "../../../scripts/tests/encodeSpells" | import { encodeSpells } from "../../../scripts/tests/encodeSpells" | ||||||
| import { getMasterSigner } from "../../../scripts/tests/getMasterSigner" | import { getMasterSigner } from "../../../scripts/tests/getMasterSigner" | ||||||
| import { addresses } from "../../../scripts/constant/addresses"; | import addresses from "../../../scripts/constant/addresses"; | ||||||
| import { abis } from "../../../scripts/constant/abis"; | import { abis } from "../../../scripts/constant/abis"; | ||||||
| import { constants } from "../../../scripts/constant/constant"; | import { constants } from "../../../scripts/constant/constant"; | ||||||
| import { ConnectV2BCompound__factory } from "../../../typechain"; | import { ConnectV2BCompound__factory } from "../../../typechain"; | ||||||
|  |  | ||||||
|  | @ -7,7 +7,7 @@ import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnable | ||||||
| import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2" | import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2" | ||||||
| import { encodeSpells } from "../../../scripts/tests/encodeSpells" | import { encodeSpells } from "../../../scripts/tests/encodeSpells" | ||||||
| import { getMasterSigner } from "../../../scripts/tests/getMasterSigner" | import { getMasterSigner } from "../../../scripts/tests/getMasterSigner" | ||||||
| import { addresses } from "../../../scripts/constant/addresses"; | import addresses from "../../../scripts/constant/addresses"; | ||||||
| import { abis } from "../../../scripts/constant/abis"; | import { abis } from "../../../scripts/constant/abis"; | ||||||
| import { tokens } from "../../../scripts/constant/tokens"; | import { tokens } from "../../../scripts/constant/tokens"; | ||||||
| import { ConnectV2BMakerDAO__factory } from "../../../typechain"; | import { ConnectV2BMakerDAO__factory } from "../../../typechain"; | ||||||
|  |  | ||||||
|  | @ -8,7 +8,7 @@ import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnable | ||||||
| import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2" | import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2" | ||||||
| import { encodeSpells } from "../../../scripts/tests/encodeSpells" | import { encodeSpells } from "../../../scripts/tests/encodeSpells" | ||||||
| import { getMasterSigner } from "../../../scripts/tests/getMasterSigner" | import { getMasterSigner } from "../../../scripts/tests/getMasterSigner" | ||||||
| import { addresses } from "../../../scripts/constant/addresses" | import addresses from "../../../scripts/constant/addresses" | ||||||
| import { abis } from "../../../scripts/constant/abis" | import { abis } from "../../../scripts/constant/abis" | ||||||
| import type { Signer, Contract } from "ethers"; | import type { Signer, Contract } from "ethers"; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -8,7 +8,7 @@ import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnable | ||||||
| import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2" | import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2" | ||||||
| import { encodeSpells } from "../../../scripts/tests/encodeSpells" | import { encodeSpells } from "../../../scripts/tests/encodeSpells" | ||||||
| import { getMasterSigner } from "../../../scripts/tests/getMasterSigner" | import { getMasterSigner } from "../../../scripts/tests/getMasterSigner" | ||||||
| import { addresses } from "../../../scripts/constant/addresses" | import addresses from "../../../scripts/constant/addresses" | ||||||
| import { abis } from "../../../scripts/constant/abis" | import { abis } from "../../../scripts/constant/abis" | ||||||
| import type { Signer, Contract } from "ethers"; | import type { Signer, Contract } from "ethers"; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -9,7 +9,7 @@ import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnable | ||||||
| import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2" | import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2" | ||||||
| import { encodeSpells } from "../../../scripts/tests/encodeSpells"; | import { encodeSpells } from "../../../scripts/tests/encodeSpells"; | ||||||
| import { getMasterSigner } from "../../../scripts/tests/getMasterSigner" | import { getMasterSigner } from "../../../scripts/tests/getMasterSigner" | ||||||
| import { addresses } from "../../../scripts/constant/addresses"; | import addresses from "../../../scripts/constant/addresses"; | ||||||
| import { abis } from "../../../scripts/constant/abis"; | import { abis } from "../../../scripts/constant/abis"; | ||||||
| import { constants } from "../../../scripts/constant/constant"; | import { constants } from "../../../scripts/constant/constant"; | ||||||
| import { ConnectV2Compound__factory } from "../../../typechain"; | import { ConnectV2Compound__factory } from "../../../typechain"; | ||||||
|  |  | ||||||
|  | @ -9,7 +9,7 @@ import { encodeSpells } from "../../../scripts/tests/encodeSpells" | ||||||
| import encodeFlashcastData from "../../../scripts/tests/encodeFlashcastData" | import encodeFlashcastData from "../../../scripts/tests/encodeFlashcastData" | ||||||
| import { getMasterSigner } from "../../../scripts/tests/getMasterSigner" | import { getMasterSigner } from "../../../scripts/tests/getMasterSigner" | ||||||
| 
 | 
 | ||||||
| import { addresses } from "../../../scripts/constant/addresses"; | import addresses from "../../../scripts/constant/addresses"; | ||||||
| import { abis } from "../../../scripts/constant/abis"; | import { abis } from "../../../scripts/constant/abis"; | ||||||
| import type { Signer, Contract } from "ethers"; | import type { Signer, Contract } from "ethers"; | ||||||
| import { ConnectV2Compound__factory } from "../../../typechain"; | import { ConnectV2Compound__factory } from "../../../typechain"; | ||||||
|  |  | ||||||
|  | @ -69,7 +69,7 @@ const COLL_SURPLUS_ABI = [ | ||||||
|   "function getCollateral(address _account) external view returns (uint)", |   "function getCollateral(address _account) external view returns (uint)", | ||||||
| ]; | ]; | ||||||
| 
 | 
 | ||||||
| module.exports = { | export default { | ||||||
|   TROVE_MANAGER_ADDRESS, |   TROVE_MANAGER_ADDRESS, | ||||||
|   TROVE_MANAGER_ABI, |   TROVE_MANAGER_ABI, | ||||||
|   BORROWER_OPERATIONS_ADDRESS, |   BORROWER_OPERATIONS_ADDRESS, | ||||||
|  |  | ||||||
|  | @ -3,30 +3,31 @@ 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" | ||||||
| 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" | ||||||
| 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/constant/addresses"; | ||||||
| import { instadappAbi } from "../../../scripts/constant/abis"; | import { abis } 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"; | ||||||
| import type { Signer, Contract } from "ethers"; | import type { Signer, Contract, BigNumber } 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)
 | // @ts-ignore
 | ||||||
|  | const MAX_GAS = hardhatConfig.networks.hardhat.blockGasLimit ?? 12000000; // Maximum gas limit (12000000)
 | ||||||
| const INSTADAPP_BASIC_V1_CONNECTOR = "Basic-v1"; | const INSTADAPP_BASIC_V1_CONNECTOR = "Basic-v1"; | ||||||
|  | const ETH = constants.native_address | ||||||
| 
 | 
 | ||||||
| const openTroveSpell = async ( | const openTroveSpell = async ( | ||||||
|   dsa: any, |   dsa: any, | ||||||
|  | @ -121,24 +122,26 @@ const resetHardhatBlockNumber = async (blockNumber: number) => { | ||||||
| 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 = { |   type Liquidity = { | ||||||
|     troveManager: Contract, |     troveManager: Contract, | ||||||
|     borrowerOperations: null, |     borrowerOperations: Contract, | ||||||
|     stabilityPool: null, |     stabilityPool: Contract, | ||||||
|     lusdToken: null, |     lusdToken: Contract, | ||||||
|     lqtyToken: null, |     lqtyToken: Contract, | ||||||
|     activePool: null, |     activePool: Contract, | ||||||
|     priceFeed: null, |     priceFeed: Contract, | ||||||
|     hintHelpers: null, |     hintHelpers: Contract, | ||||||
|     sortedTroves: null, |     sortedTroves: Contract, | ||||||
|     staking: null, |     staking: Contract, | ||||||
|     collSurplus: null, |     collSurplus: Contract, | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|  |   const liquity = {} as Liquidity | ||||||
|  | 
 | ||||||
|   const masterSigner = await getMasterSigner(); |   const masterSigner = await getMasterSigner(); | ||||||
|   const instaConnectorsV2 = await ethers.getContractAt( |   const instaConnectorsV2 = await ethers.getContractAt( | ||||||
|     instadappAbi.core.connectorsV2, |     abis.core.connectorsV2, | ||||||
|     instadappAddresses.core.connectorsV2 |     instadappAddresses.mainnet.core.connectorsV2 | ||||||
|   ); |   ); | ||||||
|   const connector = await deployAndEnableConnector({ |   const connector = await deployAndEnableConnector({ | ||||||
|     connectorName: LIQUITY_CONNECTOR, |     connectorName: LIQUITY_CONNECTOR, | ||||||
|  | @ -225,7 +228,7 @@ const deployAndConnect = async (contracts: any, isDebug = false) => { | ||||||
|   return liquity; |   return liquity; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| const getTroveInsertionHints = async (depositAmount, borrowAmount, liquity: any) => { | const getTroveInsertionHints = async (depositAmount: BigNumber, borrowAmount: BigNumber, liquity: any) => { | ||||||
|   const nominalCR = await liquity.hintHelpers.computeNominalCR( |   const nominalCR = await liquity.hintHelpers.computeNominalCR( | ||||||
|     depositAmount, |     depositAmount, | ||||||
|     borrowAmount |     borrowAmount | ||||||
|  | @ -259,7 +262,7 @@ const getTroveInsertionHints = async (depositAmount, borrowAmount, liquity: any) | ||||||
| 
 | 
 | ||||||
| let randomSeed = 4223; | let randomSeed = 4223; | ||||||
| 
 | 
 | ||||||
| const getRedemptionHints = async (amount, liquity) => { | const getRedemptionHints = async (amount: any, liquity: any) => { | ||||||
|   const ethPrice = await liquity.priceFeed.callStatic.fetchPrice(); |   const ethPrice = await liquity.priceFeed.callStatic.fetchPrice(); | ||||||
|   const [ |   const [ | ||||||
|     firstRedemptionHint, |     firstRedemptionHint, | ||||||
|  | @ -299,7 +302,7 @@ const getRedemptionHints = async (amount, liquity) => { | ||||||
|   }; |   }; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| const redeem = async (amount, from, wallet, liquity) => { | const redeem = async (amount: any, from: any, wallet: { address: any; }, liquity: any) => { | ||||||
|   await sendToken(liquity.lusdToken, amount, from, wallet.address); |   await sendToken(liquity.lusdToken, amount, from, wallet.address); | ||||||
|   const { |   const { | ||||||
|     partialRedemptionHintNicr, |     partialRedemptionHintNicr, | ||||||
|  | @ -325,7 +328,7 @@ const redeem = async (amount, from, wallet, liquity) => { | ||||||
|     ); |     ); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| module.exports = { | export default { | ||||||
|   deployAndConnect, |   deployAndConnect, | ||||||
|   resetInitialState, |   resetInitialState, | ||||||
|   createDsaTrove, |   createDsaTrove, | ||||||
|  | @ -339,5 +342,5 @@ module.exports = { | ||||||
|   LIQUIDATABLE_TROVE_ADDRESS, |   LIQUIDATABLE_TROVE_ADDRESS, | ||||||
|   MAX_GAS, |   MAX_GAS, | ||||||
|   INSTADAPP_BASIC_V1_CONNECTOR, |   INSTADAPP_BASIC_V1_CONNECTOR, | ||||||
|   ETH_ADDRESS, |   ETH, | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | @ -3,13 +3,14 @@ import { expect } from "chai"; | ||||||
| 
 | 
 | ||||||
| // Instadapp deployment and testing helpers
 | // Instadapp deployment and testing helpers
 | ||||||
| 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"; | ||||||
| 
 | 
 | ||||||
| // Liquity smart contracts
 | // Liquity smart contracts
 | ||||||
| import contracts from "./liquity.contracts"; | import contracts from "./liquity.contracts"; | ||||||
| 
 | 
 | ||||||
| // Liquity helpers
 | // Liquity helpers
 | ||||||
| import helpers from "./liquity.helpers"; | import helpers from "./liquity.helpers"; | ||||||
|  | import { Contract, Signer } from "ethers"; | ||||||
| 
 | 
 | ||||||
| describe("Liquity", () => { | describe("Liquity", () => { | ||||||
|   const { waffle, ethers } = hre; |   const { waffle, ethers } = hre; | ||||||
|  | @ -17,8 +18,8 @@ describe("Liquity", () => { | ||||||
| 
 | 
 | ||||||
|   // Waffle test account 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266 (holds 1000 ETH)
 |   // Waffle test account 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266 (holds 1000 ETH)
 | ||||||
|   const userWallet = provider.getWallets()[0]; |   const userWallet = provider.getWallets()[0]; | ||||||
|   let dsa = null; |   let dsa: any; | ||||||
|   let liquity = null; |   let liquity: any; | ||||||
| 
 | 
 | ||||||
|   before(async () => { |   before(async () => { | ||||||
|     await hre.network.provider.request({ |     await hre.network.provider.request({ | ||||||
|  | @ -26,6 +27,7 @@ describe("Liquity", () => { | ||||||
|       params: [ |       params: [ | ||||||
|         { |         { | ||||||
|           forking: { |           forking: { | ||||||
|  |             // @ts-ignore
 | ||||||
|             jsonRpcUrl: hre.config.networks.hardhat.forking.url, |             jsonRpcUrl: hre.config.networks.hardhat.forking.url, | ||||||
|             blockNumber: 13300000, |             blockNumber: 13300000, | ||||||
|           }, |           }, | ||||||
|  | @ -143,7 +145,7 @@ describe("Liquity", () => { | ||||||
|           const depositEthSpell = { |           const depositEthSpell = { | ||||||
|             connector: helpers.INSTADAPP_BASIC_V1_CONNECTOR, |             connector: helpers.INSTADAPP_BASIC_V1_CONNECTOR, | ||||||
|             method: "deposit", |             method: "deposit", | ||||||
|             args: [helpers.ETH_ADDRESS, depositAmount, 0, depositId], |             args: [helpers.ETH, depositAmount, 0, depositId], | ||||||
|           }; |           }; | ||||||
| 
 | 
 | ||||||
|           const openTroveSpell = { |           const openTroveSpell = { | ||||||
|  | @ -321,8 +323,9 @@ describe("Liquity", () => { | ||||||
|             } |             } | ||||||
|           ); |           ); | ||||||
|           const receipt = await openTx.wait(); |           const receipt = await openTx.wait(); | ||||||
|           const castLogEvent = receipt.events.find((e) => e.event === "LogCast") |           const castLogEvent = receipt.events.find( | ||||||
|             .args; |             (e: { event: string }) => e.event === "LogCast" | ||||||
|  |           ).args; | ||||||
|           expect(castLogEvent.eventNames[0]).eq( |           expect(castLogEvent.eventNames[0]).eq( | ||||||
|             "LogOpen(address,uint256,uint256,uint256,uint256[],uint256[])" |             "LogOpen(address,uint256,uint256,uint256,uint256[],uint256[])" | ||||||
|           ); |           ); | ||||||
|  | @ -541,7 +544,7 @@ describe("Liquity", () => { | ||||||
|             connector: helpers.INSTADAPP_BASIC_V1_CONNECTOR, |             connector: helpers.INSTADAPP_BASIC_V1_CONNECTOR, | ||||||
|             method: "withdraw", |             method: "withdraw", | ||||||
|             args: [ |             args: [ | ||||||
|               helpers.ETH_ADDRESS, |               helpers.ETH, | ||||||
|               0, // amount comes from the previous spell's setId
 |               0, // amount comes from the previous spell's setId
 | ||||||
|               dsa.address, |               dsa.address, | ||||||
|               collateralWithdrawId, |               collateralWithdrawId, | ||||||
|  | @ -612,8 +615,9 @@ describe("Liquity", () => { | ||||||
|             .cast(...encodeSpells([closeTroveSpell]), userWallet.address); |             .cast(...encodeSpells([closeTroveSpell]), userWallet.address); | ||||||
| 
 | 
 | ||||||
|           const receipt = await closeTx.wait(); |           const receipt = await closeTx.wait(); | ||||||
|           const castLogEvent = receipt.events.find((e) => e.event === "LogCast") |           const castLogEvent = receipt.events.find( | ||||||
|             .args; |             (e: { event: string }) => e.event === "LogCast" | ||||||
|  |           ).args; | ||||||
|           const expectedEventParams = ethers.utils.defaultAbiCoder.encode( |           const expectedEventParams = ethers.utils.defaultAbiCoder.encode( | ||||||
|             ["address", "uint256"], |             ["address", "uint256"], | ||||||
|             [dsa.address, 0] |             [dsa.address, 0] | ||||||
|  | @ -673,7 +677,7 @@ describe("Liquity", () => { | ||||||
|           const depositEthSpell = { |           const depositEthSpell = { | ||||||
|             connector: helpers.INSTADAPP_BASIC_V1_CONNECTOR, |             connector: helpers.INSTADAPP_BASIC_V1_CONNECTOR, | ||||||
|             method: "deposit", |             method: "deposit", | ||||||
|             args: [helpers.ETH_ADDRESS, topupAmount, 0, depositId], |             args: [helpers.ETH, topupAmount, 0, depositId], | ||||||
|           }; |           }; | ||||||
| 
 | 
 | ||||||
|           const upperHint = ethers.constants.AddressZero; |           const upperHint = ethers.constants.AddressZero; | ||||||
|  | @ -725,8 +729,9 @@ describe("Liquity", () => { | ||||||
|             }); |             }); | ||||||
| 
 | 
 | ||||||
|           const receipt = await depositTx.wait(); |           const receipt = await depositTx.wait(); | ||||||
|           const castLogEvent = receipt.events.find((e) => e.event === "LogCast") |           const castLogEvent = receipt.events.find( | ||||||
|             .args; |             (e: { event: string }) => e.event === "LogCast" | ||||||
|  |           ).args; | ||||||
|           const expectedEventParams = ethers.utils.defaultAbiCoder.encode( |           const expectedEventParams = ethers.utils.defaultAbiCoder.encode( | ||||||
|             ["address", "uint256", "uint256", "uint256"], |             ["address", "uint256", "uint256", "uint256"], | ||||||
|             [dsa.address, topupAmount, 0, 0] |             [dsa.address, topupAmount, 0, 0] | ||||||
|  | @ -796,7 +801,7 @@ describe("Liquity", () => { | ||||||
|           const withdrawEthSpell = { |           const withdrawEthSpell = { | ||||||
|             connector: helpers.INSTADAPP_BASIC_V1_CONNECTOR, |             connector: helpers.INSTADAPP_BASIC_V1_CONNECTOR, | ||||||
|             method: "withdraw", |             method: "withdraw", | ||||||
|             args: [helpers.ETH_ADDRESS, 0, userWallet.address, withdrawId, 0], |             args: [helpers.ETH, 0, userWallet.address, withdrawId, 0], | ||||||
|           }; |           }; | ||||||
|           const spells = [withdrawEthFromTroveSpell, withdrawEthSpell]; |           const spells = [withdrawEthFromTroveSpell, withdrawEthSpell]; | ||||||
|           await dsa |           await dsa | ||||||
|  | @ -844,8 +849,9 @@ describe("Liquity", () => { | ||||||
|             .cast(...encodeSpells([withdrawEthSpell]), userWallet.address); |             .cast(...encodeSpells([withdrawEthSpell]), userWallet.address); | ||||||
| 
 | 
 | ||||||
|           const receipt = await withdrawTx.wait(); |           const receipt = await withdrawTx.wait(); | ||||||
|           const castLogEvent = receipt.events.find((e) => e.event === "LogCast") |           const castLogEvent = receipt.events.find( | ||||||
|             .args; |             (e: { event: string }) => e.event === "LogCast" | ||||||
|  |           ).args; | ||||||
|           const expectedEventParams = ethers.utils.defaultAbiCoder.encode( |           const expectedEventParams = ethers.utils.defaultAbiCoder.encode( | ||||||
|             ["address", "uint256", "uint256", "uint256"], |             ["address", "uint256", "uint256", "uint256"], | ||||||
|             [dsa.address, withdrawAmount, 0, 0] |             [dsa.address, withdrawAmount, 0, 0] | ||||||
|  | @ -973,8 +979,9 @@ describe("Liquity", () => { | ||||||
|             .cast(...encodeSpells([borrowSpell]), userWallet.address); |             .cast(...encodeSpells([borrowSpell]), userWallet.address); | ||||||
| 
 | 
 | ||||||
|           const receipt = await borrowTx.wait(); |           const receipt = await borrowTx.wait(); | ||||||
|           const castLogEvent = receipt.events.find((e) => e.event === "LogCast") |           const castLogEvent = receipt.events.find( | ||||||
|             .args; |             (e: { event: string }) => e.event === "LogCast" | ||||||
|  |           ).args; | ||||||
|           const expectedEventParams = ethers.utils.defaultAbiCoder.encode( |           const expectedEventParams = ethers.utils.defaultAbiCoder.encode( | ||||||
|             ["address", "uint256", "uint256", "uint256"], |             ["address", "uint256", "uint256", "uint256"], | ||||||
|             [dsa.address, borrowAmount, 0, 0] |             [dsa.address, borrowAmount, 0, 0] | ||||||
|  | @ -1130,8 +1137,9 @@ describe("Liquity", () => { | ||||||
|             }); |             }); | ||||||
| 
 | 
 | ||||||
|           const receipt = await repayTx.wait(); |           const receipt = await repayTx.wait(); | ||||||
|           const castLogEvent = receipt.events.find((e) => e.event === "LogCast") |           const castLogEvent = receipt.events.find( | ||||||
|             .args; |             (e: { event: string }) => e.event === "LogCast" | ||||||
|  |           ).args; | ||||||
|           const expectedEventParams = ethers.utils.defaultAbiCoder.encode( |           const expectedEventParams = ethers.utils.defaultAbiCoder.encode( | ||||||
|             ["address", "uint256", "uint256", "uint256"], |             ["address", "uint256", "uint256", "uint256"], | ||||||
|             [dsa.address, repayAmount, 0, 0] |             [dsa.address, repayAmount, 0, 0] | ||||||
|  | @ -1295,7 +1303,7 @@ describe("Liquity", () => { | ||||||
|           const depositEthSpell = { |           const depositEthSpell = { | ||||||
|             connector: helpers.INSTADAPP_BASIC_V1_CONNECTOR, |             connector: helpers.INSTADAPP_BASIC_V1_CONNECTOR, | ||||||
|             method: "deposit", |             method: "deposit", | ||||||
|             args: [helpers.ETH_ADDRESS, depositAmount, 0, ethDepositId], |             args: [helpers.ETH, depositAmount, 0, ethDepositId], | ||||||
|           }; |           }; | ||||||
| 
 | 
 | ||||||
|           const depositLusdSpell = { |           const depositLusdSpell = { | ||||||
|  | @ -1403,13 +1411,7 @@ describe("Liquity", () => { | ||||||
|           const withdrawEthSpell = { |           const withdrawEthSpell = { | ||||||
|             connector: helpers.INSTADAPP_BASIC_V1_CONNECTOR, |             connector: helpers.INSTADAPP_BASIC_V1_CONNECTOR, | ||||||
|             method: "withdraw", |             method: "withdraw", | ||||||
|             args: [ |             args: [helpers.ETH, 0, userWallet.address, ethWithdrawId, 0], | ||||||
|               helpers.ETH_ADDRESS, |  | ||||||
|               0, |  | ||||||
|               userWallet.address, |  | ||||||
|               ethWithdrawId, |  | ||||||
|               0, |  | ||||||
|             ], |  | ||||||
|           }; |           }; | ||||||
| 
 | 
 | ||||||
|           const withdrawLusdSpell = { |           const withdrawLusdSpell = { | ||||||
|  | @ -1484,8 +1486,9 @@ describe("Liquity", () => { | ||||||
|             }); |             }); | ||||||
| 
 | 
 | ||||||
|           const receipt = await adjustTx.wait(); |           const receipt = await adjustTx.wait(); | ||||||
|           const castLogEvent = receipt.events.find((e) => e.event === "LogCast") |           const castLogEvent = receipt.events.find( | ||||||
|             .args; |             (e: { event: string }) => e.event === "LogCast" | ||||||
|  |           ).args; | ||||||
|           const expectedEventParams = ethers.utils.defaultAbiCoder.encode( |           const expectedEventParams = ethers.utils.defaultAbiCoder.encode( | ||||||
|             [ |             [ | ||||||
|               "address", |               "address", | ||||||
|  | @ -1645,8 +1648,9 @@ describe("Liquity", () => { | ||||||
|             ); |             ); | ||||||
| 
 | 
 | ||||||
|           const receipt = await claimTx.wait(); |           const receipt = await claimTx.wait(); | ||||||
|           const castLogEvent = receipt.events.find((e) => e.event === "LogCast") |           const castLogEvent = receipt.events.find( | ||||||
|             .args; |             (e: { event: string }) => e.event === "LogCast" | ||||||
|  |           ).args; | ||||||
|           const expectedEventParams = ethers.utils.defaultAbiCoder.encode( |           const expectedEventParams = ethers.utils.defaultAbiCoder.encode( | ||||||
|             ["address", "uint256", "uint256"], |             ["address", "uint256", "uint256"], | ||||||
|             [dsa.address, claimAmount, setId] |             [dsa.address, claimAmount, setId] | ||||||
|  | @ -1768,7 +1772,7 @@ describe("Liquity", () => { | ||||||
| 
 | 
 | ||||||
|           // Fast forward in time so we have an LQTY gain
 |           // Fast forward in time so we have an LQTY gain
 | ||||||
|           await provider.send("evm_increaseTime", [600]); |           await provider.send("evm_increaseTime", [600]); | ||||||
|           await provider.send("evm_mine"); |           await provider.send("evm_mine", []); | ||||||
| 
 | 
 | ||||||
|           // Create a Stability Pool deposit with a differen DSA so that LQTY gains can be calculated
 |           // Create a Stability Pool deposit with a differen DSA so that LQTY gains can be calculated
 | ||||||
|           // See: https://github.com/liquity/dev/#lqty-reward-events-and-payouts
 |           // See: https://github.com/liquity/dev/#lqty-reward-events-and-payouts
 | ||||||
|  | @ -1796,8 +1800,9 @@ describe("Liquity", () => { | ||||||
|             .cast(...encodeSpells([stabilityDepositSpell]), userWallet.address); |             .cast(...encodeSpells([stabilityDepositSpell]), userWallet.address); | ||||||
| 
 | 
 | ||||||
|           const receipt = await depositAgainTx.wait(); |           const receipt = await depositAgainTx.wait(); | ||||||
|           const castLogEvent = receipt.events.find((e) => e.event === "LogCast") |           const castLogEvent = receipt.events.find( | ||||||
|             .args; |             (e: { event: string }) => e.event === "LogCast" | ||||||
|  |           ).args; | ||||||
|           const expectedEventParams = ethers.utils.defaultAbiCoder.encode( |           const expectedEventParams = ethers.utils.defaultAbiCoder.encode( | ||||||
|             [ |             [ | ||||||
|               "address", |               "address", | ||||||
|  | @ -1992,7 +1997,7 @@ describe("Liquity", () => { | ||||||
| 
 | 
 | ||||||
|           // Fast forward in time so we have an LQTY gain
 |           // Fast forward in time so we have an LQTY gain
 | ||||||
|           await provider.send("evm_increaseTime", [600]); |           await provider.send("evm_increaseTime", [600]); | ||||||
|           await provider.send("evm_mine"); |           await provider.send("evm_mine", []); | ||||||
| 
 | 
 | ||||||
|           // Create another Stability Pool deposit so that LQTY gains are realized
 |           // Create another Stability Pool deposit so that LQTY gains are realized
 | ||||||
|           // See: https://github.com/liquity/dev/#lqty-reward-events-and-payouts
 |           // See: https://github.com/liquity/dev/#lqty-reward-events-and-payouts
 | ||||||
|  | @ -2034,8 +2039,9 @@ describe("Liquity", () => { | ||||||
|             ); |             ); | ||||||
| 
 | 
 | ||||||
|           const receipt = await withdrawTx.wait(); |           const receipt = await withdrawTx.wait(); | ||||||
|           const castLogEvent = receipt.events.find((e) => e.event === "LogCast") |           const castLogEvent = receipt.events.find( | ||||||
|             .args; |             (e: { event: string }) => e.event === "LogCast" | ||||||
|  |           ).args; | ||||||
|           const expectedEventParams = ethers.utils.defaultAbiCoder.encode( |           const expectedEventParams = ethers.utils.defaultAbiCoder.encode( | ||||||
|             [ |             [ | ||||||
|               "address", |               "address", | ||||||
|  | @ -2172,8 +2178,9 @@ describe("Liquity", () => { | ||||||
| 
 | 
 | ||||||
|           const receipt = await moveEthGainTx.wait(); |           const receipt = await moveEthGainTx.wait(); | ||||||
| 
 | 
 | ||||||
|           const castLogEvent = receipt.events.find((e) => e.event === "LogCast") |           const castLogEvent = receipt.events.find( | ||||||
|             .args; |             (e: { event: string }) => e.event === "LogCast" | ||||||
|  |           ).args; | ||||||
|           const expectedEventParams = ethers.utils.defaultAbiCoder.encode( |           const expectedEventParams = ethers.utils.defaultAbiCoder.encode( | ||||||
|             ["address", "uint256"], |             ["address", "uint256"], | ||||||
|             [dsa.address, ethGainFromLiquidation] |             [dsa.address, ethGainFromLiquidation] | ||||||
|  | @ -2293,8 +2300,9 @@ describe("Liquity", () => { | ||||||
| 
 | 
 | ||||||
|           const receipt = await stakeTx.wait(); |           const receipt = await stakeTx.wait(); | ||||||
| 
 | 
 | ||||||
|           const castLogEvent = receipt.events.find((e) => e.event === "LogCast") |           const castLogEvent = receipt.events.find( | ||||||
|             .args; |             (e: { event: string }) => e.event === "LogCast" | ||||||
|  |           ).args; | ||||||
|           const expectedEventParams = ethers.utils.defaultAbiCoder.encode( |           const expectedEventParams = ethers.utils.defaultAbiCoder.encode( | ||||||
|             ["address", "uint256", "uint256", "uint256", "uint256", "uint256"], |             ["address", "uint256", "uint256", "uint256", "uint256", "uint256"], | ||||||
|             [ |             [ | ||||||
|  | @ -2457,8 +2465,9 @@ describe("Liquity", () => { | ||||||
| 
 | 
 | ||||||
|           const receipt = await unstakeTx.wait(); |           const receipt = await unstakeTx.wait(); | ||||||
| 
 | 
 | ||||||
|           const castLogEvent = receipt.events.find((e) => e.event === "LogCast") |           const castLogEvent = receipt.events.find( | ||||||
|             .args; |             (e: { event: string }) => e.event === "LogCast" | ||||||
|  |           ).args; | ||||||
|           const expectedEventParams = ethers.utils.defaultAbiCoder.encode( |           const expectedEventParams = ethers.utils.defaultAbiCoder.encode( | ||||||
|             ["address", "uint256", "uint256", "uint256", "uint256", "uint256"], |             ["address", "uint256", "uint256", "uint256", "uint256", "uint256"], | ||||||
|             [ |             [ | ||||||
|  | @ -2601,7 +2610,7 @@ describe("Liquity", () => { | ||||||
|           const withdrawEthSpell = { |           const withdrawEthSpell = { | ||||||
|             connector: helpers.INSTADAPP_BASIC_V1_CONNECTOR, |             connector: helpers.INSTADAPP_BASIC_V1_CONNECTOR, | ||||||
|             method: "withdraw", |             method: "withdraw", | ||||||
|             args: [helpers.ETH_ADDRESS, 0, userWallet.address, ethGainId, 0], |             args: [helpers.ETH, 0, userWallet.address, ethGainId, 0], | ||||||
|           }; |           }; | ||||||
| 
 | 
 | ||||||
|           const withdrawLusdSpell = { |           const withdrawLusdSpell = { | ||||||
|  | @ -2702,8 +2711,9 @@ describe("Liquity", () => { | ||||||
| 
 | 
 | ||||||
|           const receipt = await claimGainsTx.wait(); |           const receipt = await claimGainsTx.wait(); | ||||||
| 
 | 
 | ||||||
|           const castLogEvent = receipt.events.find((e) => e.event === "LogCast") |           const castLogEvent = receipt.events.find( | ||||||
|             .args; |             (e: { event: string }) => e.event === "LogCast" | ||||||
|  |           ).args; | ||||||
|           const expectedEventParams = ethers.utils.defaultAbiCoder.encode( |           const expectedEventParams = ethers.utils.defaultAbiCoder.encode( | ||||||
|             ["address", "uint256", "uint256", "uint256", "uint256"], |             ["address", "uint256", "uint256", "uint256", "uint256"], | ||||||
|             [stakerDsa.address, ethGain, lusdGain, setEthGainId, setLusdGainId] |             [stakerDsa.address, ethGain, lusdGain, setEthGainId, setLusdGainId] | ||||||
|  |  | ||||||
|  | @ -8,7 +8,7 @@ import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2"; | ||||||
| import { encodeSpells } from "../../../scripts/tests/encodeSpells"; | import { encodeSpells } from "../../../scripts/tests/encodeSpells"; | ||||||
| import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"; | import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"; | ||||||
| 
 | 
 | ||||||
| import { addresses } from "../../../scripts/constant/addresses"; | import addresses from "../../../scripts/constant/addresses"; | ||||||
| import { abis } from "../../../scripts/constant/abis"; | import { abis } from "../../../scripts/constant/abis"; | ||||||
| import { constants } from "../../../scripts/constant/constant"; | import { constants } from "../../../scripts/constant/constant"; | ||||||
| import { tokens } from "../../../scripts/constant/tokens"; | import { tokens } from "../../../scripts/constant/tokens"; | ||||||
|  |  | ||||||
|  | @ -8,7 +8,7 @@ import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2"; | ||||||
| import { encodeSpells } from "../../../scripts/tests/encodeSpells"; | import { encodeSpells } from "../../../scripts/tests/encodeSpells"; | ||||||
| import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"; | import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"; | ||||||
| import { addLiquidity } from "../../../scripts/tests/addLiquidity"; | import { addLiquidity } from "../../../scripts/tests/addLiquidity"; | ||||||
| import { addresses } from "../../../scripts/constant/addresses"; | import addresses from "../../../scripts/constant/addresses"; | ||||||
| import { abis } from "../../../scripts/constant/abis"; | import { abis } from "../../../scripts/constant/abis"; | ||||||
| import type { Signer, Contract } from "ethers"; | import type { Signer, Contract } from "ethers"; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -9,7 +9,7 @@ import { encodeSpells } from "../../../scripts/tests/encodeSpells"; | ||||||
| import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"; | import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"; | ||||||
| import { addLiquidity } from "../../../scripts/tests/addLiquidity"; | import { addLiquidity } from "../../../scripts/tests/addLiquidity"; | ||||||
| 
 | 
 | ||||||
| import { addresses } from "../../../scripts/constant/addresses"; | import addresses from "../../../scripts/constant/addresses"; | ||||||
| import { abis } from "../../../scripts/constant/abis"; | import { abis } from "../../../scripts/constant/abis"; | ||||||
| import { abi } from "@uniswap/v3-periphery/artifacts/contracts/NonfungiblePositionManager.sol/NonfungiblePositionManager.json" | import { abi } from "@uniswap/v3-periphery/artifacts/contracts/NonfungiblePositionManager.sol/NonfungiblePositionManager.json" | ||||||
| import type { Signer, Contract } from "ethers"; | import type { Signer, Contract } from "ethers"; | ||||||
|  |  | ||||||
|  | @ -8,7 +8,7 @@ import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2"; | ||||||
| import { encodeSpells } from "../../../scripts/tests/encodeSpells"; | import { encodeSpells } from "../../../scripts/tests/encodeSpells"; | ||||||
| import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"; | import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"; | ||||||
| 
 | 
 | ||||||
| import { addresses } from "../../../scripts/constant/addresses"; | import addresses from "../../../scripts/constant/addresses"; | ||||||
| import { abis } from "../../../scripts/constant/abis"; | import { abis } from "../../../scripts/constant/abis"; | ||||||
| import { tokens } from "../../../scripts/constant/tokens"; | import { tokens } from "../../../scripts/constant/tokens"; | ||||||
| import { Signer, Contract, BigNumber } from "ethers"; | import { Signer, Contract, BigNumber } from "ethers"; | ||||||
|  |  | ||||||
|  | @ -10,7 +10,7 @@ import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2"; | ||||||
| import { encodeSpells } from "../../../scripts/tests/encodeSpells"; | import { encodeSpells } from "../../../scripts/tests/encodeSpells"; | ||||||
| import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"; | import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"; | ||||||
| 
 | 
 | ||||||
| import { addresses } from "../../../scripts/constant/addresses"; | import addresses from "../../../scripts/constant/addresses"; | ||||||
| import { abis } from "../../../scripts/constant/abis"; | import { abis } from "../../../scripts/constant/abis"; | ||||||
| import { tokens } from "../../../scripts/constant/tokens"; | import { tokens } from "../../../scripts/constant/tokens"; | ||||||
| import type { Signer, Contract } from "ethers"; | import type { Signer, Contract } from "ethers"; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 pradyuman-verma
						pradyuman-verma