npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@lit-protocol/vincent-ability-uniswap-swap

v8.0.4

Published

This Uniswap Swap Ability is part of the Vincent Abilities ecosystem and is built using the Vincent Ability SDK. It allows Vincent Apps to execute token swaps on Uniswap V3 on behalf of Vincent Users, enabling integration with decentralized exchanges.

Readme

Vincent Ability Uniswap Swap

This Uniswap Swap Ability is part of the Vincent Abilities ecosystem and is built using the Vincent Ability SDK. It allows Vincent Apps to execute token swaps on Uniswap V3 on behalf of Vincent Users, enabling integration with decentralized exchanges.

Features

  • Execute token swaps on Uniswap V3
  • Support for exact input and exact output swaps
  • Support for multi-hop swaps through multiple pools
  • Support for multiple chains that Uniswap V3 is deployed to

Installation

npm install @lit-protocol/vincent-ability-uniswap-swap

Usage

To use the Uniswap Swap Ability, you need to generate a signed swap quote first, then provide it to both the precheck and execute functions.

1. Generate a Signed Swap Quote

Before executing a swap, you must generate a signed quote using the getSignedUniswapQuote function:

import { LitNodeClient } from '@lit-protocol/lit-node-client';
import { getSignedUniswapQuote } from '@lit-protocol/vincent-ability-uniswap-swap';
import { ethers } from 'ethers';

// Initialize Lit Node Client
const litNodeClient = new LitNodeClient({
  litNetwork: 'datil',
  debug: true,
});
await litNodeClient.connect();

// Your delegatee signer (one of the delegatee signers for the Vincent App)
const delegateeSigner = new ethers.Wallet('YOUR_DELEGATEE_PRIVATE_KEY', provider);

// Generate the signed quote
const signedUniswapQuote = await getSignedUniswapQuote({
  quoteParams: {
    rpcUrl: 'https://mainnet.base.org',
    tokenInAddress: '0x4ed4E862860beD51a9570b96d89aF5E1B0Efefed', // DEGEN
    tokenInAmount: '80', // Amount in token's smallest unit
    tokenOutAddress: '0x4200000000000000000000000000000000000006', // WETH
    recipient: delegatorPkpEthAddress, // The PKP that will execute the swap
  },
  ethersSigner: delegateeSigner,
  litNodeClient,
});

The return value of getSignedUniswapQuote is an object containing:

  • quote: The Uniswap Quote/Route generated by the V3 SDK using the Alpha Router
  • signature: A signature of quote signed by a Lit PKP that is configured to only ever be able to sign these generated Uniswap Quotes within the specific Lit Action configured by this Ability
  • dataSigned: The data signed by the PKP, an ETH Personal Message containing the hash of the stringified quote
  • signerPublicKey: The public key of the PKP that signed the quote
  • signerEthAddress: The Ethereum address of the PKP that signed the quote

Because the Uniswap SDK makes a lot of RPC calls when generating a quote/route, it exceeded the usage limits of Lit Actions when running within the same Lit Action as the Vincent logic for checking and executing Policies, and verifying on-chain delegation.

So, the purpose of getSignedUniswapQuote is to generate a signed quote/route outside of the Vincent Ability Lit Action, and then provide it to the precheck and execute functions in a tamper-proof manner. The Vincent Delegatee is unable to modify the quote/route after it has been signed by the PKP, because the Ability verifies the provided route data was signed by the hardcoded PKP address.

2. Run Precheck

Provide the signed quote to precheck to check if the swap can be executed:

import { getVincentAbilityClient } from '@lit-protocol/vincent-app-sdk/abilityClient';
import { bundledVincentAbility } from '@lit-protocol/vincent-ability-uniswap-swap';

// Initialize the ability client
const abilityClient = getVincentAbilityClient({
  bundledVincentAbility,
  ethersSigner: delegateeSigner,
});

// Run precheck with the signed quote
const precheckResult = await abilityClient.precheck(
  {
    rpcUrlForUniswap: 'https://mainnet.base.org',
    signedUniswapQuote: {
      quote: signedUniswapQuote.quote,
      signature: signedUniswapQuote.signature,
    },
  },
  {
    delegatorPkpEthAddress: '0x...', // The delegator PKP ETH address
  },
);

if (precheckResult.success) {
  console.log('Swap can be executed');
}

3. Execute the Swap

If precheck succeeds, execute the swap using the same signed quote:

const executeResult = await abilityClient.execute(
  {
    rpcUrlForUniswap: 'https://mainnet.base.org',
    signedUniswapQuote: {
      quote: signedUniswapQuote.quote,
      signature: signedUniswapQuote.signature,
    },
  },
  {
    delegatorPkpEthAddress: '0x...', // The delegator PKP ETH address
  },
);

if (executeResult.success) {
  console.log('Swap executed successfully!');
  console.log('Transaction hash:', executeResult.result.swapTxHash);
}

A complete example of generating the signed quote, running precheck, and executing the swap is available in the abilities-e2e's end-to-end swap.spec.ts test.

Development

Because of the need for the getSignedUniswapQuote function and it's corresponding Lit Action, included in this package is a script (create-pkp-for-prepare.js) that is used to mint the PKP that is configured to only ever be able to sign these generated Uniswap Quotes within the specific Lit Action configured by this Ability.

Anytime changes are made to the Prepare Lit Action, you MUST run the PKP minting script to update the PKP info recorded in vincent-prepare-metadata.json file. You can execute the script using the Nx target:

pnpm nx run ability-uniswap-swap:action:create-pkp

This will run the action:deploy target, which will build the Prepare Lit Action and deploy it to IPFS, recording the IPFS CID in vincent-prepare-metadata.json file. Then the create-pkp-for-prepare.js script will be executed minting a new PKP that has the IPFS CID of the Prepare Lit Action as the only permitted Auth Method.

After making any changes to the Prepare Lit Action, generating a new signer PKP, run the build target to update the Swap Ability Lit Action with the new PKP ETH address used for verifying the quote signatures.