Skip to content

Commit

Permalink
[farms page] add uniswap data fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-diamond committed Oct 18, 2023
1 parent 0d90184 commit d98f88b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/contracts/abis/UniswapPoolAbi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"inputs":[],"name":"liquidity","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"slot0","outputs":[{"internalType":"uint160","name":"sqrtPriceX96","type":"uint160"},{"internalType":"int24","name":"tick","type":"int24"},{"internalType":"uint16","name":"observationIndex","type":"uint16"},{"internalType":"uint16","name":"observationCardinality","type":"uint16"},{"internalType":"uint16","name":"observationCardinalityNext","type":"uint16"},{"internalType":"uint8","name":"feeProtocol","type":"uint8"},{"internalType":"bool","name":"unlocked","type":"bool"}],"stateMutability":"view","type":"function"}]
2 changes: 2 additions & 0 deletions src/contracts/abis/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import VestingEscrowAbi from './VestingEscrowAbi.json'
import PrivateVaultAbi from './PrivateVaultAbi.json'
import VaultFactoryAbi from './VaultFactoryAbi.json'
import PriceOracleAbi from './PriceOracleAbi.json'
import UniswapPoolAbi from './UniswapPoolAbi.json'
import SwiseTokenAbi from './SwiseTokenAbi.json'
import Erc20VaultAbi from './Erc20VaultAbi.json'
import MulticallAbi from './MulticallAbi.json'
Expand All @@ -34,6 +35,7 @@ export {
PrivateVaultAbi,
VaultFactoryAbi,
PriceOracleAbi,
UniswapPoolAbi,
SwiseTokenAbi,
Erc20VaultAbi,
MulticallAbi,
Expand Down
3 changes: 3 additions & 0 deletions src/contracts/createContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
MulticallAbi,
Erc20VaultAbi,
SwiseTokenAbi,
UniswapPoolAbi,
PriceOracleAbi,
PrivateVaultAbi,
VaultFactoryAbi,
Expand All @@ -32,6 +33,7 @@ import type {
PrivateVaultAbi as PrivateVaultType,
Erc20VaultAbi as Erc20VaultAbiType,
PriceOracleAbi as PriceOracleType,
UniswapPoolAbi as UniswapPoolType,
SwiseTokenAbi as SwiseTokenType,
MulticallAbi as MulticallType,
MintTokenAbi as MintTokenType,
Expand Down Expand Up @@ -127,6 +129,7 @@ export const createContracts = (input: CreateContractsInput) => {
createMulticall: multicall(multicallContract as MulticallType),
createErc20: (address: string) => createContract<Erc20Type>(address, Erc20Abi, provider),
createVaultContract: (address: string) => createContract<VaultAbiType>(address, VaultAbi, provider),
createUniswapPoolAbi: (address: string) => createContract<UniswapPoolType>(address, UniswapPoolAbi, provider),
createUsdRateContract: (address: string) => createContract<UsdRateType>(address, UsdRateAbi, provider),
createErc20VaultContract: (address: string) => createContract<Erc20VaultAbiType>(address, Erc20VaultAbi, provider),
createPrivateVaultContract: (address: string) => createContract<PrivateVaultType>(address, PrivateVaultAbi, provider),
Expand Down
12 changes: 7 additions & 5 deletions src/methods/utils/getSwiseUsdPrice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ type GetSwiseUsdPriceInput = {
const getSwiseUsdPrice = async (input: GetSwiseUsdPriceInput) => {
const { options } = input

const data = await backend.swise.fetchSwiseStatsQuery({
url: apiUrls.getBackendUrl(options),
})

return data?.swiseStats?.price || '0'
// const data = await backend.swise.fetchSwiseStatsQuery({
// url: apiUrls.getBackendUrl(options),
// })
//
// return data?.swiseStats?.price || '0'
// TODO remove when backend will be ready
return '0.058806999999999998'
}


Expand Down

0 comments on commit d98f88b

Please sign in to comment.