支付
Monad






































支付、代币化资产和DeFi汇聚于同一个全天候开放的EVM网络:稳定币、链上资产以及交易它们的市场,都可以通过同样的合约和钱包触达。
import { NextResponse } from "next/server";
import { withX402, type RouteConfig } from "@x402/next";
import { x402ResourceServer, HTTPFacilitatorClient } from "@x402/core/server";
import { ExactEvmScheme } from "@x402/evm/exact/server";
import type { Network } from "@x402/core/types";
// Monad Testnet configuration
const MONAD_NETWORK: Network = "eip155:10143";
const MONAD_USDC_TESTNET = "0x534b2f3A21130d7a60830c2Df862319e593943A3";
// Monad Facilitator URL
const FACILITATOR_URL = "https://x402-facilitator.molandak.org";
if (!process.env.PAY_TO_ADDRESS) {
throw new Error("PAY_TO_ADDRESS environment variable is required");
}
const PAY_TO = process.env.PAY_TO_ADDRESS;
// Create facilitator client for Monad
const facilitatorClient = new HTTPFacilitatorClient({ url: FACILITATOR_URL });
// Create and configure x402 resource server
const server = new x402ResourceServer(facilitatorClient);
// Monad testnet USDC is not in @x402/evm's built-in asset table, so register
// it here. Mainnet (eip155:143) is built in since 2.22.0 and needs no parser.
const monadScheme = new ExactEvmScheme();
monadScheme.registerMoneyParser(async (amount: number, network: string) => {
if (network === MONAD_NETWORK) {
// Convert decimal amount to USDC smallest units (6 decimals).
// `Math.floor(amount * 1_000_000)` is safe up to ~9 billion USDC
// (~9 quadrillion atomic units) — bounded by JS Number's 2^53 precision.
// For tokens with 18 decimals or very large balances, use `BigInt` to avoid
// precision loss, e.g.:
// BigInt(Math.round(amount * 1e6)).toString() // USDC, 6 decimals
// (BigInt(Math.round(amount * 1e9)) * 1_000_000_000n).toString() // 18d, ≤9 fractional digits
const tokenAmount = Math.floor(amount * 1_000_000).toString();
return {
amount: tokenAmount,
asset: MONAD_USDC_TESTNET, // Raw address for EIP-712 verifyingContract
extra: {
name: "USDC",
version: "2",
},
};
}
return null; // Use default parser for other networks
});
import { NextResponse } from "next/server";
import { withX402, type RouteConfig } from "@x402/next";
import { x402ResourceServer, HTTPFacilitatorClient } from "@x402/core/server";
import { ExactEvmScheme } from "@x402/evm/exact/server";
import type { Network } from "@x402/core/types";
// Monad Testnet configuration
const MONAD_NETWORK: Network = "eip155:10143";
const MONAD_USDC_TESTNET = "0x534b2f3A21130d7a60830c2Df862319e593943A3";
// Monad Facilitator URL
const FACILITATOR_URL = "https://x402-facilitator.molandak.org";
if (!process.env.PAY_TO_ADDRESS) {
throw new Error("PAY_TO_ADDRESS environment variable is required");
}
const PAY_TO = process.env.PAY_TO_ADDRESS;
// Create facilitator client for Monad
const facilitatorClient = new HTTPFacilitatorClient({ url: FACILITATOR_URL });
// Create and configure x402 resource server
const server = new x402ResourceServer(facilitatorClient);
// Monad testnet USDC is not in @x402/evm's built-in asset table, so register
// it here. Mainnet (eip155:143) is built in since 2.22.0 and needs no parser.
const monadScheme = new ExactEvmScheme();
monadScheme.registerMoneyParser(async (amount: number, network: string) => {
if (network === MONAD_NETWORK) {
// Convert decimal amount to USDC smallest units (6 decimals).
// `Math.floor(amount * 1_000_000)` is safe up to ~9 billion USDC
// (~9 quadrillion atomic units) — bounded by JS Number's 2^53 precision.
// For tokens with 18 decimals or very large balances, use `BigInt` to avoid
// precision loss, e.g.:
// BigInt(Math.round(amount * 1e6)).toString() // USDC, 6 decimals
// (BigInt(Math.round(amount * 1e9)) * 1_000_000_000n).toString() // 18d, ≤9 fractional digits
const tokenAmount = Math.floor(amount * 1_000_000).toString();
return {
amount: tokenAmount,
asset: MONAD_USDC_TESTNET, // Raw address for EIP-712 verifyingContract
extra: {
name: "USDC",
version: "2",
},
};
}
return null; // Use default parser for other networks
});
import { NextResponse } from "next/server";
import { withX402, type RouteConfig } from "@x402/next";
import { x402ResourceServer, HTTPFacilitatorClient } from "@x402/core/server";
import { ExactEvmScheme } from "@x402/evm/exact/server";
import type { Network } from "@x402/core/types";
// Monad Testnet configuration
const MONAD_NETWORK: Network = "eip155:10143";
const MONAD_USDC_TESTNET = "0x534b2f3A21130d7a60830c2Df862319e593943A3";
// Monad Facilitator URL
const FACILITATOR_URL = "https://x402-facilitator.molandak.org";
if (!process.env.PAY_TO_ADDRESS) {
throw new Error("PAY_TO_ADDRESS environment variable is required");
}
const PAY_TO = process.env.PAY_TO_ADDRESS;
// Create facilitator client for Monad
const facilitatorClient = new HTTPFacilitatorClient({ url: FACILITATOR_URL });
// Create and configure x402 resource server
const server = new x402ResourceServer(facilitatorClient);
// Monad testnet USDC is not in @x402/evm's built-in asset table, so register
// it here. Mainnet (eip155:143) is built in since 2.22.0 and needs no parser.
const monadScheme = new ExactEvmScheme();
monadScheme.registerMoneyParser(async (amount: number, network: string) => {
if (network === MONAD_NETWORK) {
// Convert decimal amount to USDC smallest units (6 decimals).
// `Math.floor(amount * 1_000_000)` is safe up to ~9 billion USDC
// (~9 quadrillion atomic units) — bounded by JS Number's 2^53 precision.
// For tokens with 18 decimals or very large balances, use `BigInt` to avoid
// precision loss, e.g.:
// BigInt(Math.round(amount * 1e6)).toString() // USDC, 6 decimals
// (BigInt(Math.round(amount * 1e9)) * 1_000_000_000n).toString() // 18d, ≤9 fractional digits
const tokenAmount = Math.floor(amount * 1_000_000).toString();
return {
amount: tokenAmount,
asset: MONAD_USDC_TESTNET, // Raw address for EIP-712 verifyingContract
extra: {
name: "USDC",
version: "2",
},
};
}
return null; // Use default parser for other networks
});
import { NextResponse } from "next/server";
import { withX402, type RouteConfig } from "@x402/next";
import { x402ResourceServer, HTTPFacilitatorClient } from "@x402/core/server";
import { ExactEvmScheme } from "@x402/evm/exact/server";
import type { Network } from "@x402/core/types";
// Monad Testnet configuration
const MONAD_NETWORK: Network = "eip155:10143";
const MONAD_USDC_TESTNET = "0x534b2f3A21130d7a60830c2Df862319e593943A3";
// Monad Facilitator URL
const FACILITATOR_URL = "https://x402-facilitator.molandak.org";
if (!process.env.PAY_TO_ADDRESS) {
throw new Error("PAY_TO_ADDRESS environment variable is required");
}
const PAY_TO = process.env.PAY_TO_ADDRESS;
// Create facilitator client for Monad
const facilitatorClient = new HTTPFacilitatorClient({ url: FACILITATOR_URL });
// Create and configure x402 resource server
const server = new x402ResourceServer(facilitatorClient);
// Monad testnet USDC is not in @x402/evm's built-in asset table, so register
// it here. Mainnet (eip155:143) is built in since 2.22.0 and needs no parser.
const monadScheme = new ExactEvmScheme();
monadScheme.registerMoneyParser(async (amount: number, network: string) => {
if (network === MONAD_NETWORK) {
// Convert decimal amount to USDC smallest units (6 decimals).
// `Math.floor(amount * 1_000_000)` is safe up to ~9 billion USDC
// (~9 quadrillion atomic units) — bounded by JS Number's 2^53 precision.
// For tokens with 18 decimals or very large balances, use `BigInt` to avoid
// precision loss, e.g.:
// BigInt(Math.round(amount * 1e6)).toString() // USDC, 6 decimals
// (BigInt(Math.round(amount * 1e9)) * 1_000_000_000n).toString() // 18d, ≤9 fractional digits
const tokenAmount = Math.floor(amount * 1_000_000).toString();
return {
amount: tokenAmount,
asset: MONAD_USDC_TESTNET, // Raw address for EIP-712 verifyingContract
extra: {
name: "USDC",
version: "2",
},
};
}
return null; // Use default parser for other networks
});
import { NextResponse } from "next/server";
import { withX402, type RouteConfig } from "@x402/next";
import { x402ResourceServer, HTTPFacilitatorClient } from "@x402/core/server";
import { ExactEvmScheme } from "@x402/evm/exact/server";
import type { Network } from "@x402/core/types";
// Monad Testnet configuration
const MONAD_NETWORK: Network = "eip155:10143";
const MONAD_USDC_TESTNET = "0x534b2f3A21130d7a60830c2Df862319e593943A3";
// Monad Facilitator URL
const FACILITATOR_URL = "https://x402-facilitator.molandak.org";
if (!process.env.PAY_TO_ADDRESS) {
throw new Error("PAY_TO_ADDRESS environment variable is required");
}
const PAY_TO = process.env.PAY_TO_ADDRESS;
// Create facilitator client for Monad
const facilitatorClient = new HTTPFacilitatorClient({ url: FACILITATOR_URL });
// Create and configure x402 resource server
const server = new x402ResourceServer(facilitatorClient);
// Monad testnet USDC is not in @x402/evm's built-in asset table, so register
// it here. Mainnet (eip155:143) is built in since 2.22.0 and needs no parser.
const monadScheme = new ExactEvmScheme();
monadScheme.registerMoneyParser(async (amount: number, network: string) => {
if (network === MONAD_NETWORK) {
// Convert decimal amount to USDC smallest units (6 decimals).
// `Math.floor(amount * 1_000_000)` is safe up to ~9 billion USDC
// (~9 quadrillion atomic units) — bounded by JS Number's 2^53 precision.
// For tokens with 18 decimals or very large balances, use `BigInt` to avoid
// precision loss, e.g.:
// BigInt(Math.round(amount * 1e6)).toString() // USDC, 6 decimals
// (BigInt(Math.round(amount * 1e9)) * 1_000_000_000n).toString() // 18d, ≤9 fractional digits
const tokenAmount = Math.floor(amount * 1_000_000).toString();
return {
amount: tokenAmount,
asset: MONAD_USDC_TESTNET, // Raw address for EIP-712 verifyingContract
extra: {
name: "USDC",
version: "2",
},
};
}
return null; // Use default parser for other networks
});
import { NextResponse } from "next/server";
import { withX402, type RouteConfig } from "@x402/next";
import { x402ResourceServer, HTTPFacilitatorClient } from "@x402/core/server";
import { ExactEvmScheme } from "@x402/evm/exact/server";
import type { Network } from "@x402/core/types";
// Monad Testnet configuration
const MONAD_NETWORK: Network = "eip155:10143";
const MONAD_USDC_TESTNET = "0x534b2f3A21130d7a60830c2Df862319e593943A3";
// Monad Facilitator URL
const FACILITATOR_URL = "https://x402-facilitator.molandak.org";
if (!process.env.PAY_TO_ADDRESS) {
throw new Error("PAY_TO_ADDRESS environment variable is required");
}
const PAY_TO = process.env.PAY_TO_ADDRESS;
// Create facilitator client for Monad
const facilitatorClient = new HTTPFacilitatorClient({ url: FACILITATOR_URL });
// Create and configure x402 resource server
const server = new x402ResourceServer(facilitatorClient);
// Monad testnet USDC is not in @x402/evm's built-in asset table, so register
// it here. Mainnet (eip155:143) is built in since 2.22.0 and needs no parser.
const monadScheme = new ExactEvmScheme();
monadScheme.registerMoneyParser(async (amount: number, network: string) => {
if (network === MONAD_NETWORK) {
// Convert decimal amount to USDC smallest units (6 decimals).
// `Math.floor(amount * 1_000_000)` is safe up to ~9 billion USDC
// (~9 quadrillion atomic units) — bounded by JS Number's 2^53 precision.
// For tokens with 18 decimals or very large balances, use `BigInt` to avoid
// precision loss, e.g.:
// BigInt(Math.round(amount * 1e6)).toString() // USDC, 6 decimals
// (BigInt(Math.round(amount * 1e9)) * 1_000_000_000n).toString() // 18d, ≤9 fractional digits
const tokenAmount = Math.floor(amount * 1_000_000).toString();
return {
amount: tokenAmount,
asset: MONAD_USDC_TESTNET, // Raw address for EIP-712 verifyingContract
extra: {
name: "USDC",
version: "2",
},
};
}
return null; // Use default parser for other networks
});随时在链上发送稳定币,网络费用不到一美分。
import { createPublicClient, http, parseAbi } from "viem";
import { monad } from "viem/chains";
const client = createPublicClient({ chain: monad, transport: http() });
const SPYx = "0x90A2a4c76b5D8c0bc892A69EA28Aa775a8f2dD48";
const account = "0x..."; // the holder to look up
const abi = parseAbi([
"function getCurrentMultiplier() view returns (uint256 currentMultiplier, uint256 periodsPassed, uint256 currentMultiplierNonce)",
"function sharesOf(address account) view returns (uint256)",
"function balanceOf(address account) view returns (uint256)",
]);
const [multiplier] = await client.readContract({
address: SPYx,
abi,
functionName: "getCurrentMultiplier",
});
// 1007474126658766000n on November 16, 2026, a multiplier of about 1.0075
const shares = await client.readContract({
address: SPYx,
abi,
functionName: "sharesOf",
args: [account],
});
const scheduleAbi = parseAbi([
"event MultiplierScheduled(uint256 newMultiplier, uint256 activationTime)",
"function newMultiplierActivationTime() view returns (uint256)",
]);
// The scheduling transaction for the October 30, 2026 change.
// The public RPC accepts at most 100 blocks per eth_getLogs call.
const logs = await client.getLogs({
address: SPYx,
event: scheduleAbi[0],
fromBlock: 117996000n,
toBlock: 117996099n,
});
// logs[0].args: { newMultiplier: 1005732155949979200n, activationTime: 1793404500n }
import { createPublicClient, http, parseAbi } from "viem";
import { monad } from "viem/chains";
const client = createPublicClient({ chain: monad, transport: http() });
const SPYx = "0x90A2a4c76b5D8c0bc892A69EA28Aa775a8f2dD48";
const account = "0x..."; // the holder to look up
const abi = parseAbi([
"function getCurrentMultiplier() view returns (uint256 currentMultiplier, uint256 periodsPassed, uint256 currentMultiplierNonce)",
"function sharesOf(address account) view returns (uint256)",
"function balanceOf(address account) view returns (uint256)",
]);
const [multiplier] = await client.readContract({
address: SPYx,
abi,
functionName: "getCurrentMultiplier",
});
// 1007474126658766000n on November 16, 2026, a multiplier of about 1.0075
const shares = await client.readContract({
address: SPYx,
abi,
functionName: "sharesOf",
args: [account],
});
const scheduleAbi = parseAbi([
"event MultiplierScheduled(uint256 newMultiplier, uint256 activationTime)",
"function newMultiplierActivationTime() view returns (uint256)",
]);
// The scheduling transaction for the October 30, 2026 change.
// The public RPC accepts at most 100 blocks per eth_getLogs call.
const logs = await client.getLogs({
address: SPYx,
event: scheduleAbi[0],
fromBlock: 117996000n,
toBlock: 117996099n,
});
// logs[0].args: { newMultiplier: 1005732155949979200n, activationTime: 1793404500n }
import { createPublicClient, http, parseAbi } from "viem";
import { monad } from "viem/chains";
const client = createPublicClient({ chain: monad, transport: http() });
const SPYx = "0x90A2a4c76b5D8c0bc892A69EA28Aa775a8f2dD48";
const account = "0x..."; // the holder to look up
const abi = parseAbi([
"function getCurrentMultiplier() view returns (uint256 currentMultiplier, uint256 periodsPassed, uint256 currentMultiplierNonce)",
"function sharesOf(address account) view returns (uint256)",
"function balanceOf(address account) view returns (uint256)",
]);
const [multiplier] = await client.readContract({
address: SPYx,
abi,
functionName: "getCurrentMultiplier",
});
// 1007474126658766000n on November 16, 2026, a multiplier of about 1.0075
const shares = await client.readContract({
address: SPYx,
abi,
functionName: "sharesOf",
args: [account],
});
const scheduleAbi = parseAbi([
"event MultiplierScheduled(uint256 newMultiplier, uint256 activationTime)",
"function newMultiplierActivationTime() view returns (uint256)",
]);
// The scheduling transaction for the October 30, 2026 change.
// The public RPC accepts at most 100 blocks per eth_getLogs call.
const logs = await client.getLogs({
address: SPYx,
event: scheduleAbi[0],
fromBlock: 117996000n,
toBlock: 117996099n,
});
// logs[0].args: { newMultiplier: 1005732155949979200n, activationTime: 1793404500n }
import { createPublicClient, http, parseAbi } from "viem";
import { monad } from "viem/chains";
const client = createPublicClient({ chain: monad, transport: http() });
const SPYx = "0x90A2a4c76b5D8c0bc892A69EA28Aa775a8f2dD48";
const account = "0x..."; // the holder to look up
const abi = parseAbi([
"function getCurrentMultiplier() view returns (uint256 currentMultiplier, uint256 periodsPassed, uint256 currentMultiplierNonce)",
"function sharesOf(address account) view returns (uint256)",
"function balanceOf(address account) view returns (uint256)",
]);
const [multiplier] = await client.readContract({
address: SPYx,
abi,
functionName: "getCurrentMultiplier",
});
// 1007474126658766000n on November 16, 2026, a multiplier of about 1.0075
const shares = await client.readContract({
address: SPYx,
abi,
functionName: "sharesOf",
args: [account],
});
const scheduleAbi = parseAbi([
"event MultiplierScheduled(uint256 newMultiplier, uint256 activationTime)",
"function newMultiplierActivationTime() view returns (uint256)",
]);
// The scheduling transaction for the October 30, 2026 change.
// The public RPC accepts at most 100 blocks per eth_getLogs call.
const logs = await client.getLogs({
address: SPYx,
event: scheduleAbi[0],
fromBlock: 117996000n,
toBlock: 117996099n,
});
// logs[0].args: { newMultiplier: 1005732155949979200n, activationTime: 1793404500n }
import { createPublicClient, http, parseAbi } from "viem";
import { monad } from "viem/chains";
const client = createPublicClient({ chain: monad, transport: http() });
const SPYx = "0x90A2a4c76b5D8c0bc892A69EA28Aa775a8f2dD48";
const account = "0x..."; // the holder to look up
const abi = parseAbi([
"function getCurrentMultiplier() view returns (uint256 currentMultiplier, uint256 periodsPassed, uint256 currentMultiplierNonce)",
"function sharesOf(address account) view returns (uint256)",
"function balanceOf(address account) view returns (uint256)",
]);
const [multiplier] = await client.readContract({
address: SPYx,
abi,
functionName: "getCurrentMultiplier",
});
// 1007474126658766000n on November 16, 2026, a multiplier of about 1.0075
const shares = await client.readContract({
address: SPYx,
abi,
functionName: "sharesOf",
args: [account],
});
const scheduleAbi = parseAbi([
"event MultiplierScheduled(uint256 newMultiplier, uint256 activationTime)",
"function newMultiplierActivationTime() view returns (uint256)",
]);
// The scheduling transaction for the October 30, 2026 change.
// The public RPC accepts at most 100 blocks per eth_getLogs call.
const logs = await client.getLogs({
address: SPYx,
event: scheduleAbi[0],
fromBlock: 117996000n,
toBlock: 117996099n,
});
// logs[0].args: { newMultiplier: 1005732155949979200n, activationTime: 1793404500n }
import { createPublicClient, http, parseAbi } from "viem";
import { monad } from "viem/chains";
const client = createPublicClient({ chain: monad, transport: http() });
const SPYx = "0x90A2a4c76b5D8c0bc892A69EA28Aa775a8f2dD48";
const account = "0x..."; // the holder to look up
const abi = parseAbi([
"function getCurrentMultiplier() view returns (uint256 currentMultiplier, uint256 periodsPassed, uint256 currentMultiplierNonce)",
"function sharesOf(address account) view returns (uint256)",
"function balanceOf(address account) view returns (uint256)",
]);
const [multiplier] = await client.readContract({
address: SPYx,
abi,
functionName: "getCurrentMultiplier",
});
// 1007474126658766000n on November 16, 2026, a multiplier of about 1.0075
const shares = await client.readContract({
address: SPYx,
abi,
functionName: "sharesOf",
args: [account],
});
const scheduleAbi = parseAbi([
"event MultiplierScheduled(uint256 newMultiplier, uint256 activationTime)",
"function newMultiplierActivationTime() view returns (uint256)",
]);
// The scheduling transaction for the October 30, 2026 change.
// The public RPC accepts at most 100 blocks per eth_getLogs call.
const logs = await client.getLogs({
address: SPYx,
event: scheduleAbi[0],
fromBlock: 117996000n,
toBlock: 117996099n,
});
// logs[0].args: { newMultiplier: 1005732155949979200n, activationTime: 1793404500n }发行代币化国债、股票和现实世界资产,600 ms内完成链上结算。
import {BaseHook} from "@openzeppelin/uniswap-hooks/src/base/BaseHook.sol";
function _beforeSwap(address, PoolKey calldata key, SwapParams calldata, bytes calldata)
internal
override
returns (bytes4, BeforeSwapDelta, uint24)
{
beforeSwapCount[key.toId()]++;
return (BaseHook.beforeSwap.selector, BeforeSwapDeltaLibrary.ZERO_DELTA, 0);
}
import { erc20Abi, erc4626Abi, parseUnits } from "viem";
const wSPYx = "0xE7E553Cd128F0011777323A0b44a7b96EA1CB540";
const amount = parseUnits("10", 18); // 10 SPYx
// walletClient is a viem wallet client for the depositor
await walletClient.writeContract({
address: SPYx,
abi: erc20Abi,
functionName: "approve",
args: [wSPYx, amount],
});
await walletClient.writeContract({
address: wSPYx,
abi: erc4626Abi,
functionName: "deposit",
args: [amount, walletClient.account.address],
});
import {BaseHook} from "@openzeppelin/uniswap-hooks/src/base/BaseHook.sol";
function _beforeSwap(address, PoolKey calldata key, SwapParams calldata, bytes calldata)
internal
override
returns (bytes4, BeforeSwapDelta, uint24)
{
beforeSwapCount[key.toId()]++;
return (BaseHook.beforeSwap.selector, BeforeSwapDeltaLibrary.ZERO_DELTA, 0);
}
import { erc20Abi, erc4626Abi, parseUnits } from "viem";
const wSPYx = "0xE7E553Cd128F0011777323A0b44a7b96EA1CB540";
const amount = parseUnits("10", 18); // 10 SPYx
// walletClient is a viem wallet client for the depositor
await walletClient.writeContract({
address: SPYx,
abi: erc20Abi,
functionName: "approve",
args: [wSPYx, amount],
});
await walletClient.writeContract({
address: wSPYx,
abi: erc4626Abi,
functionName: "deposit",
args: [amount, walletClient.account.address],
});
import {BaseHook} from "@openzeppelin/uniswap-hooks/src/base/BaseHook.sol";
function _beforeSwap(address, PoolKey calldata key, SwapParams calldata, bytes calldata)
internal
override
returns (bytes4, BeforeSwapDelta, uint24)
{
beforeSwapCount[key.toId()]++;
return (BaseHook.beforeSwap.selector, BeforeSwapDeltaLibrary.ZERO_DELTA, 0);
}
import { erc20Abi, erc4626Abi, parseUnits } from "viem";
const wSPYx = "0xE7E553Cd128F0011777323A0b44a7b96EA1CB540";
const amount = parseUnits("10", 18); // 10 SPYx
// walletClient is a viem wallet client for the depositor
await walletClient.writeContract({
address: SPYx,
abi: erc20Abi,
functionName: "approve",
args: [wSPYx, amount],
});
await walletClient.writeContract({
address: wSPYx,
abi: erc4626Abi,
functionName: "deposit",
args: [amount, walletClient.account.address],
});
import {BaseHook} from "@openzeppelin/uniswap-hooks/src/base/BaseHook.sol";
function _beforeSwap(address, PoolKey calldata key, SwapParams calldata, bytes calldata)
internal
override
returns (bytes4, BeforeSwapDelta, uint24)
{
beforeSwapCount[key.toId()]++;
return (BaseHook.beforeSwap.selector, BeforeSwapDeltaLibrary.ZERO_DELTA, 0);
}
import { erc20Abi, erc4626Abi, parseUnits } from "viem";
const wSPYx = "0xE7E553Cd128F0011777323A0b44a7b96EA1CB540";
const amount = parseUnits("10", 18); // 10 SPYx
// walletClient is a viem wallet client for the depositor
await walletClient.writeContract({
address: SPYx,
abi: erc20Abi,
functionName: "approve",
args: [wSPYx, amount],
});
await walletClient.writeContract({
address: wSPYx,
abi: erc4626Abi,
functionName: "deposit",
args: [amount, walletClient.account.address],
});
import {BaseHook} from "@openzeppelin/uniswap-hooks/src/base/BaseHook.sol";
function _beforeSwap(address, PoolKey calldata key, SwapParams calldata, bytes calldata)
internal
override
returns (bytes4, BeforeSwapDelta, uint24)
{
beforeSwapCount[key.toId()]++;
return (BaseHook.beforeSwap.selector, BeforeSwapDeltaLibrary.ZERO_DELTA, 0);
}
import { erc20Abi, erc4626Abi, parseUnits } from "viem";
const wSPYx = "0xE7E553Cd128F0011777323A0b44a7b96EA1CB540";
const amount = parseUnits("10", 18); // 10 SPYx
// walletClient is a viem wallet client for the depositor
await walletClient.writeContract({
address: SPYx,
abi: erc20Abi,
functionName: "approve",
args: [wSPYx, amount],
});
await walletClient.writeContract({
address: wSPYx,
abi: erc4626Abi,
functionName: "deposit",
args: [amount, walletClient.account.address],
});
import {BaseHook} from "@openzeppelin/uniswap-hooks/src/base/BaseHook.sol";
function _beforeSwap(address, PoolKey calldata key, SwapParams calldata, bytes calldata)
internal
override
returns (bytes4, BeforeSwapDelta, uint24)
{
beforeSwapCount[key.toId()]++;
return (BaseHook.beforeSwap.selector, BeforeSwapDeltaLibrary.ZERO_DELTA, 0);
}
import { erc20Abi, erc4626Abi, parseUnits } from "viem";
const wSPYx = "0xE7E553Cd128F0011777323A0b44a7b96EA1CB540";
const amount = parseUnits("10", 18); // 10 SPYx
// walletClient is a viem wallet client for the depositor
await walletClient.writeContract({
address: SPYx,
abi: erc20Abi,
functionName: "approve",
args: [wSPYx, amount],
});
await walletClient.writeContract({
address: wSPYx,
abi: erc4626Abi,
functionName: "deposit",
args: [amount, walletClient.account.address],
});在相互组合的各类协议中借贷、交易和赚取收益,从Aave到Uniswap。
出块时间
300 ms
每300 ms产生一个新区块,让网络为实时应用保持快速响应。
最终确定性
600 ms
交易在600 ms内达到链上最终确定性,此后不可逆转。
交易成本
不到一美分
网络费用不到一美分,让高频、小额交易切实可行。
兼容性
完全兼容EVM
与以太坊字节码兼容:为以太坊构建的合约、钱包和工具都能在Monad上运行。














