From e975444eaf47df1b7089e5490ae5d17cdb8c1dfe Mon Sep 17 00:00:00 2001 From: Lifopam <45771448+Lifopam@users.noreply.github.com> Date: Mon, 21 Oct 2024 18:59:37 +0300 Subject: [PATCH 1/4] [Common] change algebraFeeRecipient address in deployment script --- src/core/scripts/deploy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/scripts/deploy.js b/src/core/scripts/deploy.js index 37786f53..f6cdee5c 100644 --- a/src/core/scripts/deploy.js +++ b/src/core/scripts/deploy.js @@ -41,7 +41,7 @@ async function main() { await setVaultTx.wait() // protocol fee settings - const algebraFeeRecipient = "0x1d8b6fa722230153be08c4fa4aa4b4c7cd01a95a" + const algebraFeeRecipient = "0x6cbd743d9b97DA1855E64893D3226F8eDCa16e76" const partnerAddress = "0xDeaD1F5aF792afc125812E875A891b038f888258" // owner address, must be changed const algebraFeeShare = 1000 // specified on algebraVault, 100% of community fee by default(3% of all fees) const defaultCommunityFee = 30 // 3% by default From 36f2c32b9c23bbf230d88cf1521f19771bfbb09b Mon Sep 17 00:00:00 2001 From: IliaAzhel Date: Fri, 25 Oct 2024 13:41:04 +0300 Subject: [PATCH 2/4] [Plugin] set default base fee 0.3% in sliding fee plugin --- src/plugin/contracts/BasePluginV2Factory.sol | 2 +- src/plugin/contracts/plugins/SlidingFeePlugin.sol | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugin/contracts/BasePluginV2Factory.sol b/src/plugin/contracts/BasePluginV2Factory.sol index 512d34c7..5de4a226 100644 --- a/src/plugin/contracts/BasePluginV2Factory.sol +++ b/src/plugin/contracts/BasePluginV2Factory.sol @@ -19,7 +19,7 @@ contract BasePluginV2Factory is IBasePluginV2Factory { address public override farmingAddress; /// @inheritdoc IBasePluginV2Factory - uint16 public override defaultBaseFee = 500; + uint16 public override defaultBaseFee = 3000; /// @inheritdoc IBasePluginV2Factory mapping(address poolAddress => address pluginAddress) public override pluginByPool; diff --git a/src/plugin/contracts/plugins/SlidingFeePlugin.sol b/src/plugin/contracts/plugins/SlidingFeePlugin.sol index a86a56a3..ae0fc32e 100644 --- a/src/plugin/contracts/plugins/SlidingFeePlugin.sol +++ b/src/plugin/contracts/plugins/SlidingFeePlugin.sol @@ -22,7 +22,7 @@ abstract contract SlidingFeePlugin is BasePlugin, ISlidingFeePlugin { FeeFactors public s_feeFactors; uint16 public s_priceChangeFactor = 1000; - uint16 public s_baseFee = 500; + uint16 public s_baseFee = 3000; constructor() { FeeFactors memory feeFactors = FeeFactors(uint128(1 << FEE_FACTOR_SHIFT), uint128(1 << FEE_FACTOR_SHIFT)); From 76edce144b5878fe050c29a54fbd5f6f31d1c9b3 Mon Sep 17 00:00:00 2001 From: IliaAzhel Date: Fri, 25 Oct 2024 13:45:02 +0300 Subject: [PATCH 3/4] [Plugin] set adaptive fee plugin as default --- src/farming/scripts/deploy.js | 4 ++-- src/plugin/scripts/deploy.js | 6 +++--- src/plugin/scripts/verify.js | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/farming/scripts/deploy.js b/src/farming/scripts/deploy.js index e0b2623b..3c897b6c 100644 --- a/src/farming/scripts/deploy.js +++ b/src/farming/scripts/deploy.js @@ -1,7 +1,7 @@ const hre = require('hardhat') const fs = require('fs') const path = require('path') -const BasePluginV2FactoryComplied = require('@cryptoalgebra/integral-base-plugin/artifacts/contracts/BasePluginV2Factory.sol/BasePluginV2Factory.json'); +const BasePluginV1FactoryComplied = require('@cryptoalgebra/integral-base-plugin/artifacts/contracts/BasePluginV1Factory.sol/BasePluginV1Factory.json'); async function main() { const deployDataPath = path.resolve(__dirname, '../../../deploys.json') @@ -26,7 +26,7 @@ async function main() { await (await AlgebraEternalFarming.setFarmingCenterAddress(FarmingCenter.target)).wait() console.log('Updated farming center address in eternal(incentive) farming') - const pluginFactory = await hre.ethers.getContractAt(BasePluginV2FactoryComplied.abi, deploysData.BasePluginV2Factory) + const pluginFactory = await hre.ethers.getContractAt(BasePluginV1FactoryComplied.abi, deploysData.BasePluginV1Factory) await (await pluginFactory.setFarmingAddress(FarmingCenter.target)).wait() console.log('Updated farming center address in plugin factory') diff --git a/src/plugin/scripts/deploy.js b/src/plugin/scripts/deploy.js index b64ac984..fa1ac5a9 100644 --- a/src/plugin/scripts/deploy.js +++ b/src/plugin/scripts/deploy.js @@ -7,8 +7,8 @@ async function main() { const deployDataPath = path.resolve(__dirname, '../../../deploys.json') const deploysData = JSON.parse(fs.readFileSync(deployDataPath, 'utf8')) - const BasePluginV2Factory = await hre.ethers.getContractFactory("BasePluginV2Factory"); - const dsFactory = await BasePluginV2Factory.deploy(deploysData.factory); + const BasePluginV1Factory = await hre.ethers.getContractFactory("BasePluginV1Factory"); + const dsFactory = await BasePluginV1Factory.deploy(deploysData.factory); await dsFactory.waitForDeployment() @@ -19,7 +19,7 @@ async function main() { await factory.setDefaultPluginFactory(dsFactory.target) console.log('Updated plugin factory address in factory') - deploysData.BasePluginV2Factory = dsFactory.target; + deploysData.BasePluginV1Factory = dsFactory.target; fs.writeFileSync(deployDataPath, JSON.stringify(deploysData), 'utf-8'); } diff --git a/src/plugin/scripts/verify.js b/src/plugin/scripts/verify.js index c9e38a23..3af76260 100644 --- a/src/plugin/scripts/verify.js +++ b/src/plugin/scripts/verify.js @@ -7,10 +7,10 @@ async function main() { const deployDataPath = path.resolve(__dirname, '../../../deploys.json'); let deploysData = JSON.parse(fs.readFileSync(deployDataPath, 'utf8')); - const BasePluginV2Factory = deploysData.BasePluginV2Factory; + const BasePluginV1Factory = deploysData.BasePluginV1Factory; await hre.run("verify:verify", { - address: BasePluginV2Factory, + address: BasePluginV1Factory, constructorArguments: [ deploysData.factory ], From 357ae6bc435530938764fa62222d8996303e2171 Mon Sep 17 00:00:00 2001 From: IliaAzhel Date: Thu, 5 Dec 2024 21:49:19 +0300 Subject: [PATCH 4/4] [Common] add create pool script --- src/periphery/contracts/test/TestToken.sol | 11 ++++ src/periphery/scripts/createPool.js | 72 ++++++++++++++++++++++ src/periphery/scripts/deployToken.js | 23 +++++++ 3 files changed, 106 insertions(+) create mode 100644 src/periphery/contracts/test/TestToken.sol create mode 100644 src/periphery/scripts/createPool.js create mode 100644 src/periphery/scripts/deployToken.js diff --git a/src/periphery/contracts/test/TestToken.sol b/src/periphery/contracts/test/TestToken.sol new file mode 100644 index 00000000..ebbdd0f0 --- /dev/null +++ b/src/periphery/contracts/test/TestToken.sol @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity =0.8.20; +pragma abicoder v1; + +import '@openzeppelin/contracts/token/ERC20/ERC20.sol'; + +contract TestToken is ERC20 { + constructor(uint256 amountToMint, string memory name, string memory symbol) ERC20(name, symbol) { + _mint(msg.sender, amountToMint); + } +} diff --git a/src/periphery/scripts/createPool.js b/src/periphery/scripts/createPool.js new file mode 100644 index 00000000..e28102fc --- /dev/null +++ b/src/periphery/scripts/createPool.js @@ -0,0 +1,72 @@ +const hre = require('hardhat'); +const fs = require('fs'); +const path = require('path'); +const { ethers } = require('ethers'); +const bn = require('bignumber.js'); +const AlgebraFactoryComplied = require('@cryptoalgebra/integral-core/artifacts/contracts/AlgebraFactory.sol/AlgebraFactory.json'); +const { ZeroAddress } = require('ethers'); + +async function main() { + const deployDataPath = path.resolve(__dirname, '../../../deploys.json'); + let deploysData = JSON.parse(fs.readFileSync(deployDataPath, 'utf8')); + + // WNativeTokenAddress + const token0 = '0x83D4a9Ea77a4dbA073cD90b30410Ac9F95F93E7C'; + const token1 = '0x91077c999344a0d5b2A745fA75403489EB374987'; + + const signer = await hre.ethers.provider.getSigner(); + const { abi: TestTokenAbi } = require('../../core/artifacts/contracts/test/TestERC20.sol/TestERC20.json'); + const { abi: WrapTokenAbi } = require('../artifacts/contracts/interfaces/external/IWNativeToken.sol/IWNativeToken.json'); + const testToken0 = new ethers.Contract(token0, TestTokenAbi, signer); + const testToken1 = new ethers.Contract(token1, WrapTokenAbi, signer); + + const tx0 = await testToken1.deposit({value: 5n * 10n ** 18n}); + await tx0.wait(); + + const tx1 = await testToken0.approve(deploysData.nonfungiblePositionManager, ethers.MaxUint256); + await tx1.wait(); + + const tx2 = await testToken1.approve(deploysData.nonfungiblePositionManager, ethers.MaxUint256); + await tx2.wait(); + + const { abi: NfTPosManagerAbi } = require('../artifacts/contracts/NonfungiblePositionManager.sol/NonfungiblePositionManager.json'); + const positionManager = new ethers.Contract(deploysData.nonfungiblePositionManager, NfTPosManagerAbi, signer); + + const tx3 = await positionManager.createAndInitializePoolIfNecessary(token0, token1, ZeroAddress, 2n ** 96n, '0x'); + await tx3.wait(); + + const mintParams = { + token0: token0, + token1: token1, + deployer: ZeroAddress, + tickLower: -887220, + tickUpper: 887220, + amount0Desired: 10n * 10n ** 18n, + amount1Desired: 5n * 10n ** 18n, + amount0Min: 0, + amount1Min: 0, + recipient: signer.address, + deadline: 2n ** 32n - 1n, + }; + + const mintResult = await positionManager.mint.staticCall(mintParams); + + const tx4 = await positionManager.mint(mintParams); + await tx4.wait(); + + const { abi: FactoryAbi } = require('../../core/artifacts/contracts/AlgebraFactory.sol/AlgebraFactory.json'); + const algebraFactory = new ethers.Contract(deploysData.factory, FactoryAbi, signer); + + const poolAddress = await algebraFactory.poolByPair.staticCall(token0, token1); + console.log(`Pool address: ${poolAddress}`); + console.log(`Liquidity minted, tokenId: ${mintResult.tokenId}`); +} + +// We recommend this pattern to be able to use async/await everywhere +// and properly handle errors. +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error); + process.exit(1); + }); diff --git a/src/periphery/scripts/deployToken.js b/src/periphery/scripts/deployToken.js new file mode 100644 index 00000000..394863d6 --- /dev/null +++ b/src/periphery/scripts/deployToken.js @@ -0,0 +1,23 @@ +const hre = require('hardhat'); +const ethers = require('ethers'); +const fs = require('fs'); +const path = require('path'); + +async function main() { + const TokenFactory = await hre.ethers.getContractFactory('TestToken'); + const tokenA = await TokenFactory.deploy(10n ** 25n, "USDC", "USDC"); + + const addressA = await tokenA.getAddress(); + + console.log(`token deployed to: ${addressA}`); + +} + +// We recommend this pattern to be able to use async/await everywhere +// and properly handle errors. +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error); + process.exit(1); + });