LLX is a provider agnostic dev kit interacting with the main dapps on the LightLink network
npm install @cryptokass/llx!LLX
LLX simplifies interacting with the main dapps on the LightLink network. Its platform agnostic and can be used with ethers, wagmi, viem, etc.
- Token Actions: fetch token info, balance, allowance, permit2 allowance
- Swaps: quote, swap
- Domain resolution: resolve ENS domain to address
- Allowance and Permit2: prepare and execute allowance and permit2 transactions
- Bridge: bridge ETH between L1 (Ethereum, Sepolia) and L2 (Phoenix, Pegasus)
``bash`
npm install --save @cryptokass/llx
`ts
import { fetchTokenInfo } from "llx";
import { Phoenix } from "llx/chains";
const { name, symbol, decimals, totalSupply } = await fetchTokenInfo(
Phoenix.id,
TOKEN_ADDRESS
);
const balance = await fetchBalance(Phoenix.id, TOKEN_ADDRESS);
`
`ts
import { swap } from "llx";
import { Phoenix } from "llx/chains";
const AMOUNT_IN = 1n 10n * 6n;
const FEE = 3000;
// First get a quote for the swap
const quote = await swap.quoteExactInput(Phoenix.id, {
fromToken,
toToken,
amountIn: AMOUNT_IN,
fee: FEE,
});
// Then prepare the swap transaction
const preparedTxs = await swap.prepareSwapExactInput(Phoenix.id, {
tokenIn: fromToken,
tokenOut: toToken,
amountIn: AMOUNT_IN,
amountOut: quote.amountOut,
fee: FEE,
slippage: 0.1, // 10%
});
// Finally run the prepared tx with your provider. For example using viem:
for (const tx of preparedTxs) {
const hash = await walletClient.sendTransaction({
account: myAccount,
to: tx.to,
value: tx.value,
data: tx.data,
});
// wait for the tx to be mined
await publicClient.waitForTransactionReceipt({
hash,
});
}
`
`ts
import { resolveEnsDomain } from "llx";
import { Phoenix } from "llx/chains";
const address = await resolveEnsDomain(Phoenix.id, "lightlink.ll");
`
`ts
import { ensureAllowance } from "llx";
import { Phoenix } from "llx/chains";
// Ensure allowance will prepare approval transactions for the token
// if there is not sufficient allowance.
const txs = await ensureAllowance(
Phoenix.id,
TOKEN_ADDRESS,
myAccount,
ALLOWANCE_AMOUNT
);
// You can now run the prepared txs with your provider. For example using viem:
for (const tx of txs) {
const hash = await walletClient.sendTransaction({
account: myAccount,
to: tx.to,
value: tx.value,
data: tx.data,
});
// wait for the tx to be mined
await publicClient.waitForTransactionReceipt({
hash,
});
}
`
Only ETH bridging is supported for now.
`ts
import { prepareBridgeTransfer } from "llx";
import { Phoenix } from "llx/chains";
const txs = await prepareBridgeTransfer(Phoenix.id, {
amount: AMOUNT,
});
for (const tx of txs) {
const hash = await walletClient.sendTransaction({
account: myAccount,
to: tx.to,
value: tx.value,
data: tx.data,
});
}
``