Skip to content

Commit

Permalink
feature: add new project - doubleup
Browse files Browse the repository at this point in the history
  • Loading branch information
danhsucowboy committed Sep 16, 2024
1 parent 0c25d2b commit 1e59060
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions projects/doubleup/index.js
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,
},
};

0 comments on commit 1e59060

Please sign in to comment.