feat: provider payment at ca. break-even

This commit is contained in:
gitpusha 2020-11-03 19:57:25 +01:00 committed by Twin Fish
parent 10f62bbc9a
commit 1673e08d78
5 changed files with 23 additions and 11 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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",

View File

@ -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(

View File

@ -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);