Skip to content

Commit

Permalink
add btc (DefiLlama#11135)
Browse files Browse the repository at this point in the history
  • Loading branch information
Define101 authored and tlatkdgus1 committed Nov 25, 2024
1 parent a608879 commit f50383a
Showing 1 changed file with 32 additions and 21 deletions.
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 })]),
},
};

0 comments on commit f50383a

Please sign in to comment.