Package Exports
- @xweb3/react-hooks
- @xweb3/react-hooks/dist/index.esm.js
- @xweb3/react-hooks/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@xweb3/react-hooks) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@xweb3/react-hooks
Api Host
- Dev Version https://api-dev.png.fi
- Staging Version https://api-staging.png.fi
- Online Version https://api.png.fi
react hooks base api
xweb3Provider
import { xweb3Provider } from '@xweb3/react-hooks';
import { Connection } from '@solana/web3.js';
const connection = new Connection(
'https://api.png.fi'
);
const App = ({ children }) => {
const wallet = useWallet();
return (
<xweb3Provider
connection={connection}
cluster="mainnet-beta"
publicKey={wallet.publicKey}
>
{/* You can use useBonding in children now */}
{children}
</xweb3Provider>
)
}useTokens
const { data, error, loading } = useTokens();usePools
const { data, error, loading } = usePools();useMarkets
const { data, error, loading } = useMarkets();usePrices
const { data, error, loading } = usePrices(['SOL', 'UST']);useBonding
const { data, error, loading } = useBonding();useStaking
const { data, error, loading } = useStaking();useRewards
const { data, error, loading } = useRewards();useBalances
const { data, error, loading } = useBalances(user);useUserVesting
const { data, error, loading } = useUserVesting(owner, vestConfig);Distributors
useDistributorsUser
const { data, error, loading } = useDistributorsUser(user: string);useDistributorEpochs
const { data, error, loading } = useDistributorEpochs(distributor: string);useMerkleRewardsUser
const { data, error, loading } = useMerkleRewardsUser(user: string);useMerkleRewardssDistributor
const { data, error, loading } = useMerkleRewardssDistributor(distributor: string);useDistributorRewardsEpoch
const { data, error, loading } = useDistributorRewardsEpoch(distributor: string, epoch: string);useDistributorMerkleRewards
interface IMerkleRewardsUpsertRequest {
// A string to identify the project using this. For now, use your token symbol.
projectID: string;
// Describes what the rewards. Display in the rewards caiming UI.
title: string;
// (base58 pubkey) An account key for storing the merkle tree rewards state. You need to have this secert key to initialize the on-chain sate.
base: string;
// A unique ID to indicate a particular merkle tree update. Repeated POST using the same epochID is idempotent.
epochID: string;
// (base58 pubkey) The account key that should sign the merkle tree upsert
adminAuth: string;
// The reward type for this merkle tree.
mint: string;
// List of rewards to be included in the update. For each update, the amount would be added to the existing amount. The destination address is the owner address of token accounts, not the associated token account addresses.
rewards: { dest: string, amount: string }[]
}
interface IMerkleRewardsUpsertResponse {
// Dex string of the merkle root
merkleRoot: string;
// (base58 pubkey) Distributor state PDA derived from the `base` pubkey.
distributor: string;
// The transaction you should sign & submit
tx: string; // serialized hex string of transaction
}
const { data, error, loading }: {
data: IMerkleRewardsUpsertResponse,
error: IError,
loading: boolean
} = useDistributorMerkleRewards(options: IMerkleRewardsUpsertRequest);