mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Partially fixed repay tests
This commit is contained in:
parent
72e2102529
commit
13f6c264b3
|
@ -9,7 +9,7 @@ usePlugin('buidler-typechain');
|
|||
usePlugin('solidity-coverage');
|
||||
usePlugin('@nomiclabs/buidler-waffle');
|
||||
usePlugin('@nomiclabs/buidler-etherscan');
|
||||
//usePlugin('buidler-gas-reporter');
|
||||
usePlugin('buidler-gas-reporter');
|
||||
const DEFAULT_BLOCK_GAS_LIMIT = 10000000;
|
||||
const DEFAULT_GAS_PRICE = 10;
|
||||
const HARDFORK = 'istanbul';
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x9Dc554694756dC303a087e04bA6918C333Bc26a7",
|
||||
"address": "0x58F132FBB86E21545A4Bace3C19f1C05d86d7A22",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -15,7 +15,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0xAfC307938C1c0035942c141c31524504c89Aaa8B",
|
||||
"address": "0xa4bcDF64Cdd5451b6ac3743B414124A6299B65FF",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -25,7 +25,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x73DE1e0ab6A5C221258703bc546E0CAAcCc6EC87",
|
||||
"address": "0x5A0773Ff307Bf7C71a832dBB5312237fD3437f9F",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -53,7 +53,7 @@
|
|||
"address": "0x6642B57e4265BAD868C17Fc1d1F4F88DBBA04Aa8"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x65e0Cd5B8904A02f2e00BC6f58bf881998D54BDe"
|
||||
"address": "0x6642B57e4265BAD868C17Fc1d1F4F88DBBA04Aa8"
|
||||
}
|
||||
},
|
||||
"LendingPoolDataProvider": {
|
||||
|
@ -66,7 +66,7 @@
|
|||
"address": "0xD9273d497eDBC967F39d419461CfcF382a0A822e"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x5d12dDe3286D94E0d85F9D3B01B7099cfA0aBCf1"
|
||||
"address": "0xD9273d497eDBC967F39d419461CfcF382a0A822e"
|
||||
}
|
||||
},
|
||||
"PriceOracle": {
|
||||
|
@ -75,7 +75,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0xbeA90474c2F3C7c43bC7c36CaAf5272c927Af5a1",
|
||||
"address": "0x1750499D05Ed1674d822430FB960d5F6731fDf64",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -85,7 +85,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x19E42cA990cF697D3dda0e59131215C43bB6989F",
|
||||
"address": "0xEC1C93A9f6a9e18E97784c76aC52053587FcDB89",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -95,7 +95,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0xE30c3983E51bC9d6baE3E9437710a1459e21e81F",
|
||||
"address": "0x7B6C3e5486D9e6959441ab554A889099eed76290",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -105,7 +105,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0xDf69898e844197a24C658CcF9fD53dF15948dc8b",
|
||||
"address": "0xD83D2773a7873ae2b5f8Fb92097e20a8C64F691E",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -115,7 +115,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0xBe6d8642382C241c9B4B50c89574DbF3f4181E7D",
|
||||
"address": "0x626FdE749F9d499d3777320CAf29484B624ab84a",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -169,7 +169,7 @@
|
|||
"address": "0x2B681757d757fbB80cc51c6094cEF5eE75bF55aA"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0xAd49512dFBaD6fc13D67d3935283c0606812E962"
|
||||
"address": "0x2B681757d757fbB80cc51c6094cEF5eE75bF55aA"
|
||||
}
|
||||
},
|
||||
"WalletBalanceProvider": {
|
||||
|
@ -178,7 +178,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0xA29C2A7e59aa49C71aF084695337E3AA5e820758",
|
||||
"address": "0xDf73fC454FA018051D4a1509e63D11530A59DE10",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -188,7 +188,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0xbe66dC9DFEe580ED968403e35dF7b5159f873df8",
|
||||
"address": "0x7c2C195CD6D34B8F845992d380aADB2730bB9C6F",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -198,7 +198,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x93AfC6Df4bB8F62F2493B19e577f8382c0BA9EBC",
|
||||
"address": "0x8858eeB3DfffA017D4BCE9801D340D36Cf895CCf",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -208,7 +208,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x75Ded61646B5945BdDd0CD9a9Db7c8288DA6F810",
|
||||
"address": "0x0078371BDeDE8aAc7DeBfFf451B74c5EDB385Af7",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -218,7 +218,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0xdE7c40e675bF1aA45c18cCbaEb9662B16b0Ddf7E",
|
||||
"address": "0xf4e77E5Da47AC3125140c470c71cBca77B5c638c",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -228,7 +228,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0xDFbeeed692AA81E7f86E72F7ACbEA2A1C4d63544",
|
||||
"address": "0x3619DbE27d7c1e7E91aA738697Ae7Bc5FC3eACA5",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -238,7 +238,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x5191aA68c7dB195181Dd2441dBE23A48EA24b040",
|
||||
"address": "0x038B86d9d8FAFdd0a02ebd1A476432877b0107C8",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -248,7 +248,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x8F9422aa37215c8b3D1Ea1674138107F84D68F26",
|
||||
"address": "0x1A1FEe7EeD918BD762173e4dc5EfDB8a78C924A8",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -258,7 +258,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0xa89E20284Bd638F31b0011D0fC754Fc9d2fa73e3",
|
||||
"address": "0x500D1d6A4c7D8Ae28240b47c8FCde034D827fD5e",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -268,7 +268,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0xaA935993065F2dDB1d13623B1941C7AEE3A60F23",
|
||||
"address": "0xc4905364b78a742ccce7B890A89514061E47068D",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -278,7 +278,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x35A2624888e207e4B3434E9a9E250bF6Ee68FeA3",
|
||||
"address": "0xD6C850aeBFDC46D7F4c207e445cC0d6B0919BDBe",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -288,7 +288,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x1f569c307949a908A4b8Ff7453a88Ca0b8D8df13",
|
||||
"address": "0x8B5B7a6055E54a36fF574bbE40cf2eA68d5554b3",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -298,7 +298,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x4301cb254CCc126B9eb9cbBE030C6FDA2FA16D4a",
|
||||
"address": "0xEcc0a6dbC0bb4D51E4F84A315a9e5B0438cAD4f0",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -308,7 +308,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x0766c9592a8686CAB0081b4f35449462c6e82F11",
|
||||
"address": "0x20Ce94F404343aD2752A2D01b43fa407db9E0D00",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -318,7 +318,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0xaF6D34adD35E1A565be4539E4d1069c48A49C953",
|
||||
"address": "0x1d80315fac6aBd3EfeEbE97dEc44461ba7556160",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -328,7 +328,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x48bb3E35D2D6994374db457a6Bf61de2d9cC8E49",
|
||||
"address": "0x2D8553F9ddA85A9B3259F6Bf26911364B85556F5",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -338,7 +338,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x1E59BA56B1F61c3Ee946D8c7e2994B4A9b0cA45C",
|
||||
"address": "0x52d3b94181f8654db2530b0fEe1B19173f519C52",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -348,7 +348,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x53813198c75959DDB604462831d8989C29152164",
|
||||
"address": "0xd15468525c35BDBC1eD8F2e09A00F8a173437f2f",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -358,7 +358,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x0eD6115873ce6B807a03FE0df1f940387779b729",
|
||||
"address": "0x7e35Eaf7e8FBd7887ad538D4A38Df5BbD073814a",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -368,7 +368,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0xFFfDa24e7E3d5F89a24278f53d6f0F81B3bE0d6B",
|
||||
"address": "0x5bcb88A0d20426e451332eE6C4324b0e663c50E0",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -378,7 +378,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x5889354f21A1C8D8D2f82669d778f6Dab778B519",
|
||||
"address": "0x3521eF8AaB0323004A6dD8b03CE890F4Ea3A13f5",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -388,7 +388,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x09F7bF33B3F8922268B34103af3a8AF83148C9B1",
|
||||
"address": "0x53369fd4680FfE3DfF39Fc6DDa9CfbfD43daeA2E",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -398,7 +398,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x8f3966F7d53Fd5f12b701C8835e1e32541613869",
|
||||
"address": "0xB00cC45B4a7d3e1FEE684cFc4417998A1c183e6d",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -408,7 +408,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x9Dc554694756dC303a087e04bA6918C333Bc26a7",
|
||||
"address": "0x58F132FBB86E21545A4Bace3C19f1C05d86d7A22",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -417,7 +417,7 @@
|
|||
"address": "0x2cfcA5785261fbC88EFFDd46fCFc04c22525F9e4"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x9305d862ee95a899b83906Cd9CB666aC269E5f66"
|
||||
"address": "0x2cfcA5785261fbC88EFFDd46fCFc04c22525F9e4"
|
||||
}
|
||||
},
|
||||
"StableDebtToken": {
|
||||
|
@ -426,7 +426,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x02BB514187B830d6A2111197cd7D8cb60650B970",
|
||||
"address": "0xB660Fdd109a95718cB9d20E3A89EE6cE342aDcB6",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -436,13 +436,13 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x6774Ce86Abf5EBB22E9F45b5f55daCbB4170aD7f",
|
||||
"address": "0x830bceA96E56DBC1F8578f75fBaC0AF16B32A07d",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
"AToken": {
|
||||
"localhost": {
|
||||
"address": "0x007C1a44e85bDa8F562F916685A9DC8BdC6542bF",
|
||||
"address": "0xA0AB1cB92A4AF81f84dCd258155B5c25D247b54E",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"buidlerevm": {
|
||||
|
@ -466,7 +466,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0xEcb928A3c079a1696Aa5244779eEc3dE1717fACd",
|
||||
"address": "0xf784709d2317D872237C4bC22f867d1BAe2913AB",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -493,6 +493,9 @@
|
|||
"MockSwapAdapter": {
|
||||
"buidlerevm": {
|
||||
"address": "0xBEF0d4b9c089a5883741fC14cbA352055f35DDA2"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0xBEF0d4b9c089a5883741fC14cbA352055f35DDA2"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -125,7 +125,9 @@ makeSuite('LendingPool. repayWithCollateral() with liquidator', (testEnv: TestEn
|
|||
).minus(usdcUserDataBefore.currentVariableDebt);
|
||||
|
||||
const expectedStableDebtIncrease = calcExpectedStableDebtTokenBalance(
|
||||
usdcUserDataBefore,
|
||||
usdcUserDataBefore.principalStableDebt,
|
||||
usdcUserDataBefore.stableBorrowRate,
|
||||
usdcUserDataBefore.stableRateLastUpdated,
|
||||
new BigNumber(repayWithCollateralTimestamp)
|
||||
).minus(usdcUserDataBefore.currentStableDebt);
|
||||
|
||||
|
|
|
@ -319,19 +319,16 @@ export const calcExpectedReserveDataAfterBorrow = (
|
|||
expectedReserveData.variableBorrowIndex
|
||||
);
|
||||
|
||||
const totalStableDebtUntilTx = calcExpectedTotalStableDebt(
|
||||
reserveDataBeforeAction,
|
||||
txTimestamp
|
||||
);
|
||||
|
||||
expectedReserveData.averageStableBorrowRate = calcExpectedAverageStableBorrowRate(
|
||||
reserveDataBeforeAction.averageStableBorrowRate,
|
||||
totalStableDebtUntilTx,
|
||||
reserveDataBeforeAction.totalStableDebt,
|
||||
amountBorrowedBN,
|
||||
reserveDataBeforeAction.stableBorrowRate
|
||||
);
|
||||
|
||||
expectedReserveData.principalStableDebt = totalStableDebtUntilTx.plus(amountBorrowedBN);
|
||||
expectedReserveData.principalStableDebt = reserveDataBeforeAction.totalStableDebt.plus(
|
||||
amountBorrowedBN
|
||||
);
|
||||
|
||||
expectedReserveData.totalStableDebt = calcExpectedTotalStableDebt(
|
||||
{
|
||||
|
@ -385,7 +382,7 @@ export const calcExpectedReserveDataAfterBorrow = (
|
|||
expectedReserveData.variableBorrowIndex
|
||||
);
|
||||
|
||||
expectedReserveData.utilizationRate = calcExpectedUtilizationRate(
|
||||
const utilizationRateAfterTx = calcExpectedUtilizationRate(
|
||||
expectedReserveData.totalStableDebt,
|
||||
totalVariableDebtAfterTx,
|
||||
expectedReserveData.availableLiquidity
|
||||
|
@ -396,7 +393,7 @@ export const calcExpectedReserveDataAfterBorrow = (
|
|||
const rates = calcExpectedInterestRates(
|
||||
reserveDataBeforeAction.symbol,
|
||||
reserveDataBeforeAction.marketStableRate,
|
||||
expectedReserveData.utilizationRate,
|
||||
utilizationRateAfterTx,
|
||||
expectedReserveData.totalStableDebt,
|
||||
totalVariableDebtAfterTx,
|
||||
expectedReserveData.averageStableBorrowRate
|
||||
|
@ -411,11 +408,17 @@ export const calcExpectedReserveDataAfterBorrow = (
|
|||
expectedReserveData.totalVariableDebt = expectedReserveData.scaledVariableDebt.rayMul(
|
||||
calcExpectedReserveNormalizedDebt(expectedReserveData, currentTimestamp)
|
||||
);
|
||||
}
|
||||
|
||||
expectedReserveData.totalLiquidity = expectedReserveData.availableLiquidity
|
||||
.plus(expectedReserveData.totalStableDebt)
|
||||
.plus(expectedReserveData.totalVariableDebt);
|
||||
expectedReserveData.totalLiquidity = expectedReserveData.availableLiquidity
|
||||
.plus(expectedReserveData.totalStableDebt)
|
||||
.plus(expectedReserveData.totalVariableDebt);
|
||||
|
||||
expectedReserveData.utilizationRate = calcExpectedUtilizationRate(
|
||||
expectedReserveData.totalStableDebt,
|
||||
expectedReserveData.totalVariableDebt,
|
||||
expectedReserveData.totalLiquidity
|
||||
);
|
||||
}
|
||||
|
||||
return expectedReserveData;
|
||||
};
|
||||
|
@ -447,7 +450,7 @@ export const calcExpectedReserveDataAfterRepay = (
|
|||
txTimestamp
|
||||
);
|
||||
|
||||
//if amount repaid = MAX_UINT_AMOUNT, user is repaying everything
|
||||
//if amount repaid == MAX_UINT_AMOUNT, user is repaying everything
|
||||
if (amountRepaidBN.abs().eq(MAX_UINT_AMOUNT)) {
|
||||
if (borrowRateMode == RateMode.Stable) {
|
||||
amountRepaidBN = userStableDebt;
|
||||
|
@ -456,36 +459,40 @@ export const calcExpectedReserveDataAfterRepay = (
|
|||
}
|
||||
}
|
||||
|
||||
expectedReserveData.liquidityIndex = calcExpectedLiquidityIndex(
|
||||
reserveDataBeforeAction,
|
||||
txTimestamp
|
||||
);
|
||||
expectedReserveData.variableBorrowIndex = calcExpectedVariableBorrowIndex(
|
||||
reserveDataBeforeAction,
|
||||
txTimestamp
|
||||
);
|
||||
|
||||
if (borrowRateMode == RateMode.Stable) {
|
||||
const debtAccrued = userStableDebt.minus(userDataBeforeAction.principalStableDebt);
|
||||
|
||||
expectedReserveData.totalLiquidity = reserveDataBeforeAction.totalLiquidity.plus(debtAccrued);
|
||||
|
||||
expectedReserveData.totalStableDebt = reserveDataBeforeAction.totalStableDebt
|
||||
.minus(amountRepaidBN)
|
||||
.plus(debtAccrued);
|
||||
expectedReserveData.principalStableDebt = expectedReserveData.totalStableDebt = reserveDataBeforeAction.totalStableDebt.minus(
|
||||
amountRepaidBN
|
||||
);
|
||||
|
||||
expectedReserveData.averageStableBorrowRate = calcExpectedAverageStableBorrowRate(
|
||||
reserveDataBeforeAction.averageStableBorrowRate,
|
||||
reserveDataBeforeAction.totalStableDebt.plus(debtAccrued),
|
||||
reserveDataBeforeAction.totalStableDebt,
|
||||
amountRepaidBN.negated(),
|
||||
userDataBeforeAction.stableBorrowRate
|
||||
);
|
||||
expectedReserveData.scaledVariableDebt = reserveDataBeforeAction.scaledVariableDebt;
|
||||
expectedReserveData.totalVariableDebt = reserveDataBeforeAction.totalVariableDebt;
|
||||
} else {
|
||||
const variableDebtBefore = userDataBeforeAction.scaledVariableDebt.rayMul(
|
||||
reserveDataBeforeAction.variableBorrowIndex
|
||||
expectedReserveData.scaledVariableDebt = reserveDataBeforeAction.scaledVariableDebt.minus(
|
||||
amountRepaidBN.rayDiv(expectedReserveData.variableBorrowIndex)
|
||||
);
|
||||
|
||||
const debtAccrued = userVariableDebt.minus(variableDebtBefore);
|
||||
|
||||
expectedReserveData.totalLiquidity = reserveDataBeforeAction.totalLiquidity.plus(debtAccrued);
|
||||
|
||||
expectedReserveData.totalVariableDebt = reserveDataBeforeAction.totalVariableDebt
|
||||
.plus(debtAccrued)
|
||||
.minus(amountRepaidBN);
|
||||
expectedReserveData.totalVariableDebt = expectedReserveData.scaledVariableDebt.rayMul(
|
||||
expectedReserveData.variableBorrowIndex
|
||||
);
|
||||
|
||||
expectedReserveData.principalStableDebt = reserveDataBeforeAction.principalStableDebt;
|
||||
expectedReserveData.totalStableDebt = reserveDataBeforeAction.totalStableDebt;
|
||||
|
||||
expectedReserveData.averageStableBorrowRate = reserveDataBeforeAction.averageStableBorrowRate;
|
||||
}
|
||||
|
||||
|
@ -493,9 +500,9 @@ export const calcExpectedReserveDataAfterRepay = (
|
|||
amountRepaidBN
|
||||
);
|
||||
|
||||
expectedReserveData.availableLiquidity = reserveDataBeforeAction.availableLiquidity.plus(
|
||||
amountRepaidBN
|
||||
);
|
||||
expectedReserveData.totalLiquidity = expectedReserveData.availableLiquidity
|
||||
.plus(expectedReserveData.totalStableDebt)
|
||||
.plus(expectedReserveData.totalVariableDebt);
|
||||
|
||||
expectedReserveData.utilizationRate = calcExpectedUtilizationRate(
|
||||
expectedReserveData.totalStableDebt,
|
||||
|
@ -517,15 +524,6 @@ export const calcExpectedReserveDataAfterRepay = (
|
|||
|
||||
expectedReserveData.variableBorrowRate = rates[2];
|
||||
|
||||
expectedReserveData.liquidityIndex = calcExpectedLiquidityIndex(
|
||||
reserveDataBeforeAction,
|
||||
txTimestamp
|
||||
);
|
||||
expectedReserveData.variableBorrowIndex = calcExpectedVariableBorrowIndex(
|
||||
reserveDataBeforeAction,
|
||||
txTimestamp
|
||||
);
|
||||
|
||||
expectedReserveData.lastUpdateTimestamp = txTimestamp;
|
||||
|
||||
return expectedReserveData;
|
||||
|
@ -571,12 +569,6 @@ export const calcExpectedUserDataAfterBorrow = (
|
|||
);
|
||||
|
||||
expectedUserData.scaledVariableDebt = userDataBeforeAction.scaledVariableDebt;
|
||||
|
||||
expectedUserData.currentVariableDebt = calcExpectedVariableDebtTokenBalance(
|
||||
expectedDataAfterAction,
|
||||
expectedUserData,
|
||||
currentTimestamp
|
||||
);
|
||||
} else {
|
||||
expectedUserData.scaledVariableDebt = reserveDataBeforeAction.scaledVariableDebt.plus(
|
||||
amountBorrowedBN.rayDiv(expectedDataAfterAction.variableBorrowIndex)
|
||||
|
@ -587,8 +579,20 @@ export const calcExpectedUserDataAfterBorrow = (
|
|||
expectedUserData.stableBorrowRate = userDataBeforeAction.stableBorrowRate;
|
||||
|
||||
expectedUserData.stableRateLastUpdated = userDataBeforeAction.stableRateLastUpdated;
|
||||
|
||||
expectedUserData.currentStableDebt = calcExpectedStableDebtTokenBalance(
|
||||
userDataBeforeAction.principalStableDebt,
|
||||
userDataBeforeAction.stableBorrowRate,
|
||||
userDataBeforeAction.stableRateLastUpdated,
|
||||
currentTimestamp
|
||||
);
|
||||
}
|
||||
|
||||
expectedUserData.currentVariableDebt = calcExpectedVariableDebtTokenBalance(
|
||||
expectedDataAfterAction,
|
||||
expectedUserData,
|
||||
currentTimestamp
|
||||
);
|
||||
expectedUserData.liquidityRate = expectedDataAfterAction.liquidityRate;
|
||||
|
||||
expectedUserData.usageAsCollateralEnabled = userDataBeforeAction.usageAsCollateralEnabled;
|
||||
|
@ -620,32 +624,33 @@ export const calcExpectedUserDataAfterRepay = (
|
|||
): UserReserveData => {
|
||||
const expectedUserData = <UserReserveData>{};
|
||||
|
||||
const variableBorrowBalance = calcExpectedVariableDebtTokenBalance(
|
||||
const variableDebt = calcExpectedVariableDebtTokenBalance(
|
||||
reserveDataBeforeAction,
|
||||
userDataBeforeAction,
|
||||
currentTimestamp
|
||||
);
|
||||
|
||||
const stableBorrowBalance = calcExpectedStableDebtTokenBalance(
|
||||
const stableDebt = calcExpectedStableDebtTokenBalance(
|
||||
userDataBeforeAction.principalStableDebt,
|
||||
userDataBeforeAction.stableBorrowRate,
|
||||
userDataBeforeAction.stableRateLastUpdated,
|
||||
currentTimestamp
|
||||
);
|
||||
|
||||
if (new BigNumber(totalRepaid).abs().eq(MAX_UINT_AMOUNT)) {
|
||||
totalRepaid =
|
||||
|
||||
let totalRepaidBN = new BigNumber(totalRepaid);
|
||||
if (totalRepaidBN.abs().eq(MAX_UINT_AMOUNT)) {
|
||||
totalRepaidBN =
|
||||
rateMode == RateMode.Stable
|
||||
? stableBorrowBalance.toFixed(0)
|
||||
: variableBorrowBalance.toFixed();
|
||||
? stableDebt
|
||||
: variableDebt;
|
||||
}
|
||||
|
||||
if (rateMode == RateMode.Stable) {
|
||||
expectedUserData.principalVariableDebt = userDataBeforeAction.principalVariableDebt;
|
||||
expectedUserData.currentVariableDebt = variableBorrowBalance;
|
||||
expectedUserData.variableBorrowIndex = userDataBeforeAction.variableBorrowIndex;
|
||||
|
||||
expectedUserData.currentStableDebt = expectedUserData.principalStableDebt = stableBorrowBalance.minus(
|
||||
expectedUserData.scaledVariableDebt = userDataBeforeAction.scaledVariableDebt;
|
||||
expectedUserData.currentVariableDebt = userDataBeforeAction.currentVariableDebt;
|
||||
|
||||
expectedUserData.principalStableDebt = expectedUserData.currentStableDebt = stableDebt.minus(
|
||||
totalRepaid
|
||||
);
|
||||
|
||||
|
@ -659,21 +664,15 @@ export const calcExpectedUserDataAfterRepay = (
|
|||
expectedUserData.stableRateLastUpdated = txTimestamp;
|
||||
}
|
||||
} else {
|
||||
expectedUserData.currentStableDebt = stableBorrowBalance;
|
||||
expectedUserData.principalStableDebt = userDataBeforeAction.principalStableDebt;
|
||||
|
||||
expectedUserData.currentStableDebt = userDataBeforeAction.principalStableDebt;
|
||||
expectedUserData.principalStableDebt = stableDebt;
|
||||
expectedUserData.stableBorrowRate = userDataBeforeAction.stableBorrowRate;
|
||||
expectedUserData.stableRateLastUpdated = userDataBeforeAction.stableRateLastUpdated;
|
||||
|
||||
expectedUserData.scaledVariableDebt = userDataBeforeAction.scaledVariableDebt.minus(totalRepaidBN.rayDiv(expectedDataAfterAction.variableBorrowIndex));
|
||||
expectedUserData.currentVariableDebt = expectedUserData.scaledVariableDebt.rayMul(expectedDataAfterAction.variableBorrowIndex);
|
||||
|
||||
expectedUserData.currentVariableDebt = expectedUserData.principalVariableDebt = variableBorrowBalance.minus(
|
||||
totalRepaid
|
||||
);
|
||||
|
||||
if (expectedUserData.currentVariableDebt.eq('0')) {
|
||||
//user repaid everything
|
||||
expectedUserData.variableBorrowIndex = new BigNumber('0');
|
||||
} else {
|
||||
expectedUserData.variableBorrowIndex = expectedDataAfterAction.variableBorrowIndex;
|
||||
}
|
||||
}
|
||||
|
||||
expectedUserData.liquidityRate = expectedDataAfterAction.liquidityRate;
|
||||
|
@ -688,7 +687,7 @@ export const calcExpectedUserDataAfterRepay = (
|
|||
expectedUserData.scaledATokenBalance = userDataBeforeAction.scaledATokenBalance;
|
||||
|
||||
if (user === onBehalfOf) {
|
||||
expectedUserData.walletBalance = userDataBeforeAction.walletBalance.minus(totalRepaid);
|
||||
expectedUserData.walletBalance = userDataBeforeAction.walletBalance.minus(totalRepaidBN);
|
||||
} else {
|
||||
//wallet balance didn't change
|
||||
expectedUserData.walletBalance = userDataBeforeAction.walletBalance;
|
||||
|
|
|
@ -175,7 +175,9 @@ makeSuite('LendingPool liquidation - liquidator receiving the underlying asset',
|
|||
);
|
||||
|
||||
const stableDebtBeforeTx = calcExpectedStableDebtTokenBalance(
|
||||
userReserveDataBefore,
|
||||
userReserveDataBefore.principalStableDebt,
|
||||
userReserveDataBefore.stableBorrowRate,
|
||||
userReserveDataBefore.stableRateLastUpdated,
|
||||
txTimestamp
|
||||
);
|
||||
|
||||
|
|
|
@ -420,7 +420,9 @@ makeSuite('LendingPool. repayWithCollateral()', (testEnv: TestEnv) => {
|
|||
).minus(usdcUserDataBefore.currentVariableDebt);
|
||||
|
||||
const expectedStableDebtIncrease = calcExpectedStableDebtTokenBalance(
|
||||
usdcUserDataBefore,
|
||||
usdcUserDataBefore.principalStableDebt,
|
||||
usdcUserDataBefore.stableBorrowRate,
|
||||
usdcUserDataBefore.stableRateLastUpdated,
|
||||
new BigNumber(repayWithCollateralTimestamp)
|
||||
).minus(usdcUserDataBefore.currentStableDebt);
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import {executeStory} from './helpers/scenario-engine';
|
|||
|
||||
const scenarioFolder = './test/helpers/scenarios/';
|
||||
|
||||
const selectedScenarios: string[] = ['borrow-repay-variable.json'];
|
||||
const selectedScenarios: string[] = [];
|
||||
|
||||
fs.readdirSync(scenarioFolder).forEach((file) => {
|
||||
if (selectedScenarios.length > 0 && !selectedScenarios.includes(file)) return;
|
||||
|
|
Loading…
Reference in New Issue
Block a user