Skip to content

Commit

Permalink
Add logic for bigger address on uni fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiovb committed Nov 28, 2023
1 parent 3c7745c commit bebfa97
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 27 deletions.
2 changes: 1 addition & 1 deletion hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module.exports = {
},
],
},
defaultNetwork: "localFunctionsTestnet",
// defaultNetwork: "localFunctionsTestnet",
networks: {
...networks,
},
Expand Down
32 changes: 20 additions & 12 deletions test/common/allFixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ async function deployUniPoolFixture(deployer, drexToken, tselicToken) {
nativeCurrencyLabelBytes
)
await nonfungibleTokenPositionDescriptor.deployed()

const NonfungiblePositionManager = new ethers.ContractFactory(
artifacts.NonfungiblePositionManager.abi,
artifacts.NonfungiblePositionManager.bytecode,
Expand All @@ -149,28 +148,30 @@ async function deployUniPoolFixture(deployer, drexToken, tselicToken) {
nonfungibleTokenPositionDescriptor.address
)
await nonfungiblePositionManager.deployed()

endereco1 = drexToken.address
endereco2 = tselicToken.address
if (tselicToken.address > drexToken.address) {
endereco1 = tselicToken.address
endereco2 = drexToken.address
}
await nonfungiblePositionManager
.connect(deployer)
.createAndInitializePoolIfNecessary(
tselicToken.address,
drexToken.address,
endereco2,
endereco1,
3000,
encodePriceSqrt(13991000000, 1000000000000000000),
{ gasLimit: 5000000 }
)

const poolAddress = await uniFactory
.connect(deployer)
.getPool(tselicToken.address, drexToken.address, 3000)

tselicToken
.connect(deployer)
.approve(nonfungiblePositionManager.address, ethers.utils.parseUnits("1000000", 18))
drexToken
.connect(deployer)
.approve(nonfungiblePositionManager.address, ethers.utils.parseUnits("1000000", 6))

const poolContract = new ethers.Contract(
poolAddress,
artifacts.UniswapV3Pool.abi,
Expand All @@ -180,7 +181,6 @@ async function deployUniPoolFixture(deployer, drexToken, tselicToken) {

const TselicToken = new Token(1337, tselicToken.address, 18, "TSELIC29", "TESOURO SELIC 2029")
const DrexToken = new Token(1337, drexToken.address, 6, "DREX", "Real Digital X")

const pool = new Pool(
TselicToken,
DrexToken,
Expand All @@ -189,7 +189,6 @@ async function deployUniPoolFixture(deployer, drexToken, tselicToken) {
poolData.liquidity.toString(),
poolData.tick
)

const position = new Position({
pool: pool,
liquidity: ethers.utils.parseEther("1"),
Expand All @@ -198,10 +197,19 @@ async function deployUniPoolFixture(deployer, drexToken, tselicToken) {
tickUpper:
nearestUsableTick(poolData.tick, poolData.tickSpacing) + poolData.tickSpacing * 2,
})
const { amount0: amount0Desired, amount1: amount1Desired } = position.mintAmounts
let { amount0: amount0Desired, amount1: amount1Desired } = position.mintAmounts
token1addr = drexToken.address
token0addr = tselicToken.address
if (tselicToken.address > drexToken.address) {
amount0Desired = amount1Desired
amount1Desired = amount0Desired
token1addr = tselicToken.address
token0addr = drexToken.address
}

params = {
token0: tselicToken.address,
token1: drexToken.address,
token0: token0addr,
token1: token1addr,
fee: poolData.fee,
tickLower:
nearestUsableTick(poolData.tick, poolData.tickSpacing) - poolData.tickSpacing * 2,
Expand Down
30 changes: 16 additions & 14 deletions test/rBRLLPool.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { time, loadFixture } = require("@nomicfoundation/hardhat-network-helpers")
const { ethers } = require("hardhat")
// const { ethers } = require("hardhat")
const { expect } = require("chai")

const {
Expand Down Expand Up @@ -37,14 +37,16 @@ describe("rBRLLPool", function () {
let mockMinter

beforeEach("load fixture", async () => {
// const provider = new ethers.providers.JsonRpcProvider("http://localhost:8545")
// ethers.provider = provider
;[admin, deployer, drexInvestor, tselicInvestor, feeCollector] = await ethers.getSigners()
// deploy tokens
;({ drexToken, tselicToken } = await deployTokensFixture(
deployer,
drexInvestor,
tselicInvestor
))
;({ selicUniPool } = await deployUniPoolFixture(deployer, drexToken, tselicToken))
// deploy tokens
; ({ drexToken, tselicToken } = await deployTokensFixture(
deployer,
drexInvestor,
tselicInvestor
))
; ({ selicUniPool } = await deployUniPoolFixture(deployer, drexToken, tselicToken))
// ; ({ priceFeed } = await deployMockPriceFeedFixture(deployer))
// ; ({ mockMinter } = await deployMockMinter(deployer, stbtToken, mxpRedeemPool))
// ; ({ rustpool } = await deployrUSTPoolFixture(admin, deployer, stbtToken, usdcToken))
Expand Down Expand Up @@ -92,12 +94,12 @@ describe("rBRLLPool", function () {
expect(true)
})

// it("Should fail if supply zero USDC", async function () {
// // await expect(rustpool.connect(usdcInvestor).supplyUSDC(0)).to.be.revertedWith(
// // "Supply USDC should more then 0."
// // )
// expect(true)
// })
it("Should fail if supply zero USDC", async function () {
// await expect(rustpool.connect(usdcInvestor).supplyUSDC(0)).to.be.revertedWith(
// "Supply USDC should more then 0."
// )
expect(true)
})
})
// describe("Supply STBT", function () {
// it("Should be able to supply", async function () {
Expand Down

0 comments on commit bebfa97

Please sign in to comment.