Skip to content

Commit

Permalink
Add Margined Protocol Vaults (#11909)
Browse files Browse the repository at this point in the history
Co-authored-by: g1nt0ki <[email protected]>
  • Loading branch information
shapeshed and g1nt0ki authored Oct 14, 2024
1 parent 3d51e15 commit 3943d9a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 16 deletions.
3 changes: 2 additions & 1 deletion projects/helper/chain/cosmos.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ async function lpMinter({ token, block, chain } = {}) {
return data.minter;
}

async function queryContract({ contract, chain, data }) {
async function queryContract({ contract, chain, data, api }) {
if (api) chain = api.chain;
if (typeof data !== "string") data = JSON.stringify(data);
data = Buffer.from(data).toString("base64");
return (
Expand Down
51 changes: 36 additions & 15 deletions projects/margined-protocol/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,40 @@
const { sumTokensExport} = require('../helper/sumTokens')

const contractAddresses = [
'osmo1rk4hregdr63rlqqj0k2rjzk6kz7w6v6tw8f5fqx2wg8203eam5equ67tdl',
'osmo1zttzenjrnfr8tgrsfyu8kw0eshd8mas7yky43jjtactkhvmtkg2qz769y2',
'osmo18pfsg9n2kn6epty7uhur7vxfszadvflx6f66569ejc469k8p64pqrve3yz',
]
const { queryContract } = require('../helper/chain/cosmos')

const osmosisVaults = {
stOSMO: "osmo16s3sxs5886p42kteunp6370pken2n5ukzszz0trkr39epqtawn2qk4r9l5",
stTIA: "osmo1q3w9kedgtc8sdh7xlcr77ydv3qu7fs2e3q6xznysp2lrdfyz9xyqv26yqv",
ampOSMO: "osmo1cztgw4e467vjljd0s2flz8asu3x3wg9q0ttga9t6kzmpyaauxxrs2gjshq",
bOSMO: "osmo159f7axyc32cyfgzx0gs9r98jwpgutj5qz4ns97xvu7nw3xzpavzsg2uxr3",
qOSMO: "osmo18vk0rsu4qwzx74g9alu2f7x5zs99sluwkuh5wp70yed2ne4pmutqf9lvdu",
usdcaxlGrid: "osmo1qngwlgzt0r3fdg6zgln5wa6mr5c7t6fek3qqgxesujjak5ds747sy6qu2f",
// usdtGrid: "osmo1cj8tzmvun6urr0djrax7v92jyk86gnp8hsep0hacf83quvknq5lsutucjj",
OSMORedemption: "osmo15fqmdl8lfl9h0qflljd63ufw9j2m7xmsk3hu5vsn8xpta4hk5chqt7mddc",
TIARedemption: "osmo1reyz7pwu7y9e7lmzqg6j4h7jcv32du7n7jhnk2lz93a9lxr56ess2qtgzl",
ATOMRedemption: "osmo1hvl5kj4xzdj4udxjv2dzk2zfqhzkd9afqygwq3t84tn53e0250zqrltj48",
}

const neutronVaults = {
ATOMFund: "neutron1puedrclm6rn33x3zv66xg6m23qcdagayqua6jj2wqzvfznlqef8qe53wr2",
NTRNStructured: "neutron13h4jzme5880knnc23xvwu9gytynnxu5cc0fek6fndmjyctzznj9sd5yhhy",
}

const config = {
osmosis: osmosisVaults,
neutron: neutronVaults,
}

module.exports = {
methodology: 'Total collateral held on power perpetual contracts',
osmosis: {
tvl: sumTokensExport({ owners: contractAddresses}),
},
hallmarks:[
[Math.floor(new Date('2023-11-06') / 1e3), 'sqOSMO contract deployed'],
[Math.floor(new Date('2023-11-21') / 1e3), 'sqATOM contract deployed'],
[Math.floor(new Date('2024-01-19') / 1e3), 'sqTIA contract deployed'],
]
methodology: 'Total TVL on vaults',
}

Object.keys(config).forEach(chain => module.exports[chain] = { tvl })

async function tvl(api) {
const vaults = config[api.chain]
for (const contract of Object.values(vaults)) {
let vaultInfo = await queryContract({ contract, api, data: { 'info': {} }, });
let totalAssets = await queryContract({ contract, api, data: { 'total_assets': {} }, });
api.add(vaultInfo.base_token, totalAssets);
}
}

0 comments on commit 3943d9a

Please sign in to comment.