Skip to content
Merged
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
22 changes: 0 additions & 22 deletions contracts/Greeter.sol

This file was deleted.

53 changes: 49 additions & 4 deletions contracts/HubPool.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,57 @@
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

contract HubPool {
// constructor() {}
import "@uma/core/contracts/common/implementation/Testable.sol";
import "@uma/core/contracts/common/implementation/Lockable.sol";
import "@uma/core/contracts/common/implementation/MultiCaller.sol";

function addLiquidity(address token, uint256 amount) public {}
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

interface WETH9Like {
function withdraw(uint256 wad) external;

function deposit() external payable;
}

contract HubPool is Testable, Lockable, MultiCaller, Ownable {
struct LPToken {
address lpToken;
bool isWeth;
bool isEnabled;
}

mapping(address => LPToken) public lpTokens; // Mapping of L1TokenAddress to the associated LPToken.

constructor(address timerAddress) Testable(timerAddress) {}

function removeLiquidity(address token, uint256 amount) public {}
/*************************************************
* ADMIN FUNCTIONS *
*************************************************/

// TODO: the two functions below should be called by the Admin contract.
function enableL1TokenForLiquidityProvision(
address l1Token,
bool isWeth,
string memory lpTokenName,
string memory lpTokenSymbol
) public onlyOwner {
ERC20 lpToken = new ERC20(lpTokenName, lpTokenSymbol);
lpTokens[l1Token] = LPToken({ lpToken: address(lpToken), isWeth: isWeth, isEnabled: true });
}

function disableL1TokenForLiquidityProvision(address l1Token) public onlyOwner {
lpTokens[l1Token].isEnabled = false;
}

// TODO: implement this. this will likely go into a separate Admin contract that contains all the L1->L2 Admin logic.
// function setTokenToAcceptDeposits(address token) public {}

/*************************************************
* LIQUIDITY PROVIDER FUNCTIONS *
*************************************************/

function addLiquidity(address token, uint256 amount) public {}

function exchangeRateCurrent(address token) public returns (uint256) {}

Expand Down
2 changes: 1 addition & 1 deletion contracts/SpokePool.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

contract HubPool {
contract SpokePool {
// constructor() {}

function deposit(
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
"type": "git",
"url": "git+https://github.com/across-protocol/across-smart-contracts-v2.git"
},
"dependencies": {},
"dependencies": {
"@openzeppelin/contracts": "^4.4.2",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why shouldn't these be dev dependencies?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made them normal dependencies because that's what we do in the V1 repo: https://github.com/across-protocol/across-smart-contracts/blob/master/package.json

"@uma/contracts-node": "^0.2.0",
"@uma/core": "^2.24.0"
},
"devDependencies": {
"@nomiclabs/hardhat-ethers": "^2.0.0",
"@nomiclabs/hardhat-etherscan": "^2.1.3",
Expand Down
20 changes: 20 additions & 0 deletions test/HubPool.LiquidityProvision.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { expect } from "chai";
import { Contract } from "ethers";
import { deployContract, MockProvider } from "ethereum-waffle";
import { getContract } from "./utils";

let hubPool: Contract;
let timer: Contract;

describe("HubPool LiquidityProvision", async function () {
const [owner] = new MockProvider().getWallets();

before(async function () {
timer = await deployContract(owner, await getContract("Timer"));

hubPool = await deployContract(owner, await getContract("HubPool"), [timer.address]);
});
it("Only owner can enable L1 Tokens for liquidity provision", async function () {
expect(await hubPool.callStatic.timerAddress()).to.equal(timer.address);
});
});
19 changes: 0 additions & 19 deletions test/index.ts

This file was deleted.

13 changes: 13 additions & 0 deletions test/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { getBytecode, getAbi } from "@uma/contracts-node";

import { ethers } from "hardhat";

export async function getContract(name: string): Promise<{ abi: any[]; bytecode: string }> {
try {
// Try fetch from the local ethers factory from HRE. If this exists then the contract is in this package.
const ethersFactory = await ethers.getContractFactory(name);
return { bytecode: ethersFactory.bytecode, abi: ethersFactory.interface as any };
} catch (error) { }
// If it does not exist then try find the contract in the UMA core package.
return { bytecode: getBytecode(name as any), abi: getAbi(name as any) };
}
Loading