forked from DefiLlama/peggedassets-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add EURS on Stellar, and some Stellar-specific helper functions
- Loading branch information
1 parent
f7abea7
commit 63ab304
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const axios = require("axios"); | ||
const retry = require("async-retry"); | ||
|
||
const stellarExpertEndpoint = (assetCode: string, assetIssuer: string): string => | ||
`https://api.stellar.expert/explorer/public/asset/${assetCode}-${assetIssuer}`; | ||
|
||
export async function getAsset(assetID: string) { | ||
// assetID is concatenation of the assetCode and assetIssuer, separated by a colon | ||
const [assetCode, assetIssuer] = assetID.split(":"); | ||
const asset = await retry( | ||
async (_bail: any) => | ||
await axios.get(stellarExpertEndpoint(assetCode, assetIssuer)) | ||
); | ||
const data = asset.data; | ||
return data; | ||
} | ||
|
||
export async function getTotalSupply(assetID: string) { | ||
// assetID is concatenation of the assetCode and assetIssuer, separated by a colon | ||
const asset = await getAsset(assetID); | ||
const decimals = 7; | ||
const supply = asset?.supply; | ||
return supply / 10 ** decimals; | ||
} |
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