diff --git a/docs/test-report/mochawesome.html b/docs/test-report/mochawesome.html
index bbcd8e15..491fb0b4 100644
--- a/docs/test-report/mochawesome.html
+++ b/docs/test-report/mochawesome.html
@@ -1,2 +1,2 @@
-
Kresko Protocol Hardhat Test Report
\ No newline at end of file
+Kresko Protocol Hardhat Test Report
\ No newline at end of file
diff --git a/docs/test-report/mochawesome.json b/docs/test-report/mochawesome.json
index a190bede..5baeebf1 100644
--- a/docs/test-report/mochawesome.json
+++ b/docs/test-report/mochawesome.json
@@ -1,16 +1,16 @@
{
"stats": {
- "suites": 90,
- "tests": 275,
- "passes": 253,
- "pending": 22,
+ "suites": 2,
+ "tests": 1,
+ "passes": 1,
+ "pending": 0,
"failures": 0,
- "start": "2023-11-18T21:56:10.700Z",
- "end": "2023-11-18T21:58:20.093Z",
- "duration": 129393,
- "testsRegistered": 275,
+ "start": "2023-11-19T00:20:47.919Z",
+ "end": "2023-11-19T00:20:52.470Z",
+ "duration": 4551,
+ "testsRegistered": 1,
"passPercent": 100,
- "pendingPercent": 8,
+ "pendingPercent": 0,
"other": 0,
"hasOther": false,
"skipped": 0,
@@ -18,35 +18,35 @@
},
"results": [
{
- "uuid": "c57a933e-8bae-4c0a-9f59-98a7de64212d",
+ "uuid": "6e2384a7-af34-424e-88da-5c7d52b789bc",
"title": "",
- "fullFile": "",
- "file": "",
+ "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/scdp/00-scdp.ts",
+ "file": "/src/test/scdp/00-scdp.ts",
"beforeHooks": [],
"afterHooks": [],
"tests": [],
"suites": [
{
- "uuid": "d69e0ac0-12fa-4f9a-a143-603063be2ce5",
- "title": "Asset Amounts & Values",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/asset-values/00-asset-values.ts",
- "file": "/src/test/asset-values/00-asset-values.ts",
+ "uuid": "80ce1fbf-0725-4612-94fa-867e69e0ea67",
+ "title": "SCDP",
+ "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/scdp/00-scdp.ts",
+ "file": "/src/test/scdp/00-scdp.ts",
"beforeHooks": [
{
- "title": "\"before each\" hook in \"Asset Amounts & Values\"",
- "fullTitle": "Asset Amounts & Values \"before each\" hook in \"Asset Amounts & Values\"",
+ "title": "\"before each\" hook in \"SCDP\"",
+ "fullTitle": "SCDP \"before each\" hook in \"SCDP\"",
"timedOut": false,
- "duration": 18,
+ "duration": 1642,
"state": null,
"speed": null,
"pass": false,
"fail": false,
"pending": false,
"context": null,
- "code": "f = await (0, _fixtures.assetValuesFixture)();\nf.user = hre.users.userEight;\nUser = (0, _redstone.wrapKresko)(hre.Diamond, f.user);",
+ "code": "f = await (0, _fixtures.scdpFixture)();\nawait f.reset();",
"err": {},
- "uuid": "b9ac9a81-1bb4-46c8-84eb-87b1e772aa53",
- "parentUUID": "d69e0ac0-12fa-4f9a-a143-603063be2ce5",
+ "uuid": "d3e1cd41-bc53-4b21-ae7f-e0b6f2e20f02",
+ "parentUUID": "80ce1fbf-0725-4612-94fa-867e69e0ea67",
"isHook": true,
"skipped": false
}
@@ -55,7244 +55,37 @@
"tests": [],
"suites": [
{
- "uuid": "6dde25b3-1bdd-46ec-b888-3756b43c651a",
- "title": "#Collateral Deposit Values",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/asset-values/00-asset-values.ts",
- "file": "/src/test/asset-values/00-asset-values.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "should return the correct deposit value with 18 decimals",
- "fullTitle": "Asset Amounts & Values #Collateral Deposit Values should return the correct deposit value with 18 decimals",
- "timedOut": false,
- "duration": 109,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const depositAmount = (0, _values.toBig)(10);\nconst expectedDepositValue = (0, _values.toBig)(50, f.oracleDecimals) // cfactor = 0.5, collateralPrice = 10, depositAmount = 10\n;\nawait User.depositCollateral(f.user.address, f.CollateralAsset.address, depositAmount);\nconst depositValue = await hre.Diamond.getAccountTotalCollateralValue(f.user.address);\n(0, _chai.expect)(depositValue).to.equal(expectedDepositValue);",
- "err": {},
- "uuid": "754018b3-f0c3-493b-aede-27a4ba700169",
- "parentUUID": "6dde25b3-1bdd-46ec-b888-3756b43c651a",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should return the correct deposit value with less than 18 decimals",
- "fullTitle": "Asset Amounts & Values #Collateral Deposit Values should return the correct deposit value with less than 18 decimals",
- "timedOut": false,
- "duration": 106,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const depositAmount = (0, _values.toBig)(10, 8);\nconst expectedDepositValue = (0, _values.toBig)(50, f.oracleDecimals) // cfactor = 0.5, collateralPrice = 10, depositAmount = 10\n;\nawait User.depositCollateral(f.user.address, f.CollateralAsset8Dec.address, depositAmount);\nconst depositValue = await hre.Diamond.getAccountTotalCollateralValue(f.user.address);\n(0, _chai.expect)(depositValue).to.equal(expectedDepositValue);",
- "err": {},
- "uuid": "859e76f4-2f77-4d5e-bf59-486a579b3303",
- "parentUUID": "6dde25b3-1bdd-46ec-b888-3756b43c651a",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should return the correct deposit value with over 18 decimals",
- "fullTitle": "Asset Amounts & Values #Collateral Deposit Values should return the correct deposit value with over 18 decimals",
- "timedOut": false,
- "duration": 106,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const depositAmount = (0, _values.toBig)(10, 21);\nconst expectedDepositValue = (0, _values.toBig)(50, f.oracleDecimals) // cfactor = 0.5, collateralPrice = 10, depositAmount = 10\n;\nawait User.depositCollateral(f.user.address, f.CollateralAsset21Dec.address, depositAmount);\nconst depositValue = await hre.Diamond.getAccountTotalCollateralValue(f.user.address);\n(0, _chai.expect)(depositValue).to.equal(expectedDepositValue);",
- "err": {},
- "uuid": "6b38fa99-3ace-4986-8bbd-0a2635e49a73",
- "parentUUID": "6dde25b3-1bdd-46ec-b888-3756b43c651a",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should return the correct deposit value combination of different decimals",
- "fullTitle": "Asset Amounts & Values #Collateral Deposit Values should return the correct deposit value combination of different decimals",
- "timedOut": false,
- "duration": 239,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await User.depositCollateral(f.user.address, f.CollateralAsset.address, (0, _values.toBig)(10));\nawait User.depositCollateral(f.user.address, f.CollateralAsset8Dec.address, (0, _values.toBig)(10, 8));\nawait User.depositCollateral(f.user.address, f.CollateralAsset21Dec.address, (0, _values.toBig)(10, 21));\nconst expectedDepositValue = (0, _values.toBig)(150, f.oracleDecimals) // cfactor = 0.5, collateralPrice = 10, depositAmount = 30\n;\nconst depositValue = await hre.Diamond.getAccountTotalCollateralValue(f.user.address);\n(0, _chai.expect)(depositValue).to.equal(expectedDepositValue);",
- "err": {},
- "uuid": "70b0706d-3fcc-4533-8f62-0a66b8ec9b7a",
- "parentUUID": "6dde25b3-1bdd-46ec-b888-3756b43c651a",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "754018b3-f0c3-493b-aede-27a4ba700169",
- "859e76f4-2f77-4d5e-bf59-486a579b3303",
- "6b38fa99-3ace-4986-8bbd-0a2635e49a73",
- "70b0706d-3fcc-4533-8f62-0a66b8ec9b7a"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 560,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "70ea6629-c254-40de-8dbc-e6c9c61a9a9f",
- "title": "#Collateral Deposit Amount",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/asset-values/00-asset-values.ts",
- "file": "/src/test/asset-values/00-asset-values.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "should return the correct deposit amount with 18 decimals",
- "fullTitle": "Asset Amounts & Values #Collateral Deposit Amount should return the correct deposit amount with 18 decimals",
- "timedOut": false,
- "duration": 145,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const depositAmount = (0, _values.toBig)(10);\nawait User.depositCollateral(f.user.address, f.CollateralAsset.address, depositAmount);\nconst withdrawIndex = await _optimizations.default.getAccountDepositIndex(f.user.address, f.CollateralAsset.address);\nconst deposits = await hre.Diamond.getAccountCollateralAmount(f.user.address, f.CollateralAsset.address);\n(0, _chai.expect)(deposits).to.equal(depositAmount);\nawait User.withdrawCollateral(f.user.address, f.CollateralAsset.address, depositAmount, withdrawIndex);\nconst balance = await f.CollateralAsset.balanceOf(f.user.address);\n(0, _chai.expect)(balance).to.equal((0, _values.toBig)(f.startingBalance));",
- "err": {},
- "uuid": "9cc53f93-7d88-4bf8-882c-650a9e3fbfbe",
- "parentUUID": "70ea6629-c254-40de-8dbc-e6c9c61a9a9f",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should return the correct deposit amount with less than 18 decimals",
- "fullTitle": "Asset Amounts & Values #Collateral Deposit Amount should return the correct deposit amount with less than 18 decimals",
- "timedOut": false,
- "duration": 109,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const depositAmount = (0, _values.toBig)(10, 8);\nawait User.depositCollateral(f.user.address, f.CollateralAsset8Dec.address, depositAmount);\nconst withdrawIndex = await _optimizations.default.getAccountDepositIndex(f.user.address, f.CollateralAsset8Dec.address);\nconst deposits = await hre.Diamond.getAccountCollateralAmount(f.user.address, f.CollateralAsset8Dec.address);\n(0, _chai.expect)(deposits).to.equal(depositAmount);\nawait User.withdrawCollateral(f.user.address, f.CollateralAsset8Dec.address, depositAmount, withdrawIndex);\nconst balance = await f.CollateralAsset8Dec.balanceOf(f.user.address);\n(0, _chai.expect)(balance).to.equal((0, _values.toBig)(f.startingBalance, 8));",
- "err": {},
- "uuid": "fa7d8cc1-de19-4629-8e4f-d5f2f3d5a969",
- "parentUUID": "70ea6629-c254-40de-8dbc-e6c9c61a9a9f",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should return the correct deposit value with over 18 decimals",
- "fullTitle": "Asset Amounts & Values #Collateral Deposit Amount should return the correct deposit value with over 18 decimals",
- "timedOut": false,
- "duration": 140,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const depositAmount = (0, _values.toBig)(10, 21);\nawait User.depositCollateral(f.user.address, f.CollateralAsset21Dec.address, depositAmount);\nconst withdrawIndex = await _optimizations.default.getAccountDepositIndex(f.user.address, f.CollateralAsset21Dec.address);\nconst deposits = await hre.Diamond.getAccountCollateralAmount(f.user.address, f.CollateralAsset21Dec.address);\n(0, _chai.expect)(deposits).to.equal(depositAmount);\nawait User.withdrawCollateral(f.user.address, f.CollateralAsset21Dec.address, depositAmount, withdrawIndex);\nconst balance = await f.CollateralAsset21Dec.balanceOf(f.user.address);\n(0, _chai.expect)(balance).to.equal((0, _values.toBig)(f.startingBalance, 21));",
- "err": {},
- "uuid": "cb950bc8-1451-48fb-bb35-3213b897a094",
- "parentUUID": "70ea6629-c254-40de-8dbc-e6c9c61a9a9f",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "9cc53f93-7d88-4bf8-882c-650a9e3fbfbe",
- "fa7d8cc1-de19-4629-8e4f-d5f2f3d5a969",
- "cb950bc8-1451-48fb-bb35-3213b897a094"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 394,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "68d58545-5c4e-4266-a47c-7d0929b5e5b9",
- "title": "#Kresko Asset Debt Values",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/asset-values/00-asset-values.ts",
- "file": "/src/test/asset-values/00-asset-values.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "should return the correct debt value (+CR) with 18 decimal collateral",
- "fullTitle": "Asset Amounts & Values #Kresko Asset Debt Values should return the correct debt value (+CR) with 18 decimal collateral",
- "timedOut": false,
- "duration": 601,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const depositAmount = (0, _values.toBig)(10);\nawait User.depositCollateral(f.user.address, f.CollateralAsset.address, depositAmount);\nconst mintAmount = (0, _values.toBig)(1);\nconst expectedMintValue = (0, _values.toBig)(20, f.oracleDecimals) // kFactor = 2, krAssetPrice = 10, mintAmount = 1, openFee = 0.1\n;\nawait User.mintKreskoAsset(f.user.address, f.KreskoAsset.address, mintAmount);\nconst expectedDepositValue = (0, _values.toBig)(49.5, f.oracleDecimals) // cfactor = 0.5, collateralPrice = 10, depositAmount = 10, openFee = 0.1\n;\nconst depositValue = await hre.Diamond.getAccountTotalCollateralValue(f.user.address);\n(0, _chai.expect)(depositValue).to.equal(expectedDepositValue);\nconst mintValue = await hre.Diamond.getAccountTotalDebtValue(f.user.address);\n(0, _chai.expect)(mintValue).to.equal(expectedMintValue);\nconst assetValue = await hre.Diamond.getValue(f.KreskoAsset.address, mintAmount);\nconst kFactor = (await hre.Diamond.getAsset(f.KreskoAsset.address)).kFactor;\n(0, _chai.expect)(assetValue).to.equal(expectedMintValue.percentDiv(kFactor));\nconst collateralRatio = await hre.Diamond.getAccountCollateralRatio(f.user.address);\n(0, _chai.expect)(collateralRatio).to.equal(expectedDepositValue.percentDiv(expectedMintValue)) // 2.475\n;",
- "err": {},
- "uuid": "c3b461ba-3daa-4d82-8964-42380b53a596",
- "parentUUID": "68d58545-5c4e-4266-a47c-7d0929b5e5b9",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should return the correct debt value (+CR) with less than 18 decimal collateral",
- "fullTitle": "Asset Amounts & Values #Kresko Asset Debt Values should return the correct debt value (+CR) with less than 18 decimal collateral",
- "timedOut": false,
- "duration": 596,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const depositAmount = (0, _values.toBig)(10, 8);\nawait User.depositCollateral(f.user.address, f.CollateralAsset8Dec.address, depositAmount);\nconst mintAmount = (0, _values.toBig)(1);\nconst expectedMintValue = (0, _values.toBig)(20, f.oracleDecimals) // kFactor = 2, krAssetPrice = 10, mintAmount = 1, openFee = 0.1\n;\nawait User.mintKreskoAsset(f.user.address, f.KreskoAsset.address, mintAmount);\nconst expectedDepositValue = (0, _values.toBig)(49.5, f.oracleDecimals) // cfactor = 0.5, collateralPrice = 10, depositAmount = 10, openFee = 0.1\n;\nconst depositValue = await hre.Diamond.getAccountTotalCollateralValue(f.user.address);\n(0, _chai.expect)(depositValue).to.equal(expectedDepositValue);\nconst mintValue = await hre.Diamond.getAccountTotalDebtValue(f.user.address);\n(0, _chai.expect)(mintValue).to.equal(expectedMintValue);\nconst assetValue = await hre.Diamond.getValue(f.KreskoAsset.address, mintAmount);\nconst kFactor = (await hre.Diamond.getAsset(f.KreskoAsset.address)).kFactor;\n(0, _chai.expect)(assetValue).to.equal(expectedMintValue.percentDiv(kFactor));\nconst collateralRatio = await hre.Diamond.getAccountCollateralRatio(f.user.address);\n(0, _chai.expect)(collateralRatio).to.equal(expectedDepositValue.percentDiv(expectedMintValue)) // 2.475\n;",
- "err": {},
- "uuid": "5b3f2a7c-c15d-4135-938c-2d345699a461",
- "parentUUID": "68d58545-5c4e-4266-a47c-7d0929b5e5b9",
- "isHook": false,
- "skipped": false
- },
+ "uuid": "02070f8e-45c2-4cd2-a957-b1c39ec1adad",
+ "title": "#Swap",
+ "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/scdp/00-scdp.ts",
+ "file": "/src/test/scdp/00-scdp.ts",
+ "beforeHooks": [
{
- "title": "should return the correct debt value (+CR) with more than 18 decimal collateral",
- "fullTitle": "Asset Amounts & Values #Kresko Asset Debt Values should return the correct debt value (+CR) with more than 18 decimal collateral",
+ "title": "\"before each\" hook in \"#Swap\"",
+ "fullTitle": "SCDP #Swap \"before each\" hook in \"#Swap\"",
"timedOut": false,
- "duration": 592,
- "state": "passed",
- "speed": "slow",
- "pass": true,
+ "duration": 45,
+ "state": null,
+ "speed": null,
+ "pass": false,
"fail": false,
"pending": false,
"context": null,
- "code": "const depositAmount = (0, _values.toBig)(10, 21);\nawait User.depositCollateral(f.user.address, f.CollateralAsset21Dec.address, depositAmount);\nconst mintAmount = (0, _values.toBig)(1);\nconst expectedMintValue = (0, _values.toBig)(20, f.oracleDecimals) // kFactor = 2, krAssetPrice = 10, mintAmount = 1, openFee = 0.1\n;\nawait User.mintKreskoAsset(f.user.address, f.KreskoAsset.address, mintAmount);\nconst expectedDepositValue = (0, _values.toBig)(49.5, f.oracleDecimals) // cfactor = 0.5, collateralPrice = 10, depositAmount = 10, openFee = 0.1\n;\nconst depositValue = await hre.Diamond.getAccountTotalCollateralValue(f.user.address);\n(0, _chai.expect)(depositValue).to.equal(expectedDepositValue);\nconst mintValue = await hre.Diamond.getAccountTotalDebtValue(f.user.address);\n(0, _chai.expect)(mintValue).to.equal(expectedMintValue);\nconst assetValue = await hre.Diamond.getValue(f.KreskoAsset.address, mintAmount);\nconst kFactor = (await hre.Diamond.getAsset(f.KreskoAsset.address)).kFactor;\n(0, _chai.expect)(assetValue).to.equal(expectedMintValue.percentDiv(kFactor));\nconst collateralRatio = await hre.Diamond.getAccountCollateralRatio(f.user.address);\n(0, _chai.expect)(collateralRatio).to.equal(expectedDepositValue.percentDiv(expectedMintValue)) // 2.475\n;",
+ "code": "await Promise.all(f.usersArr.map((signer)=>f.Collateral.setBalance(signer, (0, _values.toBig)(1_000_000))));\nawait f.KISS.setBalance(f.swapper, (0, _values.toBig)(10_000));\nawait f.KISS.setBalance(f.depositor, (0, _values.toBig)(10_000));\nawait f.KreskoDepositor.depositSCDP(f.depositor.address, f.KISS.address, depositAmount18Dec);",
"err": {},
- "uuid": "f5f8ce2f-da3f-417d-bb55-606dd3debeb7",
- "parentUUID": "68d58545-5c4e-4266-a47c-7d0929b5e5b9",
- "isHook": false,
+ "uuid": "ffc2f2dc-93cd-4940-9a13-663e68d90d90",
+ "parentUUID": "02070f8e-45c2-4cd2-a957-b1c39ec1adad",
+ "isHook": true,
"skipped": false
}
],
- "suites": [],
- "passes": [
- "c3b461ba-3daa-4d82-8964-42380b53a596",
- "5b3f2a7c-c15d-4135-938c-2d345699a461",
- "f5f8ce2f-da3f-417d-bb55-606dd3debeb7"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 1789,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "3cc55668-b6ca-4c01-a0f5-3a355ce1114a",
- "title": "Diamond",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/diamond/00-init.ts",
- "file": "/src/test/diamond/00-init.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"Diamond\"",
- "fullTitle": "Diamond \"before each\" hook in \"Diamond\"",
- "timedOut": false,
- "duration": 0,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "f = await (0, _fixtures.diamondFixture)();",
- "err": {},
- "uuid": "46419129-4b5a-4403-b071-29861dbf140b",
- "parentUUID": "3cc55668-b6ca-4c01-a0f5-3a355ce1114a",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [],
- "suites": [
- {
- "uuid": "351e46a8-7a4a-4c11-b62a-2af766bc6e46",
- "title": "#initialization",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/diamond/00-init.ts",
- "file": "/src/test/diamond/00-init.ts",
- "beforeHooks": [],
"afterHooks": [],
"tests": [
{
- "title": "sets correct state",
- "fullTitle": "Diamond #initialization sets correct state",
+ "title": "should be able to swap, debt < assetsIn | swap deposits < assetsOut",
+ "fullTitle": "SCDP #Swap should be able to swap, debt < assetsIn | swap deposits < assetsOut",
"timedOut": false,
- "duration": 69,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "(0, _chai.expect)(await _hardhat.default.Diamond.owner()).to.equal(_hardhat.default.users.deployer.address);\n(0, _chai.expect)(await _hardhat.default.Diamond.initialized()).to.equal(true);",
- "err": {},
- "uuid": "028f8692-62c1-473b-9317-f64f43f72c56",
- "parentUUID": "351e46a8-7a4a-4c11-b62a-2af766bc6e46",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "sets standard facet addresses",
- "fullTitle": "Diamond #initialization sets standard facet addresses",
- "timedOut": false,
- "duration": 86,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const facetAddressesOnChain = (await _hardhat.default.Diamond.facets()).map((f)=>f.facetAddress);\nconst facetAddressesArtifact = f.facets.map((f)=>f.facetAddress);\n(0, _chai.expect)(facetAddressesOnChain.length).to.equal(facetAddressesArtifact.length);\n(0, _chai.expect)(facetAddressesOnChain).to.have.members(facetAddressesArtifact);",
- "err": {},
- "uuid": "cf3a10b4-cb49-4bd7-be07-ec8351024242",
- "parentUUID": "351e46a8-7a4a-4c11-b62a-2af766bc6e46",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "sets selectors of standard facets",
- "fullTitle": "Diamond #initialization sets selectors of standard facets",
- "timedOut": false,
- "duration": 85,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const facetsSelectorsOnChain = (await _hardhat.default.Diamond.facets()).flatMap((f)=>f.functionSelectors);\nconst facetSelectorsOnArtifact = f.facets.flatMap((f)=>f.functionSelectors);\n(0, _chai.expect)(facetsSelectorsOnChain.length).to.equal(facetSelectorsOnArtifact.length);\n(0, _chai.expect)(facetsSelectorsOnChain).to.have.members(facetSelectorsOnArtifact);",
- "err": {},
- "uuid": "540179c5-36ef-4ef1-bb4b-a476ec30eb3e",
- "parentUUID": "351e46a8-7a4a-4c11-b62a-2af766bc6e46",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "028f8692-62c1-473b-9317-f64f43f72c56",
- "cf3a10b4-cb49-4bd7-be07-ec8351024242",
- "540179c5-36ef-4ef1-bb4b-a476ec30eb3e"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 240,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "43782690-8b86-4c7d-ad54-e61eeeb32dd0",
- "title": "Diamond",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/diamond/01-ownership.ts",
- "file": "/src/test/diamond/01-ownership.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"Diamond\"",
- "fullTitle": "Diamond \"before each\" hook in \"Diamond\"",
- "timedOut": false,
- "duration": 0,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await (0, _fixtures.diamondFixture)();",
- "err": {},
- "uuid": "fa729d56-daf9-4173-88d3-f4b21fc6b9ce",
- "parentUUID": "43782690-8b86-4c7d-ad54-e61eeeb32dd0",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [],
- "suites": [
- {
- "uuid": "fc3b64b9-49cf-45a6-bb00-48d82c725de8",
- "title": "#ownership",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/diamond/01-ownership.ts",
- "file": "/src/test/diamond/01-ownership.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "sets correct owner",
- "fullTitle": "Diamond #ownership sets correct owner",
- "timedOut": false,
- "duration": 35,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "(0, _chai.expect)(await hre.Diamond.owner()).to.equal(hre.addr.deployer);",
- "err": {},
- "uuid": "f4aba089-5f19-4e0d-a263-69d14f1eca5c",
- "parentUUID": "fc3b64b9-49cf-45a6-bb00-48d82c725de8",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "sets correct default admin role",
- "fullTitle": "Diamond #ownership sets correct default admin role",
- "timedOut": false,
- "duration": 35,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "(0, _chai.expect)(await hre.Diamond.hasRole(_roles.Role.ADMIN, hre.addr.deployer)).to.equal(true);",
- "err": {},
- "uuid": "946c6598-91b7-4916-ae1d-40bb605727c3",
- "parentUUID": "fc3b64b9-49cf-45a6-bb00-48d82c725de8",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "sets a new pending owner",
- "fullTitle": "Diamond #ownership sets a new pending owner",
- "timedOut": false,
- "duration": 72,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const pendingOwner = hre.users.userOne;\nawait hre.Diamond.transferOwnership(pendingOwner.address);\n(0, _chai.expect)(await hre.Diamond.pendingOwner()).to.equal(pendingOwner.address);",
- "err": {},
- "uuid": "5a160ceb-5403-4465-b64d-8837e3a5b124",
- "parentUUID": "fc3b64b9-49cf-45a6-bb00-48d82c725de8",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "sets the pending owner as new owner",
- "fullTitle": "Diamond #ownership sets the pending owner as new owner",
- "timedOut": false,
- "duration": 123,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const pendingOwner = hre.users.userOne;\nawait hre.Diamond.transferOwnership(pendingOwner.address);\nawait (0, _general.wrapContractWithSigner)(hre.Diamond, pendingOwner).acceptOwnership();\n(0, _chai.expect)(await hre.Diamond.owner()).to.equal(pendingOwner.address);",
- "err": {},
- "uuid": "fc0208b2-4585-41e2-a1ad-45313da62d9e",
- "parentUUID": "fc3b64b9-49cf-45a6-bb00-48d82c725de8",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "f4aba089-5f19-4e0d-a263-69d14f1eca5c",
- "946c6598-91b7-4916-ae1d-40bb605727c3",
- "5a160ceb-5403-4465-b64d-8837e3a5b124",
- "fc0208b2-4585-41e2-a1ad-45313da62d9e"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 265,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "457d42d2-e72c-4652-a346-d32c528c109e",
- "title": "Diamond",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/diamond/02-upgrades.ts",
- "file": "/src/test/diamond/02-upgrades.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"Diamond\"",
- "fullTitle": "Diamond \"before each\" hook in \"Diamond\"",
- "timedOut": false,
- "duration": 1,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await (0, _fixtures.diamondFixture)();",
- "err": {},
- "uuid": "71207aaf-b564-4efb-9c2c-e833e6cebf54",
- "parentUUID": "457d42d2-e72c-4652-a346-d32c528c109e",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [],
- "suites": [
- {
- "uuid": "bd40985f-db54-4562-a843-e3bb56863c1f",
- "title": "#upgrades",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/diamond/02-upgrades.ts",
- "file": "/src/test/diamond/02-upgrades.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "can add a new facet",
- "fullTitle": "Diamond #upgrades can add a new facet",
- "timedOut": false,
- "duration": 641,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const Factory = await _smock.smock.mock('SmockFacet');\nconst SmockFacet = await Factory.deploy();\nconst [SmockInitializer] = await hre.deploy('SmockInit');\nconst signatures = hre.getSignatures([\n ..._typechain.SmockFacet__factory.abi\n]);\nconst Cut = {\n facetAddress: SmockFacet.address,\n functionSelectors: signatures,\n action: _types.FacetCutAction.Add\n};\nconst initData = await SmockInitializer.populateTransaction.initialize(hre.addr.userOne);\nawait hre.Diamond.diamondCut([\n Cut\n], initData.to, initData.data);\nconst TEST_OPERATOR_ROLE = hre.ethers.utils.id('kresko.test.operator');\nconst isTestOperator = await hre.Diamond.hasRole(TEST_OPERATOR_ROLE, hre.addr.userOne);\n// Succesfully added the new operator through the initialization contract\n(0, _chai.expect)(isTestOperator).to.equal(true);\nconst Facet = await hre.ethers.getContractAt([\n ..._typechain.SmockFacet__factory.abi\n], hre.Diamond.address);\n// Ensure facet has it's own storage\nconst operatorFromNewStorage = await Facet.operator() // Retrieved from SmockStorage\n;\n(0, _chai.expect)(operatorFromNewStorage).to.equal(hre.addr.userOne);",
- "err": {},
- "uuid": "1fca8908-f74a-4986-bd9a-0c5c51793066",
- "parentUUID": "bd40985f-db54-4562-a843-e3bb56863c1f",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "can remove a facet",
- "fullTitle": "Diamond #upgrades can remove a facet",
- "timedOut": false,
- "duration": 597,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const NewFacet = await (0, _addfacet.addFacet)({\n name: 'SmockFacet',\n initializerName: 'SmockInit',\n initializerArgs: hre.addr.userOne\n});\nconst facetsBefore = await hre.Diamond.facets();\n(0, _chai.expect)(facetsBefore.filter((f)=>f.facetAddress === NewFacet.address).length).to.equal(1);\nawait (0, _removefacet.removeFacet)({\n name: 'SmockFacet'\n});\nconst facetsAfter = await hre.Diamond.facets();\n(0, _chai.expect)(facetsBefore.length - facetsAfter.length).to.equal(1);\n(0, _chai.expect)(facetsAfter).to.not.deep.contain(NewFacet.address);",
- "err": {},
- "uuid": "bb9ad686-5a6b-4024-a4a6-330bba5750c0",
- "parentUUID": "bd40985f-db54-4562-a843-e3bb56863c1f",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "can remove a function",
- "fullTitle": "Diamond #upgrades can remove a function",
- "timedOut": false,
- "duration": 157,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Delete acceptOwnership from DiamondStateFacet\n// Check there is no pending owner\nlet pendingOwner = await hre.Diamond.pendingOwner();\n(0, _chai.expect)(pendingOwner).to.equal(hre.ethers.constants.AddressZero);\n// Transfer to eg. wrong address\nconst wrongOwner = hre.addr.notAdmin;\nawait hre.Diamond.transferOwnership(wrongOwner);\n// Ensure\npendingOwner = await hre.Diamond.pendingOwner();\n(0, _chai.expect)(pendingOwner).to.equal(wrongOwner);\n// Fragment and signature for acceptOwnersip\nconst functionFragment = hre.Diamond.interface.functions['acceptOwnership()'];\nconst signature = hre.ethers.utils.Interface.getSighash(functionFragment);\nconst facetAddress = await hre.Diamond.facetAddress(signature);\nconst functions = await hre.Diamond.facetFunctionSelectors(facetAddress);\nconst Cut = {\n facetAddress: hre.ethers.constants.AddressZero,\n action: _types.FacetCutAction.Remove,\n functionSelectors: [\n signature\n ]\n};\n// We will set a correct owner with delegatecall into the Diamond itself with the cut transaction\nconst correctOwner = hre.addr.userOne;\nconst initData = await hre.Diamond.populateTransaction.transferOwnership(correctOwner);\nawait hre.Diamond.diamondCut([\n Cut\n], initData.to, initData.data);\n// Ensure rest of the functions remain\nconst functionsAfterCut = await hre.Diamond.facetFunctionSelectors(facetAddress);\n(0, _chai.expect)(functionsAfterCut.length).to.equal(functions.length - 1);\n// Ensure delegatecall did set the correct pending owner with the cut\nconst contract = await hre.ethers.getContractAt('DSCore', hre.Diamond.address);\nconst filter = contract.filters.PendingOwnershipTransfer(hre.addr.deployer, correctOwner);\nconst [event] = await contract.queryFilter(filter);\nconst { previousOwner, newOwner } = event.args;\n(0, _chai.expect)(previousOwner).to.equal(hre.addr.deployer);\n(0, _chai.expect)(newOwner).to.equal(correctOwner);\n// Ensure there is no function to accept the ownership\nawait (0, _chai.expect)((0, _general.wrapContractWithSigner)(hre.Diamond, hre.users.notAdmin).acceptOwnership()).to.be.reverted;",
- "err": {},
- "uuid": "ec31708f-513c-4420-a367-7522e4015518",
- "parentUUID": "bd40985f-db54-4562-a843-e3bb56863c1f",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "can replace a function",
- "fullTitle": "Diamond #upgrades can replace a function",
- "timedOut": false,
- "duration": 229,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Same as above but instead replace the function\n// Check there is no pending owner\nlet pendingOwner = await hre.Diamond.pendingOwner();\n(0, _chai.expect)(pendingOwner).to.equal(hre.ethers.constants.AddressZero);\n// Transfer to eg. wrong address\nconst wrongOwner = hre.addr.notAdmin;\nawait hre.Diamond.transferOwnership(wrongOwner);\n// Ensure\npendingOwner = await hre.Diamond.pendingOwner();\n(0, _chai.expect)(pendingOwner).to.equal(wrongOwner);\n// Fragment and signature for acceptOwnersip\nconst functionFragment = hre.Diamond.interface.functions['acceptOwnership()'];\nconst signature = hre.ethers.utils.Interface.getSighash(functionFragment);\nconst OldOwnershipFacet = await hre.Diamond.facetAddress(signature);\nconst [NewOwnershipFacet, allOwnershipFacetSignatures] = await hre.deploy('DiamondStateFacet', {\n deploymentName: 'DiamondStateFacet2'\n});\n// Only replace a single function, we could replace all of them\nconst Cut = {\n facetAddress: NewOwnershipFacet.address,\n action: _types.FacetCutAction.Replace,\n functionSelectors: [\n signature\n ]\n};\n// We will set a correct owner with delegatecall into the Diamond itself with the cut transaction\nconst correctOwner = hre.addr.userOne;\nconst initData = await hre.Diamond.populateTransaction.transferOwnership(correctOwner);\nawait hre.Diamond.diamondCut([\n Cut\n], initData.to, initData.data);\n// Ensure function exists and revert is for invalid address instead of missing function\nawait (0, _chai.expect)((0, _general.wrapContractWithSigner)(hre.Diamond, hre.users.notAdmin).acceptOwnership()).to.be.reverted;\n// Ensure one function is contained in the new facet\nconst functionsNewFacet = await hre.Diamond.facetFunctionSelectors(NewOwnershipFacet.address);\n(0, _chai.expect)(functionsNewFacet.length).to.equal(1);\n(0, _chai.expect)(functionsNewFacet).to.have.members([\n signature\n]);\n// Ensure rest are in the previous one\nconst functionsOldFacet = await hre.Diamond.facetFunctionSelectors(OldOwnershipFacet);\n(0, _chai.expect)(functionsOldFacet).to.not.have.members([\n signature\n]);\n(0, _chai.expect)(functionsOldFacet.length).to.equal(allOwnershipFacetSignatures.length - 1);\n// Ensure correct owner can now accept the ownership\n(0, _chai.expect)((0, _general.wrapContractWithSigner)(hre.Diamond, hre.users.userOne).acceptOwnership());\nconst currentOwner = await hre.Diamond.owner();\n(0, _chai.expect)(currentOwner).to.equal(correctOwner);",
- "err": {},
- "uuid": "b6c89bee-1f38-4c8c-a732-babf194662f2",
- "parentUUID": "bd40985f-db54-4562-a843-e3bb56863c1f",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "can upgrade state",
- "fullTitle": "Diamond #upgrades can upgrade state",
- "timedOut": false,
- "duration": 537,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "(0, _chai.expect)(await hre.Diamond.initialized()).to.equal(true);\nconst Factory = await _smock.smock.mock('SmockInit');\nconst SmockInit = await Factory.deploy();\nconst tx = await SmockInit.populateTransaction.upgradeState();\nawait hre.Diamond.executeInitializer(tx.to, tx.data);\n(0, _chai.expect)(await hre.Diamond.initialized()).to.equal(false);",
- "err": {},
- "uuid": "9b21a6e7-ea07-4c4d-8a99-80b9032682f4",
- "parentUUID": "bd40985f-db54-4562-a843-e3bb56863c1f",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "can preserve old state when extending storage layout",
- "fullTitle": "Diamond #upgrades can preserve old state when extending storage layout",
- "timedOut": false,
- "duration": 1128,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "(0, _chai.expect)(await hre.Diamond.initialized()).to.equal(true);\n// Add the first facet\nconst Factory = await _smock.smock.mock('SmockFacet');\nconst SmockFacet = await Factory.deploy();\nconst [SmockInitializer] = await hre.deploy('SmockInit');\nconst signatures = hre.getSignatures([\n ..._typechain.SmockFacet__factory.abi\n]);\nconst Cut = {\n facetAddress: SmockFacet.address,\n functionSelectors: signatures,\n action: _types.FacetCutAction.Add\n};\nconst initData = await SmockInitializer.populateTransaction.initialize(hre.addr.userOne);\nawait hre.Diamond.diamondCut([\n Cut\n], initData.to, initData.data);\nconst Diamond = await hre.ethers.getContractAt('SmockFacet', hre.Diamond.address);\nconst isInitialized = await Diamond.smockInitialized();\n(0, _chai.expect)(isInitialized).to.equal(true);\n// Add facet with extended state\n// Add the first facet\nconst Factory2 = await _smock.smock.mock('SmockFacet2');\nconst SmockFacet2 = await Factory2.deploy();\nconst signatures2 = hre.getSignatures([\n ..._typechain.SmockFacet2__factory.abi\n]);\nconst Cut2 = {\n facetAddress: SmockFacet2.address,\n functionSelectors: signatures2,\n action: _types.FacetCutAction.Add\n};\n// Initializer only sets the new extended value, does not touch old storage\nconst initData2 = await SmockFacet2.populateTransaction.initialize();\nawait hre.Diamond.diamondCut([\n Cut2\n], initData2.to, initData2.data);\n// Here we have appended the storage layout with the `extended` bool property.\nconst DiamondExtended = await hre.ethers.getContractAt('SmockFacet2', hre.Diamond.address);\nconst initializedAfterExtend = await DiamondExtended.getOldStructValueFromExtended();\nconst extendedValue = await DiamondExtended.getNewStructValueFromExtended();\n// Old values remain\n(0, _chai.expect)(initializedAfterExtend).to.equal(true);\n// And we get new ones\n(0, _chai.expect)(extendedValue).to.equal(true);",
- "err": {},
- "uuid": "41d20c0a-b38f-44e6-8a0e-3b56f7fd8097",
- "parentUUID": "bd40985f-db54-4562-a843-e3bb56863c1f",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "1fca8908-f74a-4986-bd9a-0c5c51793066",
- "bb9ad686-5a6b-4024-a4a6-330bba5750c0",
- "ec31708f-513c-4420-a367-7522e4015518",
- "b6c89bee-1f38-4c8c-a732-babf194662f2",
- "9b21a6e7-ea07-4c4d-8a99-80b9032682f4",
- "41d20c0a-b38f-44e6-8a0e-3b56f7fd8097"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 3289,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "05636797-6b11-46dc-a9c6-05fba876a86f",
- "title": "Diamond",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/diamond/03-protocol.ts",
- "file": "/src/test/diamond/03-protocol.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"Diamond\"",
- "fullTitle": "Diamond \"before each\" hook in \"Diamond\"",
- "timedOut": false,
- "duration": 0,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await (0, _fixtures.defaultFixture)();",
- "err": {},
- "uuid": "4fbe9aa7-4c99-4ffa-a598-ccfe70f001d0",
- "parentUUID": "05636797-6b11-46dc-a9c6-05fba876a86f",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [],
- "suites": [
- {
- "uuid": "35af4755-acd2-4be6-b727-5ef60d81c46f",
- "title": "#protocol initialization",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/diamond/03-protocol.ts",
- "file": "/src/test/diamond/03-protocol.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "initialized all facets",
- "fullTitle": "Diamond #protocol initialization initialized all facets",
- "timedOut": false,
- "duration": 79,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const facetsOnChain = (await hre.Diamond.facets()).map(([facetAddress, functionSelectors])=>({\n facetAddress,\n functionSelectors\n }));\nconst expectedFacets = await Promise.all([\n ..._deploy.diamondFacets,\n ..._deploy.minterFacets,\n ..._deploy.scdpFacets,\n ..._deploy.commonFacets,\n ..._deploy.peripheryFacets\n].map(async (name)=>{\n const deployment = await hre.deployments.get(name);\n return {\n facetAddress: deployment.address,\n functionSelectors: facetsOnChain.find((f)=>f.facetAddress === deployment.address).functionSelectors\n };\n}));\n(0, _chai.expect)(facetsOnChain).to.have.deep.members(expectedFacets);",
- "err": {},
- "uuid": "262c3fbe-62e1-41ec-bc6c-027b3ece92b5",
- "parentUUID": "35af4755-acd2-4be6-b727-5ef60d81c46f",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "initialized correct state",
- "fullTitle": "Diamond #protocol initialization initialized correct state",
- "timedOut": false,
- "duration": 343,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "(0, _chai.expect)(await hre.Diamond.getStorageVersion()).to.equal(3);\nconst { args } = await (0, _deploy.getCommonInitializer)(hre);\nconst { args: minterArgs } = await (0, _deploy.getMinterInitializer)(hre);\nconst { args: scdpArgs } = await (0, _deploy.getSCDPInitializer)(hre);\n(0, _chai.expect)(await hre.Diamond.hasRole(_roles.Role.ADMIN, args.admin)).to.equal(true);\n(0, _chai.expect)(await hre.Diamond.hasRole(_roles.Role.SAFETY_COUNCIL, hre.Multisig.address)).to.equal(true);\n(0, _chai.expect)(await hre.Diamond.getFeeRecipient()).to.equal(args.treasury);\n(0, _chai.expect)(await hre.Diamond.getMinCollateralRatioMinter()).to.equal(minterArgs.minCollateralRatio);\n(0, _chai.expect)(await hre.Diamond.getLiquidationThresholdMinter()).to.equal(minterArgs.liquidationThreshold);\n(0, _chai.expect)(await hre.Diamond.getMinDebtValueMinter()).to.equal(minterArgs.minDebtValue);\n(0, _chai.expect)(await hre.Diamond.getMaxLiquidationRatioMinter()).to.equal(Number(minterArgs.liquidationThreshold) + 0.01e4);\nconst scdpParams = await hre.Diamond.getParametersSCDP();\n(0, _chai.expect)(scdpParams.minCollateralRatio).to.equal(scdpArgs.minCollateralRatio);\n(0, _chai.expect)(scdpParams.liquidationThreshold).to.equal(scdpArgs.liquidationThreshold);\n(0, _chai.expect)(await hre.Diamond.getOracleDeviationPct()).to.equal(args.maxPriceDeviationPct);",
- "err": {},
- "uuid": "f1978aaa-563d-460c-8b96-4e860244f052",
- "parentUUID": "35af4755-acd2-4be6-b727-5ef60d81c46f",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "can modify configuration parameters",
- "fullTitle": "Diamond #protocol initialization can modify configuration parameters",
- "timedOut": false,
- "duration": 327,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await (0, _chai.expect)(hre.Diamond.setMaxPriceDeviationPct(0.05e4)).to.not.be.reverted;\nawait (0, _chai.expect)(hre.Diamond.setSequencerGracePeriod(1000)).to.not.be.reverted;\nawait (0, _chai.expect)(hre.Diamond.setDefaultOraclePrecision(9)).to.not.be.reverted;\nawait (0, _chai.expect)(hre.Diamond.setStaleTime(9)).to.not.be.reverted;\nawait (0, _chai.expect)(hre.Diamond.setMinDebtValueMinter(20e8)).to.not.be.reverted;\n(0, _chai.expect)(await hre.Diamond.getMinDebtValueMinter()).to.equal(20e8);\n(0, _chai.expect)(await hre.Diamond.getDefaultOraclePrecision()).to.equal(9);\n(0, _chai.expect)(await hre.Diamond.getOracleDeviationPct()).to.equal(0.05e4);\n(0, _chai.expect)(await hre.Diamond.getSequencerGracePeriod()).to.equal(1000);",
- "err": {},
- "uuid": "e8474a30-a0f6-479f-88da-3a619b9ad6ee",
- "parentUUID": "35af4755-acd2-4be6-b727-5ef60d81c46f",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "262c3fbe-62e1-41ec-bc6c-027b3ece92b5",
- "f1978aaa-563d-460c-8b96-4e860244f052",
- "e8474a30-a0f6-479f-88da-3a619b9ad6ee"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 749,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "33ac4bf3-11a5-42cf-a16e-4e221737cfe0",
- "title": "Forking",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/forking/00-setup.ts",
- "file": "/src/test/forking/00-setup.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [],
- "suites": [
- {
- "uuid": "ce26fb52-0b40-4d8b-826c-c50b0bc6a225",
- "title": "#setup",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/forking/00-setup.ts",
- "file": "/src/test/forking/00-setup.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "should get Kresko from the companion network locally",
- "fullTitle": "Forking #setup should get Kresko from the companion network locally",
- "timedOut": false,
- "duration": 0,
- "state": "pending",
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": true,
- "context": null,
- "code": "",
- "err": {},
- "uuid": "389df43a-d085-4e2d-b5e6-67c4894fd364",
- "parentUUID": "ce26fb52-0b40-4d8b-826c-c50b0bc6a225",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [],
- "failures": [],
- "pending": [
- "389df43a-d085-4e2d-b5e6-67c4894fd364"
- ],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "57b5e0ea-1608-4000-a03c-927ee2d6d616",
- "title": "#rate-upgrade-11-04-2023",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/forking/00-setup.ts",
- "file": "/src/test/forking/00-setup.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "should be able to deploy facets",
- "fullTitle": "Forking #rate-upgrade-11-04-2023 should be able to deploy facets",
- "timedOut": false,
- "duration": 0,
- "state": "pending",
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": true,
- "context": null,
- "code": "",
- "err": {},
- "uuid": "e3f181d6-72d1-4c5a-bc31-8f5f59bdba3e",
- "parentUUID": "57b5e0ea-1608-4000-a03c-927ee2d6d616",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [],
- "failures": [],
- "pending": [
- "e3f181d6-72d1-4c5a-bc31-8f5f59bdba3e"
- ],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "b7686690-f6c7-45ed-bee1-af96abc75edf",
- "title": "KreskoAsset",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/krasset/00-init.ts",
- "file": "/src/test/krasset/00-init.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"KreskoAsset\"",
- "fullTitle": "KreskoAsset \"before each\" hook in \"KreskoAsset\"",
- "timedOut": false,
- "duration": 1,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "f = await (0, _fixtures.kreskoAssetFixture)({\n name,\n symbol,\n underlyingToken: _viem.zeroAddress\n});",
- "err": {},
- "uuid": "bc266a68-7176-42a3-aaa3-bd9247c0cec9",
- "parentUUID": "b7686690-f6c7-45ed-bee1-af96abc75edf",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [],
- "suites": [
- {
- "uuid": "98adaf84-3033-44c8-b5b6-8a1fc8979610",
- "title": "KreskoAsset",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/krasset/00-init.ts",
- "file": "/src/test/krasset/00-init.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "sets correct state",
- "fullTitle": "KreskoAsset KreskoAsset sets correct state",
- "timedOut": false,
- "duration": 23,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "(0, _chai.expect)(await f.KreskoAsset.name()).to.equal(name);\n(0, _chai.expect)(await f.KreskoAsset.symbol()).to.equal(symbol);\n(0, _chai.expect)(await f.KreskoAsset.kresko()).to.equal(hre.Diamond.address);\n(0, _chai.expect)(await f.KreskoAsset.hasRole(_roles.Role.ADMIN, hre.addr.deployer)).to.equal(true);\n(0, _chai.expect)(await f.KreskoAsset.hasRole(_roles.Role.OPERATOR, hre.Diamond.address)).to.equal(true);\n(0, _chai.expect)(await f.KreskoAsset.totalSupply()).to.equal(0);\n(0, _chai.expect)(await f.KreskoAsset.isRebased()).to.equal(false);\nconst rebaseInfo = await f.KreskoAsset.rebaseInfo();\n(0, _chai.expect)(rebaseInfo.denominator).to.equal(0);\n(0, _chai.expect)(rebaseInfo.positive).to.equal(false);",
- "err": {},
- "uuid": "d43334db-8ae3-4031-bf25-147662e66250",
- "parentUUID": "98adaf84-3033-44c8-b5b6-8a1fc8979610",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "can reinitialize metadata",
- "fullTitle": "KreskoAsset KreskoAsset can reinitialize metadata",
- "timedOut": false,
- "duration": 14,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const newName = 'foo';\nconst newSymbol = 'bar';\nawait (0, _chai.expect)(f.KreskoAsset.reinitializeERC20(newName, newSymbol, 2)).to.not.be.reverted;\n(0, _chai.expect)(await f.KreskoAsset.name()).to.equal(newName);\n(0, _chai.expect)(await f.KreskoAsset.symbol()).to.equal(newSymbol);",
- "err": {},
- "uuid": "cd4ff05b-96d6-4184-bddd-192361655511",
- "parentUUID": "98adaf84-3033-44c8-b5b6-8a1fc8979610",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [
- {
- "uuid": "a6d56eba-f234-43e2-98a8-2f9789228bb3",
- "title": "#initialization",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/krasset/00-init.ts",
- "file": "/src/test/krasset/00-init.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "cant initialize twice",
- "fullTitle": "KreskoAsset KreskoAsset #initialization cant initialize twice",
- "timedOut": false,
- "duration": 9,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await (0, _chai.expect)(f.KreskoAsset.initialize(name, symbol, 18, hre.addr.deployer, hre.Diamond.address, hre.ethers.constants.AddressZero, hre.addr.deployer, 0, 0)).to.be.reverted;",
- "err": {},
- "uuid": "2b031c02-c14f-490b-ad64-5b0a137e78f3",
- "parentUUID": "a6d56eba-f234-43e2-98a8-2f9789228bb3",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "cant initialize implementation",
- "fullTitle": "KreskoAsset KreskoAsset #initialization cant initialize implementation",
- "timedOut": false,
- "duration": 0,
- "state": "pending",
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": true,
- "context": null,
- "code": "",
- "err": {},
- "uuid": "7398fdd1-d158-49cc-aa54-cb4f03a32c3f",
- "parentUUID": "a6d56eba-f234-43e2-98a8-2f9789228bb3",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "sets correct state",
- "fullTitle": "KreskoAsset KreskoAsset #initialization sets correct state",
- "timedOut": false,
- "duration": 26,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "(0, _chai.expect)(await f.KreskoAsset.name()).to.equal(name);\n(0, _chai.expect)(await f.KreskoAsset.symbol()).to.equal(symbol);\n(0, _chai.expect)(await f.KreskoAsset.kresko()).to.equal(hre.Diamond.address);\n(0, _chai.expect)(await f.KreskoAsset.hasRole(_roles.Role.DEFAULT_ADMIN, hre.addr.deployer)).to.equal(true);\n(0, _chai.expect)(await f.KreskoAsset.hasRole(_roles.Role.ADMIN, hre.addr.deployer)).to.equal(true);\n(0, _chai.expect)(await f.KreskoAsset.hasRole(_roles.Role.OPERATOR, hre.Diamond.address)).to.equal(true);\n(0, _chai.expect)(await f.KreskoAsset.totalSupply()).to.equal(0);\n(0, _chai.expect)(await f.KreskoAsset.isRebased()).to.equal(false);\nconst rebaseInfo = await f.KreskoAsset.rebaseInfo();\n(0, _chai.expect)(rebaseInfo.denominator).to.equal(0);\n(0, _chai.expect)(rebaseInfo.positive).to.equal(false);",
- "err": {},
- "uuid": "c8906b12-babe-4b7f-955c-fe79b04636b7",
- "parentUUID": "a6d56eba-f234-43e2-98a8-2f9789228bb3",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "can reinitialize metadata",
- "fullTitle": "KreskoAsset KreskoAsset #initialization can reinitialize metadata",
- "timedOut": false,
- "duration": 17,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const newName = 'foo';\nconst newSymbol = 'bar';\nawait (0, _chai.expect)(f.KreskoAsset.reinitializeERC20(newName, newSymbol, 2)).to.not.be.reverted;\n(0, _chai.expect)(await f.KreskoAsset.name()).to.equal(newName);\n(0, _chai.expect)(await f.KreskoAsset.symbol()).to.equal(newSymbol);",
- "err": {},
- "uuid": "a38e8298-7b6b-437c-8bf4-ba224ac31859",
- "parentUUID": "a6d56eba-f234-43e2-98a8-2f9789228bb3",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "2b031c02-c14f-490b-ad64-5b0a137e78f3",
- "c8906b12-babe-4b7f-955c-fe79b04636b7",
- "a38e8298-7b6b-437c-8bf4-ba224ac31859"
- ],
- "failures": [],
- "pending": [
- "7398fdd1-d158-49cc-aa54-cb4f03a32c3f"
- ],
- "skipped": [],
- "duration": 52,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [
- "d43334db-8ae3-4031-bf25-147662e66250",
- "cd4ff05b-96d6-4184-bddd-192361655511"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 37,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "81f30e48-1877-4b5c-8b99-70836550cb98",
- "title": "#initialization - anchor",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/krasset/00-init.ts",
- "file": "/src/test/krasset/00-init.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "cant initialize twice",
- "fullTitle": "KreskoAsset #initialization - anchor cant initialize twice",
- "timedOut": false,
- "duration": 5,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await (0, _chai.expect)(f.KreskoAssetAnchor.initialize(f.KreskoAsset.address, name, symbol, hre.addr.deployer)).to.be.reverted;",
- "err": {},
- "uuid": "cb31d7a2-80eb-4b70-a85e-82410e160429",
- "parentUUID": "81f30e48-1877-4b5c-8b99-70836550cb98",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "sets correct state",
- "fullTitle": "KreskoAsset #initialization - anchor sets correct state",
- "timedOut": false,
- "duration": 25,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "(0, _chai.expect)(await f.KreskoAssetAnchor.name()).to.equal(anchorName);\n(0, _chai.expect)(await f.KreskoAssetAnchor.symbol()).to.equal(anchorSymbol);\n(0, _chai.expect)(await f.KreskoAssetAnchor.asset()).to.equal(f.KreskoAsset.address);\n(0, _chai.expect)(await f.KreskoAssetAnchor.hasRole(_roles.Role.ADMIN, hre.addr.deployer)).to.equal(true);\n(0, _chai.expect)(await f.KreskoAssetAnchor.hasRole(_roles.Role.OPERATOR, hre.Diamond.address)).to.equal(true);\n(0, _chai.expect)(await f.KreskoAssetAnchor.totalSupply()).to.equal(0);\n(0, _chai.expect)(await f.KreskoAssetAnchor.totalAssets()).to.equal(await f.KreskoAsset.totalSupply());\nconst rebaseInfo = await f.KreskoAsset.rebaseInfo();\n(0, _chai.expect)(rebaseInfo.denominator).to.equal(0);\n(0, _chai.expect)(rebaseInfo.positive).to.equal(false);",
- "err": {},
- "uuid": "8daa5d1a-07c4-4b44-8ca8-f00406a8a80a",
- "parentUUID": "81f30e48-1877-4b5c-8b99-70836550cb98",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "cant initialize implementation",
- "fullTitle": "KreskoAsset #initialization - anchor cant initialize implementation",
- "timedOut": false,
- "duration": 29,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const deployment = await hre.deployments.get(anchorSymbol);\nconst implementationAddress = deployment.implementation;\n(0, _chai.expect)(implementationAddress).to.not.equal(hre.ethers.constants.AddressZero);\nconst KreskoAssetAnchorImpl = await hre.ethers.getContractAt('KreskoAssetAnchor', implementationAddress);\nawait (0, _chai.expect)(KreskoAssetAnchorImpl.initialize(f.KreskoAsset.address, name, symbol, hre.addr.deployer)).to.be.reverted;",
- "err": {},
- "uuid": "a94a8be6-f5d8-4fec-92e5-dae3b5e41bba",
- "parentUUID": "81f30e48-1877-4b5c-8b99-70836550cb98",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "can reinitialize metadata",
- "fullTitle": "KreskoAsset #initialization - anchor can reinitialize metadata",
- "timedOut": false,
- "duration": 21,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const newName = 'foo';\nconst newSymbol = 'bar';\nawait (0, _chai.expect)(f.KreskoAssetAnchor.reinitializeERC20(newName, newSymbol, 2)).to.not.be.reverted;\n(0, _chai.expect)(await f.KreskoAssetAnchor.name()).to.equal(newName);\n(0, _chai.expect)(await f.KreskoAssetAnchor.symbol()).to.equal(newSymbol);\nawait f.KreskoAssetAnchor.reinitializeERC20(name, symbol, 3);",
- "err": {},
- "uuid": "6964c024-4900-4d5e-afad-df8fd8b49d9f",
- "parentUUID": "81f30e48-1877-4b5c-8b99-70836550cb98",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "cb31d7a2-80eb-4b70-a85e-82410e160429",
- "8daa5d1a-07c4-4b44-8ca8-f00406a8a80a",
- "a94a8be6-f5d8-4fec-92e5-dae3b5e41bba",
- "6964c024-4900-4d5e-afad-df8fd8b49d9f"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 80,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "09e1aa6c-fd03-400e-8183-d43871a76904",
- "title": "KreskoAsset",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/krasset/01-erc20.ts",
- "file": "/src/test/krasset/01-erc20.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"KreskoAsset\"",
- "fullTitle": "KreskoAsset \"before each\" hook in \"KreskoAsset\"",
- "timedOut": false,
- "duration": 8,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "({ KreskoAsset } = await (0, _fixtures.kreskoAssetFixture)({\n name: 'Ether',\n symbol: 'krETH',\n underlyingToken: _viem.zeroAddress\n}));\nthis.mintAmount = 125;\nthis.owner = hre.users.deployer;\nawait KreskoAsset.grantRole(_roles.Role.OPERATOR, this.owner.address);",
- "err": {},
- "uuid": "3fe860ea-42ac-4ad9-9e7d-a303a298b5b4",
- "parentUUID": "09e1aa6c-fd03-400e-8183-d43871a76904",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [],
- "suites": [
- {
- "uuid": "d1ce0014-8aec-460c-8363-6be747dbb9e3",
- "title": "#mint",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/krasset/01-erc20.ts",
- "file": "/src/test/krasset/01-erc20.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "should allow the owner to mint to their own address",
- "fullTitle": "KreskoAsset #mint should allow the owner to mint to their own address",
- "timedOut": false,
- "duration": 17,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "(0, _chai.expect)(await KreskoAsset.totalSupply()).to.equal(0);\n(0, _chai.expect)(await KreskoAsset.balanceOf(this.owner.address)).to.equal(0);\nawait KreskoAsset.connect(this.owner).mint(this.owner.address, this.mintAmount);\n// Check total supply and owner's balances increased\n(0, _chai.expect)(await KreskoAsset.totalSupply()).to.equal(this.mintAmount);\n(0, _chai.expect)(await KreskoAsset.balanceOf(this.owner.address)).to.equal(this.mintAmount);",
- "err": {},
- "uuid": "f8875baa-6b5f-45f1-a0a5-69128017a004",
- "parentUUID": "d1ce0014-8aec-460c-8363-6be747dbb9e3",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should allow the asset owner to mint to another address",
- "fullTitle": "KreskoAsset #mint should allow the asset owner to mint to another address",
- "timedOut": false,
- "duration": 16,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "(0, _chai.expect)(await KreskoAsset.totalSupply()).to.equal(0);\n(0, _chai.expect)(await KreskoAsset.balanceOf(hre.users.userOne.address)).to.equal(0);\nawait KreskoAsset.connect(this.owner).mint(hre.users.userOne.address, this.mintAmount);\n// Check total supply and user's balances increased\n(0, _chai.expect)(await KreskoAsset.totalSupply()).to.equal(this.mintAmount);\n(0, _chai.expect)(await KreskoAsset.balanceOf(hre.users.userOne.address)).to.equal(this.mintAmount);",
- "err": {},
- "uuid": "f46fc0ba-dba0-471f-89e9-b4d06b970076",
- "parentUUID": "d1ce0014-8aec-460c-8363-6be747dbb9e3",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should not allow non-owner addresses to mint tokens",
- "fullTitle": "KreskoAsset #mint should not allow non-owner addresses to mint tokens",
- "timedOut": false,
- "duration": 17,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "(0, _chai.expect)(await KreskoAsset.totalSupply()).to.equal(0);\n(0, _chai.expect)(await KreskoAsset.balanceOf(this.owner.address)).to.equal(0);\nawait (0, _chai.expect)(KreskoAsset.connect(hre.users.userOne).mint(this.owner.address, this.mintAmount)).to.be.reverted;\n// Check total supply and all account balances unchanged\n(0, _chai.expect)(await KreskoAsset.totalSupply()).to.equal(0);\n(0, _chai.expect)(await KreskoAsset.balanceOf(this.owner.address)).to.equal(0);\n(0, _chai.expect)(await KreskoAsset.balanceOf(hre.users.userOne.address)).to.equal(0);",
- "err": {},
- "uuid": "1f287f2c-2d56-4f14-b2fd-e4d1ad342d1b",
- "parentUUID": "d1ce0014-8aec-460c-8363-6be747dbb9e3",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should not allow admin to mint tokens",
- "fullTitle": "KreskoAsset #mint should not allow admin to mint tokens",
- "timedOut": false,
- "duration": 9,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await KreskoAsset.renounceRole(_roles.Role.OPERATOR, this.owner.address);\nawait (0, _chai.expect)(KreskoAsset.connect(this.owner).mint(this.owner.address, this.mintAmount)).to.be.reverted;",
- "err": {},
- "uuid": "e8fec170-7377-4eea-af29-9c6d221fa786",
- "parentUUID": "d1ce0014-8aec-460c-8363-6be747dbb9e3",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "f8875baa-6b5f-45f1-a0a5-69128017a004",
- "f46fc0ba-dba0-471f-89e9-b4d06b970076",
- "1f287f2c-2d56-4f14-b2fd-e4d1ad342d1b",
- "e8fec170-7377-4eea-af29-9c6d221fa786"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 59,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "0cc740cd-891c-4071-b8f2-7ed97bc746a9",
- "title": "#burn",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/krasset/01-erc20.ts",
- "file": "/src/test/krasset/01-erc20.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"#burn\"",
- "fullTitle": "KreskoAsset #burn \"before each\" hook in \"#burn\"",
- "timedOut": false,
- "duration": 10,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await KreskoAsset.connect(this.owner).mint(hre.users.userOne.address, this.mintAmount);\nthis.owner = hre.users.deployer;\nthis.mintAmount = 125;\nawait KreskoAsset.grantRole(_roles.Role.OPERATOR, this.owner.address);",
- "err": {},
- "uuid": "1d1ea219-4adc-4361-ae5b-54c659f3e44f",
- "parentUUID": "0cc740cd-891c-4071-b8f2-7ed97bc746a9",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [
- {
- "title": "should allow the owner to burn tokens from user's address (without token allowance)",
- "fullTitle": "KreskoAsset #burn should allow the owner to burn tokens from user's address (without token allowance)",
- "timedOut": false,
- "duration": 16,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "(0, _chai.expect)(await KreskoAsset.totalSupply()).to.equal(this.mintAmount);\nawait KreskoAsset.connect(this.owner).burn(hre.users.userOne.address, this.mintAmount);\n// Check total supply and user's balances decreased\n(0, _chai.expect)(await KreskoAsset.totalSupply()).to.equal(0);\n(0, _chai.expect)(await KreskoAsset.balanceOf(this.owner.address)).to.equal(0);\n// Confirm that owner doesn't hold any tokens\n(0, _chai.expect)(await KreskoAsset.balanceOf(hre.users.userOne.address)).to.equal(0);",
- "err": {},
- "uuid": "d87975bd-ebfe-4296-b924-bf19feec4092",
- "parentUUID": "0cc740cd-891c-4071-b8f2-7ed97bc746a9",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should allow the operator to burn tokens from user's address without changing existing allowances",
- "fullTitle": "KreskoAsset #burn should allow the operator to burn tokens from user's address without changing existing allowances",
- "timedOut": false,
- "duration": 27,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await KreskoAsset.connect(this.owner).approve(hre.users.userOne.address, this.mintAmount);\n(0, _chai.expect)(await KreskoAsset.totalSupply()).to.equal(this.mintAmount);\n(0, _chai.expect)(await KreskoAsset.allowance(this.owner.address, hre.users.userOne.address)).to.equal(this.mintAmount);\nawait KreskoAsset.connect(this.owner).burn(hre.users.userOne.address, this.mintAmount);\n// Check total supply and user's balances decreased\n(0, _chai.expect)(await KreskoAsset.totalSupply()).to.equal(0);\n(0, _chai.expect)(await KreskoAsset.balanceOf(hre.users.userOne.address)).to.equal(0);\n// Confirm that owner doesn't hold any tokens\n(0, _chai.expect)(await KreskoAsset.balanceOf(this.owner.address)).to.equal(0);\n// Confirm that token allowances are unchanged\n(0, _chai.expect)(await KreskoAsset.allowance(this.owner.address, hre.users.userOne.address)).to.equal(this.mintAmount);",
- "err": {},
- "uuid": "25c9136b-0ee5-46f0-a9c9-fc0a50fad795",
- "parentUUID": "0cc740cd-891c-4071-b8f2-7ed97bc746a9",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should not allow the operator to burn more tokens than user holds",
- "fullTitle": "KreskoAsset #burn should not allow the operator to burn more tokens than user holds",
- "timedOut": false,
- "duration": 11,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const userBalance = await KreskoAsset.balanceOf(hre.users.userOne.address);\nconst overUserBalance = Number(userBalance) + 1;\nawait (0, _chai.expect)(KreskoAsset.connect(this.owner).burn(hre.users.userOne.address, overUserBalance)).to.be.reverted;\n// Check total supply and user's balances are unchanged\n(0, _chai.expect)(await KreskoAsset.totalSupply()).to.equal(this.mintAmount);\n(0, _chai.expect)(await KreskoAsset.balanceOf(hre.users.userOne.address)).to.equal(this.mintAmount);",
- "err": {},
- "uuid": "63673783-2ed6-465f-879a-a57cc2c655fa",
- "parentUUID": "0cc740cd-891c-4071-b8f2-7ed97bc746a9",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should not allow non-operator addresses to burn tokens",
- "fullTitle": "KreskoAsset #burn should not allow non-operator addresses to burn tokens",
- "timedOut": false,
- "duration": 13,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await (0, _chai.expect)(KreskoAsset.connect(hre.users.userTwo).burn(hre.users.userOne.address, this.mintAmount)).to.be.revertedWithCustomError(KreskoAsset, 'AccessControlUnauthorizedAccount').withArgs(hre.users.userTwo.address, _roles.Role.OPERATOR);\n// Check total supply and user's balances unchanged\n(0, _chai.expect)(await KreskoAsset.totalSupply()).to.equal(this.mintAmount);\n(0, _chai.expect)(await KreskoAsset.balanceOf(hre.users.userOne.address)).to.equal(this.mintAmount);",
- "err": {},
- "uuid": "0da25539-7a46-45ed-8db8-9c5e3c304c5e",
- "parentUUID": "0cc740cd-891c-4071-b8f2-7ed97bc746a9",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "d87975bd-ebfe-4296-b924-bf19feec4092",
- "25c9136b-0ee5-46f0-a9c9-fc0a50fad795",
- "63673783-2ed6-465f-879a-a57cc2c655fa",
- "0da25539-7a46-45ed-8db8-9c5e3c304c5e"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 67,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "32ca020d-eed4-45fc-ad89-ec7e0645eb9a",
- "title": "KreskoAsset",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/krasset/02-krasset.ts",
- "file": "/src/test/krasset/02-krasset.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"KreskoAsset\"",
- "fullTitle": "KreskoAsset \"before each\" hook in \"KreskoAsset\"",
- "timedOut": false,
- "duration": 806,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const result = await hre.deployments.fixture('diamond-init');\nif (result.Diamond) {\n hre.Diamond = (0, _redstone.wrapKresko)(await hre.getContractOrFork('Kresko'));\n}\nKreskoAsset = (await (0, _createkrasset.createKrAsset)('krSYMBOL', 'Kresko Asset: SYMBOL', 18, _viem.zeroAddress)).KreskoAsset;\n// Grant minting rights for test deployer\nawait KreskoAsset.grantRole(_roles.Role.OPERATOR, hre.addr.deployer);",
- "err": {},
- "uuid": "39bd3139-5995-4eda-ae7b-6f7cc714bace",
- "parentUUID": "32ca020d-eed4-45fc-ad89-ec7e0645eb9a",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [],
- "suites": [
- {
- "uuid": "aabe6cea-b4bb-4169-bc0d-853ca0706b68",
- "title": "#rebase",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/krasset/02-krasset.ts",
- "file": "/src/test/krasset/02-krasset.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "can set a positive rebase",
- "fullTitle": "KreskoAsset #rebase can set a positive rebase",
- "timedOut": false,
- "duration": 10,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const denominator = (0, _values.toBig)('1.525');\nconst positive = true;\nawait (0, _chai.expect)(KreskoAsset.rebase(denominator, positive, [])).to.not.be.reverted;\n(0, _chai.expect)(await KreskoAsset.isRebased()).to.equal(true);\nconst rebaseInfo = await KreskoAsset.rebaseInfo();\n(0, _chai.expect)(rebaseInfo.denominator).equal(denominator);\n(0, _chai.expect)(rebaseInfo.positive).equal(true);",
- "err": {},
- "uuid": "c8782fa7-df83-4c3d-9e8e-81a094b38224",
- "parentUUID": "aabe6cea-b4bb-4169-bc0d-853ca0706b68",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "can set a negative rebase",
- "fullTitle": "KreskoAsset #rebase can set a negative rebase",
- "timedOut": false,
- "duration": 11,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const denominator = (0, _values.toBig)('1.525');\nconst positive = false;\nawait (0, _chai.expect)(KreskoAsset.rebase(denominator, positive, [])).to.not.be.reverted;\n(0, _chai.expect)(await KreskoAsset.isRebased()).to.equal(true);\nconst rebaseInfo = await KreskoAsset.rebaseInfo();\n(0, _chai.expect)(rebaseInfo.denominator).equal(denominator);\n(0, _chai.expect)(rebaseInfo.positive).equal(false);",
- "err": {},
- "uuid": "6b8a7847-16f6-47e2-b3b2-8660c40963b9",
- "parentUUID": "aabe6cea-b4bb-4169-bc0d-853ca0706b68",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "can be disabled by setting the denominator to 1 ether",
- "fullTitle": "KreskoAsset #rebase can be disabled by setting the denominator to 1 ether",
- "timedOut": false,
- "duration": 8,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const denominator = (0, _values.toBig)(1);\nconst positive = false;\nawait (0, _chai.expect)(KreskoAsset.rebase(denominator, positive, [])).to.not.be.reverted;\n(0, _chai.expect)(await KreskoAsset.isRebased()).to.equal(false);",
- "err": {},
- "uuid": "3dd65746-3087-42f2-96d9-1b65bab4941c",
- "parentUUID": "aabe6cea-b4bb-4169-bc0d-853ca0706b68",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [
- {
- "uuid": "fbe82f44-5b50-4b58-ae82-601441d428d4",
- "title": "#balance + supply",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/krasset/02-krasset.ts",
- "file": "/src/test/krasset/02-krasset.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "has no effect when not enabled",
- "fullTitle": "KreskoAsset #rebase #balance + supply has no effect when not enabled",
- "timedOut": false,
- "duration": 10,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await KreskoAsset.mint(hre.addr.deployer, _mocks.defaultMintAmount);\n(0, _chai.expect)(await KreskoAsset.isRebased()).to.equal(false);\n(0, _chai.expect)(await KreskoAsset.balanceOf(hre.addr.deployer)).to.equal(_mocks.defaultMintAmount);",
- "err": {},
- "uuid": "9777cd81-425e-4794-803b-beffadefc2ee",
- "parentUUID": "fbe82f44-5b50-4b58-ae82-601441d428d4",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "increases balance and supply with positive rebase @ 2",
- "fullTitle": "KreskoAsset #rebase #balance + supply increases balance and supply with positive rebase @ 2",
- "timedOut": false,
- "duration": 15,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const denominator = 2;\nconst positive = true;\nawait KreskoAsset.mint(hre.addr.deployer, _mocks.defaultMintAmount);\nawait KreskoAsset.rebase((0, _values.toBig)(denominator), positive, []);\n(0, _chai.expect)(await KreskoAsset.balanceOf(hre.addr.deployer)).to.equal(_mocks.defaultMintAmount.mul(denominator));\n(0, _chai.expect)(await KreskoAsset.totalSupply()).to.equal(_mocks.defaultMintAmount.mul(denominator));",
- "err": {},
- "uuid": "bf798c46-07b1-4a20-87d3-0359385df14c",
- "parentUUID": "fbe82f44-5b50-4b58-ae82-601441d428d4",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "increases balance and supply with positive rebase @ 3",
- "fullTitle": "KreskoAsset #rebase #balance + supply increases balance and supply with positive rebase @ 3",
- "timedOut": false,
- "duration": 15,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const denominator = 3;\nconst positive = true;\nawait KreskoAsset.mint(hre.addr.deployer, _mocks.defaultMintAmount);\nawait KreskoAsset.rebase((0, _values.toBig)(denominator), positive, []);\n(0, _chai.expect)(await KreskoAsset.balanceOf(hre.addr.deployer)).to.equal(_mocks.defaultMintAmount.mul(denominator));\n(0, _chai.expect)(await KreskoAsset.totalSupply()).to.equal(_mocks.defaultMintAmount.mul(denominator));",
- "err": {},
- "uuid": "bdbf06a5-7048-4612-9381-5e6d23bca378",
- "parentUUID": "fbe82f44-5b50-4b58-ae82-601441d428d4",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "increases balance and supply with positive rebase @ 100",
- "fullTitle": "KreskoAsset #rebase #balance + supply increases balance and supply with positive rebase @ 100",
- "timedOut": false,
- "duration": 17,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const denominator = 100;\nconst positive = true;\nawait KreskoAsset.mint(hre.addr.deployer, _mocks.defaultMintAmount);\nawait KreskoAsset.rebase((0, _values.toBig)(denominator), positive, []);\n(0, _chai.expect)(await KreskoAsset.balanceOf(hre.addr.deployer)).to.equal(_mocks.defaultMintAmount.mul(denominator));\n(0, _chai.expect)(await KreskoAsset.totalSupply()).to.equal(_mocks.defaultMintAmount.mul(denominator));",
- "err": {},
- "uuid": "569eca8f-5ebf-4331-8e1d-9d5e5a78b5c3",
- "parentUUID": "fbe82f44-5b50-4b58-ae82-601441d428d4",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "reduces balance and supply with negative rebase @ 2",
- "fullTitle": "KreskoAsset #rebase #balance + supply reduces balance and supply with negative rebase @ 2",
- "timedOut": false,
- "duration": 16,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const denominator = 2;\nconst positive = false;\nawait KreskoAsset.mint(hre.addr.deployer, _mocks.defaultMintAmount);\nawait KreskoAsset.rebase((0, _values.toBig)(denominator), positive, []);\n(0, _chai.expect)(await KreskoAsset.balanceOf(hre.addr.deployer)).to.equal(_mocks.defaultMintAmount.div(denominator));\n(0, _chai.expect)(await KreskoAsset.totalSupply()).to.equal(_mocks.defaultMintAmount.div(denominator));",
- "err": {},
- "uuid": "79e94649-b3e6-4d2b-9591-6787a68b9abb",
- "parentUUID": "fbe82f44-5b50-4b58-ae82-601441d428d4",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "reduces balance and supply with negative rebase @ 3",
- "fullTitle": "KreskoAsset #rebase #balance + supply reduces balance and supply with negative rebase @ 3",
- "timedOut": false,
- "duration": 15,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const denominator = 3;\nconst positive = false;\nawait KreskoAsset.mint(hre.addr.deployer, _mocks.defaultMintAmount);\nawait KreskoAsset.rebase((0, _values.toBig)(denominator), positive, []);\n(0, _chai.expect)(await KreskoAsset.balanceOf(hre.addr.deployer)).to.equal(_mocks.defaultMintAmount.div(denominator));\n(0, _chai.expect)(await KreskoAsset.totalSupply()).to.equal(_mocks.defaultMintAmount.div(denominator));",
- "err": {},
- "uuid": "9eaaa7a2-7e24-496e-94ac-046ae0c5a55c",
- "parentUUID": "fbe82f44-5b50-4b58-ae82-601441d428d4",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "reduces balance and supply with negative rebase @ 100",
- "fullTitle": "KreskoAsset #rebase #balance + supply reduces balance and supply with negative rebase @ 100",
- "timedOut": false,
- "duration": 14,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const denominator = 100;\nconst positive = false;\nawait KreskoAsset.mint(hre.addr.deployer, _mocks.defaultMintAmount);\nawait KreskoAsset.rebase((0, _values.toBig)(denominator), positive, []);\n(0, _chai.expect)(await KreskoAsset.balanceOf(hre.addr.deployer)).to.equal(_mocks.defaultMintAmount.div(denominator));\n(0, _chai.expect)(await KreskoAsset.totalSupply()).to.equal(_mocks.defaultMintAmount.div(denominator));",
- "err": {},
- "uuid": "3cba8b20-e225-4793-979f-ead5ff23a1d8",
- "parentUUID": "fbe82f44-5b50-4b58-ae82-601441d428d4",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "9777cd81-425e-4794-803b-beffadefc2ee",
- "bf798c46-07b1-4a20-87d3-0359385df14c",
- "bdbf06a5-7048-4612-9381-5e6d23bca378",
- "569eca8f-5ebf-4331-8e1d-9d5e5a78b5c3",
- "79e94649-b3e6-4d2b-9591-6787a68b9abb",
- "9eaaa7a2-7e24-496e-94ac-046ae0c5a55c",
- "3cba8b20-e225-4793-979f-ead5ff23a1d8"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 102,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "3c889de4-d859-4a63-b52a-23ab89d568ed",
- "title": "#transfer",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/krasset/02-krasset.ts",
- "file": "/src/test/krasset/02-krasset.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "has default transfer behaviour after positive rebase",
- "fullTitle": "KreskoAsset #rebase #transfer has default transfer behaviour after positive rebase",
- "timedOut": false,
- "duration": 23,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const transferAmount = (0, _values.toBig)(1);\nawait KreskoAsset.mint(hre.addr.deployer, _mocks.defaultMintAmount);\nawait KreskoAsset.mint(hre.addr.userOne, _mocks.defaultMintAmount);\nconst denominator = 2;\nconst positive = true;\nawait KreskoAsset.rebase((0, _values.toBig)(denominator), positive, []);\nconst rebaseInfodDefaultMintAMount = _mocks.defaultMintAmount.mul(denominator);\nawait KreskoAsset.transfer(hre.addr.userOne, transferAmount);\n(0, _chai.expect)(await KreskoAsset.balanceOf(hre.addr.userOne)).to.equal(rebaseInfodDefaultMintAMount.add(transferAmount));\n(0, _chai.expect)(await KreskoAsset.balanceOf(hre.addr.deployer)).to.equal(rebaseInfodDefaultMintAMount.sub(transferAmount));",
- "err": {},
- "uuid": "8a50c650-512c-4710-b579-0e1f908cbd29",
- "parentUUID": "3c889de4-d859-4a63-b52a-23ab89d568ed",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "has default transfer behaviour after negative rebase",
- "fullTitle": "KreskoAsset #rebase #transfer has default transfer behaviour after negative rebase",
- "timedOut": false,
- "duration": 23,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const transferAmount = (0, _values.toBig)(1);\nawait KreskoAsset.mint(hre.addr.deployer, _mocks.defaultMintAmount);\nawait KreskoAsset.mint(hre.addr.userOne, _mocks.defaultMintAmount);\nconst denominator = 2;\nconst positive = false;\nawait KreskoAsset.rebase((0, _values.toBig)(denominator), positive, []);\nconst rebaseInfodDefaultMintAMount = _mocks.defaultMintAmount.div(denominator);\nawait KreskoAsset.transfer(hre.addr.userOne, transferAmount);\n(0, _chai.expect)(await KreskoAsset.balanceOf(hre.addr.userOne)).to.equal(rebaseInfodDefaultMintAMount.add(transferAmount));\n(0, _chai.expect)(await KreskoAsset.balanceOf(hre.addr.deployer)).to.equal(rebaseInfodDefaultMintAMount.sub(transferAmount));",
- "err": {},
- "uuid": "8a003e75-c38c-43ab-9616-29299bdea359",
- "parentUUID": "3c889de4-d859-4a63-b52a-23ab89d568ed",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "has default transferFrom behaviour after positive rebase",
- "fullTitle": "KreskoAsset #rebase #transfer has default transferFrom behaviour after positive rebase",
- "timedOut": false,
- "duration": 40,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const transferAmount = (0, _values.toBig)(1);\nawait KreskoAsset.mint(hre.addr.deployer, _mocks.defaultMintAmount);\nawait KreskoAsset.mint(hre.addr.userOne, _mocks.defaultMintAmount);\nconst denominator = 2;\nconst positive = true;\nawait KreskoAsset.rebase((0, _values.toBig)(denominator), positive, []);\nawait KreskoAsset.approve(hre.addr.userOne, transferAmount);\nconst rebaseInfodDefaultMintAMount = _mocks.defaultMintAmount.mul(denominator);\nawait KreskoAsset.connect(hre.users.userOne).transferFrom(hre.addr.deployer, hre.addr.userOne, transferAmount);\n(0, _chai.expect)(await KreskoAsset.balanceOf(hre.addr.userOne)).to.equal(rebaseInfodDefaultMintAMount.add(transferAmount));\n(0, _chai.expect)(await KreskoAsset.balanceOf(hre.addr.deployer)).to.equal(rebaseInfodDefaultMintAMount.sub(transferAmount));\nawait (0, _chai.expect)(KreskoAsset.connect(hre.users.userOne).transferFrom(hre.addr.deployer, hre.addr.userOne, transferAmount)).to.be.reverted;\n(0, _chai.expect)(await KreskoAsset.allowance(hre.addr.deployer, hre.addr.userOne)).to.equal(0);",
- "err": {},
- "uuid": "13cfbc53-e2b8-44b9-bfab-d1d11bb712fa",
- "parentUUID": "3c889de4-d859-4a63-b52a-23ab89d568ed",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "has default transferFrom behaviour after positive rebase @ 100",
- "fullTitle": "KreskoAsset #rebase #transfer has default transferFrom behaviour after positive rebase @ 100",
- "timedOut": false,
- "duration": 37,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const transferAmount = (0, _values.toBig)(1);\nawait KreskoAsset.mint(hre.addr.deployer, _mocks.defaultMintAmount);\nawait KreskoAsset.mint(hre.addr.userOne, _mocks.defaultMintAmount);\nconst denominator = 100;\nconst positive = true;\nawait KreskoAsset.rebase((0, _values.toBig)(denominator), positive, []);\nawait KreskoAsset.approve(hre.addr.userOne, transferAmount);\nconst rebaseInfodDefaultMintAMount = _mocks.defaultMintAmount.mul(denominator);\nawait KreskoAsset.connect(hre.users.userOne).transferFrom(hre.addr.deployer, hre.addr.userOne, transferAmount);\n(0, _chai.expect)(await KreskoAsset.balanceOf(hre.addr.userOne)).to.equal(rebaseInfodDefaultMintAMount.add(transferAmount));\n(0, _chai.expect)(await KreskoAsset.balanceOf(hre.addr.deployer)).to.equal(rebaseInfodDefaultMintAMount.sub(transferAmount));\nawait (0, _chai.expect)(KreskoAsset.connect(hre.users.userOne).transferFrom(hre.addr.deployer, hre.addr.userOne, transferAmount)).to.be.reverted;\n(0, _chai.expect)(await KreskoAsset.allowance(hre.addr.deployer, hre.addr.userOne)).to.equal(0);",
- "err": {},
- "uuid": "f42280d5-8df6-49ec-a61f-949456010377",
- "parentUUID": "3c889de4-d859-4a63-b52a-23ab89d568ed",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "has default transferFrom behaviour after negative rebase",
- "fullTitle": "KreskoAsset #rebase #transfer has default transferFrom behaviour after negative rebase",
- "timedOut": false,
- "duration": 37,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const transferAmount = (0, _values.toBig)(1);\nawait KreskoAsset.mint(hre.addr.deployer, _mocks.defaultMintAmount);\nawait KreskoAsset.mint(hre.addr.userOne, _mocks.defaultMintAmount);\nconst denominator = 2;\nconst positive = false;\nawait KreskoAsset.rebase((0, _values.toBig)(denominator), positive, []);\nawait KreskoAsset.approve(hre.addr.userOne, transferAmount);\nconst rebaseInfodDefaultMintAMount = _mocks.defaultMintAmount.div(denominator);\nawait KreskoAsset.connect(hre.users.userOne).transferFrom(hre.addr.deployer, hre.addr.userOne, transferAmount);\n(0, _chai.expect)(await KreskoAsset.balanceOf(hre.addr.userOne)).to.equal(rebaseInfodDefaultMintAMount.add(transferAmount));\n(0, _chai.expect)(await KreskoAsset.balanceOf(hre.addr.deployer)).to.equal(rebaseInfodDefaultMintAMount.sub(transferAmount));\nawait (0, _chai.expect)(KreskoAsset.connect(hre.users.userOne).transferFrom(hre.addr.deployer, hre.addr.userOne, transferAmount)).to.be.reverted;\n(0, _chai.expect)(await KreskoAsset.allowance(hre.addr.deployer, hre.addr.userOne)).to.equal(0);",
- "err": {},
- "uuid": "8ed38e62-47f6-424e-86a3-9a3a7e805bb1",
- "parentUUID": "3c889de4-d859-4a63-b52a-23ab89d568ed",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "has default transferFrom behaviour after negative rebase @ 100",
- "fullTitle": "KreskoAsset #rebase #transfer has default transferFrom behaviour after negative rebase @ 100",
- "timedOut": false,
- "duration": 36,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const transferAmount = (0, _values.toBig)(1);\nawait KreskoAsset.mint(hre.addr.deployer, _mocks.defaultMintAmount);\nawait KreskoAsset.mint(hre.addr.userOne, _mocks.defaultMintAmount);\nconst denominator = 100;\nconst positive = false;\nawait KreskoAsset.rebase((0, _values.toBig)(denominator), positive, []);\nawait KreskoAsset.approve(hre.addr.userOne, transferAmount);\nconst rebaseInfodDefaultMintAMount = _mocks.defaultMintAmount.div(denominator);\nawait KreskoAsset.connect(hre.users.userOne).transferFrom(hre.addr.deployer, hre.addr.userOne, transferAmount);\n(0, _chai.expect)(await KreskoAsset.balanceOf(hre.addr.userOne)).to.equal(rebaseInfodDefaultMintAMount.add(transferAmount));\n(0, _chai.expect)(await KreskoAsset.balanceOf(hre.addr.deployer)).to.equal(rebaseInfodDefaultMintAMount.sub(transferAmount));\nawait (0, _chai.expect)(KreskoAsset.connect(hre.users.userOne).transferFrom(hre.addr.deployer, hre.addr.userOne, transferAmount)).to.be.reverted;\n(0, _chai.expect)(await KreskoAsset.allowance(hre.addr.deployer, hre.addr.userOne)).to.equal(0);",
- "err": {},
- "uuid": "92d16f11-5a41-46b8-9885-3fab64fcbf68",
- "parentUUID": "3c889de4-d859-4a63-b52a-23ab89d568ed",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "8a50c650-512c-4710-b579-0e1f908cbd29",
- "8a003e75-c38c-43ab-9616-29299bdea359",
- "13cfbc53-e2b8-44b9-bfab-d1d11bb712fa",
- "f42280d5-8df6-49ec-a61f-949456010377",
- "8ed38e62-47f6-424e-86a3-9a3a7e805bb1",
- "92d16f11-5a41-46b8-9885-3fab64fcbf68"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 196,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [
- "c8782fa7-df83-4c3d-9e8e-81a094b38224",
- "6b8a7847-16f6-47e2-b3b2-8660c40963b9",
- "3dd65746-3087-42f2-96d9-1b65bab4941c"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 29,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "27e2e97b-488a-4a8e-8a0a-ed02d92e646c",
- "title": "KreskoAssetAnchor",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/krasset/03-krasset-anchor.ts",
- "file": "/src/test/krasset/03-krasset-anchor.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"KreskoAssetAnchor\"",
- "fullTitle": "KreskoAssetAnchor \"before each\" hook in \"KreskoAssetAnchor\"",
- "timedOut": false,
- "duration": 816,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const result = await hre.deployments.fixture('diamond-init');\nif (result.Diamond) {\n hre.Diamond = (0, _redstone.wrapKresko)(await hre.getContractOrFork('Kresko'));\n}\nconst deployments = await (0, _createkrasset.createKrAsset)('krSYMBOL', 'Kresko Asset: SYMBOL', 18, _viem.zeroAddress);\nKreskoAsset = deployments.KreskoAsset;\nKreskoAssetAnchor = deployments.KreskoAssetAnchor;\n// Grant minting rights for test deployer\nawait KreskoAsset.grantRole(_roles.Role.OPERATOR, hre.addr.deployer);\n// Grant minting rights for test deployer\nawait Promise.all([\n KreskoAsset.grantRole(_roles.Role.OPERATOR, hre.addr.deployer),\n KreskoAssetAnchor.grantRole(_roles.Role.OPERATOR, hre.addr.deployer),\n KreskoAsset.approve(KreskoAssetAnchor.address, hre.ethers.constants.MaxUint256)\n]);",
- "err": {},
- "uuid": "7340874c-d0a3-405f-8ab0-fea8e5a82d60",
- "parentUUID": "27e2e97b-488a-4a8e-8a0a-ed02d92e646c",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [],
- "suites": [
- {
- "uuid": "98f8b589-8836-4f22-b6dc-2f66d3bfe6ea",
- "title": "#minting and burning",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/krasset/03-krasset-anchor.ts",
- "file": "/src/test/krasset/03-krasset-anchor.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "tracks the supply of underlying",
- "fullTitle": "KreskoAssetAnchor #minting and burning tracks the supply of underlying",
- "timedOut": false,
- "duration": 21,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await KreskoAsset.mint(hre.addr.deployer, _mocks.defaultMintAmount);\n(0, _chai.expect)(await KreskoAssetAnchor.totalAssets()).to.equal(_mocks.defaultMintAmount);\n(0, _chai.expect)(await KreskoAssetAnchor.totalSupply()).to.equal(0);\nawait KreskoAsset.mint(hre.addr.deployer, _mocks.defaultMintAmount);\n(0, _chai.expect)(await KreskoAssetAnchor.totalAssets()).to.equal(_mocks.defaultMintAmount.add(_mocks.defaultMintAmount));\n(0, _chai.expect)(await KreskoAssetAnchor.totalSupply()).to.equal(0);",
- "err": {},
- "uuid": "f9a346d3-c9bc-44de-84b1-987ebf7f951e",
- "parentUUID": "98f8b589-8836-4f22-b6dc-2f66d3bfe6ea",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "mints 1:1 with no rebases",
- "fullTitle": "KreskoAssetAnchor #minting and burning mints 1:1 with no rebases",
- "timedOut": false,
- "duration": 0,
- "state": "pending",
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": true,
- "context": null,
- "code": "",
- "err": {},
- "uuid": "da0fe64f-d815-4d22-b673-2fea92d35837",
- "parentUUID": "98f8b589-8836-4f22-b6dc-2f66d3bfe6ea",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "deposits 1:1 with no rebases",
- "fullTitle": "KreskoAssetAnchor #minting and burning deposits 1:1 with no rebases",
- "timedOut": false,
- "duration": 0,
- "state": "pending",
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": true,
- "context": null,
- "code": "",
- "err": {},
- "uuid": "27f3e575-9bda-4070-bf65-1c6c18461c4d",
- "parentUUID": "98f8b589-8836-4f22-b6dc-2f66d3bfe6ea",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "redeems 1:1 with no rebases",
- "fullTitle": "KreskoAssetAnchor #minting and burning redeems 1:1 with no rebases",
- "timedOut": false,
- "duration": 0,
- "state": "pending",
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": true,
- "context": null,
- "code": "",
- "err": {},
- "uuid": "071bd043-af34-459c-b0d8-9f5f628a847e",
- "parentUUID": "98f8b589-8836-4f22-b6dc-2f66d3bfe6ea",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "withdraws 1:1 with no rebases",
- "fullTitle": "KreskoAssetAnchor #minting and burning withdraws 1:1 with no rebases",
- "timedOut": false,
- "duration": 0,
- "state": "pending",
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": true,
- "context": null,
- "code": "",
- "err": {},
- "uuid": "d22567a2-6a6b-4e61-8627-157b936dceea",
- "parentUUID": "98f8b589-8836-4f22-b6dc-2f66d3bfe6ea",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [
- {
- "uuid": "6f5fc3f9-b425-4150-9e88-321845d67e36",
- "title": "#rebases",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/krasset/03-krasset-anchor.ts",
- "file": "/src/test/krasset/03-krasset-anchor.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [],
- "suites": [
- {
- "uuid": "fe9a43a2-f5d3-45cb-b475-d2203b6b9ee2",
- "title": "#conversions",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/krasset/03-krasset-anchor.ts",
- "file": "/src/test/krasset/03-krasset-anchor.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "mints 1:1 and redeems 1:2 after 1:2 rebase",
- "fullTitle": "KreskoAssetAnchor #minting and burning #rebases #conversions mints 1:1 and redeems 1:2 after 1:2 rebase",
- "timedOut": false,
- "duration": 0,
- "state": "pending",
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": true,
- "context": null,
- "code": "",
- "err": {},
- "uuid": "f5708c02-02d3-41b4-8747-c7604e362d94",
- "parentUUID": "fe9a43a2-f5d3-45cb-b475-d2203b6b9ee2",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "deposits 1:1 and withdraws 1:2 after 1:2 rebase",
- "fullTitle": "KreskoAssetAnchor #minting and burning #rebases #conversions deposits 1:1 and withdraws 1:2 after 1:2 rebase",
- "timedOut": false,
- "duration": 0,
- "state": "pending",
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": true,
- "context": null,
- "code": "",
- "err": {},
- "uuid": "3318b040-1bf3-40b1-b772-41017d4bc0dc",
- "parentUUID": "fe9a43a2-f5d3-45cb-b475-d2203b6b9ee2",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "mints 1:1 and redeems 1:6 after 1:6 rebase",
- "fullTitle": "KreskoAssetAnchor #minting and burning #rebases #conversions mints 1:1 and redeems 1:6 after 1:6 rebase",
- "timedOut": false,
- "duration": 0,
- "state": "pending",
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": true,
- "context": null,
- "code": "",
- "err": {},
- "uuid": "3b5c2a4d-ff9f-422c-ad67-b8e6dbafe306",
- "parentUUID": "fe9a43a2-f5d3-45cb-b475-d2203b6b9ee2",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "deposits 1:1 and withdraws 1:6 after 1:6 rebase",
- "fullTitle": "KreskoAssetAnchor #minting and burning #rebases #conversions deposits 1:1 and withdraws 1:6 after 1:6 rebase",
- "timedOut": false,
- "duration": 0,
- "state": "pending",
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": true,
- "context": null,
- "code": "",
- "err": {},
- "uuid": "1a406f64-954e-4826-a323-17b8b163286f",
- "parentUUID": "fe9a43a2-f5d3-45cb-b475-d2203b6b9ee2",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "mints 1:1 and redeems 2:1 after 2:1 rebase",
- "fullTitle": "KreskoAssetAnchor #minting and burning #rebases #conversions mints 1:1 and redeems 2:1 after 2:1 rebase",
- "timedOut": false,
- "duration": 0,
- "state": "pending",
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": true,
- "context": null,
- "code": "",
- "err": {},
- "uuid": "7becacbf-6d71-4337-b317-fa4a48f4b28e",
- "parentUUID": "fe9a43a2-f5d3-45cb-b475-d2203b6b9ee2",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "deposits 1:1 and withdraws 2:1 after 2:1 rebase",
- "fullTitle": "KreskoAssetAnchor #minting and burning #rebases #conversions deposits 1:1 and withdraws 2:1 after 2:1 rebase",
- "timedOut": false,
- "duration": 0,
- "state": "pending",
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": true,
- "context": null,
- "code": "",
- "err": {},
- "uuid": "054992b6-673b-48ee-bb37-df7d52321647",
- "parentUUID": "fe9a43a2-f5d3-45cb-b475-d2203b6b9ee2",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "mints 1:1 and redeems 6:1 after 6:1 rebase",
- "fullTitle": "KreskoAssetAnchor #minting and burning #rebases #conversions mints 1:1 and redeems 6:1 after 6:1 rebase",
- "timedOut": false,
- "duration": 0,
- "state": "pending",
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": true,
- "context": null,
- "code": "",
- "err": {},
- "uuid": "e8497b73-b4c1-4cb5-b596-1764c0c8d5f4",
- "parentUUID": "fe9a43a2-f5d3-45cb-b475-d2203b6b9ee2",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "deposits 1:1 and withdraws 6:1 after 6:1 rebase",
- "fullTitle": "KreskoAssetAnchor #minting and burning #rebases #conversions deposits 1:1 and withdraws 6:1 after 6:1 rebase",
- "timedOut": false,
- "duration": 0,
- "state": "pending",
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": true,
- "context": null,
- "code": "",
- "err": {},
- "uuid": "0c03fc30-9be9-4de0-aae3-2aaaf0b05bb5",
- "parentUUID": "fe9a43a2-f5d3-45cb-b475-d2203b6b9ee2",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [],
- "failures": [],
- "pending": [
- "f5708c02-02d3-41b4-8747-c7604e362d94",
- "3318b040-1bf3-40b1-b772-41017d4bc0dc",
- "3b5c2a4d-ff9f-422c-ad67-b8e6dbafe306",
- "1a406f64-954e-4826-a323-17b8b163286f",
- "7becacbf-6d71-4337-b317-fa4a48f4b28e",
- "054992b6-673b-48ee-bb37-df7d52321647",
- "e8497b73-b4c1-4cb5-b596-1764c0c8d5f4",
- "0c03fc30-9be9-4de0-aae3-2aaaf0b05bb5"
- ],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [
- "f9a346d3-c9bc-44de-84b1-987ebf7f951e"
- ],
- "failures": [],
- "pending": [
- "da0fe64f-d815-4d22-b673-2fea92d35837",
- "27f3e575-9bda-4070-bf65-1c6c18461c4d",
- "071bd043-af34-459c-b0d8-9f5f628a847e",
- "d22567a2-6a6b-4e61-8627-157b936dceea"
- ],
- "skipped": [],
- "duration": 21,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "f1b6ac21-6aab-4b40-9d5e-0f892ae26472",
- "title": "Test KreskoAsset with Rebase and sync",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/krasset/04-krasset-sync-rebase.ts",
- "file": "/src/test/krasset/04-krasset-sync-rebase.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "Rebases the asset with no sync of uniswap pools - Reserves not updated",
- "fullTitle": "Test KreskoAsset with Rebase and sync Rebases the asset with no sync of uniswap pools - Reserves not updated",
- "timedOut": false,
- "duration": 0,
- "state": "pending",
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": true,
- "context": null,
- "code": "",
- "err": {},
- "uuid": "5271a128-a2f2-40c2-b4c1-569023ec9113",
- "parentUUID": "f1b6ac21-6aab-4b40-9d5e-0f892ae26472",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "Rebases the asset with sync of uniswap pools - Reserve should be updated",
- "fullTitle": "Test KreskoAsset with Rebase and sync Rebases the asset with sync of uniswap pools - Reserve should be updated",
- "timedOut": false,
- "duration": 0,
- "state": "pending",
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": true,
- "context": null,
- "code": "",
- "err": {},
- "uuid": "f920c6ed-eef0-4c8f-8960-93cdcba90017",
- "parentUUID": "f1b6ac21-6aab-4b40-9d5e-0f892ae26472",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [],
- "failures": [],
- "pending": [
- "5271a128-a2f2-40c2-b4c1-569023ec9113",
- "f920c6ed-eef0-4c8f-8960-93cdcba90017"
- ],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "d32ef596-558f-44fe-8409-6a0be11c0b66",
- "title": "KreskoAsset",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/krasset/05-krasset-wrap.ts",
- "file": "/src/test/krasset/05-krasset-wrap.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"KreskoAsset\"",
- "fullTitle": "KreskoAsset \"before each\" hook in \"KreskoAsset\"",
- "timedOut": false,
- "duration": 44,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "operator = hre.users.deployer;\nuser = hre.users.userOne;\ntreasury = hre.addr.treasury;\n({ KreskoAsset } = await (0, _fixtures.kreskoAssetFixture)({\n name: 'Ether',\n symbol: 'krETH'\n}));\n// Deploy WETH\nWETH = await hre.ethers.deployContract('WETH9');\n// Give WETH to deployer\nawait WETH.connect(user).deposit({\n value: (0, _values.toBig)(100)\n});\nawait KreskoAsset.connect(hre.users.deployer).grantRole(_roles.Role.OPERATOR, operator.address);\nawait KreskoAsset.connect(hre.users.deployer).setUnderlying(WETH.address);\n// Approve WETH for KreskoAsset\nawait WETH.connect(user).approve(KreskoAsset.address, hre.ethers.constants.MaxUint256);",
- "err": {},
- "uuid": "bcb6b5f2-4aa2-4b6a-8c79-9794accab5a0",
- "parentUUID": "d32ef596-558f-44fe-8409-6a0be11c0b66",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [],
- "suites": [
- {
- "uuid": "38e5ea11-3338-4e01-8541-336569b626ff",
- "title": "Deposit / Wrap",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/krasset/05-krasset-wrap.ts",
- "file": "/src/test/krasset/05-krasset-wrap.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "cannot deposit when paused",
- "fullTitle": "KreskoAsset Deposit / Wrap cannot deposit when paused",
- "timedOut": false,
- "duration": 14,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await KreskoAsset.connect(operator).pause();\nawait (0, _chai.expect)(KreskoAsset.wrap(user.address, (0, _values.toBig)(10))).to.be.revertedWithCustomError(KreskoAsset, 'EnforcedPause');\nawait KreskoAsset.connect(operator).unpause();",
- "err": {},
- "uuid": "bc553968-c4aa-412e-b184-0ed740f4522e",
- "parentUUID": "38e5ea11-3338-4e01-8541-336569b626ff",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "can deposit with token",
- "fullTitle": "KreskoAsset Deposit / Wrap can deposit with token",
- "timedOut": false,
- "duration": 12,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await KreskoAsset.connect(user).wrap(user.address, (0, _values.toBig)(10));\n(0, _chai.expect)(await KreskoAsset.balanceOf(user.address)).to.equal((0, _values.toBig)(10));",
- "err": {},
- "uuid": "be10a006-ed91-461e-b8ec-5289fafd02ad",
- "parentUUID": "38e5ea11-3338-4e01-8541-336569b626ff",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "cannot deposit native token if not enabled",
- "fullTitle": "KreskoAsset Deposit / Wrap cannot deposit native token if not enabled",
- "timedOut": false,
- "duration": 6,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await (0, _chai.expect)(user.sendTransaction({\n to: KreskoAsset.address,\n value: (0, _values.toBig)(10)\n})).to.be.reverted;",
- "err": {},
- "uuid": "f3038efc-f5ea-4a0a-827b-0b8ac7baf1cb",
- "parentUUID": "38e5ea11-3338-4e01-8541-336569b626ff",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "can deposit native token if enabled",
- "fullTitle": "KreskoAsset Deposit / Wrap can deposit native token if enabled",
- "timedOut": false,
- "duration": 78,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await KreskoAsset.connect(operator).enableNativeUnderlying(true);\nconst prevBalance = await KreskoAsset.balanceOf(user.address);\nawait user.sendTransaction({\n to: KreskoAsset.address,\n value: (0, _values.toBig)(10)\n});\nconst currentBalance = await KreskoAsset.balanceOf(user.address);\n(0, _chai.expect)(currentBalance.sub(prevBalance)).to.equal((0, _values.toBig)(10));",
- "err": {},
- "uuid": "25aa8d86-4496-4924-881b-20026d9c7a77",
- "parentUUID": "38e5ea11-3338-4e01-8541-336569b626ff",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "transfers the correct fees to feeRecipient",
- "fullTitle": "KreskoAsset Deposit / Wrap transfers the correct fees to feeRecipient",
- "timedOut": false,
- "duration": 136,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await KreskoAsset.connect(operator).setOpenFee(0.1e4);\nawait KreskoAsset.connect(operator).enableNativeUnderlying(true);\nlet prevBalanceDevOne = await KreskoAsset.balanceOf(user.address);\nconst treasuryWETHBal = await WETH.balanceOf(treasury);\nawait KreskoAsset.connect(user).wrap(user.address, (0, _values.toBig)(10));\nlet currentBalanceDevOne = await KreskoAsset.balanceOf(user.address);\nconst currentWETHBalanceTreasury = await WETH.balanceOf(treasury);\n(0, _chai.expect)(currentBalanceDevOne.sub(prevBalanceDevOne)).to.equal((0, _values.toBig)(9));\n(0, _chai.expect)(currentWETHBalanceTreasury.sub(treasuryWETHBal)).to.equal((0, _values.toBig)(1));\nprevBalanceDevOne = await KreskoAsset.balanceOf(user.address);\nconst prevBalanceTreasury = await hre.ethers.provider.getBalance(treasury);\nawait user.sendTransaction({\n to: KreskoAsset.address,\n value: (0, _values.toBig)(10)\n});\ncurrentBalanceDevOne = await KreskoAsset.balanceOf(user.address);\nconst currentBalanceTreasury = await hre.ethers.provider.getBalance(treasury);\n(0, _chai.expect)(currentBalanceDevOne.sub(prevBalanceDevOne)).to.equal((0, _values.toBig)(9));\n(0, _chai.expect)(currentBalanceTreasury.sub(prevBalanceTreasury)).to.equal((0, _values.toBig)(1));\n// Set openfee to 0\nawait KreskoAsset.connect(operator).setOpenFee(0);",
- "err": {},
- "uuid": "821354fe-cd93-43b4-bd7e-f9e629b361ea",
- "parentUUID": "38e5ea11-3338-4e01-8541-336569b626ff",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "bc553968-c4aa-412e-b184-0ed740f4522e",
- "be10a006-ed91-461e-b8ec-5289fafd02ad",
- "f3038efc-f5ea-4a0a-827b-0b8ac7baf1cb",
- "25aa8d86-4496-4924-881b-20026d9c7a77",
- "821354fe-cd93-43b4-bd7e-f9e629b361ea"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 246,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "890c115f-b01f-4a5b-96ee-ab2f1b41c388",
- "title": "Withdraw / Unwrap",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/krasset/05-krasset-wrap.ts",
- "file": "/src/test/krasset/05-krasset-wrap.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"Withdraw / Unwrap\"",
- "fullTitle": "KreskoAsset Withdraw / Unwrap \"before each\" hook in \"Withdraw / Unwrap\"",
- "timedOut": false,
- "duration": 92,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Deposit some tokens here\nawait KreskoAsset.connect(user).wrap(user.address, (0, _values.toBig)(10));\nawait KreskoAsset.connect(operator).enableNativeUnderlying(true);\nawait user.sendTransaction({\n to: KreskoAsset.address,\n value: (0, _values.toBig)(100)\n});",
- "err": {},
- "uuid": "7d30f475-3ced-4b09-a808-42a476bdc0dd",
- "parentUUID": "890c115f-b01f-4a5b-96ee-ab2f1b41c388",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [
- {
- "title": "cannot withdraw when paused",
- "fullTitle": "KreskoAsset Withdraw / Unwrap cannot withdraw when paused",
- "timedOut": false,
- "duration": 12,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await KreskoAsset.connect(operator).pause();\nawait (0, _chai.expect)(KreskoAsset.unwrap((0, _values.toBig)(1), false)).to.be.revertedWithCustomError(KreskoAsset, 'EnforcedPause');\nawait KreskoAsset.connect(operator).unpause();",
- "err": {},
- "uuid": "847388d9-5d7f-4f97-a271-5169dbd0273a",
- "parentUUID": "890c115f-b01f-4a5b-96ee-ab2f1b41c388",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "can withdraw",
- "fullTitle": "KreskoAsset Withdraw / Unwrap can withdraw",
- "timedOut": false,
- "duration": 17,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const prevBalance = await WETH.balanceOf(user.address);\nawait KreskoAsset.connect(user).unwrap((0, _values.toBig)(1), false);\nconst currentBalance = await WETH.balanceOf(user.address);\n(0, _chai.expect)(currentBalance).to.equal((0, _values.toBig)(1).add(prevBalance));",
- "err": {},
- "uuid": "2c7fc8e0-a31a-442e-8def-a3fc06150ee1",
- "parentUUID": "890c115f-b01f-4a5b-96ee-ab2f1b41c388",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "can withdraw native token if enabled",
- "fullTitle": "KreskoAsset Withdraw / Unwrap can withdraw native token if enabled",
- "timedOut": false,
- "duration": 22,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await KreskoAsset.connect(operator).enableNativeUnderlying(true);\nconst prevBalance = await KreskoAsset.balanceOf(user.address);\nawait KreskoAsset.connect(user).unwrap((0, _values.toBig)(1), true);\nconst currentBalance = await KreskoAsset.balanceOf(user.address);\n(0, _chai.expect)(prevBalance.sub(currentBalance)).to.equal((0, _values.toBig)(1));",
- "err": {},
- "uuid": "bbf37069-befd-46b5-8a66-db2e12dfc496",
- "parentUUID": "890c115f-b01f-4a5b-96ee-ab2f1b41c388",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "transfers the correct fees to feeRecipient",
- "fullTitle": "KreskoAsset Withdraw / Unwrap transfers the correct fees to feeRecipient",
- "timedOut": false,
- "duration": 119,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// set close fee to 10%\nawait KreskoAsset.connect(operator).setCloseFee(0.1e4);\nconst prevBalanceDevOne = await WETH.balanceOf(user.address);\nlet prevBalanceTreasury = await WETH.balanceOf(treasury);\nawait KreskoAsset.connect(user).unwrap((0, _values.toBig)(9), false);\nconst currentBalanceDevOne = await WETH.balanceOf(user.address);\nlet currentBalanceTreasury = await WETH.balanceOf(treasury);\n(0, _chai.expect)(currentBalanceDevOne.sub(prevBalanceDevOne)).to.equal((0, _values.toBig)(8.1));\n(0, _chai.expect)(currentBalanceTreasury.sub(prevBalanceTreasury)).to.equal((0, _values.toBig)(0.9));\n// Withdraw native token and check if fee is transferred\nawait user.sendTransaction({\n to: KreskoAsset.address,\n value: (0, _values.toBig)(10)\n});\nprevBalanceTreasury = await hre.ethers.provider.getBalance(treasury);\nawait KreskoAsset.connect(user).unwrap((0, _values.toBig)(9), true);\ncurrentBalanceTreasury = await hre.ethers.provider.getBalance(treasury);\n(0, _chai.expect)(currentBalanceTreasury.sub(prevBalanceTreasury)).to.equal((0, _values.toBig)(0.9));",
- "err": {},
- "uuid": "b0f3e5cf-8c68-427e-9cd0-550736e6b517",
- "parentUUID": "890c115f-b01f-4a5b-96ee-ab2f1b41c388",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "847388d9-5d7f-4f97-a271-5169dbd0273a",
- "2c7fc8e0-a31a-442e-8def-a3fc06150ee1",
- "bbf37069-befd-46b5-8a66-db2e12dfc496",
- "b0f3e5cf-8c68-427e-9cd0-550736e6b517"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 170,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "cf4de65c-a7d9-482c-b338-c710995867d5",
- "title": "Minter - Configuration",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/01-configuration.ts",
- "file": "/src/test/minter/01-configuration.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"Minter - Configuration\"",
- "fullTitle": "Minter - Configuration \"before each\" hook in \"Minter - Configuration\"",
- "timedOut": false,
- "duration": 1,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "f = await (0, _fixtures.defaultFixture)();",
- "err": {},
- "uuid": "5f19cd9f-bfb9-4220-9947-e17519b33c36",
- "parentUUID": "cf4de65c-a7d9-482c-b338-c710995867d5",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [],
- "suites": [
- {
- "uuid": "7b9ac396-625f-4661-8912-d3fdd3e20886",
- "title": "#configuration",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/01-configuration.ts",
- "file": "/src/test/minter/01-configuration.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "can modify all parameters",
- "fullTitle": "Minter - Configuration #configuration can modify all parameters",
- "timedOut": false,
- "duration": 155,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const update = (0, _mocks.testMinterParams)(hre.users.treasury.address);\nawait (0, _chai.expect)(hre.Diamond.setMinCollateralRatioMinter(update.minCollateralRatio)).to.not.be.reverted;\nawait (0, _chai.expect)(hre.Diamond.setLiquidationThresholdMinter(update.liquidationThreshold)).to.not.be.reverted;\nawait (0, _chai.expect)(hre.Diamond.setMaxLiquidationRatioMinter(update.maxLiquidationRatio)).to.not.be.reverted;\nconst params = await hre.Diamond.getParametersMinter();\n(0, _chai.expect)(update.minCollateralRatio).to.equal(params.minCollateralRatio);\n(0, _chai.expect)(update.maxLiquidationRatio).to.equal(params.maxLiquidationRatio);\n(0, _chai.expect)(update.liquidationThreshold).to.equal(params.liquidationThreshold);",
- "err": {},
- "uuid": "fdd8e890-c17b-4ef5-b14b-d40b5e107511",
- "parentUUID": "7b9ac396-625f-4661-8912-d3fdd3e20886",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "can add a collateral asset",
- "fullTitle": "Minter - Configuration #configuration can add a collateral asset",
- "timedOut": false,
- "duration": 742,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const { contract } = await (0, _collaterals.addMockExtAsset)(_mocks.testCollateralConfig);\n(0, _chai.expect)(await hre.Diamond.getCollateralExists(contract.address)).to.equal(true);\nconst priceOfOne = await hre.Diamond.getValue(contract.address, (0, _values.toBig)(1));\n(0, _chai.expect)(Number(priceOfOne)).to.equal((0, _values.toBig)(_mocks.testCollateralConfig.price, 8));",
- "err": {},
- "uuid": "a890c911-6809-4a3a-b263-ed1ca7346ca1",
- "parentUUID": "7b9ac396-625f-4661-8912-d3fdd3e20886",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "can add a kresko asset",
- "fullTitle": "Minter - Configuration #configuration can add a kresko asset",
- "timedOut": false,
- "duration": 1209,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const { contract, assetInfo } = await (0, _krassets.addMockKreskoAsset)({\n ..._mocks.testKrAssetConfig,\n name: 'Kresko Asset: 5',\n symbol: 'KrAsset5',\n ticker: 'KrAsset5'\n});\nconst values = await assetInfo();\nconst kreskoPriceAnswer = (0, _values.fromBig)(await hre.Diamond.getValue(contract.address, (0, _values.toBig)(1)), 8);\nconst config = _mocks.testKrAssetConfig.krAssetConfig;\n(0, _chai.expect)(values.isMinterMintable).to.equal(true);\n(0, _chai.expect)(values.kFactor).to.equal(config.kFactor);\n(0, _chai.expect)(kreskoPriceAnswer).to.equal(_mocks.testKrAssetConfig.price);\n(0, _chai.expect)(values.maxDebtMinter).to.equal(config.maxDebtMinter);\n(0, _chai.expect)(values.closeFee).to.equal(config.closeFee);\n(0, _chai.expect)(values.openFee).to.equal(config.openFee);",
- "err": {},
- "uuid": "e0f7ecf0-8022-462c-bdfa-0494b9e21b29",
- "parentUUID": "7b9ac396-625f-4661-8912-d3fdd3e20886",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "can update default oracle precision decimals",
- "fullTitle": "Minter - Configuration #configuration can update default oracle precision decimals",
- "timedOut": false,
- "duration": 71,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const decimals = 8;\nawait hre.Diamond.setDefaultOraclePrecision(decimals);\n(0, _chai.expect)(await hre.Diamond.getDefaultOraclePrecision()).to.equal(decimals);",
- "err": {},
- "uuid": "56df09c0-1ec5-4ea2-abd7-24d7b8b0cba6",
- "parentUUID": "7b9ac396-625f-4661-8912-d3fdd3e20886",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "can update minter max liquidation ratio",
- "fullTitle": "Minter - Configuration #configuration can update minter max liquidation ratio",
- "timedOut": false,
- "duration": 109,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const currentMLM = await hre.Diamond.getMaxLiquidationRatioMinter();\nconst newMLR = 1.42e4;\n(0, _chai.expect)(currentMLM).to.not.eq(newMLR);\nawait (0, _chai.expect)(hre.Diamond.setMaxLiquidationRatioMinter(newMLR)).to.not.be.reverted;\n(0, _chai.expect)(await hre.Diamond.getMaxLiquidationRatioMinter()).to.eq(newMLR);",
- "err": {},
- "uuid": "103a2a42-2457-44ef-a2de-25f8eba18dac",
- "parentUUID": "7b9ac396-625f-4661-8912-d3fdd3e20886",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "can update global oracle deviation pct",
- "fullTitle": "Minter - Configuration #configuration can update global oracle deviation pct",
- "timedOut": false,
- "duration": 104,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const currentDeviationPct = await hre.Diamond.getOracleDeviationPct();\nconst newDeviationPct = 0.03e4;\n(0, _chai.expect)(currentDeviationPct).to.not.equal(newDeviationPct);\nawait (0, _chai.expect)(hre.Diamond.setMaxPriceDeviationPct(newDeviationPct)).to.not.be.reverted;\n(0, _chai.expect)(await hre.Diamond.getOracleDeviationPct()).to.equal(newDeviationPct);",
- "err": {},
- "uuid": "a48c6f9d-de4b-4d6a-8e6b-ce08c9e3ca90",
- "parentUUID": "7b9ac396-625f-4661-8912-d3fdd3e20886",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "can update kFactor of a kresko asset",
- "fullTitle": "Minter - Configuration #configuration can update kFactor of a kresko asset",
- "timedOut": false,
- "duration": 110,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const oldRatio = (await hre.Diamond.getAsset(f.KrAsset.address)).kFactor;\nconst newRatio = 1.2e4;\n(0, _chai.expect)(oldRatio === newRatio).to.be.false;\nawait (0, _chai.expect)(hre.Diamond.setAssetKFactor(f.KrAsset.address, newRatio)).to.not.be.reverted;\n(0, _chai.expect)((await hre.Diamond.getAsset(f.KrAsset.address)).kFactor === newRatio).to.be.true;",
- "err": {},
- "uuid": "09eee61f-c34d-4c32-bdff-aeaa85cf062d",
- "parentUUID": "7b9ac396-625f-4661-8912-d3fdd3e20886",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "can update cFactor of a collateral asset",
- "fullTitle": "Minter - Configuration #configuration can update cFactor of a collateral asset",
- "timedOut": false,
- "duration": 112,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const oldRatio = (await hre.Diamond.getAsset(f.Collateral.address)).factor;\nconst newRatio = 0.9e4;\n(0, _chai.expect)(oldRatio === newRatio).to.be.false;\nawait (0, _chai.expect)(hre.Diamond.setAssetCFactor(f.Collateral.address, newRatio)).to.not.be.reverted;\n(0, _chai.expect)((await hre.Diamond.getAsset(f.Collateral.address)).factor === newRatio).to.be.true;",
- "err": {},
- "uuid": "83d3d364-edab-4fbb-85f4-ddbd36b65d62",
- "parentUUID": "7b9ac396-625f-4661-8912-d3fdd3e20886",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "can update configuration of an asset",
- "fullTitle": "Minter - Configuration #configuration can update configuration of an asset",
- "timedOut": false,
- "duration": 460,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const oracleAnswer = (0, _values.fromBig)((await f.KrAsset.priceFeed.latestRoundData())[1], 8);\nconst priceOfOne = (0, _values.fromBig)(await hre.Diamond.getValue(f.KrAsset.address, (0, _values.toBig)(1)), 8);\n(0, _chai.expect)(oracleAnswer).to.equal(priceOfOne);\n(0, _chai.expect)(oracleAnswer).to.equal(_mocks.testKrAssetConfig.price);\nconst update = {\n kFactor: 1.2e4,\n maxDebtMinter: (0, _values.toBig)(12000),\n closeFee: 0.03e4,\n openFee: 0.03e4,\n anchor: f.KrAsset.anchor.address\n};\nconst FakeFeed = await (0, _oracle.getFakeOracle)(20);\nconst newConfig = await (0, _general.getAssetConfig)(f.KrAsset.contract, {\n ..._mocks.testKrAssetConfig,\n feed: FakeFeed.address,\n price: 20,\n krAssetConfig: update\n});\nawait hre.Diamond.setFeedsForTicker(newConfig.assetStruct.ticker, newConfig.feedConfig);\nawait (0, _general.wrapContractWithSigner)(hre.Diamond, hre.users.deployer).updateAsset(f.KrAsset.address, newConfig.assetStruct);\nconst newValues = await hre.Diamond.getAsset(f.KrAsset.address);\nconst updatedOracleAnswer = (0, _values.fromBig)((await FakeFeed.latestRoundData())[1], 8);\nconst newPriceOfOne = (0, _values.fromBig)(await hre.Diamond.getValue(f.KrAsset.address, (0, _values.toBig)(1)), 8);\n(0, _chai.expect)(newValues.isMinterMintable).to.equal(true);\n(0, _chai.expect)(newValues.isMinterCollateral).to.equal(false);\n(0, _chai.expect)(newValues.kFactor).to.equal(update.kFactor);\n(0, _chai.expect)(newValues.maxDebtMinter).to.equal(update.maxDebtMinter);\n(0, _chai.expect)(updatedOracleAnswer).to.equal(newPriceOfOne);\n(0, _chai.expect)(updatedOracleAnswer).to.equal(20);\nconst update2 = {\n ...await hre.Diamond.getAsset(f.KrAsset.address),\n kFactor: 1.75e4,\n maxDebtMinter: (0, _values.toBig)(12000),\n closeFee: 0.052e4,\n openFee: 0.052e4,\n isSwapMintable: true,\n swapInFeeSCDP: 0.052e4,\n liqIncentiveSCDP: 1.1e4,\n anchor: f.KrAsset.anchor.address\n};\nawait hre.Diamond.updateAsset(f.KrAsset.address, update2);\nconst newValues2 = await hre.Diamond.getAsset(f.KrAsset.address);\n(0, _chai.expect)(newValues2.isMinterMintable).to.equal(true);\n(0, _chai.expect)(newValues2.isSharedOrSwappedCollateral).to.equal(true);\n(0, _chai.expect)(newValues2.isSwapMintable).to.equal(true);\n(0, _chai.expect)(newValues2.isMinterCollateral).to.equal(false);\n(0, _chai.expect)(newValues2.isSharedCollateral).to.equal(false);\n(0, _chai.expect)(newValues2.isCoverAsset).to.equal(false);\n(0, _chai.expect)(newValues2.kFactor).to.equal(update2.kFactor);\n(0, _chai.expect)(newValues2.openFee).to.equal(update2.closeFee);\n(0, _chai.expect)(newValues2.closeFee).to.equal(update2.openFee);\n(0, _chai.expect)(newValues2.swapInFeeSCDP).to.equal(update2.swapInFeeSCDP);\n(0, _chai.expect)(newValues2.maxDebtMinter).to.equal(update2.maxDebtMinter);",
- "err": {},
- "uuid": "57c8b417-51f8-4b2e-81da-d55e09760673",
- "parentUUID": "7b9ac396-625f-4661-8912-d3fdd3e20886",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "fdd8e890-c17b-4ef5-b14b-d40b5e107511",
- "a890c911-6809-4a3a-b263-ed1ca7346ca1",
- "e0f7ecf0-8022-462c-bdfa-0494b9e21b29",
- "56df09c0-1ec5-4ea2-abd7-24d7b8b0cba6",
- "103a2a42-2457-44ef-a2de-25f8eba18dac",
- "a48c6f9d-de4b-4d6a-8e6b-ce08c9e3ca90",
- "09eee61f-c34d-4c32-bdff-aeaa85cf062d",
- "83d3d364-edab-4fbb-85f4-ddbd36b65d62",
- "57c8b417-51f8-4b2e-81da-d55e09760673"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 3072,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "8440a62a-9ede-4aa1-87da-a7e036776b5c",
- "title": "Minter - Deposit Withdraw",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/02-deposit-withdraw.ts",
- "file": "/src/test/minter/02-deposit-withdraw.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"Minter - Deposit Withdraw\"",
- "fullTitle": "Minter - Deposit Withdraw \"before each\" hook in \"Minter - Deposit Withdraw\"",
- "timedOut": false,
- "duration": 1,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "f = await (0, _fixtures.depositWithdrawFixture)();",
- "err": {},
- "uuid": "25b21bb6-2372-4102-9531-9256e7c25611",
- "parentUUID": "8440a62a-9ede-4aa1-87da-a7e036776b5c",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [],
- "suites": [
- {
- "uuid": "cfcdac51-26a2-43d4-923d-4923434a5c54",
- "title": "#collateral",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/02-deposit-withdraw.ts",
- "file": "/src/test/minter/02-deposit-withdraw.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [],
- "suites": [
- {
- "uuid": "1d990730-669c-4d3b-b7c8-3cdf6393f936",
- "title": "#deposit",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/02-deposit-withdraw.ts",
- "file": "/src/test/minter/02-deposit-withdraw.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "reverts withdraws of krAsset collateral when deposits go below MIN_KRASSET_COLLATERAL_AMOUNT",
- "fullTitle": "Minter - Deposit Withdraw #collateral #deposit reverts withdraws of krAsset collateral when deposits go below MIN_KRASSET_COLLATERAL_AMOUNT",
- "timedOut": false,
- "duration": 123,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const collateralAmount = (0, _values.toBig)(100);\nawait f.KrAssetCollateral.setBalance(f.user, collateralAmount, _hardhat.default.Diamond.address);\nconst depositAmount = collateralAmount.div(2);\nawait f.User.depositCollateral(f.user.address, f.KrAssetCollateral.address, depositAmount);\n// Rebase the asset according to params\nconst denominator = 4;\nconst positive = true;\nawait f.KrAssetCollateral.contract.rebase((0, _values.toBig)(denominator), positive, []);\nconst rebasedDepositAmount = depositAmount.mul(denominator);\nconst withdrawAmount = rebasedDepositAmount.sub(9e11.toString());\n(0, _chai.expect)(await _hardhat.default.Diamond.getAccountCollateralAssets(f.user.address)).to.include(f.KrAssetCollateral.address);\nawait (0, _chai.expect)(f.User.withdrawCollateral(f.user.address, f.KrAssetCollateral.address, withdrawAmount, 0)).to.be.revertedWithCustomError((0, _errors.Errors)(_hardhat.default), 'COLLATERAL_AMOUNT_LOW').withArgs(f.KrAssetCollateral.errorId, 9e11, 1e12);",
- "err": {},
- "uuid": "4032c0d5-ad8d-4a32-bdd9-c9bb57ad4afb",
- "parentUUID": "1d990730-669c-4d3b-b7c8-3cdf6393f936",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "reverts deposits of krAsset collateral for less than MIN_KRASSET_COLLATERAL_AMOUNT",
- "fullTitle": "Minter - Deposit Withdraw #collateral #deposit reverts deposits of krAsset collateral for less than MIN_KRASSET_COLLATERAL_AMOUNT",
- "timedOut": false,
- "duration": 40,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const collateralAmount = (0, _values.toBig)(100);\nawait f.KrAssetCollateral.setBalance(f.user, collateralAmount, _hardhat.default.Diamond.address);\nawait (0, _chai.expect)(f.User.depositCollateral(f.user.address, f.KrAssetCollateral.address, 9e11.toString())).to.be.revertedWithCustomError((0, _errors.Errors)(_hardhat.default), 'COLLATERAL_AMOUNT_LOW').withArgs(f.KrAssetCollateral.errorId, 9e11, 1e12);",
- "err": {},
- "uuid": "89a5341e-5d4f-4bfc-a21a-46aa0c08e3af",
- "parentUUID": "1d990730-669c-4d3b-b7c8-3cdf6393f936",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should allow an account to deposit whitelisted collateral",
- "fullTitle": "Minter - Deposit Withdraw #collateral #deposit should allow an account to deposit whitelisted collateral",
- "timedOut": false,
- "duration": 107,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await (0, _chai.expect)(f.Depositor.depositCollateral(f.depositor.address, f.Collateral.address, f.initialDeposits)).not.to.be.reverted;\n// Account has deposit entry\nconst depositedCollateralAssetsAfter = await _hardhat.default.Diamond.getAccountCollateralAssets(f.depositor.address);\n(0, _chai.expect)(depositedCollateralAssetsAfter).to.deep.equal([\n f.Collateral.address\n]);\n// Account's collateral deposit balances have increased\n(0, _chai.expect)(await _hardhat.default.Diamond.getAccountCollateralAmount(f.depositor.address, f.Collateral.address)).to.equal(f.initialDeposits);\n// Kresko's balance has increased\n(0, _chai.expect)(await f.Collateral.balanceOf(_hardhat.default.Diamond.address)).to.equal(f.initialDeposits.add(f.initialDeposits));\n// Account's balance has decreased\n(0, _chai.expect)((0, _values.fromBig)(await f.Collateral.balanceOf(f.depositor.address))).to.equal((0, _values.fromBig)(f.initialBalance) - (0, _values.fromBig)(f.initialDeposits));",
- "err": {},
- "uuid": "5f08f375-7a75-4000-8188-6bd0c66213b4",
- "parentUUID": "1d990730-669c-4d3b-b7c8-3cdf6393f936",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should allow an arbitrary account to deposit whitelisted collateral on behalf of another account",
- "fullTitle": "Minter - Deposit Withdraw #collateral #deposit should allow an arbitrary account to deposit whitelisted collateral on behalf of another account",
- "timedOut": false,
- "duration": 144,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Initially, the array of the f.user's deposited collateral assets should be empty.\nconst depositedCollateralAssetsBefore = await _hardhat.default.Diamond.getAccountCollateralAssets(f.user.address);\n(0, _chai.expect)(depositedCollateralAssetsBefore).to.deep.equal([]);\n// Deposit collateral, from f.depositor -> f.user.\nawait (0, _chai.expect)(f.Depositor.depositCollateral(f.user.address, f.Collateral.address, f.initialDeposits)).not.to.be.reverted;\n// Confirm the array of the f.user's deposited collateral assets has been pushed to.\nconst depositedCollateralAssetsAfter = await _hardhat.default.Diamond.getAccountCollateralAssets(f.user.address);\n(0, _chai.expect)(depositedCollateralAssetsAfter).to.deep.equal([\n f.Collateral.address\n]);\n// Confirm the amount deposited is recorded for the f.user.\nconst amountDeposited = await _hardhat.default.Diamond.getAccountCollateralAmount(f.user.address, f.Collateral.address);\n(0, _chai.expect)(amountDeposited).to.equal(f.initialDeposits);\n// Confirm the amount as been transferred from the f.user into Kresko.sol\nconst kreskoBalance = await f.Collateral.balanceOf(_hardhat.default.Diamond.address);\n(0, _chai.expect)(kreskoBalance).to.equal(f.initialDeposits.add(f.initialDeposits));\n// Confirm the f.depositor's wallet balance has been adjusted accordingly\nconst depositorBalanceAfter = await f.Collateral.balanceOf(f.depositor.address);\n(0, _chai.expect)((0, _values.fromBig)(depositorBalanceAfter)).to.equal((0, _values.fromBig)(f.initialBalance) - (0, _values.fromBig)(f.initialDeposits));",
- "err": {},
- "uuid": "9bc70342-cc56-48f7-b2b5-948cb9d6c591",
- "parentUUID": "1d990730-669c-4d3b-b7c8-3cdf6393f936",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should allow an account to deposit more collateral to an existing deposit",
- "fullTitle": "Minter - Deposit Withdraw #collateral #deposit should allow an account to deposit more collateral to an existing deposit",
- "timedOut": false,
- "duration": 143,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Deposit first batch of collateral\nawait (0, _chai.expect)(f.Depositor.depositCollateral(f.depositor.address, f.Collateral.address, f.initialDeposits)).not.to.be.reverted;\n// Deposit second batch of collateral\nawait (0, _chai.expect)(f.Depositor.depositCollateral(f.depositor.address, f.Collateral.address, f.initialDeposits)).not.to.be.reverted;\n// Confirm the array of the f.user's deposited collateral assets hasn't been double-pushed to.\nconst depositedCollateralAssetsAfter = await _hardhat.default.Diamond.getAccountCollateralAssets(f.depositor.address);\n(0, _chai.expect)(depositedCollateralAssetsAfter).to.deep.equal([\n f.Collateral.address\n]);\n// Confirm the amount deposited is recorded for the f.user.\nconst amountDeposited = await _hardhat.default.Diamond.getAccountCollateralAmount(f.depositor.address, f.Collateral.address);\n(0, _chai.expect)(amountDeposited).to.equal(f.initialDeposits.add(f.initialDeposits));",
- "err": {},
- "uuid": "cd0b0f63-69e2-493b-a759-2a8fc6c82c9d",
- "parentUUID": "1d990730-669c-4d3b-b7c8-3cdf6393f936",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should allow an account to have deposited multiple collateral assets",
- "fullTitle": "Minter - Deposit Withdraw #collateral #deposit should allow an account to have deposited multiple collateral assets",
- "timedOut": false,
- "duration": 111,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Load f.user account with a different type of collateral\nawait f.Collateral2.setBalance(f.depositor, f.initialBalance, _hardhat.default.Diamond.address);\n// Deposit batch of first collateral type\nawait (0, _chai.expect)(f.Depositor.depositCollateral(f.depositor.address, f.Collateral.address, f.initialDeposits)).not.to.be.reverted;\n// Deposit batch of second collateral type\nawait (0, _chai.expect)(f.Depositor.depositCollateral(f.depositor.address, f.Collateral2.address, f.initialDeposits)).not.to.be.reverted;\n// Confirm the array of the f.user's deposited collateral assets contains both collateral assets\nconst depositedCollateralAssetsAfter = await _hardhat.default.Diamond.getAccountCollateralAssets(f.depositor.address);\n(0, _chai.expect)(depositedCollateralAssetsAfter).to.deep.equal([\n f.Collateral.address,\n f.Collateral2.address\n]);",
- "err": {},
- "uuid": "1ae841cc-55f2-4874-aa8c-66b1dfdfe230",
- "parentUUID": "1d990730-669c-4d3b-b7c8-3cdf6393f936",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should emit CollateralDeposited event",
- "fullTitle": "Minter - Deposit Withdraw #collateral #deposit should emit CollateralDeposited event",
- "timedOut": false,
- "duration": 39,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const tx = await f.Depositor.depositCollateral(f.depositor.address, f.Collateral.address, f.initialDeposits);\nconst event = await (0, _events.getInternalEvent)(tx, _hardhat.default.Diamond, 'CollateralDeposited');\n(0, _chai.expect)(event.account).to.equal(f.depositor.address);\n(0, _chai.expect)(event.collateralAsset).to.equal(f.Collateral.address);\n(0, _chai.expect)(event.amount).to.equal(f.initialDeposits);",
- "err": {},
- "uuid": "84dd90df-8980-4bb1-9065-fcde1fb83394",
- "parentUUID": "1d990730-669c-4d3b-b7c8-3cdf6393f936",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should revert if depositing collateral that has not been whitelisted",
- "fullTitle": "Minter - Deposit Withdraw #collateral #deposit should revert if depositing collateral that has not been whitelisted",
- "timedOut": false,
- "duration": 32,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await (0, _chai.expect)(f.Depositor.depositCollateral(f.depositor.address, '0x0000000000000000000000000000000000000001', f.initialDeposits)).to.be.revertedWithCustomError((0, _errors.Errors)(_hardhat.default), 'ASSET_NOT_MINTER_COLLATERAL').withArgs([\n '',\n '0x0000000000000000000000000000000000000001'\n]);",
- "err": {},
- "uuid": "3f8b3d0e-bc9a-438a-accb-3d0db5ba0772",
- "parentUUID": "1d990730-669c-4d3b-b7c8-3cdf6393f936",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should revert if depositing an amount of 0",
- "fullTitle": "Minter - Deposit Withdraw #collateral #deposit should revert if depositing an amount of 0",
- "timedOut": false,
- "duration": 36,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await (0, _chai.expect)(f.Depositor.depositCollateral(f.depositor.address, f.Collateral.address, 0)).to.be.revertedWithCustomError((0, _errors.Errors)(_hardhat.default), 'ZERO_DEPOSIT').withArgs(f.Collateral.errorId);",
- "err": {},
- "uuid": "093baca3-e872-445f-9b70-b0602adf995a",
- "parentUUID": "1d990730-669c-4d3b-b7c8-3cdf6393f936",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should revert if collateral is not depositable",
- "fullTitle": "Minter - Deposit Withdraw #collateral #deposit should revert if collateral is not depositable",
- "timedOut": false,
- "duration": 125,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const { deployer, devOne, extOne } = await _hardhat.default.ethers.getNamedSigners();\nawait (0, _execution.executeContractCallWithSigners)(_hardhat.default.Multisig, _hardhat.default.Diamond, 'toggleAssetsPaused', [\n [\n f.Collateral.address\n ],\n _types.Action.DEPOSIT,\n true,\n 0\n], [\n deployer,\n devOne,\n extOne\n]);\nconst isDepositPaused = await _hardhat.default.Diamond.assetActionPaused(_types.Action.DEPOSIT.toString(), f.Collateral.address);\n(0, _chai.expect)(isDepositPaused).to.equal(true);\nawait (0, _chai.expect)((0, _redstone.wrapKresko)(_hardhat.default.Diamond, f.depositor).depositCollateral(f.depositor.address, f.Collateral.contract.address, 0)).to.be.revertedWithCustomError((0, _errors.Errors)(_hardhat.default), 'ASSET_PAUSED_FOR_THIS_ACTION').withArgs(f.Collateral.errorId, _types.Action.DEPOSIT);",
- "err": {},
- "uuid": "daa5568b-d166-44b8-a142-579518a1f306",
- "parentUUID": "1d990730-669c-4d3b-b7c8-3cdf6393f936",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "4032c0d5-ad8d-4a32-bdd9-c9bb57ad4afb",
- "89a5341e-5d4f-4bfc-a21a-46aa0c08e3af",
- "5f08f375-7a75-4000-8188-6bd0c66213b4",
- "9bc70342-cc56-48f7-b2b5-948cb9d6c591",
- "cd0b0f63-69e2-493b-a759-2a8fc6c82c9d",
- "1ae841cc-55f2-4874-aa8c-66b1dfdfe230",
- "84dd90df-8980-4bb1-9065-fcde1fb83394",
- "3f8b3d0e-bc9a-438a-accb-3d0db5ba0772",
- "093baca3-e872-445f-9b70-b0602adf995a",
- "daa5568b-d166-44b8-a142-579518a1f306"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 900,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "9d485b5d-3d35-4510-ae74-617363b857eb",
- "title": "#withdraw",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/02-deposit-withdraw.ts",
- "file": "/src/test/minter/02-deposit-withdraw.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [],
- "suites": [
- {
- "uuid": "623b5678-12c1-46ab-a7e8-a1fc456627af",
- "title": "when the account's minimum collateral value is 0",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/02-deposit-withdraw.ts",
- "file": "/src/test/minter/02-deposit-withdraw.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "should allow an account to withdraw their entire deposit",
- "fullTitle": "Minter - Deposit Withdraw #collateral #withdraw when the account's minimum collateral value is 0 should allow an account to withdraw their entire deposit",
- "timedOut": false,
- "duration": 144,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const depositedCollateralAssets = await _hardhat.default.Diamond.getAccountCollateralAssets(f.withdrawer.address);\n(0, _chai.expect)(depositedCollateralAssets).to.deep.equal([\n f.Collateral.address\n]);\nawait f.Withdrawer.withdrawCollateral(f.withdrawer.address, f.Collateral.address, f.initialDeposits, 0);\n// Ensure that the collateral asset is removed from the account's deposited collateral\n// assets array.\nconst depositedCollateralAssetsPostWithdraw = await _hardhat.default.Diamond.getAccountCollateralAssets(f.withdrawer.address);\n(0, _chai.expect)(depositedCollateralAssetsPostWithdraw).to.deep.equal([]);\n// Ensure the change in the f.user's deposit is recorded.\nconst amountDeposited = await _hardhat.default.Diamond.getAccountCollateralAmount(f.withdrawer.address, f.Collateral.address);\n(0, _chai.expect)(amountDeposited).to.equal(0);\n// Ensure the amount transferred is correct\nconst kreskoBalance = await f.Collateral.balanceOf(_hardhat.default.Diamond.address);\n(0, _chai.expect)(kreskoBalance).to.equal(0);\nconst userOneBalance = await f.Collateral.balanceOf(f.withdrawer.address);\n(0, _chai.expect)(userOneBalance).to.equal(f.initialDeposits);",
- "err": {},
- "uuid": "1ad6bd4f-e994-4849-be86-dbdb787a8bdc",
- "parentUUID": "623b5678-12c1-46ab-a7e8-a1fc456627af",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should allow an account to withdraw a portion of their deposit",
- "fullTitle": "Minter - Deposit Withdraw #collateral #withdraw when the account's minimum collateral value is 0 should allow an account to withdraw a portion of their deposit",
- "timedOut": false,
- "duration": 142,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const withdrawAmount = f.initialDeposits.div(2);\nawait f.Withdrawer.withdrawCollateral(f.withdrawer.address, f.Collateral.address, withdrawAmount, 0);\n// Ensure the change in the f.user's deposit is recorded.\nconst amountDeposited = await _hardhat.default.Diamond.getAccountCollateralAmount(f.withdrawer.address, f.Collateral.address);\n(0, _chai.expect)(amountDeposited).to.equal(f.initialDeposits.sub(withdrawAmount));\n// Ensure that the collateral asset is still in the account's deposited collateral\n// assets array.\nconst depositedCollateralAssets = await _hardhat.default.Diamond.getAccountCollateralAssets(f.withdrawer.address);\n(0, _chai.expect)(depositedCollateralAssets).to.deep.equal([\n f.Collateral.address\n]);\nconst kreskoBalance = await f.Collateral.balanceOf(_hardhat.default.Diamond.address);\n(0, _chai.expect)(kreskoBalance).to.equal(f.initialDeposits.sub(withdrawAmount));\nconst userOneBalance = await f.Collateral.balanceOf(f.withdrawer.address);\n(0, _chai.expect)(userOneBalance).to.equal(f.initialDeposits.sub(amountDeposited));",
- "err": {},
- "uuid": "45b07ac3-c3f1-4019-8626-a0493f11fd3d",
- "parentUUID": "623b5678-12c1-46ab-a7e8-a1fc456627af",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should allow trusted address to withdraw another accounts deposit",
- "fullTitle": "Minter - Deposit Withdraw #collateral #withdraw when the account's minimum collateral value is 0 should allow trusted address to withdraw another accounts deposit",
- "timedOut": false,
- "duration": 181,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Grant userThree the MANAGER role\nawait _hardhat.default.Diamond.grantRole(_roles.Role.MANAGER, f.user.address);\n(0, _chai.expect)(await _hardhat.default.Diamond.hasRole(_roles.Role.MANAGER, f.user.address)).to.equal(true);\nconst collateralBefore = await _hardhat.default.Diamond.getAccountCollateralAmount(f.withdrawer.address, f.Collateral.address);\nawait (0, _chai.expect)(f.User.withdrawCollateral(f.withdrawer.address, f.Collateral.address, f.initialDeposits, 0)).to.not.be.reverted;\nconst collateralAfter = await _hardhat.default.Diamond.getAccountCollateralAmount(f.withdrawer.address, f.Collateral.address);\n// Ensure that collateral was withdrawn\n(0, _chai.expect)(collateralAfter).to.equal(collateralBefore.sub(f.initialDeposits));",
- "err": {},
- "uuid": "91f5e57c-d7cf-45e6-a54c-bc995f267512",
- "parentUUID": "623b5678-12c1-46ab-a7e8-a1fc456627af",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should emit CollateralWithdrawn event",
- "fullTitle": "Minter - Deposit Withdraw #collateral #withdraw when the account's minimum collateral value is 0 should emit CollateralWithdrawn event",
- "timedOut": false,
- "duration": 39,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const tx = await f.Withdrawer.withdrawCollateral(f.withdrawer.address, f.Collateral.address, f.initialDeposits, 0);\nconst event = await (0, _events.getInternalEvent)(tx, _hardhat.default.Diamond, 'CollateralWithdrawn');\n(0, _chai.expect)(event.account).to.equal(f.withdrawer.address);\n(0, _chai.expect)(event.collateralAsset).to.equal(f.Collateral.address);\n(0, _chai.expect)(event.amount).to.equal(f.initialDeposits);",
- "err": {},
- "uuid": "54e72fa7-0458-4597-9153-f3fc8338f113",
- "parentUUID": "623b5678-12c1-46ab-a7e8-a1fc456627af",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should not allow untrusted address to withdraw another accounts deposit",
- "fullTitle": "Minter - Deposit Withdraw #collateral #withdraw when the account's minimum collateral value is 0 should not allow untrusted address to withdraw another accounts deposit",
- "timedOut": false,
- "duration": 45,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await (0, _chai.expect)(f.User.withdrawCollateral(f.withdrawer.address, f.Collateral.address, f.initialBalance, 0)).to.be.revertedWith(`AccessControl: account ${f.user.address.toLowerCase()} is missing role 0x46925e0f0cc76e485772167edccb8dc449d43b23b55fc4e756b063f49099e6a0`);",
- "err": {},
- "uuid": "aa8b4129-63c1-433f-88d8-9e4a4feca872",
- "parentUUID": "623b5678-12c1-46ab-a7e8-a1fc456627af",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [
- {
- "uuid": "8ec4dfbf-faba-4eda-8748-e205d551d968",
- "title": "when the account's minimum collateral value is > 0",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/02-deposit-withdraw.ts",
- "file": "/src/test/minter/02-deposit-withdraw.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"when the account's minimum collateral value is > 0\"",
- "fullTitle": "Minter - Deposit Withdraw #collateral #withdraw when the account's minimum collateral value is 0 when the account's minimum collateral value is > 0 \"before each\" hook in \"when the account's minimum collateral value is > 0\"",
- "timedOut": false,
- "duration": 224,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// userOne mints some kr assets\nthis.mintAmount = (0, _values.toBig)(100);\nawait f.Withdrawer.mintKreskoAsset(f.withdrawer.address, f.KrAsset.address, this.mintAmount);\n// Mint amount differs from deposited amount due to open fee\nconst amountDeposited = await _optimizations.default.getAccountCollateralAmount(f.withdrawer.address, f.Collateral.address);\nthis.initialUserOneDeposited = amountDeposited;\nthis.mcr = await _optimizations.default.getMinCollateralRatioMinter();",
- "err": {},
- "uuid": "df799a0f-5596-4e16-892b-628bdc1e72e1",
- "parentUUID": "8ec4dfbf-faba-4eda-8748-e205d551d968",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [
- {
- "title": "should allow an account to withdraw their deposit if it does not violate the health factor",
- "fullTitle": "Minter - Deposit Withdraw #collateral #withdraw when the account's minimum collateral value is 0 when the account's minimum collateral value is > 0 should allow an account to withdraw their deposit if it does not violate the health factor",
- "timedOut": false,
- "duration": 523,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const withdrawAmount = (0, _values.toBig)(10);\n// Ensure that the withdrawal would not put the account's collateral value\n// less than the account's minimum collateral value:\nconst [accMinCollateralValue, accCollateralValue, withdrawnCollateralValue] = await Promise.all([\n _hardhat.default.Diamond.getAccountMinCollateralAtRatio(f.withdrawer.address, this.mcr),\n _hardhat.default.Diamond.getAccountTotalCollateralValue(f.withdrawer.address),\n _hardhat.default.Diamond.getValue(f.Collateral.address, withdrawAmount)\n]);\n(0, _chai.expect)(accCollateralValue.sub(withdrawnCollateralValue).gte(accMinCollateralValue)).to.be.true;\nawait f.Withdrawer.withdrawCollateral(f.withdrawer.address, f.Collateral.address, withdrawAmount, 0);\n// Ensure that the collateral asset is still in the account's deposited collateral\n// assets array.\nconst depositedCollateralAssets = await _hardhat.default.Diamond.getAccountCollateralAssets(f.withdrawer.address);\n(0, _chai.expect)(depositedCollateralAssets).to.deep.equal([\n f.Collateral.address\n]);\n// Ensure the change in the f.user's deposit is recorded.\nconst amountDeposited = await _hardhat.default.Diamond.getAccountCollateralAmount(f.withdrawer.address, f.Collateral.address);\n(0, _chai.expect)(amountDeposited).to.equal(f.initialDeposits.sub(withdrawAmount));\n// Check the balances of the contract and f.user\nconst kreskoBalance = await f.Collateral.balanceOf(_hardhat.default.Diamond.address);\n(0, _chai.expect)(kreskoBalance).to.equal(f.initialDeposits.sub(withdrawAmount));\nconst withdrawerBalance = await f.Collateral.balanceOf(f.withdrawer.address);\n(0, _chai.expect)(withdrawerBalance).to.equal(withdrawAmount);\n// Ensure the account's minimum collateral value is <= the account collateral value\nconst accountMinCollateralValueAfter = await _hardhat.default.Diamond.getAccountMinCollateralAtRatio(f.withdrawer.address, this.mcr);\nconst accountCollateralValueAfter = await _hardhat.default.Diamond.getAccountTotalCollateralValue(f.withdrawer.address);\n(0, _chai.expect)(accountMinCollateralValueAfter.lte(accountCollateralValueAfter)).to.be.true;",
- "err": {},
- "uuid": "95a0851d-d58e-453b-ba75-0aa0660da278",
- "parentUUID": "8ec4dfbf-faba-4eda-8748-e205d551d968",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should allow withdraws that exceed deposits and only send the f.user total deposit available",
- "fullTitle": "Minter - Deposit Withdraw #collateral #withdraw when the account's minimum collateral value is 0 when the account's minimum collateral value is > 0 should allow withdraws that exceed deposits and only send the f.user total deposit available",
- "timedOut": false,
- "duration": 148,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const randomUser = _hardhat.default.users.userFour;\nawait f.Collateral.setBalance(randomUser, (0, _values.toBig)(0));\nawait f.Collateral.setBalance(randomUser, (0, _values.toBig)(1000));\nawait f.Collateral.contract.connect(randomUser).approve(_hardhat.default.Diamond.address, _hardhat.default.ethers.constants.MaxUint256);\nawait (0, _collaterals.depositCollateral)({\n asset: f.Collateral,\n amount: (0, _values.toBig)(1000),\n user: randomUser\n});\nawait (0, _collaterals.withdrawCollateral)({\n asset: f.Collateral,\n amount: (0, _values.toBig)(1010),\n user: randomUser\n});\n(0, _chai.expect)(await f.Collateral.balanceOf(randomUser.address)).to.equal((0, _values.toBig)(1000));",
- "err": {},
- "uuid": "b6f885f3-a63e-4a95-bea1-2f99524e92e2",
- "parentUUID": "8ec4dfbf-faba-4eda-8748-e205d551d968",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should revert if withdrawing an amount of 0",
- "fullTitle": "Minter - Deposit Withdraw #collateral #withdraw when the account's minimum collateral value is 0 when the account's minimum collateral value is > 0 should revert if withdrawing an amount of 0",
- "timedOut": false,
- "duration": 34,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const withdrawAmount = 0;\nawait (0, _chai.expect)(f.Withdrawer.withdrawCollateral(f.withdrawer.address, f.Collateral.address, 0, withdrawAmount)).to.be.revertedWithCustomError((0, _errors.Errors)(_hardhat.default), 'ZERO_AMOUNT').withArgs(f.Collateral.errorId);",
- "err": {},
- "uuid": "391c8d20-7e78-4f11-ac67-95d1275dcb8e",
- "parentUUID": "8ec4dfbf-faba-4eda-8748-e205d551d968",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should revert if the withdrawal violates the health factor",
- "fullTitle": "Minter - Deposit Withdraw #collateral #withdraw when the account's minimum collateral value is 0 when the account's minimum collateral value is > 0 should revert if the withdrawal violates the health factor",
- "timedOut": false,
- "duration": 321,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// userOne has a debt position, so attempting to withdraw the entire collateral deposit should be impossible\nconst withdrawAmount = f.initialBalance;\n// Ensure that the withdrawal would in fact put the account's collateral value\n// less than the account's minimum collateral value:\nconst accountMinCollateralValue = await _hardhat.default.Diamond.getAccountMinCollateralAtRatio(f.withdrawer.address, this.mcr);\nconst accountCollateralValue = await _hardhat.default.Diamond.getAccountTotalCollateralValue(f.withdrawer.address);\nconst withdrawnCollateralValue = await _hardhat.default.Diamond.getValue(f.Collateral.address, withdrawAmount);\n(0, _chai.expect)(accountCollateralValue.sub(withdrawnCollateralValue).lt(accountMinCollateralValue)).to.be.true;\nawait (0, _chai.expect)(f.Withdrawer.withdrawCollateral(f.withdrawer.address, f.Collateral.address, withdrawAmount, 0)).to.be.revertedWithCustomError((0, _errors.Errors)(_hardhat.default), 'ACCOUNT_COLLATERAL_VALUE_LESS_THAN_REQUIRED').withArgs(f.withdrawer.address, 0, 150000000000, await _hardhat.default.Diamond.getMinCollateralRatioMinter());",
- "err": {},
- "uuid": "aba95b4e-7816-43b1-9e13-85d003b7d6ea",
- "parentUUID": "8ec4dfbf-faba-4eda-8748-e205d551d968",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should revert if the depositIndex is incorrect",
- "fullTitle": "Minter - Deposit Withdraw #collateral #withdraw when the account's minimum collateral value is 0 when the account's minimum collateral value is > 0 should revert if the depositIndex is incorrect",
- "timedOut": false,
- "duration": 36,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const withdrawAmount = f.initialDeposits.div(2);\nawait (0, _chai.expect)(f.Withdrawer.withdrawCollateral(f.withdrawer.address, f.Collateral.address, withdrawAmount, 1)).to.be.revertedWithCustomError((0, _errors.Errors)(_hardhat.default), 'ELEMENT_DOES_NOT_MATCH_PROVIDED_INDEX').withArgs(f.Collateral.errorId, 1, [\n f.Collateral.address\n]);",
- "err": {},
- "uuid": "c5f5a70d-0d41-4245-bedb-ca148506f0b2",
- "parentUUID": "8ec4dfbf-faba-4eda-8748-e205d551d968",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "95a0851d-d58e-453b-ba75-0aa0660da278",
- "b6f885f3-a63e-4a95-bea1-2f99524e92e2",
- "391c8d20-7e78-4f11-ac67-95d1275dcb8e",
- "aba95b4e-7816-43b1-9e13-85d003b7d6ea",
- "c5f5a70d-0d41-4245-bedb-ca148506f0b2"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 1062,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [
- "1ad6bd4f-e994-4849-be86-dbdb787a8bdc",
- "45b07ac3-c3f1-4019-8626-a0493f11fd3d",
- "91f5e57c-d7cf-45e6-a54c-bc995f267512",
- "54e72fa7-0458-4597-9153-f3fc8338f113",
- "aa8b4129-63c1-433f-88d8-9e4a4feca872"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 551,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "0b1f66e9-58cc-49f1-8350-fa85a623e86c",
- "title": "#deposit - rebase",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/02-deposit-withdraw.ts",
- "file": "/src/test/minter/02-deposit-withdraw.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"#deposit - rebase\"",
- "fullTitle": "Minter - Deposit Withdraw #collateral #deposit - rebase \"before each\" hook in \"#deposit - rebase\"",
- "timedOut": false,
- "duration": 218,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await f.Collateral.setBalance(f.user, f.initialBalance, _hardhat.default.Diamond.address);\n// Add krAsset as a collateral with anchor and cFactor of 1\n// Allowance for Kresko\nawait f.KrAssetCollateral.contract.setVariable('_allowances', {\n [f.user.address]: {\n [_hardhat.default.Diamond.address]: _hardhat.default.ethers.constants.MaxInt256\n }\n});\n// Deposit some collateral\nawait f.User.depositCollateral(f.user.address, f.Collateral.address, f.initialDeposits);\n// Mint some krAssets\nawait f.User.mintKreskoAsset(f.user.address, f.KrAssetCollateral.address, mintAmount);\n// Deposit all debt on tests\nthis.krAssetCollateralAmount = await f.User.getAccountDebtAmount(f.user.address, f.KrAssetCollateral.address);",
- "err": {},
- "uuid": "a48cc638-ee48-454e-8b2a-3e10af40dcb4",
- "parentUUID": "0b1f66e9-58cc-49f1-8350-fa85a623e86c",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [],
- "suites": [
- {
- "uuid": "fdb372f2-e5d8-4f13-9ca8-7679fb74fa25",
- "title": "deposit amounts are calculated correctly",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/02-deposit-withdraw.ts",
- "file": "/src/test/minter/02-deposit-withdraw.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "when deposit is made before positive rebase",
- "fullTitle": "Minter - Deposit Withdraw #collateral #deposit - rebase deposit amounts are calculated correctly when deposit is made before positive rebase",
- "timedOut": false,
- "duration": 124,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await f.User.depositCollateral(f.user.address, f.KrAssetCollateral.address, this.krAssetCollateralAmount);\n// Rebase params\nconst denominator = 4;\nconst positive = true;\nconst expectedDepositsAfter = this.krAssetCollateralAmount.mul(denominator);\nconst depositsBefore = await _hardhat.default.Diamond.getAccountCollateralAmount(f.user.address, f.KrAssetCollateral.address);\n// Rebase the asset according to params\nawait f.KrAssetCollateral.contract.rebase((0, _values.toBig)(denominator), positive, []);\nconst finalDeposits = await _hardhat.default.Diamond.getAccountCollateralAmount(f.user.address, f.KrAssetCollateral.address);\n// Ensure that the collateral balance is adjusted by the rebase\n(0, _chai.expect)(depositsBefore).to.not.equal(finalDeposits);\n(0, _chai.expect)(finalDeposits).to.equal(expectedDepositsAfter);\n(0, _chai.expect)(await f.KrAssetCollateral.balanceOf(f.user.address)).to.equal(0);",
- "err": {},
- "uuid": "709aad2a-d01c-4bc9-958b-1ab5bc76a174",
- "parentUUID": "fdb372f2-e5d8-4f13-9ca8-7679fb74fa25",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when deposit is made before negative rebase",
- "fullTitle": "Minter - Deposit Withdraw #collateral #deposit - rebase deposit amounts are calculated correctly when deposit is made before negative rebase",
- "timedOut": false,
- "duration": 121,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = false;\nconst depositAmountAfterRebase = this.krAssetCollateralAmount.div(denominator);\n// Deposit\nawait f.User.depositCollateral(f.user.address, f.KrAssetCollateral.address, this.krAssetCollateralAmount);\nconst depositsBefore = await _hardhat.default.Diamond.getAccountCollateralAmount(f.user.address, f.KrAssetCollateral.address);\n// Rebase the asset according to params\nawait f.KrAssetCollateral.contract.rebase((0, _values.toBig)(denominator), positive, []);\nconst finalDeposits = await _hardhat.default.Diamond.getAccountCollateralAmount(f.user.address, f.KrAssetCollateral.address);\n// Ensure that the collateral balance is adjusted by the rebase\n(0, _chai.expect)(depositsBefore).to.not.equal(finalDeposits);\n(0, _chai.expect)(finalDeposits).to.equal(depositAmountAfterRebase);\n(0, _chai.expect)(await f.KrAssetCollateral.balanceOf(f.user.address)).to.equal(0);",
- "err": {},
- "uuid": "4de79417-cb9b-40de-9033-2c8e2462f1db",
- "parentUUID": "fdb372f2-e5d8-4f13-9ca8-7679fb74fa25",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when deposit is made after an positiveing rebase",
- "fullTitle": "Minter - Deposit Withdraw #collateral #deposit - rebase deposit amounts are calculated correctly when deposit is made after an positiveing rebase",
- "timedOut": false,
- "duration": 119,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = true;\nconst depositAmount = this.krAssetCollateralAmount.mul(denominator);\nconst depositsBefore = await _hardhat.default.Diamond.getAccountCollateralAmount(f.user.address, f.KrAssetCollateral.address);\n// Rebase the asset according to params\nawait f.KrAssetCollateral.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Deposit after the rebase\nawait f.User.depositCollateral(f.user.address, f.KrAssetCollateral.address, depositAmount);\n// Get collateral deposits after\nconst finalDeposits = await _hardhat.default.Diamond.getAccountCollateralAmount(f.user.address, f.KrAssetCollateral.address);\n// Ensure that the collateral balance is what was deposited as no rebases occured after\n(0, _chai.expect)(depositsBefore).to.not.equal(finalDeposits);\n(0, _chai.expect)(finalDeposits).to.equal(depositAmount);\n(0, _chai.expect)(await f.KrAssetCollateral.balanceOf(f.user.address)).to.equal(0);",
- "err": {},
- "uuid": "13f75ce9-1341-4247-b354-e050545c426b",
- "parentUUID": "fdb372f2-e5d8-4f13-9ca8-7679fb74fa25",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when deposit is made after an negative rebase",
- "fullTitle": "Minter - Deposit Withdraw #collateral #deposit - rebase deposit amounts are calculated correctly when deposit is made after an negative rebase",
- "timedOut": false,
- "duration": 123,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = false;\nconst depositAmount = this.krAssetCollateralAmount.div(denominator);\nconst depositsBefore = await _hardhat.default.Diamond.getAccountCollateralAmount(f.user.address, f.KrAssetCollateral.address);\n// Rebase the asset according to params\nawait f.KrAssetCollateral.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Deposit after the rebase\nawait f.User.depositCollateral(f.user.address, f.KrAssetCollateral.address, depositAmount);\n// Get collateral deposits after\nconst finalDeposits = await _hardhat.default.Diamond.getAccountCollateralAmount(f.user.address, f.KrAssetCollateral.address);\n// Ensure that the collateral balance is what was deposited as no rebases occured after\n(0, _chai.expect)(depositsBefore).to.not.equal(finalDeposits);\n(0, _chai.expect)(finalDeposits).to.equal(depositAmount);\n(0, _chai.expect)(await f.KrAssetCollateral.balanceOf(f.user.address)).to.equal(0);",
- "err": {},
- "uuid": "f90dbd2b-52eb-4e93-9640-29055ddf0657",
- "parentUUID": "fdb372f2-e5d8-4f13-9ca8-7679fb74fa25",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when deposit is made before and after a positiveing rebase",
- "fullTitle": "Minter - Deposit Withdraw #collateral #deposit - rebase deposit amounts are calculated correctly when deposit is made before and after a positiveing rebase",
- "timedOut": false,
- "duration": 167,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = true;\n// Deposit half before, half after\nconst halfDepositBeforeRebase = this.krAssetCollateralAmount.div(2);\nconst halfDepositAfterRebase = this.krAssetCollateralAmount.div(2).mul(denominator);\nconst fullDepositAmount = this.krAssetCollateralAmount.mul(denominator);\nawait f.User.depositCollateral(f.user.address, f.KrAssetCollateral.address, halfDepositBeforeRebase);\n// Rebase the asset according to params\nawait f.KrAssetCollateral.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Get deposits after\nconst depositsAfter = await _hardhat.default.Diamond.getAccountCollateralAmount(f.user.address, f.KrAssetCollateral.address);\n// Ensure that the collateral balance is adjusted by the rebase\n(0, _chai.expect)(depositsAfter).to.equal(halfDepositAfterRebase);\n// Deposit second time\nawait f.User.depositCollateral(f.user.address, f.KrAssetCollateral.address, halfDepositAfterRebase);\n// Get deposits after\nconst finalDeposits = await _hardhat.default.Diamond.getAccountCollateralAmount(f.user.address, f.KrAssetCollateral.address);\n(0, _chai.expect)(finalDeposits).to.equal(fullDepositAmount);\n(0, _chai.expect)(await f.KrAssetCollateral.balanceOf(f.user.address)).to.equal(0);",
- "err": {},
- "uuid": "4e90ec4a-915f-4fc0-8022-41408668a5f5",
- "parentUUID": "fdb372f2-e5d8-4f13-9ca8-7679fb74fa25",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when deposit is made before and after a negative rebase",
- "fullTitle": "Minter - Deposit Withdraw #collateral #deposit - rebase deposit amounts are calculated correctly when deposit is made before and after a negative rebase",
- "timedOut": false,
- "duration": 161,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = false;\n// Deposit half before, half after\nconst halfDepositBeforeRebase = this.krAssetCollateralAmount.div(2);\nconst halfDepositAfterRebase = this.krAssetCollateralAmount.div(2).div(denominator);\nconst fullDepositAmount = this.krAssetCollateralAmount.div(denominator);\nawait f.User.depositCollateral(f.user.address, f.KrAssetCollateral.address, halfDepositBeforeRebase);\n// Rebase the asset according to params\nawait f.KrAssetCollateral.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Get deposits after\nconst depositsAfterRebase = await _hardhat.default.Diamond.getAccountCollateralAmount(f.user.address, f.KrAssetCollateral.address);\n// Ensure that the collateral balance is adjusted by the rebase\n(0, _chai.expect)(depositsAfterRebase).to.equal(halfDepositAfterRebase);\n// Deposit second time\nawait f.User.depositCollateral(f.user.address, f.KrAssetCollateral.address, halfDepositAfterRebase);\n// Get deposits after\nconst finalDeposits = await _hardhat.default.Diamond.getAccountCollateralAmount(f.user.address, f.KrAssetCollateral.address);\n(0, _chai.expect)(finalDeposits).to.equal(fullDepositAmount);\n(0, _chai.expect)(await f.KrAssetCollateral.balanceOf(f.user.address)).to.equal(0);",
- "err": {},
- "uuid": "d7da5902-492f-44b3-afd4-c956b234fe57",
- "parentUUID": "fdb372f2-e5d8-4f13-9ca8-7679fb74fa25",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "709aad2a-d01c-4bc9-958b-1ab5bc76a174",
- "4de79417-cb9b-40de-9033-2c8e2462f1db",
- "13f75ce9-1341-4247-b354-e050545c426b",
- "f90dbd2b-52eb-4e93-9640-29055ddf0657",
- "4e90ec4a-915f-4fc0-8022-41408668a5f5",
- "d7da5902-492f-44b3-afd4-c956b234fe57"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 815,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "7fcf8e24-cbed-4e57-83d4-444c3bbc75f1",
- "title": "deposit usd values are calculated correctly",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/02-deposit-withdraw.ts",
- "file": "/src/test/minter/02-deposit-withdraw.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "when deposit is made before positiveing rebase",
- "fullTitle": "Minter - Deposit Withdraw #collateral #deposit - rebase deposit usd values are calculated correctly when deposit is made before positiveing rebase",
- "timedOut": false,
- "duration": 265,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await f.User.depositCollateral(f.user.address, f.KrAssetCollateral.address, this.krAssetCollateralAmount);\nconst valueBefore = await _hardhat.default.Diamond.getAccountTotalCollateralValue(f.user.address);\n// Rebase params\nconst denominator = 4;\nconst positive = true;\nconst newPrice = (0, _values.fromBig)(await f.KrAssetCollateral.getPrice(), 8) / denominator;\nf.KrAssetCollateral.setPrice(newPrice);\n// Rebase the asset according to params\nawait f.KrAssetCollateral.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Get collateral value of account after\nconst valueAfter = await _hardhat.default.Diamond.getAccountTotalCollateralValue(f.user.address);\n// Ensure that the collateral value stays the same\n(0, _chai.expect)(valueBefore).to.equal(valueAfter);",
- "err": {},
- "uuid": "39044cc9-09a4-459b-8fba-9daba87c1433",
- "parentUUID": "7fcf8e24-cbed-4e57-83d4-444c3bbc75f1",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when deposit is made before negative rebase",
- "fullTitle": "Minter - Deposit Withdraw #collateral #deposit - rebase deposit usd values are calculated correctly when deposit is made before negative rebase",
- "timedOut": false,
- "duration": 261,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await f.User.depositCollateral(f.user.address, f.KrAssetCollateral.address, this.krAssetCollateralAmount);\nconst valueBefore = await _hardhat.default.Diamond.getAccountTotalCollateralValue(f.user.address);\n// Rebase params\nconst denominator = 4;\nconst positive = false;\nconst newPrice = (0, _values.fromBig)(await f.KrAssetCollateral.getPrice(), 8) * denominator;\nf.KrAssetCollateral.setPrice(newPrice);\n// Rebase the asset according to params\nawait f.KrAssetCollateral.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Get collateral value of account after\nconst valueAfter = await _hardhat.default.Diamond.getAccountTotalCollateralValue(f.user.address);\n// Ensure that the collateral value stays the same\n(0, _chai.expect)(valueBefore).to.equal(valueAfter);",
- "err": {},
- "uuid": "d3dbb41c-155b-4243-bd2f-022ab55d2112",
- "parentUUID": "7fcf8e24-cbed-4e57-83d4-444c3bbc75f1",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when deposit is made after an positiveing rebase",
- "fullTitle": "Minter - Deposit Withdraw #collateral #deposit - rebase deposit usd values are calculated correctly when deposit is made after an positiveing rebase",
- "timedOut": false,
- "duration": 422,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = true;\nconst newPrice = (0, _values.fromBig)(await f.KrAssetCollateral.getPrice(), 8) / denominator;\n// Get expected value before rebase and deposit\nconst expectedValue = await _hardhat.default.Diamond.getValue(f.KrAssetCollateral.address, this.krAssetCollateralAmount);\nconst depositAmount = this.krAssetCollateralAmount.mul(denominator);\n// Rebase the asset according to params\nf.KrAssetCollateral.setPrice(newPrice);\nawait f.KrAssetCollateral.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Deposit rebased amount after\nawait f.User.depositCollateral(f.user.address, f.KrAssetCollateral.address, depositAmount);\n// Get collateral value of account after\nconst valueAfter = await _hardhat.default.Diamond.getValue(f.KrAssetCollateral.address, depositAmount);\n// Ensure that the collateral value stays the same\n(0, _chai.expect)(expectedValue).to.equal(valueAfter);",
- "err": {},
- "uuid": "df758d1d-0067-40dc-9943-d6419f03837e",
- "parentUUID": "7fcf8e24-cbed-4e57-83d4-444c3bbc75f1",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when deposit is made after an negative rebase",
- "fullTitle": "Minter - Deposit Withdraw #collateral #deposit - rebase deposit usd values are calculated correctly when deposit is made after an negative rebase",
- "timedOut": false,
- "duration": 190,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = false;\nconst newPrice = (0, _values.fromBig)(await f.KrAssetCollateral.getPrice(), 8) * denominator;\n// Get expected value before rebase and deposit\nconst expectedValue = await _hardhat.default.Diamond.getValue(f.KrAssetCollateral.address, this.krAssetCollateralAmount);\nconst depositAmount = this.krAssetCollateralAmount.div(denominator);\n// Rebase the asset according to params\nf.KrAssetCollateral.setPrice(newPrice);\nawait f.KrAssetCollateral.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Deposit rebased amount after\nawait f.User.depositCollateral(f.user.address, f.KrAssetCollateral.address, depositAmount);\n// Get collateral value of account after\nconst valueAfter = await _hardhat.default.Diamond.getValue(f.KrAssetCollateral.address, depositAmount);\n// Ensure that the collateral value stays the same\n(0, _chai.expect)(expectedValue).to.equal(valueAfter);",
- "err": {},
- "uuid": "a352d425-3a9b-4844-909b-90b053dbbabd",
- "parentUUID": "7fcf8e24-cbed-4e57-83d4-444c3bbc75f1",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when deposit is made before and after a positiveing rebase",
- "fullTitle": "Minter - Deposit Withdraw #collateral #deposit - rebase deposit usd values are calculated correctly when deposit is made before and after a positiveing rebase",
- "timedOut": false,
- "duration": 601,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = true;\nconst newPrice = (0, _values.fromBig)(await f.KrAssetCollateral.getPrice(), 8) / denominator;\n// Deposit half before, half after\nconst halfDepositBeforeRebase = this.krAssetCollateralAmount.div(2);\nconst halfDepositAfterRebase = this.krAssetCollateralAmount.div(2).mul(denominator);\nconst fullDepositAmount = this.krAssetCollateralAmount.mul(denominator);\nawait f.User.depositCollateral(f.user.address, f.KrAssetCollateral.address, halfDepositBeforeRebase);\nconst expectedValue = await _hardhat.default.Diamond.getValue(f.KrAssetCollateral.address, halfDepositBeforeRebase);\n// Rebase the asset according to params\nf.KrAssetCollateral.setPrice(newPrice);\nawait f.KrAssetCollateral.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Get value after\nconst valueAfterRebase = await _hardhat.default.Diamond.getValue(f.KrAssetCollateral.address, halfDepositAfterRebase);\n// Ensure that the collateral value stays the same\n(0, _chai.expect)(expectedValue).to.equal(valueAfterRebase);\n// Calculate added value since price adjusted in the rebase\nconst expectedValueAfterSecondDeposit = await _hardhat.default.Diamond.getValue(f.KrAssetCollateral.address, fullDepositAmount);\n// Deposit more\nawait f.User.depositCollateral(f.user.address, f.KrAssetCollateral.address, halfDepositAfterRebase);\n// Get value\nconst [finalValue] = await _hardhat.default.Diamond.getAccountCollateralValues(f.user.address, f.KrAssetCollateral.address);\n// Ensure that the collateral value stays the same\n(0, _chai.expect)(finalValue).to.equal(expectedValueAfterSecondDeposit);",
- "err": {},
- "uuid": "158194b5-b907-4191-be72-627b2b24d29e",
- "parentUUID": "7fcf8e24-cbed-4e57-83d4-444c3bbc75f1",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when deposit is made before and after a negative rebase",
- "fullTitle": "Minter - Deposit Withdraw #collateral #deposit - rebase deposit usd values are calculated correctly when deposit is made before and after a negative rebase",
- "timedOut": false,
- "duration": 608,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = false;\nconst newPrice = (0, _values.fromBig)(await f.KrAssetCollateral.getPrice(), 8) * denominator;\n// Deposit half before, half after\nconst halfDepositBeforeRebase = this.krAssetCollateralAmount.div(2);\nconst halfDepositAfterRebase = this.krAssetCollateralAmount.div(2).div(denominator);\nconst fullDepositAmount = this.krAssetCollateralAmount.div(denominator);\nawait f.User.depositCollateral(f.user.address, f.KrAssetCollateral.address, halfDepositBeforeRebase);\nconst expectedValue = await _hardhat.default.Diamond.getValue(f.KrAssetCollateral.address, halfDepositBeforeRebase);\n// Rebase the asset according to params\nf.KrAssetCollateral.setPrice(newPrice);\nawait f.KrAssetCollateral.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Get value after\nconst valueAfterRebase = await _hardhat.default.Diamond.getValue(f.KrAssetCollateral.address, halfDepositAfterRebase);\n// Ensure that the collateral value stays the same\n(0, _chai.expect)(expectedValue).to.equal(valueAfterRebase);\n// Calculate added value since price adjusted in the rebase\nconst expectedValueAfterSecondDeposit = await _hardhat.default.Diamond.getValue(f.KrAssetCollateral.address, fullDepositAmount);\n// Deposit more\nawait f.User.depositCollateral(f.user.address, f.KrAssetCollateral.address, halfDepositAfterRebase);\n// Get deposits after\nconst [finalValue] = await _hardhat.default.Diamond.getAccountCollateralValues(f.user.address, f.KrAssetCollateral.address);\n// Ensure that the collateral value stays the same\n(0, _chai.expect)(finalValue).to.equal(expectedValueAfterSecondDeposit);",
- "err": {},
- "uuid": "b8b45b83-9601-4ed0-8642-2ad5d470ecbc",
- "parentUUID": "7fcf8e24-cbed-4e57-83d4-444c3bbc75f1",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "39044cc9-09a4-459b-8fba-9daba87c1433",
- "d3dbb41c-155b-4243-bd2f-022ab55d2112",
- "df758d1d-0067-40dc-9943-d6419f03837e",
- "a352d425-3a9b-4844-909b-90b053dbbabd",
- "158194b5-b907-4191-be72-627b2b24d29e",
- "b8b45b83-9601-4ed0-8642-2ad5d470ecbc"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 2347,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "64478d6a-cd26-4c06-a7b3-e4dc8fe84e69",
- "title": "#withdraw - rebase",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/02-deposit-withdraw.ts",
- "file": "/src/test/minter/02-deposit-withdraw.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"#withdraw - rebase\"",
- "fullTitle": "Minter - Deposit Withdraw #collateral #withdraw - rebase \"before each\" hook in \"#withdraw - rebase\"",
- "timedOut": false,
- "duration": 187,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await f.Withdrawer.mintKreskoAsset(f.withdrawer.address, f.KrAssetCollateral.address, mintAmount);\n// Deposit all debt on tests\nthis.krAssetCollateralAmount = await _optimizations.default.getAccountDebtAmount(f.withdrawer.address, f.KrAssetCollateral);",
- "err": {},
- "uuid": "5fffdf0d-e269-460b-9ef4-218378e44a94",
- "parentUUID": "64478d6a-cd26-4c06-a7b3-e4dc8fe84e69",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [],
- "suites": [
- {
- "uuid": "677433fb-76df-496f-8ed1-00bfb59379ba",
- "title": "withdraw amounts are calculated correctly",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/02-deposit-withdraw.ts",
- "file": "/src/test/minter/02-deposit-withdraw.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "when withdrawing a deposit made before positive rebase",
- "fullTitle": "Minter - Deposit Withdraw #collateral #withdraw - rebase withdraw amounts are calculated correctly when withdrawing a deposit made before positive rebase",
- "timedOut": false,
- "duration": 272,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = true;\nconst rebasedDepositAmount = this.krAssetCollateralAmount.mul(denominator);\n// Deposit collateral before rebase\nawait f.Withdrawer.depositCollateral(f.withdrawer.address, f.KrAssetCollateral.address, this.krAssetCollateralAmount);\n// Rebase the asset according to params\nawait f.KrAssetCollateral.contract.rebase((0, _values.toBig)(denominator), positive, []);\nconst depositsAfter = await _hardhat.default.Diamond.getAccountCollateralAmount(f.withdrawer.address, f.KrAssetCollateral.address);\n// Ensure that the collateral balance is adjusted by the rebase\n(0, _chai.expect)(depositsAfter).to.equal(rebasedDepositAmount);\n// Withdraw rebased amount\nawait f.Withdrawer.withdrawCollateral(f.withdrawer.address, f.KrAssetCollateral.address, rebasedDepositAmount, _optimizations.default.getAccountDepositIndex(f.withdrawer.address, f.KrAssetCollateral.address));\nconst finalDeposits = await _hardhat.default.Diamond.getAccountCollateralAmount(f.withdrawer.address, f.KrAssetCollateral.address);\nconst finalBalance = await f.KrAssetCollateral.contract.balanceOf(f.withdrawer.address);\n(0, _chai.expect)(finalDeposits).to.equal(0);\n(0, _chai.expect)(finalBalance).to.equal(rebasedDepositAmount);",
- "err": {},
- "uuid": "db9e226a-28bf-4c89-a74a-7d4b0f549292",
- "parentUUID": "677433fb-76df-496f-8ed1-00bfb59379ba",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when withdrawing a deposit made before negative rebase",
- "fullTitle": "Minter - Deposit Withdraw #collateral #withdraw - rebase withdraw amounts are calculated correctly when withdrawing a deposit made before negative rebase",
- "timedOut": false,
- "duration": 272,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = false;\nconst rebasedDepositAmount = this.krAssetCollateralAmount.div(denominator);\n// Deposit collateral before rebase\nawait f.Withdrawer.depositCollateral(f.withdrawer.address, f.KrAssetCollateral.address, this.krAssetCollateralAmount);\n// Rebase the asset according to params\nawait f.KrAssetCollateral.contract.rebase((0, _values.toBig)(denominator), positive, []);\nconst depositsAfter = await _hardhat.default.Diamond.getAccountCollateralAmount(f.withdrawer.address, f.KrAssetCollateral.address);\n// Ensure that the collateral balance is adjusted by the rebase\n(0, _chai.expect)(depositsAfter).to.equal(rebasedDepositAmount);\n// Withdraw rebased amount\nawait f.Withdrawer.withdrawCollateral(f.withdrawer.address, f.KrAssetCollateral.address, rebasedDepositAmount, _optimizations.default.getAccountDepositIndex(f.withdrawer.address, f.KrAssetCollateral.address));\nconst finalDeposits = await _hardhat.default.Diamond.getAccountCollateralAmount(f.withdrawer.address, f.KrAssetCollateral.address);\nconst finalBalance = await f.KrAssetCollateral.contract.balanceOf(f.withdrawer.address);\n(0, _chai.expect)(finalDeposits).to.equal(0);\n(0, _chai.expect)(finalBalance).to.equal(rebasedDepositAmount);",
- "err": {},
- "uuid": "724f3052-3358-4f0e-be84-6b1f9d07194f",
- "parentUUID": "677433fb-76df-496f-8ed1-00bfb59379ba",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when withdrawing a deposit made after an positive rebase",
- "fullTitle": "Minter - Deposit Withdraw #collateral #withdraw - rebase withdraw amounts are calculated correctly when withdrawing a deposit made after an positive rebase",
- "timedOut": false,
- "duration": 271,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = true;\nconst rebasedDepositAmount = this.krAssetCollateralAmount.mul(denominator);\n// Rebase the asset according to params\nawait f.KrAssetCollateral.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Deposit after the rebase\nawait f.Withdrawer.depositCollateral(f.withdrawer.address, f.KrAssetCollateral.address, rebasedDepositAmount);\n// Get collateral deposits after\nconst depositsAfter = await _hardhat.default.Diamond.getAccountCollateralAmount(f.withdrawer.address, f.KrAssetCollateral.address);\n// Ensure that the collateral balance is what was deposited as no rebases occured after\n(0, _chai.expect)(depositsAfter).to.equal(rebasedDepositAmount);\n// Withdraw rebased amount\nawait f.Withdrawer.withdrawCollateral(f.withdrawer.address, f.KrAssetCollateral.address, rebasedDepositAmount, _optimizations.default.getAccountDepositIndex(f.withdrawer.address, f.KrAssetCollateral.address));\nconst finalDeposits = await _hardhat.default.Diamond.getAccountCollateralAmount(f.withdrawer.address, f.KrAssetCollateral.address);\nconst finalBalance = await f.KrAssetCollateral.contract.balanceOf(f.withdrawer.address);\n(0, _chai.expect)(finalDeposits).to.equal(0);\n(0, _chai.expect)(finalBalance).to.equal(rebasedDepositAmount);",
- "err": {},
- "uuid": "0d20077b-ec57-4873-b46d-28f066b6665e",
- "parentUUID": "677433fb-76df-496f-8ed1-00bfb59379ba",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when withdrawing a deposit made after a negative rebase",
- "fullTitle": "Minter - Deposit Withdraw #collateral #withdraw - rebase withdraw amounts are calculated correctly when withdrawing a deposit made after a negative rebase",
- "timedOut": false,
- "duration": 270,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = false;\nconst rebasedDepositAmount = this.krAssetCollateralAmount.div(denominator);\n// Rebase the asset according to params\nawait f.KrAssetCollateral.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Deposit after the rebase\nawait f.Withdrawer.depositCollateral(f.withdrawer.address, f.KrAssetCollateral.address, rebasedDepositAmount);\n// Get collateral deposits after\nconst depositsAfter = await _hardhat.default.Diamond.getAccountCollateralAmount(f.withdrawer.address, f.KrAssetCollateral.address);\n// Ensure that the collateral balance is what was deposited as no rebases occured after\n(0, _chai.expect)(depositsAfter).to.equal(rebasedDepositAmount);\n// Withdraw rebased amount\nawait f.Withdrawer.withdrawCollateral(f.withdrawer.address, f.KrAssetCollateral.address, rebasedDepositAmount, _optimizations.default.getAccountDepositIndex(f.withdrawer.address, f.KrAssetCollateral.address));\nconst finalDeposits = await _hardhat.default.Diamond.getAccountCollateralAmount(f.withdrawer.address, f.KrAssetCollateral.address);\nconst finalBalance = await f.KrAssetCollateral.contract.balanceOf(f.withdrawer.address);\n(0, _chai.expect)(finalDeposits).to.equal(0);\n(0, _chai.expect)(finalBalance).to.equal(rebasedDepositAmount);",
- "err": {},
- "uuid": "498df40a-bdd2-4156-af08-133573221213",
- "parentUUID": "677433fb-76df-496f-8ed1-00bfb59379ba",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when withdrawing a deposit made before and after a positive rebase",
- "fullTitle": "Minter - Deposit Withdraw #collateral #withdraw - rebase withdraw amounts are calculated correctly when withdrawing a deposit made before and after a positive rebase",
- "timedOut": false,
- "duration": 348,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = true;\n// Deposit half before, half (rebase adjusted) after\nconst firstDepositAmount = this.krAssetCollateralAmount.div(2);\nconst secondDepositAmount = this.krAssetCollateralAmount.div(2).mul(denominator);\nconst fullDepositAmount = this.krAssetCollateralAmount.mul(denominator);\n// Deposit before the rebase\nawait f.Withdrawer.depositCollateral(f.withdrawer.address, f.KrAssetCollateral.address, firstDepositAmount);\n// Get deposits before\nconst depositsFirst = await _hardhat.default.Diamond.getAccountCollateralAmount(f.withdrawer.address, f.KrAssetCollateral.address);\n(0, _chai.expect)(depositsFirst).to.equal(firstDepositAmount);\n// Rebase the asset according to params\nawait f.KrAssetCollateral.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Deposit after the rebase\nawait f.Withdrawer.depositCollateral(f.withdrawer.address, f.KrAssetCollateral.address, secondDepositAmount);\n// Get collateral deposits after\nconst depositsAfter = await _hardhat.default.Diamond.getAccountCollateralAmount(f.withdrawer.address, f.KrAssetCollateral.address);\n// Ensure deposit balance matches expected\n(0, _chai.expect)(depositsAfter).to.equal(fullDepositAmount);\n// Withdraw rebased amount\nawait f.Withdrawer.withdrawCollateral(f.withdrawer.address, f.KrAssetCollateral.address, fullDepositAmount, _optimizations.default.getAccountDepositIndex(f.withdrawer.address, f.KrAssetCollateral.address));\nconst finalDeposits = await _hardhat.default.Diamond.getAccountCollateralAmount(f.withdrawer.address, f.KrAssetCollateral.address);\nconst finalBalance = await f.KrAssetCollateral.contract.balanceOf(f.withdrawer.address);\n(0, _chai.expect)(finalDeposits).to.equal(0);\n(0, _chai.expect)(finalBalance).to.equal(fullDepositAmount);",
- "err": {},
- "uuid": "90e8da09-a741-491c-9fc4-b07b79968a63",
- "parentUUID": "677433fb-76df-496f-8ed1-00bfb59379ba",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when withdrawing a deposit made before and after a negative rebase",
- "fullTitle": "Minter - Deposit Withdraw #collateral #withdraw - rebase withdraw amounts are calculated correctly when withdrawing a deposit made before and after a negative rebase",
- "timedOut": false,
- "duration": 351,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = false;\n// Deposit half before, half (rebase adjusted) after\nconst firstDepositAmount = this.krAssetCollateralAmount.div(2);\nconst secondDepositAmount = this.krAssetCollateralAmount.div(2).div(denominator);\nconst fullDepositAmount = this.krAssetCollateralAmount.div(denominator);\n// Deposit before the rebase\nawait f.Withdrawer.depositCollateral(f.withdrawer.address, f.KrAssetCollateral.address, firstDepositAmount);\n// Get deposits before\nconst depositsFirst = await _hardhat.default.Diamond.getAccountCollateralAmount(f.withdrawer.address, f.KrAssetCollateral.address);\n(0, _chai.expect)(depositsFirst).to.equal(firstDepositAmount);\n// Rebase the asset according to params\nawait f.KrAssetCollateral.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Deposit after the rebase\nawait f.Withdrawer.depositCollateral(f.withdrawer.address, f.KrAssetCollateral.address, secondDepositAmount);\n// Get collateral deposits after\nconst depositsAfter = await _hardhat.default.Diamond.getAccountCollateralAmount(f.withdrawer.address, f.KrAssetCollateral.address);\n// Ensure deposit balance matches expected\n(0, _chai.expect)(depositsAfter).to.equal(fullDepositAmount);\n// Withdraw rebased amount\nawait f.Withdrawer.withdrawCollateral(f.withdrawer.address, f.KrAssetCollateral.address, fullDepositAmount, _optimizations.default.getAccountDepositIndex(f.withdrawer.address, f.KrAssetCollateral.address));\nconst finalDeposits = await _hardhat.default.Diamond.getAccountCollateralAmount(f.withdrawer.address, f.KrAssetCollateral.address);\nconst finalBalance = await f.KrAssetCollateral.contract.balanceOf(f.withdrawer.address);\n(0, _chai.expect)(finalDeposits).to.equal(0);\n(0, _chai.expect)(finalBalance).to.equal(fullDepositAmount);",
- "err": {},
- "uuid": "47350b60-2c68-49f9-9f7b-59762b1fac9d",
- "parentUUID": "677433fb-76df-496f-8ed1-00bfb59379ba",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when withdrawing a non-rebased collateral after a rebase",
- "fullTitle": "Minter - Deposit Withdraw #collateral #withdraw - rebase withdraw amounts are calculated correctly when withdrawing a non-rebased collateral after a rebase",
- "timedOut": false,
- "duration": 233,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = true;\nconst newPrice = (0, _values.fromBig)(await f.KrAssetCollateral.getPrice(), 8) / denominator;\nconst withdrawAmount = (0, _values.toBig)(10);\nawait f.Withdrawer.depositCollateral(f.withdrawer.address, f.KrAssetCollateral.address, this.krAssetCollateralAmount);\nconst nrcBalanceBefore = await f.Collateral.contract.balanceOf(f.withdrawer.address);\nconst expectedNrcBalanceAfter = nrcBalanceBefore.add(withdrawAmount);\n// Rebase the asset according to params\nf.KrAssetCollateral.setPrice(newPrice);\nawait f.KrAssetCollateral.contract.rebase((0, _values.toBig)(denominator), positive, []);\nawait f.Withdrawer.withdrawCollateral(f.withdrawer.address, f.Collateral.address, withdrawAmount, _optimizations.default.getAccountDepositIndex(f.withdrawer.address, f.Collateral.address));\n(0, _chai.expect)(await f.Collateral.contract.balanceOf(f.withdrawer.address)).to.equal(expectedNrcBalanceAfter);",
- "err": {},
- "uuid": "3c1f0a3d-a389-432d-a9ab-b7ca136c5097",
- "parentUUID": "677433fb-76df-496f-8ed1-00bfb59379ba",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "db9e226a-28bf-4c89-a74a-7d4b0f549292",
- "724f3052-3358-4f0e-be84-6b1f9d07194f",
- "0d20077b-ec57-4873-b46d-28f066b6665e",
- "498df40a-bdd2-4156-af08-133573221213",
- "90e8da09-a741-491c-9fc4-b07b79968a63",
- "47350b60-2c68-49f9-9f7b-59762b1fac9d",
- "3c1f0a3d-a389-432d-a9ab-b7ca136c5097"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 2017,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "38c4089e-a870-41f1-a8cf-b241be9cb543",
- "title": "withdraw usd values are calculated correctly",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/02-deposit-withdraw.ts",
- "file": "/src/test/minter/02-deposit-withdraw.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "when withdrawing a deposit made before positive rebase",
- "fullTitle": "Minter - Deposit Withdraw #collateral #withdraw - rebase withdraw usd values are calculated correctly when withdrawing a deposit made before positive rebase",
- "timedOut": false,
- "duration": 269,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = true;\nconst newPrice = (0, _values.fromBig)(await f.KrAssetCollateral.getPrice(), 8) / denominator;\nconst rebasedDepositAmount = this.krAssetCollateralAmount.mul(denominator);\nawait f.Withdrawer.depositCollateral(f.withdrawer.address, f.KrAssetCollateral.address, this.krAssetCollateralAmount);\n// Rebase the asset according to params\nf.KrAssetCollateral.setPrice(newPrice);\nawait f.KrAssetCollateral.contract.rebase((0, _values.toBig)(denominator), positive, []);\nawait f.Withdrawer.withdrawCollateral(f.withdrawer.address, f.KrAssetCollateral.address, rebasedDepositAmount, _optimizations.default.getAccountDepositIndex(f.withdrawer.address, f.KrAssetCollateral.address));\nconst [finalValue] = await _hardhat.default.Diamond.getAccountCollateralValues(f.withdrawer.address, f.KrAssetCollateral.address);\n(0, _chai.expect)(finalValue).to.equal(0);\n(0, _chai.expect)(await f.KrAssetCollateral.contract.balanceOf(f.withdrawer.address)).to.equal(rebasedDepositAmount);",
- "err": {},
- "uuid": "f437bcdc-44e8-499f-b439-d06b0ab7f0af",
- "parentUUID": "38c4089e-a870-41f1-a8cf-b241be9cb543",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when withdrawing a deposit made before negative rebase",
- "fullTitle": "Minter - Deposit Withdraw #collateral #withdraw - rebase withdraw usd values are calculated correctly when withdrawing a deposit made before negative rebase",
- "timedOut": false,
- "duration": 266,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = false;\nconst newPrice = (0, _values.fromBig)(await f.KrAssetCollateral.getPrice(), 8) * denominator;\nconst rebasedDepositAmount = this.krAssetCollateralAmount.div(denominator);\n// Deposit\nawait f.Withdrawer.depositCollateral(f.withdrawer.address, f.KrAssetCollateral.address, this.krAssetCollateralAmount);\n// Rebase the asset according to params\nf.KrAssetCollateral.setPrice(newPrice);\nawait f.KrAssetCollateral.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Withdraw the full rebased amount\nawait f.Withdrawer.withdrawCollateral(f.withdrawer.address, f.KrAssetCollateral.address, rebasedDepositAmount, _optimizations.default.getAccountDepositIndex(f.withdrawer.address, f.KrAssetCollateral.address));\n// Get value\nconst [finalValue] = await _hardhat.default.Diamond.getAccountCollateralValues(f.withdrawer.address, f.KrAssetCollateral.address);\n(0, _chai.expect)(finalValue).to.equal(0);\n(0, _chai.expect)(await f.KrAssetCollateral.contract.balanceOf(f.withdrawer.address)).to.equal(rebasedDepositAmount);",
- "err": {},
- "uuid": "9bcff93f-6ed6-4697-ac9c-e2a51ab0383c",
- "parentUUID": "38c4089e-a870-41f1-a8cf-b241be9cb543",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when withdrwaing a deposit made after an positiveing rebase",
- "fullTitle": "Minter - Deposit Withdraw #collateral #withdraw - rebase withdraw usd values are calculated correctly when withdrwaing a deposit made after an positiveing rebase",
- "timedOut": false,
- "duration": 266,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = true;\nconst newPrice = (0, _values.fromBig)(await f.KrAssetCollateral.getPrice(), 8) / denominator;\nconst depositAmount = this.krAssetCollateralAmount.mul(denominator);\n// Rebase the asset according to params\nf.KrAssetCollateral.setPrice(newPrice);\nawait f.KrAssetCollateral.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Deposit rebased amount after\nawait f.Withdrawer.depositCollateral(f.withdrawer.address, f.KrAssetCollateral.address, depositAmount);\n// Withdraw the full rebased amount\nawait f.Withdrawer.withdrawCollateral(f.withdrawer.address, f.KrAssetCollateral.address, depositAmount, _optimizations.default.getAccountDepositIndex(f.withdrawer.address, f.KrAssetCollateral.address));\n// Get value\nconst [finalValue] = await _hardhat.default.Diamond.getAccountCollateralValues(f.withdrawer.address, f.KrAssetCollateral.address);\n(0, _chai.expect)(finalValue).to.equal(0);\n(0, _chai.expect)(await f.KrAssetCollateral.contract.balanceOf(f.withdrawer.address)).to.equal(depositAmount);",
- "err": {},
- "uuid": "e8a77c8f-62d5-4855-9bde-d1d92aa23900",
- "parentUUID": "38c4089e-a870-41f1-a8cf-b241be9cb543",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when withdrawing a deposit made after an negative rebase",
- "fullTitle": "Minter - Deposit Withdraw #collateral #withdraw - rebase withdraw usd values are calculated correctly when withdrawing a deposit made after an negative rebase",
- "timedOut": false,
- "duration": 266,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = false;\nconst newPrice = (0, _values.fromBig)(await f.KrAssetCollateral.getPrice(), 8) * denominator;\nconst depositAmount = this.krAssetCollateralAmount.div(denominator);\n// Rebase the asset according to params\nf.KrAssetCollateral.setPrice(newPrice);\nawait f.KrAssetCollateral.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Deposit rebased amount after\nawait f.Withdrawer.depositCollateral(f.withdrawer.address, f.KrAssetCollateral.address, depositAmount);\n// Withdraw the full rebased amount\nawait f.Withdrawer.withdrawCollateral(f.withdrawer.address, f.KrAssetCollateral.address, depositAmount, _optimizations.default.getAccountDepositIndex(f.withdrawer.address, f.KrAssetCollateral.address));\n// Get value\nconst [finalValue] = await _hardhat.default.Diamond.getAccountCollateralValues(f.withdrawer.address, f.KrAssetCollateral.address);\n(0, _chai.expect)(finalValue).to.equal(0);\n(0, _chai.expect)(await f.KrAssetCollateral.contract.balanceOf(f.withdrawer.address)).to.equal(depositAmount);",
- "err": {},
- "uuid": "32464c4b-97da-4cbe-8501-7bc71d3dfc80",
- "parentUUID": "38c4089e-a870-41f1-a8cf-b241be9cb543",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when withdrawing a deposit made before and after a positive rebase",
- "fullTitle": "Minter - Deposit Withdraw #collateral #withdraw - rebase withdraw usd values are calculated correctly when withdrawing a deposit made before and after a positive rebase",
- "timedOut": false,
- "duration": 470,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = true;\nconst newPrice = (0, _values.fromBig)(await f.KrAssetCollateral.getPrice(), 8) / denominator;\n// Deposit half before, half after\nconst firstDepositAmount = this.krAssetCollateralAmount.div(2);\nconst secondDepositAmount = this.krAssetCollateralAmount.div(2).mul(denominator);\nconst fullDepositAmount = this.krAssetCollateralAmount.mul(denominator);\nawait f.Withdrawer.depositCollateral(f.withdrawer.address, f.KrAssetCollateral.address, firstDepositAmount);\nconst [expectedValue] = await _hardhat.default.Diamond.getAccountCollateralValues(f.withdrawer.address, f.KrAssetCollateral.address);\n// Rebase the asset according to params\nf.KrAssetCollateral.setPrice(newPrice);\nawait f.KrAssetCollateral.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Get value after\nconst [valueAfterRebase] = await _hardhat.default.Diamond.getAccountCollateralValues(f.withdrawer.address, f.KrAssetCollateral.address);\n// Ensure that the collateral value stays the same\n(0, _chai.expect)(expectedValue).to.equal(valueAfterRebase);\n// Deposit more\nawait f.Withdrawer.depositCollateral(f.withdrawer.address, f.KrAssetCollateral.address, secondDepositAmount);\n// Withdraw the full rebased amount\nawait f.Withdrawer.withdrawCollateral(f.withdrawer.address, f.KrAssetCollateral.address, fullDepositAmount, _optimizations.default.getAccountDepositIndex(f.withdrawer.address, f.KrAssetCollateral.address));\n// Get value\nconst [finalValue] = await _hardhat.default.Diamond.getAccountCollateralValues(f.withdrawer.address, f.KrAssetCollateral.address);\n(0, _chai.expect)(finalValue).to.equal(0);\n(0, _chai.expect)(await f.KrAssetCollateral.contract.balanceOf(f.withdrawer.address)).to.equal(fullDepositAmount);",
- "err": {},
- "uuid": "f456e803-84f4-4a92-b609-1e16442d82c6",
- "parentUUID": "38c4089e-a870-41f1-a8cf-b241be9cb543",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when withdrawing a deposit made before and after a negative rebase",
- "fullTitle": "Minter - Deposit Withdraw #collateral #withdraw - rebase withdraw usd values are calculated correctly when withdrawing a deposit made before and after a negative rebase",
- "timedOut": false,
- "duration": 461,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = false;\nconst newPrice = (0, _values.fromBig)(await f.KrAssetCollateral.getPrice(), 8) * denominator;\n// Deposit half before, half after\nconst firstDepositAmount = this.krAssetCollateralAmount.div(2);\nconst secondDepositAmount = this.krAssetCollateralAmount.div(denominator).div(2);\nconst fullDepositAmount = this.krAssetCollateralAmount.div(denominator);\nawait f.Withdrawer.depositCollateral(f.withdrawer.address, f.KrAssetCollateral.address, firstDepositAmount);\nconst [expectedValue] = await _hardhat.default.Diamond.getAccountCollateralValues(f.withdrawer.address, f.KrAssetCollateral.address);\n// Rebase the asset according to params\nf.KrAssetCollateral.setPrice(newPrice);\nawait f.KrAssetCollateral.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Get value after\nconst [valueAfterRebase] = await _hardhat.default.Diamond.getAccountCollateralValues(f.withdrawer.address, f.KrAssetCollateral.address);\n// Ensure that the collateral value stays the same\n(0, _chai.expect)(expectedValue).to.equal(valueAfterRebase);\n// Deposit more\nawait f.Withdrawer.depositCollateral(f.withdrawer.address, f.KrAssetCollateral.address, secondDepositAmount);\n// Withdraw the full rebased amount\nawait f.Withdrawer.withdrawCollateral(f.withdrawer.address, f.KrAssetCollateral.address, fullDepositAmount, _optimizations.default.getAccountDepositIndex(f.withdrawer.address, f.KrAssetCollateral.address));\n// Get value\nconst [finalValue] = await _hardhat.default.Diamond.getAccountCollateralValues(f.withdrawer.address, f.KrAssetCollateral.address);\n(0, _chai.expect)(finalValue).to.equal(0);\n(0, _chai.expect)(await f.KrAssetCollateral.contract.balanceOf(f.withdrawer.address)).to.equal(fullDepositAmount);",
- "err": {},
- "uuid": "7df9221b-7f05-4115-8d5b-f6b5c62fb9ff",
- "parentUUID": "38c4089e-a870-41f1-a8cf-b241be9cb543",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when withdrawing a non-rebased collateral after a rebase",
- "fullTitle": "Minter - Deposit Withdraw #collateral #withdraw - rebase withdraw usd values are calculated correctly when withdrawing a non-rebased collateral after a rebase",
- "timedOut": false,
- "duration": 657,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = true;\nconst newPrice = (0, _values.fromBig)(await f.KrAssetCollateral.getPrice(), 8) / denominator;\nconst withdrawAmount = (0, _values.toBig)(10);\nawait f.Withdrawer.depositCollateral(f.withdrawer.address, f.KrAssetCollateral.address, this.krAssetCollateralAmount);\nconst accountValueBefore = await _hardhat.default.Diamond.getAccountTotalCollateralValue(f.withdrawer.address);\nconst [nrcValueBefore] = await _hardhat.default.Diamond.getAccountCollateralValues(f.withdrawer.address, f.Collateral.address);\nconst withdrawValue = await _hardhat.default.Diamond.getValue(f.Collateral.address, withdrawAmount);\nconst expectedNrcValueAfter = nrcValueBefore.sub(withdrawValue);\n// Rebase the asset according to params\nf.KrAssetCollateral.setPrice(newPrice);\nawait f.KrAssetCollateral.contract.rebase((0, _values.toBig)(denominator), positive, []);\nawait f.Withdrawer.withdrawCollateral(f.withdrawer.address, f.Collateral.address, withdrawAmount, _optimizations.default.getAccountDepositIndex(f.withdrawer.address, f.KrAssetCollateral.address));\nconst finalAccountValue = await _hardhat.default.Diamond.getAccountTotalCollateralValue(f.withdrawer.address);\nconst [finalValue] = await _hardhat.default.Diamond.getAccountCollateralValues(f.withdrawer.address, f.Collateral.address);\n(0, _chai.expect)(finalValue).to.equal(expectedNrcValueAfter);\n(0, _chai.expect)(finalAccountValue).to.equal(accountValueBefore.sub(withdrawValue));",
- "err": {},
- "uuid": "73171270-db4d-4ee4-acf4-1ade48a54105",
- "parentUUID": "38c4089e-a870-41f1-a8cf-b241be9cb543",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "f437bcdc-44e8-499f-b439-d06b0ab7f0af",
- "9bcff93f-6ed6-4697-ac9c-e2a51ab0383c",
- "e8a77c8f-62d5-4855-9bde-d1d92aa23900",
- "32464c4b-97da-4cbe-8501-7bc71d3dfc80",
- "f456e803-84f4-4a92-b609-1e16442d82c6",
- "7df9221b-7f05-4115-8d5b-f6b5c62fb9ff",
- "73171270-db4d-4ee4-acf4-1ade48a54105"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 2655,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "7f3ab3a3-0296-40da-b91f-eaa8fe804f7c",
- "title": "Minter - Liquidations",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/03-liquidation.ts",
- "file": "/src/test/minter/03-liquidation.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"Minter - Liquidations\"",
- "fullTitle": "Minter - Liquidations \"before each\" hook in \"Minter - Liquidations\"",
- "timedOut": false,
- "duration": 78,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "f = await (0, _fixtures.liquidationsFixture)();\nawait f.reset();",
- "err": {},
- "uuid": "dc88cd6d-756c-4c53-8c38-9e497d3dbc30",
- "parentUUID": "7f3ab3a3-0296-40da-b91f-eaa8fe804f7c",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [],
- "suites": [
- {
- "uuid": "ac55a09c-3f3f-4a8f-9d34-0e0af787f0f0",
- "title": "#isAccountLiquidatable",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/03-liquidation.ts",
- "file": "/src/test/minter/03-liquidation.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "should identify accounts below their liquidation threshold",
- "fullTitle": "Minter - Liquidations #isAccountLiquidatable should identify accounts below their liquidation threshold",
- "timedOut": false,
- "duration": 431,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const [cr, minCollateralUSD, initialCanLiquidate] = await Promise.all([\n hre.Diamond.getAccountCollateralRatio(f.user1.address),\n hre.Diamond.getAccountMinCollateralAtRatio(f.user1.address, hre.Diamond.getLiquidationThresholdMinter()),\n hre.Diamond.getAccountLiquidatable(f.user1.address)\n]);\n(0, _chai.expect)(cr).to.be.equal(1.5e4);\n(0, _chai.expect)(f.initialDeposits.mul(10).gt(minCollateralUSD));\n(0, _chai.expect)(initialCanLiquidate).to.equal(false);\nf.Collateral.setPrice(7.5);\n(0, _chai.expect)(await hre.Diamond.getAccountLiquidatable(f.user1.address)).to.equal(true);",
- "err": {},
- "uuid": "650c6f04-b648-4adf-8231-439d059e60d0",
- "parentUUID": "ac55a09c-3f3f-4a8f-9d34-0e0af787f0f0",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "650c6f04-b648-4adf-8231-439d059e60d0"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 431,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "1f2b3905-e8bf-4d06-b892-4647353105c0",
- "title": "#maxLiquidatableValue",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/03-liquidation.ts",
- "file": "/src/test/minter/03-liquidation.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "calculates correct MLV when kFactor = 1, cFactor = 0.25",
- "fullTitle": "Minter - Liquidations #maxLiquidatableValue calculates correct MLV when kFactor = 1, cFactor = 0.25",
- "timedOut": false,
- "duration": 1170,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const MLVBeforeC1 = await hre.Diamond.getMaxLiqValue(f.user1.address, f.KrAsset.address, f.Collateral.address);\nconst MLVBeforeC2 = await hre.Diamond.getMaxLiqValue(f.user1.address, f.KrAsset.address, f.Collateral2.address);\n(0, _chai.expect)(MLVBeforeC1.repayValue).to.be.closeTo(MLVBeforeC2.repayValue, USD_DELTA);\nawait hre.Diamond.setAssetCFactor(f.Collateral.address, 0.25e4);\nawait (0, _collaterals.depositMockCollateral)({\n user: f.user1,\n amount: f.initialDeposits.div(2),\n asset: f.Collateral2\n});\nconst expectedCR = 1.125e4;\nconst [crAfter, isLiquidatableAfter, MLVAfterC1, MLVAfterC2] = await Promise.all([\n hre.Diamond.getAccountCollateralRatio(f.user1.address),\n hre.Diamond.getAccountLiquidatable(f.user1.address),\n hre.Diamond.getMaxLiqValue(f.user1.address, f.KrAsset.address, f.Collateral.address),\n hre.Diamond.getMaxLiqValue(f.user1.address, f.KrAsset.address, f.Collateral2.address)\n]);\n(0, _chai.expect)(isLiquidatableAfter).to.be.true;\n(0, _chai.expect)(crAfter).to.be.closeTo(expectedCR, 1);\n(0, _chai.expect)(MLVAfterC1.repayValue).to.gt(MLVBeforeC1.repayValue);\n(0, _chai.expect)(MLVAfterC2.repayValue).to.gt(MLVBeforeC2.repayValue);\n(0, _chai.expect)(MLVAfterC2.repayValue.gt(MLVAfterC1.repayValue)).to.be.true;",
- "err": {},
- "uuid": "2e8ce7c5-126d-45ee-9b92-bea0c11f76f9",
- "parentUUID": "1f2b3905-e8bf-4d06-b892-4647353105c0",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "calculates correct MLV with multiple cdps",
- "fullTitle": "Minter - Liquidations #maxLiquidatableValue calculates correct MLV with multiple cdps",
- "timedOut": false,
- "duration": 623,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await (0, _collaterals.depositMockCollateral)({\n user: f.user1,\n amount: (0, _values.toBig)(0.1, 8),\n asset: f.Collateral8Dec\n});\nf.Collateral.setPrice(7.5);\n(0, _chai.expect)(await hre.Diamond.getAccountLiquidatable(f.user1.address)).to.be.true;\nconst [maxLiq, maxLiq8Dec] = await Promise.all([\n hre.Diamond.getMaxLiqValue(f.user1.address, f.KrAsset.address, f.Collateral.address),\n hre.Diamond.getMaxLiqValue(f.user1.address, f.KrAsset.address, f.Collateral8Dec.address)\n]);\n(0, _chai.expect)(maxLiq.repayValue).gt(0);\n(0, _chai.expect)(maxLiq8Dec.repayValue).gt(0);\n(0, _chai.expect)(maxLiq.repayValue).gt(maxLiq8Dec.repayValue);",
- "err": {},
- "uuid": "39788d8c-307f-4f86-8d95-74acc8242360",
- "parentUUID": "1f2b3905-e8bf-4d06-b892-4647353105c0",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "2e8ce7c5-126d-45ee-9b92-bea0c11f76f9",
- "39788d8c-307f-4f86-8d95-74acc8242360"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 1793,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "3d0f8970-626e-4cd1-a8f5-66f6a7ecd198",
- "title": "#liquidation",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/03-liquidation.ts",
- "file": "/src/test/minter/03-liquidation.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [],
- "suites": [
- {
- "uuid": "ddacfe46-ad5b-49d6-bf59-1261753e4093",
- "title": "#liquidate",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/03-liquidation.ts",
- "file": "/src/test/minter/03-liquidation.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"#liquidate\"",
- "fullTitle": "Minter - Liquidations #liquidation #liquidate \"before each\" hook in \"#liquidate\"",
- "timedOut": false,
- "duration": 0,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "f.Collateral.setPrice(7.5);",
- "err": {},
- "uuid": "7da32ea1-fa09-4f0b-a7b6-18dcf544849c",
- "parentUUID": "ddacfe46-ad5b-49d6-bf59-1261753e4093",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [
- {
- "title": "should allow unhealthy accounts to be liquidated",
- "fullTitle": "Minter - Liquidations #liquidation #liquidate should allow unhealthy accounts to be liquidated",
- "timedOut": false,
- "duration": 523,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Fetch pre-liquidation state for users and contracts\nconst beforeUserOneCollateralAmount = await _optimizations.default.getAccountCollateralAmount(f.user1.address, f.Collateral);\nconst userOneDebtBefore = await _optimizations.default.getAccountDebtAmount(f.user1.address, f.KrAsset);\nconst liquidatorBalanceBefore = await f.Collateral.balanceOf(f.liquidator.address);\nconst liquidatorBalanceKrBefore = await f.KrAsset.balanceOf(f.liquidator.address);\nconst kreskoBalanceBefore = await f.Collateral.balanceOf(hre.Diamond.address);\n// Liquidate userOne\nconst maxRepayAmount = f.userOneMaxLiqPrecalc.wadDiv((0, _values.toBig)(11, 8));\nawait f.Liquidator.liquidate({\n account: f.user1.address,\n repayAssetAddr: f.KrAsset.address,\n repayAmount: maxRepayAmount,\n seizeAssetAddr: f.Collateral.address,\n repayAssetIndex: _optimizations.default.getAccountMintIndex(f.user1.address, f.KrAsset.address),\n seizeAssetIndex: _optimizations.default.getAccountDepositIndex(f.user1.address, f.Collateral.address)\n});\n// Confirm that the liquidated user's debt amount has decreased by the repaid amount\nconst userOneDebtAfterLiquidation = await _optimizations.default.getAccountDebtAmount(f.user1.address, f.KrAsset);\n(0, _chai.expect)(userOneDebtAfterLiquidation.eq(userOneDebtBefore.sub(maxRepayAmount)));\n// Confirm that some of the liquidated user's collateral has been seized\nconst userOneCollateralAfterLiquidation = await _optimizations.default.getAccountCollateralAmount(f.user1.address, f.Collateral);\n(0, _chai.expect)(userOneCollateralAfterLiquidation.lt(beforeUserOneCollateralAmount));\n// Confirm that userTwo's kresko asset balance has decreased by the repaid amount\n(0, _chai.expect)(await f.KrAsset.balanceOf(f.liquidator.address)).eq(liquidatorBalanceKrBefore.sub(maxRepayAmount));\n// Confirm that userTwo has received some collateral from the contract\n(0, _chai.expect)(await f.Collateral.balanceOf(f.liquidator.address)).gt(liquidatorBalanceBefore);\n// Confirm that Kresko contract's collateral balance has decreased.\n(0, _chai.expect)(await f.Collateral.balanceOf(hre.Diamond.address)).lt(kreskoBalanceBefore);",
- "err": {},
- "uuid": "80c8f461-3aec-424c-872e-2a503bbcd92e",
- "parentUUID": "ddacfe46-ad5b-49d6-bf59-1261753e4093",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should liquidate up to MLR with a single CDP",
- "fullTitle": "Minter - Liquidations #liquidation #liquidate should liquidate up to MLR with a single CDP",
- "timedOut": false,
- "duration": 1003,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await hre.Diamond.setAssetCFactor(f.Collateral.address, 0.99e4);\nawait hre.Diamond.setAssetKFactor(f.KrAsset.address, 1.02e4);\nconst maxLiq = await hre.Diamond.getMaxLiqValue(f.user1.address, f.KrAsset.address, f.Collateral.address);\nawait f.Liquidator.liquidate({\n account: f.user1.address,\n repayAssetAddr: f.KrAsset.address,\n repayAmount: maxLiq.repayAmount.add((0, _values.toBig)(1222, 27)),\n seizeAssetAddr: f.Collateral.address,\n repayAssetIndex: maxLiq.repayAssetIndex,\n seizeAssetIndex: maxLiq.seizeAssetIndex\n});\n(0, _chai.expect)(await hre.Diamond.getAccountCollateralRatio(f.user1.address)).to.be.eq(await _optimizations.default.getMaxLiquidationRatioMinter());\n(0, _chai.expect)(await hre.Diamond.getAccountLiquidatable(f.user1.address)).to.be.false;",
- "err": {},
- "uuid": "e96e08ab-1edb-4eb9-9536-ba7fc3bdd077",
- "parentUUID": "ddacfe46-ad5b-49d6-bf59-1261753e4093",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should liquidate up to MLR with multiple CDPs",
- "fullTitle": "Minter - Liquidations #liquidation #liquidate should liquidate up to MLR with multiple CDPs",
- "timedOut": false,
- "duration": 1310,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await (0, _collaterals.depositMockCollateral)({\n user: f.user1,\n amount: (0, _values.toBig)(10, 8),\n asset: f.Collateral8Dec\n});\nf.Collateral.setPrice(5.5);\nf.Collateral8Dec.setPrice(6);\nawait hre.Diamond.setAssetCFactor(f.Collateral.address, 0.9754e4);\nawait hre.Diamond.setAssetKFactor(f.KrAsset.address, 1.05e4);\nawait (0, _liquidations.liquidate)(f.user1, f.KrAsset, f.Collateral8Dec);\nconst [crAfter, isLiquidatableAfter] = await Promise.all([\n hre.Diamond.getAccountCollateralRatio(f.user1.address),\n hre.Diamond.getAccountLiquidatable(f.user1.address)\n]);\n(0, _chai.expect)(isLiquidatableAfter).to.be.false;\n(0, _chai.expect)(crAfter).to.be.eq(await _optimizations.default.getMaxLiquidationRatioMinter());",
- "err": {},
- "uuid": "de39647a-d852-4613-a630-62b64ddc26c1",
- "parentUUID": "ddacfe46-ad5b-49d6-bf59-1261753e4093",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should emit LiquidationOccurred event",
- "fullTitle": "Minter - Liquidations #liquidation #liquidate should emit LiquidationOccurred event",
- "timedOut": false,
- "duration": 339,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const repayAmount = f.userOneMaxLiqPrecalc.wadDiv((0, _values.toBig)(11));\nconst tx = await f.Liquidator.liquidate({\n account: f.user1.address,\n repayAssetAddr: f.KrAsset.address,\n repayAmount: repayAmount,\n seizeAssetAddr: f.Collateral.address,\n repayAssetIndex: _optimizations.default.getAccountMintIndex(f.user1.address, f.KrAsset.address),\n seizeAssetIndex: _optimizations.default.getAccountDepositIndex(f.user1.address, f.Collateral.address)\n});\nconst event = await (0, _events.getNamedEvent)(tx, 'LiquidationOccurred');\n(0, _chai.expect)(event.args.account).to.equal(f.user1.address);\n(0, _chai.expect)(event.args.liquidator).to.equal(f.liquidator.address);\n(0, _chai.expect)(event.args.repayKreskoAsset).to.equal(f.KrAsset.address);\n(0, _chai.expect)(event.args.repayAmount).to.equal(repayAmount);\n(0, _chai.expect)(event.args.seizedCollateralAsset).to.equal(f.Collateral.address);",
- "err": {},
- "uuid": "268c2aa6-e71b-4ec4-ba4f-1803eb6bb3ed",
- "parentUUID": "ddacfe46-ad5b-49d6-bf59-1261753e4093",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should not allow liquidations of healthy accounts",
- "fullTitle": "Minter - Liquidations #liquidation #liquidate should not allow liquidations of healthy accounts",
- "timedOut": false,
- "duration": 145,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "f.Collateral.setPrice(10);\nconst repayAmount = 10;\nconst mintedKreskoAssetIndex = 0;\nconst depositedCollateralAssetIndex = 0;\nawait (0, _chai.expect)(f.Liquidator.liquidate({\n account: f.user1.address,\n repayAssetAddr: f.KrAsset.address,\n repayAmount: repayAmount,\n seizeAssetAddr: f.Collateral.address,\n repayAssetIndex: mintedKreskoAssetIndex,\n seizeAssetIndex: depositedCollateralAssetIndex\n})).to.be.revertedWithCustomError((0, _errors.Errors)(hre), 'CANNOT_LIQUIDATE_HEALTHY_ACCOUNT').withArgs(f.user1.address, 16500000000, 15400000000, await hre.Diamond.getLiquidationThresholdMinter());",
- "err": {},
- "uuid": "f3e07633-d544-427c-aca1-da2669006c7a",
- "parentUUID": "ddacfe46-ad5b-49d6-bf59-1261753e4093",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should not allow liquidations if repayment amount is 0",
- "fullTitle": "Minter - Liquidations #liquidation #liquidate should not allow liquidations if repayment amount is 0",
- "timedOut": false,
- "duration": 221,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Liquidation should fail\nconst repayAmount = 0;\nawait (0, _chai.expect)(f.LiquidatorTwo.liquidate({\n account: f.user1.address,\n repayAssetAddr: f.KrAsset.address,\n repayAmount: repayAmount,\n seizeAssetAddr: f.Collateral.address,\n repayAssetIndex: 0,\n seizeAssetIndex: 0\n})).to.be.revertedWithCustomError((0, _errors.Errors)(hre), 'LIQUIDATION_VALUE_IS_ZERO').withArgs(f.KrAsset.errorId, f.Collateral.errorId);",
- "err": {},
- "uuid": "a88038fc-c05b-417b-96aa-c5dfa54cb3f9",
- "parentUUID": "ddacfe46-ad5b-49d6-bf59-1261753e4093",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should clamp liquidations if repay value/amount exceeds debt",
- "fullTitle": "Minter - Liquidations #liquidation #liquidate should clamp liquidations if repay value/amount exceeds debt",
- "timedOut": false,
- "duration": 706,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Get user's debt for this kresko asset\nconst krAssetDebtUserOne = await _optimizations.default.getAccountDebtAmount(f.user1.address, f.KrAsset);\n// Ensure we are repaying more than debt\nconst repayAmount = krAssetDebtUserOne.add((0, _values.toBig)(10));\nawait f.KrAsset.setBalance(f.liquidatorTwo, repayAmount, hre.Diamond.address);\n// Liquidation should fail\nconst liquidatorBalanceBefore = await f.KrAsset.balanceOf(f.liquidatorTwo.address);\nconst maxLiq = await hre.Diamond.getMaxLiqValue(f.user1.address, f.KrAsset.address, f.Collateral.address);\n(0, _chai.expect)(maxLiq.repayAmount).to.be.lt(repayAmount);\nconst tx = await f.LiquidatorTwo.liquidate({\n account: f.user1.address,\n repayAssetAddr: f.KrAsset.address,\n repayAmount,\n seizeAssetAddr: f.Collateral.address,\n repayAssetIndex: 0,\n seizeAssetIndex: 0\n});\nconst event = await (0, _events.getNamedEvent)(tx, 'LiquidationOccurred');\nconst liquidatorBalanceAfter = await f.KrAsset.balanceOf(f.liquidatorTwo.address);\n(0, _chai.expect)(event.args.account).to.equal(f.user1.address);\n(0, _chai.expect)(event.args.liquidator).to.equal(f.liquidatorTwo.address);\n(0, _chai.expect)(event.args.repayKreskoAsset).to.equal(f.KrAsset.address);\n(0, _chai.expect)(event.args.seizedCollateralAsset).to.equal(f.Collateral.address);\n(0, _chai.expect)(event.args.repayAmount).to.not.equal(repayAmount);\n(0, _chai.expect)(event.args.repayAmount).to.equal(maxLiq.repayAmount);\n(0, _chai.expect)(event.args.collateralSent).to.be.equal(maxLiq.seizeAmount);\n(0, _chai.expect)(liquidatorBalanceAfter.add(repayAmount)).to.not.equal(liquidatorBalanceBefore);\n(0, _chai.expect)(liquidatorBalanceAfter.add(maxLiq.repayAmount)).to.equal(liquidatorBalanceBefore);\n(0, _chai.expect)(await hre.Diamond.getAccountCollateralRatio(f.user1.address)).to.be.eq(await hre.Diamond.getMaxLiquidationRatioMinter());",
- "err": {},
- "uuid": "17356d1d-9ed9-4e0f-87fd-cda74d862673",
- "parentUUID": "ddacfe46-ad5b-49d6-bf59-1261753e4093",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should not allow liquidations when account is under MCR but not under liquidation threshold",
- "fullTitle": "Minter - Liquidations #liquidation #liquidate should not allow liquidations when account is under MCR but not under liquidation threshold",
- "timedOut": false,
- "duration": 499,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "f.Collateral.setPrice(f.Collateral.config.args.price);\n(0, _chai.expect)(await hre.Diamond.getAccountLiquidatable(f.user1.address)).to.be.false;\nconst minCollateralUSD = await hre.Diamond.getAccountMinCollateralAtRatio(f.user1.address, _optimizations.default.getMinCollateralRatioMinter());\nconst liquidationThresholdUSD = await hre.Diamond.getAccountMinCollateralAtRatio(f.user1.address, _optimizations.default.getLiquidationThresholdMinter());\nf.Collateral.setPrice(9.9);\nconst accountCollateralValue = await hre.Diamond.getAccountTotalCollateralValue(f.user1.address);\n(0, _chai.expect)(accountCollateralValue.lt(minCollateralUSD)).to.be.true;\n(0, _chai.expect)(accountCollateralValue.gt(liquidationThresholdUSD)).to.be.true;\n(0, _chai.expect)(await hre.Diamond.getAccountLiquidatable(f.user1.address)).to.be.false;",
- "err": {},
- "uuid": "6806f210-7be9-4b57-97e9-ecb740e8fc1b",
- "parentUUID": "ddacfe46-ad5b-49d6-bf59-1261753e4093",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should allow liquidations without f.liquidator token approval for Kresko Assets",
- "fullTitle": "Minter - Liquidations #liquidation #liquidate should allow liquidations without f.liquidator token approval for Kresko Assets",
- "timedOut": false,
- "duration": 339,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Check that f.liquidator's token approval to Kresko.sol contract is 0\n(0, _chai.expect)(await f.KrAsset.contract.allowance(f.liquidatorTwo.address, hre.Diamond.address)).to.equal(0);\nconst repayAmount = (0, _values.toBig)(0.5);\nawait f.KrAsset.setBalance(f.liquidatorTwo, repayAmount);\nawait f.LiquidatorTwo.liquidate({\n account: f.user1.address,\n repayAssetAddr: f.KrAsset.address,\n repayAmount: repayAmount,\n seizeAssetAddr: f.Collateral.address,\n repayAssetIndex: 0,\n seizeAssetIndex: 0\n});\n// Confirm that f.liquidator's token approval is still 0\n(0, _chai.expect)(await f.KrAsset.contract.allowance(f.user2.address, hre.Diamond.address)).to.equal(0);",
- "err": {},
- "uuid": "3cf42004-ccef-4075-b358-4ef3964ecf41",
- "parentUUID": "ddacfe46-ad5b-49d6-bf59-1261753e4093",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should not change f.liquidator's existing token approvals during a successful liquidation",
- "fullTitle": "Minter - Liquidations #liquidation #liquidate should not change f.liquidator's existing token approvals during a successful liquidation",
- "timedOut": false,
- "duration": 338,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const repayAmount = (0, _values.toBig)(0.5);\nawait f.KrAsset.setBalance(f.liquidatorTwo, repayAmount);\nawait f.KrAsset.contract.setVariable('_allowances', {\n [f.liquidatorTwo.address]: {\n [hre.Diamond.address]: repayAmount\n }\n});\nawait (0, _chai.expect)(f.LiquidatorTwo.liquidate({\n account: f.user1.address,\n repayAssetAddr: f.KrAsset.address,\n repayAmount: repayAmount,\n seizeAssetAddr: f.Collateral.address,\n repayAssetIndex: 0,\n seizeAssetIndex: 0\n})).not.to.be.reverted;\n// Confirm that f.liquidator's token approval is unchanged\n(0, _chai.expect)(await f.KrAsset.contract.allowance(f.liquidatorTwo.address, hre.Diamond.address)).to.equal(repayAmount);",
- "err": {},
- "uuid": "05b28117-2363-424a-998d-f6766164fdef",
- "parentUUID": "ddacfe46-ad5b-49d6-bf59-1261753e4093",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should not allow borrowers to liquidate themselves",
- "fullTitle": "Minter - Liquidations #liquidation #liquidate should not allow borrowers to liquidate themselves",
- "timedOut": false,
- "duration": 31,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Liquidation should fail\nconst repayAmount = 5;\nawait (0, _chai.expect)(f.User.liquidate({\n account: f.user1.address,\n repayAssetAddr: f.KrAsset.address,\n repayAmount: repayAmount,\n seizeAssetAddr: f.Collateral.address,\n repayAssetIndex: 0,\n seizeAssetIndex: 0\n})).to.be.revertedWithCustomError((0, _errors.Errors)(hre), 'CANNOT_LIQUIDATE_SELF');",
- "err": {},
- "uuid": "883604b5-5397-479b-887e-b1d6741f96d7",
- "parentUUID": "ddacfe46-ad5b-49d6-bf59-1261753e4093",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should error on seize underflow",
- "fullTitle": "Minter - Liquidations #liquidation #liquidate should error on seize underflow",
- "timedOut": false,
- "duration": 0,
- "state": "pending",
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": true,
- "context": null,
- "code": "",
- "err": {},
- "uuid": "4c2b6bc0-9e28-45fc-89c3-09a507096f40",
- "parentUUID": "ddacfe46-ad5b-49d6-bf59-1261753e4093",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "80c8f461-3aec-424c-872e-2a503bbcd92e",
- "e96e08ab-1edb-4eb9-9536-ba7fc3bdd077",
- "de39647a-d852-4613-a630-62b64ddc26c1",
- "268c2aa6-e71b-4ec4-ba4f-1803eb6bb3ed",
- "f3e07633-d544-427c-aca1-da2669006c7a",
- "a88038fc-c05b-417b-96aa-c5dfa54cb3f9",
- "17356d1d-9ed9-4e0f-87fd-cda74d862673",
- "6806f210-7be9-4b57-97e9-ecb740e8fc1b",
- "3cf42004-ccef-4075-b358-4ef3964ecf41",
- "05b28117-2363-424a-998d-f6766164fdef",
- "883604b5-5397-479b-887e-b1d6741f96d7"
- ],
- "failures": [],
- "pending": [
- "4c2b6bc0-9e28-45fc-89c3-09a507096f40"
- ],
- "skipped": [],
- "duration": 5454,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "1ad01460-781c-464f-9a80-f2502a7621e9",
- "title": "#liquidate - rebasing events",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/03-liquidation.ts",
- "file": "/src/test/minter/03-liquidation.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"#liquidate - rebasing events\"",
- "fullTitle": "Minter - Liquidations #liquidation #liquidate - rebasing events \"before each\" hook in \"#liquidate - rebasing events\"",
- "timedOut": false,
- "duration": 0,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await f.resetRebasing();",
- "err": {},
- "uuid": "a4fba808-a6f4-4f70-82ba-c0caf3c31592",
- "parentUUID": "1ad01460-781c-464f-9a80-f2502a7621e9",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [
- {
- "title": "should setup correct",
- "fullTitle": "Minter - Liquidations #liquidation #liquidate - rebasing events should setup correct",
- "timedOut": false,
- "duration": 431,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const [mcr, cr, cr2, liquidatable] = await Promise.all([\n _optimizations.default.getMinCollateralRatioMinter(),\n hre.Diamond.getAccountCollateralRatio(f.user3.address),\n hre.Diamond.getAccountCollateralRatio(f.user4.address),\n hre.Diamond.getAccountLiquidatable(f.user3.address)\n]);\n(0, _chai.expect)(cr).to.closeTo(mcr, 8);\n(0, _chai.expect)(cr2).to.closeTo(mcr, 1);\n(0, _chai.expect)(liquidatable).to.be.false;",
- "err": {},
- "uuid": "4b28e08b-2cb8-44cf-8e7b-7e1729235bb1",
- "parentUUID": "1ad01460-781c-464f-9a80-f2502a7621e9",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should not allow liquidation of healthy accounts after a positive rebase",
- "fullTitle": "Minter - Liquidations #liquidation #liquidate - rebasing events should not allow liquidation of healthy accounts after a positive rebase",
- "timedOut": false,
- "duration": 179,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = true;\nconst rebasePrice = 1 / denominator;\nf.KrAsset.setPrice(rebasePrice);\nawait f.KrAsset.contract.rebase((0, _values.toBig)(denominator), positive, []);\nawait (0, _chai.expect)(f.Liquidator.liquidate({\n account: f.user4.address,\n repayAssetAddr: f.KrAsset.address,\n repayAmount: 100,\n seizeAssetAddr: f.Collateral.address,\n repayAssetIndex: _optimizations.default.getAccountMintIndex(f.user4.address, f.KrAsset.address),\n seizeAssetIndex: _optimizations.default.getAccountDepositIndex(f.user4.address, f.Collateral.address)\n})).to.be.revertedWithCustomError((0, _errors.Errors)(hre), 'CANNOT_LIQUIDATE_HEALTHY_ACCOUNT').withArgs(f.user4.address, 1000000000000, 933333332400, await hre.Diamond.getLiquidationThresholdMinter());",
- "err": {},
- "uuid": "373a0f69-180e-4664-b96e-cf671603c444",
- "parentUUID": "1ad01460-781c-464f-9a80-f2502a7621e9",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should not allow liquidation of healthy accounts after a negative rebase",
- "fullTitle": "Minter - Liquidations #liquidation #liquidate - rebasing events should not allow liquidation of healthy accounts after a negative rebase",
- "timedOut": false,
- "duration": 179,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const denominator = 4;\nconst positive = false;\nconst rebasePrice = 1 * denominator;\nf.KrAsset.setPrice(rebasePrice);\nawait f.KrAsset.contract.rebase((0, _values.toBig)(denominator), positive, []);\nawait (0, _chai.expect)(f.Liquidator.liquidate({\n account: f.user4.address,\n repayAssetAddr: f.KrAsset.address,\n repayAmount: 100,\n seizeAssetAddr: f.Collateral.address,\n repayAssetIndex: _optimizations.default.getAccountMintIndex(f.user4.address, f.KrAsset.address),\n seizeAssetIndex: _optimizations.default.getAccountDepositIndex(f.user4.address, f.Collateral.address)\n})).to.be.revertedWithCustomError((0, _errors.Errors)(hre), 'CANNOT_LIQUIDATE_HEALTHY_ACCOUNT').withArgs(f.user4.address, 1000000000000, 933333332400, await hre.Diamond.getLiquidationThresholdMinter());",
- "err": {},
- "uuid": "3a5029de-4943-4d73-badf-55318dc7590a",
- "parentUUID": "1ad01460-781c-464f-9a80-f2502a7621e9",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should allow liquidations of unhealthy accounts after a positive rebase",
- "fullTitle": "Minter - Liquidations #liquidation #liquidate - rebasing events should allow liquidations of unhealthy accounts after a positive rebase",
- "timedOut": false,
- "duration": 1440,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const denominator = 4;\nconst positive = true;\nconst rebasePrice = 1 / denominator;\nf.KrAsset.setPrice(rebasePrice);\nawait f.KrAsset.contract.rebase((0, _values.toBig)(denominator), positive, []);\n(0, _chai.expect)(await hre.Diamond.getAccountLiquidatable(f.user4.address)).to.be.false;\nf.Collateral.setPrice(7.5);\n(0, _chai.expect)(await hre.Diamond.getAccountLiquidatable(f.user4.address)).to.be.true;\nawait (0, _liquidations.liquidate)(f.user4, f.KrAsset, f.Collateral, true);\nawait (0, _chai.expect)((0, _liquidations.liquidate)(f.user4, f.KrAsset, f.Collateral, true)).to.not.be.reverted;",
- "err": {},
- "uuid": "863ca0a7-4967-4425-a4a0-c19bf38df6bc",
- "parentUUID": "1ad01460-781c-464f-9a80-f2502a7621e9",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should allow liquidations of unhealthy accounts after a negative rebase",
- "fullTitle": "Minter - Liquidations #liquidation #liquidate - rebasing events should allow liquidations of unhealthy accounts after a negative rebase",
- "timedOut": false,
- "duration": 1097,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const denominator = 4;\nconst positive = false;\nconst rebasePrice = 1 * denominator;\nf.KrAsset.setPrice(rebasePrice);\nawait f.KrAsset.contract.rebase((0, _values.toBig)(denominator), positive, []);\n(0, _chai.expect)(await hre.Diamond.getAccountLiquidatable(f.user4.address)).to.be.false;\nf.KrAsset.setPrice(rebasePrice + 1);\n(0, _chai.expect)(await hre.Diamond.getAccountLiquidatable(f.user4.address)).to.be.true;\nawait (0, _chai.expect)((0, _liquidations.liquidate)(f.user4, f.KrAsset, f.Collateral, true)).to.not.be.reverted;",
- "err": {},
- "uuid": "edfd5b9a-4738-41cb-97af-c71ae980293e",
- "parentUUID": "1ad01460-781c-464f-9a80-f2502a7621e9",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should liquidate krAsset collaterals up to min amount",
- "fullTitle": "Minter - Liquidations #liquidation #liquidate - rebasing events should liquidate krAsset collaterals up to min amount",
- "timedOut": false,
- "duration": 813,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "f.KrAssetCollateral.setPrice(100);\nawait hre.Diamond.setAssetCFactor(f.KrAssetCollateral.address, 0.99e4);\nawait hre.Diamond.setAssetKFactor(f.KrAssetCollateral.address, 1e4);\nconst maxLiq = await hre.Diamond.getMaxLiqValue(f.user3.address, f.KrAssetCollateral.address, f.KrAssetCollateral.address);\nawait f.KrAssetCollateral.setBalance(f.liquidator, maxLiq.repayAmount, hre.Diamond.address);\nawait f.Liquidator.liquidate({\n account: f.user3.address,\n repayAssetAddr: f.KrAssetCollateral.address,\n repayAmount: maxLiq.repayAmount.sub(1e9),\n seizeAssetAddr: f.KrAssetCollateral.address,\n repayAssetIndex: maxLiq.repayAssetIndex,\n seizeAssetIndex: maxLiq.seizeAssetIndex\n});\nconst depositsAfter = await hre.Diamond.getAccountCollateralAmount(f.user3.address, f.KrAssetCollateral.address);\n(0, _chai.expect)(depositsAfter).to.equal(1e12.toString());",
- "err": {},
- "uuid": "714f1c7e-c22d-4d0e-870c-02949f50a77a",
- "parentUUID": "1ad01460-781c-464f-9a80-f2502a7621e9",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should liquidate to 0",
- "fullTitle": "Minter - Liquidations #liquidation #liquidate - rebasing events should liquidate to 0",
- "timedOut": false,
- "duration": 810,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "f.KrAssetCollateral.setPrice(100);\nawait hre.Diamond.setAssetCFactor(f.KrAssetCollateral.address, 1e4);\nawait hre.Diamond.setAssetKFactor(f.KrAssetCollateral.address, 1e4);\nconst maxLiq = await hre.Diamond.getMaxLiqValue(f.user3.address, f.KrAssetCollateral.address, f.KrAssetCollateral.address);\nconst liquidationAmount = maxLiq.repayAmount.add((0, _values.toBig)(20, 27));\nawait f.KrAssetCollateral.setBalance(hre.users.liquidator, liquidationAmount, hre.Diamond.address);\nawait f.Liquidator.liquidate({\n account: f.user3.address,\n repayAssetAddr: f.KrAssetCollateral.address,\n repayAmount: liquidationAmount,\n seizeAssetAddr: f.KrAssetCollateral.address,\n repayAssetIndex: maxLiq.repayAssetIndex,\n seizeAssetIndex: maxLiq.seizeAssetIndex\n});\nconst depositsAfter = await hre.Diamond.getAccountCollateralAmount(f.user3.address, f.KrAssetCollateral.address);\n(0, _chai.expect)(depositsAfter).to.equal(0);",
- "err": {},
- "uuid": "e0bef1b0-3956-4713-9c9c-15ecd8d64e5d",
- "parentUUID": "1ad01460-781c-464f-9a80-f2502a7621e9",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should liquidate correct amount of krAssets after a positive rebase",
- "fullTitle": "Minter - Liquidations #liquidation #liquidate - rebasing events should liquidate correct amount of krAssets after a positive rebase",
- "timedOut": false,
- "duration": 2734,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const newPrice = 1.2;\nf.KrAsset.setPrice(newPrice);\nconst results = {\n collateralSeized: 0,\n debtRepaid: 0,\n userOneValueAfter: 0,\n userOneHFAfter: 0,\n collateralSeizedRebase: 0,\n debtRepaidRebase: 0,\n userTwoValueAfter: 0,\n userTwoHFAfter: 0\n};\n// Get values for a liquidation that happens before rebase\nwhile(await hre.Diamond.getAccountLiquidatable(f.user4.address)){\n const values = await (0, _liquidations.liquidate)(f.user4, f.KrAsset, f.Collateral);\n results.collateralSeized += values.collateralSeized;\n results.debtRepaid += values.debtRepaid;\n}\nresults.userOneValueAfter = (0, _values.fromBig)(await hre.Diamond.getAccountTotalCollateralValue(f.user4.address), 8);\nresults.userOneHFAfter = (await hre.Diamond.getAccountCollateralRatio(f.user4.address)).toNumber();\n// Rebase params\nconst denominator = 4;\nconst positive = true;\nconst rebasePrice = newPrice / denominator;\n// Rebase\nf.KrAsset.setPrice(rebasePrice);\nawait f.KrAsset.contract.rebase((0, _values.toBig)(denominator), positive, []);\n(0, _chai.expect)(await hre.Diamond.getAccountLiquidatable(f.user5.address)).to.be.true;\n// Get values for a liquidation that happens after a rebase\nwhile(await hre.Diamond.getAccountLiquidatable(f.user5.address)){\n const values = await (0, _liquidations.liquidate)(f.user5, f.KrAsset, f.Collateral);\n results.collateralSeizedRebase += values.collateralSeized;\n results.debtRepaidRebase += values.debtRepaid;\n}\nresults.userTwoValueAfter = (0, _values.fromBig)(await hre.Diamond.getAccountTotalCollateralValue(f.user5.address), 8);\nresults.userTwoHFAfter = (await hre.Diamond.getAccountCollateralRatio(f.user5.address)).toNumber();\n(0, _chai.expect)(results.userTwoHFAfter).to.equal(results.userOneHFAfter);\n(0, _chai.expect)(results.collateralSeized).to.equal(results.collateralSeizedRebase);\n(0, _chai.expect)(results.debtRepaid * denominator).to.equal(results.debtRepaidRebase);\n(0, _chai.expect)(results.userOneValueAfter).to.equal(results.userTwoValueAfter);",
- "err": {},
- "uuid": "b567cad1-849c-484c-b6c0-6b23eb42f611",
- "parentUUID": "1ad01460-781c-464f-9a80-f2502a7621e9",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should liquidate correct amount of assets after a negative rebase",
- "fullTitle": "Minter - Liquidations #liquidation #liquidate - rebasing events should liquidate correct amount of assets after a negative rebase",
- "timedOut": false,
- "duration": 2532,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const newPrice = 1.2;\nf.KrAsset.setPrice(newPrice);\nconst results = {\n collateralSeized: 0,\n debtRepaid: 0,\n userOneValueAfter: 0,\n userOneHFAfter: 0,\n collateralSeizedRebase: 0,\n debtRepaidRebase: 0,\n userTwoValueAfter: 0,\n userTwoHFAfter: 0\n};\n// Get values for a liquidation that happens before rebase\nwhile(await hre.Diamond.getAccountLiquidatable(f.user4.address)){\n const values = await (0, _liquidations.liquidate)(f.user4, f.KrAsset, f.Collateral);\n results.collateralSeized += values.collateralSeized;\n results.debtRepaid += values.debtRepaid;\n}\nresults.userOneValueAfter = (0, _values.fromBig)(await hre.Diamond.getAccountTotalCollateralValue(f.user4.address), 8);\nresults.userOneHFAfter = (await hre.Diamond.getAccountCollateralRatio(f.user4.address)).toNumber();\n// Rebase params\nconst denominator = 4;\nconst positive = false;\nconst rebasePrice = newPrice * denominator;\n// Rebase\nf.KrAsset.setPrice(rebasePrice);\nawait f.KrAsset.contract.rebase((0, _values.toBig)(denominator), positive, []);\n(0, _chai.expect)(await hre.Diamond.getAccountLiquidatable(f.user5.address)).to.be.true;\n// Get values for a liquidation that happens after a rebase\nwhile(await hre.Diamond.getAccountLiquidatable(f.user5.address)){\n const values = await (0, _liquidations.liquidate)(f.user5, f.KrAsset, f.Collateral);\n results.collateralSeizedRebase += values.collateralSeized;\n results.debtRepaidRebase += values.debtRepaid;\n}\nresults.userTwoValueAfter = (0, _values.fromBig)(await hre.Diamond.getAccountTotalCollateralValue(f.user5.address), 8);\nresults.userTwoHFAfter = (await hre.Diamond.getAccountCollateralRatio(f.user5.address)).toNumber();\n(0, _chai.expect)(results.userTwoHFAfter).to.equal(results.userOneHFAfter);\n(0, _chai.expect)(results.collateralSeized).to.equal(results.collateralSeizedRebase);\n(0, _chai.expect)(results.debtRepaid / denominator).to.equal(results.debtRepaidRebase);\n(0, _chai.expect)(results.userOneValueAfter).to.equal(results.userTwoValueAfter);",
- "err": {},
- "uuid": "dd1a6a87-e86b-49dc-b624-e861f4a8d001",
- "parentUUID": "1ad01460-781c-464f-9a80-f2502a7621e9",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "4b28e08b-2cb8-44cf-8e7b-7e1729235bb1",
- "373a0f69-180e-4664-b96e-cf671603c444",
- "3a5029de-4943-4d73-badf-55318dc7590a",
- "863ca0a7-4967-4425-a4a0-c19bf38df6bc",
- "edfd5b9a-4738-41cb-97af-c71ae980293e",
- "714f1c7e-c22d-4d0e-870c-02949f50a77a",
- "e0bef1b0-3956-4713-9c9c-15ecd8d64e5d",
- "b567cad1-849c-484c-b6c0-6b23eb42f611",
- "dd1a6a87-e86b-49dc-b624-e861f4a8d001"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 10215,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "05fd28b9-81e5-4878-b8b4-aae09124642e",
- "title": "Minter",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/04-mint-repay.ts",
- "file": "/src/test/minter/04-mint-repay.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"Minter\"",
- "fullTitle": "Minter \"before each\" hook in \"Minter\"",
- "timedOut": false,
- "duration": 1,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "f = await (0, _fixtures.mintRepayFixture)();\nawait f.reset();",
- "err": {},
- "uuid": "b71d4174-fc89-49c1-8d41-cb731f9a8379",
- "parentUUID": "05fd28b9-81e5-4878-b8b4-aae09124642e",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [],
- "suites": [
- {
- "uuid": "45a1f4af-32d8-40f3-b6af-e46208764bcf",
- "title": "#mint+burn",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/04-mint-repay.ts",
- "file": "/src/test/minter/04-mint-repay.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [],
- "suites": [
- {
- "uuid": "e12aa70d-4d08-426a-918f-d27123bfb9ca",
- "title": "#mint",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/04-mint-repay.ts",
- "file": "/src/test/minter/04-mint-repay.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "should allow users to mint whitelisted Kresko assets backed by collateral",
- "fullTitle": "Minter #mint+burn #mint should allow users to mint whitelisted Kresko assets backed by collateral",
- "timedOut": false,
- "duration": 271,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const kreskoAssetTotalSupplyBefore = await f.KrAsset.contract.totalSupply();\n(0, _chai.expect)(kreskoAssetTotalSupplyBefore).to.equal(f.initialMintAmount);\n// Initially, the array of the user's minted kresko assets should be empty.\nconst mintedKreskoAssetsBefore = await hre.Diamond.getAccountMintedAssets(f.user1.address);\n(0, _chai.expect)(mintedKreskoAssetsBefore).to.deep.equal([]);\n// Mint Kresko asset\nconst mintAmount = (0, _values.toBig)(10);\nawait f.User1.mintKreskoAsset(f.user1.address, f.KrAsset.address, mintAmount);\n// Confirm the array of the user's minted Kresko assets has been pushed to.\nconst mintedKreskoAssetsAfter = await hre.Diamond.getAccountMintedAssets(f.user1.address);\n(0, _chai.expect)(mintedKreskoAssetsAfter).to.deep.equal([\n f.KrAsset.address\n]);\n// Confirm the amount minted is recorded for the user.\nconst amountMinted = await hre.Diamond.getAccountDebtAmount(f.user1.address, f.KrAsset.address);\n(0, _chai.expect)(amountMinted).to.equal(mintAmount);\n// Confirm the user's Kresko asset balance has increased\nconst userBalance = await f.KrAsset.contract.balanceOf(f.user1.address);\n(0, _chai.expect)(userBalance).to.equal(mintAmount);\n// Confirm that the Kresko asset's total supply increased as expected\nconst kreskoAssetTotalSupplyAfter = await f.KrAsset.contract.totalSupply();\n(0, _chai.expect)(kreskoAssetTotalSupplyAfter.eq(kreskoAssetTotalSupplyBefore.add(mintAmount)));",
- "err": {},
- "uuid": "4339cb85-149e-425e-b17e-ac6517a8b8cf",
- "parentUUID": "e12aa70d-4d08-426a-918f-d27123bfb9ca",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should allow successive, valid mints of the same Kresko asset",
- "fullTitle": "Minter #mint+burn #mint should allow successive, valid mints of the same Kresko asset",
- "timedOut": false,
- "duration": 461,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Mint Kresko asset\nconst firstMintAmount = (0, _values.toBig)(50);\nawait f.User1.mintKreskoAsset(f.user1.address, f.KrAsset.address, firstMintAmount);\n// Confirm the array of the user's minted Kresko assets has been pushed to.\nconst mintedKreskoAssetsAfter = await hre.Diamond.getAccountMintedAssets(f.user1.address);\n(0, _chai.expect)(mintedKreskoAssetsAfter).to.deep.equal([\n f.KrAsset.address\n]);\n// Confirm the amount minted is recorded for the user.\nconst amountMintedAfter = await hre.Diamond.getAccountDebtAmount(f.user1.address, f.KrAsset.address);\n(0, _chai.expect)(amountMintedAfter).to.equal(firstMintAmount);\n// Confirm the Kresko Asset as been minted to the user from Kresko.sol\nconst userBalanceAfter = await f.KrAsset.contract.balanceOf(f.user1.address);\n(0, _chai.expect)(userBalanceAfter).to.equal(amountMintedAfter);\n// Confirm that the Kresko asset's total supply increased as expected\nconst kreskoAssetTotalSupplyAfter = await f.KrAsset.contract.totalSupply();\n(0, _chai.expect)(kreskoAssetTotalSupplyAfter).to.equal(f.initialMintAmount.add(firstMintAmount));\n// ------------------------ Second mint ------------------------\n// Mint Kresko asset\nconst secondMintAmount = (0, _values.toBig)(50);\nawait f.User1.mintKreskoAsset(f.user1.address, f.KrAsset.address, secondMintAmount);\n// Confirm the array of the user's minted Kresko assets is unchanged\nconst mintedKreskoAssetsFinal = await hre.Diamond.getAccountMintedAssets(f.user1.address);\n(0, _chai.expect)(mintedKreskoAssetsFinal).to.deep.equal([\n f.KrAsset.address\n]);\n// Confirm the second mint amount is recorded for the user\nconst amountMintedFinal = await hre.Diamond.getAccountDebtAmount(f.user1.address, f.KrAsset.address);\n(0, _chai.expect)(amountMintedFinal).to.closeTo(firstMintAmount.add(secondMintAmount), INTEREST_RATE_DELTA);\n// Confirm the Kresko Asset as been minted to the user from Kresko.sol\nconst userBalanceFinal = await f.KrAsset.contract.balanceOf(f.user1.address);\n(0, _chai.expect)(userBalanceFinal).to.closeTo(amountMintedFinal, INTEREST_RATE_DELTA);\n// Confirm that the Kresko asset's total supply increased as expected\nconst kreskoAssetTotalSupplyFinal = await f.KrAsset.contract.totalSupply();\n(0, _chai.expect)(kreskoAssetTotalSupplyFinal).to.closeTo(kreskoAssetTotalSupplyAfter.add(secondMintAmount), INTEREST_RATE_DELTA);",
- "err": {},
- "uuid": "11a3dd0d-e0b1-462d-9db3-6ae0932ff968",
- "parentUUID": "e12aa70d-4d08-426a-918f-d27123bfb9ca",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should allow users to mint multiple different Kresko assets",
- "fullTitle": "Minter #mint+burn #mint should allow users to mint multiple different Kresko assets",
- "timedOut": false,
- "duration": 427,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Initially, the array of the user's minted kresko assets should be empty.\nconst mintedKreskoAssetsInitial = await _optimizations.default.getAccountMintedAssets(f.user1.address);\n(0, _chai.expect)(mintedKreskoAssetsInitial).to.deep.equal([]);\n// Mint Kresko asset\nconst firstMintAmount = (0, _values.toBig)(10);\nawait f.User1.mintKreskoAsset(f.user1.address, f.KrAsset.address, firstMintAmount);\n// Confirm the array of the user's minted Kresko assets has been pushed to.\nconst mintedKreskoAssetsAfter = await _optimizations.default.getAccountMintedAssets(f.user1.address);\n(0, _chai.expect)(mintedKreskoAssetsAfter).to.deep.equal([\n f.KrAsset.address\n]);\n// Confirm the amount minted is recorded for the user.\nconst amountMintedAfter = await _optimizations.default.getAccountDebtAmount(f.user1.address, f.KrAsset);\n(0, _chai.expect)(amountMintedAfter).to.equal(firstMintAmount);\n// Confirm the Kresko Asset as been minted to the user from Kresko.sol\nconst userBalanceAfter = await f.KrAsset.balanceOf(f.user1.address);\n(0, _chai.expect)(userBalanceAfter).to.equal(amountMintedAfter);\n// Confirm that the Kresko asset's total supply increased as expected\nconst kreskoAssetTotalSupplyAfter = await f.KrAsset.contract.totalSupply();\n(0, _chai.expect)(kreskoAssetTotalSupplyAfter).to.equal(f.initialMintAmount.add(firstMintAmount));\n// ------------------------ Second mint ------------------------\n// Mint Kresko asset\nconst secondMintAmount = (0, _values.toBig)(20);\nawait f.User1.mintKreskoAsset(f.user1.address, f.KrAsset2.address, secondMintAmount);\n// Confirm that the second address has been pushed to the array of the user's minted Kresko assets\nconst mintedKreskoAssetsFinal = await _optimizations.default.getAccountMintedAssets(f.user1.address);\n(0, _chai.expect)(mintedKreskoAssetsFinal).to.deep.equal([\n f.KrAsset.address,\n f.KrAsset2.address\n]);\n// Confirm the second mint amount is recorded for the user\nconst amountMintedAssetTwo = await _optimizations.default.getAccountDebtAmount(f.user1.address, f.KrAsset2);\n(0, _chai.expect)(amountMintedAssetTwo).to.equal(secondMintAmount);\n// Confirm the Kresko Asset as been minted to the user from Kresko.sol\nconst userBalanceFinal = await f.KrAsset2.balanceOf(f.user1.address);\n(0, _chai.expect)(userBalanceFinal).to.equal(amountMintedAssetTwo);\n// Confirm that the Kresko asset's total supply increased as expected\nconst secondKreskoAssetTotalSupply = await f.KrAsset2.contract.totalSupply();\n(0, _chai.expect)(secondKreskoAssetTotalSupply).to.equal(secondMintAmount);",
- "err": {},
- "uuid": "a37f9d6f-a29c-44d1-bfb7-80e5f7d39daf",
- "parentUUID": "e12aa70d-4d08-426a-918f-d27123bfb9ca",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should allow users to mint Kresko assets with USD value equal to the minimum debt value",
- "fullTitle": "Minter #mint+burn #mint should allow users to mint Kresko assets with USD value equal to the minimum debt value",
- "timedOut": false,
- "duration": 296,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Confirm that the mint amount's USD value is equal to the contract's current minimum debt value\nconst mintAmount = (0, _values.toBig)(1) // 1 * $10 = $10\n;\nconst mintAmountUSDValue = await hre.Diamond.getValue(f.KrAsset.address, mintAmount);\nconst currMinimumDebtValue = await hre.Diamond.getMinDebtValueMinter();\n(0, _chai.expect)(mintAmountUSDValue).to.equal(currMinimumDebtValue);\nawait f.User1.mintKreskoAsset(f.user1.address, f.KrAsset.address, mintAmount);\n// Confirm that the mint was successful and user's balances have increased\nconst finalKreskoAssetDebt = await _optimizations.default.getAccountDebtAmount(f.user1.address, f.KrAsset);\n(0, _chai.expect)(finalKreskoAssetDebt).to.equal(mintAmount);",
- "err": {},
- "uuid": "d3eeeb90-53dd-4f32-b9b0-78df416f936b",
- "parentUUID": "e12aa70d-4d08-426a-918f-d27123bfb9ca",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should allow a trusted address to mint Kresko assets on behalf of another user",
- "fullTitle": "Minter #mint+burn #mint should allow a trusted address to mint Kresko assets on behalf of another user",
- "timedOut": false,
- "duration": 229,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await hre.Diamond.grantRole(_roles.Role.MANAGER, f.user2.address);\n// Initially, the array of the user's minted kresko assets should be empty.\nconst mintedKreskoAssetsBefore = await _optimizations.default.getAccountMintedAssets(f.user1.address);\n(0, _chai.expect)(mintedKreskoAssetsBefore).to.deep.equal([]);\n// userThree (trusted contract) mints Kresko asset for userOne\nconst mintAmount = (0, _values.toBig)(1);\nawait f.User2.mintKreskoAsset(f.user1.address, f.KrAsset.address, mintAmount);\n// Check that debt exists now for userOne\nconst userTwoBalanceAfter = await _optimizations.default.getAccountDebtAmount(f.user1.address, f.KrAsset);\n(0, _chai.expect)(userTwoBalanceAfter).to.equal(mintAmount);\n// Initially, the array of the user's minted kresko assets should be empty.\nconst mintedKreskoAssetsAfter = await _optimizations.default.getAccountMintedAssets(f.user1.address);\n(0, _chai.expect)(mintedKreskoAssetsAfter).to.deep.equal([\n f.KrAsset.address\n]);",
- "err": {},
- "uuid": "243be653-ce1b-40f4-8b7b-3ad0f555aef6",
- "parentUUID": "e12aa70d-4d08-426a-918f-d27123bfb9ca",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should emit KreskoAssetMinted event",
- "fullTitle": "Minter #mint+burn #mint should emit KreskoAssetMinted event",
- "timedOut": false,
- "duration": 159,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const tx = await f.User1.mintKreskoAsset(f.user1.address, f.KrAsset.address, f.initialMintAmount);\nconst event = await (0, _events.getInternalEvent)(tx, hre.Diamond, 'KreskoAssetMinted');\n(0, _chai.expect)(event.account).to.equal(f.user1.address);\n(0, _chai.expect)(event.kreskoAsset).to.equal(f.KrAsset.address);\n(0, _chai.expect)(event.amount).to.equal(f.initialMintAmount);",
- "err": {},
- "uuid": "7c228732-9239-44ba-ae24-831841764c44",
- "parentUUID": "e12aa70d-4d08-426a-918f-d27123bfb9ca",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should not allow untrusted account to mint Kresko assets on behalf of another user",
- "fullTitle": "Minter #mint+burn #mint should not allow untrusted account to mint Kresko assets on behalf of another user",
- "timedOut": false,
- "duration": 44,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await (0, _chai.expect)(f.User1.mintKreskoAsset(f.user2.address, f.KrAsset.address, (0, _values.toBig)(1))).to.be.revertedWith(`AccessControl: account ${f.user1.address.toLowerCase()} is missing role 0x46925e0f0cc76e485772167edccb8dc449d43b23b55fc4e756b063f49099e6a0`);",
- "err": {},
- "uuid": "1e92070a-930d-4e11-80a1-05a8dea2b82a",
- "parentUUID": "e12aa70d-4d08-426a-918f-d27123bfb9ca",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should not allow users to mint Kresko assets if the resulting position's USD value is less than the minimum debt value",
- "fullTitle": "Minter #mint+burn #mint should not allow users to mint Kresko assets if the resulting position's USD value is less than the minimum debt value",
- "timedOut": false,
- "duration": 108,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const currMinimumDebtValue = await _optimizations.default.getMinDebtValue();\nconst mintAmount = currMinimumDebtValue.wadDiv(_mocks.TEN_USD.ebn(8)).sub(1e9);\nawait (0, _chai.expect)(f.User1.mintKreskoAsset(f.user1.address, f.KrAsset.address, mintAmount)).to.be.revertedWithCustomError((0, _errors.Errors)(hre), 'MINT_VALUE_LESS_THAN_MIN_DEBT_VALUE').withArgs(f.KrAsset.errorId, 10e8 - 1, currMinimumDebtValue);",
- "err": {},
- "uuid": "3abdc8ab-f3d9-4c8e-84d1-fbe98ca48aad",
- "parentUUID": "e12aa70d-4d08-426a-918f-d27123bfb9ca",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should not allow users to mint non-whitelisted Kresko assets",
- "fullTitle": "Minter #mint+burn #mint should not allow users to mint non-whitelisted Kresko assets",
- "timedOut": false,
- "duration": 32,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Attempt to mint a non-deployed, non-whitelisted Kresko asset\nawait (0, _chai.expect)(f.User1.mintKreskoAsset(f.user1.address, '0x0000000000000000000000000000000000000002', (0, _values.toBig)(1))).to.be.revertedWithCustomError((0, _errors.Errors)(hre), 'ASSET_NOT_MINTABLE_FROM_MINTER').withArgs([\n '',\n '0x0000000000000000000000000000000000000002'\n]);",
- "err": {},
- "uuid": "4982d288-d4b1-4db0-a433-13e17d26b57c",
- "parentUUID": "e12aa70d-4d08-426a-918f-d27123bfb9ca",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should not allow users to mint Kresko assets over their collateralization ratio limit",
- "fullTitle": "Minter #mint+burn #mint should not allow users to mint Kresko assets over their collateralization ratio limit",
- "timedOut": false,
- "duration": 363,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const collateralAmountDeposited = await _optimizations.default.getAccountCollateralAmount(f.user1.address, f.Collateral.address);\nconst MCR = await hre.Diamond.getMinCollateralRatioMinter();\nconst mcrAmount = collateralAmountDeposited.percentMul(MCR);\nconst mintAmount = mcrAmount.add(1);\nconst mintValue = await hre.Diamond.getValue(f.KrAsset.address, mintAmount);\nconst userState = await hre.Diamond.getAccountState(f.user1.address);\nawait (0, _chai.expect)(f.User1.mintKreskoAsset(f.user1.address, f.KrAsset.address, mintAmount)).to.be.revertedWithCustomError((0, _errors.Errors)(hre), 'ACCOUNT_COLLATERAL_VALUE_LESS_THAN_REQUIRED').withArgs(f.user1.address, userState.totalCollateralValue, mintValue.percentMul(MCR), MCR);",
- "err": {},
- "uuid": "bfe49441-c9b3-4e9a-a2a4-054a04c4f7f6",
- "parentUUID": "e12aa70d-4d08-426a-918f-d27123bfb9ca",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should not allow the minting of any Kresko asset amount over its maximum limit",
- "fullTitle": "Minter #mint+burn #mint should not allow the minting of any Kresko asset amount over its maximum limit",
- "timedOut": false,
- "duration": 234,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// User deposits another 10,000 collateral tokens, enabling mints of up to 20,000/1.5 = ~13,333 kresko asset tokens\nawait f.Collateral.setBalance(f.user1, (0, _values.toBig)(100000000));\nawait (0, _chai.expect)(f.User1.depositCollateral(f.user1.address, f.Collateral.address, (0, _values.toBig)(10000))).not.to.be.reverted;\nconst assetSupplyLimit = (0, _values.toBig)(1);\nconst mintAmount = (0, _values.toBig)(2);\nawait f.KrAsset.update({\n maxDebtMinter: assetSupplyLimit\n});\nawait (0, _chai.expect)(f.User1.mintKreskoAsset(f.user1.address, f.KrAsset.address, mintAmount)).to.be.revertedWithCustomError((0, _errors.Errors)(hre), 'EXCEEDS_ASSET_MINTING_LIMIT').withArgs(f.KrAsset.errorId, (await f.KrAsset.contract.totalSupply()).add(mintAmount), assetSupplyLimit);\nawait f.KrAsset.update({\n maxDebtMinter: assetSupplyLimit\n});",
- "err": {},
- "uuid": "8b6f31a2-f684-4bc5-b4e6-dbeeaa28a859",
- "parentUUID": "e12aa70d-4d08-426a-918f-d27123bfb9ca",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should not allow the minting of kreskoAssets if the market is closed",
- "fullTitle": "Minter #mint+burn #mint should not allow the minting of kreskoAssets if the market is closed",
- "timedOut": false,
- "duration": 0,
- "state": "pending",
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": true,
- "context": null,
- "code": "",
- "err": {},
- "uuid": "3a549efd-1489-4f39-9b33-939873abc695",
- "parentUUID": "e12aa70d-4d08-426a-918f-d27123bfb9ca",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "4339cb85-149e-425e-b17e-ac6517a8b8cf",
- "11a3dd0d-e0b1-462d-9db3-6ae0932ff968",
- "a37f9d6f-a29c-44d1-bfb7-80e5f7d39daf",
- "d3eeeb90-53dd-4f32-b9b0-78df416f936b",
- "243be653-ce1b-40f4-8b7b-3ad0f555aef6",
- "7c228732-9239-44ba-ae24-831841764c44",
- "1e92070a-930d-4e11-80a1-05a8dea2b82a",
- "3abdc8ab-f3d9-4c8e-84d1-fbe98ca48aad",
- "4982d288-d4b1-4db0-a433-13e17d26b57c",
- "bfe49441-c9b3-4e9a-a2a4-054a04c4f7f6",
- "8b6f31a2-f684-4bc5-b4e6-dbeeaa28a859"
- ],
- "failures": [],
- "pending": [
- "3a549efd-1489-4f39-9b33-939873abc695"
- ],
- "skipped": [],
- "duration": 2624,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "e92e188d-c136-4474-8535-3f80ccc107ce",
- "title": "#mint - rebase",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/04-mint-repay.ts",
- "file": "/src/test/minter/04-mint-repay.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [],
- "suites": [
- {
- "uuid": "9407b681-f417-41f5-8c9b-6f02ae412db6",
- "title": "debt amounts are calculated correctly",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/04-mint-repay.ts",
- "file": "/src/test/minter/04-mint-repay.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "when minted before positive rebase",
- "fullTitle": "Minter #mint+burn #mint - rebase debt amounts are calculated correctly when minted before positive rebase",
- "timedOut": false,
- "duration": 194,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = true;\n// Mint before rebase\nawait f.User1.mintKreskoAsset(f.user1.address, f.KrAsset.address, mintAmount);\nconst balanceBefore = await f.KrAsset.balanceOf(f.user1.address);\n// Rebase the asset according to params\nawait f.KrAsset.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Ensure that the minted balance is adjusted by the rebase\nconst [balanceAfter, balanceAfterAdjusted] = await (0, _krassets.getDebtIndexAdjustedBalance)(f.user1, f.KrAsset);\n(0, _chai.expect)(balanceAfter).to.equal(mintAmount.mul(denominator));\n(0, _chai.expect)(balanceBefore).to.not.equal(balanceAfter);\n// Ensure that debt amount is also adjsuted by the rebase\nconst debtAmount = await hre.Diamond.getAccountDebtAmount(f.user1.address, f.KrAsset.address);\n(0, _chai.expect)(balanceAfterAdjusted).to.equal(debtAmount);",
- "err": {},
- "uuid": "64951eb0-9c22-47ca-8330-a56b07f560f6",
- "parentUUID": "9407b681-f417-41f5-8c9b-6f02ae412db6",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when minted before negative rebase",
- "fullTitle": "Minter #mint+burn #mint - rebase debt amounts are calculated correctly when minted before negative rebase",
- "timedOut": false,
- "duration": 205,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = false;\n// Mint before rebase\nawait f.User1.mintKreskoAsset(f.user1.address, f.KrAsset.address, mintAmount);\nconst balanceBefore = await f.KrAsset.balanceOf(f.user1.address);\n// Rebase the asset according to params\nawait f.KrAsset.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Ensure that the minted balance is adjusted by the rebase\nconst [balanceAfter, balanceAfterAdjusted] = await (0, _krassets.getDebtIndexAdjustedBalance)(f.user1, f.KrAsset);\n(0, _chai.expect)(balanceAfter).to.equal(mintAmount.div(denominator));\n(0, _chai.expect)(balanceBefore).to.not.equal(balanceAfter);\n// Ensure that debt amount is also adjsuted by the rebase\nconst debtAmount = await hre.Diamond.getAccountDebtAmount(f.user1.address, f.KrAsset.address);\n(0, _chai.expect)(balanceAfterAdjusted).to.equal(debtAmount);",
- "err": {},
- "uuid": "3ba9d602-6f10-48cc-b8d1-2a3f602ae5dc",
- "parentUUID": "9407b681-f417-41f5-8c9b-6f02ae412db6",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when minted after positive rebase",
- "fullTitle": "Minter #mint+burn #mint - rebase debt amounts are calculated correctly when minted after positive rebase",
- "timedOut": false,
- "duration": 204,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = true;\n// Mint before rebase\nawait f.User1.mintKreskoAsset(f.user1.address, f.KrAsset.address, mintAmount);\nconst balanceBefore = await f.KrAsset.balanceOf(f.user1.address);\n// Rebase the asset according to params\nawait f.KrAsset.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Ensure that the minted balance is adjusted by the rebase\nconst [balanceAfter, balanceAfterAdjusted] = await (0, _krassets.getDebtIndexAdjustedBalance)(f.user1, f.KrAsset);\n(0, _chai.expect)(balanceAfter).to.equal(mintAmount.mul(denominator));\n(0, _chai.expect)(balanceBefore).to.not.equal(balanceAfter);\n// Ensure that debt amount is also adjusted by the rebase\nconst debtAmount = await hre.Diamond.getAccountDebtAmount(f.user1.address, f.KrAsset.address);\n(0, _chai.expect)(balanceAfterAdjusted).to.equal(debtAmount);",
- "err": {},
- "uuid": "99af08bb-1f97-4a52-bfe1-543b0d4bba36",
- "parentUUID": "9407b681-f417-41f5-8c9b-6f02ae412db6",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when minted after negative rebase",
- "fullTitle": "Minter #mint+burn #mint - rebase debt amounts are calculated correctly when minted after negative rebase",
- "timedOut": false,
- "duration": 202,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = false;\n// Mint before rebase\nawait f.User1.mintKreskoAsset(f.user1.address, f.KrAsset.address, mintAmount);\nconst balanceBefore = await f.KrAsset.balanceOf(f.user1.address);\n// Rebase the asset according to params\nawait f.KrAsset.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Ensure that the minted balance is adjusted by the rebase\nconst [balanceAfter, balanceAfterAdjusted] = await (0, _krassets.getDebtIndexAdjustedBalance)(f.user1, f.KrAsset);\n(0, _chai.expect)(balanceAfter).to.equal(mintAmount.div(denominator));\n(0, _chai.expect)(balanceBefore).to.not.equal(balanceAfter);\n// Ensure that debt amount is also adjusted by the rebase\nconst debtAmount = await hre.Diamond.getAccountDebtAmount(f.user1.address, f.KrAsset.address);\n(0, _chai.expect)(balanceAfterAdjusted).to.equal(debtAmount);",
- "err": {},
- "uuid": "b4d2b3db-c0bd-4aa6-ac8d-8ff749c72472",
- "parentUUID": "9407b681-f417-41f5-8c9b-6f02ae412db6",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "64951eb0-9c22-47ca-8330-a56b07f560f6",
- "3ba9d602-6f10-48cc-b8d1-2a3f602ae5dc",
- "99af08bb-1f97-4a52-bfe1-543b0d4bba36",
- "b4d2b3db-c0bd-4aa6-ac8d-8ff749c72472"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 805,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "7563db6d-106b-401c-a38a-14dade575a2d",
- "title": "debt values are calculated correctly",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/04-mint-repay.ts",
- "file": "/src/test/minter/04-mint-repay.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "when mint is made before positive rebase",
- "fullTitle": "Minter #mint+burn #mint - rebase debt values are calculated correctly when mint is made before positive rebase",
- "timedOut": false,
- "duration": 309,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = true;\n// Mint before rebase\nawait f.User1.mintKreskoAsset(f.user1.address, f.KrAsset.address, mintAmount);\nconst valueBeforeRebase = await hre.Diamond.getAccountTotalDebtValue(f.user1.address);\n// Adjust price accordingly\nconst assetPrice = await f.KrAsset.getPrice();\nf.KrAsset.setPrice((0, _values.fromBig)(assetPrice.div(denominator), 8));\n// Rebase the asset according to params\nawait f.KrAsset.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Ensure that the value inside protocol matches the value before rebase\nconst valueAfterRebase = await hre.Diamond.getAccountTotalDebtValue(f.user1.address);\n(0, _chai.expect)(valueAfterRebase).to.equal(valueBeforeRebase);",
- "err": {},
- "uuid": "206891c0-64db-4fc3-868f-cbb04547e56f",
- "parentUUID": "7563db6d-106b-401c-a38a-14dade575a2d",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when mint is made before negative rebase",
- "fullTitle": "Minter #mint+burn #mint - rebase debt values are calculated correctly when mint is made before negative rebase",
- "timedOut": false,
- "duration": 303,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = false;\n// Mint before rebase\nawait f.User1.mintKreskoAsset(f.user1.address, f.KrAsset.address, mintAmount);\nconst valueBeforeRebase = await hre.Diamond.getAccountTotalDebtValue(f.user1.address);\n// Adjust price accordingly\nconst assetPrice = await f.KrAsset.getPrice();\nf.KrAsset.setPrice((0, _values.fromBig)(assetPrice.mul(denominator), 8));\n// Rebase the asset according to params\nawait f.KrAsset.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Ensure that the value inside protocol matches the value before rebase\nconst valueAfterRebase = await hre.Diamond.getAccountTotalDebtValue(f.user1.address);\n(0, _chai.expect)(valueAfterRebase).to.equal(valueBeforeRebase);",
- "err": {},
- "uuid": "9f332e03-ae45-4a9b-8a90-90c6e2d27f7a",
- "parentUUID": "7563db6d-106b-401c-a38a-14dade575a2d",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when minted after positive rebase",
- "fullTitle": "Minter #mint+burn #mint - rebase debt values are calculated correctly when minted after positive rebase",
- "timedOut": false,
- "duration": 304,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = true;\n// Equal value after rebase\nconst equalMintAmount = mintAmount.mul(denominator);\nconst assetPrice = await f.KrAsset.getPrice();\n// Get value of the future mint before rebase\nconst valueBeforeRebase = await hre.Diamond.getValue(f.KrAsset.address, mintAmount);\n// Adjust price accordingly\nf.KrAsset.setPrice((0, _values.fromBig)(assetPrice, 8) / denominator);\nawait f.KrAsset.contract.rebase((0, _values.toBig)(denominator), positive, []);\nawait f.User1.mintKreskoAsset(f.user1.address, f.KrAsset.address, equalMintAmount);\n// Ensure that value after mint matches what is expected\nconst valueAfterRebase = await hre.Diamond.getAccountTotalDebtValue(f.user1.address);\n(0, _chai.expect)(valueAfterRebase).to.equal(valueBeforeRebase);",
- "err": {},
- "uuid": "1aa2f20d-5fea-4f21-bf9d-14f099a6d3bc",
- "parentUUID": "7563db6d-106b-401c-a38a-14dade575a2d",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when minted after negative rebase",
- "fullTitle": "Minter #mint+burn #mint - rebase debt values are calculated correctly when minted after negative rebase",
- "timedOut": false,
- "duration": 305,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = false;\n// Equal value after rebase\nconst equalMintAmount = mintAmount.div(denominator);\nconst assetPrice = await f.KrAsset.getPrice();\n// Get value of the future mint before rebase\nconst valueBeforeRebase = await hre.Diamond.getValue(f.KrAsset.address, mintAmount);\n// Adjust price accordingly\nf.KrAsset.setPrice((0, _values.fromBig)(assetPrice.mul(denominator), 8));\nawait f.KrAsset.contract.rebase((0, _values.toBig)(denominator), positive, []);\nawait f.User1.mintKreskoAsset(f.user1.address, f.KrAsset.address, equalMintAmount);\n// Ensure that value after mint matches what is expected\nconst valueAfterRebase = await hre.Diamond.getAccountTotalDebtValue(f.user1.address);\n(0, _chai.expect)(valueAfterRebase).to.equal(valueBeforeRebase);",
- "err": {},
- "uuid": "afd5ca0c-1751-4a7c-8c98-f5556475c573",
- "parentUUID": "7563db6d-106b-401c-a38a-14dade575a2d",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "206891c0-64db-4fc3-868f-cbb04547e56f",
- "9f332e03-ae45-4a9b-8a90-90c6e2d27f7a",
- "1aa2f20d-5fea-4f21-bf9d-14f099a6d3bc",
- "afd5ca0c-1751-4a7c-8c98-f5556475c573"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 1221,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "f3327b5f-82fe-4d2f-a0c4-6c75fb95ae75",
- "title": "debt values and amounts are calculated correctly",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/04-mint-repay.ts",
- "file": "/src/test/minter/04-mint-repay.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "when minted before and after a positive rebase",
- "fullTitle": "Minter #mint+burn #mint - rebase debt values and amounts are calculated correctly when minted before and after a positive rebase",
- "timedOut": false,
- "duration": 707,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const assetPrice = await f.KrAsset.getPrice();\n// Rebase params\nconst denominator = 4;\nconst positive = true;\nconst mintAmountAfterRebase = mintAmount.mul(denominator);\nconst assetPriceRebase = assetPrice.div(denominator);\n// Get value of the future mint\nconst valueBeforeRebase = await hre.Diamond.getValue(f.KrAsset.address, mintAmount);\n// Mint before rebase\nawait f.User1.mintKreskoAsset(f.user1.address, f.KrAsset.address, mintAmount);\n// Get results\nconst balanceAfterFirstMint = await f.KrAsset.contract.balanceOf(f.user1.address);\nconst debtAmountAfterFirstMint = await hre.Diamond.getAccountDebtAmount(f.user1.address, f.KrAsset.address);\nconst debtValueAfterFirstMint = await hre.Diamond.getAccountTotalDebtValue(f.user1.address);\n// Assert\n(0, _chai.expect)(balanceAfterFirstMint).to.equal(debtAmountAfterFirstMint);\n(0, _chai.expect)(valueBeforeRebase).to.equal(debtValueAfterFirstMint);\n// Adjust price and rebase\nf.KrAsset.setPrice((0, _values.fromBig)(assetPriceRebase, 8));\nawait f.KrAsset.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Ensure debt amounts and balances match\nconst [balanceAfterFirstRebase, balanceAfterFirstRebaseAdjusted] = await (0, _krassets.getDebtIndexAdjustedBalance)(f.user1, f.KrAsset);\nconst debtAmountAfterFirstRebase = await hre.Diamond.getAccountDebtAmount(f.user1.address, f.KrAsset.address);\n(0, _chai.expect)(balanceAfterFirstRebase).to.equal(mintAmountAfterRebase);\n(0, _chai.expect)(balanceAfterFirstRebaseAdjusted).to.equal(debtAmountAfterFirstRebase);\n// Ensure debt usd values match\nconst debtValueAfterFirstRebase = await hre.Diamond.getAccountTotalDebtValue(f.user1.address);\n(0, _chai.expect)(await (0, _calculations.fromScaledAmount)(debtValueAfterFirstRebase, f.KrAsset)).to.equal(debtValueAfterFirstMint);\n(0, _chai.expect)(await (0, _calculations.fromScaledAmount)(debtValueAfterFirstRebase, f.KrAsset)).to.equal(valueBeforeRebase);\n// Mint after rebase\nawait f.User1.mintKreskoAsset(f.user1.address, f.KrAsset.address, mintAmountAfterRebase);\n// Ensure debt amounts and balances match\nconst balanceAfterSecondMint = await f.KrAsset.contract.balanceOf(f.user1.address);\n// Ensure balance matches\nconst expectedBalanceAfterSecondMint = balanceAfterFirstRebase.add(mintAmountAfterRebase);\n(0, _chai.expect)(balanceAfterSecondMint).to.equal(expectedBalanceAfterSecondMint);\n// Ensure debt usd values match\nconst debtValueAfterSecondMint = await hre.Diamond.getAccountTotalDebtValue(f.user1.address);\n(0, _chai.expect)(await (0, _calculations.fromScaledAmount)(debtValueAfterSecondMint, f.KrAsset)).to.closeTo(debtValueAfterFirstMint.mul(2), INTEREST_RATE_PRICE_DELTA);\n(0, _chai.expect)(debtValueAfterSecondMint).to.closeTo(valueBeforeRebase.mul(2), INTEREST_RATE_PRICE_DELTA);",
- "err": {},
- "uuid": "866df647-06ea-4412-9dc1-9b80df3b7e20",
- "parentUUID": "f3327b5f-82fe-4d2f-a0c4-6c75fb95ae75",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when minted before and after a negative rebase",
- "fullTitle": "Minter #mint+burn #mint - rebase debt values and amounts are calculated correctly when minted before and after a negative rebase",
- "timedOut": false,
- "duration": 685,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const assetPrice = await f.KrAsset.getPrice();\n// Rebase params\nconst denominator = 4;\nconst positive = false;\nconst mintAmountAfterRebase = mintAmount.div(denominator);\nconst assetPriceRebase = assetPrice.mul(denominator);\n// Get value of the future mint\nconst valueBeforeRebase = await hre.Diamond.getValue(f.KrAsset.address, mintAmount);\n// Mint before rebase\nawait f.User1.mintKreskoAsset(f.user1.address, f.KrAsset.address, mintAmount);\n// Get results\nconst balanceAfterFirstMint = await f.KrAsset.contract.balanceOf(f.user1.address);\nconst debtAmountAfterFirstMint = await hre.Diamond.getAccountDebtAmount(f.user1.address, f.KrAsset.address);\nconst debtValueAfterFirstMint = await hre.Diamond.getAccountTotalDebtValue(f.user1.address);\n// Assert\n(0, _chai.expect)(balanceAfterFirstMint).to.equal(debtAmountAfterFirstMint);\n(0, _chai.expect)(valueBeforeRebase).to.equal(debtValueAfterFirstMint);\n// Adjust price and rebase\nf.KrAsset.setPrice((0, _values.fromBig)(assetPriceRebase, 8));\nawait f.KrAsset.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Ensure debt amounts and balances match\nconst [balanceAfterFirstRebase, balanceAfterFirstRebaseAdjusted] = await (0, _krassets.getDebtIndexAdjustedBalance)(f.user1, f.KrAsset);\nconst debtAmountAfterFirstRebase = await hre.Diamond.getAccountDebtAmount(f.user1.address, f.KrAsset.address);\n(0, _chai.expect)(balanceAfterFirstRebase).to.equal(mintAmountAfterRebase);\n(0, _chai.expect)(balanceAfterFirstRebaseAdjusted).to.equal(debtAmountAfterFirstRebase);\n// Ensure debt usd values match\nconst debtValueAfterFirstRebase = await hre.Diamond.getAccountTotalDebtValue(f.user1.address);\n(0, _chai.expect)(debtValueAfterFirstRebase).to.equal(await (0, _calculations.toScaledAmount)(debtValueAfterFirstMint, f.KrAsset));\n(0, _chai.expect)(debtValueAfterFirstRebase).to.equal(await (0, _calculations.toScaledAmount)(valueBeforeRebase, f.KrAsset));\n// Mint after rebase\nawait f.User1.mintKreskoAsset(f.user1.address, f.KrAsset.address, mintAmountAfterRebase);\n// Ensure debt usd values match\nconst debtValueAfterSecondMint = await hre.Diamond.getAccountTotalDebtValue(f.user1.address);\n(0, _chai.expect)(debtValueAfterSecondMint).to.closeTo(await (0, _calculations.toScaledAmount)(debtValueAfterFirstMint.mul(2), f.KrAsset), INTEREST_RATE_PRICE_DELTA);\n(0, _chai.expect)(debtValueAfterSecondMint).to.closeTo(await (0, _calculations.toScaledAmount)(valueBeforeRebase.mul(2), f.KrAsset), INTEREST_RATE_PRICE_DELTA);",
- "err": {},
- "uuid": "dd6faf7b-61a6-44e3-9246-a8216a85fa03",
- "parentUUID": "f3327b5f-82fe-4d2f-a0c4-6c75fb95ae75",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "866df647-06ea-4412-9dc1-9b80df3b7e20",
- "dd6faf7b-61a6-44e3-9246-a8216a85fa03"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 1392,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "763ecb7a-fce0-4a92-98c9-c3be8d5f1376",
- "title": "#burn",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/04-mint-repay.ts",
- "file": "/src/test/minter/04-mint-repay.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"#burn\"",
- "fullTitle": "Minter #mint+burn #burn \"before each\" hook in \"#burn\"",
- "timedOut": false,
- "duration": 154,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await f.User1.mintKreskoAsset(f.user1.address, f.KrAsset.address, f.initialMintAmount);",
- "err": {},
- "uuid": "9e28120f-c719-4ed5-9274-63043b100ae3",
- "parentUUID": "763ecb7a-fce0-4a92-98c9-c3be8d5f1376",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [
- {
- "title": "should allow users to burn some of their Kresko asset balances",
- "fullTitle": "Minter #mint+burn #burn should allow users to burn some of their Kresko asset balances",
- "timedOut": false,
- "duration": 196,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const kreskoAssetTotalSupplyBefore = await f.KrAsset.contract.totalSupply();\n// Burn Kresko asset\nconst burnAmount = (0, _values.toBig)(1);\nconst kreskoAssetIndex = 0;\nawait f.User1.burnKreskoAsset(f.user1.address, f.KrAsset.address, burnAmount, kreskoAssetIndex);\n// Confirm the user no long holds the burned Kresko asset amount\nconst userBalance = await f.KrAsset.balanceOf(f.user1.address);\n(0, _chai.expect)(userBalance).to.equal(f.initialMintAmount.sub(burnAmount));\n// Confirm that the Kresko asset's total supply decreased as expected\nconst kreskoAssetTotalSupplyAfter = await f.KrAsset.contract.totalSupply();\n(0, _chai.expect)(kreskoAssetTotalSupplyAfter).to.equal(kreskoAssetTotalSupplyBefore.sub(burnAmount));\n// Confirm the array of the user's minted Kresko assets still contains the asset's address\nconst mintedKreskoAssetsAfter = await _optimizations.default.getAccountMintedAssets(f.user1.address);\n(0, _chai.expect)(mintedKreskoAssetsAfter).to.deep.equal([\n f.KrAsset.address\n]);\n// Confirm the user's minted kresko asset amount has been updated\nconst userDebt = await _optimizations.default.getAccountDebtAmount(f.user1.address, f.KrAsset);\n(0, _chai.expect)(userDebt).to.closeTo(f.initialMintAmount.sub(burnAmount), INTEREST_RATE_DELTA);",
- "err": {},
- "uuid": "cce746e1-1f5b-498f-98f2-7bc09de65992",
- "parentUUID": "763ecb7a-fce0-4a92-98c9-c3be8d5f1376",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should allow users to burn their full balance of a Kresko asset",
- "fullTitle": "Minter #mint+burn #burn should allow users to burn their full balance of a Kresko asset",
- "timedOut": false,
- "duration": 0,
- "state": "pending",
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": true,
- "context": null,
- "code": "",
- "err": {},
- "uuid": "5475e05b-5827-4538-9a57-d75c3f4e4b59",
- "parentUUID": "763ecb7a-fce0-4a92-98c9-c3be8d5f1376",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should allow trusted address to burn its own Kresko asset balances on behalf of another user",
- "fullTitle": "Minter #mint+burn #burn should allow trusted address to burn its own Kresko asset balances on behalf of another user",
- "timedOut": false,
- "duration": 237,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await hre.Diamond.grantRole(_roles.Role.MANAGER, f.user2.address);\nconst kreskoAssetTotalSupplyBefore = await f.KrAsset.contract.totalSupply();\n// Burn Kresko asset\nconst burnAmount = (0, _values.toBig)(1);\nconst kreskoAssetIndex = 0;\nconst userOneBalanceBefore = await f.KrAsset.balanceOf(f.user1.address);\n// User three burns it's KreskoAsset to reduce userOnes debt\nawait f.User2.burnKreskoAsset(f.user1.address, f.KrAsset.address, burnAmount, kreskoAssetIndex);\n// await expect(f.User2.burnKreskoAsset(f.user1.address, f.KrAsset.address, burnAmount, kreskoAssetIndex)).to.not.be\n// .reverted;\n// Confirm the userOne had no effect on it's kreskoAsset balance\nconst userOneBalance = await f.KrAsset.balanceOf(f.user1.address);\n(0, _chai.expect)(userOneBalance).to.equal(userOneBalanceBefore, 'userOneBalance');\n// Confirm the userThree no long holds the burned Kresko asset amount\nconst userThreeBalance = await f.KrAsset.balanceOf(f.user2.address);\n(0, _chai.expect)(userThreeBalance).to.equal(f.initialMintAmount.sub(burnAmount), 'userThreeBalance');\n// Confirm that the Kresko asset's total supply decreased as expected\nconst kreskoAssetTotalSupplyAfter = await f.KrAsset.contract.totalSupply();\n(0, _chai.expect)(kreskoAssetTotalSupplyAfter).to.equal(kreskoAssetTotalSupplyBefore.sub(burnAmount), 'totalSupplyAfter');\n// Confirm the array of the user's minted Kresko assets still contains the asset's address\nconst mintedKreskoAssetsAfter = await _optimizations.default.getAccountMintedAssets(f.user2.address);\n(0, _chai.expect)(mintedKreskoAssetsAfter).to.deep.equal([\n f.KrAsset.address\n], 'mintedKreskoAssetsAfter');\n// Confirm the user's minted kresko asset amount has been updated\nconst userOneDebt = await _optimizations.default.getAccountDebtAmount(f.user1.address, f.KrAsset);\n(0, _chai.expect)(userOneDebt).to.equal(f.initialMintAmount.sub(burnAmount));",
- "err": {},
- "uuid": "25aff4c1-2a23-4136-b0e6-a829cb26f132",
- "parentUUID": "763ecb7a-fce0-4a92-98c9-c3be8d5f1376",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should allow trusted address to burn the full balance of its Kresko asset on behalf another user",
- "fullTitle": "Minter #mint+burn #burn should allow trusted address to burn the full balance of its Kresko asset on behalf another user",
- "timedOut": false,
- "duration": 0,
- "state": "pending",
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": true,
- "context": null,
- "code": "",
- "err": {},
- "uuid": "ed292c89-87e5-49c5-a614-9494a2c37979",
- "parentUUID": "763ecb7a-fce0-4a92-98c9-c3be8d5f1376",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should burn up to the minimum debt position amount if the requested burn would result in a position under the minimum debt value",
- "fullTitle": "Minter #mint+burn #burn should burn up to the minimum debt position amount if the requested burn would result in a position under the minimum debt value",
- "timedOut": false,
- "duration": 266,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const userBalanceBefore = await f.KrAsset.balanceOf(f.user1.address);\nconst kreskoAssetTotalSupplyBefore = await f.KrAsset.contract.totalSupply();\n// Calculate actual burn amount\nconst userOneDebt = await _optimizations.default.getAccountDebtAmount(f.user1.address, f.KrAsset);\nconst minDebtValue = (0, _values.fromBig)(await _optimizations.default.getMinDebtValue(), 8);\nconst oraclePrice = f.KrAsset.config.args.price;\nconst burnAmount = (0, _values.toBig)((0, _values.fromBig)(userOneDebt) - minDebtValue / oraclePrice);\n// Burn Kresko asset\nconst kreskoAssetIndex = 0;\nawait f.User1.burnKreskoAsset(f.user1.address, f.KrAsset.address, burnAmount, kreskoAssetIndex);\n// Confirm the user holds the expected Kresko asset amount\nconst userBalance = await f.KrAsset.balanceOf(f.user1.address);\n// expect(fromBig(userBalance)).to.equal(fromBig(userBalanceBefore.sub(burnAmount)));\n(0, _chai.expect)(userBalance).eq(userBalanceBefore.sub(burnAmount));\n// Confirm that the Kresko asset's total supply decreased as expected\nconst kreskoAssetTotalSupplyAfter = await f.KrAsset.contract.totalSupply();\n(0, _chai.expect)(kreskoAssetTotalSupplyAfter).eq(kreskoAssetTotalSupplyBefore.sub(burnAmount));\n// Confirm the array of the user's minted Kresko assets still contains the asset's address\nconst mintedKreskoAssetsAfter = await _optimizations.default.getAccountMintedAssets(f.user1.address);\n(0, _chai.expect)(mintedKreskoAssetsAfter).to.deep.equal([\n f.KrAsset.address\n]);\n// Confirm the user's minted kresko asset amount has been updated\nconst newUserDebt = await _optimizations.default.getAccountDebtAmount(f.user1.address, f.KrAsset);\n(0, _chai.expect)(newUserDebt).to.be.equal(userOneDebt.sub(burnAmount));",
- "err": {},
- "uuid": "3ee3afd1-df73-46d5-8cfc-7b76e73b99f7",
- "parentUUID": "763ecb7a-fce0-4a92-98c9-c3be8d5f1376",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should emit KreskoAssetBurned event",
- "fullTitle": "Minter #mint+burn #burn should emit KreskoAssetBurned event",
- "timedOut": false,
- "duration": 158,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const kreskoAssetIndex = 0;\nconst tx = await f.User1.burnKreskoAsset(f.user1.address, f.KrAsset.address, f.initialMintAmount.div(5), kreskoAssetIndex);\nconst event = await (0, _events.getInternalEvent)(tx, hre.Diamond, 'KreskoAssetBurned');\n(0, _chai.expect)(event.account).to.equal(f.user1.address);\n(0, _chai.expect)(event.kreskoAsset).to.equal(f.KrAsset.address);\n(0, _chai.expect)(event.amount).to.equal(f.initialMintAmount.div(5));",
- "err": {},
- "uuid": "cfdf7d5e-7230-4a1a-9382-5a7cbe73de8f",
- "parentUUID": "763ecb7a-fce0-4a92-98c9-c3be8d5f1376",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should allow users to burn Kresko assets without giving token approval to Kresko.sol contract",
- "fullTitle": "Minter #mint+burn #burn should allow users to burn Kresko assets without giving token approval to Kresko.sol contract",
- "timedOut": false,
- "duration": 475,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const secondMintAmount = 1;\nconst burnAmount = f.initialMintAmount.add(secondMintAmount);\nawait (0, _chai.expect)(f.User1.mintKreskoAsset(f.user1.address, f.KrAsset.address, secondMintAmount)).to.not.be.reverted;\nconst kreskoAssetIndex = 0;\nawait (0, _chai.expect)(f.User1.burnKreskoAsset(f.user1.address, f.KrAsset.address, burnAmount, kreskoAssetIndex)).to.not.be.reverted;",
- "err": {},
- "uuid": "c7e2df3b-9ddc-4e0a-b8fe-a0ba78d3edf0",
- "parentUUID": "763ecb7a-fce0-4a92-98c9-c3be8d5f1376",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should not allow users to burn an amount of 0",
- "fullTitle": "Minter #mint+burn #burn should not allow users to burn an amount of 0",
- "timedOut": false,
- "duration": 34,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const kreskoAssetIndex = 0;\nawait (0, _chai.expect)(f.User1.burnKreskoAsset(f.user1.address, f.KrAsset.address, 0, kreskoAssetIndex)).to.be.revertedWithCustomError((0, _errors.Errors)(hre), 'ZERO_BURN');",
- "err": {},
- "uuid": "c345053e-834f-4d35-b594-c9c193a2077b",
- "parentUUID": "763ecb7a-fce0-4a92-98c9-c3be8d5f1376",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should not allow untrusted address to burn any kresko assets on behalf of another user",
- "fullTitle": "Minter #mint+burn #burn should not allow untrusted address to burn any kresko assets on behalf of another user",
- "timedOut": false,
- "duration": 44,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const kreskoAssetIndex = 0;\nawait (0, _chai.expect)(f.User2.burnKreskoAsset(f.user1.address, f.KrAsset.address, 100, kreskoAssetIndex)).to.be.revertedWith(`AccessControl: account ${f.user2.address.toLowerCase()} is missing role 0x46925e0f0cc76e485772167edccb8dc449d43b23b55fc4e756b063f49099e6a0`);",
- "err": {},
- "uuid": "95305a14-3615-4366-8bb2-c6fec6938a64",
- "parentUUID": "763ecb7a-fce0-4a92-98c9-c3be8d5f1376",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should not allow users to burn more kresko assets than they hold as debt",
- "fullTitle": "Minter #mint+burn #burn should not allow users to burn more kresko assets than they hold as debt",
- "timedOut": false,
- "duration": 73,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const kreskoAssetIndex = 0;\nconst debt = await _optimizations.default.getAccountDebtAmount(f.user1.address, f.KrAsset);\nconst burnAmount = debt.add((0, _values.toBig)(1));\nawait (0, _chai.expect)(f.User1.burnKreskoAsset(f.user1.address, f.KrAsset.address, burnAmount, kreskoAssetIndex)).to.be.reverted;",
- "err": {},
- "uuid": "a2b7c9fa-bd72-4a93-9895-90e579570610",
- "parentUUID": "763ecb7a-fce0-4a92-98c9-c3be8d5f1376",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [
- {
- "uuid": "488721b7-93b5-452f-9b11-29d9cde3df3d",
- "title": "Protocol open fee",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/04-mint-repay.ts",
- "file": "/src/test/minter/04-mint-repay.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "should charge the protocol open fee with a single collateral asset if the deposit amount is sufficient and emit FeePaid event",
- "fullTitle": "Minter #mint+burn #burn Protocol open fee should charge the protocol open fee with a single collateral asset if the deposit amount is sufficient and emit FeePaid event",
- "timedOut": false,
- "duration": 450,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const openFee = 0.01e4;\nawait f.KrAsset.update({\n openFee,\n maxDebtMinter: _values.MaxUint128\n});\nconst mintAmount = (0, _values.toBig)(1);\nconst mintValue = mintAmount.wadMul(_mocks.TEN_USD.ebn(8));\nconst expectedFeeValue = mintValue.percentMul(openFee);\nconst expectedCollateralFeeAmount = expectedFeeValue.wadDiv(_mocks.TEN_USD.ebn(8));\n// Get the balances prior to the fee being charged.\nconst feeRecipient = await hre.Diamond.getFeeRecipient();\nconst kreskoCollateralAssetBalanceBefore = await f.Collateral.balanceOf(hre.Diamond.address);\nconst feeRecipientCollateralBalanceBefore = await f.Collateral.balanceOf(feeRecipient);\n// Mint Kresko asset\nconst tx = await f.User1.mintKreskoAsset(f.user1.address, f.KrAsset.address, mintAmount);\n// Get the balances after the fees have been charged.\nconst kreskoCollateralAssetBalanceAfter = await f.Collateral.balanceOf(hre.Diamond.address);\nconst feeRecipientCollateralBalanceAfter = await f.Collateral.balanceOf(feeRecipient);\n// Ensure the amount gained / lost by the kresko contract and the fee recipient are as expected\nconst feeRecipientBalanceIncrease = feeRecipientCollateralBalanceAfter.sub(feeRecipientCollateralBalanceBefore);\n(0, _chai.expect)(kreskoCollateralAssetBalanceBefore.sub(kreskoCollateralAssetBalanceAfter)).to.equal(feeRecipientBalanceIncrease);\n// Normalize expected amount because protocol closeFee has 10**18 decimals\n(0, _chai.expect)(feeRecipientBalanceIncrease).to.equal(expectedCollateralFeeAmount);\n// Ensure the emitted event is as expected.\nconst event = await (0, _events.getInternalEvent)(tx, hre.Diamond, 'FeePaid');\n(0, _chai.expect)(event.account).to.equal(f.user1.address);\n(0, _chai.expect)(event.paymentCollateralAsset).to.equal(f.Collateral.address);\n(0, _chai.expect)(event.paymentAmount).to.equal(expectedCollateralFeeAmount);\n(0, _chai.expect)(event.paymentValue).to.equal(expectedFeeValue);\n(0, _chai.expect)(event.feeType).to.equal(_types.MinterFee.OPEN);\n// Now verify that calcExpectedFee function returns accurate fee amount\nconst [, values] = await hre.Diamond.previewFee(f.user1.address, f.KrAsset.address, mintAmount, _types.MinterFee.OPEN);\n(0, _chai.expect)(values[0]).eq(expectedCollateralFeeAmount);",
- "err": {},
- "uuid": "96ed80ff-9af5-4414-9fce-0529a605c36c",
- "parentUUID": "488721b7-93b5-452f-9b11-29d9cde3df3d",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "96ed80ff-9af5-4414-9fce-0529a605c36c"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 450,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "c58a3671-bf57-4909-b483-2ec0e45e5299",
- "title": "Protocol Close Fee",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/04-mint-repay.ts",
- "file": "/src/test/minter/04-mint-repay.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "should charge the protocol close fee with a single collateral asset if the deposit amount is sufficient and emit FeePaid event",
- "fullTitle": "Minter #mint+burn #burn Protocol Close Fee should charge the protocol close fee with a single collateral asset if the deposit amount is sufficient and emit FeePaid event",
- "timedOut": false,
- "duration": 193,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const burnAmount = (0, _values.toBig)(1);\nconst burnValue = burnAmount.wadMul(_mocks.TEN_USD.ebn(8));\nconst closeFee = f.KrAsset.config.args.krAssetConfig.closeFee // use toBig() to emulate closeFee's 18 decimals on contract\n;\nconst expectedFeeValue = burnValue.percentMul(closeFee);\nconst expectedCollateralFeeAmount = expectedFeeValue.wadDiv(f.Collateral.config.args.price.ebn(8));\nconst feeRecipient = await hre.Diamond.getFeeRecipient();\n// Get the balances prior to the fee being charged.\nconst kreskoCollateralAssetBalanceBefore = await f.Collateral.balanceOf(hre.Diamond.address);\nconst feeRecipientCollateralBalanceBefore = await f.Collateral.balanceOf(feeRecipient);\n// Burn Kresko asset\nconst kreskoAssetIndex = 0;\nconst tx = await f.User1.burnKreskoAsset(f.user1.address, f.KrAsset.address, burnAmount, kreskoAssetIndex);\n// Get the balances after the fees have been charged.\nconst kreskoCollateralAssetBalanceAfter = await f.Collateral.balanceOf(hre.Diamond.address);\nconst feeRecipientCollateralBalanceAfter = await f.Collateral.balanceOf(feeRecipient);\n// Ensure the amount gained / lost by the kresko contract and the fee recipient are as expected\nconst feeRecipientBalanceIncrease = feeRecipientCollateralBalanceAfter.sub(feeRecipientCollateralBalanceBefore);\n(0, _chai.expect)(kreskoCollateralAssetBalanceBefore.sub(kreskoCollateralAssetBalanceAfter)).to.equal(feeRecipientBalanceIncrease);\n// Normalize expected amount because protocol closeFee has 10**18 decimals\n(0, _chai.expect)(feeRecipientBalanceIncrease).to.equal(expectedCollateralFeeAmount);\n// Ensure the emitted event is as expected.\nconst event = await (0, _events.getInternalEvent)(tx, hre.Diamond, 'FeePaid');\n(0, _chai.expect)(event.account).to.equal(f.user1.address);\n(0, _chai.expect)(event.paymentCollateralAsset).to.equal(f.Collateral.address);\n(0, _chai.expect)(event.paymentAmount).to.equal(expectedCollateralFeeAmount);\n(0, _chai.expect)(event.paymentValue).to.equal(expectedFeeValue);\n(0, _chai.expect)(event.feeType).to.equal(_types.MinterFee.CLOSE);",
- "err": {},
- "uuid": "470bc5c9-51bc-4839-81d8-8a4b8b2e59bc",
- "parentUUID": "c58a3671-bf57-4909-b483-2ec0e45e5299",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should charge correct protocol close fee after a positive rebase",
- "fullTitle": "Minter #mint+burn #burn Protocol Close Fee should charge correct protocol close fee after a positive rebase",
- "timedOut": false,
- "duration": 515,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const wAmount = 1;\nconst burnAmount = (0, _values.toBig)(1);\nconst expectedFeeAmount = burnAmount.percentMul(f.KrAsset.config.args.krAssetConfig.closeFee);\nconst expectedFeeValue = expectedFeeAmount.wadMul((0, _values.toBig)(_mocks.TEN_USD, 8));\nconst event = await (0, _events.getInternalEvent)(await (0, _krassets.burnKrAsset)({\n user: f.user2,\n asset: f.KrAsset,\n amount: burnAmount\n}), hre.Diamond, 'FeePaid');\n(0, _chai.expect)(event.paymentAmount).to.equal(expectedFeeAmount);\n(0, _chai.expect)(event.paymentValue).to.equal(expectedFeeValue);\n(0, _chai.expect)(event.feeType).to.equal(_types.MinterFee.CLOSE);\n// rebase params\nconst denominator = 4;\nconst positive = true;\nf.KrAsset.setPrice(_mocks.TEN_USD / denominator);\nawait f.KrAsset.contract.rebase((0, _values.toBig)(denominator), positive, []);\nconst burnAmountRebase = burnAmount.mul(denominator);\nawait (0, _collaterals.withdrawCollateral)({\n user: f.user2,\n asset: f.Collateral,\n amount: (0, _values.toBig)(wAmount)\n});\nconst eventAfterRebase = await (0, _events.getInternalEvent)(await (0, _krassets.burnKrAsset)({\n user: f.user2,\n asset: f.KrAsset,\n amount: burnAmountRebase\n}), hre.Diamond, 'FeePaid');\n(0, _chai.expect)(eventAfterRebase.paymentCollateralAsset).to.equal(event.paymentCollateralAsset);\n(0, _chai.expect)(eventAfterRebase.paymentAmount).to.equal(expectedFeeAmount);\n(0, _chai.expect)(eventAfterRebase.paymentValue).to.equal(expectedFeeValue);",
- "err": {},
- "uuid": "2f297ce7-7201-470d-8a32-457fcbdfc275",
- "parentUUID": "c58a3671-bf57-4909-b483-2ec0e45e5299",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should charge correct protocol close fee after a negative rebase",
- "fullTitle": "Minter #mint+burn #burn Protocol Close Fee should charge correct protocol close fee after a negative rebase",
- "timedOut": false,
- "duration": 521,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const wAmount = 1;\nconst burnAmount = (0, _values.toBig)(1);\nconst expectedFeeAmount = burnAmount.percentMul(f.KrAsset.config.args.krAssetConfig.closeFee);\nconst expectedFeeValue = expectedFeeAmount.wadMul((0, _values.toBig)(_mocks.TEN_USD, 8));\nconst event = await (0, _events.getInternalEvent)(await (0, _krassets.burnKrAsset)({\n user: f.user2,\n asset: f.KrAsset,\n amount: burnAmount\n}), hre.Diamond, 'FeePaid');\n(0, _chai.expect)(event.paymentAmount).to.equal(expectedFeeAmount);\n(0, _chai.expect)(event.paymentValue).to.equal(expectedFeeValue);\n(0, _chai.expect)(event.feeType).to.equal(_types.MinterFee.CLOSE);\n// rebase params\nconst denominator = 4;\nconst positive = false;\nconst priceAfter = (0, _values.fromBig)(await f.KrAsset.getPrice(), 8) * denominator;\nf.KrAsset.setPrice(priceAfter);\nawait f.KrAsset.contract.rebase((0, _values.toBig)(denominator), positive, []);\nconst burnAmountRebase = burnAmount.div(denominator);\nawait (0, _collaterals.withdrawCollateral)({\n user: f.user2,\n asset: f.Collateral,\n amount: (0, _values.toBig)(wAmount)\n});\nconst eventAfterRebase = await (0, _events.getInternalEvent)(await (0, _krassets.burnKrAsset)({\n user: f.user2,\n asset: f.KrAsset,\n amount: burnAmountRebase\n}), hre.Diamond, 'FeePaid');\n(0, _chai.expect)(eventAfterRebase.paymentCollateralAsset).to.equal(event.paymentCollateralAsset);\n(0, _chai.expect)(eventAfterRebase.paymentAmount).to.equal(expectedFeeAmount);\n(0, _chai.expect)(eventAfterRebase.paymentValue).to.equal(expectedFeeValue);",
- "err": {},
- "uuid": "097a8e00-cb99-4204-ae68-27ea913d3768",
- "parentUUID": "c58a3671-bf57-4909-b483-2ec0e45e5299",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "470bc5c9-51bc-4839-81d8-8a4b8b2e59bc",
- "2f297ce7-7201-470d-8a32-457fcbdfc275",
- "097a8e00-cb99-4204-ae68-27ea913d3768"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 1229,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [
- "cce746e1-1f5b-498f-98f2-7bc09de65992",
- "25aff4c1-2a23-4136-b0e6-a829cb26f132",
- "3ee3afd1-df73-46d5-8cfc-7b76e73b99f7",
- "cfdf7d5e-7230-4a1a-9382-5a7cbe73de8f",
- "c7e2df3b-9ddc-4e0a-b8fe-a0ba78d3edf0",
- "c345053e-834f-4d35-b594-c9c193a2077b",
- "95305a14-3615-4366-8bb2-c6fec6938a64",
- "a2b7c9fa-bd72-4a93-9895-90e579570610"
- ],
- "failures": [],
- "pending": [
- "5475e05b-5827-4538-9a57-d75c3f4e4b59",
- "ed292c89-87e5-49c5-a614-9494a2c37979"
- ],
- "skipped": [],
- "duration": 1483,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "b165c998-63b8-47c2-b4ba-e347bf737335",
- "title": "#burn - rebase",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/04-mint-repay.ts",
- "file": "/src/test/minter/04-mint-repay.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"#burn - rebase\"",
- "fullTitle": "Minter #mint+burn #burn - rebase \"before each\" hook in \"#burn - rebase\"",
- "timedOut": false,
- "duration": 163,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await (0, _krassets.mintKrAsset)({\n asset: f.KrAsset,\n amount: mintAmount,\n user: f.user1\n});",
- "err": {},
- "uuid": "90f1951d-2f13-47fe-9098-5f62def5fd10",
- "parentUUID": "b165c998-63b8-47c2-b4ba-e347bf737335",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [],
- "suites": [
- {
- "uuid": "f27e6fc6-70eb-4249-8309-b87ad9febd2b",
- "title": "debt amounts are calculated correctly",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/04-mint-repay.ts",
- "file": "/src/test/minter/04-mint-repay.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "when repaying all debt after a positive rebase",
- "fullTitle": "Minter #mint+burn #burn - rebase debt amounts are calculated correctly when repaying all debt after a positive rebase",
- "timedOut": false,
- "duration": 198,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = true;\n// Adjust price according to rebase params\nf.KrAsset.setPrice(_mocks.TEN_USD / denominator);\nawait f.KrAsset.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Pay half of debt\nconst debt = await hre.Diamond.getAccountDebtAmount(f.user1.address, f.KrAsset.address);\nconst repayAmount = debt;\nawait f.User1.burnKreskoAsset(f.user1.address, f.KrAsset.address, repayAmount, 0);\n// Debt value after half repayment\nconst debtAfter = await hre.Diamond.getAccountDebtAmount(f.user1.address, f.KrAsset.address);\n(0, _chai.expect)(debtAfter).to.equal(0);\nconst balanceAfterBurn = await f.KrAsset.contract.balanceOf(f.user1.address);\n(0, _chai.expect)(balanceAfterBurn).to.equal(0);\n// Anchor krAssets should equal balance * denominator\nconst wkrAssetBalanceKresko = await f.KrAsset.anchor.balanceOf(hre.Diamond.address);\n(0, _chai.expect)(wkrAssetBalanceKresko).to.equal(f.initialMintAmount) // WEI\n;",
- "err": {},
- "uuid": "65ed8acb-05e8-4ccb-b16a-d2d730686a9b",
- "parentUUID": "f27e6fc6-70eb-4249-8309-b87ad9febd2b",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when repaying partial debt after a positive rebase",
- "fullTitle": "Minter #mint+burn #burn - rebase debt amounts are calculated correctly when repaying partial debt after a positive rebase",
- "timedOut": false,
- "duration": 239,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = true;\n// Adjust price according to rebase params\nf.KrAsset.setPrice(_mocks.TEN_USD / denominator);\nawait f.KrAsset.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Pay half of debt\nconst debt = await hre.Diamond.getAccountDebtAmount(f.user1.address, f.KrAsset.address);\nconst repayAmount = debt.div(2);\nawait f.User1.burnKreskoAsset(f.user1.address, f.KrAsset.address, repayAmount, 0);\n// Debt value after half repayment\nconst debtAfter = await hre.Diamond.getAccountDebtAmount(f.user1.address, f.KrAsset.address);\n// Calc expected value with last update\nconst expectedDebt = mintAmount.div(2).mul(denominator);\n(0, _chai.expect)(debtAfter).to.equal(expectedDebt);\n// Should be all burned\nconst expectedBalanceAfter = mintAmount.mul(denominator).sub(repayAmount);\nconst balanceAfterBurn = await f.KrAsset.contract.balanceOf(f.user1.address);\n(0, _chai.expect)(balanceAfterBurn).to.equal(expectedBalanceAfter);\n// All wkrAssets should be burned\nconst expectedwkrBalance = mintAmount.sub(repayAmount.div(denominator)).add(f.initialMintAmount);\nconst wkrAssetBalanceKresko = await f.KrAsset.anchor.balanceOf(hre.Diamond.address);\n(0, _chai.expect)(wkrAssetBalanceKresko).to.equal(expectedwkrBalance);",
- "err": {},
- "uuid": "909168b5-6470-4b3c-9c95-c460a5490ab1",
- "parentUUID": "f27e6fc6-70eb-4249-8309-b87ad9febd2b",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when repaying all debt after a negative rebase",
- "fullTitle": "Minter #mint+burn #burn - rebase debt amounts are calculated correctly when repaying all debt after a negative rebase",
- "timedOut": false,
- "duration": 201,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = false;\n// Adjust price according to rebase params\nf.KrAsset.setPrice(_mocks.TEN_USD * denominator);\nawait f.KrAsset.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Pay half of debt\nconst debt = await hre.Diamond.getAccountDebtAmount(f.user1.address, f.KrAsset.address);\nconst repayAmount = debt;\nawait f.User1.burnKreskoAsset(f.user1.address, f.KrAsset.address, repayAmount, 0);\n// Debt value after half repayment\nconst debtAfter = await hre.Diamond.getAccountDebtAmount(f.user1.address, f.KrAsset.address);\n// Calc expected value with last update\nconst expectedDebt = 0;\n(0, _chai.expect)(debtAfter).to.equal(expectedDebt);\nconst expectedBalanceAfterBurn = 0;\nconst balanceAfterBurn = (0, _values.fromBig)(await f.KrAsset.contract.balanceOf(f.user1.address));\n(0, _chai.expect)(balanceAfterBurn).to.equal(expectedBalanceAfterBurn);\n// Anchor krAssets should equal balance * denominator\nconst wkrAssetBalanceKresko = await f.KrAsset.anchor.balanceOf(hre.Diamond.address);\n(0, _chai.expect)(wkrAssetBalanceKresko).to.equal((0, _values.toBig)(expectedBalanceAfterBurn * denominator).add(f.initialMintAmount));",
- "err": {},
- "uuid": "3c16b60c-3482-48c6-807a-cd743f6286c0",
- "parentUUID": "f27e6fc6-70eb-4249-8309-b87ad9febd2b",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when repaying partial debt after a negative rebase",
- "fullTitle": "Minter #mint+burn #burn - rebase debt amounts are calculated correctly when repaying partial debt after a negative rebase",
- "timedOut": false,
- "duration": 239,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = false;\n// Adjust price according to rebase params\nf.KrAsset.setPrice(_mocks.TEN_USD * denominator);\nawait f.KrAsset.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Pay half of debt\nconst debt = await hre.Diamond.getAccountDebtAmount(f.user1.address, f.KrAsset.address);\nconst repayAmount = debt.div(2);\nawait f.User1.burnKreskoAsset(f.user1.address, f.KrAsset.address, repayAmount, 0);\n// Debt value after half repayment\nconst debtAfter = await hre.Diamond.getAccountDebtAmount(f.user1.address, f.KrAsset.address);\n// Calc expected value with last update\nconst expectedDebt = mintAmount.div(2).div(denominator);\n(0, _chai.expect)(debtAfter).to.equal(expectedDebt);\n// Should be all burned\nconst expectedBalanceAfter = mintAmount.div(denominator).sub(repayAmount);\nconst balanceAfterBurn = await f.KrAsset.contract.balanceOf(f.user1.address);\n(0, _chai.expect)(balanceAfterBurn).to.equal(expectedBalanceAfter);\n// All wkrAssets should be burned\nconst expectedwkrBalance = mintAmount.sub(repayAmount.mul(denominator)).add(f.initialMintAmount);\nconst wkrAssetBalanceKresko = await f.KrAsset.anchor.balanceOf(hre.Diamond.address);\n(0, _chai.expect)(wkrAssetBalanceKresko).to.equal(expectedwkrBalance);",
- "err": {},
- "uuid": "c02024c9-381a-48e5-b15d-b0958b2982ec",
- "parentUUID": "f27e6fc6-70eb-4249-8309-b87ad9febd2b",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "65ed8acb-05e8-4ccb-b16a-d2d730686a9b",
- "909168b5-6470-4b3c-9c95-c460a5490ab1",
- "3c16b60c-3482-48c6-807a-cd743f6286c0",
- "c02024c9-381a-48e5-b15d-b0958b2982ec"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 877,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "b62b2f28-b257-448f-8df1-523c39739ea3",
- "title": "debt value and mintedKreskoAssets book-keeping is calculated correctly",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/04-mint-repay.ts",
- "file": "/src/test/minter/04-mint-repay.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "when repaying all debt after a positive rebase",
- "fullTitle": "Minter #mint+burn #burn - rebase debt value and mintedKreskoAssets book-keeping is calculated correctly when repaying all debt after a positive rebase",
- "timedOut": false,
- "duration": 191,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = true;\nconst fullRepayAmount = mintAmount.mul(denominator);\n// Adjust price according to rebase params\nf.KrAsset.setPrice(_mocks.TEN_USD / denominator);\nawait f.KrAsset.contract.rebase((0, _values.toBig)(denominator), positive, []);\nawait f.User1.burnKreskoAsset(f.user1.address, f.KrAsset.address, fullRepayAmount, 0);\n// Debt value after half repayment\nconst debtAfter = await hre.Diamond.getAccountDebtAmount(f.user1.address, f.KrAsset.address);\nconst debtValueAfter = await hre.Diamond.getValue(f.KrAsset.address, debtAfter);\n(0, _chai.expect)(debtValueAfter).to.equal(0);",
- "err": {},
- "uuid": "8049a50a-02f9-4abd-8b2c-13befbb10a3c",
- "parentUUID": "b62b2f28-b257-448f-8df1-523c39739ea3",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when repaying partial debt after a positive rebase",
- "fullTitle": "Minter #mint+burn #burn - rebase debt value and mintedKreskoAssets book-keeping is calculated correctly when repaying partial debt after a positive rebase",
- "timedOut": false,
- "duration": 379,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = true;\nconst mintValue = await hre.Diamond.getValue(f.KrAsset.address, mintAmount);\n// Adjust price according to rebase params\nf.KrAsset.setPrice(_mocks.TEN_USD / denominator);\nawait f.KrAsset.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Should contain minted krAsset\nconst mintedKreskoAssetsBeforeBurn = await _optimizations.default.getAccountMintedAssets(f.user1.address);\n(0, _chai.expect)(mintedKreskoAssetsBeforeBurn).to.contain(f.KrAsset.address);\n// Burn assets\n// Pay half of debt\nconst debt = await hre.Diamond.getAccountDebtAmount(f.user1.address, f.KrAsset.address);\nawait f.User1.burnKreskoAsset(f.user1.address, f.KrAsset.address, debt.div(2), 0);\n// Debt value after half repayment\nconst debtAfter = await hre.Diamond.getAccountDebtAmount(f.user1.address, f.KrAsset.address);\nconst debtValueAfter = await hre.Diamond.getValue(f.KrAsset.address, debtAfter);\n// Calc expected value with last update\nconst expectedValue = mintValue.div(2);\n(0, _chai.expect)(debtValueAfter).to.equal(expectedValue);\n// Should still contain minted krAsset\nconst mintedKreskoAssetsAfterBurn = await _optimizations.default.getAccountMintedAssets(f.user1.address);\n(0, _chai.expect)(mintedKreskoAssetsAfterBurn).to.contain(f.KrAsset.address);",
- "err": {},
- "uuid": "3546cb79-cd93-4f7d-826c-339c02dbac67",
- "parentUUID": "b62b2f28-b257-448f-8df1-523c39739ea3",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when repaying all debt after a negative rebase",
- "fullTitle": "Minter #mint+burn #burn - rebase debt value and mintedKreskoAssets book-keeping is calculated correctly when repaying all debt after a negative rebase",
- "timedOut": false,
- "duration": 185,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = false;\nconst fullRepayAmount = mintAmount.div(denominator);\n// Adjust price according to rebase params\nf.KrAsset.setPrice(_mocks.TEN_USD * denominator);\nawait f.KrAsset.contract.rebase((0, _values.toBig)(denominator), positive, []);\nawait f.User1.burnKreskoAsset(f.user1.address, f.KrAsset.address, fullRepayAmount, 0);\n// Debt value after half repayment\nconst debtAfter = await hre.Diamond.getAccountDebtAmount(f.user1.address, f.KrAsset.address);\nconst debtValueAfter = await hre.Diamond.getValue(f.KrAsset.address, debtAfter);\n(0, _chai.expect)(debtValueAfter).to.equal(0);",
- "err": {},
- "uuid": "8586f6c1-7ce4-4def-9257-5c3ed1e33c79",
- "parentUUID": "b62b2f28-b257-448f-8df1-523c39739ea3",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "when repaying partial debt after a negative rebase",
- "fullTitle": "Minter #mint+burn #burn - rebase debt value and mintedKreskoAssets book-keeping is calculated correctly when repaying partial debt after a negative rebase",
- "timedOut": false,
- "duration": 408,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// Rebase params\nconst denominator = 4;\nconst positive = false;\nconst mintValue = await hre.Diamond.getValue(f.KrAsset.address, mintAmount);\nf.KrAsset.setPrice(_mocks.TEN_USD * denominator);\nawait f.KrAsset.contract.rebase((0, _values.toBig)(denominator), positive, []);\n// Pay half of debt\nconst debt = await hre.Diamond.getAccountDebtAmount(f.user1.address, f.KrAsset.address);\nawait f.User1.burnKreskoAsset(f.user1.address, f.KrAsset.address, debt.div(2), 0);\n// Debt value after half repayment\nconst debtAfter = await hre.Diamond.getAccountDebtAmount(f.user1.address, f.KrAsset.address);\nconst debtValueAfter = await hre.Diamond.getValue(f.KrAsset.address, debtAfter);\n// Calc expected value with last update\nconst expectedValue = mintValue.div(2);\n(0, _chai.expect)(debtValueAfter).to.equal(expectedValue);\n// Should still contain minted krAsset\nconst mintedKreskoAssetsAfterBurn = await hre.Diamond.getAccountMintedAssets(f.user1.address);\n(0, _chai.expect)(mintedKreskoAssetsAfterBurn).to.contain(f.KrAsset.address);",
- "err": {},
- "uuid": "12059e47-12ea-4960-a2ca-6f305122dc80",
- "parentUUID": "b62b2f28-b257-448f-8df1-523c39739ea3",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "8049a50a-02f9-4abd-8b2c-13befbb10a3c",
- "3546cb79-cd93-4f7d-826c-339c02dbac67",
- "8586f6c1-7ce4-4def-9257-5c3ed1e33c79",
- "12059e47-12ea-4960-a2ca-6f305122dc80"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 1163,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "9e743be3-8436-4953-a28d-bb4aaa6bc688",
- "title": "CollateralReceiver - UncheckedCollateralWithdraw",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/05-collateral-receiver.ts",
- "file": "/src/test/minter/05-collateral-receiver.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"CollateralReceiver - UncheckedCollateralWithdraw\"",
- "fullTitle": "CollateralReceiver - UncheckedCollateralWithdraw \"before each\" hook in \"CollateralReceiver - UncheckedCollateralWithdraw\"",
- "timedOut": false,
- "duration": 0,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "f = await (0, _fixtures.defaultFixture)();\n[, , [user]] = f.users;",
- "err": {},
- "uuid": "84912e2c-7c19-44a7-a8b9-c00f1fbdd953",
- "parentUUID": "9e743be3-8436-4953-a28d-bb4aaa6bc688",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [],
- "suites": [
- {
- "uuid": "c2984c8c-07ed-4dba-9334-e4c7a51cc74b",
- "title": "#unchecked-collateral-withdrawal",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/05-collateral-receiver.ts",
- "file": "/src/test/minter/05-collateral-receiver.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [],
- "suites": [
- {
- "uuid": "af124919-f626-43e2-8799-75923dea9e69",
- "title": "#unchecked-withdraw",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/05-collateral-receiver.ts",
- "file": "/src/test/minter/05-collateral-receiver.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "withdraw correct amount",
- "fullTitle": "CollateralReceiver - UncheckedCollateralWithdraw #unchecked-collateral-withdrawal #unchecked-withdraw withdraw correct amount",
- "timedOut": false,
- "duration": 128,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const withdrawalAmount = 42069;\nawait (0, _chai.expect)(f.Receiver.testWithdrawalAmount(f.Collateral.address, withdrawalAmount)).to.not.be.revertedWith('wrong amount received');\n(0, _chai.expect)(await f.Collateral.balanceOf(f.Receiver.address)).to.equal(withdrawalAmount);",
- "err": {},
- "uuid": "6466dce0-b1ce-42ac-95aa-2972061c6742",
- "parentUUID": "af124919-f626-43e2-8799-75923dea9e69",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should send correct values to the callback",
- "fullTitle": "CollateralReceiver - UncheckedCollateralWithdraw #unchecked-collateral-withdrawal #unchecked-withdraw should send correct values to the callback",
- "timedOut": false,
- "duration": 272,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const Receiver = f.Receiver;\nconst balKreskoBefore = await f.Collateral.contract.balanceOf(hre.Diamond.address);\nawait Receiver.test(f.Collateral.address, 1);\n(0, _chai.expect)(await Receiver.collateralAsset()).to.equal(f.Collateral.address);\n(0, _chai.expect)(await Receiver.account()).to.equal(user.address);\n(0, _chai.expect)((await Receiver.userData()).val).to.equal(1);\n(0, _chai.expect)(await Receiver.withdrawalAmountRequested()).to.equal(1);\n(0, _chai.expect)(await Receiver.withdrawalAmountReceived()).to.equal(1);\nconst balKreskoAfter = await f.Collateral.contract.balanceOf(hre.Diamond.address);\n(0, _chai.expect)(balKreskoBefore.sub(balKreskoAfter)).to.equal(1);\n(0, _chai.expect)(await f.Collateral.contract.balanceOf(Receiver.address)).to.equal(1);",
- "err": {},
- "uuid": "7909766f-3452-40e0-8761-5ba6a762b3c3",
- "parentUUID": "af124919-f626-43e2-8799-75923dea9e69",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should be able to withdraw collateral up to MRC without returning it",
- "fullTitle": "CollateralReceiver - UncheckedCollateralWithdraw #unchecked-collateral-withdrawal #unchecked-withdraw should be able to withdraw collateral up to MRC without returning it",
- "timedOut": false,
- "duration": 629,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const Receiver = f.Receiver;\nconst { maxWithdrawAmount } = await (0, _collaterals.getMaxWithdrawal)(user.address, f.Collateral);\n(0, _chai.expect)(maxWithdrawAmount.gt(0)).to.be.true;\nawait Receiver.test(f.Collateral.address, maxWithdrawAmount);\n(0, _chai.expect)((await Receiver.userData()).val).to.equal(maxWithdrawAmount);\n(0, _chai.expect)(await Receiver.withdrawalAmountRequested()).to.equal(maxWithdrawAmount);\n(0, _chai.expect)(await Receiver.withdrawalAmountReceived()).to.equal(maxWithdrawAmount);\n(0, _chai.expect)(await f.Collateral.contract.balanceOf(Receiver.address)).to.equal(maxWithdrawAmount);\n(0, _chai.expect)(await hre.Diamond.getAccountCollateralRatio(user.address)).to.be.eq(1.5e4);\nawait (0, _chai.expect)(Receiver.test(f.Collateral.address, 10e15.toString())).to.be.reverted;",
- "err": {},
- "uuid": "b4e08c8c-ad9a-4845-aa78-cf9e7f7f4c90",
- "parentUUID": "af124919-f626-43e2-8799-75923dea9e69",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should be able to withdraw full collateral and return it",
- "fullTitle": "CollateralReceiver - UncheckedCollateralWithdraw #unchecked-collateral-withdrawal #unchecked-withdraw should be able to withdraw full collateral and return it",
- "timedOut": false,
- "duration": 226,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const Receiver = f.Receiver;\nconst deposits = await _optimizations.default.getAccountCollateralAmount(user.address, f.Collateral.address);\n(0, _chai.expect)(deposits.gt(0)).to.be.true;\nconst balKreskoBefore = await f.Collateral.balanceOf(hre.Diamond.address);\nawait Receiver.testRedeposit(f.Collateral.address, deposits);\n(0, _chai.expect)(await Receiver.withdrawalAmountRequested()).to.equal(deposits);\n(0, _chai.expect)(await Receiver.withdrawalAmountReceived()).to.equal(deposits);\n(0, _chai.expect)(await f.Collateral.balanceOf(Receiver.address)).to.equal(0);\nconst balKreskoAfter = await f.Collateral.balanceOf(hre.Diamond.address);\n(0, _chai.expect)(balKreskoBefore).to.equal(balKreskoAfter);",
- "err": {},
- "uuid": "8d91b34c-2d6c-4f34-b985-47a52d010c2a",
- "parentUUID": "af124919-f626-43e2-8799-75923dea9e69",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should be able to withdraw full collateral and deposit another asset in its place",
- "fullTitle": "CollateralReceiver - UncheckedCollateralWithdraw #unchecked-collateral-withdrawal #unchecked-withdraw should be able to withdraw full collateral and deposit another asset in its place",
- "timedOut": false,
- "duration": 278,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const Receiver = f.Receiver;\nconst deposits = await _optimizations.default.getAccountCollateralAmount(user.address, f.Collateral.address);\n(0, _chai.expect)(deposits.gt(0)).to.be.true;\n// set second collateral price to half of the first and balance to twice that\nf.Collateral2.setPrice(10);\nawait f.Collateral2.setBalance(user, f.depositAmount);\nawait f.Collateral2.contract.setVariable('_allowances', {\n [user.address]: {\n [hre.Diamond.address]: f.depositAmount,\n [Receiver.address]: f.depositAmount\n }\n});\nawait Receiver.testDepositAlternate(f.Collateral.address, deposits, f.Collateral2.address);\nconst secondCollateralDeposits = await _optimizations.default.getAccountCollateralAmount(user.address, f.Collateral2.address);\n(0, _chai.expect)(secondCollateralDeposits.eq(deposits)).to.be.true;",
- "err": {},
- "uuid": "5eb0a8b3-8e44-457c-98d2-11a3fd780da2",
- "parentUUID": "af124919-f626-43e2-8799-75923dea9e69",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "6466dce0-b1ce-42ac-95aa-2972061c6742",
- "7909766f-3452-40e0-8761-5ba6a762b3c3",
- "b4e08c8c-ad9a-4845-aa78-cf9e7f7f4c90",
- "8d91b34c-2d6c-4f34-b985-47a52d010c2a",
- "5eb0a8b3-8e44-457c-98d2-11a3fd780da2"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 1533,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "b278a207-f69d-48de-9ef6-4b14068a6d8e",
- "title": "#unchecked-withdraw-reverts",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/05-collateral-receiver.ts",
- "file": "/src/test/minter/05-collateral-receiver.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "should revert on zero withdrawal",
- "fullTitle": "CollateralReceiver - UncheckedCollateralWithdraw #unchecked-collateral-withdrawal #unchecked-withdraw-reverts should revert on zero withdrawal",
- "timedOut": false,
- "duration": 157,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await (0, _chai.expect)(f.Receiver.test(f.Collateral.address, 0)).to.be.reverted;\n // await expect(f.Receiver.test(f.Collateral.address, 0)).to.be.revertedWith(Error.ZERO_WITHDRAW);",
- "err": {},
- "uuid": "74637804-de97-4b4d-a8dc-0fb6f383289e",
- "parentUUID": "b278a207-f69d-48de-9ef6-4b14068a6d8e",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should revert with no manager role",
- "fullTitle": "CollateralReceiver - UncheckedCollateralWithdraw #unchecked-collateral-withdrawal #unchecked-withdraw-reverts should revert with no manager role",
- "timedOut": false,
- "duration": 124,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await hre.Diamond.revokeRole(_roles.Role.MANAGER, f.Receiver.address);\nawait (0, _chai.expect)(f.Receiver.test(f.Collateral.address, 10000)).to.be.reverted;\n // await expect(f.Receiver.test(f.Collateral.address, 10000)).to.be.revertedWith(\n // `AccessControl: account ${f.Receiver.address.toLowerCase()} is missing role 0x46925e0f0cc76e485772167edccb8dc449d43b23b55fc4e756b063f49099e6a0`,\n // );",
- "err": {},
- "uuid": "8e52f03a-e917-4841-9ce8-c3e96309a932",
- "parentUUID": "b278a207-f69d-48de-9ef6-4b14068a6d8e",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should revert if under MCR after withdrawal",
- "fullTitle": "CollateralReceiver - UncheckedCollateralWithdraw #unchecked-collateral-withdrawal #unchecked-withdraw-reverts should revert if under MCR after withdrawal",
- "timedOut": false,
- "duration": 350,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const { maxWithdrawAmount } = await (0, _collaterals.getMaxWithdrawal)(user.address, f.Collateral);\n(0, _chai.expect)(maxWithdrawAmount.gt(0)).to.be.true;\nawait (0, _chai.expect)(f.Receiver.test(f.Collateral.address, maxWithdrawAmount.add(0.5e18.toString()))).to.be.reverted;",
- "err": {},
- "uuid": "eecaf7e2-a7fd-4c43-91aa-a13d96248777",
- "parentUUID": "b278a207-f69d-48de-9ef6-4b14068a6d8e",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should revert if under MCR after redeposit",
- "fullTitle": "CollateralReceiver - UncheckedCollateralWithdraw #unchecked-collateral-withdrawal #unchecked-withdraw-reverts should revert if under MCR after redeposit",
- "timedOut": false,
- "duration": 592,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const Receiver = f.Receiver;\nconst { maxWithdrawAmount } = await (0, _collaterals.getMaxWithdrawal)(user.address, f.Collateral);\n(0, _chai.expect)(maxWithdrawAmount.gt(0)).to.be.true;\nawait (0, _chai.expect)(Receiver.testInsufficientRedeposit(f.Collateral.address, maxWithdrawAmount.add(0.5e18.toString()))).to.be.reverted;",
- "err": {},
- "uuid": "fa185bb7-1931-419c-8457-576c810c91fb",
- "parentUUID": "b278a207-f69d-48de-9ef6-4b14068a6d8e",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "74637804-de97-4b4d-a8dc-0fb6f383289e",
- "8e52f03a-e917-4841-9ce8-c3e96309a932",
- "eecaf7e2-a7fd-4c43-91aa-a13d96248777",
- "fa185bb7-1931-419c-8457-576c810c91fb"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 1223,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "94763d29-8b4e-4bfa-bb22-66f2947136b4",
- "title": "Gating",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/minter/06-gating.ts",
- "file": "/src/test/minter/06-gating.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"Gating\"",
- "fullTitle": "Gating \"before each\" hook in \"Gating\"",
- "timedOut": false,
- "duration": 106,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "f = await (0, _fixtures.defaultFixture)();\n// Set Gating phase to 3\nawait hre.Diamond.setGatingPhase(2);\n// setup collateral for userOne and userTwo\nthis.initialBalance = (0, _values.toBig)(100000);\nawait f.Collateral.setBalance(hre.users.userOne, this.initialBalance, hre.Diamond.address);\nawait f.Collateral.setBalance(hre.users.userTwo, this.initialBalance, hre.Diamond.address);\nthis.depositArgsOne = {\n user: hre.users.userOne,\n asset: f.Collateral,\n amount: (0, _values.toBig)(10000)\n};\nthis.depositArgsTwo = {\n user: hre.users.userTwo,\n asset: f.Collateral,\n amount: (0, _values.toBig)(10000)\n};\n[this.nft] = await hre.deploy('MockERC1155', {\n args: [],\n from: hre.users.deployer.address\n});\nawait hre.Diamond.setKreskianCollection(this.nft.address);",
- "err": {},
- "uuid": "b623ac6d-0a77-4d31-a258-a21a0e103a84",
- "parentUUID": "94763d29-8b4e-4bfa-bb22-66f2947136b4",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [
- {
- "title": "should not allow to deposit collateral if the user doesn't have required nft's",
- "fullTitle": "Gating should not allow to deposit collateral if the user doesn't have required nft's",
- "timedOut": false,
- "duration": 50,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await (0, _chai.expect)((0, _general.wrapContractWithSigner)(hre.Diamond, this.depositArgsOne.user).depositCollateral(this.depositArgsOne.user.address, f.Collateral.address, this.depositArgsOne.amount)).to.be.reverted;",
- "err": {},
- "uuid": "6041e774-84d3-4715-a0b9-24b863fcf08e",
- "parentUUID": "94763d29-8b4e-4bfa-bb22-66f2947136b4",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should allow to deposit collateral if the user has the required nft's",
- "fullTitle": "Gating should allow to deposit collateral if the user has the required nft's",
- "timedOut": false,
- "duration": 60,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await this.nft.safeTransferFrom(hre.users.deployer.address, this.depositArgsOne.user.address, 0, 1, '0x00');\nawait (0, _chai.expect)((0, _general.wrapContractWithSigner)(hre.Diamond, this.depositArgsOne.user).depositCollateral(this.depositArgsOne.user.address, f.Collateral.address, this.depositArgsOne.amount)).not.to.be.reverted;",
- "err": {},
- "uuid": "200c24cb-0a0b-4508-aaed-016b871b711d",
- "parentUUID": "94763d29-8b4e-4bfa-bb22-66f2947136b4",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "After all the phases anyone should be able to deposit collateral",
- "fullTitle": "Gating After all the phases anyone should be able to deposit collateral",
- "timedOut": false,
- "duration": 92,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await hre.Diamond.setGatingPhase(3);\n// Anyone should be able to deposit collateral\nawait (0, _chai.expect)((0, _general.wrapContractWithSigner)(hre.Diamond, this.depositArgsTwo.user).depositCollateral(this.depositArgsTwo.user.address, f.Collateral.address, this.depositArgsTwo.amount)).not.to.be.reverted;",
- "err": {},
- "uuid": "51420d59-5254-40c3-963f-02099d99cd09",
- "parentUUID": "94763d29-8b4e-4bfa-bb22-66f2947136b4",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "6041e774-84d3-4715-a0b9-24b863fcf08e",
- "200c24cb-0a0b-4508-aaed-016b871b711d",
- "51420d59-5254-40c3-963f-02099d99cd09"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 202,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "c5a0371f-8b61-419d-879d-4365c08bc9e5",
- "title": "Oracles",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/oracle/00-oracles.ts",
- "file": "/src/test/oracle/00-oracles.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"Oracles\"",
- "fullTitle": "Oracles \"before each\" hook in \"Oracles\"",
- "timedOut": false,
- "duration": 1,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "f = await (0, _fixtures.defaultFixture)();\n[, [user]] = f.users;\nthis.deployer = await hre.ethers.getNamedSigner('deployer');\nthis.userOne = await hre.ethers.getNamedSigner('userOne');\nf.Collateral.setPrice(10);",
- "err": {},
- "uuid": "0f91d1a2-7e9b-4f50-b204-764b1babac48",
- "parentUUID": "c5a0371f-8b61-419d-879d-4365c08bc9e5",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [],
- "suites": [
- {
- "uuid": "c3dd96b8-4883-4766-b118-61de041f8a58",
- "title": "Redstone",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/oracle/00-oracles.ts",
- "file": "/src/test/oracle/00-oracles.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "should have correct setup",
- "fullTitle": "Oracles Redstone should have correct setup",
- "timedOut": false,
- "duration": 73,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "// check initial conditions\n(0, _chai.expect)(await hre.Diamond.getAccountTotalCollateralValue(user.address)).to.equal((0, _values.toBig)(10000, 8), 'collateral value should be $10');",
- "err": {},
- "uuid": "cdaef8f7-a673-49f6-be45-5a06ed75ab14",
- "parentUUID": "c3dd96b8-4883-4766-b118-61de041f8a58",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should get redstone price when chainlink price = 0",
- "fullTitle": "Oracles Redstone should get redstone price when chainlink price = 0",
- "timedOut": false,
- "duration": 159,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "/// set chainlink price to 0\nf.Collateral.setPrice(0);\nconst redstoneCollateralPrice = 20;\nconst redstoneDiamond = (0, _redstone.wrapPrices)(hre.Diamond, [\n {\n dataFeedId: _mocks.testCollateralConfig.ticker,\n value: redstoneCollateralPrice\n }\n]);\n(0, _chai.expect)(await redstoneDiamond.getAccountTotalCollateralValue(user.address)).to.equal(f.depositAmount.wadMul((0, _values.toBig)(redstoneCollateralPrice, 8)), 'collateral value should be $20');",
- "err": {},
- "uuid": "f1687eb2-52ea-4f67-9ee3-25275b64cf29",
- "parentUUID": "c3dd96b8-4883-4766-b118-61de041f8a58",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should get primary price when price +- maxPriceDeviationPct of reference price ",
- "fullTitle": "Oracles Redstone should get primary price when price +- maxPriceDeviationPct of reference price ",
- "timedOut": false,
- "duration": 161,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await f.Collateral.setOracleOrder([\n _types.OracleType.Redstone,\n _types.OracleType.Chainlink\n]);\n/// set chainlink price to 12\nf.Collateral.setPrice(12);\n/// set redstone price to 11\nconst redstoneCollateralPrice = 11;\nconst redstoneDiamond = (0, _redstone.wrapPrices)(hre.Diamond, [\n {\n dataFeedId: _mocks.testCollateralConfig.ticker,\n value: redstoneCollateralPrice\n }\n]);\n(0, _chai.expect)(await redstoneDiamond.getAccountTotalCollateralValue(user.address)).to.equal(f.depositAmount.wadMul((0, _values.toBig)(redstoneCollateralPrice, 8)), 'collateral value should be $11');",
- "err": {},
- "uuid": "e2977710-9a9e-434c-95ec-50d407be78ba",
- "parentUUID": "c3dd96b8-4883-4766-b118-61de041f8a58",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should revert if price deviates too much",
- "fullTitle": "Oracles Redstone should revert if price deviates too much",
- "timedOut": false,
- "duration": 60,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "/// set chainlink price to 20\nf.Collateral.setPrice(20);\nconst redstoneCollateralPrice = 10;\nconst redstoneDiamond = (0, _redstone.wrapPrices)(hre.Diamond, [\n {\n dataFeedId: _mocks.testCollateralConfig.ticker,\n value: redstoneCollateralPrice\n }\n]);\n// should revert if price deviates more than maxPriceDeviationPct\nawait (0, _chai.expect)(redstoneDiamond.getAccountTotalCollateralValue(user.address)).to.be.reverted;\nf.Collateral.setPrice(10);",
- "err": {},
- "uuid": "0ae7c1ce-0182-4a52-b309-c34f96fb6150",
- "parentUUID": "c3dd96b8-4883-4766-b118-61de041f8a58",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should return redstone price if sequencer is down",
- "fullTitle": "Oracles Redstone should return redstone price if sequencer is down",
- "timedOut": false,
- "duration": 161,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "/// set chainlink price to 5\nf.Collateral.setPrice(5);\nconst redstoneCollateralPrice = 200;\nconst redstoneDiamond = (0, _redstone.wrapPrices)(hre.Diamond, [\n ..._redstone.defaultRedstoneDataPoints.map((p)=>p.value === 0 ? {\n ...p,\n value: 1\n } : p),\n {\n dataFeedId: _mocks.testCollateralConfig.ticker,\n value: redstoneCollateralPrice\n }\n]);\nawait (await hre.getContractOrFork('MockSequencerUptimeFeed')).setAnswer(1);\n// should return redstone price if sequencer is down\n(0, _chai.expect)(await redstoneDiamond.getAccountTotalCollateralValue(user.address)).to.be.equal(f.depositAmount.wadMul((0, _values.toBig)(redstoneCollateralPrice, 8)), 'collateral value should be $200');\nf.Collateral.setPrice(10);\nawait (await hre.getContractOrFork('MockSequencerUptimeFeed')).setAnswer(0);",
- "err": {},
- "uuid": "4dadb50a-e094-4246-a3e0-deb3cae59385",
- "parentUUID": "c3dd96b8-4883-4766-b118-61de041f8a58",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "cdaef8f7-a673-49f6-be45-5a06ed75ab14",
- "f1687eb2-52ea-4f67-9ee3-25275b64cf29",
- "e2977710-9a9e-434c-95ec-50d407be78ba",
- "0ae7c1ce-0182-4a52-b309-c34f96fb6150",
- "4dadb50a-e094-4246-a3e0-deb3cae59385"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 614,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "4bb4c1cb-783f-4181-a02c-17a080525eff",
- "title": "Safety Council",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/safety/00-council.ts",
- "file": "/src/test/safety/00-council.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"Safety Council\"",
- "fullTitle": "Safety Council \"before each\" hook in \"Safety Council\"",
- "timedOut": false,
- "duration": 4,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "f = await (0, _fixtures.defaultFixture)();\n// These are the 5 signers on the SafetyCouncil multisig\nconst { deployer, devOne, userOne, extOne, extTwo } = await hre.ethers.getNamedSigners();\nthis.deployer = deployer;\nthis.devOne = devOne;\nthis.userOne = userOne;\nthis.extOne = extOne;\nthis.extTwo = extTwo;",
- "err": {},
- "uuid": "2332a1b4-e89c-40e7-bcd5-ea854bd16d7e",
- "parentUUID": "4bb4c1cb-783f-4181-a02c-17a080525eff",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [],
- "suites": [
- {
- "uuid": "6fb5e459-b3b2-4872-866b-d9220a639ba6",
- "title": "#setSafetyStateSet",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/safety/00-council.ts",
- "file": "/src/test/safety/00-council.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "correctly sets the safety state",
- "fullTitle": "Safety Council #setSafetyStateSet correctly sets the safety state",
- "timedOut": false,
- "duration": 92,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const beforeSafetyState = await hre.Diamond.safetyStateSet();\n(0, _chai.expect)(beforeSafetyState).to.equal(false);\nawait (0, _execution.executeContractCallWithSigners)(hre.Multisig, hre.Diamond, 'setSafetyStateSet', [\n true\n], [\n this.deployer,\n this.devOne,\n this.userOne\n]);\nconst safetyState = await hre.Diamond.safetyStateSet();\n(0, _chai.expect)(safetyState).to.equal(true);",
- "err": {},
- "uuid": "ccf8e487-b472-4f60-97be-db22d40bfdbc",
- "parentUUID": "6fb5e459-b3b2-4872-866b-d9220a639ba6",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "ccf8e487-b472-4f60-97be-db22d40bfdbc"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 92,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "b59e607e-d40b-4afd-aff7-427bdc815dc3",
- "title": "#toggleAssetsPaused",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/safety/00-council.ts",
- "file": "/src/test/safety/00-council.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [],
- "suites": [
- {
- "uuid": "81f10570-278c-4eaf-8a84-a7a05b06e7dc",
- "title": "multisig signature threshold",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/safety/00-council.ts",
- "file": "/src/test/safety/00-council.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "multisig transacts successfully with majority of signers (3/5)",
- "fullTitle": "Safety Council #toggleAssetsPaused multisig signature threshold multisig transacts successfully with majority of signers (3/5)",
- "timedOut": false,
- "duration": 57,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await (0, _execution.executeContractCallWithSigners)(hre.Multisig, hre.Diamond, 'toggleAssetsPaused', [\n [\n f.Collateral.address\n ],\n _types.Action.DEPOSIT,\n false,\n 0\n], [\n this.deployer,\n this.devOne,\n this.userOne\n]);\nconst isPaused = await hre.Diamond.assetActionPaused(_types.Action.DEPOSIT.toString(), f.Collateral.address);\n(0, _chai.expect)(isPaused).to.equal(true);",
- "err": {},
- "uuid": "9427c3a4-8fe6-4072-ae0c-65d6d3ca9600",
- "parentUUID": "81f10570-278c-4eaf-8a84-a7a05b06e7dc",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "multisig transacts successfully with super-majority of signers (4/5)",
- "fullTitle": "Safety Council #toggleAssetsPaused multisig signature threshold multisig transacts successfully with super-majority of signers (4/5)",
- "timedOut": false,
- "duration": 60,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await (0, _execution.executeContractCallWithSigners)(hre.Multisig, hre.Diamond, 'toggleAssetsPaused', [\n [\n f.Collateral.address\n ],\n _types.Action.DEPOSIT,\n false,\n 0\n], [\n this.deployer,\n this.devOne,\n this.userOne,\n this.extOne\n]);\nconst isPaused = await hre.Diamond.assetActionPaused(_types.Action.DEPOSIT.toString(), f.Collateral.address);\n(0, _chai.expect)(isPaused).to.equal(true);",
- "err": {},
- "uuid": "e05f4aa6-8978-4fe2-9df9-2270d77f8e75",
- "parentUUID": "81f10570-278c-4eaf-8a84-a7a05b06e7dc",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "multisig transacts successfully with all signers (5/5)",
- "fullTitle": "Safety Council #toggleAssetsPaused multisig signature threshold multisig transacts successfully with all signers (5/5)",
- "timedOut": false,
- "duration": 61,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await (0, _execution.executeContractCallWithSigners)(hre.Multisig, hre.Diamond, 'toggleAssetsPaused', [\n [\n f.Collateral.address\n ],\n _types.Action.DEPOSIT,\n false,\n 0\n], [\n this.deployer,\n this.devOne,\n this.userOne,\n this.extOne,\n this.extTwo\n]);\nconst isPaused = await hre.Diamond.assetActionPaused(_types.Action.DEPOSIT.toString(), f.Collateral.address);\n(0, _chai.expect)(isPaused).to.equal(true);",
- "err": {},
- "uuid": "8b12b9c6-9ee6-4907-9f08-09c3a2463ca9",
- "parentUUID": "81f10570-278c-4eaf-8a84-a7a05b06e7dc",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "multisig should reject transactions signed by a minority of signers (2/5)",
- "fullTitle": "Safety Council #toggleAssetsPaused multisig signature threshold multisig should reject transactions signed by a minority of signers (2/5)",
- "timedOut": false,
- "duration": 48,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await (0, _chai.expect)((0, _execution.executeContractCallWithSigners)(hre.Multisig, hre.Diamond, 'toggleAssetsPaused', [\n [\n f.Collateral.address\n ],\n _types.Action.DEPOSIT,\n false,\n 0\n], [\n this.deployer\n])).to.be.reverted;\nconst isPaused = await hre.Diamond.assetActionPaused(_types.Action.DEPOSIT.toString(), f.Collateral.address);\n(0, _chai.expect)(isPaused).to.equal(false);",
- "err": {},
- "uuid": "29f63aca-2b9e-4902-a53c-e7a8784d7401",
- "parentUUID": "81f10570-278c-4eaf-8a84-a7a05b06e7dc",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "9427c3a4-8fe6-4072-ae0c-65d6d3ca9600",
- "e05f4aa6-8978-4fe2-9df9-2270d77f8e75",
- "8b12b9c6-9ee6-4907-9f08-09c3a2463ca9",
- "29f63aca-2b9e-4902-a53c-e7a8784d7401"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 226,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "da86b20e-e28c-4020-aee8-36844790e52e",
- "title": "toggle actions only for listed assets",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/safety/00-council.ts",
- "file": "/src/test/safety/00-council.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "can toggle actions for listed collateral assets",
- "fullTitle": "Safety Council #toggleAssetsPaused toggle actions only for listed assets can toggle actions for listed collateral assets",
- "timedOut": false,
- "duration": 59,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await (0, _execution.executeContractCallWithSigners)(hre.Multisig, hre.Diamond, 'toggleAssetsPaused', [\n [\n f.Collateral.address\n ],\n _types.Action.DEPOSIT,\n false,\n 0\n], [\n this.deployer,\n this.devOne,\n this.userOne\n]);\nconst isPaused = await hre.Diamond.assetActionPaused(_types.Action.DEPOSIT.toString(), f.Collateral.address);\n(0, _chai.expect)(isPaused).to.equal(true);",
- "err": {},
- "uuid": "4b3d094e-ed48-4578-a8af-2dd50ce6fe5a",
- "parentUUID": "da86b20e-e28c-4020-aee8-36844790e52e",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "can toggle actions for listed krAssets",
- "fullTitle": "Safety Council #toggleAssetsPaused toggle actions only for listed assets can toggle actions for listed krAssets",
- "timedOut": false,
- "duration": 61,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await (0, _execution.executeContractCallWithSigners)(hre.Multisig, hre.Diamond, 'toggleAssetsPaused', [\n [\n f.KrAsset.address\n ],\n _types.Action.REPAY,\n false,\n 0\n], [\n this.deployer,\n this.devOne,\n this.userOne\n]);\nconst isPaused = await hre.Diamond.assetActionPaused(_types.Action.REPAY.toString(), f.KrAsset.address);\n(0, _chai.expect)(isPaused).to.equal(true);",
- "err": {},
- "uuid": "81ab48e7-5ade-4697-b1c7-0836ea4a3fcf",
- "parentUUID": "da86b20e-e28c-4020-aee8-36844790e52e",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "cannot toggle actions for addresses that are not listed collateral assets or krAssets",
- "fullTitle": "Safety Council #toggleAssetsPaused toggle actions only for listed assets cannot toggle actions for addresses that are not listed collateral assets or krAssets",
- "timedOut": false,
- "duration": 57,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const randomAddr = hre.ethers.utils.computeAddress('0xb976778317b23a1285ec2d483eda6904d9319135b89f1d8eee9f6d2593e2665d');\nawait (0, _chai.expect)((0, _execution.executeContractCallWithSigners)(hre.Multisig, hre.Diamond, 'toggleAssetsPaused', [\n [\n randomAddr\n ],\n _types.Action.DEPOSIT,\n false,\n 0\n], [\n this.deployer,\n this.devOne,\n this.userOne\n])).to.be.reverted;\nconst isPaused = await hre.Diamond.assetActionPaused(_types.Action.DEPOSIT.toString(), randomAddr);\n(0, _chai.expect)(isPaused).to.equal(false);",
- "err": {},
- "uuid": "1aaf8083-1445-4fb9-8b9a-4dda3f17514e",
- "parentUUID": "da86b20e-e28c-4020-aee8-36844790e52e",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "4b3d094e-ed48-4578-a8af-2dd50ce6fe5a",
- "81ab48e7-5ade-4697-b1c7-0836ea4a3fcf",
- "1aaf8083-1445-4fb9-8b9a-4dda3f17514e"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 177,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "65948fd5-fcf3-4e71-b92c-cb84286dca87",
- "title": "duration based pausing",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/safety/00-council.ts",
- "file": "/src/test/safety/00-council.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "can optionally set a timeout on a given pause command",
- "fullTitle": "Safety Council #toggleAssetsPaused duration based pausing can optionally set a timeout on a given pause command",
- "timedOut": false,
- "duration": 61,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const duration = 100000000;\nawait (0, _execution.executeContractCallWithSigners)(hre.Multisig, hre.Diamond, 'toggleAssetsPaused', [\n [\n f.Collateral.address\n ],\n _types.Action.DEPOSIT,\n true,\n duration\n], [\n this.deployer,\n this.devOne,\n this.userOne\n]);\nconst depositSafetyState = await hre.Diamond.safetyStateFor(f.Collateral.address, _types.Action.DEPOSIT);\n(0, _chai.expect)(depositSafetyState.length).to.equal(1);\n// Blocktime timestamp + duration should be equal to final timestamp\n(0, _chai.expect)(depositSafetyState[0].timestamp0.add(duration)).eq(depositSafetyState[0].timestamp1);",
- "err": {},
- "uuid": "f378d721-179b-45fc-b552-f53d835f42a6",
- "parentUUID": "65948fd5-fcf3-4e71-b92c-cb84286dca87",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "duration based pause functionality should expire after the duration has passed",
- "fullTitle": "Safety Council #toggleAssetsPaused duration based pausing duration based pause functionality should expire after the duration has passed",
- "timedOut": false,
- "duration": 0,
- "state": "pending",
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": true,
- "context": null,
- "code": "",
- "err": {},
- "uuid": "d25717a1-acf9-4577-8013-d1452e55058e",
- "parentUUID": "65948fd5-fcf3-4e71-b92c-cb84286dca87",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "f378d721-179b-45fc-b552-f53d835f42a6"
- ],
- "failures": [],
- "pending": [
- "d25717a1-acf9-4577-8013-d1452e55058e"
- ],
- "skipped": [],
- "duration": 61,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "38548b46-92dc-4b38-8566-6569ef837a7b",
- "title": "toggle all possible actions: DEPOSIT, WITHDRAW, REPAY, BORROW, LIQUIDATION",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/safety/00-council.ts",
- "file": "/src/test/safety/00-council.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "can toggle action DEPOSIT pause status on and off",
- "fullTitle": "Safety Council #toggleAssetsPaused toggle all possible actions: DEPOSIT, WITHDRAW, REPAY, BORROW, LIQUIDATION can toggle action DEPOSIT pause status on and off",
- "timedOut": false,
- "duration": 120,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await (0, _execution.executeContractCallWithSigners)(hre.Multisig, hre.Diamond, 'toggleAssetsPaused', [\n [\n f.Collateral.address\n ],\n _types.Action.DEPOSIT,\n false,\n 0\n], [\n this.deployer,\n this.devOne,\n this.extOne\n]);\nlet isPaused = await hre.Diamond.assetActionPaused(_types.Action.DEPOSIT.toString(), f.Collateral.address);\n(0, _chai.expect)(isPaused).to.equal(true);\nawait (0, _execution.executeContractCallWithSigners)(hre.Multisig, hre.Diamond, 'toggleAssetsPaused', [\n [\n f.Collateral.address\n ],\n _types.Action.DEPOSIT,\n false,\n 0\n], [\n this.deployer,\n this.devOne,\n this.extOne\n]);\nisPaused = await hre.Diamond.assetActionPaused(_types.Action.DEPOSIT.toString(), f.Collateral.address);\n(0, _chai.expect)(isPaused).to.equal(false);",
- "err": {},
- "uuid": "dd9cb750-4def-4dad-b7b0-38c46211099d",
- "parentUUID": "38548b46-92dc-4b38-8566-6569ef837a7b",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "can toggle action WITHDRAW pause status on and off",
- "fullTitle": "Safety Council #toggleAssetsPaused toggle all possible actions: DEPOSIT, WITHDRAW, REPAY, BORROW, LIQUIDATION can toggle action WITHDRAW pause status on and off",
- "timedOut": false,
- "duration": 118,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await (0, _execution.executeContractCallWithSigners)(hre.Multisig, hre.Diamond, 'toggleAssetsPaused', [\n [\n f.Collateral.address\n ],\n _types.Action.WITHDRAW,\n false,\n 0\n], [\n this.deployer,\n this.devOne,\n this.extOne\n]);\nlet isPaused = await hre.Diamond.assetActionPaused(_types.Action.WITHDRAW.toString(), f.Collateral.address);\n(0, _chai.expect)(isPaused).to.equal(true);\nawait (0, _execution.executeContractCallWithSigners)(hre.Multisig, hre.Diamond, 'toggleAssetsPaused', [\n [\n f.Collateral.address\n ],\n _types.Action.WITHDRAW,\n false,\n 0\n], [\n this.deployer,\n this.devOne,\n this.extOne\n]);\nisPaused = await hre.Diamond.assetActionPaused(_types.Action.WITHDRAW.toString(), f.Collateral.address);\n(0, _chai.expect)(isPaused).to.equal(false);",
- "err": {},
- "uuid": "c7415bf4-03c0-44c5-91ea-893ac4b095d7",
- "parentUUID": "38548b46-92dc-4b38-8566-6569ef837a7b",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "can toggle action REPAY pause status on and off",
- "fullTitle": "Safety Council #toggleAssetsPaused toggle all possible actions: DEPOSIT, WITHDRAW, REPAY, BORROW, LIQUIDATION can toggle action REPAY pause status on and off",
- "timedOut": false,
- "duration": 116,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await (0, _execution.executeContractCallWithSigners)(hre.Multisig, hre.Diamond, 'toggleAssetsPaused', [\n [\n f.Collateral.address\n ],\n _types.Action.REPAY,\n false,\n 0\n], [\n this.deployer,\n this.devOne,\n this.extOne\n]);\nlet isPaused = await hre.Diamond.assetActionPaused(_types.Action.REPAY.toString(), f.Collateral.address);\n(0, _chai.expect)(isPaused).to.equal(true);\nawait (0, _execution.executeContractCallWithSigners)(hre.Multisig, hre.Diamond, 'toggleAssetsPaused', [\n [\n f.Collateral.address\n ],\n _types.Action.REPAY,\n false,\n 0\n], [\n this.deployer,\n this.devOne,\n this.extOne\n]);\nisPaused = await hre.Diamond.assetActionPaused(_types.Action.REPAY.toString(), f.Collateral.address);\n(0, _chai.expect)(isPaused).to.equal(false);",
- "err": {},
- "uuid": "8bede125-498d-469d-ba21-598f780b5983",
- "parentUUID": "38548b46-92dc-4b38-8566-6569ef837a7b",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "can toggle action BORROW pause status on and off",
- "fullTitle": "Safety Council #toggleAssetsPaused toggle all possible actions: DEPOSIT, WITHDRAW, REPAY, BORROW, LIQUIDATION can toggle action BORROW pause status on and off",
- "timedOut": false,
- "duration": 118,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await (0, _execution.executeContractCallWithSigners)(hre.Multisig, hre.Diamond, 'toggleAssetsPaused', [\n [\n f.Collateral.address\n ],\n _types.Action.BORROW,\n false,\n 0\n], [\n this.deployer,\n this.devOne,\n this.extOne\n]);\nlet isPaused = await hre.Diamond.assetActionPaused(_types.Action.BORROW.toString(), f.Collateral.address);\n(0, _chai.expect)(isPaused).to.equal(true);\nawait (0, _execution.executeContractCallWithSigners)(hre.Multisig, hre.Diamond, 'toggleAssetsPaused', [\n [\n f.Collateral.address\n ],\n _types.Action.BORROW,\n false,\n 0\n], [\n this.deployer,\n this.devOne,\n this.extOne\n]);\nisPaused = await hre.Diamond.assetActionPaused(_types.Action.BORROW.toString(), f.Collateral.address);\n(0, _chai.expect)(isPaused).to.equal(false);",
- "err": {},
- "uuid": "d8cdb8bc-8bb3-4952-bc48-27e22c71eeca",
- "parentUUID": "38548b46-92dc-4b38-8566-6569ef837a7b",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "can toggle action LIQUIDATION pause status on and off",
- "fullTitle": "Safety Council #toggleAssetsPaused toggle all possible actions: DEPOSIT, WITHDRAW, REPAY, BORROW, LIQUIDATION can toggle action LIQUIDATION pause status on and off",
- "timedOut": false,
- "duration": 118,
- "state": "passed",
- "speed": "slow",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await (0, _execution.executeContractCallWithSigners)(hre.Multisig, hre.Diamond, 'toggleAssetsPaused', [\n [\n f.Collateral.address\n ],\n _types.Action.LIQUIDATION,\n false,\n 0\n], [\n this.deployer,\n this.devOne,\n this.extOne\n]);\nlet isPaused = await hre.Diamond.assetActionPaused(_types.Action.LIQUIDATION.toString(), f.Collateral.address);\n(0, _chai.expect)(isPaused).to.equal(true);\nawait (0, _execution.executeContractCallWithSigners)(hre.Multisig, hre.Diamond, 'toggleAssetsPaused', [\n [\n f.Collateral.address\n ],\n _types.Action.LIQUIDATION,\n false,\n 0\n], [\n this.deployer,\n this.devOne,\n this.extOne\n]);\nisPaused = await hre.Diamond.assetActionPaused(_types.Action.LIQUIDATION.toString(), f.Collateral.address);\n(0, _chai.expect)(isPaused).to.equal(false);",
- "err": {},
- "uuid": "fbe08986-8991-4a0c-a98f-5fd4e39b64d7",
- "parentUUID": "38548b46-92dc-4b38-8566-6569ef837a7b",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "dd9cb750-4def-4dad-b7b0-38c46211099d",
- "c7415bf4-03c0-44c5-91ea-893ac4b095d7",
- "8bede125-498d-469d-ba21-598f780b5983",
- "d8cdb8bc-8bb3-4952-bc48-27e22c71eeca",
- "fbe08986-8991-4a0c-a98f-5fd4e39b64d7"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 590,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "bf2f5347-4ae8-43da-987c-5505a1d4fa45",
- "title": "event emission",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/safety/00-council.ts",
- "file": "/src/test/safety/00-council.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "should emit event MinterEvent.SafetyStateChange on action changed containing action, asset, and description",
- "fullTitle": "Safety Council #toggleAssetsPaused event emission should emit event MinterEvent.SafetyStateChange on action changed containing action, asset, and description",
- "timedOut": false,
- "duration": 28,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const tx = await (0, _execution.executeContractCallWithSigners)(hre.Multisig, hre.Diamond, 'toggleAssetsPaused', [\n [\n f.Collateral.address\n ],\n _types.Action.DEPOSIT,\n false,\n 0\n], [\n this.deployer,\n this.devOne,\n this.extOne\n]);\nconst event = await (0, _events.getInternalEvent)(tx, hre.Diamond, 'SafetyStateChange');\n(0, _chai.expect)(event.action).to.equal(_types.Action.DEPOSIT);\n(0, _chai.expect)(event.asset).to.equal(f.Collateral.address);\n(0, _chai.expect)(event.description).to.equal('paused');",
- "err": {},
- "uuid": "98a2fa1d-4cd8-4549-ad93-42e1b53cc798",
- "parentUUID": "bf2f5347-4ae8-43da-987c-5505a1d4fa45",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "98a2fa1d-4cd8-4549-ad93-42e1b53cc798"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 28,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- }
- ],
- "passes": [],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 0,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "a8935174-f80c-40ca-ae6b-3e2c3765065a",
- "title": "SCDP",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/scdp/00-scdp.ts",
- "file": "/src/test/scdp/00-scdp.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"SCDP\"",
- "fullTitle": "SCDP \"before each\" hook in \"SCDP\"",
- "timedOut": false,
- "duration": 2,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "f = await (0, _fixtures.scdpFixture)();\nawait f.reset();",
- "err": {},
- "uuid": "388ef12b-786b-4c99-8654-a65f315b12ee",
- "parentUUID": "a8935174-f80c-40ca-ae6b-3e2c3765065a",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [],
- "suites": [
- {
- "uuid": "c2240cc3-54b9-4557-bec8-b784aeeb4a31",
- "title": "#Configuration",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/scdp/00-scdp.ts",
- "file": "/src/test/scdp/00-scdp.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "should be initialized correctly",
- "fullTitle": "SCDP #Configuration should be initialized correctly",
- "timedOut": false,
- "duration": 323,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const { args } = await (0, _deploy.getSCDPInitializer)(hre);\nconst configuration = await hre.Diamond.getParametersSCDP();\n(0, _chai.expect)(configuration.liquidationThreshold).to.equal(args.liquidationThreshold);\n(0, _chai.expect)(configuration.minCollateralRatio).to.equal(args.minCollateralRatio);\n(0, _chai.expect)(configuration.maxLiquidationRatio).to.equal(Number(args.liquidationThreshold) + 0.01e4);\nconst collaterals = await hre.Diamond.getCollateralsSCDP();\n(0, _chai.expect)(collaterals).to.include.members([\n f.Collateral.address,\n f.Collateral8Dec.address,\n f.KrAsset.address,\n f.KrAsset2.address,\n f.KISS.address\n]);\nconst krAssets = await hre.Diamond.getKreskoAssetsSCDP();\n(0, _chai.expect)(krAssets).to.include.members([\n f.KrAsset.address,\n f.KrAsset2.address,\n f.KISS.address\n]);\nconst depositsEnabled = await Promise.all([\n hre.Diamond.getDepositEnabledSCDP(f.Collateral.address),\n hre.Diamond.getDepositEnabledSCDP(f.Collateral8Dec.address),\n hre.Diamond.getDepositEnabledSCDP(f.KrAsset.address),\n hre.Diamond.getDepositEnabledSCDP(f.KrAsset2.address),\n hre.Diamond.getDepositEnabledSCDP(f.KISS.address)\n]);\n(0, _chai.expect)(depositsEnabled).to.deep.equal([\n true,\n true,\n false,\n false,\n true\n]);\nconst depositAssets = await hre.Diamond.getDepositAssetsSCDP();\n(0, _chai.expect)(depositAssets).to.include.members([\n f.Collateral.address,\n f.Collateral8Dec.address,\n f.KISS.address\n]);",
- "err": {},
- "uuid": "30aac3d5-0278-45b2-b531-6e0c197a43b3",
- "parentUUID": "c2240cc3-54b9-4557-bec8-b784aeeb4a31",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should be able to whitelist new deposit asset",
- "fullTitle": "SCDP #Configuration should be able to whitelist new deposit asset",
- "timedOut": false,
- "duration": 222,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const assetInfoBefore = await hre.Diamond.getAsset(f.KrAsset2.address);\n(0, _chai.expect)(assetInfoBefore.isSharedCollateral).to.equal(false);\nawait hre.Diamond.updateAsset(f.KrAsset2.address, {\n ...assetInfoBefore,\n isSharedCollateral: true,\n depositLimitSCDP: 1\n});\nconst assetInfoAfter = await hre.Diamond.getAsset(f.KrAsset2.address);\n(0, _chai.expect)(assetInfoAfter.decimals).to.equal(await f.KrAsset2.contract.decimals());\n(0, _chai.expect)(assetInfoAfter.depositLimitSCDP).to.equal(1);\nconst indicesAfter = await hre.Diamond.getAssetIndexesSCDP(f.KrAsset2.address);\n(0, _chai.expect)(indicesAfter.currLiqIndex).to.equal(_values.RAY);\n(0, _chai.expect)(indicesAfter.currFeeIndex).to.equal(_values.RAY);\n(0, _chai.expect)(await hre.Diamond.getDepositEnabledSCDP(f.KrAsset2.address)).to.equal(true);",
- "err": {},
- "uuid": "79b5c634-d992-488d-9a53-af7b10934aa2",
- "parentUUID": "c2240cc3-54b9-4557-bec8-b784aeeb4a31",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should be able to update deposit limit of asset",
- "fullTitle": "SCDP #Configuration should be able to update deposit limit of asset",
- "timedOut": false,
- "duration": 116,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await hre.Diamond.setDepositLimitSCDP(f.Collateral.address, 1);\nconst collateral = await hre.Diamond.getAsset(f.Collateral.address);\n(0, _chai.expect)(collateral.decimals).to.equal(await f.Collateral.contract.decimals());\n(0, _chai.expect)(collateral.depositLimitSCDP).to.equal(1);\nconst indicesAfter = await hre.Diamond.getAssetIndexesSCDP(f.Collateral.address);\n(0, _chai.expect)(indicesAfter.currLiqIndex).to.equal(_values.RAY);\n(0, _chai.expect)(indicesAfter.currFeeIndex).to.equal(_values.RAY);",
- "err": {},
- "uuid": "e0592118-dbf5-4419-8f5f-4152d541651b",
- "parentUUID": "c2240cc3-54b9-4557-bec8-b784aeeb4a31",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should be able to disable a deposit asset",
- "fullTitle": "SCDP #Configuration should be able to disable a deposit asset",
- "timedOut": false,
- "duration": 147,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await hre.Diamond.setAssetIsSharedCollateralSCDP(f.Collateral.address, false);\nconst collaterals = await hre.Diamond.getCollateralsSCDP();\n(0, _chai.expect)(collaterals).to.include(f.Collateral.address);\nconst depositAssets = await hre.Diamond.getDepositAssetsSCDP();\n(0, _chai.expect)(depositAssets).to.not.include(f.Collateral.address);\n(0, _chai.expect)(await hre.Diamond.getDepositEnabledSCDP(f.Collateral.address)).to.equal(false);",
- "err": {},
- "uuid": "3bed0542-8c64-4b44-b5a4-6570d291da83",
- "parentUUID": "c2240cc3-54b9-4557-bec8-b784aeeb4a31",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should be able to disable and enable a collateral asset",
- "fullTitle": "SCDP #Configuration should be able to disable and enable a collateral asset",
- "timedOut": false,
- "duration": 480,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await hre.Diamond.setAssetIsSharedOrSwappedCollateralSCDP(f.Collateral.address, false);\n(0, _chai.expect)(await hre.Diamond.getCollateralsSCDP()).to.not.include(f.Collateral.address);\n(0, _chai.expect)(await hre.Diamond.getDepositAssetsSCDP()).to.not.include(f.Collateral.address);\n(0, _chai.expect)(await hre.Diamond.getDepositEnabledSCDP(f.Collateral.address)).to.equal(true);\nawait hre.Diamond.setAssetIsSharedCollateralSCDP(f.Collateral.address, false);\n(0, _chai.expect)(await hre.Diamond.getDepositEnabledSCDP(f.Collateral.address)).to.equal(false);\nawait hre.Diamond.setAssetIsSharedOrSwappedCollateralSCDP(f.Collateral.address, true);\n(0, _chai.expect)(await hre.Diamond.getCollateralsSCDP()).to.include(f.Collateral.address);\n(0, _chai.expect)(await hre.Diamond.getDepositAssetsSCDP()).to.not.include(f.Collateral.address);\n(0, _chai.expect)(await hre.Diamond.getDepositEnabledSCDP(f.Collateral.address)).to.equal(false);\nawait hre.Diamond.setAssetIsSharedCollateralSCDP(f.Collateral.address, true);\n(0, _chai.expect)(await hre.Diamond.getDepositEnabledSCDP(f.Collateral.address)).to.equal(true);\n(0, _chai.expect)(await hre.Diamond.getDepositAssetsSCDP()).to.include(f.Collateral.address);",
- "err": {},
- "uuid": "be15a86b-8c71-47e7-ae23-8e1f9789b4f5",
- "parentUUID": "c2240cc3-54b9-4557-bec8-b784aeeb4a31",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should be able to add whitelisted kresko asset",
- "fullTitle": "SCDP #Configuration should be able to add whitelisted kresko asset",
- "timedOut": false,
- "duration": 41,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const assetInfo = await hre.Diamond.getAsset(f.KrAsset.address);\n(0, _chai.expect)(assetInfo.swapInFeeSCDP).to.equal(f.swapKrAssetConfig.swapInFeeSCDP);\n(0, _chai.expect)(assetInfo.swapOutFeeSCDP).to.equal(f.swapKrAssetConfig.swapOutFeeSCDP);\n(0, _chai.expect)(assetInfo.liqIncentiveSCDP).to.equal(f.swapKrAssetConfig.liqIncentiveSCDP);\n(0, _chai.expect)(assetInfo.protocolFeeShareSCDP).to.equal(f.swapKrAssetConfig.protocolFeeShareSCDP);",
- "err": {},
- "uuid": "7c1f9f56-ec22-41e4-a1e7-0f6feab10c45",
- "parentUUID": "c2240cc3-54b9-4557-bec8-b784aeeb4a31",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should be able to update a whitelisted kresko asset",
- "fullTitle": "SCDP #Configuration should be able to update a whitelisted kresko asset",
- "timedOut": false,
- "duration": 215,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const update = {\n ...f.KrAsset.config.assetStruct,\n swapInFeeSCDP: 0.05e4,\n swapOutFeeSCDP: 0.05e4,\n liqIncentiveSCDP: 1.06e4,\n protocolFeeShareSCDP: 0.4e4\n};\nawait hre.Diamond.updateAsset(f.KrAsset.address, update);\nconst assetInfo = await hre.Diamond.getAsset(f.KrAsset.address);\n(0, _chai.expect)(assetInfo.swapInFeeSCDP).to.equal(update.swapInFeeSCDP);\n(0, _chai.expect)(assetInfo.swapOutFeeSCDP).to.equal(update.swapOutFeeSCDP);\n(0, _chai.expect)(assetInfo.protocolFeeShareSCDP).to.equal(update.protocolFeeShareSCDP);\n(0, _chai.expect)(assetInfo.liqIncentiveSCDP).to.equal(update.liqIncentiveSCDP);\nconst krAssets = await hre.Diamond.getKreskoAssetsSCDP();\n(0, _chai.expect)(krAssets).to.include(f.KrAsset.address);\nconst collaterals = await hre.Diamond.getCollateralsSCDP();\n(0, _chai.expect)(collaterals).to.include(f.KrAsset.address);\n(0, _chai.expect)(await hre.Diamond.getDepositEnabledSCDP(f.KrAsset.address)).to.equal(false);",
- "err": {},
- "uuid": "65c69d83-70a5-4644-89f5-285871bf3484",
- "parentUUID": "c2240cc3-54b9-4557-bec8-b784aeeb4a31",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should be able to remove a whitelisted kresko asset",
- "fullTitle": "SCDP #Configuration should be able to remove a whitelisted kresko asset",
- "timedOut": false,
- "duration": 112,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await hre.Diamond.setAssetIsSwapMintableSCDP(f.KrAsset.address, false);\nconst krAssets = await hre.Diamond.getKreskoAssetsSCDP();\n(0, _chai.expect)(krAssets).to.not.include(f.KrAsset.address);\n(0, _chai.expect)(await hre.Diamond.getDepositEnabledSCDP(f.KrAsset.address)).to.equal(false);",
- "err": {},
- "uuid": "4063f1d8-883a-407f-a0ad-a84c13d1bbf2",
- "parentUUID": "c2240cc3-54b9-4557-bec8-b784aeeb4a31",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should be able to enable and disable swap pairs",
- "fullTitle": "SCDP #Configuration should be able to enable and disable swap pairs",
- "timedOut": false,
- "duration": 221,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const swapPairsEnabled = [\n {\n assetIn: f.Collateral.address,\n assetOut: f.KrAsset.address,\n enabled: true\n }\n];\nawait hre.Diamond.setSwapRoutesSCDP(swapPairsEnabled);\n(0, _chai.expect)(await hre.Diamond.getSwapEnabledSCDP(f.Collateral.address, f.KrAsset.address)).to.equal(true);\n(0, _chai.expect)(await hre.Diamond.getSwapEnabledSCDP(f.KrAsset.address, f.Collateral.address)).to.equal(true);\nconst swapPairsDisabled = [\n {\n assetIn: f.Collateral.address,\n assetOut: f.KrAsset.address,\n enabled: false\n }\n];\nawait hre.Diamond.setSwapRoutesSCDP(swapPairsDisabled);\n(0, _chai.expect)(await hre.Diamond.getSwapEnabledSCDP(f.Collateral.address, f.KrAsset.address)).to.equal(false);\n(0, _chai.expect)(await hre.Diamond.getSwapEnabledSCDP(f.KrAsset.address, f.Collateral.address)).to.equal(false);",
- "err": {},
- "uuid": "18851dc3-b16f-4a8b-9354-d72b4083970b",
- "parentUUID": "c2240cc3-54b9-4557-bec8-b784aeeb4a31",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "30aac3d5-0278-45b2-b531-6e0c197a43b3",
- "79b5c634-d992-488d-9a53-af7b10934aa2",
- "e0592118-dbf5-4419-8f5f-4152d541651b",
- "3bed0542-8c64-4b44-b5a4-6570d291da83",
- "be15a86b-8c71-47e7-ae23-8e1f9789b4f5",
- "7c1f9f56-ec22-41e4-a1e7-0f6feab10c45",
- "65c69d83-70a5-4644-89f5-285871bf3484",
- "4063f1d8-883a-407f-a0ad-a84c13d1bbf2",
- "18851dc3-b16f-4a8b-9354-d72b4083970b"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 1877,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "c0a085fc-3c9e-41b0-8cc9-d25d6105d1f2",
- "title": "#Deposit",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/scdp/00-scdp.ts",
- "file": "/src/test/scdp/00-scdp.ts",
- "beforeHooks": [],
- "afterHooks": [],
- "tests": [
- {
- "title": "should be able to deposit collateral, calculate correct deposit values",
- "fullTitle": "SCDP #Deposit should be able to deposit collateral, calculate correct deposit values",
- "timedOut": false,
- "duration": 1845,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const expectedValueUnadjusted = (0, _values.toBig)(f.CollateralPrice.num(8) * depositAmount, 8);\nconst expectedValueAdjusted = (f.CollateralPrice.num(8) * depositAmount).ebn(8) // cfactor = 1\n;\nawait hre.Diamond.setFeeAssetSCDP(f.Collateral.address);\nawait Promise.all(f.usersArr.map((user)=>{\n return (0, _redstone.wrapKresko)(hre.Diamond, user).depositSCDP(user.address, f.Collateral.address, depositAmount18Dec);\n}));\nconst [userInfos, statistics, assetInfo] = await Promise.all([\n hre.Diamond.getAccountsSCDP(f.usersArr.map((user)=>user.address), [\n f.Collateral.address\n ]),\n hre.Diamond.getDataSCDP(),\n hre.Diamond.getAssetDataSCDP(f.Collateral.address)\n]);\nfor (const userInfo of userInfos){\n const balance = await f.Collateral.balanceOf(userInfo.addr);\n (0, _chai.expect)(balance).to.equal(0);\n (0, _chai.expect)(userInfo.deposits[0].amountAdj).to.equal(0);\n (0, _chai.expect)(userInfo.deposits[0].amount).to.equal(depositAmount18Dec);\n (0, _chai.expect)(userInfo.totals.valColl).to.equal(expectedValueUnadjusted);\n (0, _chai.expect)(userInfo.totals.valFees).to.equal(0);\n (0, _chai.expect)(userInfo.deposits[0].val).to.equal(expectedValueUnadjusted);\n (0, _chai.expect)(userInfo.deposits[0].valAdj).to.equal(0);\n}\n(0, _chai.expect)(await f.Collateral.balanceOf(hre.Diamond.address)).to.equal(depositAmount18Dec.mul(f.usersArr.length));\n(0, _chai.expect)(assetInfo.amountColl).to.equal(depositAmount18Dec.mul(f.usersArr.length));\n(0, _chai.expect)(assetInfo.valColl).to.equal(expectedValueUnadjusted.mul(f.usersArr.length));\n(0, _chai.expect)(statistics.totals.valColl).to.equal(expectedValueUnadjusted.mul(f.usersArr.length));\n(0, _chai.expect)(statistics.totals.valDebt).to.equal(0);\n// Adjusted\n(0, _chai.expect)(assetInfo.valCollAdj).to.equal(expectedValueAdjusted.mul(f.usersArr.length));\n(0, _chai.expect)(statistics.totals.valCollAdj).to.equal(expectedValueUnadjusted.mul(f.usersArr.length));\n(0, _chai.expect)(statistics.totals.valDebtOgAdj).to.equal(0);\n(0, _chai.expect)(statistics.totals.valDebt).to.equal(0);\n(0, _chai.expect)(statistics.totals.crOgAdj).to.equal(0);\n(0, _chai.expect)(statistics.totals.crOg).to.equal(0);\n(0, _chai.expect)(statistics.totals.cr).to.equal(0);",
- "err": {},
- "uuid": "b410cdc7-4fb7-4172-97bb-72920841e897",
- "parentUUID": "c0a085fc-3c9e-41b0-8cc9-d25d6105d1f2",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should be able to deposit multiple collaterals, calculate correct deposit values",
- "fullTitle": "SCDP #Deposit should be able to deposit multiple collaterals, calculate correct deposit values",
- "timedOut": false,
- "duration": 2152,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const expectedValueUnadjusted = (0, _values.toBig)(f.CollateralPrice.num(8) * depositAmount, 8);\nconst expectedValueAdjusted = (0, _values.toBig)(f.CollateralPrice.num(8) / 1 * depositAmount, 8) // cfactor = 1\n;\nconst expectedValueUnadjusted8Dec = (0, _values.toBig)(f.CollateralPrice.num(8) * depositAmount, 8);\nconst expectedValueAdjusted8Dec = (0, _values.toBig)(f.CollateralPrice.num(8) * 0.8 * depositAmount, 8) // cfactor = 0.8\n;\nawait Promise.all(f.usersArr.map(async (user)=>{\n const User = (0, _redstone.wrapKresko)(hre.Diamond, user);\n await hre.Diamond.setFeeAssetSCDP(f.Collateral.address);\n await User.depositSCDP(user.address, f.Collateral.address, depositAmount18Dec);\n await hre.Diamond.setFeeAssetSCDP(f.Collateral8Dec.address);\n await User.depositSCDP(user.address, f.Collateral8Dec.address, depositAmount8Dec);\n}));\nconst [userInfos, assetInfos, globals] = await Promise.all([\n hre.Diamond.getAccountsSCDP(f.usersArr.map((u)=>u.address), [\n f.Collateral.address,\n f.Collateral8Dec.address\n ]),\n hre.Diamond.getAssetDatasSCDP([\n f.Collateral.address,\n f.Collateral8Dec.address\n ]),\n hre.Diamond.getDataSCDP()\n]);\nfor (const userInfo of userInfos){\n (0, _chai.expect)(userInfo.deposits[0].amount).to.equal(depositAmount18Dec);\n (0, _chai.expect)(userInfo.deposits[0].val).to.equal(expectedValueUnadjusted);\n (0, _chai.expect)(userInfo.deposits[1].amount).to.equal(depositAmount8Dec);\n (0, _chai.expect)(userInfo.deposits[1].val).to.equal(expectedValueUnadjusted8Dec);\n (0, _chai.expect)(userInfo.totals.valColl).to.equal(expectedValueUnadjusted.add(expectedValueUnadjusted8Dec));\n}\n(0, _chai.expect)(assetInfos[0].amountColl).to.equal(depositAmount18Dec.mul(f.usersArr.length));\n(0, _chai.expect)(assetInfos[1].amountColl).to.equal(depositAmount8Dec.mul(f.usersArr.length));\n// WITH_FACTORS global\nconst valueTotalAdjusted = expectedValueAdjusted.mul(f.usersArr.length);\nconst valueTotalAdjusted8Dec = expectedValueAdjusted8Dec.mul(f.usersArr.length);\nconst valueAdjusted = valueTotalAdjusted.add(valueTotalAdjusted8Dec);\n(0, _chai.expect)(assetInfos[0].valColl).to.equal(valueTotalAdjusted);\n(0, _chai.expect)(assetInfos[1].valCollAdj).to.equal(valueTotalAdjusted8Dec);\n(0, _chai.expect)(globals.totals.valCollAdj).to.equal(valueAdjusted);\n(0, _chai.expect)(globals.totals.valDebt).to.equal(0);\n(0, _chai.expect)(globals.totals.cr).to.equal(0);\n// WITHOUT_FACTORS global\nconst valueTotalUnadjusted = expectedValueUnadjusted.mul(f.usersArr.length);\nconst valueTotalUnadjusted8Dec = expectedValueUnadjusted8Dec.mul(f.usersArr.length);\nconst valueUnadjusted = valueTotalUnadjusted.add(valueTotalUnadjusted8Dec);\n(0, _chai.expect)(assetInfos[0].valColl).to.equal(valueTotalUnadjusted);\n(0, _chai.expect)(assetInfos[1].valColl).to.equal(valueTotalUnadjusted8Dec);\n(0, _chai.expect)(globals.totals.valColl).to.equal(valueUnadjusted);\n(0, _chai.expect)(globals.totals.valDebt).to.equal(0);\n(0, _chai.expect)(globals.totals.cr).to.equal(0);",
- "err": {},
- "uuid": "6d031513-30f7-4d30-b186-6c72f7d96025",
- "parentUUID": "c0a085fc-3c9e-41b0-8cc9-d25d6105d1f2",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "b410cdc7-4fb7-4172-97bb-72920841e897",
- "6d031513-30f7-4d30-b186-6c72f7d96025"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 3997,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "b813cae8-2aec-45cb-b928-6ab114ada7a8",
- "title": "#Withdraw",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/scdp/00-scdp.ts",
- "file": "/src/test/scdp/00-scdp.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"#Withdraw\"",
- "fullTitle": "SCDP #Withdraw \"before each\" hook in \"#Withdraw\"",
- "timedOut": false,
- "duration": 477,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await Promise.all(f.usersArr.map(async (user)=>{\n const UserKresko = (0, _redstone.wrapKresko)(hre.Diamond, user);\n await hre.Diamond.setFeeAssetSCDP(f.Collateral.address);\n await UserKresko.depositSCDP(user.address, f.Collateral.address, depositAmount18Dec);\n await hre.Diamond.setFeeAssetSCDP(f.Collateral8Dec.address);\n await UserKresko.depositSCDP(user.address, f.Collateral8Dec.address, depositAmount8Dec);\n}));",
- "err": {},
- "uuid": "daeede79-b739-4a27-a7b9-3563a9523872",
- "parentUUID": "b813cae8-2aec-45cb-b928-6ab114ada7a8",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [
- {
- "title": "should be able to withdraw full collateral of multiple assets",
- "fullTitle": "SCDP #Withdraw should be able to withdraw full collateral of multiple assets",
- "timedOut": false,
- "duration": 2403,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await Promise.all(f.usersArr.map(async (user)=>{\n const UserKresko = (0, _redstone.wrapKresko)(hre.Diamond, user);\n return Promise.all([\n UserKresko.withdrawSCDP(user.address, f.Collateral.address, depositAmount18Dec),\n UserKresko.withdrawSCDP(user.address, f.Collateral8Dec.address, depositAmount8Dec)\n ]);\n}));\n(0, _chai.expect)(await f.Collateral.balanceOf(hre.Diamond.address)).to.equal(0);\nconst [userInfos, assetInfos, globals] = await Promise.all([\n hre.Diamond.getAccountsSCDP(f.usersArr.map((u)=>u.address), [\n f.Collateral.address,\n f.Collateral8Dec.address\n ]),\n hre.Diamond.getAssetDatasSCDP([\n f.Collateral.address,\n f.Collateral8Dec.address\n ]),\n hre.Diamond.getDataSCDP()\n]);\nfor (const userInfo of userInfos){\n (0, _chai.expect)(await f.Collateral.balanceOf(userInfo.addr)).to.equal(depositAmount18Dec);\n (0, _chai.expect)(userInfo.deposits[0].amount).to.equal(0);\n (0, _chai.expect)(userInfo.deposits[0].amountAdj).to.equal(0);\n (0, _chai.expect)(userInfo.deposits[1].amount).to.equal(0);\n (0, _chai.expect)(userInfo.deposits[1].amountAdj).to.equal(0);\n (0, _chai.expect)(userInfo.totals.valColl).to.equal(0);\n}\nfor (const assetInfo of assetInfos){\n (0, _chai.expect)(assetInfo.valColl).to.equal(0);\n (0, _chai.expect)(assetInfo.amountColl).to.equal(0);\n (0, _chai.expect)(assetInfo.amountSwapDeposit).to.equal(0);\n}\n(0, _chai.expect)(globals.totals.valColl).to.equal(0);\n(0, _chai.expect)(globals.totals.valDebt).to.equal(0);\n(0, _chai.expect)(globals.totals.cr).to.equal(0);",
- "err": {},
- "uuid": "33dad968-b103-474a-a568-7f2203baa3aa",
- "parentUUID": "b813cae8-2aec-45cb-b928-6ab114ada7a8",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should be able to withdraw partial collateral of multiple assets",
- "fullTitle": "SCDP #Withdraw should be able to withdraw partial collateral of multiple assets",
- "timedOut": false,
- "duration": 2344,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const partialWithdraw = depositAmount18Dec.div(f.usersArr.length);\nconst partialWithdraw8Dec = depositAmount8Dec.div(f.usersArr.length);\nconst expectedValueUnadjusted = (0, _values.toBig)(f.CollateralPrice.num(8) * depositAmount, 8).mul(200).div(300);\nconst expectedValueAdjusted = (0, _values.toBig)(f.CollateralPrice.num(8) * 1 * depositAmount, 8).mul(200).div(300) // cfactor = 1\n;\nconst expectedValueUnadjusted8Dec = (0, _values.toBig)(f.CollateralPrice.num(8) * depositAmount, 8).mul(200).div(300);\nconst expectedValueAdjusted8Dec = (0, _values.toBig)(f.CollateralPrice.num(8) * 0.8 * depositAmount, 8).mul(200).div(300) // cfactor = 0.8\n;\nawait Promise.all(f.usersArr.map((user)=>{\n const UserKresko = (0, _redstone.wrapKresko)(hre.Diamond, user);\n return Promise.all([\n UserKresko.withdrawSCDP(user.address, f.Collateral.address, partialWithdraw),\n UserKresko.withdrawSCDP(user.address, f.Collateral8Dec.address, partialWithdraw8Dec)\n ]);\n}));\nconst [collateralBalanceAfter, collateral8DecBalanceAfter, globals, assetInfos, userInfos] = await Promise.all([\n f.Collateral.balanceOf(hre.Diamond.address),\n f.Collateral8Dec.balanceOf(hre.Diamond.address),\n hre.Diamond.getDataSCDP(),\n hre.Diamond.getAssetDatasSCDP([\n f.Collateral.address,\n f.Collateral8Dec.address\n ]),\n hre.Diamond.getAccountsSCDP(f.usersArr.map((u)=>u.address), [\n f.Collateral.address,\n f.Collateral8Dec.address\n ])\n]);\nfor (const userInfo of userInfos){\n const [balance18Dec, balance8Dec] = await Promise.all([\n f.Collateral.balanceOf(userInfo.addr),\n f.Collateral8Dec.balanceOf(userInfo.addr)\n ]);\n (0, _chai.expect)(balance18Dec).to.equal(partialWithdraw);\n (0, _chai.expect)(balance8Dec).to.equal(partialWithdraw8Dec);\n (0, _chai.expect)(userInfo.deposits[0].amount).to.equal(depositAmount18Dec.sub(partialWithdraw));\n (0, _chai.expect)(userInfo.deposits[0].amountAdj).to.equal(0);\n (0, _chai.expect)(userInfo.deposits[1].amount).to.equal(depositAmount8Dec.sub(partialWithdraw8Dec));\n (0, _chai.expect)(userInfo.deposits[1].amountAdj).to.equal(0);\n (0, _chai.expect)(userInfo.totals.valColl).to.closeTo(expectedValueUnadjusted.add(expectedValueUnadjusted8Dec), (0, _values.toBig)(0.00001, 8));\n}\n(0, _chai.expect)(collateralBalanceAfter).to.closeTo((0, _values.toBig)(2000), 1);\n(0, _chai.expect)(collateral8DecBalanceAfter).to.closeTo((0, _values.toBig)(2000, 8), 1);\n(0, _chai.expect)(assetInfos[0].amountColl).to.closeTo((0, _values.toBig)(2000), 1);\n(0, _chai.expect)(assetInfos[1].amountColl).to.closeTo((0, _values.toBig)(2000, 8), 1);\n(0, _chai.expect)(assetInfos[0].valColl).to.closeTo(expectedValueUnadjusted.mul(f.usersArr.length), 20);\n(0, _chai.expect)(assetInfos[0].valCollAdj).to.closeTo(expectedValueAdjusted.mul(f.usersArr.length), 20);\n(0, _chai.expect)(assetInfos[1].valColl).to.closeTo(expectedValueUnadjusted8Dec.mul(f.usersArr.length), 20);\n(0, _chai.expect)(assetInfos[1].valCollAdj).to.closeTo(expectedValueAdjusted8Dec.mul(f.usersArr.length), 20);\nconst totalValueRemaining = expectedValueUnadjusted8Dec.mul(f.usersArr.length).add(expectedValueUnadjusted.mul(f.usersArr.length));\n(0, _chai.expect)(globals.totals.valColl).to.closeTo(totalValueRemaining, 20);\n(0, _chai.expect)(globals.totals.valDebt).to.equal(0);\n(0, _chai.expect)(globals.totals.cr).to.equal(0);",
- "err": {},
- "uuid": "a1ba044a-fc71-47c3-ab3e-320c45a61fc1",
- "parentUUID": "b813cae8-2aec-45cb-b928-6ab114ada7a8",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "33dad968-b103-474a-a568-7f2203baa3aa",
- "a1ba044a-fc71-47c3-ab3e-320c45a61fc1"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 4747,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "96d1e5b5-d601-45ca-8df6-d6bdd29e19e5",
- "title": "#Fee Distribution",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/scdp/00-scdp.ts",
- "file": "/src/test/scdp/00-scdp.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"#Fee Distribution\"",
- "fullTitle": "SCDP #Fee Distribution \"before each\" hook in \"#Fee Distribution\"",
- "timedOut": false,
- "duration": 18,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "incomeCumulator = hre.users.deployer;\nIncomeCumulator = (0, _redstone.wrapKresko)(hre.Diamond, incomeCumulator);\nawait f.Collateral.setBalance(incomeCumulator, depositAmount18Dec.mul(f.usersArr.length), hre.Diamond.address);",
- "err": {},
- "uuid": "ae0e3a71-bbca-44cc-a33e-b39da0d6d324",
- "parentUUID": "96d1e5b5-d601-45ca-8df6-d6bdd29e19e5",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [
- {
- "title": "should be able to cumulate fees into deposits",
- "fullTitle": "SCDP #Fee Distribution should be able to cumulate fees into deposits",
- "timedOut": false,
- "duration": 3030,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await hre.Diamond.setFeeAssetSCDP(f.Collateral.address);\nconst feePerUser = depositAmount18Dec;\nconst feesToCumulate = feePerUser.mul(f.usersArr.length);\nconst feePerUserValue = (0, _values.toBig)(f.CollateralPrice.num(8) * depositAmount, 8);\nconst expectedDepositValue = (0, _values.toBig)(f.CollateralPrice.num(8) * depositAmount, 8);\n// deposit some\nawait Promise.all(f.usersArr.map((signer)=>(0, _redstone.wrapKresko)(hre.Diamond, signer).depositSCDP(signer.address, f.Collateral.address, depositAmount18Dec)));\n// cumulate some income\nawait IncomeCumulator.cumulateIncomeSCDP(f.Collateral.address, feesToCumulate);\n// check that the fees are cumulated\nfor (const data of (await hre.Diamond.getAccountsSCDP(f.usersArr.map((u)=>u.address), [\n f.Collateral.address\n]))){\n (0, _chai.expect)(data.deposits[0].val).to.equal(expectedDepositValue);\n (0, _chai.expect)(data.deposits[0].valAdj).to.equal(feePerUserValue);\n (0, _chai.expect)(data.totals.valColl).to.equal(expectedDepositValue);\n (0, _chai.expect)(data.totals.valFees).to.equal(feePerUserValue);\n}\n// withdraw principal\nawait Promise.all(f.usersArr.map((signer)=>(0, _redstone.wrapKresko)(hre.Diamond, signer).withdrawSCDP(signer.address, f.Collateral.address, depositAmount18Dec)));\nfor (const user of (await hre.Diamond.getAccountsSCDP(f.usersArr.map((u)=>u.address), [\n f.Collateral.address\n]))){\n const balance = await f.Collateral.balanceOf(user.addr);\n (0, _chai.expect)(user.deposits[0].val).to.equal(0);\n (0, _chai.expect)(user.deposits[0].valAdj).to.equal(0);\n (0, _chai.expect)(user.totals.valFees).to.equal(0);\n (0, _chai.expect)(user.totals.valColl).to.equal(0);\n (0, _chai.expect)(balance).to.equal(depositAmount18Dec.add(feePerUser));\n}\nconst [assetInfo, stats, balance] = await Promise.all([\n hre.Diamond.getAssetDataSCDP(f.Collateral.address),\n hre.Diamond.getDataSCDP(),\n f.Collateral.balanceOf(hre.Diamond.address)\n]);\n(0, _chai.expect)(balance).to.equal(0);\n(0, _chai.expect)(assetInfo.amountColl).to.equal(0);\n(0, _chai.expect)(assetInfo.valColl).to.equal(0);\n(0, _chai.expect)(assetInfo.valCollAdj).to.equal(0);\n(0, _chai.expect)(stats.totals.valColl).to.equal(0);\n// nothing left in protocol.\nconst [colalteralBalanceKresko, assetInfoFinal] = await Promise.all([\n f.Collateral.balanceOf(hre.Diamond.address),\n hre.Diamond.getAssetDataSCDP(f.Collateral.address)\n]);\n(0, _chai.expect)(colalteralBalanceKresko).to.equal(0);\n(0, _chai.expect)(assetInfoFinal.amountColl).to.equal(0);\n(0, _chai.expect)(assetInfoFinal.valColl).to.equal(0);\n(0, _chai.expect)(assetInfoFinal.valCollAdj).to.equal(0);",
- "err": {},
- "uuid": "b442167c-23ef-4116-bfd7-a5786cac7fca",
- "parentUUID": "96d1e5b5-d601-45ca-8df6-d6bdd29e19e5",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "b442167c-23ef-4116-bfd7-a5786cac7fca"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 3030,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "99489778-5ce3-4570-9c60-a6104b9d6b2d",
- "title": "#Swap",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/scdp/00-scdp.ts",
- "file": "/src/test/scdp/00-scdp.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"#Swap\"",
- "fullTitle": "SCDP #Swap \"before each\" hook in \"#Swap\"",
- "timedOut": false,
- "duration": 138,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await Promise.all(f.usersArr.map((signer)=>f.Collateral.setBalance(signer, (0, _values.toBig)(1_000_000))));\nawait f.KISS.setBalance(f.swapper, (0, _values.toBig)(10_000));\nawait f.KISS.setBalance(f.depositor, (0, _values.toBig)(10_000));\nawait f.KreskoDepositor.depositSCDP(f.depositor.address, f.KISS.address, depositAmount18Dec);",
- "err": {},
- "uuid": "2dec05cb-c0de-4167-a3b3-30f893feca6d",
- "parentUUID": "99489778-5ce3-4570-9c60-a6104b9d6b2d",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [
- {
- "title": "should have collateral in pool",
- "fullTitle": "SCDP #Swap should have collateral in pool",
- "timedOut": false,
- "duration": 852,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const value = await hre.Diamond.getDataSCDP();\n(0, _chai.expect)(value.totals.valColl).to.equal((0, _values.toBig)(depositAmount, 8));\n(0, _chai.expect)(value.totals.valDebt).to.equal(0);\n(0, _chai.expect)(value.totals.cr).to.equal(0);",
- "err": {},
- "uuid": "3ba2b187-1e3c-474b-9219-3c8d80e855a1",
- "parentUUID": "99489778-5ce3-4570-9c60-a6104b9d6b2d",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should be able to preview a swap",
- "fullTitle": "SCDP #Swap should be able to preview a swap",
- "timedOut": false,
- "duration": 118,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const swapAmount = (0, _values.toBig)(1);\n(0, _chai.expect)(await f.KrAsset2.getPrice()).to.equal(f.KrAsset2Price);\nconst feePercentageProtocol = Number(f.KISS.config.assetStruct.protocolFeeShareSCDP) + Number(f.KrAsset2.config.assetStruct.protocolFeeShareSCDP);\nconst expectedTotalFee = swapAmount.percentMul(f.KRASSET_KISS_ROUTE_FEE);\nconst expectedProtocolFee = expectedTotalFee.percentMul(feePercentageProtocol);\nconst expectedFee = expectedTotalFee.sub(expectedProtocolFee);\nconst amountInAfterFees = swapAmount.sub(expectedTotalFee);\nconst expectedAmountOut = amountInAfterFees.wadMul(f.KISSPrice).wadDiv(f.KrAsset2Price);\nconst [amountOut, feeAmount, feeAmountProtocol] = await hre.Diamond.previewSwapSCDP(f.KISS.address, f.KrAsset2.address, swapAmount);\n(0, _chai.expect)(amountOut).to.equal(expectedAmountOut);\n(0, _chai.expect)(feeAmount).to.equal(expectedFee);\n(0, _chai.expect)(feeAmountProtocol).to.equal(expectedProtocolFee);",
- "err": {},
- "uuid": "799308a6-1d82-446e-a23e-03a46ed3e365",
- "parentUUID": "99489778-5ce3-4570-9c60-a6104b9d6b2d",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should be able to swap, shared debt == 0 | swap collateral == 0",
- "fullTitle": "SCDP #Swap should be able to swap, shared debt == 0 | swap collateral == 0",
- "timedOut": false,
- "duration": 1578,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const swapAmount = (0, _values.toBig)(1) // $1\n;\nconst kissInAfterFees = swapAmount.sub(swapAmount.percentMul(f.KRASSET_KISS_ROUTE_FEE));\nconst expectedAmountOut = kissInAfterFees.wadMul(f.KISSPrice).wadDiv(f.KrAsset2Price);\nconst tx = await f.KreskoSwapper.swapSCDP(f.swapper.address, f.KISS.address, f.KrAsset2.address, swapAmount, 0);\nconst event = await (0, _events.getNamedEvent)(tx, 'Swap');\n(0, _chai.expect)(event.args.who).to.equal(f.swapper.address);\n(0, _chai.expect)(event.args.assetIn).to.equal(f.KISS.address);\n(0, _chai.expect)(event.args.assetOut).to.equal(f.KrAsset2.address);\n(0, _chai.expect)(event.args.amountIn).to.equal(swapAmount);\n(0, _chai.expect)(event.args.amountOut).to.equal(expectedAmountOut);\nconst [KR2Balance, KISSBalance, swapperInfos, assetInfos, global] = await Promise.all([\n f.KrAsset2.balanceOf(f.swapper.address),\n f.KISS.balanceOf(f.swapper.address),\n hre.Diamond.getAccountsSCDP([\n f.swapper.address\n ], [\n f.KrAsset2.address,\n f.KISS.address\n ]),\n hre.Diamond.getAssetDatasSCDP([\n f.KrAsset2.address,\n f.KISS.address\n ]),\n hre.Diamond.getDataSCDP()\n]);\nconst swapperInfo = swapperInfos[0];\n(0, _chai.expect)(KR2Balance).to.equal(expectedAmountOut);\n(0, _chai.expect)(KISSBalance).to.equal((0, _values.toBig)(10_000).sub(swapAmount));\n(0, _chai.expect)(swapperInfo.deposits[0].val).to.equal(0);\n(0, _chai.expect)(swapperInfo.deposits[1].val).to.equal(0);\n(0, _chai.expect)(assetInfos[0].amountDebt).to.equal(expectedAmountOut);\n(0, _chai.expect)(assetInfos[1].amountSwapDeposit).to.equal(kissInAfterFees);\nconst expectedDepositValue = (0, _values.toBig)(depositAmount, 8).add(kissInAfterFees.wadMul(f.KISSPrice));\n(0, _chai.expect)(assetInfos[1].valColl).to.equal(expectedDepositValue);\n(0, _chai.expect)(assetInfos[0].valDebt).to.equal(expectedAmountOut.wadMul(f.KrAsset2Price));\n(0, _chai.expect)(global.totals.valColl).to.equal(expectedDepositValue);\n(0, _chai.expect)(global.totals.valDebt).to.equal(expectedAmountOut.wadMul(f.KrAsset2Price));\n(0, _chai.expect)(global.totals.cr).to.equal(expectedDepositValue.percentDiv(expectedAmountOut.wadMul(f.KrAsset2Price)));",
- "err": {},
- "uuid": "28bdcc8b-33b5-491d-b6cb-f060e7d873b2",
- "parentUUID": "99489778-5ce3-4570-9c60-a6104b9d6b2d",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should be able to swap, shared debt == assetsIn | swap collateral == assetsOut",
- "fullTitle": "SCDP #Swap should be able to swap, shared debt == assetsIn | swap collateral == assetsOut",
- "timedOut": false,
- "duration": 2600,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const swapAmount = (0, _values.toBig)(100) // $100\n;\nconst swapAmountAsset = swapAmount.percentMul(1e4 - Number(f.KRASSET_KISS_ROUTE_FEE)).wadMul(f.KISSPrice.wadDiv(f.KrAsset2Price));\nconst expectedKissOut = swapAmountAsset.percentMul(1e4 - f.KRASSET_KISS_ROUTE_FEE).wadMul(f.KrAsset2Price).wadDiv(f.KISSPrice);\n// deposit some to kresko for minting first\nawait (0, _collaterals.depositCollateral)({\n user: f.swapper,\n asset: f.KISS,\n amount: (0, _values.toBig)(100)\n});\nawait (0, _krassets.mintKrAsset)({\n user: f.swapper,\n asset: f.KrAsset2,\n amount: (0, _values.toBig)(0.1)\n});\nconst globalBefore = await hre.Diamond.getDataSCDP();\n(0, _chai.expect)(globalBefore.totals.valColl).to.equal(initialDepositValue);\nawait f.KreskoSwapper.swapSCDP(f.swapper.address, f.KISS.address, f.KrAsset2.address, swapAmount, 0);\n// the swap that clears debt\nconst tx = await f.KreskoSwapper.swapSCDP(f.swapper.address, f.KrAsset2.address, f.KISS.address, swapAmountAsset, 0);\nconst [event, assetInfos] = await Promise.all([\n (0, _events.getNamedEvent)(tx, 'Swap'),\n hre.Diamond.getAssetDatasSCDP([\n f.KISS.address,\n f.KrAsset2.address\n ])\n]);\n(0, _chai.expect)(event.args.who).to.equal(f.swapper.address);\n(0, _chai.expect)(event.args.assetIn).to.equal(f.KrAsset2.address);\n(0, _chai.expect)(event.args.assetOut).to.equal(f.KISS.address);\n(0, _chai.expect)(event.args.amountIn).to.equal(swapAmountAsset);\n(0, _chai.expect)(event.args.amountOut).to.equal(expectedKissOut);\n(0, _chai.expect)(assetInfos[0].amountSwapDeposit).to.equal(0);\n(0, _chai.expect)(assetInfos[0].valColl).to.equal(initialDepositValue);\n(0, _chai.expect)(assetInfos[1].valDebt).to.equal(0);\n(0, _chai.expect)(assetInfos[1].amountDebt).to.equal(0);\nconst global = await hre.Diamond.getDataSCDP();\n(0, _chai.expect)(global.totals.valColl).to.equal((0, _values.toBig)(1000, 8));\n(0, _chai.expect)(global.totals.valDebt).to.equal(0);\n(0, _chai.expect)(global.totals.cr).to.equal(0);",
- "err": {},
- "uuid": "a7f74549-34c0-43b9-bd86-a688a977423f",
- "parentUUID": "99489778-5ce3-4570-9c60-a6104b9d6b2d",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should be able to swap, debt > assetsIn | swap deposits > assetsOut",
- "fullTitle": "SCDP #Swap should be able to swap, debt > assetsIn | swap deposits > assetsOut",
- "timedOut": false,
- "duration": 1750,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const swapAmount = (0, _values.toBig)(1) // $1\n;\nconst swapValue = (0, _values.toBig)(1, 8);\nawait f.KreskoSwapper.swapSCDP(f.swapper.address, f.KISS.address, f.KrAsset2.address, swapAmount, 0);\nconst assetInfoKISS = await hre.Diamond.getAssetDataSCDP(f.KISS.address);\nconst feeValueFirstSwap = swapValue.percentMul(f.KRASSET_KISS_ROUTE_FEE);\nconst valueInAfterFees = swapValue.sub(feeValueFirstSwap);\n(0, _chai.expect)(assetInfoKISS.valColl).to.equal(depositValue.add(valueInAfterFees));\nconst expectedSwapDeposits = valueInAfterFees.num(8).ebn(18);\n(0, _chai.expect)(assetInfoKISS.amountSwapDeposit).to.equal(expectedSwapDeposits);\nconst swapAmountSecond = (0, _values.toBig)(0.009) // this is $0.90, so less than $0.96 since we want to ensure debt > assetsIn | swap deposits > assetsOut\n;\nconst swapValueSecond = swapAmountSecond.wadMul(f.KrAsset2Price);\nconst feeValueSecondSwap = swapValueSecond.sub(swapValueSecond.percentMul(f.KRASSET_KISS_ROUTE_FEE));\nconst expectedKissOut = feeValueSecondSwap.wadDiv(f.KISSPrice) // 0.8685\n;\nconst tx = await f.KreskoSwapper.swapSCDP(f.swapper.address, f.KrAsset2.address, f.KISS.address, swapAmountSecond, 0);\nconst event = await (0, _events.getNamedEvent)(tx, 'Swap');\n(0, _chai.expect)(event.args.who).to.equal(f.swapper.address);\n(0, _chai.expect)(event.args.assetIn).to.equal(f.KrAsset2.address);\n(0, _chai.expect)(event.args.assetOut).to.equal(f.KISS.address);\n(0, _chai.expect)(event.args.amountIn).to.equal(swapAmountSecond);\n(0, _chai.expect)(event.args.amountOut).to.equal(expectedKissOut);\nconst [depositValueKR2, depositValueKISS, assetInfos, globals] = await Promise.all([\n f.KreskoSwapper.getAccountDepositValueSCDP(f.swapper.address, f.KrAsset2.address),\n f.KreskoSwapper.getAccountDepositValueSCDP(f.swapper.address, f.KISS.address),\n hre.Diamond.getAssetDatasSCDP([\n f.KISS.address,\n f.KrAsset2.address\n ]),\n hre.Diamond.getDataSCDP()\n]);\n(0, _chai.expect)(depositValueKR2).to.equal(0);\n(0, _chai.expect)(depositValueKISS).to.equal(0);\nconst expectedSwapDepositsAfter = expectedSwapDeposits.sub((0, _values.toBig)(0.9));\nconst expectedSwapDepositsValue = expectedSwapDepositsAfter.wadMul(assetInfoKISS.price);\n(0, _chai.expect)(assetInfos[0].amountSwapDeposit).to.equal(expectedSwapDepositsAfter);\n(0, _chai.expect)(assetInfos[0].valColl).to.equal((0, _values.toBig)(depositAmount, 8).add(expectedSwapDepositsValue));\n(0, _chai.expect)(assetInfos[1].valDebt).to.equal(expectedSwapDepositsValue);\nconst expectedDebtAfter = expectedSwapDepositsValue.wadDiv(await f.KrAsset2.getPrice());\n(0, _chai.expect)(assetInfos[0].amountDebt).to.equal(0);\n(0, _chai.expect)(assetInfos[1].amountDebt).to.equal(expectedDebtAfter);\nconst expectedCollateralValue = expectedSwapDepositsValue.add(depositAmount.ebn(8));\n(0, _chai.expect)(globals.totals.valColl).to.equal(expectedCollateralValue) // swap deposits + collateral deposited\n;\n(0, _chai.expect)(globals.totals.valDebt).to.equal(expectedSwapDepositsValue) //\n;\n(0, _chai.expect)(globals.totals.cr).to.equal(expectedCollateralValue.percentDiv(expectedSwapDepositsValue));",
- "err": {},
- "uuid": "744033e0-2a98-4bc0-882f-60cceae33b8d",
- "parentUUID": "99489778-5ce3-4570-9c60-a6104b9d6b2d",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should be able to swap, debt < assetsIn | swap deposits < assetsOut",
- "fullTitle": "SCDP #Swap should be able to swap, debt < assetsIn | swap deposits < assetsOut",
- "timedOut": false,
- "duration": 3228,
+ "duration": 2861,
"state": "passed",
"speed": "medium",
"pass": true,
@@ -7301,350 +94,20 @@
"context": null,
"code": "const swapAmountKiss = (0, _values.toBig)(100) // $100\n;\nconst swapAmountKrAsset = (0, _values.toBig)(2) // $200\n;\nconst swapValue = 200;\nconst firstSwapFeeAmount = swapAmountKiss.percentMul(f.KRASSET_KISS_ROUTE_FEE);\nconst expectedKissOutSecondSwap = swapAmountKrAsset.sub(swapAmountKrAsset.percentMul(f.KRASSET_KISS_ROUTE_FEE)).wadMul(f.KrAsset2Price).wadDiv(f.KISSPrice);\nconst krAssetOutFirstSwap = swapAmountKiss.sub(firstSwapFeeAmount).wadMul(f.KISSPrice).wadDiv(f.KrAsset2Price);\nconst krAssetOutFirstSwapValue = krAssetOutFirstSwap.wadMul(f.KrAsset2Price);\n// deposit some to kresko for minting first\nawait (0, _collaterals.depositCollateral)({\n user: f.swapper,\n asset: f.KISS,\n amount: (0, _values.toBig)(400)\n});\nconst ICDPMintAmount = (0, _values.toBig)(1.04);\nawait (0, _krassets.mintKrAsset)({\n user: f.swapper,\n asset: f.KrAsset2,\n amount: ICDPMintAmount\n});\nawait f.KreskoSwapper.swapSCDP(f.swapper.address, f.KISS.address, f.KrAsset2.address, swapAmountKiss, 0);\nconst expectedSwapDeposits = swapAmountKiss.sub(firstSwapFeeAmount);\nconst stats = await hre.Diamond.getDataSCDP();\n(0, _chai.expect)(await f.KreskoSwapper.getSwapDepositsSCDP(f.KISS.address)).to.equal(expectedSwapDeposits);\n(0, _chai.expect)(stats.totals.valColl).to.be.eq(depositAmount.ebn().add(expectedSwapDeposits).wadMul(f.KISSPrice));\n// the swap that matters, here user has 0.96 (previous swap) + 1.04 (mint). expecting 192 kiss from swap.\nconst [expectedAmountOut] = await f.KreskoSwapper.previewSwapSCDP(f.KrAsset2.address, f.KISS.address, swapAmountKrAsset);\n(0, _chai.expect)(expectedAmountOut).to.equal(expectedKissOutSecondSwap);\nconst tx = await f.KreskoSwapper.swapSCDP(f.swapper.address, f.KrAsset2.address, f.KISS.address, swapAmountKrAsset, 0);\nconst event = await (0, _events.getNamedEvent)(tx, 'Swap');\n(0, _chai.expect)(event.args.who).to.equal(f.swapper.address);\n(0, _chai.expect)(event.args.assetIn).to.equal(f.KrAsset2.address);\n(0, _chai.expect)(event.args.assetOut).to.equal(f.KISS.address);\n(0, _chai.expect)(event.args.amountIn).to.equal(swapAmountKrAsset);\n(0, _chai.expect)(event.args.amountOut).to.equal(expectedKissOutSecondSwap);\nconst assetInfos = await hre.Diamond.getAssetDatasSCDP([\n f.KISS.address,\n f.KrAsset2.address\n]);\n// f.KISS deposits sent in swap\nconst acocuntPrincipalDepositsKISS = await f.KreskoSwapper.getAccountDepositSCDP(f.depositor.address, f.KISS.address);\n(0, _chai.expect)(assetInfos[0].amountSwapDeposit).to.equal(0) // half of 2 krAsset\n;\n(0, _chai.expect)(assetInfos[0].amountColl).to.equal(acocuntPrincipalDepositsKISS);\n// KrAsset debt is cleared\n(0, _chai.expect)(assetInfos[1].valDebt).to.equal(0);\n(0, _chai.expect)(assetInfos[1].amountDebt).to.equal(0);\n// KISS debt is issued\nconst expectedKissDebtValue = (0, _values.toBig)(swapValue, 8).sub(krAssetOutFirstSwapValue);\n(0, _chai.expect)(assetInfos[0].valDebt).to.equal(expectedKissDebtValue);\n(0, _chai.expect)(assetInfos[0].amountDebt).to.equal(expectedKissDebtValue.wadDiv(f.KISSPrice));\n// krAsset swap deposits\nconst expectedSwapDepositValue = (0, _values.toBig)(swapValue, 8).sub(krAssetOutFirstSwapValue);\n(0, _chai.expect)(assetInfos[1].amountSwapDeposit).to.equal((0, _values.toBig)(2).sub(krAssetOutFirstSwap));\n(0, _chai.expect)(assetInfos[1].valColl).to.equal(expectedSwapDepositValue) // asset price is $100\n;\nconst global = await hre.Diamond.getDataSCDP();\nconst expectedCollateralValue = (0, _values.toBig)(1000, 8).add(expectedSwapDepositValue);\n(0, _chai.expect)(global.totals.valColl).to.equal(expectedCollateralValue);\n(0, _chai.expect)(global.totals.valDebt).to.equal(expectedKissDebtValue);\n(0, _chai.expect)(global.totals.cr).to.equal(expectedCollateralValue.percentDiv(expectedKissDebtValue));",
"err": {},
- "uuid": "258463b5-adff-42a0-bbfe-06548bedbb15",
- "parentUUID": "99489778-5ce3-4570-9c60-a6104b9d6b2d",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "cumulates fees on swap",
- "fullTitle": "SCDP #Swap cumulates fees on swap",
- "timedOut": false,
- "duration": 985,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const depositAmountNew = (0, _values.toBig)(10000 - depositAmount);\nawait f.KISS.setBalance(f.depositor, depositAmountNew);\nawait f.KreskoDepositor.depositSCDP(f.depositor.address, f.KISS.address, depositAmountNew);\nconst swapAmount = (0, _values.toBig)(2600);\nconst feesBeforeSwap = await f.KreskoSwapper.getAccountFeesSCDP(f.depositor.address, f.KISS.address);\nawait f.KreskoSwapper.swapSCDP(f.swapper.address, f.KISS.address, f.KrAsset2.address, swapAmount, 0);\nconst feesAfterSwap = await f.KreskoSwapper.getAccountFeesSCDP(f.depositor.address, f.KISS.address);\n(0, _chai.expect)(feesAfterSwap).to.gt(feesBeforeSwap);\nawait f.KreskoSwapper.swapSCDP(f.swapper.address, f.KrAsset2.address, f.KISS.address, f.KrAsset2.balanceOf(f.swapper.address), 0);\nconst feesAfterSecondSwap = await f.KreskoSwapper.getAccountFeesSCDP(f.depositor.address, f.KISS.address);\n(0, _chai.expect)(feesAfterSecondSwap).to.gt(feesAfterSwap);\nawait f.KreskoDepositor.claimFeesSCDP(f.depositor.address, f.KISS.address);\nconst [depositsAfter, feesAfter] = await Promise.all([\n f.KreskoSwapper.getAccountDepositSCDP(f.depositor.address, f.KISS.address),\n f.KreskoSwapper.getAccountFeesSCDP(f.depositor.address, f.KISS.address)\n]);\n(0, _chai.expect)(feesAfter).to.eq(0);\n(0, _chai.expect)(depositsAfter).to.eq((0, _values.toBig)(10000));\nawait f.KreskoDepositor.withdrawSCDP(f.depositor.address, f.KISS.address, (0, _values.toBig)(10000));\nconst [depositsAfterWithdraw, feesAfterWithdraw] = await Promise.all([\n f.KreskoSwapper.getAccountDepositValueSCDP(f.depositor.address, f.KISS.address),\n f.KreskoSwapper.getAccountFeesSCDP(f.depositor.address, f.KISS.address)\n]);\n(0, _chai.expect)(depositsAfterWithdraw).to.eq(0);\n(0, _chai.expect)(feesAfterWithdraw).to.eq(0);",
- "err": {},
- "uuid": "727c370f-f105-4668-aabc-d523402f5f68",
- "parentUUID": "99489778-5ce3-4570-9c60-a6104b9d6b2d",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "3ba2b187-1e3c-474b-9219-3c8d80e855a1",
- "799308a6-1d82-446e-a23e-03a46ed3e365",
- "28bdcc8b-33b5-491d-b6cb-f060e7d873b2",
- "a7f74549-34c0-43b9-bd86-a688a977423f",
- "744033e0-2a98-4bc0-882f-60cceae33b8d",
- "258463b5-adff-42a0-bbfe-06548bedbb15",
- "727c370f-f105-4668-aabc-d523402f5f68"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 11111,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "94169623-e7e9-4e3b-bf3b-2ed9c7d70c35",
- "title": "#Liquidations",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/scdp/00-scdp.ts",
- "file": "/src/test/scdp/00-scdp.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"#Liquidations\"",
- "fullTitle": "SCDP #Liquidations \"before each\" hook in \"#Liquidations\"",
- "timedOut": false,
- "duration": 190,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "for (const signer of f.usersArr){\n await f.Collateral.setBalance(signer, (0, _values.toBig)(1_000_000));\n}\nawait f.KISS.setBalance(f.swapper, (0, _values.toBig)(10_000));\nawait f.KISS.setBalance(f.depositor2, (0, _values.toBig)(10_000));\nawait hre.Diamond.setFeeAssetSCDP(f.Collateral.address);\nawait f.KreskoDepositor.depositSCDP(f.depositor.address, f.Collateral.address, depositAmount18Dec);\nawait hre.Diamond.setFeeAssetSCDP(f.Collateral8Dec.address);\nawait f.KreskoDepositor.depositSCDP(f.depositor.address, f.Collateral8Dec.address, depositAmount8Dec);\nawait hre.Diamond.setFeeAssetSCDP(f.KISS.address);\nf.KreskoDepositor2.depositSCDP(f.depositor2.address, f.KISS.address, depositAmount18Dec);",
- "err": {},
- "uuid": "655b8c34-2753-4c6d-8ad0-96f8453294da",
- "parentUUID": "94169623-e7e9-4e3b-bf3b-2ed9c7d70c35",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [
- {
- "title": "should identify if the pool is not underwater",
- "fullTitle": "SCDP #Liquidations should identify if the pool is not underwater",
- "timedOut": false,
- "duration": 549,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const swapAmount = (0, _values.toBig)(2600) // $1\n;\nawait f.KreskoSwapper.swapSCDP(f.swapper.address, f.KISS.address, f.KrAsset2.address, swapAmount, 0);\n(0, _chai.expect)(await hre.Diamond.getLiquidatableSCDP()).to.be.false;",
- "err": {},
- "uuid": "47fdd713-4457-4728-9f96-87924af78707",
- "parentUUID": "94169623-e7e9-4e3b-bf3b-2ed9c7d70c35",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should revert liquidations if the pool is not underwater",
- "fullTitle": "SCDP #Liquidations should revert liquidations if the pool is not underwater",
- "timedOut": false,
- "duration": 771,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const swapAmount = (0, _values.toBig)(2600) // $1\n;\nawait f.KreskoSwapper.swapSCDP(f.swapper.address, f.KISS.address, f.KrAsset2.address, swapAmount, 0);\n(0, _chai.expect)(await hre.Diamond.getLiquidatableSCDP()).to.be.false;\nawait f.KrAsset2.setBalance(hre.users.liquidator, (0, _values.toBig)(1_000_000));\nawait (0, _chai.expect)(f.KreskoLiquidator.liquidateSCDP(f.KrAsset2.address, (0, _values.toBig)(7.7), f.Collateral8Dec.address)).to.be.revertedWithCustomError((0, _errors.Errors)(hre), 'COLLATERAL_VALUE_GREATER_THAN_REQUIRED');",
- "err": {},
- "uuid": "7837b1e2-081e-4bdb-bbd9-a2f5920a13e0",
- "parentUUID": "94169623-e7e9-4e3b-bf3b-2ed9c7d70c35",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should identify if the pool is underwater",
- "fullTitle": "SCDP #Liquidations should identify if the pool is underwater",
- "timedOut": false,
- "duration": 1356,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const swapAmount = (0, _values.toBig)(2600);\nawait f.KreskoSwapper.swapSCDP(f.swapper.address, f.KISS.address, f.KrAsset2.address, swapAmount, 0);\nf.Collateral.setPrice(f.CollateralPrice.num(8) / 1000);\nf.Collateral8Dec.setPrice(f.CollateralPrice.num(8) / 1000);\nconst [stats, liquidatable] = await Promise.all([\n hre.Diamond.getDataSCDP(),\n hre.Diamond.getLiquidatableSCDP()\n]);\n(0, _chai.expect)(stats.totals.cr).to.be.lt(stats.LT);\n(0, _chai.expect)(liquidatable).to.be.true;",
- "err": {},
- "uuid": "11cd067b-11ae-4ce4-af11-2f91a9ab28b1",
- "parentUUID": "94169623-e7e9-4e3b-bf3b-2ed9c7d70c35",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should allow liquidating the underwater pool",
- "fullTitle": "SCDP #Liquidations should allow liquidating the underwater pool",
- "timedOut": false,
- "duration": 4731,
- "state": "passed",
- "speed": "medium",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const swapAmount = (0, _values.toBig)(2600);\nawait f.KreskoSwapper.swapSCDP(f.swapper.address, f.KISS.address, f.KrAsset2.address, swapAmount, 0);\nconst newKreskoAssetPrice = 500;\nf.KrAsset2.setPrice(newKreskoAssetPrice);\nconst [scdpParams, maxLiquidatable, krAssetPrice, statsBefore] = await Promise.all([\n hre.Diamond.getParametersSCDP(),\n hre.Diamond.getMaxLiqValueSCDP(f.KrAsset2.address, f.Collateral8Dec.address),\n f.KrAsset2.getPrice(),\n hre.Diamond.getDataSCDP()\n]);\nconst repayAmount = maxLiquidatable.repayValue.wadDiv(krAssetPrice);\nawait f.KrAsset2.setBalance(hre.users.liquidator, repayAmount.add(1e18.toString()));\n(0, _chai.expect)(statsBefore.totals.cr).to.lt(scdpParams.liquidationThreshold);\n(0, _chai.expect)(statsBefore.totals.cr).to.gt(1e4);\n// Liquidate the shared CDP\nconst tx = await f.KreskoLiquidator.liquidateSCDP(f.KrAsset2.address, repayAmount, f.Collateral8Dec.address);\n// Check the state after liquidation\nconst [statsAfter, liquidatableAfter] = await Promise.all([\n hre.Diamond.getDataSCDP(),\n hre.Diamond.getLiquidatableSCDP()\n]);\n(0, _chai.expect)(statsAfter.totals.cr).to.gt(scdpParams.liquidationThreshold);\n(0, _chai.expect)(statsAfter.totals.crOgAdj).to.eq(2.01e4);\n(0, _chai.expect)(liquidatableAfter).to.eq(false);\n// Shared CDP should not be liquidatable since it is above the threshold\nawait (0, _chai.expect)(f.KreskoLiquidator.liquidateSCDP(f.KrAsset2.address, repayAmount, f.Collateral8Dec.address)).to.be.revertedWithCustomError((0, _errors.Errors)(hre), 'COLLATERAL_VALUE_GREATER_THAN_REQUIRED');\n// Check what was emitted in the event\nconst event = await (0, _events.getNamedEvent)(tx, 'SCDPLiquidationOccured');\nconst expectedSeizeAmount = repayAmount.wadMul((0, _values.toBig)(newKreskoAssetPrice, 8)).percentMul(1.05e4).wadDiv(f.CollateralPrice).div(10 ** 10);\n(0, _chai.expect)(event.args.liquidator).to.eq(hre.users.liquidator.address);\n(0, _chai.expect)(event.args.seizeAmount).to.eq(expectedSeizeAmount);\n(0, _chai.expect)(event.args.repayAmount).to.eq(repayAmount);\n(0, _chai.expect)(event.args.seizeCollateral).to.eq(f.Collateral8Dec.address);\n(0, _chai.expect)(event.args.repayKreskoAsset).to.eq(f.KrAsset2.address);\n// Check account state changes\nconst expectedDepositsAfter = depositAmount8Dec.sub(event.args.seizeAmount);\n(0, _chai.expect)(expectedDepositsAfter).to.be.lt(depositAmount8Dec);\nconst [principalDeposits, fees, params] = await Promise.all([\n hre.Diamond.getAccountDepositSCDP(f.depositor.address, f.Collateral8Dec.address),\n hre.Diamond.getAccountFeesSCDP(f.depositor.address, f.Collateral8Dec.address),\n hre.Diamond.getParametersSCDP()\n]);\n(0, _chai.expect)(principalDeposits).to.eq(expectedDepositsAfter);\n(0, _chai.expect)(fees).to.eq(0);\n// Sanity checking that users should be able to withdraw what is left\nawait hre.Diamond.setFeeAssetSCDP(f.Collateral.address);\nawait f.KreskoDepositor.depositSCDP(f.depositor.address, f.Collateral.address, depositAmount18Dec.mul(10));\nconst stats = await hre.Diamond.getDataSCDP();\n(0, _chai.expect)(stats.totals.cr).to.gt(params.minCollateralRatio);\nawait (0, _chai.expect)(f.KreskoDepositor.withdrawSCDP(f.depositor.address, f.Collateral8Dec.address, expectedDepositsAfter)).to.not.be.reverted;\nconst [principalEnd, feesAfter] = await Promise.all([\n hre.Diamond.getAccountDepositSCDP(f.depositor.address, f.Collateral8Dec.address),\n hre.Diamond.getAccountFeesSCDP(f.depositor.address, f.Collateral8Dec.address)\n]);\n(0, _chai.expect)(principalEnd).to.eq(0);\n(0, _chai.expect)(feesAfter).to.eq(0);",
- "err": {},
- "uuid": "ac6d64a2-d923-4971-979e-fca58c9f992f",
- "parentUUID": "94169623-e7e9-4e3b-bf3b-2ed9c7d70c35",
- "isHook": false,
- "skipped": false
- }
- ],
- "suites": [],
- "passes": [
- "47fdd713-4457-4728-9f96-87924af78707",
- "7837b1e2-081e-4bdb-bbd9-a2f5920a13e0",
- "11cd067b-11ae-4ce4-af11-2f91a9ab28b1",
- "ac6d64a2-d923-4971-979e-fca58c9f992f"
- ],
- "failures": [],
- "pending": [],
- "skipped": [],
- "duration": 7407,
- "root": false,
- "rootEmpty": false,
- "_timeout": 30000
- },
- {
- "uuid": "fb05d770-2ad9-458f-b53d-e9a048288476",
- "title": "#Error",
- "fullFile": "/Users/panukettunen/projects/kresko-protocol/src/test/scdp/00-scdp.ts",
- "file": "/src/test/scdp/00-scdp.ts",
- "beforeHooks": [
- {
- "title": "\"before each\" hook in \"#Error\"",
- "fullTitle": "SCDP #Error \"before each\" hook in \"#Error\"",
- "timedOut": false,
- "duration": 156,
- "state": null,
- "speed": null,
- "pass": false,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "await Promise.all(f.usersArr.map((signer)=>f.Collateral.setBalance(signer, (0, _values.toBig)(1_000_000))));\nawait f.KISS.setBalance(f.swapper, (0, _values.toBig)(10_000));\nawait f.KISS.setBalance(f.depositor, hre.ethers.BigNumber.from(1));\nawait hre.Diamond.setFeeAssetSCDP(f.Collateral.address);\nawait f.KreskoDepositor.depositSCDP(f.depositor.address, f.Collateral.address, depositAmount18Dec);\nawait hre.Diamond.setFeeAssetSCDP(f.KISS.address);\nawait f.KreskoDepositor.depositSCDP(f.depositor.address, f.KISS.address, 1);",
- "err": {},
- "uuid": "bcca6ecd-f055-4df0-bdcc-7b8c7e7c3aa1",
- "parentUUID": "fb05d770-2ad9-458f-b53d-e9a048288476",
- "isHook": true,
- "skipped": false
- }
- ],
- "afterHooks": [],
- "tests": [
- {
- "title": "should revert depositing unsupported tokens",
- "fullTitle": "SCDP #Error should revert depositing unsupported tokens",
- "timedOut": false,
- "duration": 113,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const [UnsupportedToken] = await hre.deploy('MockERC20', {\n args: [\n 'UnsupportedToken',\n 'UnsupportedToken',\n 18,\n (0, _values.toBig)(1)\n ]\n});\nawait UnsupportedToken.approve(hre.Diamond.address, hre.ethers.constants.MaxUint256);\nconst { deployer } = await hre.getNamedAccounts();\nawait (0, _chai.expect)(hre.Diamond.depositSCDP(deployer, UnsupportedToken.address, 1)).to.be.revertedWithCustomError((0, _errors.Errors)(hre), 'ASSET_NOT_FEE_ACCUMULATING_ASSET').withArgs([\n 'UnsupportedToken',\n UnsupportedToken.address\n]);",
- "err": {},
- "uuid": "7a38907c-2691-4b69-8f61-25023c29ecca",
- "parentUUID": "fb05d770-2ad9-458f-b53d-e9a048288476",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should revert withdrawing without deposits",
- "fullTitle": "SCDP #Error should revert withdrawing without deposits",
- "timedOut": false,
- "duration": 41,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const withdrawAmount = 1;\nconst principalDeposits = 0;\nconst scaledDeposits = 0;\nawait (0, _chai.expect)(f.KreskoSwapper.withdrawSCDP(f.depositor.address, f.Collateral.address, withdrawAmount)).to.be.revertedWithCustomError((0, _errors.Errors)(hre), 'NOTHING_TO_WITHDRAW').withArgs(f.swapper.address, f.Collateral.errorId, withdrawAmount, principalDeposits, scaledDeposits);",
- "err": {},
- "uuid": "d01c135f-9d19-4d62-b88c-af1d7697cf94",
- "parentUUID": "fb05d770-2ad9-458f-b53d-e9a048288476",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should revert withdrawals below MCR",
- "fullTitle": "SCDP #Error should revert withdrawals below MCR",
- "timedOut": false,
- "duration": 466,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const swapAmount = (0, _values.toBig)(1000) // $1000\n;\nawait f.KreskoSwapper.swapSCDP(f.swapper.address, f.KISS.address, f.KrAsset2.address, swapAmount, 0) // generates the debt\n;\nconst deposits = await f.KreskoSwapper.getAccountDepositSCDP(f.depositor.address, f.Collateral.address);\nawait (0, _chai.expect)(f.KreskoDepositor.withdrawSCDP(f.depositor.address, f.Collateral.address, deposits)).to.be.revertedWithCustomError((0, _errors.Errors)(hre), 'COLLATERAL_VALUE_LESS_THAN_REQUIRED').withArgs(960e8, 4800e8, 5e4);",
- "err": {},
- "uuid": "0663597e-b0a0-4760-9d95-56ae44763354",
- "parentUUID": "fb05d770-2ad9-458f-b53d-e9a048288476",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should revert withdrawals of swap owned collateral deposits",
- "fullTitle": "SCDP #Error should revert withdrawals of swap owned collateral deposits",
- "timedOut": false,
- "duration": 435,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const swapAmount = (0, _values.toBig)(1);\nawait f.KrAsset2.setBalance(f.swapper, swapAmount);\nawait f.KreskoSwapper.swapSCDP(f.swapper.address, f.KrAsset2.address, f.KISS.address, swapAmount, 0);\nconst deposits = await f.KreskoSwapper.getSwapDepositsSCDP(f.KrAsset2.address);\n(0, _chai.expect)(deposits).to.be.gt(0);\nawait (0, _chai.expect)(f.KreskoSwapper.withdrawSCDP(f.swapper.address, f.KrAsset2.address, deposits)).to.be.revertedWithCustomError((0, _errors.Errors)(hre), 'ASSET_DOES_NOT_HAVE_DEPOSITS').withArgs(f.KrAsset2.errorId);",
- "err": {},
- "uuid": "2319b1c6-da69-48e7-94ce-ec113ef98594",
- "parentUUID": "fb05d770-2ad9-458f-b53d-e9a048288476",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should revert swapping with price below minAmountOut",
- "fullTitle": "SCDP #Error should revert swapping with price below minAmountOut",
- "timedOut": false,
- "duration": 270,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const swapAmount = (0, _values.toBig)(1);\nawait f.KrAsset2.setBalance(f.swapper, swapAmount);\nconst [amountOut] = await f.KreskoSwapper.previewSwapSCDP(f.KrAsset2.address, f.KISS.address, swapAmount);\nawait (0, _chai.expect)(f.KreskoSwapper.swapSCDP(f.swapper.address, f.KrAsset2.address, f.KISS.address, swapAmount, amountOut.add(1))).to.be.revertedWithCustomError((0, _errors.Errors)(hre), 'RECEIVED_LESS_THAN_DESIRED').withArgs(f.KISS.errorId, amountOut, amountOut.add(1));",
- "err": {},
- "uuid": "39f56bfe-0c7f-4af2-8d41-f0171a422ed9",
- "parentUUID": "fb05d770-2ad9-458f-b53d-e9a048288476",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should revert swapping unsupported asset",
- "fullTitle": "SCDP #Error should revert swapping unsupported asset",
- "timedOut": false,
- "duration": 44,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const swapAmount = (0, _values.toBig)(1);\nawait f.KrAsset2.setBalance(f.swapper, swapAmount);\nawait (0, _chai.expect)(f.KreskoSwapper.swapSCDP(f.swapper.address, f.KrAsset2.address, f.Collateral.address, swapAmount, 0)).to.be.revertedWithCustomError((0, _errors.Errors)(hre), 'SWAP_ROUTE_NOT_ENABLED').withArgs(f.KrAsset2.errorId, f.Collateral.errorId);",
- "err": {},
- "uuid": "c2290c0a-d50b-462b-aad9-cf37ff8d32c4",
- "parentUUID": "fb05d770-2ad9-458f-b53d-e9a048288476",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should revert swapping a disabled route",
- "fullTitle": "SCDP #Error should revert swapping a disabled route",
- "timedOut": false,
- "duration": 83,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const swapAmount = (0, _values.toBig)(1);\nawait f.KrAsset2.setBalance(f.swapper, swapAmount);\nawait hre.Diamond.setSingleSwapRouteSCDP({\n assetIn: f.KrAsset2.address,\n assetOut: f.KISS.address,\n enabled: false\n});\nawait (0, _chai.expect)(f.KreskoSwapper.swapSCDP(f.swapper.address, f.KrAsset2.address, f.KISS.address, swapAmount, 0)).to.be.revertedWithCustomError((0, _errors.Errors)(hre), 'SWAP_ROUTE_NOT_ENABLED').withArgs(f.KrAsset2.errorId, f.KISS.errorId);",
- "err": {},
- "uuid": "9a1fb4ae-3294-4f13-91e2-cd786a02ce1a",
- "parentUUID": "fb05d770-2ad9-458f-b53d-e9a048288476",
- "isHook": false,
- "skipped": false
- },
- {
- "title": "should revert swapping causes CDP to go below MCR",
- "fullTitle": "SCDP #Error should revert swapping causes CDP to go below MCR",
- "timedOut": false,
- "duration": 332,
- "state": "passed",
- "speed": "fast",
- "pass": true,
- "fail": false,
- "pending": false,
- "context": null,
- "code": "const swapAmount = (0, _values.toBig)(1_500_000);\nawait f.KrAsset2.setBalance(f.swapper, swapAmount);\nconst tx = f.KreskoSwapper.swapSCDP(f.swapper.address, f.KrAsset2.address, f.KISS.address, swapAmount, 0);\nawait (0, _chai.expect)(tx).to.be.revertedWithCustomError((0, _errors.Errors)(hre), 'COLLATERAL_VALUE_LESS_THAN_REQUIRED').withArgs('15001000000000000', '75000000000000000', 5e4);",
- "err": {},
- "uuid": "ae5ed22b-5b0b-41d1-a5ec-2081d4c004e3",
- "parentUUID": "fb05d770-2ad9-458f-b53d-e9a048288476",
+ "uuid": "139821f8-7e7e-455c-95b0-51524468ed6b",
+ "parentUUID": "02070f8e-45c2-4cd2-a957-b1c39ec1adad",
"isHook": false,
"skipped": false
}
],
"suites": [],
"passes": [
- "7a38907c-2691-4b69-8f61-25023c29ecca",
- "d01c135f-9d19-4d62-b88c-af1d7697cf94",
- "0663597e-b0a0-4760-9d95-56ae44763354",
- "2319b1c6-da69-48e7-94ce-ec113ef98594",
- "39f56bfe-0c7f-4af2-8d41-f0171a422ed9",
- "c2290c0a-d50b-462b-aad9-cf37ff8d32c4",
- "9a1fb4ae-3294-4f13-91e2-cd786a02ce1a",
- "ae5ed22b-5b0b-41d1-a5ec-2081d4c004e3"
+ "139821f8-7e7e-455c-95b0-51524468ed6b"
],
"failures": [],
"pending": [],
"skipped": [],
- "duration": 1784,
+ "duration": 2861,
"root": false,
"rootEmpty": false,
"_timeout": 30000
diff --git a/src/contracts/core/common/Errors.sol b/src/contracts/core/common/Errors.sol
index ac3adee7..0734a7cb 100644
--- a/src/contracts/core/common/Errors.sol
+++ b/src/contracts/core/common/Errors.sol
@@ -23,6 +23,7 @@ library Errors {
error ADDRESS_HAS_NO_CODE(address);
error NOT_INITIALIZING();
+ error TO_WAD_AMOUNT_IS_NEGATIVE(int256);
error COMMON_ALREADY_INITIALIZED();
error MINTER_ALREADY_INITIALIZED();
error SCDP_ALREADY_INITIALIZED();
@@ -144,6 +145,7 @@ library Errors {
error NOTHING_TO_WITHDRAW(address who, ID, uint256 requested, uint256 principal, uint256 scaled);
error ACCOUNT_KRASSET_NOT_FOUND(address account, ID, address[] accountCollaterals);
error ACCOUNT_COLLATERAL_NOT_FOUND(address account, ID, address[] accountCollaterals);
+ error ARRAY_INDEX_OUT_OF_BOUNDS(ID element, uint256 index, address[] elements);
error ELEMENT_DOES_NOT_MATCH_PROVIDED_INDEX(ID element, uint256 index, address[] elements);
error NO_FEES_TO_CLAIM(ID asset, address claimer);
error REPAY_OVERFLOW(ID repayAsset, ID seizeAsset, uint256 invalid, uint256 valid);
diff --git a/src/contracts/core/common/Modifiers.sol b/src/contracts/core/common/Modifiers.sol
index c0bf0e88..89d32901 100644
--- a/src/contracts/core/common/Modifiers.sol
+++ b/src/contracts/core/common/Modifiers.sol
@@ -183,11 +183,11 @@ contract Modifiers {
}
/**
- * @notice Ensure only trusted contracts can act on behalf of `_account`
- * @param _accountIsNotMsgSender The address of the collateral asset.
+ * @notice Check for role if the condition is true.
+ * @param _shouldCheckRole Should be checking the role.
*/
- modifier onlyRoleIf(bool _accountIsNotMsgSender, bytes32 role) {
- if (_accountIsNotMsgSender) {
+ modifier onlyRoleIf(bool _shouldCheckRole, bytes32 role) {
+ if (_shouldCheckRole) {
Auth.checkRole(role);
}
_;
diff --git a/src/contracts/core/common/Validations.sol b/src/contracts/core/common/Validations.sol
index a247af14..4c83a6e7 100644
--- a/src/contracts/core/common/Validations.sol
+++ b/src/contracts/core/common/Validations.sol
@@ -325,7 +325,7 @@ library Validations {
) internal view {
if (_amount == 0) revert Errors.ZERO_AMOUNT(Errors.id(_collateralAsset));
if (_collateralIndex > self.depositedCollateralAssets[_account].length - 1)
- revert Errors.ELEMENT_DOES_NOT_MATCH_PROVIDED_INDEX(
+ revert Errors.ARRAY_INDEX_OUT_OF_BOUNDS(
Errors.id(_collateralAsset),
_collateralIndex,
self.depositedCollateralAssets[_account]
diff --git a/src/contracts/core/common/funcs/Actions.sol b/src/contracts/core/common/funcs/Actions.sol
index 3732868c..33fc0874 100644
--- a/src/contracts/core/common/funcs/Actions.sol
+++ b/src/contracts/core/common/funcs/Actions.sol
@@ -48,7 +48,7 @@ function burnSCDP(Asset storage _asset, uint256 _burnAmount, address _fromAddr)
/// @param _toAddr the account to mint the assets to
/// @return issued Normalized amount of minted assets.
function mintSCDP(Asset storage _asset, uint256 _mintAmount, address _toAddr) returns (uint256 issued) {
- if (!_asset.marketStatus()) revert Errors.MARKET_CLOSED(Errors.id(_asset.anchor), _asset.ticker.toString());
+ if (!_asset.isMarketOpen()) revert Errors.MARKET_CLOSED(Errors.id(_asset.anchor), _asset.ticker.toString());
issued = mintKrAsset(_mintAmount, _toAddr, _asset.anchor);
unchecked {
sdi().totalDebt += _asset.debtAmountToSDI(_mintAmount, false);
diff --git a/src/contracts/core/common/funcs/Assets.sol b/src/contracts/core/common/funcs/Assets.sol
index 89d8a8d7..c764ddd6 100644
--- a/src/contracts/core/common/funcs/Assets.sol
+++ b/src/contracts/core/common/funcs/Assets.sol
@@ -49,7 +49,7 @@ library Assets {
return Redstone.getPrice(self.ticker);
}
- function marketStatus(Asset storage) internal pure returns (bool) {
+ function isMarketOpen(Asset storage) internal pure returns (bool) {
return true;
}
diff --git a/src/contracts/core/common/funcs/Math.sol b/src/contracts/core/common/funcs/Math.sol
index 5722b8e3..09fd20d4 100644
--- a/src/contracts/core/common/funcs/Math.sol
+++ b/src/contracts/core/common/funcs/Math.sol
@@ -3,6 +3,7 @@ pragma solidity 0.8.21;
import {WadRay} from "libs/WadRay.sol";
import {PercentageMath} from "libs/PercentageMath.sol";
+import {Errors} from "common/Errors.sol";
using WadRay for uint256;
using PercentageMath for uint256;
@@ -47,6 +48,9 @@ function toWad(uint256 _amount, uint8 _decimals) pure returns (uint256) {
}
function toWad(int256 _amount, uint8 _decimals) pure returns (uint256) {
+ if (_amount < 0) {
+ revert Errors.TO_WAD_AMOUNT_IS_NEGATIVE(_amount);
+ }
return toWad(uint256(_amount), _decimals);
}
diff --git a/src/contracts/core/minter/facets/MinterMintFacet.sol b/src/contracts/core/minter/facets/MinterMintFacet.sol
index 0cfde043..9afd61b3 100644
--- a/src/contracts/core/minter/facets/MinterMintFacet.sol
+++ b/src/contracts/core/minter/facets/MinterMintFacet.sol
@@ -37,7 +37,7 @@ contract MinterMintFacet is IMinterMintFacet, Modifiers {
MinterState storage s = ms();
- if (!asset.marketStatus()) revert Errors.MARKET_CLOSED(Errors.id(_krAsset), asset.ticker.toString());
+ if (!asset.isMarketOpen()) revert Errors.MARKET_CLOSED(Errors.id(_krAsset), asset.ticker.toString());
uint256 newSupply = IKreskoAsset(_krAsset).totalSupply() + _mintAmount;
if (newSupply > asset.maxDebtMinter) {
diff --git a/src/contracts/core/periphery/DataV1.sol b/src/contracts/core/periphery/DataV1.sol
index 621f8b64..0e788a64 100644
--- a/src/contracts/core/periphery/DataV1.sol
+++ b/src/contracts/core/periphery/DataV1.sol
@@ -151,7 +151,7 @@ contract DataV1 is ProxyConnector, IDataV1 {
tSupply: asset.token.totalSupply(),
vSupply: asset.token.balanceOf(VAULT),
price: answer > 0 ? uint256(answer) : 0,
- marketStatus: answer > 0 ? true : false,
+ isMarketOpen: answer > 0 ? true : false,
oracleDecimals: asset.feed.decimals(),
priceRaw: RawPrice(
answer,
diff --git a/src/contracts/core/periphery/IDataV1.sol b/src/contracts/core/periphery/IDataV1.sol
index ebd2072a..e398f272 100644
--- a/src/contracts/core/periphery/IDataV1.sol
+++ b/src/contracts/core/periphery/IDataV1.sol
@@ -7,7 +7,7 @@ import {VaultAsset} from "vault/VTypes.sol";
interface IDataV1 {
struct DVAsset {
address addr;
- bool marketStatus;
+ bool isMarketOpen;
uint8 oracleDecimals;
string name;
string symbol;
diff --git a/src/contracts/core/periphery/PFuncs.sol b/src/contracts/core/periphery/PFuncs.sol
index d90c722c..140348bd 100644
--- a/src/contracts/core/periphery/PFuncs.sol
+++ b/src/contracts/core/periphery/PFuncs.sol
@@ -192,7 +192,7 @@ library PFunc {
name: token.name(),
tSupply: token.totalSupply(),
price: uint256(price.answer),
- marketStatus: asset.marketStatus(),
+ isMarketOpen: asset.isMarketOpen(),
priceRaw: price,
config: asset
});
diff --git a/src/contracts/core/periphery/PTypes.sol b/src/contracts/core/periphery/PTypes.sol
index 793c6e5e..c086b29b 100644
--- a/src/contracts/core/periphery/PTypes.sol
+++ b/src/contracts/core/periphery/PTypes.sol
@@ -95,7 +95,7 @@ library PType {
string symbol;
uint256 tSupply;
uint256 price;
- bool marketStatus;
+ bool isMarketOpen;
RawPrice priceRaw;
Asset config;
}
diff --git a/src/contracts/core/scdp/facets/SCDPSwapFacet.sol b/src/contracts/core/scdp/facets/SCDPSwapFacet.sol
index 554239d2..366dbb29 100644
--- a/src/contracts/core/scdp/facets/SCDPSwapFacet.sol
+++ b/src/contracts/core/scdp/facets/SCDPSwapFacet.sol
@@ -54,6 +54,7 @@ contract SCDPSwapFacet is ISCDPSwapFacet, Modifiers {
} else {
amountOut = assetIn.krAssetUSD(_amountIn).wadDiv(assetOut.price());
feeAmount = amountOut.percentMul(feePercentage);
+ amountOut = amountOut - feeAmount;
feeAmountProtocol = feeAmount.percentMul(protocolFee);
feeAmount -= feeAmountProtocol;
}