Skip to content

Commit e7c95c2

Browse files
authored
Create Pool booster central registry and Merkl pool booster on Mainnet (#2676)
* add deployment file * improve test * prettier * correct market name * better name for CampaignCreator
1 parent c267e54 commit e7c95c2

9 files changed

Lines changed: 202 additions & 27 deletions

contracts/contracts/poolBooster/AbstractPoolBoosterFactory.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ contract AbstractPoolBoosterFactory is Governable {
1616
IPoolBoostCentralRegistry.PoolBoosterType boosterType;
1717
}
1818

19-
// @notice address of Origin Sonic
20-
address public immutable oSonic;
19+
// @notice address of Origin Token
20+
address public immutable oToken;
2121
// @notice Central registry contract
2222
IPoolBoostCentralRegistry public immutable centralRegistry;
2323

@@ -26,22 +26,22 @@ contract AbstractPoolBoosterFactory is Governable {
2626
// @notice mapping of AMM pool to pool booster
2727
mapping(address => PoolBoosterEntry) public poolBoosterFromPool;
2828

29-
// @param address _oSonic address of the OSonic token
29+
// @param address _oToken address of the OToken token
3030
// @param address _governor address governor
3131
// @param address _centralRegistry address of the central registry
3232
constructor(
33-
address _oSonic,
33+
address _oToken,
3434
address _governor,
3535
address _centralRegistry
3636
) {
37-
require(_oSonic != address(0), "Invalid oSonic address");
37+
require(_oToken != address(0), "Invalid oToken address");
3838
require(_governor != address(0), "Invalid governor address");
3939
require(
4040
_centralRegistry != address(0),
4141
"Invalid central registry address"
4242
);
4343

44-
oSonic = _oSonic;
44+
oToken = _oToken;
4545
centralRegistry = IPoolBoostCentralRegistry(_centralRegistry);
4646
_setGovernor(_governor);
4747
}

contracts/contracts/poolBooster/PoolBoosterFactoryMerkl.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ contract PoolBoosterFactoryMerkl is AbstractPoolBoosterFactory {
1818
event MerklDistributorUpdated(address newDistributor);
1919

2020
/**
21-
* @param _oSonic address of the OSonic token
21+
* @param _oToken address of the OToken token
2222
* @param _governor address governor
2323
* @param _centralRegistry address of the central registry
2424
* @param _merklDistributor address of the Merkl distributor
2525
*/
2626
constructor(
27-
address _oSonic,
27+
address _oToken,
2828
address _governor,
2929
address _centralRegistry,
3030
address _merklDistributor
31-
) AbstractPoolBoosterFactory(_oSonic, _governor, _centralRegistry) {
31+
) AbstractPoolBoosterFactory(_oToken, _governor, _centralRegistry) {
3232
_setMerklDistributor(_merklDistributor);
3333
}
3434

@@ -64,7 +64,7 @@ contract PoolBoosterFactoryMerkl is AbstractPoolBoosterFactory {
6464
abi.encodePacked(
6565
type(PoolBoosterMerkl).creationCode,
6666
abi.encode(
67-
oSonic,
67+
oToken,
6868
merklDistributor,
6969
_campaignDuration,
7070
_campaignType,
@@ -111,7 +111,7 @@ contract PoolBoosterFactoryMerkl is AbstractPoolBoosterFactory {
111111
abi.encodePacked(
112112
type(PoolBoosterMerkl).creationCode,
113113
abi.encode(
114-
oSonic,
114+
oToken,
115115
merklDistributor,
116116
_campaignDuration,
117117
_campaignType,

contracts/contracts/poolBooster/PoolBoosterFactoryMetropolis.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ contract PoolBoosterFactoryMetropolis is AbstractPoolBoosterFactory {
1313
address public immutable rewardFactory;
1414
address public immutable voter;
1515

16-
// @param address _oSonic address of the OSonic token
16+
// @param address _oToken address of the OToken token
1717
// @param address _governor address governor
1818
// @param address _centralRegistry address of the central registry
1919
// @param address _rewardFactory address of the Metropolis reward factory
2020
// @param address _voter address of the Metropolis voter
2121
constructor(
22-
address _oSonic,
22+
address _oToken,
2323
address _governor,
2424
address _centralRegistry,
2525
address _rewardFactory,
2626
address _voter
27-
) AbstractPoolBoosterFactory(_oSonic, _governor, _centralRegistry) {
27+
) AbstractPoolBoosterFactory(_oToken, _governor, _centralRegistry) {
2828
rewardFactory = _rewardFactory;
2929
voter = _voter;
3030
}
@@ -49,7 +49,7 @@ contract PoolBoosterFactoryMetropolis is AbstractPoolBoosterFactory {
4949
address poolBoosterAddress = _deployContract(
5050
abi.encodePacked(
5151
type(PoolBoosterMetropolis).creationCode,
52-
abi.encode(oSonic, rewardFactory, _ammPoolAddress, voter)
52+
abi.encode(oToken, rewardFactory, _ammPoolAddress, voter)
5353
),
5454
_salt
5555
);
@@ -83,7 +83,7 @@ contract PoolBoosterFactoryMetropolis is AbstractPoolBoosterFactory {
8383
_computeAddress(
8484
abi.encodePacked(
8585
type(PoolBoosterMetropolis).creationCode,
86-
abi.encode(oSonic, rewardFactory, _ammPoolAddress, voter)
86+
abi.encode(oToken, rewardFactory, _ammPoolAddress, voter)
8787
),
8888
_salt
8989
);

contracts/contracts/poolBooster/PoolBoosterFactorySwapxDouble.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ import { AbstractPoolBoosterFactory, IPoolBoostCentralRegistry } from "./Abstrac
1212
contract PoolBoosterFactorySwapxDouble is AbstractPoolBoosterFactory {
1313
uint256 public constant version = 1;
1414

15-
// @param address _oSonic address of the OSonic token
15+
// @param address _oToken address of the OToken token
1616
// @param address _governor address governor
1717
// @param address _centralRegistry address of the central registry
1818
constructor(
19-
address _oSonic,
19+
address _oToken,
2020
address _governor,
2121
address _centralRegistry
22-
) AbstractPoolBoosterFactory(_oSonic, _governor, _centralRegistry) {}
22+
) AbstractPoolBoosterFactory(_oToken, _governor, _centralRegistry) {}
2323

2424
/**
2525
* @dev Create a Pool Booster for SwapX Ichi vault based pool where 2 Bribe contracts need to be
@@ -49,7 +49,7 @@ contract PoolBoosterFactorySwapxDouble is AbstractPoolBoosterFactory {
4949
address poolBoosterAddress = _deployContract(
5050
abi.encodePacked(
5151
type(PoolBoosterSwapxDouble).creationCode,
52-
abi.encode(_bribeAddressOS, _bribeAddressOther, oSonic, _split)
52+
abi.encode(_bribeAddressOS, _bribeAddressOther, oToken, _split)
5353
),
5454
_salt
5555
);
@@ -92,7 +92,7 @@ contract PoolBoosterFactorySwapxDouble is AbstractPoolBoosterFactory {
9292
abi.encode(
9393
_bribeAddressOS,
9494
_bribeAddressOther,
95-
oSonic,
95+
oToken,
9696
_split
9797
)
9898
),

contracts/contracts/poolBooster/PoolBoosterFactorySwapxSingle.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ import { AbstractPoolBoosterFactory, IPoolBoostCentralRegistry } from "./Abstrac
1313
contract PoolBoosterFactorySwapxSingle is AbstractPoolBoosterFactory {
1414
uint256 public constant version = 1;
1515

16-
// @param address _oSonic address of the OSonic token
16+
// @param address _oToken address of the OToken token
1717
// @param address _governor address governor
1818
// @param address _centralRegistry address of the central registry
1919
constructor(
20-
address _oSonic,
20+
address _oToken,
2121
address _governor,
2222
address _centralRegistry
23-
) AbstractPoolBoosterFactory(_oSonic, _governor, _centralRegistry) {}
23+
) AbstractPoolBoosterFactory(_oToken, _governor, _centralRegistry) {}
2424

2525
/**
2626
* @dev Create a Pool Booster for SwapX classic volatile or classic stable pools where
@@ -45,7 +45,7 @@ contract PoolBoosterFactorySwapxSingle is AbstractPoolBoosterFactory {
4545
address poolBoosterAddress = _deployContract(
4646
abi.encodePacked(
4747
type(PoolBoosterSwapxSingle).creationCode,
48-
abi.encode(_bribeAddress, oSonic)
48+
abi.encode(_bribeAddress, oToken)
4949
),
5050
_salt
5151
);
@@ -81,7 +81,7 @@ contract PoolBoosterFactorySwapxSingle is AbstractPoolBoosterFactory {
8181
_computeAddress(
8282
abi.encodePacked(
8383
type(PoolBoosterSwapxSingle).creationCode,
84-
abi.encode(_bribeAddress, oSonic)
84+
abi.encode(_bribeAddress, oToken)
8585
),
8686
_salt
8787
);
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
const addresses = require("../../utils/addresses");
2+
const { deploymentWithGovernanceProposal } = require("../../utils/deploy");
3+
4+
module.exports = deploymentWithGovernanceProposal(
5+
{
6+
deployName: "152_pool_booster_setup",
7+
forceDeploy: false,
8+
reduceQueueTime: true,
9+
deployerIsProposer: false,
10+
proposalId: "",
11+
},
12+
async ({ deployWithConfirmation, withConfirmation }) => {
13+
const { deployerAddr } = await getNamedAccounts();
14+
const sDeployer = await ethers.provider.getSigner(deployerAddr);
15+
16+
const oethProxy = await ethers.getContract("OETHProxy");
17+
const oeth = await ethers.getContractAt("OETH", oethProxy.address);
18+
19+
// ---------------------------------------------------------------------------------------------------------
20+
// ---
21+
// --- Deploy PoolBoostCentralRegistry
22+
// ---
23+
// ---------------------------------------------------------------------------------------------------------
24+
25+
await deployWithConfirmation("PoolBoostCentralRegistryProxy");
26+
const cPoolBoostCentralRegistryProxy = await ethers.getContract(
27+
"PoolBoostCentralRegistryProxy"
28+
);
29+
30+
console.log(
31+
`Pool boost central registry proxy deployed: ${cPoolBoostCentralRegistryProxy.address}`
32+
);
33+
34+
const dPoolBoostCentralRegistry = await deployWithConfirmation(
35+
"PoolBoostCentralRegistry",
36+
[]
37+
);
38+
console.log(
39+
`Deployed Pool Boost Central Registry to ${dPoolBoostCentralRegistry.address}`
40+
);
41+
42+
const cPoolBoostCentralRegistry = await ethers.getContractAt(
43+
"PoolBoostCentralRegistry",
44+
cPoolBoostCentralRegistryProxy.address
45+
);
46+
47+
// prettier-ignore
48+
await withConfirmation(
49+
cPoolBoostCentralRegistryProxy
50+
.connect(sDeployer)["initialize(address,address,bytes)"](
51+
dPoolBoostCentralRegistry.address,
52+
addresses.mainnet.Timelock,
53+
"0x"
54+
)
55+
);
56+
console.log(
57+
"Initialized PoolBoostCentralRegistry proxy and implementation"
58+
);
59+
60+
// ---------------------------------------------------------------------------------------------------------
61+
// ---
62+
// --- Deploy PoolBoosterFactoryMerkl
63+
// ---
64+
// ---------------------------------------------------------------------------------------------------------
65+
const dPoolBoosterFactoryMerkl = await deployWithConfirmation(
66+
"PoolBoosterFactoryMerkl",
67+
[
68+
oeth.address,
69+
// so we can create a Merkl pool booster fast via a multichain strategist and kick off yield forwarding
70+
addresses.multichainStrategist,
71+
cPoolBoostCentralRegistryProxy.address,
72+
addresses.mainnet.CampaignCreator,
73+
]
74+
);
75+
const cPoolBoosterMerklFactory = await ethers.getContract(
76+
"PoolBoosterFactoryMerkl"
77+
);
78+
79+
console.log(
80+
`Pool Booster Merkl Factory deployed to ${cPoolBoosterMerklFactory.address}`
81+
);
82+
83+
return {
84+
name: "Upgrade PoolBoosterCentralRegistry and deploy PoolBoosterFactoryMerkl",
85+
actions: [
86+
{
87+
// set the factory as an approved one
88+
contract: cPoolBoostCentralRegistry,
89+
signature: "approveFactory(address)",
90+
args: [dPoolBoosterFactoryMerkl.address],
91+
},
92+
],
93+
};
94+
}
95+
);

contracts/test/_fixture.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const morphoLensAbi = require("./abi/morphoLens.json");
3838
const crvMinterAbi = require("./abi/crvMinter.json");
3939
const susdsAbi = require("./abi/sUSDS.json");
4040
const metamorphoAbi = require("./abi/metamorpho.json");
41+
const merklDistributorAbi = require("./abi/merklDistributor.json");
4142

4243
// const curveFactoryAbi = require("./abi/curveFactory.json")
4344
const ousdMetapoolAbi = require("./abi/ousdMetapool.json");
@@ -779,7 +780,10 @@ const defaultFixture = deployments.createFixture(async () => {
779780
mock1InchSwapRouter,
780781
convexEthMetaStrategy,
781782
vaultValueChecker,
782-
oethVaultValueChecker;
783+
oethVaultValueChecker,
784+
poolBoosterCentralRegistry,
785+
poolBoosterMerklFactory,
786+
merklDistributor;
783787

784788
if (isFork) {
785789
usdt = await ethers.getContractAt(usdtAbi, addresses.mainnet.USDT);
@@ -908,6 +912,21 @@ const defaultFixture = deployments.createFixture(async () => {
908912

909913
vaultValueChecker = await ethers.getContract("VaultValueChecker");
910914
oethVaultValueChecker = await ethers.getContract("OETHVaultValueChecker");
915+
916+
poolBoosterCentralRegistry = await ethers.getContractAt(
917+
"PoolBoostCentralRegistry",
918+
(
919+
await ethers.getContract("PoolBoostCentralRegistryProxy")
920+
).address
921+
);
922+
poolBoosterMerklFactory = await ethers.getContract(
923+
"PoolBoosterFactoryMerkl"
924+
);
925+
926+
merklDistributor = await ethers.getContractAt(
927+
merklDistributorAbi,
928+
addresses.mainnet.CampaignCreator
929+
);
911930
} else {
912931
usdt = await ethers.getContract("MockUSDT");
913932
usds = await ethers.getContract("MockUSDS");
@@ -1152,6 +1171,9 @@ const defaultFixture = deployments.createFixture(async () => {
11521171

11531172
morphoToken,
11541173
legacyMorphoToken,
1174+
poolBoosterCentralRegistry,
1175+
poolBoosterMerklFactory,
1176+
merklDistributor,
11551177
};
11561178
});
11571179

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
const { createFixtureLoader, defaultFixture } = require("../_fixture");
2+
const { expect } = require("chai");
3+
const { oethUnits } = require("../helpers");
4+
const addresses = require("../../utils/addresses");
5+
6+
const sonicFixture = createFixtureLoader(defaultFixture);
7+
8+
describe("ForkTest: Merkl Pool Booster", function () {
9+
//const INCENTIVISE_BORROWING_TYPE = 45;
10+
//const DEFAULT_DURATION = 86400 * 7; // a week
11+
//const MOPRHO_CAMPAIGN_DATA = "0xb8fef900b383db2dbbf4458c7f46acf5b140f26d603a6d1829963f241b82510e00000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
12+
13+
let fixture, poolBoosterMerklFactory, merklDistributor, oeth;
14+
beforeEach(async () => {
15+
fixture = await sonicFixture();
16+
oeth = fixture.oeth;
17+
poolBoosterMerklFactory = fixture.poolBoosterMerklFactory;
18+
merklDistributor = fixture.merklDistributor;
19+
});
20+
21+
it("Should have correct deployment params", async () => {
22+
expect(await poolBoosterMerklFactory.merklDistributor()).to.equal(
23+
addresses.mainnet.CampaignCreator
24+
);
25+
26+
// Uncomment once the pool booster is deployed
27+
// const poolBooster = await poolBoosterMerklFactory.poolBoosters(0)
28+
// expect(await poolBooster.campaignType()).to.equal(
29+
// INCENTIVISE_BORROWING_TYPE
30+
// );
31+
32+
// expect(await poolBooster.duration()).to.equal(
33+
// DEFAULT_DURATION
34+
// );
35+
36+
// expect(await poolBooster.campaignData()).to.equal(
37+
// MOPRHO_CAMPAIGN_DATA
38+
// );
39+
40+
// expect(await poolBooster.rewardToken()).to.equal(oeth.address);
41+
// expect(await poolBooster.merklDistributor()).to.equal(merklDistributor.address);
42+
});
43+
44+
it("Should have OETH token supported by Merkl Distributor", async () => {
45+
expect(await merklDistributor.rewardTokenMinAmounts(oeth.address)).to.equal(
46+
oethUnits("0.00001")
47+
);
48+
});
49+
});

0 commit comments

Comments
 (0)