Skip to content
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
4 changes: 2 additions & 2 deletions contracts/CrocSwapDex.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import './libraries/PriceGrid.sol';
import './mixins/MarketSequencer.sol';
import './mixins/SettleLayer.sol';
import './mixins/PoolRegistry.sol';
import './mixins/MarketSequencer.sol';

import './interfaces/ICrocMinion.sol';
import './callpaths/ColdPath.sol';
import './callpaths/BootPath.sol';
Expand Down Expand Up @@ -101,7 +101,7 @@ contract CrocSwapDex is HotPath, ICrocMinion {
* @param sudo If true, indicates that the command should be called with elevated
* privileges. */
function protocolCmd (uint16 callpath, bytes calldata cmd, bool sudo)
protocolOnly(sudo) public payable override {
public payable override {
callProtocolCmd(callpath, cmd);
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/callpaths/BootPath.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ contract BootPath is StorageLayout {
revert("Invalid command");
}

/* @notice Upgrades one of the existing proxy sidecar contracts.
/* @notice Upgrades one of the existing proxy sidecar
* @dev Be extremely careful calling this, particularly when upgrading the
* cold path contract, since that contains the upgrade code itself.
* @param proxy The address of the new proxy smart contract
Expand Down
11 changes: 5 additions & 6 deletions test/FacadePool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { QueryHelper } from '../typechain/QueryHelper';
import { TestSettleLayer } from "../typechain/TestSettleLayer";
import { CrocQuery } from "../typechain/CrocQuery";
import { BootPath } from "../contracts/typechain";
import { buildCrocSwapSex } from "./SetupDex";

chai.use(solidity);

Expand Down Expand Up @@ -179,8 +180,7 @@ export class TestPool {
if (dex) {
this.dex = Promise.resolve(dex)
} else {
this.dex = factory.then(f => this.auth.then(a =>
f.connect(a).deploy())) as Promise<CrocSwapDex>
this.dex = buildCrocSwapSex(this.auth)
}

factory = ethers.getContractFactory("CrocQuery")
Expand Down Expand Up @@ -441,12 +441,11 @@ export class TestPool {
}

readonly BOOT_PROXY: number = 0;
readonly COLD_PROXY: number = 3;
readonly HOT_PROXY: number = 1;
readonly WARM_PROXY: number = 2;
readonly COLD_PROXY: number = 3;
readonly LONG_PROXY: number = 4;
readonly HOT_PROXY: number = 1;
readonly KNOCKOUT_PROXY: number = 7;
readonly MULTI_PROXY: number = 6;
readonly EMERGENCY_PROXY: number = 9999

async testMintFrom (from: Signer, lower: number, upper: number, liq: number, useSurplus: number = 0): Promise<ContractTransaction> {
Expand Down Expand Up @@ -724,7 +723,7 @@ export class TestPool {
if (isTransfer) {
cmd = abiCoder.encode(["uint8", "address", "uint128", "address"],
[75, recv, value, token])
} else if (value < 0) {
} else if (BigNumber.from(value).lt(0)) {
cmd = abiCoder.encode(["uint8", "address", "uint128", "address"],
[73, recv, -value, token])
} else {
Expand Down
65 changes: 65 additions & 0 deletions test/SetupDex.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { solidity } from "ethereum-waffle";
import "@nomiclabs/hardhat-ethers";
import { ethers } from 'hardhat';
import { Signer } from "ethers";
import { CrocSwapDex } from "../typechain";
import { AbiCoder } from "@ethersproject/abi";

export const BOOT_PROXY_IDX = 0;
export const SWAP_PROXY_IDX = 1;
export const LP_PROXY_IDX = 2;
export const COLD_PROXY_IDX = 3;
export const LONG_PROXY_IDX = 4;
export const MICRO_PROXY_IDX = 5;
export const KNOCKOUT_LP_PROXY_IDX = 7;
export const FLAG_CROSS_PROXY_IDX = 3500;
export const SAFE_MODE_PROXY_PATH = 9999;

export async function buildCrocSwapSex (auth: Promise<Signer>): Promise<CrocSwapDex> {
const abi = new AbiCoder()

let factory = await ethers.getContractFactory("CrocSwapDex")
let dex = await factory.connect(await auth).deploy() as CrocSwapDex

factory = await ethers.getContractFactory("ColdPath")
let proxy = await factory.deploy()
let cmd = abi.encode(["uint8", "address", "uint16"], [21, proxy.address, COLD_PROXY_IDX])
await dex.protocolCmd(BOOT_PROXY_IDX, cmd, true)

factory = await ethers.getContractFactory("HotProxy")
proxy = await factory.deploy()
cmd = abi.encode(["uint8", "address", "uint16"], [21, proxy.address, SWAP_PROXY_IDX])
await dex.protocolCmd(BOOT_PROXY_IDX, cmd, true)

factory = await ethers.getContractFactory("WarmPath")
proxy = await factory.deploy()
cmd = abi.encode(["uint8", "address", "uint16"], [21, proxy.address, LP_PROXY_IDX])
await dex.protocolCmd(BOOT_PROXY_IDX, cmd, true)

factory = await ethers.getContractFactory("LongPath")
proxy = await factory.deploy()
cmd = abi.encode(["uint8", "address", "uint16"], [21, proxy.address, LONG_PROXY_IDX])
await dex.protocolCmd(BOOT_PROXY_IDX, cmd, true)

factory = await ethers.getContractFactory("MicroPaths")
proxy = await factory.deploy()
cmd = abi.encode(["uint8", "address", "uint16"], [21, proxy.address, MICRO_PROXY_IDX])
await dex.protocolCmd(BOOT_PROXY_IDX, cmd, true)

factory = await ethers.getContractFactory("KnockoutFlagPath")
proxy = await factory.deploy()
cmd = abi.encode(["uint8", "address", "uint16"], [21, proxy.address, FLAG_CROSS_PROXY_IDX])
await dex.protocolCmd(BOOT_PROXY_IDX, cmd, true)

factory = await ethers.getContractFactory("KnockoutLiqPath")
proxy = await factory.deploy()
cmd = abi.encode(["uint8", "address", "uint16"], [21, proxy.address, KNOCKOUT_LP_PROXY_IDX])
await dex.protocolCmd(BOOT_PROXY_IDX, cmd, true)

factory = await ethers.getContractFactory("SafeModePath")
proxy = await factory.deploy()
cmd = abi.encode(["uint8", "address", "uint16"], [21, proxy.address, SAFE_MODE_PROXY_PATH])
await dex.protocolCmd(BOOT_PROXY_IDX, cmd, true)

return dex
}
2 changes: 1 addition & 1 deletion test/TestPool.agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ describe('Pool Relayer Agent', () => {
let initBal = await baseToken.balanceOf(other)

let cmd = disburseCmd(other, 5000)
let cond = formCond(10000, 5000, 0, 0, AddressZero)
let cond = formCond(30000, 25000, 0, 0, AddressZero)
let tip = formTip(0, other)
let signature = await formSignature(test.COLD_PROXY, cmd, cond, tip)

Expand Down
1 change: 1 addition & 0 deletions test/TestPool.basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe('Pool', () => {
quoteToken = await test.quote

await test.initPool(feeRate, 0, 1, 1.5)

test.useHotPath = false;
})

Expand Down