This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable camelcase */ | |
import { ethers, network } from 'hardhat' | |
import { Signer, Contract, constants, BigNumber } from 'ethers' | |
import { smock, FakeContract, MockContract } from '@defi-wonderland/smock' | |
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' | |
import { expect } from 'chai' | |
import { | |
REGISTRY_DEPLOY_TX, | |
REGISTRY_DEPLOYER_ADDRESS, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable camelcase */ | |
import { ethers, upgrades } from 'hardhat' | |
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' | |
import { AddressZero } from '@ethersproject/constants' | |
import { NON_NULL_BYTES32, NON_ZERO_ADDRESS } from './utils/constants' | |
import { expect } from 'chai' | |
import { ERROR_STRINGS } from './utils/errors' | |
import { deployL2Test, transferOwnershipTest } from './utils/fixtures' | |
import { L2ECO, L2ECOBridge, ProxyAdmin } from '../typechain-types' | |
const hre = require('hardhat') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable camelcase */ | |
import { ethers } from 'hardhat' | |
import { Signer, Contract, constants, BigNumber } from 'ethers' | |
import { smock, FakeContract, MockContract } from '@defi-wonderland/smock' | |
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' | |
import * as L1CrossDomainMessenger from '@eth-optimism/contracts/artifacts/contracts/L1/messaging/L1CrossDomainMessenger.sol/L1CrossDomainMessenger.json' | |
import * as L2CrossDomainMessenger from '@eth-optimism/contracts/artifacts/contracts/L2/messaging/L2CrossDomainMessenger.sol/L2CrossDomainMessenger.json' | |
import { expect } from 'chai' | |
import { | |
REGISTRY_DEPLOY_TX, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////note: a trader can maximally withdraw against temporary PnL and being liquidated instantly after with profits | |
////note: Two tests conditions below. The first test results in bad debts not covered. The second test trader maximally withdraw before and after liquidation with profits. | |
////note: This test is in the context of JOJO unit tet file- liquidation-test.ts-"check position" | |
////note: a trader can maximally withdraw against temporary PnL leaving bad debts | |
it("trader withdraw maximally against temporary PnL leaving bad debts", async () => { | |
////note: withdraw | |
await context.dealer | |
.connect(trader1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////note: trader may experience drastic loss at the point of order execution due to slippage | |
////note: This test is in the context of JoJo unit test file- liquidation-test.ts-"check position" | |
it("trader loss due to slippage and at brink of liquidation", async () => { | |
//note: test preparation so that trader1 starts a trade with sufficient deposits | |
//note: trader1 withdraw 5000-1885=3115 (1885 is calculated in trade-test.ts with transaction execution price of 29000) | |
await context.dealer | |
.connect(trader1) | |
.requestWithdraw(utils.parseEther("3115"), utils.parseEther("5000")); | |
await timeJump(100); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////Even with 0 collateral deposits, user can take on trades and protocol will acquire bad debts | |
////This test is in the context of JOJO unit test file -liquidation-test.ts-"check position" | |
it("free riding position liquidatable", async () => { | |
////note: test preparation to ensure trader1 has zero deposits to begin the trade | |
await context.dealer | |
.connect(trader1) | |
.requestWithdraw(utils.parseEther("5000"), utils.parseEther("5000")); | |
await timeJump(100); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: UNLICENSED | |
pragma solidity ^0.8.9; | |
import "./JUSDBankInit4.t.sol"; | |
import "../../src/utils/JUSDError.sol"; | |
import "../../src/oracle/UniswapPriceAdaptor.sol"; | |
import "../mocks/MockUniswapOracle.sol"; | |
import "../mocks/MockEmergencyOracle.sol"; | |
contract SecondaryOracleRevertsTest is JUSDBankInitTest { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: UNLICENSED | |
pragma solidity ^0.8.9; | |
import "./JUSDBankInit3.t.sol"; | |
import "../../src/utils/JUSDError.sol"; | |
import {DecimalMath} from "../../src/lib/DecimalMath.sol"; | |
/** | |
* @notice Key global and reserve settings such as borrowFeeRate, Reserve.liquidateMortgageRate and Reserve.initialMortgageRate not checked and reverted. | |
* This tests when borrowFeeRate is set high and when liquidateMortageRate is eqaul or too close to initialMortgageRate, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: UNLICENSED | |
pragma solidity ^0.8.9; | |
import "./JUSDBankInit.t.sol"; | |
import "../mocks/MockChainLink900.sol"; | |
import "../../src/utils/JUSDError.sol"; | |
import "../../src/Impl/flashloanImpl/FlashLoanLiquidate.sol"; | |
contract SelfLiquidateFlashLoanTest is JUSDBankInitTest { | |
/**When a borrower's account becomes unsafe, they can call flashloan function to self-liquidate the account, making a profit without |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: UNLICENSED | |
pragma solidity ^0.8.9; | |
import "./JUSDBankInit2.t.sol"; | |
import "../mocks/MockChainLink900.sol"; | |
import "../../src/utils/JUSDError.sol"; | |
import "../../src/Impl/flashloanImpl/FlashLoanLiquidate.sol"; | |
contract BorrowersInstantlyLiquidatedWhenReserveDelistedTest is | |
JUSDBankInitTest |
NewerOlder