From b1377238aa8b124b02fe7afba6da1b1e050d4861 Mon Sep 17 00:00:00 2001 From: Shane Fontaine <9441295+shanefontaine@users.noreply.github.com> Date: Fri, 20 Sep 2024 09:13:30 -0700 Subject: [PATCH 1/2] hn: add unwind --- packages/hop-node/src/cli/cli.ts | 1 + packages/hop-node/src/cli/unwind.ts | 54 +++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 packages/hop-node/src/cli/unwind.ts diff --git a/packages/hop-node/src/cli/cli.ts b/packages/hop-node/src/cli/cli.ts index 929768f57..9a2ea6f35 100644 --- a/packages/hop-node/src/cli/cli.ts +++ b/packages/hop-node/src/cli/cli.ts @@ -40,6 +40,7 @@ import './transfersTable.js' import './unbondedTransferRoots.js' import './unsettledRoots.js' import './unstake.js' +import './unwind.js' import './unwithdrawnTransfers.js' import './updateConfig.js' import './verifyAwsSigner.js' diff --git a/packages/hop-node/src/cli/unwind.ts b/packages/hop-node/src/cli/unwind.ts new file mode 100644 index 000000000..9d0d66f2b --- /dev/null +++ b/packages/hop-node/src/cli/unwind.ts @@ -0,0 +1,54 @@ +import { wallets } from '#wallets/index.js' +import { ChainSlug } from '@hop-protocol/sdk' +import { actionHandler, root, parseString } from './shared/index.js' + +root + .command('unwind') + .description('Unwind ERC20') + .option('--to
', 'To address', parseString) + .action(actionHandler(main)) + +async function main (source: any) { + const { to } = source + + if (!to) { + throw new Error('to is required') + } + + const gnosisChain = ChainSlug.Gnosis + const gnosisWallet = wallets.get(gnosisChain) + + const opChain = ChainSlug.Optimism + const opWallet = wallets.get(opChain) + + const recipient = to + + const stETHAddress = '0x6C76971f98945AE98dD7d4DFcA8711ebea946eA6' + const opAddress = '0x4200000000000000000000000000000000000042' + + // 236504013705435798 + const stETHData = `0xa9059cbb000000000000000000000000${to.substring(2)}00000000000000000000000000000000000000000000000003483b25bcddda96` + // 65681465303725250000 + const opData = `0xa9059cbb000000000000000000000000${to.substring(2)}0000000000000000000000000000000000000000000000038f8370b2cbb015d0` + + console.log('Sending OP') + await opWallet.sendTransaction({ + value: '0', + to: opAddress, + data: opData + }) + + console.log('Sending stETH') + await gnosisWallet.sendTransaction({ + value: '0', + to: stETHAddress, + data: stETHData + }) + + console.log('Sending DAI') + await gnosisWallet.sendTransaction({ + value: '27000000000000000000', + to: recipient + }) +} + From ac6ffd6fdc24b615b2695a34afd39ca7ae59db2d Mon Sep 17 00:00:00 2001 From: Shane Fontaine <9441295+shanefontaine@users.noreply.github.com> Date: Fri, 20 Sep 2024 09:14:26 -0700 Subject: [PATCH 2/2] hn: bump --- packages/hop-node/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/hop-node/package.json b/packages/hop-node/package.json index 7d5d49308..b64a69153 100644 --- a/packages/hop-node/package.json +++ b/packages/hop-node/package.json @@ -1,6 +1,6 @@ { "name": "@hop-protocol/hop-node", - "version": "0.0.24", + "version": "0.0.25", "description": "The V1 Hop Node for Hop Protocol", "author": "Authereum Labs, Inc.", "license": "MIT",