diff --git a/test/fork/dao.test.js b/test/fork/dao.test.js index 15429c2..1e3c340 100644 --- a/test/fork/dao.test.js +++ b/test/fork/dao.test.js @@ -69,6 +69,9 @@ const FORWARDER_DELEGATE_VOTE_USER_DATA = const FORWARDER_STAKE_USER_DATA = // secretlint-disable-next-line '0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000ddb5f4535123daa5ae343c24006f4075abaf5f7b0000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000123456789012345678901234567890123456789000000000000000000000000dee8ebe2b7152eccd935fd67134bf1bad55302bc0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000dee8ebe2b7152eccd935fd67134bf1bad55302bc0000000000000000000000000000000000000000000000000162ea854d0fc0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000642b54f551000000000000000000000000ddb5f4535123daa5ae343c24006f4075abaf5f7b0000000000000000000000000000000000000000000000000162ea854d0fc0000000000000000000000000000000000000000000000000000000000000093a8000000000000000000000000000000000000000000000000000000000' +const FORWARDER_STAKE_USER_DATA_2 = + // secretlint-disable-next-line + '0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000ddb5f4535123daa5ae343c24006f4075abaf5f7b0000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000008805aa0c1a8e59b03fa95740f691e28942cf44f6000000000000000000000000dee8ebe2b7152eccd935fd67134bf1bad55302bc0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000dee8ebe2b7152eccd935fd67134bf1bad55302bc0000000000000000000000000000000000000000000000000b0bfa54806c1db90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000642b54f551000000000000000000000000ddb5f4535123daa5ae343c24006f4075abaf5f7b0000000000000000000000000000000000000000000000000b0bfa54806c1db90000000000000000000000000000000000000000000000000000000000093a8000000000000000000000000000000000000000000000000000000000' const WITHDRAW_INFLATION_FROM_GNOSIS_USER_DATA = // secretlint-disable-next-line '0x000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db80000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000443352d49b000000000000000000000000e0bfe5ae5cebbf666c381f267187379117d0da73000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db8000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000124c322525d000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b200000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000010000f1918e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a30783632333939363865363233313136343638374342343066383338396439333364443766376530413500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' @@ -791,6 +794,42 @@ describe('Integration tests on Gnosis deployment', () => { expect(await pntOnGnosis.balanceOf(STAKING_MANAGER)).to.be.eq(smBalance + ethers.parseUnits('0.0999')) }) + it('[dapp] should stake from forwarder call (2)', async () => { + expect(await daoPNT.balanceOf(USER_ADDRESS)).to.be.eq(ethers.parseUnits('0')) + const smBalance = await pntOnGnosis.balanceOf(STAKING_MANAGER) + const metadata = encodeMetadata(ethers, { + userData: + // secretlint-disable-next-line + FORWARDER_STAKE_USER_DATA_2, + sourceNetworkId: PNETWORK_NETWORK_IDS.POLYGON, + senderAddress: FORWARDER_ON_POLYGON, + destinationNetworkId: PNETWORK_NETWORK_IDS.GNOSIS, + receiverAddress: forwarder.target + }) + await expect( + mintPToken( + pntOnGnosis, + pntMinter, + forwarder.target, + (ethers.parseUnits('0.797999999999789996') * (1000000n - 2500n)) / 1000000n, + metadata + ) + ) + .to.emit(pntOnGnosis, 'Approval') + .withArgs( + forwarder.target, + stakingManager.target, + (ethers.parseUnits('0.797999999999789996') * (1000000n - 2500n)) / 1000000n + ) + .to.emit(stakingManager, 'Staked') + expect(await daoPNT.balanceOf(USER_ADDRESS)).to.be.eq( + (ethers.parseUnits('0.797999999999789996') * (1000000n - 2500n)) / 1000000n + ) + expect(await pntOnGnosis.balanceOf(STAKING_MANAGER)).to.be.eq( + smBalance + (ethers.parseUnits('0.797999999999789996') * (1000000n - 2500n)) / 1000000n + ) + }) + it('[dapp] should delegateVote from forwarder call', async () => { const stakedAmount = ethers.parseUnits('10') await mintPntOnGnosis(user.address, stakedAmount) @@ -1265,6 +1304,26 @@ describe('Integration tests on Polygon deployment', () => { ) }) + it('[dapp] should call forwarder for staking (2)', async () => { + await expect( + user.sendTransaction({ + to: '0xC85cd78555DF9991245F15c7AA6c4eDBb7791c19', + // secretlint-disable-next-line + data: '0x996adf550000000000000000000000000000000000000000000000000b1310c5a2bfcbac00000000000000000000000099405b4e46256dd28e424a0edf296a28e2ae32a0000000000000000000000000000000000000000000000000000000000000008000f1918e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000008805aa0c1a8e59b03fa95740f691e28942cf44f6000000000000000000000000dee8ebe2b7152eccd935fd67134bf1bad55302bc0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000dee8ebe2b7152eccd935fd67134bf1bad55302bc0000000000000000000000000000000000000000000000000b0bfa54806c1db90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000642b54f551000000000000000000000000ddb5f4535123daa5ae343c24006f4075abaf5f7b0000000000000000000000000000000000000000000000000b0bfa54806c1db90000000000000000000000000000000000000000000000000000000000093a8000000000000000000000000000000000000000000000000000000000' + }) + ) + .to.emit(pntOnPolygon, 'Redeem') + .withArgs( + forwarder.target, + ethers.parseUnits('0.797999999999789996'), + FORWARDER_ON_GNOSIS.toLowerCase().slice(2), + // secretlint-disable-next-line + FORWARDER_STAKE_USER_DATA_2, + PNETWORK_NETWORK_IDS.POLYGON, + PNETWORK_NETWORK_IDS.GNOSIS + ) + }) + it('[dapp] should call forwarder for voting', async () => { await expect( forwarder.connect(user).call(