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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@vaultlayer/vincent-ability-molten-swap

v0.2.12

Published

## Overview

Downloads

45

Readme

Vincent Ability: Molten Swap

Overview

The Molten Swap Ability enables Vincent Apps to swap tokens on the CoreDAO chain using Molten DEX (a Uniswap V4 fork). This ability provides token swapping functionality with automatic approval handling and supports both approve and swap actions.

Key Features

  • Molten DEX Integration: Uses Molten DEX router for token swaps on CoreDAO
  • Separate Actions: Supports both approve and swap actions for flexible workflows
  • Automatic Token Validation: Validates that tokens are supported by Molten DEX
  • Automatic Approval: Handles ERC20 approvals before swapping
  • Minimum Output Protection: Supports minimum output amount for slippage protection
  • CoreDAO Only: Exclusively works on CoreDAO chain (Chain ID: 1116)

Supported Tokens

The ability supports the following tokens on CoreDAO:

  • USDT: 0x900101d06A7426441Ae63e9AB3B9b0F63Be145F1 (6 decimals)
  • USDC: 0xa4151B2B3e269645181dCcF2D426cE75fcbDeca9 (6 decimals)
  • wBTC: 0x5832f53d147b3d6Cd4578B9CBD62425C7ea9d0Bd (8 decimals)
  • wCORE: 0x191E94fa59739e188dcE837F7f6978d84727AD01 (18 decimals)
  • vltCORE: 0x3093304eCE0F35969B580CbD155a1357829870f2 (18 decimals)
  • ASX: 0xB28B43209d9de61306172Af0320f4f55e50E2f29 (18 decimals)

Tokens can be referenced by either their address or symbol (e.g., 'USDC' or '0xa4151B2B3e269645181dCcF2D426cE75fcbDeca9').

Installation

npm install @vaultlayer/vincent-ability-molten-swap
# or
pnpm add @vaultlayer/vincent-ability-molten-swap
# or
yarn add @vaultlayer/vincent-ability-molten-swap

Basic Usage

import { bundledVincentAbility } from '@vaultlayer/vincent-ability-molten-swap';

// Swap USDC for USDT on Molten DEX
const result = await executeAbility({
  ability: bundledVincentAbility,
  params: {
    action: 'swap',
    tokenIn: 'USDC',
    tokenOut: 'USDT',
    recipient: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
    amountIn: '100.5', // 100.5 USDC
    amountOutMinimum: '99.0', // Minimum 99 USDT expected
    rpcUrl: 'https://rpc.coredao.org', // Optional
  },
});

// Approve USDC for swapping (separate action)
const approvalResult = await executeAbility({
  ability: bundledVincentAbility,
  params: {
    action: 'approve',
    tokenIn: 'USDC',
    tokenOut: 'USDT', // Required but not used for approve action
    recipient: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb', // Required but not used for approve action
    amountIn: '1000', // Amount to approve
    rpcUrl: 'https://rpc.coredao.org',
  },
});

Parameters

Required Parameters

action

  • Type: 'approve' | 'swap'
  • Description: Whether to perform an ERC20 approval or a swap operation
  • Note: Approval must be done before swapping (unless sufficient allowance already exists)

tokenIn

  • Type: string
  • Description: Input token address or symbol
  • Example: 'USDC' or '0xa4151B2B3e269645181dCcF2D426cE75fcbDeca9'
  • Validation: Must be a supported token address or symbol

tokenOut

  • Type: string
  • Description: Output token address or symbol
  • Example: 'USDT' or '0x900101d06A7426441Ae63e9AB3B9b0F63Be145F1'
  • Validation: Must be a supported token address or symbol
  • Note: Required for swap action, may be unused for approve action

recipient

  • Type: string
  • Description: Recipient address for the swapped tokens
  • Example: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb'
  • Validation: Must be a valid Ethereum address
  • Note: Required for swap action, may be unused for approve action

amountIn

  • Type: string
  • Description: Input amount as a decimal string
  • Example: '100.5' (100.5 tokens)
  • Note: Decimals are handled automatically based on token type

Optional Parameters

amountOutMinimum

  • Type: string
  • Description: Minimum output amount as a decimal string for slippage protection
  • Default: '0'
  • Example: '99.0' (minimum 99 tokens expected)
  • Note: Use this to protect against excessive slippage

rpcUrl

  • Type: string
  • Description: RPC URL for CoreDAO chain (optional, defaults to https://rpc.coredao.org)
  • Example: 'https://rpc.coredao.org'

Contract Addresses

Molten DEX Contracts (CoreDAO)

  • Factory: 0x74EfE55beA4988e7D92D03EFd8ddB8BF8b7bD597
  • Router: 0x832933BA44658C50ae6152039Cd30A6f4C2432b1
  • Quoter: 0x20dA24b5FaC067930Ced329A3457298172510Fe7
  • NonfungiblePositionManager: 0x1F98431c8aD98523631AE4a59f267346ea31F984
  • Chain ID: 1116
  • Block Explorer: https://scan.coredao.org

How It Works

  1. Precheck Phase:

    • Validates native token balance (for gas fees)
    • Validates tokenIn is supported by Molten DEX
    • Validates tokenOut is supported by Molten DEX (for swap action)
    • Checks ERC20 balance of tokenIn
    • Checks ERC20 allowance for Molten router
    • Returns current allowance status
  2. Execute Phase (approve action):

    • Checks current allowance for Molten router
    • If sufficient, returns success without transaction
    • If insufficient, sends approval transaction with MaxUint256
    • Returns approval transaction hash
  3. Execute Phase (swap action):

    • Validates tokens are supported
    • Ensures allowance is sufficient (fails if not)
    • Builds swap parameters with recipient and minimum output
    • Executes swap transaction via Molten router
    • Returns swap transaction hash

Approval Handling

This ability uses a two-step approval pattern:

  • Separate Actions: Approval and swap are separate actions
  • Flexible Workflow: Approve once, swap multiple times
  • Max Approval: Approves MaxUint256 to minimize approval transactions
  • Reusable: Once approved, can swap multiple times without re-approving

Error Handling

The ability will fail gracefully with descriptive error messages for:

  • Unsupported token addresses or symbols
  • Insufficient token balance
  • Insufficient allowance (when swapping without approval)
  • Insufficient native token balance (for gas)
  • Invalid recipient address
  • Swap transaction failures

Examples

Approve Tokens for Swapping

const result = await executeAbility({
  ability: bundledVincentAbility,
  params: {
    action: 'approve',
    tokenIn: 'USDC',
    tokenOut: 'USDT', // Required parameter but not used for approve
    recipient: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb', // Required parameter but not used for approve
    amountIn: '1000', // Approve enough for multiple swaps
  },
});

console.log('Approval tx hash:', result.approvalTxHash);
console.log('Current allowance:', result.currentAllowance);

Swap USDC to USDT

const result = await executeAbility({
  ability: bundledVincentAbility,
  params: {
    action: 'swap',
    tokenIn: 'USDC',
    tokenOut: 'USDT',
    recipient: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
    amountIn: '100',
    amountOutMinimum: '99', // 1% slippage tolerance
  },
});

console.log('Swap tx hash:', result.swapTxHash);

Swap Using Token Addresses

const result = await executeAbility({
  ability: bundledVincentAbility,
  params: {
    action: 'swap',
    tokenIn: '0xa4151B2B3e269645181dCcF2D426cE75fcbDeca9', // USDC address
    tokenOut: '0x5832f53d147b3d6Cd4578B9CBD62425C7ea9d0Bd', // wBTC address
    recipient: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
    amountIn: '1000',
    amountOutMinimum: '0.001', // Minimum wBTC expected
  },
});

Swap with Custom RPC

const result = await executeAbility({
  ability: bundledVincentAbility,
  params: {
    action: 'swap',
    tokenIn: 'wCORE',
    tokenOut: 'vltCORE',
    recipient: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
    amountIn: '50',
    rpcUrl: 'https://custom-rpc.coredao.org',
  },
});

Response Format

Success Response (swap action)

{
  swapTxHash: '0x...', // Transaction hash
  approvalTxHash: undefined, // No approval needed
  currentAllowance: undefined,
  requiredAllowance: undefined
}

Success Response (approve action)

{
  approvalTxHash: '0x...', // Transaction hash (if new approval created)
  swapTxHash: undefined,
  currentAllowance: '115792089237316195423570985008687907853269984665640564039457584007913129639935', // MaxUint256
  requiredAllowance: '1000000000' // Requested amount
}

Error Response

{
  reason: 'Token with address "0x..." is not supported by Molten DEX on CoreDAO';
}

Use Cases

  • Token swaps on CoreDAO via Molten DEX
  • DeFi portfolio management on CoreDAO
  • Liquidity provision preparation
  • Multi-token workflows on CoreDAO
  • Automated trading strategies

Security Considerations

  • Token Validation: Only allows swaps between supported tokens
  • Approval Pattern: Separate approval step provides additional control
  • Max Approval: Approves MaxUint256 - ensure you trust the Molten router
  • Slippage Protection: Use amountOutMinimum to protect against excessive slippage
  • Chain Specific: Only works on CoreDAO chain (Chain ID: 1116)

Limitations

  • CoreDAO Only: This ability only works on CoreDAO chain
  • Supported Tokens Only: Can only swap between pre-configured supported tokens
  • No Gas Sponsorship: Gas sponsorship (EIP-7702) is not supported on CoreDAO
  • Requires Approval: Must approve tokens before swapping (unless sufficient allowance exists)

Related Packages

License

MIT