Skip to content

Commit

Permalink
Switch CLE reward urls based on request source
Browse files Browse the repository at this point in the history
  • Loading branch information
piekczyk committed Oct 3, 2024
1 parent 09ac809 commit 522cf0e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions blockchain/better-calls/sky.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,13 @@ export const skyUsdsStakeCleDetails = async () => {
}
}

export const skyUsdsWalletStakeCleDetails = async ({ ownerAddress }: { ownerAddress?: string }) => {
export const skyUsdsWalletStakeCleDetails = async ({
ownerAddress,
isServer = false,
}: {
ownerAddress?: string
isServer?: boolean
}) => {
const rpcProvider = getRpcProvider(NetworkIds.MAINNET)
if (!ownerAddress) {
return undefined
Expand All @@ -203,7 +209,11 @@ export const skyUsdsWalletStakeCleDetails = async ({ ownerAddress }: { ownerAddr
return new BigNumber(ethers.utils.formatUnits(tokensStaked, 18))
},
),
fetch(`/api/sky/cle?walletAddress=${ownerAddress}`)
fetch(
isServer
? `https://info-sky.blockanalitica.com/api/v1/farms/${mainnetContracts.sky.stakingCle.address}/wallets/${ownerAddress}/?format=json`
: `/api/sky/cle?walletAddress=${ownerAddress}`,
)
.then((resp) => resp.json())
.catch((error) => {
console.error('Failed to fetch earned CLE rewards:', error)
Expand Down
2 changes: 1 addition & 1 deletion handlers/portfolio/positions/handlers/sky/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const skyPositionsHandler: PortfolioPositionsHandler = async ({ address,
ownerAddress: address,
}),
skyUsdsStakeDetails({ mkrPrice: new BigNumber(prices.MKR) }),
skyUsdsWalletStakeCleDetails({ ownerAddress: address }),
skyUsdsWalletStakeCleDetails({ ownerAddress: address, isServer: true }),
]).then(([usdsWalletStakeDetails, usdsStakeDetails, usdsWalletStakeCleDetails]) => {
const positions = []
if (usdsWalletStakeDetails?.balance.isGreaterThan(0)) {
Expand Down

0 comments on commit 522cf0e

Please sign in to comment.