9
9
v3PartyFactory ,
10
10
BNBPositionManager ,
11
11
BNBSwapRouter ,
12
- weth9 ,
12
+ wbnb ,
13
13
deployContracts ,
14
14
} from "./helper"
15
15
@@ -33,18 +33,18 @@ describe("Smart Router", function () {
33
33
tokenId = ( await BNBPositionManager . totalSupply ( ) ) . toString ( )
34
34
deadline = Math . floor ( Date . now ( ) / 1000 ) + 60 * 20 // 20 minutes from now
35
35
position = await BNBPositionManager . positions ( tokenId )
36
- MEME = position . token1 == ( await weth9 . getAddress ( ) ) ? position . token0 : position . token1
37
- lpAddress = await v3PartyFactory . getPool ( await weth9 . getAddress ( ) , MEME , FeeAmount . HIGH )
36
+ MEME = position . token1 == ( await wbnb . getAddress ( ) ) ? position . token0 : position . token1
37
+ lpAddress = await v3PartyFactory . getPool ( await wbnb . getAddress ( ) , MEME , FeeAmount . HIGH )
38
38
MEMEToken = await ethers . getContractAt ( "ERC20" , MEME )
39
39
await MEMEToken . approve ( await bnbPartyFactory . getAddress ( ) , ethers . parseEther ( "1000000" ) )
40
40
await MEMEToken . approve ( await BNBSwapRouter . getAddress ( ) , ethers . parseEther ( "10000000" ) )
41
41
} )
42
42
43
43
it ( "should increase wbnb on party lp after join party" , async ( ) => {
44
44
const amountIn = ethers . parseUnits ( "5" , 17 )
45
- const lpBalanceBefore = await weth9 . balanceOf ( lpAddress )
45
+ const lpBalanceBefore = await wbnb . balanceOf ( lpAddress )
46
46
await bnbPartyFactory . joinParty ( MEME , 0 , { value : amountIn } )
47
- const lpBalanceAfter = await weth9 . balanceOf ( lpAddress )
47
+ const lpBalanceAfter = await wbnb . balanceOf ( lpAddress )
48
48
expect ( lpBalanceAfter ) . to . be . equal ( lpBalanceBefore + amountIn )
49
49
} )
50
50
@@ -75,16 +75,16 @@ describe("Smart Router", function () {
75
75
it ( "should deacrease wbnb on party lp after leave party" , async ( ) => {
76
76
const amountIn = ethers . parseUnits ( "1" , 16 )
77
77
78
- const lpBalanceBefore = await weth9 . balanceOf ( lpAddress )
78
+ const lpBalanceBefore = await wbnb . balanceOf ( lpAddress )
79
79
await bnbPartyFactory . leaveParty ( MEME , amountIn , 0 )
80
- const lpBalanceAfter = await weth9 . balanceOf ( lpAddress )
80
+ const lpBalanceAfter = await wbnb . balanceOf ( lpAddress )
81
81
82
82
expect ( lpBalanceBefore ) . to . be . gt ( lpBalanceAfter )
83
83
} )
84
84
85
85
it ( "BNB -> WBNB -> MEME exactInput call" , async ( ) => {
86
86
const amountIn = ethers . parseUnits ( "1" , 18 )
87
- const path = getDataHexString ( await weth9 . getAddress ( ) , MEME )
87
+ const path = getDataHexString ( await wbnb . getAddress ( ) , MEME )
88
88
89
89
const params = {
90
90
path : path ,
@@ -95,16 +95,16 @@ describe("Smart Router", function () {
95
95
}
96
96
97
97
const balanceBefore = await MEMEToken . balanceOf ( await signers [ 0 ] . getAddress ( ) )
98
- await expect ( await BNBSwapRouter . exactInput ( params , { value : amountIn } ) ) . to . emit ( weth9 , "Deposit" )
98
+ await expect ( await BNBSwapRouter . exactInput ( params , { value : amountIn } ) ) . to . emit ( wbnb , "Deposit" )
99
99
const balanceAfter = await MEMEToken . balanceOf ( await signers [ 0 ] . getAddress ( ) )
100
100
101
101
expect ( balanceAfter ) . to . be . gt ( balanceBefore )
102
102
} )
103
103
104
104
it ( "MEME -> WBNB -> BNB multicall" , async function ( ) {
105
105
const amountIn = ethers . parseUnits ( "1" , 17 )
106
- const MEME = position . token1 == ( await weth9 . getAddress ( ) ) ? position . token0 : position . token1
107
- const path = getDataHexString ( MEME , await weth9 . getAddress ( ) )
106
+ const MEME = position . token1 == ( await wbnb . getAddress ( ) ) ? position . token0 : position . token1
107
+ const path = getDataHexString ( MEME , await wbnb . getAddress ( ) )
108
108
109
109
const params = {
110
110
path : path ,
@@ -121,19 +121,19 @@ describe("Smart Router", function () {
121
121
await signers [ 1 ] . getAddress ( ) ,
122
122
] )
123
123
const balanceBefore = await ethers . provider . getBalance ( await signers [ 1 ] . getAddress ( ) )
124
- await expect ( await BNBSwapRouter . multicall ( [ exactInputData , unwrapWETH9Data ] ) ) . to . emit ( weth9 , "Withdrawal" )
124
+ await expect ( await BNBSwapRouter . multicall ( [ exactInputData , unwrapWETH9Data ] ) ) . to . emit ( wbnb , "Withdrawal" )
125
125
const balanceAfter = await ethers . provider . getBalance ( await signers [ 1 ] . getAddress ( ) )
126
126
expect ( balanceAfter ) . to . be . gt ( balanceBefore )
127
127
} )
128
128
129
129
it ( "WBNB -> MEME exactInput call" , async ( ) => {
130
130
const amountIn = ethers . parseUnits ( "1" , 17 )
131
131
const amountOutMinimum = 0 // For testing, accept any amount out
132
- const path = getDataHexString ( await weth9 . getAddress ( ) , MEME )
132
+ const path = getDataHexString ( await wbnb . getAddress ( ) , MEME )
133
133
134
134
const deadline = Math . floor ( Date . now ( ) / 1000 ) + 60 * 20 // 20 minutes from now
135
- await weth9 . deposit ( { value : amountIn } )
136
- await weth9 . approve ( await BNBSwapRouter . getAddress ( ) , amountIn )
135
+ await wbnb . deposit ( { value : amountIn } )
136
+ await wbnb . approve ( await BNBSwapRouter . getAddress ( ) , amountIn )
137
137
138
138
const params = {
139
139
path : path ,
@@ -156,9 +156,9 @@ describe("Smart Router", function () {
156
156
await tx . wait ( )
157
157
const events = await bnbPartyFactory . queryFilter ( bnbPartyFactory . filters [ "StartParty(address,address,address)" ] )
158
158
const tokenAddress = events [ events . length - 1 ] . args . tokenAddress
159
- const lpAddress = await v3PartyFactory . getPool ( await weth9 . getAddress ( ) , tokenAddress , FeeAmount . HIGH )
159
+ const lpAddress = await v3PartyFactory . getPool ( await wbnb . getAddress ( ) , tokenAddress , FeeAmount . HIGH )
160
160
// check liquidity pool balance
161
- const liquidityPoolBalance = await weth9 . balanceOf ( lpAddress )
161
+ const liquidityPoolBalance = await wbnb . balanceOf ( lpAddress )
162
162
expect ( liquidityPoolBalance ) . to . be . equal ( amountIn - tokenCreationFee )
163
163
} )
164
164
0 commit comments