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

add btc #11135

Merged
merged 1 commit into from
Jul 29, 2024
Merged

add btc #11135

Changes from all 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
53 changes: 32 additions & 21 deletions projects/pstake/index.js
Original file line number Diff line number Diff line change
@@ -1,67 +1,78 @@
const { nullAddress } = require('../helper/tokenMapping');
const { get } = require('../helper/http')
const { nullAddress } = require("../helper/tokenMapping");
const { get } = require("../helper/http");
const sdk = require("@defillama/sdk");

const { sumTokensExport } = require("../helper/sumTokens");

async function bsctvl(api) {
const bal = await api.call({ abi: 'function exchangeRate() external view returns (uint256 totalWei, uint256 poolTokenSupply)', target: '0xc228cefdf841defdbd5b3a18dfd414cc0dbfa0d8' })
const bal = await api.call({
abi: "function exchangeRate() external view returns (uint256 totalWei, uint256 poolTokenSupply)",
target: "0xc228cefdf841defdbd5b3a18dfd414cc0dbfa0d8",
});

return {
['bsc:' + nullAddress]: bal.totalWei
["bsc:" + nullAddress]: bal.totalWei,
};
}

const baseEndpoint = 'https://api.persistence.one/pstake'
const baseEndpoint = "https://api.persistence.one/pstake";

const chainInfos = {
cosmos: {
name: "cosmos",
decimals: 1e6,
endpoint: "/stkatom/atom_tvu"
endpoint: "/stkatom/atom_tvu",
},
osmosis: {
name: "osmosis",
decimals: 1e6,
endpoint: "/stkosmo/osmo_tvu"
endpoint: "/stkosmo/osmo_tvu",
},
dydx: {
name: "dydx-chain",
decimals: 1e18,
endpoint: "/stkdydx/dydx_tvu"
endpoint: "/stkdydx/dydx_tvu",
},
stargaze: {
name: "stargaze",
decimals: 1e6,
endpoint: "/stkstars/stars_tvu"
endpoint: "/stkstars/stars_tvu",
},
persistence: {
name: "persistence",
decimals: 1e6,
endpoint: "/stkxprt/xprt_tvu"
}
}
endpoint: "/stkxprt/xprt_tvu",
},
};

function cosmostvl() {
return async () => {

let tvl = {}
let tvl = {};
for (const chain of Object.values(chainInfos)) {
const api = baseEndpoint + chain.endpoint
const api = baseEndpoint + chain.endpoint;

const amount = await get(api)
const amount = await get(api);

const balance = {};
sdk.util.sumSingleBalance(balance, chain.name, amount.amount.amount / chain.decimals);
sdk.util.sumSingleBalance(
balance,
chain.name,
amount.amount.amount / chain.decimals
);

tvl[chain.name] = balance[chain.name]
tvl[chain.name] = balance[chain.name];
}

return tvl
}
return tvl;
};
}

const owner = "bc1qajcp935tuvqakut95f0sc9qm09hxjj6egexl9d";

module.exports = {
methodology: `Total amount of liquid staked tokens on Persistence.`,
bsc: { tvl: bsctvl },
persistence: { tvl: cosmostvl() },
bitcoin: {
tvl: sdk.util.sumChainTvls([sumTokensExport({ owner })]),
},
};
Loading