To start interacting with the SQFSuperFluidStrategy contract, create a new
instance of SQFSuperFluidStrategy
:
import { SQFSuperFluidStrategy } from "@allo-team/allo-v2-sdk/";
const strategy = new SQFSuperFluidStrategy({
chain: 1,
});
If you are aware of the poolId, you can load that while creating the instance
import { SQFSuperFluidStrategy } from "@allo-team/allo-v2-sdk/";
const strategy = new SQFSuperFluidStrategy({
chain: 1,
poolId: 1, // valid pool Id
});
To perform operations that require a specific pool and strategy contract, set the pool ID and strategy contract address:
const poolId = 1;
const strategyAddress = "0xYourStrategyContractAddress";
await strategy.setPoolId(poolId);
strategy.setContract(strategyAddress);
Retrieve the native token address used in the strategy:
const nativeToken = await strategy.getNative();
console.log(`Native Token Address: ${nativeToken}`);
Check if a specific allocator has already cast their allocation
const allocatorAddress = "0xYourAllocatorAddress";
const isAllocator = await strategy.allocator(allocatorAddress);
console.log(`Is Allocator: ${isAllocator}`);
Check if a specific allocator has already cast their allocation to a specific recipient
const allocatorAddress = "0xYourAllocatorAddress";
const recipientAddress = "0xYourRecipientAddress";
const isAllocated = await strategy.allocated(
allocatorAddress,
recipientAddress,
);
console.log(`Is Allocated: ${isAllocated}`);
Retrieve the start time of the registration period:
const startTime = await strategy.registrationStartTime();
console.log(`Registration Start Time: ${startTime}`);
Retrieve the end time of the registration period:
const endTime = await strategy.registrationEndTime();
console.log(`Registration End Time: ${EndTime}`);
Retrieve the start time of the allocation period:
const startTime = await strategy.allocationStartTime();
console.log(`Allocation Start Time: ${startTime}`);
Retrieve the end time of the allocation period:
const endTime = await strategy.allocationEndTime();
console.log(`Allocation End Time: ${endTime}`);
Retrieve the associated Allo instance for the strategy:
const alloInstance = await strategy.getAllo();
console.log(`Allo Instance: ${alloInstance}`);
Retrieve the total amount available in the pool:
const poolAmount = await strategy.getPoolAmount();
console.log(`Pool Amount: ${poolAmount}`);
Retrieve the current pool ID associated with the strategy:
const currentPoolId = await strategy.getPoolId();
console.log(`Current Pool ID: ${currentPoolId}`);
Retrieve details of a specific recipient:
const recipientId = "0xYourRecipientId";
const recipientDetails = await strategy.getRecipient(recipientId);
console.log(`Recipient Details: ${recipientDetails}`);
Retrieve the status of a specific recipient:
const recipientId = "0xYourRecipientId";
const recipientStatus = await strategy.getRecipientStatus(recipientId);
console.log(`Recipient Status: ${recipientStatus}`);
Retrieve the unique identifier for the strategy:
const strategyId = await strategy.getStrategyId();
console.log(`Strategy ID: ${strategyId}`);
Check if the pool associated with the strategy is active:
const isActive = await strategy.isPoolActive();
console.log(`Is Pool Active: ${isActive}`);
Check if the strategy uses a registry anchor:
const useRegistryAnchor = await strategy.useRegistryAnchor();
console.log(`Use Registry Anchor: ${useRegistryAnchor}`);
const metadataRequired = await strategy.metadataRequired();
console.log(`Require Metadata: ${metadataRequired}`);
Check if a specific allocator address is valid for the strategy:
const allocatorAddress = "0xYourAllocatorAddress";
const isValid = await strategy.isValidAllocator(allocatorAddress);
console.log(`Is Allocator Valid: ${isValid}`);
const recipientId = "0xYourRecipientId";
const totalUnits = await strategy.totalUnitsByRecipient(recipientId);
console.log(`Total Units: ${totalUnits}`);
Generate deployment parameters for deploying a new strategy:
import { StrategyType } from "@allo-team/allo-v2-sdk/dist/strategies/MicroGrantsStrategy/types";
const strategyType = StrategyType.SQFSuperFluid; // Specify the strategy type
const deployParams = strategy.getDeployParams(strategyType);
// Client could be from ethers, viem, etc.
const hash = await walletClient!.deployContract({
abi: deployParams.abi,
bytecode: deployParams.bytecode as `0x${string}`,
args: [],
});
Generate transaction data for updating pool timestamps:
const registrationStartTime = 1642320000; // Example timestamp, replace with the actual value
const registrationEndTime = 1642410000; // Example timestamp, replace with the actual value
const allocationStartTime = 1642320000; // Example timestamp, replace with the actual value
const allocationEndTime = 1642410000; // Example timestamp, replace with the actual value
const txData = strategy.getUpdatePoolTimestampsData(registrationStartTime, registrationEndTime, allocationStartTime, allocationEndTime);
// Client could be from ethers, viem, etc.
const tx = await sendTransaction({
to: txData.to as string,
data: txData.data,
value: BigInt(txData.value),
});