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

Neutral.trade adapter #12674

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 122 additions & 0 deletions projects/neutral-trade/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
const DATA_URL = 'https://raw.githubusercontent.com/neutral-trade/vaults-data/main';

const START_TIMESTAMP = 1730419200; // 2024-11-01


const TOKENS = {
USDC: {
name: 'USDC',
mint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
decimals: 6
},
SOL: {
name: 'SOL',
mint: 'So11111111111111111111111111111111111111112',
decimals: 9
},
WBTC: {
name: 'Wrapped BTC (Wormhole) (WBTC)',
mint: '3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh',
decimals: 8
},
WETH: {
name: 'Wrapped ETH (Wormhole) (WETH)',
mint: '7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs',
decimals: 8
}
};

const VAULTS = [
{
name: "USDC Basis (Perps Basket)",
address: "4cvgasNfbJ36yeMVJSkscgL2Yco9dFGdj52Wrg91fmHv",
token: TOKENS.USDC,
dataUrl: `${DATA_URL}/btcethfunding.json`
},
{
name: "BTC Super Staking",
address: "BVddkVtFJLCihbVrtLo8e3iEd9NftuLunaznAxFFW8vf",
token: TOKENS.WBTC,
dataUrl: `${DATA_URL}/btcjlpnl.json`
},
{
name: "ETH Super Staking",
address: "ENr5e1BMN5vFUHf4iCCPzR4GjWCKgtHnQcdniRQqMdEL",
token: TOKENS.WETH,
dataUrl: `${DATA_URL}/ethjlpnl.json`
},
{
name: "USDC Staking (JLP Delta Neutral)",
address: "9Fcn3Fd4d5ocrb12xCUtEvezxcjFEAyHBPfrZDiPt9Qj",
token: TOKENS.USDC,
dataUrl: `${DATA_URL}/jlpdn.json`
},
{
name: "USDC Staking (JLP Delta Neutral) v2",
address: "41Y8C4oxk4zgJT1KXyQr35UhZcfsp5mP86Z2G7UUzojU",
token: TOKENS.USDC,
dataUrl: `${DATA_URL}/jlpdnv2.json`
},
{
name: "USDC Basis (Sanctum-INF)",
address: "CxL8eQmGhN9LKSoHj7bU95JekFPtyZoUc57mbehb5A56",
token: TOKENS.USDC,
dataUrl: `${DATA_URL}/solbasis.json`
},
{
name: "SOL Super Staking",
address: "EuSLjg23BrtwYAk1t4TFe5ArYSXCVXLBqrHRBfWQiTeJ",
token: TOKENS.SOL,
dataUrl: `${DATA_URL}/soljlpnl.json`
},
{
name: "JLP Traders Print",
address: "85XuR4kE5yxp1hk91WHAawinXZsuJowxy59STYYpM9pK",
token: TOKENS.USDC,
dataUrl: `${DATA_URL}/tradersprint.json`
},
{
name: "JLP Traders Rekt",
address: "2r81MPMDjGSrbmGRwzDg6aqhe3t3vbKcrYfpes5bXckS",
token: TOKENS.USDC,
dataUrl: `${DATA_URL}/tradersrekt.json`
},
{
name: "vip01",
address: "CZU38L2NyL6tqFxzYAGYkmkf2JG98tZfZ2CnUapVgXQe",
token: TOKENS.USDC,
dataUrl: `${DATA_URL}/vip01.json`
},
{
name: "vip02",
address: "DUW6uWcrsjYmsYDjp9iGDN4JdRa2MqznjuxjKVok5Fsj",
token: TOKENS.USDC,
dataUrl: `${DATA_URL}/vip02.json`
},
{
name: "vip03",
address: "Fd3k4c6Dv7m9673ae87P6duQrftY9UVfwiCxngNbJrUQ",
token: TOKENS.USDC,
dataUrl: `${DATA_URL}/vip03.json`
},
// 'vip04', // currently inactive
{
name: "vip05",
address: "9BMEyctGvajEubk5iCRBnM9fkeTXUhrxaweYq34jZdC8",
token: TOKENS.USDC,
dataUrl: `${DATA_URL}/vip05.json`
},
{
name: "vip06",
address: "6DFDj66PbPoTC16Sh51MJijoTTMYCbMCVC85tnc5UfQ3",
token: TOKENS.USDC,
dataUrl: `${DATA_URL}/vip06.json`
},
];

module.exports = {
DATA_URL,
START_TIMESTAMP,
TOKENS,
VAULTS,
};
43 changes: 43 additions & 0 deletions projects/neutral-trade/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const { VAULTS, START_TIMESTAMP } = require("./constants");

async function fetchHistoricalTvl(vault, date) {
let usd_tvl = 0;
let token_tvl = 0;
try {
const response = await fetch(vault.dataUrl);
const all = Object.entries(await response.json());
for (let i = 0; i < all.length; i++) {
const [entryTime, entryData] = all[i];
usd_tvl = entryData?.TVL_USD;
token_tvl = entryData?.TVL_TOKEN;
if (entryTime?.startsWith(date)) {
break;
}
}
usd_tvl = usd_tvl || 0;
token_tvl = (token_tvl || 0) * Math.pow(10, vault.token.decimals);
} catch (_e) {
console.log(_e);
}
return { usd_tvl, token_tvl };
}

async function tvl(api) {
const ts = new Date(api.timestamp * 1000);
const year = ts.getFullYear();
const month = String(ts.getMonth() + 1).padStart(2, '0');
const day = String(ts.getDate()).padStart(2, '0');
const date = `${year}-${month}-${day}`;

for (let i = 0; i < VAULTS.length; i++) {
const { token_tvl } = await fetchHistoricalTvl(VAULTS[i], date);
api.add(VAULTS[i].token.mint, token_tvl);
}
}

module.exports = {
start: START_TIMESTAMP,
timetravel: true,
methodology: "The combined TVL and PnL of all public and private vaults ; the historical data is pulled from the Neutral.trade vaults data repository.",
solana: { tvl },
};
Loading