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

chore: new payment splitter factory + pricing for HAT on mainnet #736

Merged
merged 12 commits into from
Jul 26, 2024
Merged
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hats.finance/shared",
"version": "1.1.109",
"version": "1.1.112",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
23 changes: 7 additions & 16 deletions packages/shared/src/abis/HATPaymentSplitterFactory_abi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ export const HATPaymentSplitterFactory_abi = [
stateMutability: "nonpayable",
type: "constructor",
},
{ inputs: [], name: "ArrayLengthMismatch", type: "error" },
{ inputs: [], name: "DuplicatedPayee", type: "error" },
{ inputs: [], name: "NoPayees", type: "error" },
{ inputs: [], name: "ZeroAddress", type: "error" },
{ inputs: [], name: "ZeroShares", type: "error" },
{
anonymous: false,
inputs: [{ indexed: true, internalType: "address", name: "_hatPaymentSplitter", type: "address" }],
Expand All @@ -27,24 +32,10 @@ export const HATPaymentSplitterFactory_abi = [
stateMutability: "view",
type: "function",
},
{
inputs: [{ internalType: "address", name: "", type: "address" }],
name: "nonce",
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
stateMutability: "view",
type: "function",
},
{
inputs: [{ internalType: "address", name: "_deployer", type: "address" }],
name: "predictNextSplitterAddress",
outputs: [{ internalType: "address", name: "", type: "address" }],
stateMutability: "view",
type: "function",
},
{
inputs: [
{ internalType: "uint256", name: "_nonce", type: "uint256" },
{ internalType: "address", name: "_deployer", type: "address" },
{ internalType: "address[]", name: "_payees", type: "address[]" },
{ internalType: "uint256[]", name: "_shares", type: "uint256[]" },
],
name: "predictSplitterAddress",
outputs: [{ internalType: "address", name: "", type: "address" }],
Expand Down
12 changes: 6 additions & 6 deletions packages/shared/src/config/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const ChainsConfig: { [index: number]: IChainConfiguration } = {
growthMultisig: "0x53E9152417EcD338E7e85cCFBc1F5eDA053C910c",
whitelistedReviewers: ["0x5b7B59862447Cf3dE479C8166cc2784cbf8e53D6"],
uniswapSubgraph: "https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3",
paymentSplitterFactory: "0x0aA1464dB005857Db8FC3E0470d306FB9E54b908",
paymentSplitterFactory: "0x8633212777Da1394bb379Df9520f098B014fB77b",
infuraKey: "mainnet",
provider: "https://eth-mainnet.g.alchemy.com/v2/gRQ81Lr6Vnbm5WgD4Et6csRjnEv3V83Z",
},
Expand All @@ -76,7 +76,7 @@ export const ChainsConfig: { [index: number]: IChainConfiguration } = {
growthMultisig: "0xA5BA173Cf84D532FE368690D37eff843678E0bFF",
whitelistedReviewers: ["0x5b7B59862447Cf3dE479C8166cc2784cbf8e53D6"],
uniswapSubgraph: undefined,
paymentSplitterFactory: "0x09959581544511916A80185FFe3De3Df11D623D7",
paymentSplitterFactory: "0x8343D06cDFDe42cA0864029D5fE6138433A68a24",
infuraKey: "sepolia",
provider: "https://eth-goerli.g.alchemy.com/v2/HMtXCk0FyIfbiNAVm4Xcgr8Eqlc5_DKd",
},
Expand All @@ -95,7 +95,7 @@ export const ChainsConfig: { [index: number]: IChainConfiguration } = {
growthMultisig: "0x862966C9e09a3058DF47a29d30a429565E176D8B",
whitelistedReviewers: ["0x5b7B59862447Cf3dE479C8166cc2784cbf8e53D6"],
uniswapSubgraph: "https://api.thegraph.com/subgraphs/name/ianlapham/optimism-post-regenesis",
paymentSplitterFactory: "0x028A7C6873dFA8357c9dcF9C9d76EF2abb66256E",
paymentSplitterFactory: "0x0aA1464dB005857Db8FC3E0470d306FB9E54b908",
infuraKey: "optimism-mainnet",
provider: "https://winter-alien-reel.optimism.quiknode.pro/3b8fcb9fa592b6025c5ec16de15be9e85ed0e051",
},
Expand All @@ -114,7 +114,7 @@ export const ChainsConfig: { [index: number]: IChainConfiguration } = {
growthMultisig: "0xBCa8856B5995092Df3f100436b0Ee8056A2E065a",
whitelistedReviewers: ["0x5b7B59862447Cf3dE479C8166cc2784cbf8e53D6"],
uniswapSubgraph: "https://api.thegraph.com/subgraphs/name/ianlapham/arbitrum-minimal",
paymentSplitterFactory: "0x028A7C6873dFA8357c9dcF9C9d76EF2abb66256E",
paymentSplitterFactory: "0x83E0dfc2c1891Ada906D8F266029F2a416BC8b3f",
infuraKey: "arbitrum-mainnet",
provider: "https://few-maximum-voice.arbitrum-mainnet.quiknode.pro/5abae8858e1e7248437717c16d14ff7193d6aae6",
},
Expand All @@ -133,7 +133,7 @@ export const ChainsConfig: { [index: number]: IChainConfiguration } = {
growthMultisig: "0xa5c6d757ca69c92eea05b22924d9774658e10c62",
whitelistedReviewers: ["0x5b7B59862447Cf3dE479C8166cc2784cbf8e53D6"],
uniswapSubgraph: "https://api.thegraph.com/subgraphs/name/ianlapham/uniswap-v3-polygon",
paymentSplitterFactory: "0xadd155731473A9501881234A865FF79668F1B6cF",
paymentSplitterFactory: "0x10C483158B8aF7e91CE7068bA45eb5446789851D",
infuraKey: "polygon-mainnet",
provider: "https://frequent-billowing-smoke.matic.quiknode.pro/518ec9b749b64717da7d8495bdac26d1d27933d1",
},
Expand All @@ -151,7 +151,7 @@ export const ChainsConfig: { [index: number]: IChainConfiguration } = {
govMultisig: "0xE650ba24115AE0260d8f723F89603DaF63b496cA",
growthMultisig: "0xE650ba24115AE0260d8f723F89603DaF63b496cA",
whitelistedReviewers: ["0x5b7B59862447Cf3dE479C8166cc2784cbf8e53D6"],
paymentSplitterFactory: "0x878Cab06E6f4a85D90E5f236d326a41Ef6f44F9f",
paymentSplitterFactory: "0x1065A9e3AC47f2624293727F4b8319A0a10F6015",
// infuraKey: "polygon-mainnet",
provider: "https://frosty-convincing-choice.xdai.quiknode.pro/db844278bdba30f1567a37c679660797fbbea869",
},
Expand Down
14 changes: 12 additions & 2 deletions packages/shared/src/utils/vaults.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ import { fixObject } from "./vaultEditor.utils";

export type IVaultInfoWithCommittee = IVaultInfo & { committee: string; registered: boolean };
type IVaultInfoWithCommitteeNoHatsGovFee = Omit<IVaultInfoWithCommittee, "hatsGovFee">;
export type IVaultInfoWithCommitteeAndRewardControllers = IVaultInfoWithCommitteeNoHatsGovFee & {
rewardControllers: { id: string; token: string; tokenSymbol: string; tokenDecimals: string }[];
};

export const getAllVaultsInfoWithCommittee = async (): Promise<IVaultInfoWithCommitteeNoHatsGovFee[]> => {
export const getAllVaultsInfoWithCommittee = async (): Promise<IVaultInfoWithCommitteeAndRewardControllers[]> => {
try {
const GET_ALL_VAULTS = `
query getVaults {
Expand All @@ -25,6 +28,12 @@ export const getAllVaultsInfoWithCommittee = async (): Promise<IVaultInfoWithCom
master {
address
}
rewardControllers {
id
token: rewardToken
tokenSymbol: rewardTokenSymbol
tokenDecimals: rewardTokenDecimals
}
}
}
`;
Expand Down Expand Up @@ -52,7 +61,7 @@ export const getAllVaultsInfoWithCommittee = async (): Promise<IVaultInfoWithCom
(res) => (res as PromiseFulfilledResult<{ chainId: number; request: AxiosResponse<any> }>).value
);

const vaults: IVaultInfoWithCommitteeNoHatsGovFee[] = [];
const vaults: IVaultInfoWithCommitteeAndRewardControllers[] = [];
for (let i = 0; i < subgraphsData.length; i++) {
const chainId = subgraphsData[i].chainId;

Expand All @@ -69,6 +78,7 @@ export const getAllVaultsInfoWithCommittee = async (): Promise<IVaultInfoWithCom
registered: vault.registered,
stakingToken: vault.stakingToken,
claimsManager: vault.claimsManager,
rewardControllers: vault.rewardControllers,
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/web/sitemap-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const buildSitemap = async () => {
})
)
.filter((res) => res != null)
.map((res) => res.data.vaults)
.map((res) => res.data?.vaults ?? [])
.flat()
.filter((vault) => vault.registered);
const descriptionHashes = subgraphResults.map((vault) => vault.descriptionHash);
Expand Down
14 changes: 11 additions & 3 deletions packages/web/src/helpers/getContractPrices.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { formatUnits } from "@ethersproject/units";
import { GoodDollar_abi, InsureDao_abi } from "@hats.finance/shared";
import { GoodDollar_abi, HATTokensConfig, InsureDao_abi } from "@hats.finance/shared";
import axios from "axios";
import { BigNumber } from "ethers";
import { getCoingeckoTokensPrices } from "utils/tokens.utils";
import { getCamelotTokenPrices, getCoingeckoTokensPrices } from "utils/tokens.utils";
import { readContract } from "wagmi/actions";
import { mainnet } from "wagmi/chains";
import { arbitrum, mainnet } from "wagmi/chains";

const InsureDAOTokenMainnet = "0x22453153978D0C25f86010c0fd405527feD9764b";
const GoodDollarPriceContractMainnet = "0xa150a825d425B36329D8294eeF8bD0fE68f8F6E0";
Expand Down Expand Up @@ -55,9 +55,17 @@ export const getUMAVotingPriceOP = async () => {
return apiRes[UMATokenMainnet.toLowerCase()]?.["usd"] as number | undefined;
};

export const getHATPriceMainnet = async () => {
const HATArbitrum = HATTokensConfig.prod[arbitrum.id].address.toLowerCase();
const apiRes = await getCamelotTokenPrices([{ address: HATArbitrum, chainId: arbitrum.id }]);

return apiRes[HATArbitrum]?.["usd"] as number | undefined;
};

export const tokenPriceFunctions = {
[InsureDAOTokenMainnet.toLowerCase()]: getInsureDAOPriceMainnet,
[GoodDollarTokenMainnet.toLowerCase()]: getGoodDollarPriceMainnet,
[SpiralDaoTokenMainnet.toLowerCase()]: getSpiralDaoPriceMainnet,
[UMAVotingTokenOP.toLowerCase()]: getUMAVotingPriceOP,
[HATTokensConfig.prod[mainnet.id].address.toLowerCase()]: getHATPriceMainnet,
};
2 changes: 1 addition & 1 deletion packages/web/src/hooks/subgraph/vaults/useVaults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export function VaultsProvider({ children }: PropsWithChildren<{}>) {

// Get prices from the backend
try {
const tokensLeft = stakingTokens.filter((token) => !(token.address in foundTokenPrices));
const tokensLeft = tokenToSearch.filter((token) => !(token.address in foundTokenPrices));
const backendTokenPrices = await getBackendTokenPrices();

if (backendTokenPrices) {
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/hooks/vaults/useVaultApy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type IVaultApy = {
};

export const useVaultApy = (vault?: IVault): IVaultApy[] => {
const provider = useProvider();
const provider = useProvider({ chainId: vault?.chainId });
const [vaultApys, setVaultApys] = useState<IVaultApy[]>([]);
const { data: blockNumber } = useBlockNumber({ chainId: vault?.chainId, watch: false });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ export const AirdropRedeemDelegatee = () => {

<div className="delegatees-list">
{!isLoading && delegateesToShow && delegateesToShow?.length > 0 ? (
delegateesToShow?.map((delegatee) => (
delegateesToShow?.map((delegatee, i) => (
<DelegateeCard
key={i}
delegatee={delegatee as IDelegateeInfo | "self"}
onShowMore={delegatee !== "self" ? () => setShowingMoreDelegate(delegatee as IDelegateeInfo) : undefined}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const AirdropRedeemReview = () => {
const daysLocked = moment(airdrop.lockEndDate).format("MMMM Do 24'");

return (
<li>
<li key={i}>
<strong>{airdrop.descriptionData.name}:</strong> {total}
{", "}
{airdrop.isLocked ? t("Airdrop.linearlyReleasedUntil", { date: daysLocked }) : t("Airdrop.immediatelyReleased")}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const getSinglePayoutDataYupSchema = (intl: TFunction, vault: IVault | un
.test(getTestNumberInBetween(intl, 0, vault?.maxBounty ? Number(vault.maxBounty) / 100 : 100, true))
.required(intl("required"))
.typeError(intl("required")),
nftUrl: Yup.string().required(intl("required")),
nftUrl: Yup.string(),
explanation: Yup.string(),
additionalInfo: Yup.string(),
});
Expand Down Expand Up @@ -59,7 +59,7 @@ export const getSplitPayoutDataYupSchema = (intl: TFunction, vault: IVault | und
);
return +sumOfPercentages.toFixed(6) === 100;
}),
nftUrl: Yup.string().required(intl("required")),
nftUrl: Yup.string(),
})
),
rewardsConstraints: Yup.array().of(
Expand Down
Loading