Skip to content
This repository was archived by the owner on May 24, 2024. It is now read-only.

Commit ffed13f

Browse files
committed
clean up tests
1 parent 7325ec4 commit ffed13f

File tree

2 files changed

+34
-35
lines changed

2 files changed

+34
-35
lines changed

contracts/modules/Liquidation.sol

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,7 @@ contract Liquidation is BaseLogic {
126126
AssetConfig memory underlyingConfig;
127127

128128
collateralConfig = resolveAssetConfig(liqLocs.collateral);
129-
underlyingConfig = liqLocs.underlying == liqLocs.collateral
130-
? collateralConfig
131-
: resolveAssetConfig(liqLocs.underlying);
129+
underlyingConfig = resolveAssetConfig(liqLocs.underlying);
132130

133131
uint collateralFactor = collateralConfig.collateralFactor;
134132
uint borrowFactor = underlyingConfig.borrowFactor;

test/liquidation.js

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,7 @@ et.testSet({
851851

852852
.test({
853853
desc: "zero borrow factor with basic full liquidation",
854+
dev: 1,
854855
actions: ctx => [
855856
{ from: ctx.wallet2, send: 'dTokens.dTST.borrow', args: [0, et.eth(5)], },
856857

@@ -909,38 +910,38 @@ et.testSet({
909910
{ send: 'liquidation.liquidate', args: [ctx.wallet2.address, ctx.contracts.tokens.TST.address, ctx.contracts.tokens.TST2.address, () => ctx.stash.repay, 0], expectError: 'e/collateral-violation' },
910911

911912
// Successful liquidation on asset with zero borrow factor with deferred liquidity checks
912-
// {
913-
// action: 'sendBatch', batch: [
914-
// { send: 'liquidation.liquidate', args: [ctx.wallet2.address, ctx.contracts.tokens.TST.address, ctx.contracts.tokens.TST2.address, () => ctx.stash.repay, 0], },
915-
// { from: ctx.wallet, send: 'dTokens.dTST.repay', args: [0, ctx.stash.repay], },
916-
// ],
917-
// deferLiquidityChecks: [ctx.wallet.address],
918-
// },
919-
920-
// // liquidator:
921-
// // debt is repaid in batch transaction above
922-
// { call: 'dTokens.dTST.balanceOf', args: [ctx.wallet.address], equals: [0], },
923-
// { call: 'eTokens.eTST2.balanceOfUnderlying', args: [ctx.wallet.address], equals: () => [ctx.stash.yield, '0.000000000001'], },
924-
925-
// // reserves:
926-
// { call: 'eTokens.eTST.reserveBalanceUnderlying', onResult: (r) => ctx.stash.reserves = r, },
927-
928-
// // violator:
929-
// { call: 'dTokens.dTST.balanceOf', args: [ctx.wallet2.address], equals: () => [et.units(5).sub(ctx.stash.repay).add(ctx.stash.reserves), '0.000000000001'], },
930-
// { call: 'eTokens.eTST2.balanceOfUnderlying', args: [ctx.wallet2.address], equals: () => [et.units(100).sub(ctx.stash.yield), '0.000000000001'], },
931-
932-
933-
// // Confirming innocent bystander's balance not changed:
934-
935-
// { call: 'eTokens.eTST.balanceOfUnderlying', args: [ctx.wallet3.address], equals: [et.eth('30'), '0.000000000001'], },
936-
// { call: 'eTokens.eTST2.balanceOfUnderlying', args: [ctx.wallet3.address], equals: [et.eth('18'), '0.000000000001'], },
937-
938-
// {
939-
// call: 'exec.liquidity', args: [ctx.wallet2.address], onResult: async (r) => {
940-
// let targetHealth = (await ctx.contracts.liquidation.TARGET_HEALTH()) / 1e18;
941-
// et.equals(r.collateralFactor / r.liabilityValue, targetHealth, 1e-24);
942-
// }
943-
// },
913+
{
914+
action: 'sendBatch', batch: [
915+
{ send: 'liquidation.liquidate', args: [ctx.wallet2.address, ctx.contracts.tokens.TST.address, ctx.contracts.tokens.TST2.address, () => ctx.stash.repay, 0], },
916+
{ from: ctx.wallet, send: 'dTokens.dTST.repay', args: [0, () => ctx.stash.repay], },
917+
],
918+
deferLiquidityChecks: [ctx.wallet.address],
919+
},
920+
921+
// liquidator:
922+
// debt is repaid in batch transaction above
923+
{ call: 'dTokens.dTST.balanceOf', args: [ctx.wallet.address], equals: [0], },
924+
{ call: 'eTokens.eTST2.balanceOfUnderlying', args: [ctx.wallet.address], equals: () => [ctx.stash.yield, '0.000000000001'], },
925+
926+
// reserves:
927+
{ call: 'eTokens.eTST.reserveBalanceUnderlying', onResult: (r) => ctx.stash.reserves = r, },
928+
929+
// violator:
930+
{ call: 'dTokens.dTST.balanceOf', args: [ctx.wallet2.address], equals: () => [et.units(5).sub(ctx.stash.repay).add(ctx.stash.reserves), '0.000000000001'], },
931+
{ call: 'eTokens.eTST2.balanceOfUnderlying', args: [ctx.wallet2.address], equals: () => [et.units(100).sub(ctx.stash.yield), '0.000000000001'], },
932+
933+
934+
// Confirming innocent bystander's balance not changed:
935+
936+
{ call: 'eTokens.eTST.balanceOfUnderlying', args: [ctx.wallet3.address], equals: [et.eth('30'), '0.000000000001'], },
937+
{ call: 'eTokens.eTST2.balanceOfUnderlying', args: [ctx.wallet3.address], equals: [et.eth('18'), '0.000000000001'], },
938+
939+
{
940+
call: 'exec.liquidity', args: [ctx.wallet2.address], onResult: async (r) => {
941+
let targetHealth = (await ctx.contracts.liquidation.TARGET_HEALTH()) / 1e18;
942+
et.equals(r.collateralFactor / r.liabilityValue, targetHealth, 1e-24);
943+
}
944+
},
944945
],
945946
})
946947

0 commit comments

Comments
 (0)