Skip to content

Commit

Permalink
Merge branch 'integral-v1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
IliaAzhel committed Dec 16, 2024
2 parents 343d07d + 357ae6b commit 47dcc53
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/farming/scripts/deploy.js
Original file line number Diff line number Diff line change
@@ -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')
Expand All @@ -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')
Expand Down
11 changes: 11 additions & 0 deletions src/periphery/contracts/test/TestToken.sol
Original file line number Diff line number Diff line change
@@ -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);
}
}
72 changes: 72 additions & 0 deletions src/periphery/scripts/createPool.js
Original file line number Diff line number Diff line change
@@ -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);
});
23 changes: 23 additions & 0 deletions src/periphery/scripts/deployToken.js
Original file line number Diff line number Diff line change
@@ -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);
});
2 changes: 1 addition & 1 deletion src/plugin/contracts/BasePluginV2Factory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/plugin/contracts/plugins/SlidingFeePlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
6 changes: 3 additions & 3 deletions src/plugin/scripts/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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');

}
Expand Down
4 changes: 2 additions & 2 deletions src/plugin/scripts/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
],
Expand Down

0 comments on commit 47dcc53

Please sign in to comment.