Skip to content
Merged
Show file tree
Hide file tree
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
23 changes: 23 additions & 0 deletions projects/udon-staking/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const { fetchURL } = require('../helper/utils');

const BASE_URL = 'https://mainnet-dapp1.sunube.net:7740/query';
const BLOCKCHAIN_RID = 'F4E33267A8FF1ACCE3C6D7B441B8542FB84FF6DAA5114105563D2AA34979BEF6';

function buildQueryUrl(queryType, params = {}) {
const url = `${BASE_URL}/${BLOCKCHAIN_RID}?type=${queryType}`;
const queryParams = new URLSearchParams(params).toString();
return queryParams ? `${url}&${queryParams}` : url;
}

async function tvl(api) {
const { data: totalStakeRaw } = await fetchURL(buildQueryUrl('get_total_stake_all_users'));

api.add('5F16D1545A0881F971B164F1601CBBF51C29EFD0633B2730DA18C403C3B428B5', totalStakeRaw);
}

module.exports = {
timetravel: false,
chromia: {
tvl
},
}
32 changes: 20 additions & 12 deletions projects/udon/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
const { sumTokens2 } = require('../helper/unwrapLPs');
const { fetchURL } = require('../helper/utils')
const { fetchURL } = require('../helper/utils');

const BASE_URL = 'https://mainnet-dapp1.sunube.net:7740/query';
const BLOCKCHAIN_RID = 'F4E33267A8FF1ACCE3C6D7B441B8542FB84FF6DAA5114105563D2AA34979BEF6';

function buildQueryUrl(queryType, params = {}) {
const url = `${BASE_URL}/${BLOCKCHAIN_RID}?type=${queryType}`;
const queryParams = new URLSearchParams(params).toString();
return queryParams ? `${url}&${queryParams}` : url;
}

async function tvl(api, isBorrows) {
const { data } = await fetchURL("https://mainnet-dapp1.sunube.net:7740/query/F4E33267A8FF1ACCE3C6D7B441B8542FB84FF6DAA5114105563D2AA34979BEF6?type=get_stats_supply_deposit");
const { data } = await fetchURL(
buildQueryUrl('get_stats_supply_deposit')
);


data.forEach(({ asset_id, total_borrow, total_deposit }) => {
const balance = isBorrows ? total_borrow : total_deposit - total_borrow;
api.add(asset_id, balance);
});

data.map(({ asset_id, total_borrow, total_deposit, price, decimals }) => {
// const multiplier = price/10 **decimals
// total_borrow = total_borrow * multiplier
// total_deposit = total_deposit * multiplier
// const balance = isBorrows ? total_borrow : total_deposit - total_borrow
// api.addUSDValue(balance)
const balance = isBorrows ? total_borrow : total_deposit - total_borrow
api.add(asset_id, balance)
})
return sumTokens2({ api })
return sumTokens2({ api });
}

module.exports = {
Expand Down
Loading