Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1533: Add new handlers and add support for depositing stETH and wstETH #14

Merged
merged 9 commits into from
Jun 17, 2024

Conversation

9inpachi
Copy link
Collaborator

The new deposit functions can be tested by first building the SDK (pnpm build) and then using the following script. Just make sure to update the import path to the correct "main.js" file.

<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Example</title>
  </head>
  <body>
    <button id="button">Deposit</button>

    <script type="module">
      import {
        PufferClient,
        PufferClientHelpers,
        Chain,
      } from '../dist/main.js';

      document.getElementById('button').addEventListener('click', async () => {
        const walletClient = PufferClientHelpers.createWalletClient({
          chain: Chain.Mainnet,
          provider: window.ethereum,
        });
        const publicClient = PufferClientHelpers.createPublicClient({
          chain: Chain.Mainnet,
          rpcUrls: [
            'https://rpc.tenderly.co/fork/4b490ec1-effd-4246-8d7f-87429df60ff4',
          ],
        });
        const client = new PufferClient(
          Chain.Mainnet,
          walletClient,
          publicClient,
        );
        const [walletAddress] = await client.requestAddresses();

        const { transact, estimate } = await client.depositor.depositWstETH(
          walletAddress,
          BigInt(1),
        );
        console.log(Number(await estimate()) / 1e18);
        console.log(await transact());

        const { transact: transactStETH, estimate: estimateStETH } = await client.depositor.depositStETH(
          walletAddress,
          BigInt(1),
        );
        console.log(Number(await estimateStETH()) / 1e18);
        console.log(await transactStETH());
      });
    </script>
  </body>
</html>

The depositStETH function can be tested on holesky but depositWstETH requires a fork of mainnet as used in the script. If you want to use the fork, ask someone from the smart contract channel. See my conversation with Ben for more info.

Tests are coming in the next PR.

@guestn guestn merged commit d639554 into main Jun 17, 2024
1 check failed
@guestn guestn deleted the 1533/deposit-steth-and-wsteth branch June 17, 2024 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants