Last active
December 17, 2021 21:31
-
-
Save 0xdef1/20cc1373260b2ba91ea3b3d3fe32871b to your computer and use it in GitHub Desktop.
ASTRO Lockdrop Stats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { LCDClient } from '@terra-money/terra.js'; | |
const terra = new LCDClient({ | |
URL: 'https://lcd.terra.dev', | |
chainID: 'columbus-5', | |
}); | |
const pools = [ | |
{ | |
name: 'bLUNA-LUNA', | |
tlp: 'terra1nuy34nwnsh53ygpc4xprlj263cztw7vc99leh2' | |
}, | |
{ | |
name: 'LUNA-UST', | |
tlp: 'terra17dkr9rnmtmu7x4azrpupukvur2crnptyfvsrvr' | |
}, | |
{ | |
name: 'PSI-UST', | |
tlp: 'terra1q6r8hfdl203htfvpsmyh8x689lp2g0m7856fwd' | |
}, | |
{ | |
name: 'ANC-UST', | |
tlp: 'terra1gecs98vcuktyfkrve9czrpgtg0m3aq586x6gzm' | |
}, | |
{ | |
name: 'MIR-UST', | |
tlp: 'terra17gjf2zehfvnyjtdgua9p9ygquk6gukxe7ucgwh' | |
}, | |
{ | |
name: 'MINE-UST', | |
tlp: 'terra1rqkyau9hanxtn63mjrdfhpnkpddztv3qav0tq2' | |
}, | |
{ | |
name: 'VKR-UST', | |
tlp: 'terra17fysmcl52xjrs8ldswhz7n6mt37r9cmpcguack' | |
}, | |
{ | |
name: 'STT-UST', | |
tlp: 'terra1uwhf02zuaw7grj6gjs7pxt5vuwm79y87ct5p70' | |
}, | |
{ | |
name: 'APOLLO-UST', | |
tlp: 'terra1n3gt4k3vth0uppk0urche6m3geu9eqcyujt88q' | |
}, | |
{ | |
name: 'ORION-UST', | |
tlp: 'terra14ffp0waxcck733a9jfd58d86h9rac2chf5xhev' | |
}, | |
] | |
// ugly global variables updated inside main() | |
var tvl = 0 | |
var lunaPrice = 57.05 | |
main() | |
async function main() { | |
lunaPrice = await getLUNAPrice() | |
console.log(`LUNA Price: ${lunaPrice}\n`) | |
for (var i = 0; i < pools.length; i++) { | |
console.log(`${pools[i].name}: `) | |
console.log('-------------------------------------------------------') | |
await process(pools[i].tlp) | |
console.log() | |
} | |
console.log(`TVL: ${tvl}`) | |
} | |
async function process(tlp) { | |
try { | |
let stats = await getLockdropStats(tlp) | |
let price = await getTLPPrice(tlp) | |
let astroPerDollar = (stats.incentives_share / stats.weighted_amount) / price | |
tvl += (stats.terraswap_amount_in_lockups / 1e6) * price | |
console.log(`Locked LP Tokens: ${stats.terraswap_amount_in_lockups / 1e6}`) | |
console.log(`Price per LP token: ${price}`) | |
console.log(`Locked value: ${(stats.terraswap_amount_in_lockups / 1e6) * price}`) | |
console.log(`Average Lock Duration (Days): ${(stats.weighted_amount / stats.terraswap_amount_in_lockups - 1) / 3 * 351 + 14}`) | |
console.log(`ASTRO per dollar minlocked: ${astroPerDollar}`) | |
} catch(e) { | |
console.log(e) | |
} | |
} | |
async function getLockdropStats(tlp) { | |
let result = await terra.wasm.contractQuery( | |
'terra1627ldjvxatt54ydd3ns6xaxtd68a2vtyu7kakj', | |
{ | |
pool: {terraswap_lp_token: tlp} | |
} | |
) | |
return result | |
} | |
async function getTLPPrice(tlp) { | |
let pool = (await terra.wasm.contractQuery( | |
tlp, | |
{ minter: {} } | |
)).minter | |
let poolInfo = await terra.wasm.contractQuery( | |
pool, | |
{ pool: {} } | |
) | |
let ust = poolInfo.assets.filter((a) => a.info.native_token && a.info.native_token.denom == 'uusd')[0] | |
let luna = poolInfo.assets.filter((a) => a.info.native_token && a.info.native_token.denom == 'uluna')[0] | |
return (2 * (ust ? ust.amount : luna.amount * lunaPrice)) / poolInfo.total_share | |
} | |
async function getLUNAPrice() { | |
let pool = (await terra.wasm.contractQuery( | |
pools.filter((p) => p.name == 'LUNA-UST')[0].tlp, | |
{ minter: {} } | |
)).minter | |
let poolInfo = await terra.wasm.contractQuery( | |
pool, | |
{ pool: {} } | |
) | |
let ust = poolInfo.assets.filter((a) => a.info.native_token && a.info.native_token.denom == 'uusd')[0] | |
let luna = poolInfo.assets.filter((a) => a.info.native_token && a.info.native_token.denom == 'uluna')[0] | |
return ust.amount / luna.amount; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment