-
-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.21; | ||
|
||
import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
import "@openzeppelin/contracts-upgradeable5/access/OwnableUpgradeable.sol"; | ||
import "@openzeppelin/contracts-upgradeable5/proxy/utils/Initializable.sol"; | ||
|
||
contract UPSwap is Initializable, OwnableUpgradeable { | ||
address public up; | ||
address public udt; | ||
|
||
/// @custom:oz-upgrades-unsafe-allow constructor | ||
constructor() { | ||
_disableInitializers(); | ||
} | ||
|
||
function initialize( | ||
address _up, | ||
address _udt, | ||
address initialOwner | ||
) public initializer { | ||
__Ownable_init(initialOwner); | ||
|
||
// store addresses | ||
up = _up; | ||
udt = _udt; | ||
} | ||
|
||
function swapUDTForUP( | ||
address sender, | ||
uint amount, | ||
address recipient | ||
) public {} | ||
|
||
function swapUPforUDT( | ||
address sender, | ||
uint amount, | ||
address recipient | ||
) public {} | ||
|
||
function swapUPForUDTWithSignature( | ||
address sender, | ||
uint amount, | ||
address recipient, | ||
bytes calldata signature | ||
) public {} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const { assert } = require('chai') | ||
const { ethers, upgrades } = require('hardhat') | ||
const { deployContracts } = require('../helpers') | ||
|
||
describe('UPSwap / swap UDT for UP', () => { | ||
let owner, preMinter | ||
let up, udt, swap | ||
|
||
before(async () => { | ||
;[owner, preMinter] = await ethers.getSigners() | ||
;({ udt } = await deployContracts()) | ||
|
||
const UP = await ethers.getContractFactory('UnlockProtocolToken') | ||
up = await upgrades.deployProxy(UP, [ | ||
await owner.getAddress(), | ||
await preMinter.getAddress(), | ||
]) | ||
|
||
const UPSwap = await ethers.getContractFactory('UPSwap') | ||
swap = await upgrades.deployProxy(UPSwap, [ | ||
await up.getAddress(), | ||
await udt.getAddress(), | ||
await owner.getAddress(), | ||
]) | ||
}) | ||
|
||
describe('settings', () => { | ||
it('udt is properly set', async () => { | ||
assert.equal(await swap.up(), await up.getAddress()) | ||
}) | ||
it('up is properly set', async () => { | ||
assert.equal(await swap.udt(), await udt.getAddress()) | ||
}) | ||
}) | ||
describe('ownership', () => { | ||
it('is properly set', async () => { | ||
assert.equal(await owner.getAddress(), await swap.owner()) | ||
}) | ||
}) | ||
}) |