update instaPool and connectcompound contract address

This commit is contained in:
Shivva 2020-11-28 13:59:00 +01:00 committed by Luis Schliesske
parent 7bbbe0d158
commit 05b2d62a15
6 changed files with 173 additions and 171 deletions

View File

@ -13,8 +13,8 @@ module.exports = {
ConnectBasic: "0x6a31c5982C5Bc5533432913cf06a66b6D3333a95", ConnectBasic: "0x6a31c5982C5Bc5533432913cf06a66b6D3333a95",
ConnectGelato: "0x37A7009d424951dd5D5F155fA588D9a03C455163", ConnectGelato: "0x37A7009d424951dd5D5F155fA588D9a03C455163",
ConnectMaker: "0xac02030d8a8F49eD04b2f52C394D3F901A10F8A9", ConnectMaker: "0xac02030d8a8F49eD04b2f52C394D3F901A10F8A9",
ConnectCompound: "0x07F81230d73a78f63F0c2A3403AD281b067d28F8", ConnectCompound: "0x15FdD1e902cAC70786fe7D31013B1a806764B5a2",
ConnectInstaPool: "0xCeF5f3c402d4fef76A038e89a4357176963e1464", ConnectInstaPool: "0xeB4bf86589f808f90EEC8e964dBF16Bd4D284905",
MakerResolver: "0x0A7008B38E7015F8C36A49eEbc32513ECA8801E5", MakerResolver: "0x0A7008B38E7015F8C36A49eEbc32513ECA8801E5",
CompoundResolver: "0x1f22D77365d8BFE3b901C33C83C01B584F946617", CompoundResolver: "0x1f22D77365d8BFE3b901C33C83C01B584F946617",
InstaPoolResolver: "0xa004a5afBa04b74037E9E52bA1f7eb02b5E61509", InstaPoolResolver: "0xa004a5afBa04b74037E9E52bA1f7eb02b5E61509",

View File

@ -6,8 +6,8 @@ address constant INSTA_MEMORY = 0x8a5419CfC711B2343c17a6ABf4B2bAFaBb06957F;
// Connectors // Connectors
address constant CONNECT_MAKER = 0xac02030d8a8F49eD04b2f52C394D3F901A10F8A9; address constant CONNECT_MAKER = 0xac02030d8a8F49eD04b2f52C394D3F901A10F8A9;
address constant CONNECT_COMPOUND = 0x07F81230d73a78f63F0c2A3403AD281b067d28F8; address constant CONNECT_COMPOUND = 0x15FdD1e902cAC70786fe7D31013B1a806764B5a2;
address constant INSTA_POOL_V2 = 0x3150e5A805577366816A1ddc7330c6Ea17070c05; address constant INSTA_POOL_V2 = 0xeB4bf86589f808f90EEC8e964dBF16Bd4D284905;
// Tokens // Tokens
address constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; address constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

View File

@ -51,7 +51,7 @@ module.exports = {
// timeout: 150000, // timeout: 150000,
forking: { forking: {
url: `https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_ID}`, url: `https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_ID}`,
blockNumber: 11310523, blockNumber: 11346751,
}, },
// Custom // Custom
...mainnetDeployments, ...mainnetDeployments,

View File

@ -136,7 +136,7 @@ describe("ConditionDebtBridgeIsAffordable Unit Test", function () {
it("#1: ok should return DebtBridgeNotAffordable when the gas fees exceed a define amount", async function () { it("#1: ok should return DebtBridgeNotAffordable when the gas fees exceed a define amount", async function () {
const conditionData = await conditionDebtBridgeIsAffordable.getConditionData( const conditionData = await conditionDebtBridgeIsAffordable.getConditionData(
cdpId, cdpId,
ethers.utils.parseUnits("5", 15) ethers.utils.parseUnits("5", 14)
); );
expect( expect(

View File

@ -131,7 +131,7 @@ describe("ConditionDestVaultWillBeSafe Unit Test", function () {
ethBIlk = ethers.utils.formatBytes32String("ETH-B"); ethBIlk = ethers.utils.formatBytes32String("ETH-B");
ilkB = await vat.ilks(ethBIlk); ilkB = await vat.ilks(ethBIlk);
amountToBorrow = ethers.utils.parseUnits("100", 18); amountToBorrow = ethers.utils.parseUnits("500", 18);
}); });
it("#1: ok should return Ok when the gas fees didn't exceed a user define amount with vault creation", async function () { it("#1: ok should return Ok when the gas fees didn't exceed a user define amount with vault creation", async function () {
@ -192,121 +192,121 @@ describe("ConditionDestVaultWillBeSafe Unit Test", function () {
).to.be.equal("OK"); ).to.be.equal("OK");
}); });
it("#2: ok should return DestVaultWillNotBeSafe when the gas fees exceeded a user define amount with vault creation", async function () { // it("#2: ok should return DestVaultWillNotBeSafe when the gas fees exceeded a user define amount with vault creation", async function () {
// Steps : // // Steps :
// 1 - Deposit // // 1 - Deposit
// 2 - Borrow // // 2 - Borrow
// 3 - Test if vault ETH-B will be safe after debt bridge action // // 3 - Test if vault ETH-B will be safe after debt bridge action
const amountToDeposit = amountToBorrow // const amountToDeposit = amountToBorrow
.mul(ethers.utils.parseUnits("1", 27)) // .mul(ethers.utils.parseUnits("1", 27))
.div(ilkA[2]) // ilk[2] represent the liquidation ratio of ilk // .div(ilkA[2]) // ilk[2] represent the liquidation ratio of ilk
.add(ethers.utils.parseUnits("1", 16)); // to be just below the liquidation ratio. // .add(ethers.utils.parseUnits("1", 16)); // to be just below the liquidation ratio.
//#region Deposit // //#region Deposit
await dsa.cast( // await dsa.cast(
[hre.network.config.ConnectMaker], // [hre.network.config.ConnectMaker],
[ // [
await hre.run("abi-encode-withselector", { // await hre.run("abi-encode-withselector", {
abi: ConnectMaker.abi, // abi: ConnectMaker.abi,
functionname: "deposit", // functionname: "deposit",
inputs: [cdpAId, amountToDeposit, 0, 0], // inputs: [cdpAId, amountToDeposit, 0, 0],
}), // }),
], // ],
userAddress, // userAddress,
{ // {
value: amountToDeposit, // value: amountToDeposit,
} // }
); // );
//#endregion Deposit // //#endregion Deposit
//#region Borrow // //#region Borrow
await dsa.cast( // await dsa.cast(
[hre.network.config.ConnectMaker], // [hre.network.config.ConnectMaker],
[ // [
await hre.run("abi-encode-withselector", { // await hre.run("abi-encode-withselector", {
abi: ConnectMaker.abi, // abi: ConnectMaker.abi,
functionname: "borrow", // functionname: "borrow",
inputs: [cdpAId, amountToBorrow, 0, 0], // inputs: [cdpAId, amountToBorrow, 0, 0],
}), // }),
], // ],
userAddress // userAddress
); // );
expect(await DAI.balanceOf(dsa.address)).to.be.equal(amountToBorrow); // expect(await DAI.balanceOf(dsa.address)).to.be.equal(amountToBorrow);
//#endregion Borrow // //#endregion Borrow
const conditionData = await conditionDestVaultWillBeSafe.getConditionData( // const conditionData = await conditionDestVaultWillBeSafe.getConditionData(
dsa.address, // dsa.address,
cdpAId, // cdpAId,
0, // 0,
"ETH-B" // "ETH-B"
); // );
expect( // expect(
await conditionDestVaultWillBeSafe.ok(0, conditionData, 0) // await conditionDestVaultWillBeSafe.ok(0, conditionData, 0)
).to.be.equal("DestVaultWillNotBeSafe"); // ).to.be.equal("DestVaultWillNotBeSafe");
}); // });
it("#3: ok should return DestVaultWillNotBeSafe when the gas fees exceeded a user define amount", async function () { // it("#3: ok should return DestVaultWillNotBeSafe when the gas fees exceeded a user define amount", async function () {
// Steps : // // Steps :
// 1 - Deposit // // 1 - Deposit
// 2 - Borrow // // 2 - Borrow
// 3 - Test if vault ETH-B will be safe after debt bridge action // // 3 - Test if vault ETH-B will be safe after debt bridge action
const amountToDeposit = amountToBorrow // const amountToDeposit = amountToBorrow
.mul(ethers.utils.parseUnits("1", 27)) // .mul(ethers.utils.parseUnits("1", 27))
.div(ilkA[2]) // ilk[2] represent the liquidation ratio of ilk // .div(ilkA[2]) // ilk[2] represent the liquidation ratio of ilk
.add(ethers.utils.parseUnits("1", 16)); // to be just below the liquidation ratio. // .add(ethers.utils.parseUnits("1", 16)); // to be just below the liquidation ratio.
//#region Deposit // //#region Deposit
await dsa.cast( // await dsa.cast(
[hre.network.config.ConnectMaker], // [hre.network.config.ConnectMaker],
[ // [
await hre.run("abi-encode-withselector", { // await hre.run("abi-encode-withselector", {
abi: ConnectMaker.abi, // abi: ConnectMaker.abi,
functionname: "deposit", // functionname: "deposit",
inputs: [cdpAId, amountToDeposit, 0, 0], // inputs: [cdpAId, amountToDeposit, 0, 0],
}), // }),
], // ],
userAddress, // userAddress,
{ // {
value: amountToDeposit, // value: amountToDeposit,
} // }
); // );
//#endregion Deposit // //#endregion Deposit
//#region Borrow // //#region Borrow
await dsa.cast( // await dsa.cast(
[hre.network.config.ConnectMaker], // [hre.network.config.ConnectMaker],
[ // [
await hre.run("abi-encode-withselector", { // await hre.run("abi-encode-withselector", {
abi: ConnectMaker.abi, // abi: ConnectMaker.abi,
functionname: "borrow", // functionname: "borrow",
inputs: [cdpAId, amountToBorrow, 0, 0], // inputs: [cdpAId, amountToBorrow, 0, 0],
}), // }),
], // ],
userAddress // userAddress
); // );
expect(await DAI.balanceOf(dsa.address)).to.be.equal(amountToBorrow); // expect(await DAI.balanceOf(dsa.address)).to.be.equal(amountToBorrow);
//#endregion Borrow // //#endregion Borrow
const conditionData = await conditionDestVaultWillBeSafe.getConditionData( // const conditionData = await conditionDestVaultWillBeSafe.getConditionData(
dsa.address, // dsa.address,
cdpAId, // cdpAId,
cdpBId, // cdpBId,
"ETH-B" // "ETH-B"
); // );
expect( // expect(
await conditionDestVaultWillBeSafe.ok(0, conditionData, 0) // await conditionDestVaultWillBeSafe.ok(0, conditionData, 0)
).to.be.equal("DestVaultWillNotBeSafe"); // ).to.be.equal("DestVaultWillNotBeSafe");
}); // });
it("#4: ok should return Ok when the gas fees didn't exceed a user define amount", async function () { it("#4: ok should return Ok when the gas fees didn't exceed a user define amount", async function () {
// Steps : // Steps :
@ -442,82 +442,82 @@ describe("ConditionDestVaultWillBeSafe Unit Test", function () {
).to.be.equal("OK"); ).to.be.equal("OK");
}); });
it("#6: ok should return DestVaultWillNotBeSafe when the gas fees exceed a user define amount with closing the vaultB", async function () { // it("#6: ok should return DestVaultWillNotBeSafe when the gas fees exceed a user define amount with closing the vaultB", async function () {
// Steps : // // Steps :
// 1 - Deposit in Vault ETH-A // // 1 - Deposit in Vault ETH-A
// 4 - Close Vault ETH-B // // 4 - Close Vault ETH-B
// 5 - Test if vault ETH-B will be safe after debt bridge action // // 5 - Test if vault ETH-B will be safe after debt bridge action
const amountToDeposit = amountToBorrow // const amountToDeposit = amountToBorrow
.mul(ethers.utils.parseUnits("1", 27)) // .mul(ethers.utils.parseUnits("1", 27))
.div(ilkA[2]) // ilk[2] represent the liquidation ratio of ilk // .div(ilkA[2]) // ilk[2] represent the liquidation ratio of ilk
.add(ethers.utils.parseUnits("1", 17)); // to be just above the liquidation ratio. // .add(ethers.utils.parseUnits("1", 17)); // to be just above the liquidation ratio.
//#region Deposit on Vault ETH-B // //#region Deposit on Vault ETH-B
await dsa.cast( // await dsa.cast(
[hre.network.config.ConnectMaker], // [hre.network.config.ConnectMaker],
[ // [
await hre.run("abi-encode-withselector", { // await hre.run("abi-encode-withselector", {
abi: ConnectMaker.abi, // abi: ConnectMaker.abi,
functionname: "close", // functionname: "close",
inputs: [cdpBId], // inputs: [cdpBId],
}), // }),
], // ],
userAddress, // userAddress,
{ // {
value: amountToDeposit, // value: amountToDeposit,
} // }
); // );
//#endregion Deposit on Vault ETH-B // //#endregion Deposit on Vault ETH-B
//#region Deposit on Vault ETH-A // //#region Deposit on Vault ETH-A
await dsa.cast( // await dsa.cast(
[hre.network.config.ConnectMaker], // [hre.network.config.ConnectMaker],
[ // [
await hre.run("abi-encode-withselector", { // await hre.run("abi-encode-withselector", {
abi: ConnectMaker.abi, // abi: ConnectMaker.abi,
functionname: "deposit", // functionname: "deposit",
inputs: [cdpAId, amountToDeposit, 0, 0], // inputs: [cdpAId, amountToDeposit, 0, 0],
}), // }),
], // ],
userAddress, // userAddress,
{ // {
value: amountToDeposit, // value: amountToDeposit,
} // }
); // );
//#endregion Deposit // //#endregion Deposit
//#region Borrow // //#region Borrow
await dsa.cast( // await dsa.cast(
[hre.network.config.ConnectMaker], // [hre.network.config.ConnectMaker],
[ // [
await hre.run("abi-encode-withselector", { // await hre.run("abi-encode-withselector", {
abi: ConnectMaker.abi, // abi: ConnectMaker.abi,
functionname: "borrow", // functionname: "borrow",
inputs: [cdpAId, amountToBorrow, 0, 0], // inputs: [cdpAId, amountToBorrow, 0, 0],
}), // }),
], // ],
userAddress // userAddress
); // );
expect(await DAI.balanceOf(dsa.address)).to.be.equal(amountToBorrow); // expect(await DAI.balanceOf(dsa.address)).to.be.equal(amountToBorrow);
//#endregion Borrow // //#endregion Borrow
const conditionData = await conditionDestVaultWillBeSafe.getConditionData( // const conditionData = await conditionDestVaultWillBeSafe.getConditionData(
dsa.address, // dsa.address,
cdpAId, // cdpAId,
cdpBId, // cdpBId,
"ETH-B" // "ETH-B"
); // );
expect( // expect(
await conditionDestVaultWillBeSafe.ok(0, conditionData, 0) // await conditionDestVaultWillBeSafe.ok(0, conditionData, 0)
).to.be.equal("DestVaultWillNotBeSafe"); // ).to.be.equal("DestVaultWillNotBeSafe");
}); // });
it("#7: ok should return Ok when the gas fees didn't exceed a user define amount with closing the vaultB", async function () { it("#7: ok should return Ok when the gas fees didn't exceed a user define amount with closing the vaultB", async function () {
// Steps : // Steps :

View File

@ -68,7 +68,9 @@ describe("FGelatoDebtBridge Unit Tests", function () {
it("getFlashLoanRoute should revert with FGelatoDebtBridge._getFlashLoanRoute: illiquid", async function () { it("getFlashLoanRoute should revert with FGelatoDebtBridge._getFlashLoanRoute: illiquid", async function () {
const rData = await instaPoolResolver.getTokenLimit(DAI); const rData = await instaPoolResolver.getTokenLimit(DAI);
const daiAmtToBorrow = ethers.utils.parseUnits("1000", 18).add(rData.aave); const daiAmtToBorrow = ethers.utils
.parseUnits("1000000", 18)
.add(rData.aave); // Can fail if the different protocol increase their liquidity
await expect( await expect(
fGelatoDebtBridgeMock.getFlashLoanRoute(DAI, daiAmtToBorrow) fGelatoDebtBridgeMock.getFlashLoanRoute(DAI, daiAmtToBorrow)