diff --git a/contracts/contracts/connectors/ConnectGelatoDataForFullRefinance.sol b/contracts/contracts/connectors/ConnectGelatoDataForFullRefinance.sol index 486933e..da23c1e 100644 --- a/contracts/contracts/connectors/ConnectGelatoDataForFullRefinance.sol +++ b/contracts/contracts/connectors/ConnectGelatoDataForFullRefinance.sol @@ -48,7 +48,7 @@ contract ConnectGelatoDataForFullRefinance is ConnectorInterface { uint256 internal immutable _id; address internal immutable _connectGelatoProviderPayment; - uint256 public constant GAS_COST = 1800000 + (18000 * 12); // 1800000 + ~12% (Estimated Value) + uint256 public constant GAS_COST = 1850000; constructor(uint256 id, address connectGelatoProviderPayment) { _id = id; diff --git a/contracts/contracts/connectors/ConnectGelatoDataForPartialRefinance.sol b/contracts/contracts/connectors/ConnectGelatoDataForPartialRefinance.sol index b5d307b..6a274df 100644 --- a/contracts/contracts/connectors/ConnectGelatoDataForPartialRefinance.sol +++ b/contracts/contracts/connectors/ConnectGelatoDataForPartialRefinance.sol @@ -69,7 +69,7 @@ contract ConnectGelatoDataForPartialRefinance is ConnectorInterface { uint256 internal immutable _id; address internal immutable _connectGelatoProviderPayment; - uint256 public constant GAS_COST = 1490779 + (14908 * 12); // 1490779 + ~12% (Estimated Value) + uint256 public constant GAS_COST = 1850000; constructor(uint256 id, address connectGelatoProviderPayment) { _id = id; diff --git a/hardhat.config.js b/hardhat.config.js index 93dea4f..04fba57 100644 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -26,7 +26,7 @@ module.exports = { // timeout: 150000, forking: { url: `https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_ID}`, - blockNumber: 11104384, + blockNumber: 11189230, }, // Custom GelatoCore: "0x1d681d76ce96E4d70a88A00EBbcfc1E47808d0b8", diff --git a/test/2_Full-Debt-Bridge-Maker-Compound.test.js b/test/2_Full-Debt-Bridge-Maker-Compound.test.js index 6e114e7..13851bd 100644 --- a/test/2_Full-Debt-Bridge-Maker-Compound.test.js +++ b/test/2_Full-Debt-Bridge-Maker-Compound.test.js @@ -183,9 +183,9 @@ describe("Full Debt Bridge refinancing loan from Maker to Compound", function () vaultId ); - const gasFeesPaidFromCol = ethers.utils - .parseUnits(String(1800000 + 18000 * 12), 0) - .mul(gelatoGasPrice); + const gasFeesPaidFromCol = ethers.BigNumber.from(1850000).mul( + gelatoGasPrice + ); const pricedCollateral = ( await contracts.makerResolver.getMakerVaultCollateralBalance(vaultId) @@ -220,7 +220,13 @@ describe("Full Debt Bridge refinancing loan from Maker to Compound", function () expect( await contracts.gelatoCore.providerFunds(wallets.providerAddress) - ).to.be.gt(providerBalanceBeforeExecution); + ).to.be.gt( + providerBalanceBeforeExecution.sub( + gasFeesPaidFromCol + .mul(await contracts.gelatoCore.totalSuccessShare()) + .div(100) + ) + ); // compound position of DSA on cDai and cEth const compoundPosition = await contracts.compoundResolver.getCompoundData( diff --git a/test/3_Full-Debt-Bridge-ETHA-ETHB.test.js b/test/3_Full-Debt-Bridge-ETHA-ETHB.test.js index a124109..aff0bc9 100644 --- a/test/3_Full-Debt-Bridge-ETHA-ETHB.test.js +++ b/test/3_Full-Debt-Bridge-ETHA-ETHB.test.js @@ -187,9 +187,9 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B", function () { vaultAId ); - const gasFeesPaidFromCol = ethers.utils - .parseUnits(String(1800000 + 18000 * 12), 0) - .mul(gelatoGasPrice); + const gasFeesPaidFromCol = ethers.BigNumber.from(1850000).mul( + gelatoGasPrice + ); const pricedCollateral = ( await contracts.makerResolver.getMakerVaultCollateralBalance(vaultAId) @@ -238,7 +238,13 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B", function () { expect( await contracts.gelatoCore.providerFunds(wallets.providerAddress) - ).to.be.gt(providerBalanceBeforeExecution); + ).to.be.gt( + providerBalanceBeforeExecution.sub( + gasFeesPaidFromCol + .mul(await contracts.gelatoCore.totalSuccessShare()) + .div(100) + ) + ); // Estimated amount to borrowed token should be equal to the actual one read on compound contracts expect(debtOnMakerBefore).to.be.equal(debtOnMakerVaultB);