Skip to content

Commit

Permalink
dexe multiplier nft (#180)
Browse files Browse the repository at this point in the history
* dexe multiplier nft

* multiplier mock

* Update deploy/97_DEXEDAOMultiplier.migration.js

Co-authored-by: Artem Chystiakov <47551140+Arvolear@users.noreply.github.com>

* cosmetics

---------

Co-authored-by: Artem Chystiakov <47551140+Arvolear@users.noreply.github.com>
Co-authored-by: Artem Chystiakov <artem.ch31@gmail.com>
  • Loading branch information
3 people authored Nov 30, 2023
1 parent 6435c7d commit 5301a58
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 2 deletions.
5 changes: 4 additions & 1 deletion contracts/gov/ERC721/multipliers/DexeERC721Multiplier.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts/utils/math/Math.sol";

import "../../../interfaces/gov/ERC721/multipliers/IDexeERC721Multiplier.sol";
Expand All @@ -9,7 +10,7 @@ import "../../../libs/math/MathHelper.sol";

import "./AbstractERC721Multiplier.sol";

contract DexeERC721Multiplier is IDexeERC721Multiplier, AbstractERC721Multiplier {
contract DexeERC721Multiplier is IDexeERC721Multiplier, AbstractERC721Multiplier, UUPSUpgradeable {
using MathHelper for uint256;
using Math for uint256;

Expand Down Expand Up @@ -91,4 +92,6 @@ contract DexeERC721Multiplier is IDexeERC721Multiplier, AbstractERC721Multiplier
_multiplierSlashing[tokenId] = (_multiplierSlashing[tokenId] +
MULTIPLIER_SLASHING_PERCENTAGE).min(PERCENTAGE_100);
}

function _authorizeUpgrade(address newImplementation) internal override onlyOwner {}
}
10 changes: 10 additions & 0 deletions contracts/mock/gov/tokens/DexeERC721MultiplierMock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "../../../gov/ERC721/multipliers/DexeERC721Multiplier.sol";

contract DexeERC721MultiplierMock is DexeERC721Multiplier {
function getImplementation() external view returns (address) {
return _getImplementation();
}
}
16 changes: 16 additions & 0 deletions deploy/97_DEXEDAOMultiplier.migration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { Reporter } = require("@solarity/hardhat-migrate");

const ERC1967Proxy = artifacts.require("ERC1967Proxy");
const DexeMultiplier = artifacts.require("DexeERC721Multiplier");

module.exports = async (deployer) => {
let dexeMultiplier = await deployer.deploy(DexeMultiplier);
await deployer.deploy(ERC1967Proxy, [dexeMultiplier.address, "0x"], { name: "multiplierProxy" });

dexeMultiplier = await deployer.deployed(DexeMultiplier, "multiplierProxy");

await dexeMultiplier.__ERC721Multiplier_init("DeXe Multiplier NFT", "DEXE MULTNFT");
await dexeMultiplier.transferOwnership(deployer.dexeDaoAddress);

Reporter.reportContracts(["DEXE MULTIPLIER NFT", dexeMultiplier.address]);
};
27 changes: 26 additions & 1 deletion test/gov/ERC721/DexeERC721Multiplier.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const { PRECISION } = require("../../../scripts/utils/constants");
const Reverter = require("../../helpers/reverter");
const truffleAssert = require("truffle-assertions");

const DexeERC721Multiplier = artifacts.require("DexeERC721Multiplier");
const Proxy = artifacts.require("ERC1967Proxy");
const DexeERC721Multiplier = artifacts.require("DexeERC721MultiplierMock");
const GovPoolMock = artifacts.require("GovPoolMock");

DexeERC721Multiplier.numberFormat = "BigNumber";
Expand Down Expand Up @@ -59,6 +60,30 @@ describe("DexeERC721Multiplier", () => {
});
});

describe("upgradeability", () => {
beforeEach(async () => {
const proxy = await Proxy.new(nft.address, "0x");
dexeNft = await DexeERC721Multiplier.at(proxy.address);

dexeNft.__ERC721Multiplier_init(NFT_NAME, NFT_SYMBOL);
});

it("correct implementation", async () => {
assert.equal(await dexeNft.getImplementation(), nft.address);
});

it("not owner cant upgrade", async () => {
await truffleAssert.reverts(dexeNft.upgradeTo(nft.address, { from: SECOND }), "Ownable: caller is not the owner");
});

it("could upgrade", async () => {
const nft1 = await DexeERC721Multiplier.new();
await dexeNft.upgradeTo(nft1.address);

assert.equal(await dexeNft.getImplementation(), nft1.address);
});
});

describe("functionality", async () => {
beforeEach(async () => {
TOKENS = [
Expand Down

0 comments on commit 5301a58

Please sign in to comment.