Open gravenp opened 3 months ago
@tnrdd Can the details you mentioned from the call here regarding the appropriate functions & approaches to querying/storing the token types?
From @tnrdd
The function to check what kind of super token the pool is using are symbol()
and getUnderlyingToken()
, if using viem we can do something like this
const publicClient = createPublicClient({
transport: http("https://rpc.degen.tips"),
batch: {
multicall: true,
},
});
const allocationTokenSymbol = await publicClient.readContract({
address: queryRes.recipient.poolChain.allocationToken,
abi: superTokenAbi,
functionName: "symbol",
});
const underlyingToken = await publicClient.readContract({
address: queryRes.recipient.poolChain.allocationToken,
abi: superTokenAbi,
functionName: "getUnderlyingToken",
});
const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
let isPureSuperToken = false;
let isNativeSuperToken = false;
if (
allocationTokenSymbol === "ETHx" ||
allocationTokenSymbol === "DEGENx"
) {
isNativeSuperToken = true;
} else if (underlyingToken === ZERO_ADDRESS) {
isPureSuperToken = true;
}
If isPureSuperToken
is true we can avoid showing the wrapping button, if not we can pass to the query params of the wrapping handler something like isWrapperSuperToken: "true"
depending on if the super token is native or not and use it in https://github.com/flow-state-coop/sqf-frames/blob/main/app/frames/stream/wrapDegen/route.ts to decide what upgrade function function to call like this
if (isWrapperSuperToken) {
wrapCalldata = encodeFunctionData({
abi: superTokenAbi,
functionName: "upgradeByETH",
});
} else {
wrapCalldata = encodeFunctionData({
abi: superTokenAbi,
functionName: "upgrade",
args: [parseEther(amount)],
});
}
if isWrapperSuperToken
is true value
here should be 0
I made a commit to update the super token ABI so that it has all the functions needed for all kind of super tokens, you can pull it from main
Depending on what the underlying token is for SQF donations, Frame functions/design will need to adjust:
wrap
buttons presented with the frame should call the right function depending on the token type.