Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: external calls for cvx crv extra rewards #197

Merged
merged 2 commits into from
Oct 5, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 38 additions & 3 deletions packages/sdk/src/internal/External/Convex.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Abis from "@enzymefinance/abis";
import { Assertion, Viem } from "@enzymefinance/sdk/Utils";
import { type Address, type PublicClient } from "viem";
import { type Address, type PublicClient, parseAbi } from "viem";

//--------------------------------------------------------------------------------------------
// CVX MINING
Expand Down Expand Up @@ -140,12 +140,14 @@ export async function getUserLocks(
lockNumber: bigint;
}>,
) {
return Viem.readContract(client, args, {
const [amount, boosted, unlockTime] = await Viem.readContract(client, args, {
abi: cvxLockerV2Abi,
address: args.voteLockedConvexToken,
functionName: "userLocks",
args: [args.user, args.lockNumber],
});

return { amount, boosted, unlockTime };
}

//--------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -277,7 +279,7 @@ export async function getPlatformFee(
}

//--------------------------------------------------------------------------------------------
// CVX BOOSTER
// CVX CRV REWARDS
//--------------------------------------------------------------------------------------------

// ABI from https://etherscan.io/address/0x3fe65692bfcd0e6cf84cb1e7d24108e434a7587e#code
Expand Down Expand Up @@ -349,6 +351,39 @@ export async function getExtraRewards(
});
}

//--------------------------------------------------------------------------------------------
// CVX CRV EXTRA REWARDS
//--------------------------------------------------------------------------------------------

export async function getExtraRewardsRewards(
client: PublicClient,
args: Viem.ContractCallParameters<{
cvxCrvExtraRewards: Address;
user: Address;
}>,
) {
return Viem.readContract(client, args, {
abi: parseAbi(["function rewards(address user) view returns (uint256)"]),
functionName: "rewards",
address: args.cvxCrvExtraRewards,
args: [args.user],
});
}

export async function getExtraRewardsRewardToken(
client: PublicClient,
args: Viem.ContractCallParameters<{
cvxCrvExtraRewards: Address;
user: Address;
}>,
) {
return Viem.readContract(client, args, {
abi: parseAbi(["function rewardToken() view returns (address)"]),
functionName: "rewardToken",
address: args.cvxCrvExtraRewards,
});
}

//--------------------------------------------------------------------------------------------
// STAKING WRAPPER
//--------------------------------------------------------------------------------------------
Expand Down
Loading