Skip to content

Commit

Permalink
AlphaFi: Updated code to include newly launched single asset vaults (…
Browse files Browse the repository at this point in the history
…Sui, vSui, USDC, USDT) (#11167)

* alphafi TVL

* code refactor

* added tvls for navi pools

* added space

---------

Co-authored-by: g1nt0ki <[email protected]>
  • Loading branch information
Zorag44 and g1nt0ki authored Jul 31, 2024
1 parent 5421af3 commit 2a4e9e7
Showing 1 changed file with 42 additions and 4 deletions.
46 changes: 42 additions & 4 deletions projects/alphafi/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const sui = require("../helper/chain/sui")
const { addUniV3LikePosition } = require("../helper/unwrapLPs")

const ALPHAFI_TVL_IDS = [
const ALPHAFI_CETUS_TVL_IDS = [
{

poolID: "0x30066d9879374276dc01177fbd239a9377b497bcd347c82811d75fcda35b18e5",
Expand Down Expand Up @@ -40,6 +40,29 @@ const ALPHAFI_TVL_IDS = [
},
]

const ALPHAFI_NAVI_TVL_IDS = [
{
poolID: "0x643f84e0a33b19e2b511be46232610c6eb38e772931f582f019b8bbfb893ddb3",
tokenType: "0x2::sui::SUI",
expo: 9
},
{
poolID: "0x0d9598006d37077b4935400f6525d7f1070784e2d6f04765d76ae0a4880f7d0a",
tokenType: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT",
expo: 9
},
{
poolID: "0xc696ca5b8f21a1f8fcd62cff16bbe5a396a4bed6f67909cfec8269eb16e60757",
tokenType: "0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN",
expo: 6,
},
{
poolID: "0x01493446093dfcdcfc6c16dc31ffe40ba9ac2e99a3f6c16a0d285bff861944ae",
tokenType: "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN",
expo: 6
},
]

const ALPHAFI_POOL2_IDS = [{
poolID: "0x594f13b8f287003fd48e4264e7056e274b84709ada31e3657f00eeedc1547e37",
cetusPoolID: "0xda7347c3192a27ddac32e659c9d9cbed6f8c9d1344e605c71c8886d7b787d720",
Expand All @@ -56,8 +79,8 @@ function asIntN(int, bits = 32) {
return Number(BigInt.asIntN(bits, BigInt(int)))
}

async function addPoolTVL(api, pools) {
for (const { poolID, cetusPoolID, investorID, token0Type, token1Type } of pools) {
async function addPoolTVL(api, alphafiCetusPools) {
for (const { poolID, cetusPoolID, investorID, token0Type, token1Type } of alphafiCetusPools) {
let investorObject = await sui.getObject(investorID)
let poolObject = await sui.getObject(poolID)
let cetusPoolObject = await sui.getObject(cetusPoolID)
Expand All @@ -73,13 +96,28 @@ async function addPoolTVL(api, pools) {
}
}

async function addPoolTVL2(api, alphafiNaviPools){

for (const { poolID, tokenType, expo } of alphafiNaviPools){
let poolObject = await sui.getObject(poolID);
let tokensInvested = poolObject.fields.tokensInvested;
let balance = BigInt(tokensInvested)/BigInt(Math.pow(10, 9-expo));
api.add(tokenType, balance);
}
}

async function tvl(api) {
await addPoolTVL(api, ALPHAFI_TVL_IDS)

await Promise.all([addPoolTVL(api, ALPHAFI_CETUS_TVL_IDS), addPoolTVL2(api, ALPHAFI_NAVI_TVL_IDS)])

}
async function pool2(api) {

await addPoolTVL(api, ALPHAFI_POOL2_IDS)

}


async function staking(api) {
let alphaPoolObject = await sui.getObject(ALPHA_POOL_ID)
api.addToken(ALPHA_COIN_TYPE, Number(alphaPoolObject.fields.alpha_bal))
Expand Down

0 comments on commit 2a4e9e7

Please sign in to comment.