Skip to content

Commit 9412aad

Browse files
committed
track typus treasury DefiLlama#12421
1 parent 5d2a346 commit 9412aad

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

projects/helper/chain/sui.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,23 @@ function dexExport({
134134
}
135135

136136

137-
async function sumTokens({ balances = {}, owners = [], blacklistedTokens = [], tokens = [], api }) {
137+
async function sumTokens({ owners = [], blacklistedTokens = [], api, tokens = [], }) {
138138
owners = getUniqueAddresses(owners, true)
139139
const bals = await call('suix_getAllBalances', owners)
140-
bals.forEach(i => api.add(i.coinType, i.totalBalance))
140+
const blacklistSet = new Set(blacklistedTokens)
141+
const tokenSet = new Set(tokens)
142+
bals.forEach(i => {
143+
if (blacklistSet.has(i.coinType)) return;
144+
if (tokenSet.size > 0 && !tokenSet.has(i.coinType)) return;
145+
api.add(i.coinType, i.totalBalance)
146+
})
141147
return api.getBalances()
142148
}
143149

150+
function sumTokensExport(config) {
151+
return (api) => sumTokens({ ...config, api })
152+
}
153+
144154
async function queryEventsByType({ eventType, transform = i => i }) {
145155
const query = `query GetEvents($after: String, $eventType: String!) {
146156
events(first: 50, after: $after, filter: { eventType: $eventType }) {
@@ -174,5 +184,6 @@ module.exports = {
174184
getDynamicFieldObjects,
175185
dexExport,
176186
sumTokens,
187+
sumTokensExport,
177188
queryEventsByType,
178189
};

projects/helper/sumTokens.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const { sumTokens2: sumTokensEVM, nullAddress, } = require('./unwrapLPs')
44
const sdk = require('@defillama/sdk')
55

66
const helpers = {
7+
"sui": require("./chain/sui"),
78
"eos": require("./chain/eos"),
89
"ton": require("./chain/ton"),
910
"ergo": require("./chain/ergo"),

projects/treasury/typus-finance.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const { treasuryExports } = require("../helper/treasury");
2+
3+
module.exports = treasuryExports({
4+
sui: {
5+
owners: ['0xb9a09efd534d29cc9f990db26b2dab00289f32de0cdcefa68c6808de208bc9cb'],
6+
ownTokens: ['0xf82dc05634970553615eef6112a1ac4fb7bf10272bf6cbe0f80ef44a6c489385::typus::TYPUS'],
7+
},
8+
})

0 commit comments

Comments
 (0)