Skip to content

Commit

Permalink
init swap contract
Browse files Browse the repository at this point in the history
  • Loading branch information
clemsos committed May 21, 2024
1 parent 618a91e commit d5621bb
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
47 changes: 47 additions & 0 deletions smart-contracts/contracts/tokens/UP/UPSwap.sol
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 {}
}
40 changes: 40 additions & 0 deletions smart-contracts/test/UnlockProtocolToken/swap.js
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())
})
})
})

0 comments on commit d5621bb

Please sign in to comment.