@paxoslabs/earn-sdk
Version:
Paxos Labs Earn SDK
136 lines (131 loc) • 3.7 kB
JavaScript
;
var chunkEG4XMABU_js = require('./chunk-EG4XMABU.js');
var chunkQ52QVNPZ_js = require('./chunk-Q52QVNPZ.js');
var chunkTFV7VK2Y_js = require('./chunk-TFV7VK2Y.js');
var chunkNEVIH2LY_js = require('./chunk-NEVIH2LY.js');
var chunkU72Q2IH5_js = require('./chunk-U72Q2IH5.js');
var viem = require('viem');
async function getVaultAllowance({
tokenAddress,
spenderAddress,
userAddress,
chainId
}) {
const client = await chunkTFV7VK2Y_js.getClient(chainId);
const allowance = await client.readContract({
abi: viem.erc20Abi,
address: tokenAddress,
functionName: "allowance",
args: [userAddress, spenderAddress]
});
return allowance;
}
async function getTotalSupply({
tokenAddress,
chainId
}) {
const client = await chunkTFV7VK2Y_js.getClient(chainId);
const totalSupply = await client.readContract({
abi: viem.erc20Abi,
address: tokenAddress,
functionName: "totalSupply"
});
return totalSupply;
}
// src/contracts/chainlink-abi.ts
var ChainlinkAbi = [
{
type: "function",
name: "latestRoundData",
inputs: [],
outputs: [
{
name: "roundId",
type: "uint80",
internalType: "uint80"
},
{
name: "answer",
type: "int256",
internalType: "int256"
},
{
name: "startedAt",
type: "uint256",
internalType: "uint256"
},
{
name: "updatedAt",
type: "uint256",
internalType: "uint256"
},
{
name: "answeredInRound",
type: "uint80",
internalType: "uint80"
}
],
stateMutability: "view"
}
];
// src/api/chainlink.ts
async function getEthPrice({
chainId
}) {
const client = await chunkTFV7VK2Y_js.getClient(chainId);
const priceData = await client.readContract({
abi: ChainlinkAbi,
address: chunkU72Q2IH5_js.CHAINLINK_ADDRESS,
functionName: "latestRoundData",
args: []
});
if (!priceData || !priceData[1]) {
throw new Error("Failed to fetch ETH price from Chainlink");
}
return priceData[1];
}
Object.defineProperty(exports, "fetchWithdrawAssets", {
enumerable: true,
get: function () { return chunkEG4XMABU_js.fetchWithdrawAssets; }
});
Object.defineProperty(exports, "getAssetSlippage", {
enumerable: true,
get: function () { return chunkEG4XMABU_js.getAssetSlippage; }
});
Object.defineProperty(exports, "getPausedStates", {
enumerable: true,
get: function () { return chunkQ52QVNPZ_js.getPausedStates; }
});
Object.defineProperty(exports, "getErc20Allowance", {
enumerable: true,
get: function () { return chunkTFV7VK2Y_js.getErc20Allowance; }
});
Object.defineProperty(exports, "getErc20Balance", {
enumerable: true,
get: function () { return chunkTFV7VK2Y_js.getErc20Balance; }
});
Object.defineProperty(exports, "getErc20Decimals", {
enumerable: true,
get: function () { return chunkTFV7VK2Y_js.getErc20Decimals; }
});
Object.defineProperty(exports, "getPreviewFee", {
enumerable: true,
get: function () { return chunkTFV7VK2Y_js.getPreviewFee; }
});
Object.defineProperty(exports, "getRateInQuoteWithAssetDecimals", {
enumerable: true,
get: function () { return chunkTFV7VK2Y_js.getRateInQuoteWithAssetDecimals; }
});
Object.defineProperty(exports, "fetchVaultConfig", {
enumerable: true,
get: function () { return chunkNEVIH2LY_js.fetchVaultConfig; }
});
Object.defineProperty(exports, "toChainId", {
enumerable: true,
get: function () { return chunkNEVIH2LY_js.toChainId; }
});
exports.getEthPrice = getEthPrice;
exports.getTotalSupply = getTotalSupply;
exports.getVaultAllowance = getVaultAllowance;
//# sourceMappingURL=core.js.map
//# sourceMappingURL=core.js.map