Skip to content

Commit

Permalink
Revert changing exchange rate for compound
Browse files Browse the repository at this point in the history
  • Loading branch information
Evert0x committed Dec 23, 2020
1 parent 9f17c2f commit 445ea95
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion contracts/test/MockCToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import "@openzeppelin/contracts/math/SafeMath.sol";
contract MockCToken is MockToken, ICToken {
using SafeMath for uint256;
// representable value taken from cEth
uint256 public exchangeRate = 200000000000000000000000000;
uint256 public exchangeRate = 1 ether / 5;
MockToken public underlying;
uint256 someValue;

Expand Down
70 changes: 35 additions & 35 deletions test/LendingManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import DiamondArtifact from "../artifacts/Diamond.json";

import TimeTraveler from "../utils/TimeTraveler";
import { parseEther, formatBytes32String } from "ethers/lib/utils";
import {
import {
MockAToken,
MockCToken,
MockToken,
Expand Down Expand Up @@ -141,7 +141,7 @@ describe("LendingManager", function() {
}

await pieFactory.setDefaultController(account);

const diamondImplementation = await(deployContract(signers[0], DiamondArtifact)) as Diamond;
diamondImplementation.initialize([], constants.AddressZero);
pieFactory.setDiamondImplementation(diamondImplementation.address);
Expand Down Expand Up @@ -197,46 +197,46 @@ describe("LendingManager", function() {
describe("Aave", async() => {
it("Lending less than max should work", async() => {
const lendAmount = mintAmount.div(2);

await lendingManager.lend(token.address, lendAmount, AAVE);

const tokens = await pie.getTokens();

expect(tokens.length).to.eq(2);
expect(tokens[0]).to.eq(token.address);
expect(tokens[1]).to.eq(aToken.address);

const tokenBalance = await token.balanceOf(pie.address);
const aTokenBalance = await aToken.balanceOf(pie.address);

expect(tokenBalance).to.eq(lendAmount);
expect(aTokenBalance).to.eq(lendAmount);
});
it("Lending the max should work", async() => {
await lendingManager.lend(token.address, mintAmount, AAVE);

const tokens = await pie.getTokens();

expect(tokens.length).to.eq(1);
expect(tokens[0]).to.eq(aToken.address);

const tokenBalance = await token.balanceOf(pie.address);
const aTokenBalance = await aToken.balanceOf(pie.address);

expect(tokenBalance).to.eq(0);
expect(aTokenBalance).to.eq(mintAmount);
});
it("Lending more than the max should lend the max", async() => {
await lendingManager.lend(token.address, mintAmount.add(parseEther("2")), AAVE);

const tokens = await pie.getTokens();

expect(tokens.length).to.eq(1);
expect(tokens[0]).to.eq(aToken.address);

const tokenBalance = await token.balanceOf(pie.address);
const aTokenBalance = await aToken.balanceOf(pie.address);

expect(tokenBalance).to.eq(0);
expect(aTokenBalance).to.eq(mintAmount);
});
Expand All @@ -245,44 +245,44 @@ describe("LendingManager", function() {
it("Lending less than the max should work", async() => {
const lendAmount = mintAmount.div(2);
await lendingManager.lend(token.address, lendAmount, COMPOUND);

const tokens = await pie.getTokens();

expect(tokens.length).to.eq(2);
expect(tokens[0]).to.eq(token.address);
expect(tokens[1]).to.eq(cToken.address);

const tokenBalance = await token.balanceOf(pie.address);
const cTokenBalance = await cToken.balanceOf(pie.address);

expect(tokenBalance).to.eq(lendAmount);
expect(cTokenBalance).to.eq(lendAmount.mul(5));
});
it("Lending the max should work", async() => {
await lendingManager.lend(token.address, mintAmount, COMPOUND);

const tokens = await pie.getTokens();

expect(tokens.length).to.eq(1);
expect(tokens[0]).to.eq(cToken.address);

const tokenBalance = await token.balanceOf(pie.address);
const cTokenBalance = await cToken.balanceOf(pie.address);

expect(tokenBalance).to.eq(0);
expect(cTokenBalance).to.eq(mintAmount.mul(5));
});
it("Lending more than the max should lend the max", async() => {
await lendingManager.lend(token.address, mintAmount.add(parseEther("2")), COMPOUND);

const tokens = await pie.getTokens();

expect(tokens.length).to.eq(1);
expect(tokens[0]).to.eq(cToken.address);

const tokenBalance = await token.balanceOf(pie.address);
const cTokenBalance = await cToken.balanceOf(pie.address);

expect(tokenBalance).to.eq(0);
expect(cTokenBalance).to.eq(mintAmount.mul(5));
});
Expand All @@ -298,7 +298,7 @@ describe("LendingManager", function() {
it("Unlending less than the max should work", async() => {
const unlendAmount = mintAmount.div(2);
await lendingManager.unlend(aToken.address, unlendAmount);

const tokens = await pie.getTokens();

expect(tokens.length).to.eq(2);
Expand Down Expand Up @@ -351,7 +351,7 @@ describe("LendingManager", function() {
it("Unlending less than the max should work", async() => {
const unlendAmount = mintAmount.div(2).mul(5);
await lendingManager.unlend(cToken.address, unlendAmount);

const tokens = await pie.getTokens();

expect(tokens.length).to.eq(2);
Expand Down Expand Up @@ -419,7 +419,7 @@ describe("LendingManager", function() {

const cTokenBalance = await cToken.balanceOf(pie.address);
const aTokenBalance = await aToken.balanceOf(pie.address);

expect(cTokenBalance).to.eq(bounceAmount);
expect(aTokenBalance).to.eq(mintAmount.div(2));
});
Expand All @@ -434,7 +434,7 @@ describe("LendingManager", function() {

const cTokenBalance = await cToken.balanceOf(pie.address);
const aTokenBalance = await aToken.balanceOf(pie.address);

expect(cTokenBalance).to.eq(0);
expect(aTokenBalance).to.eq(mintAmount);
});
Expand All @@ -449,7 +449,7 @@ describe("LendingManager", function() {

const cTokenBalance = await cToken.balanceOf(pie.address);
const aTokenBalance = await aToken.balanceOf(pie.address);

expect(cTokenBalance).to.eq(0);
expect(aTokenBalance).to.eq(mintAmount);
});
Expand All @@ -473,7 +473,7 @@ describe("LendingManager", function() {

const cTokenBalance = await cToken.balanceOf(pie.address);
const aTokenBalance = await aToken.balanceOf(pie.address);

expect(cTokenBalance).to.eq(cTokenAmount);
expect(aTokenBalance).to.eq(bounceAmount);
});
Expand All @@ -489,7 +489,7 @@ describe("LendingManager", function() {

const cTokenBalance = await cToken.balanceOf(pie.address);
const aTokenBalance = await aToken.balanceOf(pie.address);

expect(cTokenBalance).to.eq(cTokenAmount);
expect(aTokenBalance).to.eq(0);
});
Expand All @@ -505,7 +505,7 @@ describe("LendingManager", function() {

const cTokenBalance = await cToken.balanceOf(pie.address);
const aTokenBalance = await aToken.balanceOf(pie.address);

expect(cTokenBalance).to.eq(cTokenAmount);
expect(aTokenBalance).to.eq(0);
});
Expand Down
4 changes: 2 additions & 2 deletions test/lendingLogicCompound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ describe("LendingLogicCompound", function() {

it("exchangeRateView()", async() => {
const exchangeRate = await cToken.exchangeRateStored()
// 1 wrapped (8 decimals) = 0.02 (18 decimals)
expect(exchangeRate).to.eq(ethers.BigNumber.from("10").pow(26).mul(2))
// 1 wrapped (8 decimals) = 0.2 (8 decimals)
expect(exchangeRate).to.eq(ethers.BigNumber.from("10").pow(17).mul(2))
const exchangeRateLending = await lendingLogic.exchangeRateView(cToken.address);
expect(exchangeRate).to.eq(exchangeRateLending)
})
Expand Down

0 comments on commit 445ea95

Please sign in to comment.