-
Notifications
You must be signed in to change notification settings - Fork 6.3k
add pacifica #16080
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
Open
ops-pacifica
wants to merge
1
commit into
DefiLlama:main
Choose a base branch
from
ops-pacifica:add-pacifica
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
add pacifica #16080
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
// @ts-ignore | ||
const { sumTokens2 } = require('../helper/solana'); | ||
// @ts-ignore | ||
const { getConfig } = require('../helper/cache'); | ||
|
||
// Pacifica Exchange - Solana only | ||
const PACIFICA_SOLANA_CONTRACT = '72R843XwZxqWhsJceARQQTTbYtWy6Zw9et2YV4FpRHTa'; | ||
|
||
// Pacifica API Endpoints (confirmed) | ||
const PACIFICA_INFO_API = 'https://api.pacifica.fi/api/v1/info'; | ||
const PACIFICA_PRICES_API = 'https://api.pacifica.fi/api/v1/info/prices'; | ||
|
||
const OWNER_MAP: { [chain: string]: string } = { | ||
'solana': '72R843XwZxqWhsJceARQQTTbYtWy6Zw9et2YV4FpRHTa', | ||
}; | ||
|
||
// TypeScript interfaces for API responses | ||
interface PacificaMarketInfo { | ||
symbol: string; | ||
tick_size: string; | ||
min_tick: string; | ||
max_tick: string; | ||
lot_size: string; | ||
max_leverage: number; | ||
isolated_only: boolean; | ||
min_order_size: string; | ||
max_order_size: string; | ||
funding_rate: string; | ||
next_funding_rate: string; | ||
} | ||
|
||
interface PacificaPriceData { | ||
funding: string; | ||
mark: string; | ||
mid: string; | ||
next_funding: string; | ||
open_interest: string; | ||
oracle: string; | ||
symbol: string; | ||
timestamp: number; | ||
volume_24h: string; | ||
yesterday_price: string; | ||
} | ||
|
||
interface PacificaPricesApiResponse { | ||
success: boolean; | ||
data: PacificaPriceData[]; | ||
error: string | null; | ||
code: string | null; | ||
} | ||
|
||
interface PacificaInfoApiResponse { | ||
success: boolean; | ||
data: PacificaMarketInfo[]; | ||
error: string | null; | ||
code: string | null; | ||
} | ||
|
||
interface ApiContext { | ||
chain: string; | ||
chainId: number; | ||
} | ||
|
||
async function fetchTokenData(api: ApiContext): Promise<string[]> { | ||
// Pacifica is a perps exchange that only accepts USDC as collateral | ||
// USDC on Solana mint address | ||
return ['EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v']; | ||
} | ||
|
||
async function fetchVolumeData(): Promise<PacificaPriceData[]> { | ||
try { | ||
const response: PacificaPricesApiResponse = await getConfig('pacifica/volume-data', PACIFICA_PRICES_API); | ||
return response.data || []; | ||
} catch (error) { | ||
console.error('Error fetching Pacifica volume data:', error); | ||
return []; | ||
} | ||
} | ||
|
||
async function fetchMarketInfo(): Promise<PacificaMarketInfo[]> { | ||
try { | ||
const response: PacificaInfoApiResponse = await getConfig('pacifica/market-info', PACIFICA_INFO_API); | ||
return response.data || []; | ||
} catch (error) { | ||
console.error('Error fetching Pacifica market info:', error); | ||
return []; | ||
} | ||
} | ||
|
||
// @ts-ignore | ||
module.exports = { | ||
timetravel: false, | ||
hallmarks: [ | ||
[Math.floor(new Date('2025-06-10').getTime() / 1000), 'Pacifica Exchange Launch'] | ||
], | ||
category: 'Derivatives' as const, | ||
website: 'https://pacifica.fi/', | ||
github: 'https://github.com/pacifica-fi', | ||
twitter: 'https://x.com/pacifica_fi', | ||
solana: { | ||
tvl: async (api: ApiContext) => { | ||
return sumTokens2({ owner: OWNER_MAP.solana, tokens: await fetchTokenData(api) }); | ||
}, | ||
volume: async (api: ApiContext) => { | ||
const volumeData = await fetchVolumeData(); | ||
// Calculate total volume across all trading pairs using volume_24h from API | ||
const totalVolume = volumeData.reduce((sum: number, pair: PacificaPriceData) => { | ||
return sum + (parseFloat(pair.volume_24h) || 0); | ||
}, 0); | ||
return totalVolume; | ||
} | ||
}, | ||
methodology: 'USDC collateral deposited into Pacifica Exchange for perpetual futures trading. Volume data fetched from Pacifica API.' | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
volume should be in a seperate file here https://github.com/DefiLlama/dimension-adapters