Skip to content
Open
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
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
"dependencies": {
"@coral-xyz/anchor": "^0.30.1",
"@defillama/sdk": "latest",
"@mysten/bcs": "^1.8.0",
"@mysten/sui": "^1.37.1",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it feasible to calculate this without adding dependancies? using our helpers etc?

Copy link
Contributor Author

@burhanuddin03 burhanuddin03 Sep 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a lot of effort to add the sdk dependency on your front? Creating the txBlock manually without bcs encoding is something a bit of an effort to add.

"@project-serum/anchor": "^0.26.0",
"@solana/web3.js": "^1.87.6",
"@solendprotocol/solend-sdk": "^0.4.3",
Expand Down
51 changes: 51 additions & 0 deletions projects/ember-protocol/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const sui = require("../helper/chain/sui");
const suiSdk = require('@mysten/sui/transactions')
const client = require('@mysten/sui/client')
const bcs = require('@mysten/bcs')
const BigNumber = require('bignumber.js')
const axios = require('axios')

const PACKAGE_ID = "0xc83d5406fd355f34d3ce87b35ab2c0b099af9d309ba96c17e40309502a49976f";

async function suiTvl(api) {
const vaults = (await axios.get(`https://vaults.api.sui-prod.bluefin.io/api/v1/vaults/info`)).data.Vaults;
for (const vault of Object.values(vaults)) {
const vaultTvl = await getVaultTvl(vault.ObjectId, vault.DepositCoinType, vault.ReceiptCoinType)
api.add(vault.DepositCoinType, vaultTvl)
}
}

async function getVaultTvl(vaultId, depositCoinType, receiptCoinType) {
const suiClient = new client.SuiClient({
url: sui.endpoint,
})
const txb = new suiSdk.Transaction();
txb.moveCall({
target: `${PACKAGE_ID}::vault::get_vault_tvl`,
arguments: [
txb.object(
vaultId
)
],
typeArguments: [
depositCoinType, // T
receiptCoinType // R
]
});
const result = (
await suiClient.devInspectTransactionBlock({
transactionBlock: txb,
sender: "0xbaef681eafe323b507b76bdaf397731c26f46a311e5f3520ebb1bde091fff295"
})
).results[0].returnValues.map(([bytes, _]) =>
new BigNumber(bcs.bcs.u64().parse(Uint8Array.from(bytes)))
);
return result
}


module.exports = {
sui: {
tvl: suiTvl
},
}
Loading