Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix workflow ubuntu version 2 #121

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Compile and test contracts
run: yarn compile && yarn test
scenario-tests:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Install Git
Expand Down
7 changes: 3 additions & 4 deletions contracts/partial/yToken/helpers.ligo
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ function calcMaxCollateralInCU(
verifyInterestUpdated(token);

(* sum += collateralFactorF * exchangeRate * oraclePrice * balance *)
acc := acc + userBalance * token.lastPrice
* token.collateralFactorF * liquidityF / token.totalSupplyF / precision;
acc := acc + userBalance * token.lastPrice * token.collateralFactorF * liquidityF / token.totalSupplyF / precision;
}
else skip;

Expand Down Expand Up @@ -156,10 +155,10 @@ function calcLiquidateCollateral(
verifyInterestUpdated(token);

(* sum += balance * oraclePrice * exchangeRate *)
acc := acc + userBalance * token.lastPrice * liquidityF / token.totalSupplyF;
acc := acc + userBalance * token.lastPrice * token.threshold * liquidityF / token.totalSupplyF / precision;
}
else skip;
} with acc * token.threshold / precision;
} with acc;
} with Set.fold(oneToken, userMarkets, 0n)

function applyInterestToBorrows(
Expand Down
27 changes: 27 additions & 0 deletions integration_tests/test_quick.py
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,33 @@ def test_withraw_admin_rewards(self):
with self.assertRaises(MichelsonRuntimeError):
chain.execute(self.ct.withdrawReserve(1, 1), sender=admin)

def test_multicollateral_liquidate(self):
chain = LocalChain(storage=self.storage)
config = {
"collateral_factor": 0.5,
"reserve_factor": 0.5,
"price": 100,
"liquidity": INITIAL_LIQUIDITY,
"threshold": 0.5,
"reserve_liquidation_rate": 0.05,
}
self.add_token(chain, token_a, config)
self.add_token(chain, token_b, config)
self.add_token(chain, token_c, config)

chain.execute(self.ct.mint(0, 100_000, 1))
chain.execute(self.ct.mint(1, 100_000, 1))
chain.execute(self.ct.enterMarket(0))
chain.execute(self.ct.enterMarket(1))

with self.assertRaises(MichelsonRuntimeError):
chain.execute(self.ct.borrow(2, 100_001, chain.now + 2))

chain.execute(self.ct.borrow(2, 100_000, chain.now + 2))

with self.assertRaises(MichelsonRuntimeError):
chain.execute(self.ct.liquidate(2, 0, me, 1, 1, chain.now + 2), sender=bob)

def test_real_world_liquidation(self):
price_a = 5244313
price_b = 56307584485
Expand Down
Loading