-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c25d2b
commit 1e59060
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const ADDRESSES = require("../helper/coreAssets.json"); | ||
const sui = require("../helper/chain/sui"); | ||
|
||
const UNI_HOUSE_OBJ_ID = "0x75c63644536b1a7155d20d62d9f88bf794dc847ea296288ddaf306aa320168ab" | ||
const SUI = ADDRESSES.sui.SUI; | ||
|
||
async function tvl(api) { | ||
const unihouseDynamicFields = await sui.getDynamicFieldObjects({ | ||
parent: UNI_HOUSE_OBJ_ID, | ||
}); | ||
|
||
const unihouseList = unihouseDynamicFields?.filter( | ||
(field) => field?.type.includes("house::House"), | ||
); | ||
|
||
const unihouseIdList = unihouseList.map((house) => house.fields.id.id); | ||
|
||
// console.log(unihouseIdList); | ||
|
||
for (const id of unihouseIdList) { | ||
const house = await sui.getObject(id); | ||
|
||
const pipeDebt = house?.fields?.pipe_debt?.fields?.value; | ||
const totalSui = Number(pipeDebt) + Number(house?.fields?.pool); | ||
|
||
api.add(SUI, totalSui); | ||
} | ||
} | ||
|
||
module.exports = { | ||
timetravel: false, | ||
sui: { | ||
tvl, | ||
}, | ||
}; |