- Allo Table of Contents
- Allo
- Initialization
- Read Only Functions
- Write Functions
- Create Pool With Custom Strategy
- Create Pool
- Update Pool Metadata
- Update Registry
- Update Treasury
- Update Percent Fee
- Update Base Fee
- Add to Cloneable Strategies
- Remove from Cloneable Strategies
- Add Pool Manager
- Remove Pool Manager
- Recover Funds
- Register Recipient
- Batch Register Recipient
- Fund Pool
- Allocate
- Batch Allocate
- Distribute
The Allo class provides a set of functions for interacting with the Allo contract's view and write functions. This README provides examples and explanations for using these functions.
To create a new Allo instance, you need to provide the chain information. In this example, we're using the 5 chain information.
import { Allo } from "@allo-team/allo-v2-sdk/";
const allo = new Allo({ chain: 5 });
This allo
instance can then be used to call various read and transactional functions provided by the Allo module. Refer to the sections below for detailed examples on how to use these functions. Remember to replace placeholder values with actual values according to your requirements.
To retrieve the Allo contract address:
const alloAddress: `0x${string}` = allo.address();
console.log(alloAddress);
To retrieve the Fee Denominator:
const feeDenominator: number = await allo.getFeeDenominator();
console.log(feeDenominator);
To check if an address is a Pool Admin:
const poolId = 1; // Replace with the desired pool ID
const address = "your_address_here";
const isPoolAdmin: boolean = await allo.isPoolAdmin(poolId, address);
console.log(isPoolAdmin);
To check if an address is a Pool Manager:
const poolId = 1; // Replace with the desired pool ID
const address = "your_address_here";
const isPoolManager: boolean = await allo.isPoolManager(poolId, address);
console.log(isPoolManager);
To retrieve the Strategy address for a specific pool:
const poolId = 1; // Replace with the desired pool ID
const strategyAddress: string = await allo.getStrategy(poolId);
console.log(strategyAddress);
To retrieve the Percent Fee:
const percentFee: number = await allo.getPercentFee();
console.log(percentFee);
To retrieve the Base Fee:
const baseFee: number = await allo.getBaseFee();
console.log(baseFee);
To retrieve the Treasury address:
const treasuryAddress: string = await allo.getTreasury();
console.log(treasuryAddress);
To retrieve the Registry address:
const registryAddress: string = await allo.getRegistry();
console.log(registryAddress);
To check if the Strategy is cloneable:
const isCloneable: boolean = await allo.isCloneableStrategy();
console.log(isCloneable);
To retrieve information about a specific pool:
const poolId = 1; // Replace with the desired pool ID
const pool: Pool = await allo.getPool(poolId);
console.log(pool);
To create a new pool with a custom strategy:
import { CreatePoolArgs } from "@allo-team/allo-v2-sdk/dist/Allo/types";
import { TransactionData } from "@allo-team/allo-v2-sdk/dist/Common/types";
const createPoolArgs: CreatePoolArgs = {
profileId: "your_profileId_here", // sender must be a profile member
strategy: "deployed_strategy_contract", // deployed strategy contract
initStrategyData: initStrategyData, // unique to the strategy
token: "token_address_here",
amount: "pool_amount_here",
metadata: {
protocol: BigInt(1),
pointer: "your_ipfs_hash",
},
managers: ["pool_manager_address"],
};
const txData: TransactionData = allo.createPoolWithCustomStrategy(createPoolArgs);
// Client could be from ethers, viem, etc.
const hash = await client.sendTransaction({
data: txData.data,
to: txData.to,
value: BigInt(txData.value),
});
console.log(`Transaction hash: ${hash}`);
To create a new pool:
import { CreatePoolArgs } from "@allo-team/allo-v2-sdk/dist/Allo/types";
import { TransactionData } from "@allo-team/allo-v2-sdk/dist/Common/types";
const createPoolArgs: CreatePoolArgs = {
profileId: "your_profileId_here", // sender must be a profile member
strategy: "approved_strategy_contract", // approved strategy contract
initStrategyData: initStrategyData, // unique to the strategy
token: "token_address_here",
amount: "pool_amount_here",
metadata: {
protocol: BigInt(1),
pointer: "your_ipfs_hash",
},
managers: ["pool_manager_address"],
};
const txData: TransactionData = allo.createPool(createPoolArgs);
// Client could be from ethers, viem, etc.
const hash = await client.sendTransaction({
data: txData.data,
to: txData.to,
value: BigInt(txData.value),
});
console.log(`Transaction hash: ${hash}`);
To update pool metadata:
import { UpdateMetaDataArgs } from "@allo-team/allo-v2-sdk/dist/Allo/types";
import { TransactionData } from "@allo-team/allo-v2-sdk/dist/Common/types";
const updateMetadataArgs: UpdateMetaDataArgs = {
poolId = 1,
metadata: {
protocol: BigInt(1),
pointer: "bafybeia4khbew3r2mkflyn7nzlvfzcb3qpfeftz5ivpzfwn77ollj47gqi",
},
};
const txData: TransactionData = allo.updatePoolMetadata(updateMetadataArgs);
// Client could be from ethers, viem, etc.
const hash = await client.sendTransaction({
data: txData.data,
to: txData.to,
value: BigInt(txData.value),
});
console.log(`Transaction hash: ${hash}`);
To update the Registry address:
import { TransactionData } from "@allo-team/allo-v2-sdk/dist/Common/types";
const registryAddress = "new_registry_address_here";
const txData
: TransactionData = allo.updateRegistry(registryAddress);
// Client could be from ethers, viem, etc.
const hash = await client.sendTransaction({
data: txData.data,
to: txData.to,
value: BigInt(txData.value),
});
console.log(`Transaction hash: ${hash}`);
To update the Treasury address:
import { TransactionData } from "@allo-team/allo-v2-sdk/dist/Common/types";
const treasuryAddress = "new_treasury_address_here";
const txData: TransactionData = allo.updateTreasury(treasuryAddress);
// Client could be from ethers, viem, etc.
const hash = await client.sendTransaction({
data: txData.data,
to: txData.to,
value: BigInt(txData.value),
});
console.log(`Transaction hash: ${hash}`);
To update the Percent Fee:
import { TransactionData } from "@allo-team/allo-v2-sdk/dist/Common/types";
const percentage = 1e12; // Replace with the desired percentage
const txData: TransactionData = allo.updatePercentFee(percentage);
// Client could be from ethers, viem, etc.
const hash = await client.sendTransaction({
data: txData.data,
to: txData.to,
value: BigInt(txData.value),
});
console.log(`Transaction hash: ${hash}`);
To update the Base Fee:
import { TransactionData } from "@allo-team/allo-v2-sdk/dist/Common/types";
const percentage = 1e12; // Replace with the desired percentage
const txData: TransactionData = allo.updateBaseFee(percentage);
// Client could be from ethers, viem, etc.
const hash = await client.sendTransaction({
data: txData.data,
account,
to: txData.to,
value: BigInt(txData.value),
});
console.log(`Transaction hash: ${hash}`);
To add a strategy to the list of cloneable strategies:
import { TransactionData } from "@allo-team/allo-v2-sdk/dist/Common/types";
const strategyAddress = "strategy_address_here";
const txData: TransactionData = allo.addToCloneableStrategies(strategyAddress);
// Client could be from ethers, viem, etc.
const hash = await client.sendTransaction({
data: txData.data,
to: txData.to,
value: BigInt(txData.value),
});
console.log(`Transaction hash: ${hash}`);
To remove a strategy from the list of cloneable strategies:
import { TransactionData } from "@allo-team/allo-v2-sdk/dist/Common/types";
const strategyAddress = "strategy_address_here";
const txData: TransactionData = allo.removeFromCloneableStrategies(strategyAddress);
// Client could be from ethers, viem, etc.
const hash = await client.sendTransaction({
data: txData.data,
to: txData.to,
value: BigInt(txData.value),
});
console.log(`Transaction hash: ${hash}`);
To add a manager to a pool:
import { TransactionData } from "@allo-team/allo-v2-sdk/dist/Common/types";
const poolId = 1; // Replace with the desired pool ID
const manager = "manager_address_here";
const txData: TransactionData = allo.addPoolManager(poolId, manager);
// Client could be from ethers, viem, etc.
const hash = await client.sendTransaction({
data: txData.data,
to: txData.to,
value: BigInt(txData.value),
});
console.log(`Transaction hash: ${hash}`);
To remove a manager from a pool:
import { TransactionData } from "@allo-team/allo-v2-sdk/dist/Common/types";
const poolId = 1; // Replace with the desired pool ID
const manager = "manager_address_here";
const txData: TransactionData = allo.removePoolManager(poolId, manager);
// Client could be from ethers, viem, etc.
const hash = await client.sendTransaction({
data: txData.data,
to: txData.to,
value: BigInt(txData.value),
});
console.log(`Transaction hash: ${hash}`);
To recover funds:
import { TransactionData } from "@allo-team/allo-v2-sdk/dist/Common/types";
const token = "token_address_here";
const recipient = "recipient_address_here";
const txData: TransactionData = allo.recoverFunds(token, recipient);
// Client could be from ethers, viem, etc.
const hash = await client.sendTransaction({
data: txData.data,
to: txData.to,
value: BigInt(txData.value),
});
console.log(`Transaction hash: ${hash}`);
To register a recipient for a specific pool:
import { TransactionData } from "@allo-team/allo-v2-sdk/dist/Common/types";
const poolId = 1; // Replace with the desired pool ID
const strategyData = "strategy_data_here";
const txData: TransactionData = allo.registerRecipient(poolId, strategyData);
// Client could be from ethers, viem, etc.
const hash = await client.sendTransaction({
data: txData.data,
to: txData.to,
value: BigInt(txData.value),
});
console.log(`Transaction hash: ${hash}`);
To batch register recipients for multiple pools:
import { TransactionData } from "@allo-team/allo-v2-sdk/dist/Common/types";
const poolIds = [1, 2, 3]; // Replace with the desired pool IDs
const strategyData = ["strategy_data_1", "strategy_data_2", "strategy_data_3"]; // Replace with the corresponding strategy data
const txData: TransactionData = allo.batchRegisterRecipient(poolIds, strategyData);
// Client could be from ethers, viem, etc.
const hash = await client.sendTransaction({
data: txData.data,
to: txData.to,
value: BigInt(txData.value),
});
console.log(`Transaction hash: ${hash}`);
To fund a pool with a specific amount:
import { TransactionData } from "@allo-team/allo-v2-sdk/dist/Common/types";
const poolId = 1; // Replace with the desired pool ID
const amount = 1e18; // Replace with the desired amount
const txData: TransactionData = allo.fundPool(poolId, amount);
// Client could be from ethers, viem, etc.
const hash = await client.sendTransaction({
data: txData.data,
to: txData.to,
value: BigInt(txData.value),
});
console.log(`Transaction hash: ${hash}`);
To allocate funds for a specific pool:
import { TransactionData } from "@allo-team/allo-v2-sdk/dist/Common/types";
const poolId = 1; // Replace with the desired pool ID
const strategyData = "strategy_data_here";
const txData: TransactionData = allo.allocate(poolId, strategyData);
// Client could be from ethers, viem, etc.
const hash = await client.sendTransaction({
data: txData.data,
account,
to: txData.to,
value: BigInt(txData.value),
});
console.log(`Transaction hash: ${hash}`);
To batch allocate funds to multiple pools:
import { TransactionData } from "@allo-team/allo-v2-sdk/dist/Common/types";
const poolIds = [1, 2, 3]; // Example pool IDs
const strategyData = ["0xStrategyData1", "0xStrategyData2", "0xStrategyData3"]; // Example strategy data
const txData: TransactionData = allo.batchAllocate(poolIds, strategyData);
// Use a client to send the transaction
const hash = await client.sendTransaction({
data: txData.data,
to: txData.to,
value: BigInt(txData.value),
});
console.log(`Transaction hash: ${hash}`);
To distribute funds to multiple recipients in a pool:
import { TransactionData } from "@allo-team/allo-v2-sdk/dist/Common/types";
const poolId = 1;
const recipientIds = ["0xRecipient1", "0xRecipient2", "0xRecipient3"]; // Example recipient addresses
const strategyData = "0xStrategyData"; // Example strategy data
const txData: TransactionData = allo.distribute(poolId, recipientIds, strategyData);
// Use a client to send the transaction
const hash = await client.sendTransaction({
data: txData.data,
to: txData.to,
value: BigInt(txData.value),
});
console.log(`Transaction hash: ${hash}`);