Skip to content

Commit

Permalink
Add Metastable mUSD Adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
collin-aftermath committed Jan 17, 2025
1 parent 402edfc commit f474c49
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions projects/metastable-musd/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const sui = require("../helper/chain/sui");
const http = require('../helper/http');
const { getEnv } = require('../helper/env')

const endpoint = () => getEnv('SUI_RPC')

async function tvl(api) {
const vaultData = await sui.getObjects(["0xb950819c5eba1bb5980f714f2a3b1d8738e3da58a4d9daf5fa21b6c2a7dd1e12"])

for (const { fields: { metadata, } } of vaultData) {

const {
result: { data: fields }
} = await http.post(endpoint(), { jsonrpc: "2.0", id: 1, method: 'suix_getDynamicFields', params: [metadata.fields.id.id , null, 48], })
const fieldObjects = await sui.getDynamicFieldObjects({
parent: metadata.fields.id.id
})

let i = 0
for (const field of fields) {

const coin = field.name.value.name
const amount = fieldObjects[i].fields.balance

api.add("0x" + coin, amount)
i++
}
}
}

module.exports = {
timetravel: true,
sui: {
tvl,
},
};

0 comments on commit f474c49

Please sign in to comment.