Skip to content

Commit

Permalink
fix: pools api
Browse files Browse the repository at this point in the history
  • Loading branch information
MGrgr committed Feb 6, 2024
1 parent 5f8fdf9 commit e1fe486
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 17 deletions.
1 change: 0 additions & 1 deletion .env.dev
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
VITE_PASSWORD_PROTECT=345719
VITE_ALBUS_APP_URL='https://dev.app.albus.finance'
VITE_POOLS_API_URL='http://49.13.124.83:3004'
1 change: 0 additions & 1 deletion .env.prod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
VITE_GTAG_ID=
VITE_SENTRY_DSN=
VITE_ALBUS_APP_URL='https://app.albus.finance'
VITE_POOLS_API_URL='https://app.albus.finance'
1 change: 0 additions & 1 deletion .env.stage
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
VITE_PASSWORD_PROTECT=345719
VITE_ALBUS_APP_URL='https://stage.app.albus.finance'
VITE_POOLS_API_URL='https://stage.app.albus.finance'
6 changes: 3 additions & 3 deletions src/components/pools/PoolsListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const dialog = ref(false)
APR 24H
</div>
<div class="pool-card__apr-amount">
{{ poolStats ? `${formatPct.format(poolStats.apr24)}` : '---' }}
{{ poolStats && !Number.isNaN(poolStats.apr24) ? `${formatPct.format(poolStats.apr24)}` : '---' }}
</div>
</div>
<div class="pool-card__income__user row q-ml-auto">
Expand All @@ -135,15 +135,15 @@ const dialog = ref(false)
My Liquidity
</div>
<div class="pool-card__amount">
{{ poolStats && userTokens ? `$${formatUsd.format(userTokens / poolStats.poolTokenSupply * poolStats.tvl)}` : '---' }}
{{ poolStats && !Number.isNaN(poolStats.poolTokenSupply) && userTokens ? `$${formatUsd.format(userTokens / poolStats.poolTokenSupply * poolStats.tvl)}` : '---' }}
</div>
</div>
<div class="q-ml-md">
<div class="pool-card__label">
My Share
</div>
<div class="pool-card__amount">
{{ poolStats && userTokens ? `${formatPct.format(userTokens / poolStats.poolTokenSupply)}` : '---' }}
{{ poolStats && !Number.isNaN(poolStats.poolTokenSupply) && userTokens ? `${formatPct.format(userTokens / poolStats.poolTokenSupply)}` : '---' }}
</div>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions src/config/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ export const TWITTER_URL = 'https://twitter.com/AlbusProtocol'
export const DISCORD_URL = ''

export const ALBUS_APP_URL = import.meta.env.VITE_ALBUS_APP_URL || (import.meta.env.DEV && 'https://dev.app.albus.finance') || 'https://app.albus.finance'
// export const POOLS_API_URL = import.meta.env.VITE_POOLS_API_URL || (import.meta.env.DEV && 'http://localhost:3000')
export const POOLS_API_URL = import.meta.env.VITE_POOLS_API_URL || (import.meta.env.DEV && 'http://49.13.124.83:3004')
console.log('POOLS_API_URL = ', POOLS_API_URL)
export const DEV_POOLS_API_URL = 'https://api.dev.defi.albus.finance'
export const MAIN_POOLS_API_URL = 'https://api.defi.albus.finance'

export const RENT_FEE = 0.00203928
export const MIN_TRANSFER_FEE = 0.00203928
// TODO: where from 0.0000016
Expand Down
2 changes: 1 addition & 1 deletion src/config/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export const TOKENS_DEV = [
TOKEN_B,
USDC_TOKEN_DEV,
// USDT_TOKEN_DEV,
TOKEN_C,
// TOKEN_C,
]

export const TOKENS_MAIN = [
Expand Down
22 changes: 15 additions & 7 deletions src/utils/pools-api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import axios from 'axios'
import { POOLS_API_URL } from '@/config'
import type { Cluster } from '@solana/web3.js'
import { DEV_POOLS_API_URL, MAIN_POOLS_API_URL } from '@/config'

export interface PoolData {
id: number
Expand Down Expand Up @@ -42,17 +43,24 @@ export interface TxData {
type?: string
}

export async function getPoolsStats(): Promise<PoolData[]> {
const { data } = await axios.get(`${POOLS_API_URL}`)
export async function getPoolsStats(cluster: Cluster): Promise<PoolData[]> {
const { data } = await axios.get(`${getApiUrl(cluster)}`)
return data
}

export async function getPoolsTransactions(): Promise<TxData[]> {
const { data } = await axios.get(`${POOLS_API_URL}/transactions?type=swap`)
export async function getPoolsTransactions(cluster: Cluster): Promise<TxData[]> {
const { data } = await axios.get(`${getApiUrl(cluster)}/transactions?type=swap`)
return data
}

export async function getCoinsPrice(): Promise<Record<string, number>> {
const { data } = await axios.get(`${POOLS_API_URL}/coin-price`)
export async function getCoinsPrice(cluster: Cluster): Promise<Record<string, number>> {
const { data } = await axios.get(`${getApiUrl(cluster)}/coin-price`)
return data
}

function getApiUrl(cluster: Cluster) {
if (cluster === 'mainnet-beta') {
return MAIN_POOLS_API_URL
}
return DEV_POOLS_API_URL
}

0 comments on commit e1fe486

Please sign in to comment.