0.1.0-9 • Published 11 months ago

@lit-protocol/aw-tool-uniswap-swap v0.1.0-9

Weekly downloads
-
License
-
Repository
-
Last release
11 months ago

AW-Tool Uniswap Swap Documentation

The aw-tool-uniswap-swap folder contains utilities for performing Uniswap swaps using Lit Protocol and Ethereum.


Files Overview (in src/lib)

1. ipfs.ts

Handles IPFS CIDs for different environments (development, testing, production). Falls back to default CIDs if the build output is not found.

Key Features:

  • Default CIDs: Predefined CIDs for datil-dev, datil-test, and datil environments.
  • Dynamic CID Loading: Attempts to load CIDs from dist/ipfs.json at runtime.
  • Fallback Mechanism: Uses default CIDs if the file is missing or unreadable.

2. lit-action.ts

Contains the main logic for executing a Lit Action to perform a Uniswap swap.

Key Features:

  • PKP Info Retrieval: Fetches PKP details (token ID, Ethereum address, public key) from the PubkeyRouter contract.
  • Input Validation: Validates inputs against the policy defined in the PKP Tool Registry.
  • Gas Estimation: Estimates gas limits and fees for the transaction.
  • Transaction Creation: Creates and signs the transaction using the PKP public key.
  • Broadcasting: Sends the signed transaction to the network.

3. policy.ts

Defines and validates the Uniswap swap policy schema using Zod.

Key Features:

  • Policy Schema: Validates policy fields like maxAmount and allowedTokens.
  • Encoding/Decoding: Converts policies to and from ABI-encoded strings.
  • Type Safety: Uses Zod for robust validation and TypeScript for type inference.

4. tool.ts

Configures the Uniswap swap tool for different Lit networks.

Key Features:

  • Parameter Validation: Validates inputs like tokenIn, tokenOut, amountIn, and chainId.
  • Network-Specific Tools: Creates tools for datil-dev, datil-test, and datil environments.
  • Policy Integration: Integrates with the UniswapSwapPolicy for policy handling.
0.1.0-23

9 months ago

0.1.0-22

10 months ago

0.1.0-21

10 months ago

0.1.0-20

10 months ago

0.1.0-19

10 months ago

0.1.0-18

10 months ago

0.1.0-17

10 months ago

0.1.0-16

10 months ago

0.1.0-15

10 months ago

0.1.0-13

10 months ago

0.1.0-12

10 months ago

0.1.0-11

10 months ago

0.1.0-10

10 months ago

0.1.0-9

11 months ago

0.1.0-8

11 months ago

0.1.0-7

11 months ago

0.1.0-6

11 months ago

0.1.0-5

11 months ago

0.1.0-4

11 months ago

0.1.0-3

11 months ago

0.1.0-2

11 months ago