mirror of
				https://github.com/Instadapp/Gelato-automations.git
				synced 2024-07-29 22:28:07 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			82 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			82 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| const {expect} = require("chai");
 | |
| const hre = require("hardhat");
 | |
| const {deployments, ethers} = hre;
 | |
| const GelatoCoreLib = require("@gelatonetwork/core");
 | |
| 
 | |
| // Instadapp UI should do the same implementation for submitting debt bridge task
 | |
| async function providerWhiteListTaskForMakerETHAToMakerETHBWithVaultB(
 | |
|   wallets,
 | |
|   contracts,
 | |
|   constants,
 | |
|   vaultAId,
 | |
|   vaultBId
 | |
| ) {
 | |
|   //#region Step 9 Provider should whitelist task
 | |
| 
 | |
|   // By WhiteList task, the provider can constrain the type
 | |
|   // of task the user can submitting.
 | |
| 
 | |
|   //#region Actions
 | |
| 
 | |
|   const spells = [];
 | |
| 
 | |
|   const debtBridgeCalculationForFullRefinance = new GelatoCoreLib.Action({
 | |
|     addr: contracts.connectGelatoDataFullRefinanceMaker.address,
 | |
|     data: await hre.run("abi-encode-withselector", {
 | |
|       abi: (
 | |
|         await deployments.getArtifact("ConnectGelatoDataFullRefinanceMaker")
 | |
|       ).abi,
 | |
|       functionname: "getDataAndCastMakerToMaker",
 | |
|       inputs: [vaultAId, vaultBId, constants.ETH, "ETH-B"],
 | |
|     }),
 | |
|     operation: GelatoCoreLib.Operation.Delegatecall,
 | |
|   });
 | |
| 
 | |
|   spells.push(debtBridgeCalculationForFullRefinance);
 | |
| 
 | |
|   const gasPriceCeil = ethers.constants.MaxUint256;
 | |
| 
 | |
|   const connectGelatoFullDebtBridgeFromMakerTaskSpec = new GelatoCoreLib.TaskSpec(
 | |
|     {
 | |
|       conditions: [
 | |
|         contracts.conditionMakerVaultUnsafe.address,
 | |
|         contracts.conditionDebtBridgeIsAffordable.address,
 | |
|       ],
 | |
|       actions: spells,
 | |
|       gasPriceCeil,
 | |
|     }
 | |
|   );
 | |
| 
 | |
|   await expect(
 | |
|     contracts.gelatoCore
 | |
|       .connect(wallets.gelatoProviderWallet)
 | |
|       .provideTaskSpecs([connectGelatoFullDebtBridgeFromMakerTaskSpec])
 | |
|   ).to.emit(contracts.gelatoCore, "LogTaskSpecProvided");
 | |
| 
 | |
|   expect(
 | |
|     await contracts.gelatoCore
 | |
|       .connect(wallets.gelatoProviderWallet)
 | |
|       .isTaskSpecProvided(
 | |
|         wallets.gelatoProviderAddress,
 | |
|         connectGelatoFullDebtBridgeFromMakerTaskSpec
 | |
|       )
 | |
|   ).to.be.equal("OK");
 | |
| 
 | |
|   expect(
 | |
|     await contracts.gelatoCore
 | |
|       .connect(wallets.gelatoProviderWallet)
 | |
|       .taskSpecGasPriceCeil(
 | |
|         wallets.gelatoProviderAddress,
 | |
|         await contracts.gelatoCore
 | |
|           .connect(wallets.gelatoProviderWallet)
 | |
|           .hashTaskSpec(connectGelatoFullDebtBridgeFromMakerTaskSpec)
 | |
|       )
 | |
|   ).to.be.equal(gasPriceCeil);
 | |
| 
 | |
|   //#endregion
 | |
| 
 | |
|   return spells;
 | |
| }
 | |
| 
 | |
| module.exports = providerWhiteListTaskForMakerETHAToMakerETHBWithVaultB;
 | 
