@paxoslabs/amplify-sdk
v0.4.2
Published
Paxos Labs Amplify SDK
Downloads
4,669
Readme
_____ .__ .__ _____ _________________ ____ __.
/ _ \ _____ ______ | | |__|/ ____\__.__. / _____/\______ \ | |/ _|
/ /_\ \ / \\____ \| | | \ __< | | \_____ \ | | \| <
/ | \ Y Y \ |_> > |_| || | \___ | / \ | ` \ | \
\____|__ /__|_| / __/|____/__||__| / ____| /_______ //_______ /____|__ \
\/ \/|__| \/ \/ \/ \/Paxos Labs Amplify SDK
A TypeScript SDK for interacting with Paxos Labs Amplify Vaults, providing type-safe functions for discovering vaults, depositing assets, and withdrawing across multiple blockchain networks.
Features
- Vault Discovery - Query available vaults and supported assets via API
- Deposits - Deposit assets into vaults with slippage protection
- Withdrawals - Withdraw assets from vaults with deadline protection
- Permit Deposits - Gas-optimized deposits using EIP-2612 permit signatures
- Cache Management - Optimize API calls with built-in caching
- Multi-Chain Support - Seamless operations across 7+ blockchain networks
- Full TypeScript Support - Complete type definitions and autocomplete
- React Ready - Works with viem (vanilla) and wagmi (React hooks)
Installation
# npm
npm install @paxoslabs/amplify-sdk viem
# yarn
yarn add @paxoslabs/amplify-sdk viem
# pnpm
pnpm add @paxoslabs/amplify-sdk viem
# For React apps, also install wagmi
pnpm add wagmi @tanstack/react-queryQuick Start
import {
initAmplifySDK,
prepareDepositAuthorization,
prepareDeposit,
DepositAuthMethod,
} from "@paxoslabs/amplify-sdk";
// Initialize SDK with your API key
await initAmplifySDK("pxl_your_api_key");
// Or initialize with custom RPC URLs for better reliability
await initAmplifySDK("pxl_your_api_key", {
rpcUrls: {
1: "https://my-eth-rpc.com", // Ethereum
999: "https://my-hyperEVM-rpc.com", // HyperEVM
},
});
// Prepare deposit authorization (auto-detects permit vs approval)
const auth = await prepareDepositAuthorization({
yieldType: "CORE",
depositAsset: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
depositAmount: "1000.0",
to: userAddress,
chainId: 1,
});
// Shared deposit parameters
const depositParams = {
yieldType: "CORE",
depositAsset: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
depositAmount: "1000.0",
to: userAddress,
chainId: 1,
};
// Handle based on authorization method
if (auth.method === DepositAuthMethod.PERMIT) {
// Token supports EIP-2612: sign permit and deposit in one transaction
const signature = await signTypedData(auth.permitData);
const tx = await prepareDeposit({
...depositParams,
signature,
deadline: auth.permitData.message.deadline,
});
await writeContract(tx.txData);
} else if (auth.method === DepositAuthMethod.APPROVAL) {
// Token requires ERC20 approval: approve first, then deposit
await writeContract(auth.txData);
const tx = await prepareDeposit(depositParams);
await writeContract(tx.txData);
} else if (auth.method === DepositAuthMethod.ALREADY_APPROVED) {
// Sufficient allowance exists: proceed directly to deposit
const tx = await prepareDeposit(depositParams);
await writeContract(tx.txData);
}Documentation
Full documentation at https://developers.paxoslabs.com/
License
BSD © Paxos Labs
Need Help?
