├── .babelrc ├── .github └── workflows │ └── deploy.yml ├── .gitignore ├── .prettierignore ├── Dockerfile ├── README.md ├── api2 ├── cache.ts ├── cron-task │ ├── getStableCoins.ts │ ├── getStablecoinChains.ts │ ├── getStablecoinPrices.ts │ ├── index.ts │ ├── storeCharts.ts │ └── storePeggedPrices.ts ├── ecosystem.config.js ├── env.ts ├── file-cache.ts ├── index.ts ├── routes │ ├── getChainDominance.ts │ ├── getStableCoin.ts │ ├── index.ts │ └── utils.ts └── scripts │ ├── prod_start.sh │ └── storeRates.ts ├── docker-compose.yml ├── env.js ├── package-lock.json ├── package.json ├── resources ├── api-cloudfront-distribution.yml └── table-and-api.yml ├── serverless.yml ├── src ├── __mocks__ │ └── @sentry │ │ ├── serverless.ts │ │ └── tracing.ts ├── adapters │ ├── .gitignore │ ├── README.md │ ├── env.sample │ ├── package-lock.json │ ├── package.json │ └── peggedAssets │ │ ├── a7a5 │ │ └── index.ts │ │ ├── acala-dollar │ │ └── index.ts │ │ ├── aegis-yusd │ │ └── index.ts │ │ ├── agora-dollar │ │ └── index.ts │ │ ├── alchemix-usd │ │ └── index.ts │ │ ├── alternity-cny │ │ └── index.ts │ │ ├── anchored-coins-eur │ │ └── index.ts │ │ ├── angle-usd │ │ └── index.ts │ │ ├── anzen-usdz │ │ └── index.ts │ │ ├── anzens-usda │ │ └── index.ts │ │ ├── arable-usd │ │ └── index.ts │ │ ├── arche-protocol-msd │ │ └── index.ts │ │ ├── aryze-eeur │ │ └── index.ts │ │ ├── aryze-egbp │ │ └── index.ts │ │ ├── aryze-esgd │ │ └── index.ts │ │ ├── aryze-eusd │ │ └── index.ts │ │ ├── astherus-usdf │ │ └── index.ts │ │ ├── asymmetry-usdaf │ │ └── index.ts │ │ ├── avalon-usda │ │ └── index.ts │ │ ├── avant-usd │ │ └── index.ts │ │ ├── bacon-protocol-home │ │ └── index.ts │ │ ├── bai-stablecoin │ │ └── index.ts │ │ ├── balanced-dollars │ │ └── index.ts │ │ ├── bank-of-chain │ │ └── index.ts │ │ ├── baousd │ │ └── index.ts │ │ ├── bean2 │ │ └── index.ts │ │ ├── binance-peg-busd │ │ └── index.ts │ │ ├── binance-usd │ │ └── index.ts │ │ ├── bitcoin-usd-btcfi │ │ └── index.ts │ │ ├── bitsmiley-bitusd │ │ └── index.ts │ │ ├── blackrock-usd │ │ └── index.ts │ │ ├── bob │ │ └── index.ts │ │ ├── bread │ │ └── index.ts │ │ ├── brz │ │ └── index.ts │ │ ├── bucket-protocol-buck-stablecoin │ │ └── index.ts │ │ ├── cadc │ │ └── index.ts │ │ ├── celo-dollar │ │ └── index.ts │ │ ├── celo-euro │ │ └── index.ts │ │ ├── celo-real-creal │ │ └── index.ts │ │ ├── chad-usd │ │ └── index.ts │ │ ├── ckusdc │ │ └── index.ts │ │ ├── classic-usd │ │ └── index.ts │ │ ├── clever-usd │ │ └── index.ts │ │ ├── coin98-dollar │ │ └── index.ts │ │ ├── coinshift-usdl-morpho-vault │ │ └── index.ts │ │ ├── colb-usd-stablecolb │ │ └── index.ts │ │ ├── collateralized-debt-token │ │ └── index.ts │ │ ├── composite │ │ └── index.ts │ │ ├── convertible-jpy-token │ │ └── index.ts │ │ ├── crvusd │ │ └── index.ts │ │ ├── cygnus-finance-global-usd │ │ └── index.ts │ │ ├── czusd │ │ └── index.ts │ │ ├── dackie-usd │ │ └── index.ts │ │ ├── dai │ │ ├── config.ts │ │ └── index.ts │ │ ├── dam-finance │ │ └── index.ts │ │ ├── davos-protocol │ │ └── index.ts │ │ ├── defi-franc │ │ └── index.ts │ │ ├── dei-token │ │ └── index.ts │ │ ├── dexfinance-usdex │ │ └── index.ts │ │ ├── digital-standard-unit │ │ └── index.ts │ │ ├── digitaldollar │ │ └── index.ts │ │ ├── djed │ │ └── index.ts │ │ ├── doc │ │ └── index.ts │ │ ├── dola-usd │ │ └── index.ts │ │ ├── dtrinity-usd │ │ └── index.ts │ │ ├── dyad │ │ └── index.ts │ │ ├── e-money-eur │ │ └── index.ts │ │ ├── electronic-usd │ │ └── index.ts │ │ ├── elixir-deusd │ │ └── index.ts │ │ ├── ethena-usde │ │ └── index.ts │ │ ├── ethos-reserve-note │ │ └── index.ts │ │ ├── eura │ │ └── index.ts │ │ ├── eurc │ │ └── index.ts │ │ ├── euro3 │ │ └── index.ts │ │ ├── euroe-stablecoin │ │ └── index.ts │ │ ├── eusd │ │ └── index.ts │ │ ├── eusdv2 │ │ └── index.ts │ │ ├── f-x-btc-usd │ │ └── index.ts │ │ ├── falcon-finance │ │ └── index.ts │ │ ├── fantom-usd │ │ └── index.ts │ │ ├── fathom-dollar │ │ └── index.ts │ │ ├── fei-usd │ │ └── index.ts │ │ ├── felix-feusd │ │ └── index.ts │ │ ├── feth │ │ └── index.ts │ │ ├── first-digital-usd │ │ └── index.ts │ │ ├── fixed-income-asset-token │ │ └── index.ts │ │ ├── flex-usd │ │ └── index.ts │ │ ├── float-protocol-float │ │ └── index.ts │ │ ├── frankencoin │ │ └── index.ts │ │ ├── franklin-onchain-u-s-government-money-fund │ │ └── index.ts │ │ ├── frax-price-index │ │ └── index.ts │ │ ├── frax-usd │ │ └── index.ts │ │ ├── frax │ │ └── index.ts │ │ ├── fx-rusd │ │ └── index.ts │ │ ├── fxusd │ │ └── index.ts │ │ ├── gai-stablecoin │ │ └── index.ts │ │ ├── gemini-dollar │ │ └── index.ts │ │ ├── gho │ │ └── index.ts │ │ ├── glo-dollar │ │ └── index.ts │ │ ├── grai │ │ └── index.ts │ │ ├── gyen │ │ └── index.ts │ │ ├── gyroscope-gyd │ │ └── index.ts │ │ ├── hashnote-usyc │ │ └── index.ts │ │ ├── hedera-swiss-franc │ │ └── index.ts │ │ ├── hedge-usd │ │ └── index.ts │ │ ├── helio-protocol-hay │ │ └── index.ts │ │ ├── helper │ │ ├── algorand.js │ │ ├── algorandUtils │ │ │ └── address.js │ │ ├── aptos.ts │ │ ├── cardano.ts │ │ ├── chains.json │ │ ├── generalUtil.ts │ │ ├── getBlock.js │ │ ├── getSupply.ts │ │ ├── getTimestampAtStartOfHour.ts │ │ ├── http.js │ │ ├── icon.ts │ │ ├── kava.ts │ │ ├── mixin.ts │ │ ├── near.js │ │ ├── nibiru.ts │ │ ├── ontology.ts │ │ ├── polynetwork.ts │ │ ├── solana.js │ │ ├── starknet.js │ │ ├── stellar.ts │ │ ├── sui.ts │ │ ├── tezos.ts │ │ ├── tron.js │ │ └── utils.js │ │ ├── hermetica-usdh │ │ └── index.ts │ │ ├── hex-dollar-coin │ │ └── index.ts │ │ ├── hex-trust-usdx │ │ └── index.ts │ │ ├── high-yield-usd │ │ └── index.ts │ │ ├── honey-3 │ │ └── index.ts │ │ ├── husd │ │ └── index.ts │ │ ├── hydt │ │ └── index.ts │ │ ├── hyperstable │ │ └── index.ts │ │ ├── index.ts │ │ ├── inter-stable-token │ │ └── index.ts │ │ ├── interest-protocol │ │ └── index.ts │ │ ├── international-stable-currency │ │ └── index.ts │ │ ├── iron-bank-euro │ │ └── index.ts │ │ ├── iusd │ │ └── index.ts │ │ ├── jpy-coin │ │ └── index.ts │ │ ├── just-stablecoin │ │ └── index.ts │ │ ├── knox-dollar │ │ └── index.ts │ │ ├── kolibri-usd │ │ └── index.ts │ │ ├── legacy-bold │ │ └── index.ts │ │ ├── let-s-get-hai │ │ └── index.ts │ │ ├── level-usd │ │ └── index.ts │ │ ├── lift-dollar │ │ └── index.ts │ │ ├── liquid-loans-usdl │ │ └── index.ts │ │ ├── liquity-bold │ │ └── index.ts │ │ ├── liquity-usd │ │ └── index.ts │ │ ├── lugh │ │ └── index.ts │ │ ├── m-by-m^0 │ │ └── index.ts │ │ ├── magic-internet-money │ │ ├── abis │ │ │ ├── bentobox.ts │ │ │ └── cauldron-v1.ts │ │ └── index.ts │ │ ├── magma-wen │ │ └── index.ts │ │ ├── mead-2 │ │ └── index.ts │ │ ├── meme-dollar │ │ └── index.ts │ │ ├── mimatic │ │ └── index.ts │ │ ├── monerium-eur-money │ │ └── index.ts │ │ ├── moneta │ │ └── index.ts │ │ ├── moremoney-usd │ │ └── index.ts │ │ ├── move-dollar │ │ └── index.ts │ │ ├── musd │ │ └── index.ts │ │ ├── myusd │ │ └── index.ts │ │ ├── nars │ │ └── index.ts │ │ ├── neutrino │ │ └── index.ts │ │ ├── nexus-usd │ │ └── index.ts │ │ ├── nexus │ │ └── index.ts │ │ ├── noon-usn │ │ └── index.ts │ │ ├── nostra-uno │ │ ├── abi.ts │ │ └── index.ts │ │ ├── note │ │ └── index.ts │ │ ├── novatti-australian-digital-dollar │ │ └── index.ts │ │ ├── nusd │ │ └── index.ts │ │ ├── nxusd │ │ └── index.ts │ │ ├── offshift-anonusd │ │ └── index.ts │ │ ├── ondo-us-dollar-yield │ │ └── index.ts │ │ ├── openeden-open-dollar │ │ └── index.ts │ │ ├── openeden-tbill │ │ └── index.ts │ │ ├── opus-cash │ │ ├── abi.ts │ │ └── index.ts │ │ ├── orby-network-usc-stablecoin │ │ └── index.ts │ │ ├── origin-dollar │ │ └── index.ts │ │ ├── orki-usd │ │ └── index.ts │ │ ├── overnight-dai │ │ └── index.ts │ │ ├── pago-linea-usdcb │ │ └── index.ts │ │ ├── pando-usd │ │ └── index.ts │ │ ├── par-stablecoin │ │ └── index.ts │ │ ├── parallel-usd │ │ └── index.ts │ │ ├── parrot-usd │ │ └── index.ts │ │ ├── paxos-standard │ │ └── index.ts │ │ ├── paypal-usd │ │ └── index.ts │ │ ├── peg-eusd │ │ └── index.ts │ │ ├── peggedAsset.type.ts │ │ ├── phase-dollar │ │ └── index.ts │ │ ├── pinto │ │ └── index.ts │ │ ├── platypus-usd │ │ └── index.ts │ │ ├── plume-usd │ │ └── index.ts │ │ ├── powercity-pxdc │ │ └── index.ts │ │ ├── prices │ │ └── index.ts │ │ ├── prisma-mkusd │ │ └── index.ts │ │ ├── prismalrt-ultra │ │ └── index.ts │ │ ├── psy │ │ └── index.ts │ │ ├── pusd-2 │ │ └── index.ts │ │ ├── quantoz-eurd │ │ └── index.ts │ │ ├── quantoz-eurq │ │ └── index.ts │ │ ├── quantoz-usdq │ │ └── index.ts │ │ ├── quill-usd │ │ └── index.ts │ │ ├── r │ │ └── index.ts │ │ ├── rai │ │ └── index.ts │ │ ├── ratio-stable-coin │ │ ├── index.ts │ │ └── ratio-state.json │ │ ├── real-usd │ │ └── index.ts │ │ ├── redeemable │ │ └── index.ts │ │ ├── reserve │ │ └── index.ts │ │ ├── reservoir-stablecoin │ │ └── index.ts │ │ ├── resolv-usr │ │ └── index.ts │ │ ├── resupply-usd │ │ └── index.ts │ │ ├── revenue-generating-usd │ │ └── index.ts │ │ ├── rings-scusd │ │ └── index.ts │ │ ├── ripple-usd │ │ └── index.ts │ │ ├── sable-coin │ │ └── index.ts │ │ ├── satoshi-stablecoin │ │ └── index.ts │ │ ├── savvy-usd │ │ └── index.ts │ │ ├── schuman-europ │ │ └── index.ts │ │ ├── sdai │ │ └── index.ts │ │ ├── seur │ │ └── index.ts │ │ ├── sigmausd │ │ └── index.ts │ │ ├── silk │ │ └── index.ts │ │ ├── societe-generale-forge-eurcv │ │ ├── config.ts │ │ └── index.ts │ │ ├── solayer-usd │ │ └── index.ts │ │ ├── solomon-usdv │ │ └── index.ts │ │ ├── sovryn-dollar │ │ └── index.ts │ │ ├── sperax-usd │ │ └── index.ts │ │ ├── spiceusd │ │ └── index.ts │ │ ├── stabl-fi │ │ └── index.ts │ │ ├── stable-jack-ausd │ │ └── index.ts │ │ ├── stablr-euro │ │ └── index.ts │ │ ├── stablr-usd │ │ └── index.ts │ │ ├── standx-dusd │ │ └── index.ts │ │ ├── star │ │ └── index.ts │ │ ├── stasis-eurs │ │ └── index.ts │ │ ├── stbl │ │ └── index.ts │ │ ├── storeCurrencyPriceHistory.ts │ │ ├── syusd │ │ └── index.ts │ │ ├── tbill │ │ └── index.ts │ │ ├── terrausd │ │ └── index.ts │ │ ├── test.ts │ │ ├── tether-eurt │ │ └── index.ts │ │ ├── tether │ │ ├── config.ts │ │ └── index.ts │ │ ├── thestandard-usd │ │ └── index.ts │ │ ├── three-usd │ │ └── index.ts │ │ ├── threshold-usd │ │ └── index.ts │ │ ├── token-dforce-usd │ │ └── index.ts │ │ ├── tor │ │ └── index.ts │ │ ├── tren-debt-token │ │ └── index.ts │ │ ├── true-usd │ │ └── index.ts │ │ ├── uaht │ │ └── index.ts │ │ ├── usbd │ │ └── index.ts │ │ ├── usc-2 │ │ └── index.ts │ │ ├── usd-balance │ │ └── index.ts │ │ ├── usd-coin │ │ ├── config.ts │ │ └── index.ts │ │ ├── usd-rif │ │ └── index.ts │ │ ├── usd │ │ └── index.ts │ │ ├── usd1-wlfi │ │ └── index.ts │ │ ├── usd2 │ │ └── index.ts │ │ ├── usdb │ │ └── index.ts │ │ ├── usdd │ │ └── index.ts │ │ ├── usdfc │ │ └── index.ts │ │ ├── usdh │ │ └── index.ts │ │ ├── usdk │ │ └── index.ts │ │ ├── usdlemma │ │ └── index.ts │ │ ├── usdm │ │ └── index.ts │ │ ├── usdp │ │ └── index.ts │ │ ├── usds │ │ └── index.ts │ │ ├── usdtb │ │ └── index.ts │ │ ├── usdtez │ │ └── index.ts │ │ ├── usdtplus │ │ └── index.ts │ │ ├── usdv │ │ └── index.ts │ │ ├── usdw │ │ └── index.ts │ │ ├── usdx-money-usdx │ │ └── index.ts │ │ ├── usdx │ │ └── index.ts │ │ ├── usk │ │ └── index.ts │ │ ├── usn │ │ └── index.ts │ │ ├── usual-usd │ │ └── index.ts │ │ ├── uxd-stablecoin │ │ └── index.ts │ │ ├── vai │ │ └── index.ts │ │ ├── vdollar-finance │ │ └── index.ts │ │ ├── vesta-stable │ │ └── index.ts │ │ ├── vnx-euro │ │ └── index.ts │ │ ├── vnx-gold │ │ └── index.ts │ │ ├── vnx-swiss-franc │ │ └── index.ts │ │ ├── volt-protocol │ │ └── index.ts │ │ ├── web-3-dollar │ │ └── index.ts │ │ ├── worldwide-usd │ │ └── index.ts │ │ ├── xai │ │ └── index.ts │ │ ├── xbanking-usde │ │ └── index.ts │ │ ├── xsgd │ │ └── index.ts │ │ ├── xusd-babelfish │ │ └── index.ts │ │ ├── yala-stablecoin │ │ └── index.ts │ │ ├── ylds │ │ └── index.ts │ │ ├── youves-uusd │ │ └── index.ts │ │ ├── yusd-stablecoin │ │ └── index.ts │ │ ├── zkusd │ │ └── index.ts │ │ ├── zoth-zeusd │ │ └── index.ts │ │ ├── zun-eth │ │ └── index.ts │ │ ├── zun-usd │ │ └── index.ts │ │ ├── zunami-protocol │ │ └── index.ts │ │ └── zusd │ │ └── index.ts ├── alertOutdated.ts ├── checkRecentDbEntries.ts ├── cli │ ├── buildRequires.ts │ ├── storeAllPeggedAssets.ts │ └── utils.ts ├── config.ts ├── constants.ts ├── fallback.test.ts ├── fallback.ts ├── getChainDominance.ts ├── getRates.ts ├── getStablecoin.ts ├── getStablecoinChains.ts ├── getStablecoinChart.ts ├── getStablecoinPrices.ts ├── getStablecoins.ts ├── peggedAssets │ ├── storePeggedAssets │ │ ├── errorDb.ts │ │ ├── getAndStorePeggedAssets.ts │ │ ├── storeNewPeggedBalances.ts │ │ ├── storePegged.ts │ │ └── testStorePegged.ts │ └── utils │ │ ├── getLastRecord.ts │ │ ├── importAdapter.ts │ │ └── sluggifyPegged.ts ├── peggedData │ ├── backfilledChains.ts │ ├── bridgeData.ts │ ├── peggedData.ts │ └── types.ts ├── sendDiscordMessage.ts ├── setupTestEnv.js ├── storeGetStablecoinChart.ts ├── storePeggedAssets.ts ├── storePeggedPrices.ts ├── storeRates.ts ├── testGetPeggedChart.ts ├── testGetPeggeds.ts ├── testStorePeggedPrices.ts ├── triggerStorePegged.ts ├── types.ts └── utils │ ├── date.test.ts │ ├── date.ts │ ├── discord.ts │ ├── error.ts │ ├── fetchPrices.ts │ ├── getLastRecord.ts │ ├── normalizeChain.ts │ ├── normalizeChains.test.ts │ ├── s3.ts │ ├── shared │ ├── coingeckoLocks.ts │ ├── dynamodb.ts │ ├── getRecordClosestToTimestamp.ts │ ├── index.ts │ ├── invokeLambda.ts │ ├── lambda-response.test.ts │ ├── lambda-response.ts │ ├── parseRequestBody.test.ts │ ├── parseRequestBody.ts │ ├── sleep.ts │ └── wrap.ts │ └── wrapOrRedirect.ts ├── tsconfig.json └── webpack.config.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "@babel/preset-env", 5 | { 6 | "targets": { 7 | "node": "14" 8 | } 9 | } 10 | ] 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /.github/workflows/deploy.yml: -------------------------------------------------------------------------------- 1 | name: Deploy 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | 7 | jobs: 8 | deploy: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v2 12 | - name: Get Node.js 13 | uses: actions/setup-node@v1 14 | with: 15 | node-version: '16' 16 | - run: npm ci 17 | - name: Deploy infrastructure stack 18 | run: npm run deploy:dev 19 | env: 20 | AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} 21 | AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} 22 | OUTDATED_WEBHOOK: ${{ secrets.OUTDATED_WEBHOOK }} 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .webpack 3 | .env 4 | .serverless 5 | imported-db 6 | docker 7 | .DS_Store 8 | .esbuild 9 | src/utils/imports/adapters.ts 10 | src/adapters/peggedAssets/addNewPeggedChecklist.md 11 | src/adapters/peggedAssets/storeCoinGeckoHistory.ts 12 | src/adapters/peggedAssets/testAdapter.ts 13 | src/peggedAssets/storePeggedAssets/testGetAndStore.ts 14 | src/adapters/peggedAssets/testAllAdapters.ts 15 | src/testGetPeggedChart.ts 16 | src/adapters/peggedAssets/historical/ 17 | package-lock.json 18 | src/adapters/peggedAssets/storeCoinGeckoPriceHistory.ts 19 | api2/.api2-cache/* 20 | .current_commit_hash -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | # Ignore all files 2 | * -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Use an official Node.js runtime as a parent image 2 | FROM node:20 3 | 4 | # Set the working directory in the container to /app 5 | WORKDIR /app 6 | 7 | # Clone your repo 8 | RUN git clone https://github.com/DefiLlama/peggedassets-server /app/repo 9 | 10 | # Change to the directory of your repo 11 | WORKDIR /app/repo 12 | 13 | # RUN git checkout api2 14 | 15 | # Install any needed packages specified in package.json 16 | RUN npm install 17 | 18 | # Make port 5001 available to the world outside this container 19 | EXPOSE 5001 20 | 21 | # bash command to keep the container running 22 | CMD ["bash", "-c", "npm run api2-prod; while true; do sleep 10000; done"] -------------------------------------------------------------------------------- /api2/cache.ts: -------------------------------------------------------------------------------- 1 | import { getLastRecord, historicalRates } from "../src/peggedAssets/utils/getLastRecord"; 2 | import { readFromPGCache, writeToPGCache } from "./file-cache"; 3 | 4 | export enum CacheType { 5 | CRON, 6 | API_SERVER 7 | } 8 | 9 | type Prices = { 10 | [coinGeckoId: string]: number; 11 | }; 12 | 13 | type DailyPeggedPrices = { 14 | PK: string; 15 | SK: number; 16 | prices: Prices; 17 | } 18 | 19 | export const cache: { 20 | peggedPrices?: Prices; 21 | rates?: any; 22 | historicalRates?: any; 23 | lastPrices?: any; 24 | priceTimestamps?: any; 25 | rateTimestamps?: any; 26 | peggedAssetsData?: any; 27 | historicalPrices?: DailyPeggedPrices[] 28 | } = {} 29 | 30 | const cacheFile = 'stablecoin-cache-v5' 31 | 32 | export async function initCache(cacheType = CacheType.API_SERVER) { 33 | console.time('Cache initialized') 34 | if (cacheType === CacheType.CRON) { 35 | const _cache = await readFromPGCache(cacheFile) ?? {} 36 | Object.keys(_cache).forEach(key => cache[key] = _cache[key]) 37 | cache.rates = await getLastRecord(historicalRates); 38 | } 39 | console.timeEnd('Cache initialized') 40 | } 41 | 42 | export async function saveCache() { 43 | await writeToPGCache(cacheFile, cache) 44 | } 45 | -------------------------------------------------------------------------------- /api2/cron-task/getStablecoinPrices.ts: -------------------------------------------------------------------------------- 1 | 2 | import { secondsInHour } from "../../src/utils/date"; 3 | import { cache } from "../cache"; 4 | 5 | export function craftStablecoinPricesResponse() { 6 | const historicalPeggedPrices = cache.historicalPrices! 7 | 8 | const lastPrices = cache.lastPrices 9 | 10 | const lastDailyItem = 11 | historicalPeggedPrices[historicalPeggedPrices.length - 1]; 12 | if ( 13 | lastPrices !== undefined && 14 | lastPrices.SK > lastDailyItem.SK && 15 | lastDailyItem.SK + secondsInHour * 25 > lastPrices.SK 16 | ) { 17 | lastPrices.SK = lastDailyItem.SK; 18 | historicalPeggedPrices[historicalPeggedPrices.length - 1] = lastPrices; 19 | } 20 | 21 | let response = historicalPeggedPrices 22 | ?.map((item) => 23 | typeof item === "object" 24 | ? { 25 | date: item.SK, 26 | prices: item.prices, 27 | } 28 | : { prices: undefined } 29 | ) 30 | .filter((item) => item.prices !== undefined); 31 | 32 | return response; 33 | } 34 | -------------------------------------------------------------------------------- /api2/ecosystem.config.js: -------------------------------------------------------------------------------- 1 | // https://pm2.keymetrics.io/docs/usage/application-declaration/ 2 | module.exports = { 3 | apps: [ 4 | { 5 | name: 'api2-stablecoin-rest-server', 6 | script: './api2/index.ts', // Path to your main TypeScript file 7 | interpreter: 'node', 8 | args: '-r ts-node/register', // Use ts-node for running TypeScript files 9 | listen_timeout: 120_000, // Wait 120 seconds for the app to start 10 | kill_timeout: 10_000, // Wait 10 seconds for the app to start 11 | wait_ready: true, // Wait for the 'ready' signal 12 | instances: 2, 13 | exec_mode: 'cluster', // Start in cluster mode 14 | env: { 15 | TS_NODE_TRANSPILE_ONLY: 'true', // Enable ts-node's transpile-only mode, setting it via args is not working for some reason 16 | }, 17 | }, 18 | ], 19 | }; -------------------------------------------------------------------------------- /api2/env.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | const requiredEnvVars = ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'] 4 | 5 | export function validateEnv() { 6 | const ENV = process.env 7 | 8 | if (requiredEnvVars.some((envVar) => !ENV[envVar])) 9 | throw new Error(`Missing required environment variables: ${requiredEnvVars.join(', ')}`) 10 | } 11 | 12 | export default function geEnv() { 13 | const ENV = process.env 14 | 15 | if (!process.env.tableName) process.env.tableName = 'prod-stablecoins-table' 16 | if (!process.env.AWS_REGION) process.env.AWS_REGION = 'eu-central-1' 17 | 18 | 19 | return { 20 | tableName: ENV.tableName, 21 | AWS_REGION: ENV.AWS_REGION, 22 | api2CacheDir: __dirname + '/.api2-cache', 23 | } 24 | } -------------------------------------------------------------------------------- /api2/routes/utils.ts: -------------------------------------------------------------------------------- 1 | import * as HyperExpress from "hyper-express"; 2 | import * as sdk from '@defillama/sdk' 3 | 4 | function getTimeInFutureMinutes(minutes: number) { 5 | const date = new Date(); 6 | // add five minutes to the current time 7 | date.setMinutes(date.getMinutes() + minutes); 8 | return date.toUTCString() 9 | } 10 | 11 | export function successResponse(res: HyperExpress.Response, data: any, cacheMinutes: number = 30, { 12 | isJson = true, 13 | isPost = false, 14 | } = {}) { 15 | res.setHeaders({ 16 | "Expires": getTimeInFutureMinutes(cacheMinutes) // cache for 5 minutes 17 | }) 18 | if (isPost) 19 | res.removeHeader("Expires") 20 | 21 | isJson ? res.json(data) : res.send(data) 22 | } 23 | 24 | export function errorResponse(res: HyperExpress.Response, data: any = 'Internal server error', { 25 | statusCode = 400, 26 | } = {}) { 27 | res.status(statusCode) 28 | res.send(data, true) 29 | } 30 | 31 | export function errorWrapper(routeFn: any) { 32 | return async (req: HyperExpress.Request, res: HyperExpress.Response) => { 33 | try { 34 | await routeFn(req, res) 35 | } catch (e) { 36 | sdk.log(e) 37 | res.status(500) 38 | return res.send('Internal Error', true) 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /api2/scripts/storeRates.ts: -------------------------------------------------------------------------------- 1 | 2 | import { handler } from '../../src/storeRates' 3 | 4 | handler({}).then(() => console.log('Stored rates')).catch(console.error) -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.8' 2 | services: 3 | dynamodb-local: 4 | command: "-jar DynamoDBLocal.jar -sharedDb -optimizeDbBeforeStartup -dbPath ./data" 5 | image: "amazon/dynamodb-local:latest" 6 | container_name: dynamodb-local 7 | ports: 8 | - "8000:8000" 9 | volumes: 10 | - "./docker/dynamodb:/home/dynamodblocal/data" 11 | working_dir: /home/dynamodblocal 12 | -------------------------------------------------------------------------------- /env.js: -------------------------------------------------------------------------------- 1 | try{ 2 | require('dotenv').config() 3 | }catch(e){} 4 | module.exports = { 5 | } 6 | -------------------------------------------------------------------------------- /resources/table-and-api.yml: -------------------------------------------------------------------------------- 1 | Resources: 2 | # DynamoDB 3 | DynamoTable: 4 | Type: AWS::DynamoDB::Table 5 | DeletionPolicy: Retain # Make sure the tables can't be deleted by CloudFormation/Serverless 6 | Properties: 7 | TableName: ${self:custom.tableName} 8 | AttributeDefinitions: 9 | - AttributeName: PK 10 | AttributeType: S 11 | - AttributeName: SK 12 | AttributeType: N 13 | KeySchema: 14 | - AttributeName: PK 15 | KeyType: HASH 16 | - AttributeName: SK 17 | KeyType: RANGE 18 | # Set the capacity to auto-scale 19 | BillingMode: PAY_PER_REQUEST 20 | # CORS for api gateway errors 21 | GatewayResponseDefault4XX: 22 | Type: 'AWS::ApiGateway::GatewayResponse' 23 | Properties: 24 | ResponseParameters: 25 | gatewayresponse.header.Access-Control-Allow-Origin: "'*'" 26 | gatewayresponse.header.Access-Control-Allow-Headers: "'*'" 27 | ResponseType: DEFAULT_4XX 28 | RestApiId: 29 | Ref: 'ApiGatewayRestApi' 30 | GatewayResponseDefault5XX: 31 | Type: 'AWS::ApiGateway::GatewayResponse' 32 | Properties: 33 | ResponseParameters: 34 | gatewayresponse.header.Access-Control-Allow-Origin: "'*'" 35 | gatewayresponse.header.Access-Control-Allow-Headers: "'*'" 36 | ResponseType: DEFAULT_5XX 37 | RestApiId: 38 | Ref: 'ApiGatewayRestApi' -------------------------------------------------------------------------------- /src/__mocks__/@sentry/serverless.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/prefer-default-export */ 2 | const AWSLambda = { 3 | init: () => {}, 4 | wrapHandler: (f: Function) => f, 5 | captureException() {}, 6 | }; 7 | 8 | export { AWSLambda }; 9 | -------------------------------------------------------------------------------- /src/__mocks__/@sentry/tracing.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/prefer-default-export */ 2 | function addExtensionMethods() {} 3 | 4 | export { addExtensionMethods }; 5 | -------------------------------------------------------------------------------- /src/adapters/.gitignore: -------------------------------------------------------------------------------- 1 | helper/db.js 2 | node_modules 3 | .env 4 | run.js 5 | blocks.js 6 | historical-data.js 7 | /.idea 8 | yarn.lock 9 | .DS_Store 10 | projects/pooltogether/index.js 11 | -------------------------------------------------------------------------------- /src/adapters/README.md: -------------------------------------------------------------------------------- 1 | Example test: 2 | ``` 3 | npx ts-node peggedAssets/test.ts peggedAssets/liquity-usd/index.ts 4 | npx ts-node --transpile-only test.ts YOURPEGGEDASSET peggedTYPE (default is USD) 5 | ``` 6 | -------------------------------------------------------------------------------- /src/adapters/env.sample: -------------------------------------------------------------------------------- 1 | ETHEREUM_RPC=https://eth-mainnet.gateway.pokt.network/v1/5f3453978e354ab992c4da79 2 | BSC_RPC=https://bsc-dataseed4.binance.org 3 | POLYGON_RPC=https://rpc-mainnet.maticvigil.com/ 4 | HECO_RPC=https://http-mainnet.hecochain.com 5 | FANTOM_RPC=https://rpcapi.fantom.network 6 | RSK_RPC=https://public-node.rsk.co 7 | TOMOCHAIN_RPC=https://rpc.tomochain.com 8 | XDAI_RPC=https://xdai.poanetwork.dev 9 | AVAX_RPC=https://api.avax.network/ext/bc/C/rpc 10 | WAN_RPC=https://gwan-ssl.wandevs.org:56891 11 | HARMONY_RPC=https://api.s0.t.hmny.io 12 | THUNDERCORE_RPC=https://mainnet-rpc.thundercore.com 13 | OKEXCHAIN_RPC=https://exchainrpc.okex.org 14 | OPTIMISM_RPC=https://mainnet.optimism.io/ 15 | ARBITRUM_RPC=https://arb1.arbitrum.io/rpc 16 | KCC_RPC=https://rpc-mainnet.kcc.network 17 | CELO_RPC=https://forno.celo.org 18 | POLIS_RPC=https://rpc.polis.tech 19 | KLAYTN_RPC=https://public-node-api.klaytnapi.com/v1/cypress 20 | -------------------------------------------------------------------------------- /src/adapters/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "defillama-adapters", 3 | "version": "1.0.0", 4 | "private": true, 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "dev": "" 9 | }, 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "@defillama/sdk": "^5.0.44", 14 | "@project-serum/anchor": "^0.26.0", 15 | "@solana/web3.js": "^1.36.0", 16 | "@supercharge/promise-pool": "^3.2.0", 17 | "async-retry": "^1.3.1", 18 | "axios": "^1.6.8", 19 | "bignumber.js": "^9.0.1", 20 | "dotenv": "^16.4.5", 21 | "pact-lang-api": "^4.3.5", 22 | "starknet": "^6.0.0" 23 | }, 24 | "overrides": { 25 | "ansi-regex": "5.0.1", 26 | "mocha": { 27 | "nanoid": "3.3.1" 28 | }, 29 | "@project-serum/anchor": { 30 | "nth-check": "2.0.1" 31 | } 32 | }, 33 | "description": "" 34 | } 35 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/a7a5/index.ts: -------------------------------------------------------------------------------- 1 | const pegType = "peggedRUB"; 2 | const chainContracts = { 3 | ethereum: { 4 | issued: "0x6fA0BE17e4beA2fCfA22ef89BF8ac9aab0AB0fc9", pegType 5 | }, 6 | tron: { 7 | issued: "TLeVfrdym8RoJreJ23dAGyfJDygRtiWKBZ", pegType 8 | }, 9 | }; 10 | 11 | import { addChainExports } from "../helper/getSupply"; 12 | const adapter = addChainExports(chainContracts, undefined, { pegType }); 13 | export default adapter; 14 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/aegis-yusd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x4274cd7277c7bb0806bd5fe84b9adae466a8da0a"], 4 | }, 5 | bsc: { 6 | issued: ["0xAB3dBcD9B096C3fF76275038bf58eAC10D22C61f"], 7 | }, 8 | }; 9 | 10 | import { addChainExports } from "../helper/getSupply"; 11 | const adapter = addChainExports(chainContracts); 12 | export default adapter; 13 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/alchemix-usd/index.ts: -------------------------------------------------------------------------------- 1 | import { addChainExports, } from "../helper/getSupply"; 2 | import { 3 | ChainContracts, 4 | } from "../peggedAsset.type"; 5 | 6 | const chainContracts: ChainContracts = { 7 | ethereum: { 8 | issued: ["0xbc6da0fe9ad5f3b0d58160288917aa56653660e9"], 9 | unreleased: ["0x9735f7d3ea56b454b24ffd74c58e9bd85cfad31b"], // AMO 10 | }, 11 | arbitrum: { 12 | bridgedFromETH: ["0x2130d2a1e51112D349cCF78D2a1EE65843ba36e0"], // multichain 13 | }, 14 | optimism: { 15 | bridgedFromETH: [ 16 | "0xb2c22A9fb4FC02eb9D1d337655Ce079a04a526C7", // multichain 17 | "0xCB8FA9a76b8e203D8C3797bF438d8FB81Ea3326A", // also multichain? 18 | ], 19 | }, 20 | fantom: { 21 | bridgedFromETH: ["0xB67FA6deFCe4042070Eb1ae1511Dcd6dcc6a532E"], // has more than in multichain bridge contract 22 | }, 23 | }; 24 | 25 | const adapter = addChainExports(chainContracts); 26 | export default adapter; 27 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/alternity-cny/index.ts: -------------------------------------------------------------------------------- 1 | 2 | const chainContracts: any = { 3 | ethereum: { 4 | issued: ["0x7635b612792e4bfb7f2fa12a3e5d5a3f2e3c34bc"], 5 | pegType: "peggedCNY", 6 | }, 7 | }; 8 | 9 | import { addChainExports } from "../helper/getSupply"; 10 | const adapter = addChainExports(chainContracts); 11 | export default adapter; 12 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/anchored-coins-eur/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0xA40640458FBc27b6EefEdeA1E9C9E17d4ceE7a21"], 4 | pegType: 'peggedEUR', 5 | }, 6 | bsc: { 7 | issued: ["0xA40640458FBc27b6EefEdeA1E9C9E17d4ceE7a21"], 8 | pegType: 'peggedEUR', 9 | }, 10 | }; 11 | 12 | 13 | import { addChainExports } from "../helper/getSupply"; 14 | const adapter = addChainExports(chainContracts); 15 | export default adapter; 16 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/angle-usd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x0000206329b97DB379d5E1Bf586BbDB969C63274"], 4 | } 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/anzen-usdz/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0xa469b7ee9ee773642b3e93e842e5d9b5baa10067"], 4 | }, 5 | base: { 6 | issued: ["0x04d5ddf5f3a8939889f11e97f8c4bb48317f1938"], 7 | }, 8 | blast: { 9 | issued: ["0x52056ed29fe015f4ba2e3b079d10c0b87f46e8c6"], 10 | }, 11 | manta: { 12 | issued: ["0x73d23f3778a90be8846e172354a115543df2a7e4"], 13 | } 14 | }; 15 | 16 | import { addChainExports } from "../helper/getSupply"; 17 | const adapter = addChainExports(chainContracts); 18 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/anzens-usda/index.ts: -------------------------------------------------------------------------------- 1 | import { 2 | PeggedIssuanceAdapter, 3 | Balances, 4 | } from "../peggedAsset.type"; 5 | import { sumSingleBalance } from "../helper/generalUtil"; 6 | import { getTotalSupply } from "../helper/cardano"; 7 | 8 | const assetIDs = { 9 | cardano: { 10 | issued: [ 11 | "fe7c786ab321f41c654ef6c1af7b3250a613c24e4213e0425a7ae45655534441", 12 | ], 13 | }, 14 | }; 15 | 16 | async function getCardanoSupply() { 17 | let balances: Balances = {}; 18 | const supply = await getTotalSupply(assetIDs.cardano.issued[0]); 19 | sumSingleBalance(balances, "peggedUSD", supply, "issued", false); 20 | 21 | return balances; 22 | } 23 | 24 | const adapter: PeggedIssuanceAdapter = { 25 | cardano: { 26 | minted: getCardanoSupply, 27 | }, 28 | }; 29 | 30 | export default adapter; 31 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/arable-usd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | avax: { 3 | issued: ["0x025AB35fF6AbccA56d57475249baaEae08419039"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/arche-protocol-msd/index.ts: -------------------------------------------------------------------------------- 1 | import { PeggedIssuanceAdapter } from "../peggedAsset.type"; 2 | import { function_view } from "../helper/aptos"; 3 | import { Balances } from "../peggedAsset.type"; 4 | 5 | async function moveSupply(): Promise { 6 | const balances = {} as Balances; 7 | 8 | const resp = await function_view({ 9 | functionStr: '0x1::fungible_asset::supply', 10 | type_arguments: ['0x1::object::ObjectCore'], 11 | args: ["0x7c9d9f4972072b6ff7dfa48f259688e7286abac9ebd192bbda30fea910139024"], 12 | }); 13 | balances["peggedUSD"] = Number(resp.vec[0]) / 1e6; 14 | 15 | return balances; 16 | } 17 | 18 | 19 | 20 | const adapter: PeggedIssuanceAdapter = { 21 | move: { 22 | minted: moveSupply, 23 | }, 24 | }; 25 | 26 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/aryze-eeur/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x735fa792e731a2e8F83F32eb539841b7B72e6d8f"], 4 | pegType: 'peggedEUR', 5 | }, 6 | polygon: { 7 | issued: ["0x735fa792e731a2e8F83F32eb539841b7B72e6d8f"], 8 | pegType: 'peggedEUR', 9 | }, 10 | bsc: { 11 | issued: ["0x735fa792e731a2e8F83F32eb539841b7B72e6d8f"], 12 | pegType: 'peggedEUR', 13 | }, 14 | }; 15 | 16 | import { addChainExports } from "../helper/getSupply"; 17 | const adapter = addChainExports(chainContracts); 18 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/aryze-egbp/index.ts: -------------------------------------------------------------------------------- 1 | 2 | const pegType = "peggedGBP"; 3 | 4 | const chainContracts = { 5 | ethereum: { 6 | issued: ["0xD711D7D893de57dc13Ff465763218770Bd42DB1D"], pegType, 7 | }, 8 | polygon: { 9 | issued: ["0xD711D7D893de57dc13Ff465763218770Bd42DB1D"], pegType 10 | }, 11 | bsc: { 12 | issued: ["0xD711D7D893de57dc13Ff465763218770Bd42DB1D"], pegType 13 | }, 14 | }; 15 | 16 | 17 | import { addChainExports } from "../helper/getSupply"; 18 | const adapter = addChainExports(chainContracts); 19 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/aryze-esgd/index.ts: -------------------------------------------------------------------------------- 1 | 2 | const pegType = "peggedSGD"; 3 | 4 | const chainContracts = { 5 | ethereum: { 6 | issued: ["0x58A849E1f3c7044bB317DB4611269c352c53d399"], pegType, 7 | }, 8 | polygon: { 9 | issued: ["0x58A849E1f3c7044bB317DB4611269c352c53d399"], pegType, 10 | }, 11 | bsc: { 12 | issued: ["0x58A849E1f3c7044bB317DB4611269c352c53d399"], pegType, 13 | }, 14 | }; 15 | 16 | import { addChainExports } from "../helper/getSupply"; 17 | const adapter = addChainExports(chainContracts); 18 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/aryze-eusd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0xa4335da338ec4C07C391Fc1A9bF75F306adadc08"], 4 | }, 5 | polygon: { 6 | issued: ["0xa4335da338ec4C07C391Fc1A9bF75F306adadc08"], 7 | }, 8 | bsc: { 9 | issued: ["0xa4335da338ec4C07C391Fc1A9bF75F306adadc08"], 10 | }, 11 | }; 12 | 13 | 14 | import { addChainExports } from "../helper/getSupply"; 15 | const adapter = addChainExports(chainContracts); 16 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/astherus-usdf/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | bsc: { 3 | issued: ["0x5A110fC00474038f6c02E89C707D638602EA44B5"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/asymmetry-usdaf/index.ts: -------------------------------------------------------------------------------- 1 | 2 | import { addChainExports } from "../helper/getSupply"; 3 | 4 | const chainContracts = { 5 | ethereum: { 6 | issued: ["0x85e30b8b263bc64d94b827ed450f2edfee8579da"], 7 | }, 8 | }; 9 | 10 | const adapter = addChainExports(chainContracts); 11 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/avant-usd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | avax: { 3 | issued: ["0x24dE8771bC5DdB3362Db529Fc3358F2df3A0E346"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/bacon-protocol-home/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: "0xb8919522331C59f5C16bDfAA6A121a6E03A91F62", 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/bai-stablecoin/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | astar: { 3 | issued: ["0x733ebcC6DF85f8266349DEFD0980f8Ced9B45f35"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/balanced-dollars/index.ts: -------------------------------------------------------------------------------- 1 | import { getXSupply, getICONSupply } from "../helper/icon" 2 | 3 | const adapter = { 4 | icon: { 5 | minted: () => getICONSupply() 6 | }, 7 | // ICON chains where bnUSD is minted natively 8 | havah: { 9 | minted: () => getXSupply("0x100.icon"), 10 | }, 11 | // COSMOS chains where bnUSD is minted natively 12 | injective: { 13 | minted: () => getXSupply("injective-1"), 14 | }, 15 | archway: { 16 | minted: () => getXSupply("archway-1"), 17 | }, 18 | // EVM chains where bnUSD is minted natively 19 | avax: { 20 | minted: () => getXSupply("0xa86a.avax"), 21 | }, 22 | arbitrum: { 23 | minted: () => getXSupply("0xa4b1.arbitrum"), 24 | }, 25 | base: { 26 | minted: () => getXSupply("0x2105.base"), 27 | }, 28 | optimism: { 29 | minted: () => getXSupply("0xa.optimism"), 30 | }, 31 | bsc: { 32 | minted: () => getXSupply("0x38.bsc"), 33 | }, 34 | }; 35 | 36 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/bank-of-chain/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x83131242843257bc6C43771762ba467346Efb2CF"], //USDi 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/baousd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x7945b0A6674b175695e5d1D08aE1e6F13744Abb0"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/bean2/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0xBEA0000029AD1c77D3d5D23Ba2D8893dB9d1Efab"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/bitcoin-usd-btcfi/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | bfc: { 3 | issued: ["0x6906Ccda405926FC3f04240187dd4fAd5DF6d555"] 4 | }, 5 | base: { 6 | bridgedFromBfc: ["0xe4b20925d9e9a62f1e492e15a81dc0de62804dd4"] 7 | }, 8 | }; 9 | 10 | import { addChainExports } from "../helper/getSupply"; 11 | const adapter = addChainExports(chainContracts) 12 | export default adapter; 13 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/bitsmiley-bitusd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | btr: { 3 | issued: ["0x07373d112edc4570b46996ad1187bc4ac9fb5ed0"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/blackrock-usd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x7712c34205737192402172409a8F7ccef8aA2AEc","0x6a9DA2D710BB9B700acde7Cb81F10F1fF8C89041"], 4 | }, 5 | aptos: { 6 | issued: ["0x50038be55be5b964cfa32cf128b5cf05f123959f286b4cc02b86cafd48945f89"], 7 | }, 8 | arbitrum: { 9 | issued: ["0xA6525Ae43eDCd03dC08E775774dCAbd3bb925872"], 10 | }, 11 | avax: { 12 | issued: ["0x53FC82f14F009009b440a706e31c9021E1196A2F"], 13 | }, 14 | optimism: { 15 | issued: ["0xa1CDAb15bBA75a80dF4089CaFbA013e376957cF5"], 16 | }, 17 | polygon: { 18 | issued: ["0x2893Ef551B6dD69F661Ac00F11D93E5Dc5Dc0e99"], 19 | }, 20 | }; 21 | 22 | import { addChainExports } from "../helper/getSupply"; 23 | const adapter = addChainExports(chainContracts); 24 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/bread/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | xdai: { 3 | issued: ["0xa555d5344f6fb6c65da19e403cb4c1ec4a1a5ee3"], 4 | }, 5 | }; 6 | import { addChainExports } from "../helper/getSupply"; 7 | const adapter = addChainExports(chainContracts); 8 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/bucket-protocol-buck-stablecoin/index.ts: -------------------------------------------------------------------------------- 1 | import { sumSingleBalance } from "../helper/generalUtil"; 2 | import { 3 | Balances, 4 | PeggedIssuanceAdapter, ChainContracts, 5 | } from "../peggedAsset.type"; 6 | import * as sui from "../helper/sui"; 7 | 8 | 9 | const chainContracts: ChainContracts = { 10 | sui: { 11 | issued: [ 12 | "0x9e3dab13212b27f5434416939db5dec6a319d15b89a84fd074d03ece6350d3df", 13 | ], 14 | }, 15 | } 16 | 17 | async function suiMinted() { 18 | return async function (): Promise { 19 | let balances = {} as Balances; 20 | const { fields: buckAmount } = await sui.getObject( 21 | chainContracts.sui.issued[0] 22 | ); 23 | const mintedAmount = 24 | buckAmount.buck_treasury_cap.fields.total_supply.fields.value; 25 | 26 | sumSingleBalance( 27 | balances, 28 | "peggedUSD", 29 | mintedAmount / 10 ** 9, 30 | undefined, 31 | true 32 | ); 33 | return balances; 34 | }; 35 | } 36 | 37 | const adapter: PeggedIssuanceAdapter = { 38 | sui: { 39 | minted: suiMinted(), 40 | }, 41 | }; 42 | 43 | export default adapter; 44 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/cadc/index.ts: -------------------------------------------------------------------------------- 1 | 2 | const pegType = "peggedCAD"; 3 | 4 | const chainContracts = { 5 | ethereum: { 6 | issued: "0xcaDC0acd4B445166f12d2C07EAc6E2544FbE2Eef", pegType 7 | }, 8 | polygon: { 9 | issued: "0x9de41aFF9f55219D5bf4359F167d1D0c772A396D", pegType 10 | }, 11 | arbitrum: { 12 | issued: "0x2b28E826b55e399F4d4699b85f68666AC51e6f70", pegType 13 | }, 14 | base: { 15 | issued: "0x043eb4b75d0805c43d7c834902e335621983cf03", pegType 16 | } 17 | }; 18 | 19 | import { addChainExports } from "../helper/getSupply"; 20 | const adapter = addChainExports(chainContracts, undefined, { pegType}); 21 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/celo-real-creal/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | celo: { 3 | issued: "0xe8537a3d056DA446677B9E9d6c5dB704EaAb4787", 4 | pegType: 'peggedREAL' 5 | }, 6 | }; 7 | 8 | 9 | import { addChainExports } from "../helper/getSupply"; 10 | const adapter = addChainExports(chainContracts, undefined, { pegType: 'peggedREAL' }); 11 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/chad-usd/index.ts: -------------------------------------------------------------------------------- 1 | import { ChainBlocks, PeggedIssuanceAdapter } from "../peggedAsset.type"; 2 | const sdk = require("@defillama/sdk"); 3 | 4 | const chainContracts = { 5 | scroll: { 6 | issued: "0x9F24de635C78C5Df77F9EA9aA3C6D71FfcabEc8f", 7 | }, 8 | }; 9 | 10 | async function scrollMinted() { 11 | return async function ( 12 | _timestamp: number, 13 | _ethBlock: number, 14 | _chainBlocks: ChainBlocks 15 | ) { 16 | const totalSupply = ( 17 | await sdk.api.abi.call({ 18 | abi: "function vaultInfo(address vault) external view returns (tuple( uint128 conjureLimit , uint128 totalConjured))", 19 | target: chainContracts.scroll.issued, 20 | params: ["0x3bdfe67009FEbf4bc65378F1C07E7FfEF5339407"], 21 | block: _ethBlock, 22 | chain: "scroll", 23 | }) 24 | ).output; 25 | return { peggedUSD: totalSupply[1] / 10 ** 18 }; 26 | }; 27 | } 28 | 29 | const adapter: PeggedIssuanceAdapter = { 30 | scroll: { 31 | minted: scrollMinted(), 32 | }, 33 | }; 34 | 35 | export default adapter; 36 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/ckusdc/index.ts: -------------------------------------------------------------------------------- 1 | const axios = require("axios"); 2 | import { 3 | PeggedIssuanceAdapter, 4 | Balances, 5 | } from "../peggedAsset.type"; 6 | 7 | async function fetchEthereumTotalSupply(): Promise { 8 | let balances = {} as Balances; 9 | try { 10 | const url = 'https://xevnm-gaaaa-aaaar-qafnq-cai.raw.icp0.io/metrics'; 11 | const response = await axios.get(url, { responseType: 'text' }); 12 | const totalSupplyMatch = response.data.match(/ledger_total_supply\s+(\d+)/); 13 | if (!totalSupplyMatch) { 14 | throw new Error('Failed to extract ledger_total_supply from the API response'); 15 | } 16 | 17 | const totalSupply = Number(totalSupplyMatch[1]); 18 | 19 | if (!isNaN(totalSupply)) { 20 | balances["peggedUSD"] = totalSupply / 1e6; // convert to correct unit 21 | } else { 22 | console.error("Error converting ledger total supply to a number:", totalSupplyMatch[1]); 23 | } 24 | } catch (error) { 25 | console.error("Error fetching Ethereum total supply:", error); 26 | } 27 | return balances; 28 | } 29 | 30 | const adapter: PeggedIssuanceAdapter = { 31 | ethereum: { 32 | minted: fetchEthereumTotalSupply, 33 | }, 34 | }; 35 | 36 | export default adapter; 37 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/classic-usd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereumclassic: { 3 | issued: ["0xDE093684c796204224BC081f937aa059D903c52a"], 4 | pegType: 'peggedUSD', 5 | }, 6 | polygon: { 7 | issued: ["0x131409b31bf446737dd04353d43dacada544b6fa"], 8 | pegType: 'peggedUSD', 9 | } 10 | }; 11 | 12 | import { addChainExports } from "../helper/getSupply"; 13 | const adapter = addChainExports(chainContracts); 14 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/clever-usd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x3c20ac688410be8f391be1fb00afc5c212972f86"], 4 | }, 5 | }; 6 | 7 | 8 | import { addChainExports } from "../helper/getSupply"; 9 | const adapter = addChainExports(chainContracts); 10 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/coinshift-usdl-morpho-vault/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0xbEeFc011e94f43b8B7b455eBaB290C7Ab4E216f1"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/colb-usd-stablecolb/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | polygon: { 3 | issued: ["0x72C96C73207936E94066b4C8566C6987c9a1f1dE"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/collateralized-debt-token/index.ts: -------------------------------------------------------------------------------- 1 | import { sumSingleBalance } from "../helper/generalUtil"; 2 | import { 3 | Balances, 4 | ChainBlocks, 5 | PeggedIssuanceAdapter, ChainContracts, 6 | } from "../peggedAsset.type"; 7 | const axios = require("axios"); 8 | const retry = require("async-retry"); 9 | 10 | // There appears to be no explorer API that can give total supply; this endpoint was provided by dev. 11 | async function osmosisMinted(decimals: number) { 12 | return async function ( 13 | _timestamp: number, 14 | _ethBlock: number, 15 | _chainBlocks: ChainBlocks 16 | ) { 17 | let balances = {} as Balances; 18 | const res = await retry( 19 | async (_bail: any) => 20 | await axios.get( 21 | "https://lcd.osmosis.zone/osmosis/superfluid/v1beta1/supply?denom=factory/osmo1s794h9rxggytja3a4pmwul53u98k06zy2qtrdvjnfuxruh7s8yjs6cyxgd/ucdt" 22 | ) 23 | ); 24 | const cdtInfo = res?.data?.amount; 25 | const supply = cdtInfo?.amount / 10 ** decimals; 26 | sumSingleBalance(balances, "peggedVAR", supply, "issued", false); 27 | return balances; 28 | }; 29 | } 30 | 31 | const adapter: PeggedIssuanceAdapter = { 32 | osmosis: { 33 | minted: osmosisMinted(6), 34 | }, 35 | }; 36 | 37 | export default adapter; 38 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/composite/index.ts: -------------------------------------------------------------------------------- 1 | import { sumSingleBalance } from "../helper/generalUtil"; 2 | import { osmosisSupply } from "../helper/getSupply"; 3 | import { 4 | ChainBlocks, 5 | PeggedIssuanceAdapter, 6 | Balances, ChainContracts, 7 | } from "../peggedAsset.type"; 8 | const axios = require("axios"); 9 | const retry = require("async-retry"); 10 | 11 | 12 | const chainContracts: ChainContracts = { 13 | osmosis: { 14 | bridgedFromComdex: [ 15 | "ibc/23CA6C8D1AB2145DD13EB1E089A2E3F960DC298B468CCE034E19E5A78B61136E", 16 | ], 17 | }, 18 | }; 19 | 20 | async function compositeMinted(decimals: number) { 21 | return async function ( 22 | _timestamp: number, 23 | _ethBlock: number, 24 | _chainBlocks: ChainBlocks 25 | ) { 26 | let balances = {} as Balances; 27 | const res = await retry( 28 | async (_bail: any) => 29 | await axios.get( 30 | "https://rest.comdex.one/cosmos/bank/v1beta1/supply/ucmst" 31 | ) 32 | ); 33 | 34 | const supply = res?.data?.amount?.amount / 10 ** decimals; 35 | sumSingleBalance(balances, "peggedUSD", supply, "issued", false); 36 | return balances; 37 | }; 38 | } 39 | 40 | const adapter: PeggedIssuanceAdapter = { 41 | comdex: { 42 | minted: compositeMinted(6), 43 | }, 44 | osmosis: { 45 | comdex: osmosisSupply( 46 | chainContracts.osmosis.bridgedFromComdex, 47 | 6, 48 | "Comdex" 49 | ), 50 | }, 51 | }; 52 | 53 | export default adapter; 54 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/convertible-jpy-token/index.ts: -------------------------------------------------------------------------------- 1 | 2 | const chainContracts = { 3 | ethereum: { 4 | issued: ["0x1cfa5641c01406ab8ac350ded7d735ec41298372"], pegType: 'peggedJPY' 5 | }, 6 | }; 7 | 8 | import { addChainExports } from "../helper/getSupply"; 9 | const adapter = addChainExports(chainContracts, undefined, { pegType: 'peggedJPY' }); 10 | export default adapter -------------------------------------------------------------------------------- /src/adapters/peggedAssets/cygnus-finance-global-usd/index.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | const chainContracts = { 4 | base: { 5 | issued: "0xCa72827a3D211CfD8F6b00Ac98824872b72CAb49", 6 | }, 7 | }; 8 | 9 | import { addChainExports } from "../helper/getSupply"; 10 | const adapter = addChainExports(chainContracts); 11 | export default adapter -------------------------------------------------------------------------------- /src/adapters/peggedAssets/czusd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | bsc: { 3 | issued: "0xE68b79e51bf826534Ff37AA9CeE71a3842ee9c70", 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter -------------------------------------------------------------------------------- /src/adapters/peggedAssets/dackie-usd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | base: { 3 | issued: "0x613ce28076289DE255f1a6487437F03E37E4a71d", 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/dam-finance/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x2FdA8c6783Aa36BeD645baD28a4cDC8769dCD252"], 4 | }, 5 | moonbeam: { 6 | issued: ["0xc806B0600cbAfA0B197562a9F7e3B9856866E9bF"], 7 | }, 8 | }; 9 | 10 | 11 | import { addChainExports } from "../helper/getSupply"; 12 | const adapter = addChainExports(chainContracts); 13 | export default adapter -------------------------------------------------------------------------------- /src/adapters/peggedAssets/davos-protocol/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | polygon: { 3 | issued: ["0xec38621e72d86775a89c7422746de1f52bba5320"], 4 | }, 5 | ethereum: { 6 | issued: ["0xa48F322F8b3edff967629Af79E027628b9Dd1298"], 7 | }, 8 | arbitrum: { 9 | issued: ["0x8ec1877698acf262fe8ad8a295ad94d6ea258988"], 10 | }, 11 | optimism: { 12 | issued: ["0xb396b31599333739a97951b74652c117be86ee1d"], 13 | }, 14 | bsc: { 15 | issued: ["0x8ec1877698acf262fe8ad8a295ad94d6ea258988"], 16 | }, 17 | }; 18 | 19 | import { addChainExports } from "../helper/getSupply"; 20 | const adapter = addChainExports(chainContracts); 21 | export default adapter 22 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/defi-franc/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: "0x045da4bFe02B320f4403674B3b7d121737727A36", pegType: 'peggedVAR' 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts, undefined, { pegType: 'peggedVAR' }); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/dexfinance-usdex/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | arbitrum: { 3 | issued: ["0x4117ec0a779448872d3820f37ba2060ae0b7c34b"], 4 | }, 5 | manta: { 6 | issued: ["0x6Da9EbD271a0676F39C088a2b5fd849D5080c0af"], 7 | }, 8 | }; 9 | 10 | import { addChainExports } from "../helper/getSupply"; 11 | const adapter = addChainExports(chainContracts); 12 | export default adapter; 13 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/digitaldollar/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | arbitrum: { 3 | issued: ["0xF0B5cEeFc89684889e5F7e0A7775Bd100FcD3709"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; 10 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/djed/index.ts: -------------------------------------------------------------------------------- 1 | import { 2 | PeggedIssuanceAdapter, 3 | Balances, 4 | } from "../peggedAsset.type"; 5 | import { sumSingleBalance } from "../helper/generalUtil"; 6 | import { getTotalSupply, getTokenBalance } from "../helper/cardano"; 7 | 8 | const assetIDs = { 9 | cardano: { 10 | issued: [ 11 | "8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd61446a65644d6963726f555344", 12 | ], 13 | }, 14 | }; 15 | 16 | async function getCardanoSupply() { 17 | let balances = {} as Balances; 18 | let supply = await getTotalSupply(assetIDs.cardano.issued[0]); 19 | const lockedBalance = 20 | (await getTokenBalance( 21 | "8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd61446a65644d6963726f555344", 22 | "addr1z8mcpc26j64fmhhd6sv5qj5mk9xqnfxgm6k8zmk7h2rlu4qm5kjdmrpmng059yellupyvwgay2v0lz6663swmds7hp0qhxg9gt" 23 | // before "addr1zx82ru5f7p8ewhhdvahueg2s4gxs3gxl66fkygdekkjs74sm5kjdmrpmng059yellupyvwgay2v0lz6663swmds7hp0q4vpw0l" 24 | )) / 1e6; 25 | supply -= lockedBalance; 26 | sumSingleBalance(balances, "peggedUSD", supply, "issued", false); 27 | 28 | return balances; 29 | } 30 | 31 | const adapter: PeggedIssuanceAdapter = { 32 | cardano: { 33 | minted: getCardanoSupply, 34 | }, 35 | }; 36 | 37 | export default adapter; 38 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/doc/index.ts: -------------------------------------------------------------------------------- 1 | const sdk = require("@defillama/sdk"); 2 | import { sumSingleBalance } from "../helper/generalUtil"; 3 | import { bridgedSupply } from "../helper/getSupply"; 4 | import { 5 | ChainBlocks, 6 | PeggedIssuanceAdapter, 7 | Balances, ChainContracts, 8 | } from "../peggedAsset.type"; 9 | 10 | 11 | const chainContracts: ChainContracts = { 12 | rsk: { 13 | issued: ["0xe700691dA7b9851F2F35f8b8182c69c53CcaD9Db"], 14 | }, 15 | ethereum: { 16 | bridgedFromRSK: ["0x69f6d4d4813f8e2e618dae7572e04b6d5329e207"], 17 | }, 18 | }; 19 | 20 | async function chainMinted(chain: string, decimals: number) { 21 | return async function ( 22 | _timestamp: number, 23 | _ethBlock: number, 24 | _chainBlocks: ChainBlocks 25 | ) { 26 | let balances = {} as Balances; 27 | for (let issued of chainContracts[chain].issued) { 28 | const totalSupply = ( 29 | await sdk.api.abi.call({ 30 | abi: "erc20:totalSupply", 31 | target: issued, 32 | block: _chainBlocks?.[chain], 33 | chain: chain, 34 | }) 35 | ).output; 36 | sumSingleBalance( 37 | balances, 38 | "peggedUSD", 39 | totalSupply / 10 ** decimals, 40 | "issued", 41 | false 42 | ); 43 | } 44 | return balances; 45 | }; 46 | } 47 | 48 | const adapter: PeggedIssuanceAdapter = { 49 | rsk: { 50 | minted: chainMinted("rsk", 18), 51 | }, 52 | ethereum: { 53 | rsk: bridgedSupply("ethereum", 18, chainContracts.ethereum.bridgedFromRSK), 54 | }, 55 | }; 56 | 57 | export default adapter; 58 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/dola-usd/index.ts: -------------------------------------------------------------------------------- 1 | import { addChainExports } from "../helper/getSupply"; 2 | import { 3 | PeggedIssuanceAdapter, ChainContracts, 4 | } from "../peggedAsset.type"; 5 | 6 | const chainContracts = { 7 | ethereum: { 8 | issued: "0x865377367054516e17014CcdED1e7d814EDC9ce4", 9 | }, 10 | fantom: { 11 | bridgedFromETH: "0x3129662808bEC728a27Ab6a6b9AFd3cBacA8A43c", // multichain 12 | }, 13 | optimism: { 14 | bridgedFromETH: "0x8aE125E8653821E851F12A49F7765db9a9ce7384", 15 | }, 16 | bsc: { 17 | bridgedFromETH: "0x2f29bc0ffaf9bff337b31cbe6cb5fb3bf12e5840", 18 | }, 19 | arbitrum: { 20 | bridgedFromETH: "0x6a7661795c374c0bfc635934efaddff3a7ee23b6", 21 | }, 22 | polygon: { 23 | bridgedFromETH: "0xbc2b48bc930ddc4e5cfb2e87a45c379aab3aac5c", 24 | }, 25 | avax: { 26 | bridgedFromETH: "0x221743dc9e954be4f86844649bf19b43d6f8366d", 27 | }, 28 | base: { 29 | bridgedFromETH: "0x4621b7A9c75199271F773Ebd9A499dbd165c3191", 30 | }, 31 | }; 32 | 33 | const adapter: PeggedIssuanceAdapter = addChainExports(chainContracts); 34 | 35 | export default adapter; 36 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/dtrinity-usd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | fraxtal: { 3 | issued: "0x788D96f655735f52c676A133f4dFC53cEC614d4A", 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; 10 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/dyad/index.ts: -------------------------------------------------------------------------------- 1 | import { addChainExports } from "../helper/getSupply"; 2 | import { 3 | PeggedIssuanceAdapter, ChainContracts, 4 | } from "../peggedAsset.type"; 5 | 6 | const chainContracts = { 7 | ethereum: { 8 | issued: "0xFd03723a9A3AbE0562451496a9a394D2C4bad4ab", 9 | }, 10 | }; 11 | 12 | const adapter: PeggedIssuanceAdapter = addChainExports(chainContracts); 13 | 14 | export default adapter; 15 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/electronic-usd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0xA0d69E286B938e21CBf7E51D71F6A4c8918f482F"], 4 | }, 5 | base: { 6 | bridgedFromETH: ["0xCfA3Ef56d303AE4fAabA0592388F19d7C3399FB4"], 7 | }, 8 | arbitrum: { 9 | bridgedFromETH: ["0x12275DCB9048680c4Be40942eA4D92c74C63b844"], 10 | }, 11 | }; 12 | 13 | 14 | import { addChainExports } from "../helper/getSupply"; 15 | const adapter = addChainExports(chainContracts); 16 | export default adapter; 17 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/elixir-deusd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x15700B564Ca08D9439C58cA5053166E8317aa138"], 4 | }, 5 | sei: { 6 | bridgedFromETH: ["0x37a4dd9ced2b19cfe8fac251cd727b5787e45269"] 7 | }, 8 | avax: { 9 | bridgedFromETH: ["0xB57B25851fE2311CC3fE511c8F10E868932e0680"] 10 | }, 11 | polygon: { 12 | bridgedFromETH: ["0xB57B25851fE2311CC3fE511c8F10E868932e0680"] 13 | } 14 | }; 15 | 16 | import { addChainExports } from "../helper/getSupply"; 17 | const adapter = addChainExports(chainContracts); 18 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/ethos-reserve-note/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | optimism: { 3 | issued: ["0xc5b001dc33727f8f26880b184090d3e252470d45"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/euro3/index.ts: -------------------------------------------------------------------------------- 1 | const pegType = "peggedEUR"; 2 | const chainContracts = { 3 | polygon: { 4 | issued: "0xA0e4c84693266a9d3BBef2f394B33712c76599Ab", pegType 5 | }, 6 | linea: { 7 | issued: "0x3f817b28da4940f018c6b5c0a11c555ebb1264f9", pegType 8 | }, 9 | }; 10 | 11 | import { addChainExports } from "../helper/getSupply"; 12 | const adapter = addChainExports(chainContracts, undefined, { pegType }); 13 | export default adapter; 14 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/euroe-stablecoin/index.ts: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | import { sumSingleBalance } from "../helper/generalUtil"; 3 | import { 4 | ChainBlocks, 5 | Balances, ChainContracts, 6 | } from "../peggedAsset.type"; 7 | 8 | 9 | const chainContracts: ChainContracts = { 10 | ethereum: { 11 | issued: ["0x820802Fa8a99901F52e39acD21177b0BE6EE2974"], 12 | }, 13 | polygon: { 14 | issued: ["0x820802Fa8a99901F52e39acD21177b0BE6EE2974"], 15 | }, 16 | arbitrum: { 17 | issued: ["0xcF985abA4647a432E60efcEeB8054BBd64244305"], 18 | }, 19 | avax: { 20 | issued: ["0x820802Fa8a99901F52e39acD21177b0BE6EE2974"], 21 | }, 22 | solana: { 23 | issued: ["2VhjJ9WxaGC3EZFwJG9BDUs9KxKCAjQY4vgd1qxgYWVg"], 24 | }, 25 | optimism: { 26 | issued: ["0x820802Fa8a99901F52e39acD21177b0BE6EE2974"], 27 | }, 28 | }; 29 | 30 | 31 | import { addChainExports } from "../helper/getSupply"; 32 | const adapter = addChainExports(chainContracts, undefined, { 33 | pegType: 'peggedEUR' 34 | }); 35 | 36 | async function concordiumMinted() { 37 | let balances = {} as Balances; 38 | const { data: res } = await axios("https://www.euroe.com/api/totalsupply/CCD"); 39 | sumSingleBalance(balances, "peggedEUR", Number(res.toFixed(2)), 'euroe', true); 40 | return balances; 41 | } 42 | 43 | adapter.concordium = { minted: concordiumMinted, } 44 | 45 | export default adapter; 46 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/eusd/index.ts: -------------------------------------------------------------------------------- 1 | 2 | const chainContracts = { 3 | ethereum: { 4 | issued: ["0x97de57eC338AB5d51557DA3434828C5DbFaDA371"], 5 | }, 6 | }; 7 | 8 | import { addChainExports } from "../helper/getSupply"; 9 | const adapter = addChainExports(chainContracts); 10 | export default adapter; 11 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/eusdv2/index.ts: -------------------------------------------------------------------------------- 1 | 2 | const chainContracts = { 3 | ethereum: { 4 | issued: ["0xdf3ac4f479375802a821f7b7b46cd7eb5e4262cc"], 5 | }, 6 | }; 7 | 8 | import { addChainExports } from "../helper/getSupply"; 9 | const adapter = addChainExports(chainContracts); 10 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/f-x-btc-usd/index.ts: -------------------------------------------------------------------------------- 1 | 2 | const chainContracts = { 3 | ethereum: { 4 | issued: [ 5 | "0x9D11ab23d33aD026C466CE3c124928fDb69Ba20E", 6 | "0x576b4779727F5998577bb4e25bf726abE742b9F7", 7 | ], 8 | }, 9 | }; 10 | 11 | import { addChainExports } from "../helper/getSupply"; 12 | const adapter = addChainExports(chainContracts); 13 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/falcon-finance/index.ts: -------------------------------------------------------------------------------- 1 | import { addChainExports } from "../helper/getSupply"; 2 | import { PeggedIssuanceAdapter } from "../peggedAsset.type"; 3 | 4 | const chainContracts = { 5 | ethereum: { 6 | issued: ["0xFa2B947eEc368f42195f24F36d2aF29f7c24CeC2"], 7 | }, 8 | }; 9 | 10 | const adapter: PeggedIssuanceAdapter = { 11 | ...addChainExports(chainContracts), 12 | }; 13 | 14 | export default adapter; 15 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/fantom-usd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | fantom: { 3 | issued: ["0xad84341756bf337f5a0164515b1f6f993d194e1f"], 4 | unreleased: [ 5 | // the fUSD situation is not very transparent. the following 2 are the largest holders of fUSD. 6 | // some discussion on the 0x431e8 wallet can be found - https://twitter.com/bantg/status/1453322161540718594 7 | "0x431e81e5dfb5a24541b5ff8762bdef3f32f96354", // alleged fantom foundation EOA, could be Andre Cronje or yearn x abracadra 8 | "0x9c8aef3a8792094aede3cd67f52296e21c801b81", // could be foundation gnosis safe. rather inactive 9 | ], 10 | }, 11 | }; 12 | 13 | import { addChainExports } from "../helper/getSupply"; 14 | const adapter = addChainExports(chainContracts); 15 | export default adapter; 16 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/fathom-dollar/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | xdc: { 3 | issued: ["0x49d3f7543335cf38Fa10889CCFF10207e22110B5"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/fei-usd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x956F47F50A910163D8BF957Cf5846D573E7f87CA"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/felix-feusd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | hyperliquid: { 3 | issued: ["0x02c6a2fA58cC01A18B8D9E00eA48d65E4dF26c70"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/feth/index.ts: -------------------------------------------------------------------------------- 1 | 2 | const chainContracts = { 3 | ethereum: { 4 | issued: ["0x53805A76E1f5ebbFE7115F16f9c87C2f7e633726"], pegType: 'peggedVAR' 5 | }, 6 | }; 7 | 8 | import { addChainExports } from "../helper/getSupply"; 9 | const adapter = addChainExports(chainContracts, undefined, { pegType: 'peggedVAR' }); 10 | export default adapter; 11 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/fixed-income-asset-token/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x586aa273f262909eef8fa02d90ab65f5015e0516"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; 10 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/flex-usd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0xa774ffb4af6b0a91331c084e1aebae6ad535e6f3"], 4 | }, 5 | smartbch: { 6 | issued: ["0x7b2b3c5308ab5b2a1d9a94d20d35ccdf61e05b72"], 7 | }, 8 | }; 9 | 10 | import { addChainExports } from "../helper/getSupply"; 11 | const adapter = addChainExports(chainContracts); 12 | export default adapter; 13 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/float-protocol-float/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0xb05097849bca421a3f51b249ba6cca4af4b97cb9"], pegType: 'peggedVAR' 4 | }, 5 | } 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/franklin-onchain-u-s-government-money-fund/index.ts: -------------------------------------------------------------------------------- 1 | import { addChainExports } from "../helper/getSupply"; 2 | import { sumSingleBalance } from "../helper/generalUtil"; 3 | import { 4 | Balances, 5 | ChainBlocks, 6 | PeggedIssuanceAdapter, ChainContracts, 7 | } from "../peggedAsset.type"; 8 | import { getTotalSupply as stellarGetTotalSupply } from "../helper/stellar"; 9 | 10 | const chainContracts: ChainContracts = { 11 | polygon: { 12 | issued: ["0x408a634b8a8f0de729b48574a3a7ec3fe820b00a"], 13 | }, 14 | arbitrum: { 15 | issued: ["0xb9e4765bce2609bc1949592059b17ea72fee6c6a"], 16 | }, 17 | base: { 18 | issued: ["0x60cfc2b186a4cf647486e42c42b11cc6d571d1e4"], 19 | }, 20 | avax: { 21 | issued: ["0xe08b4c1005603427420e64252a8b120cace4d122"] 22 | } 23 | } 24 | 25 | async function stellarMinted(assetID: string) { 26 | return async function ( 27 | _timestamp: number, 28 | _ethBlock: number, 29 | _chainBlocks: ChainBlocks 30 | ) { 31 | let balances = {} as Balances; 32 | const totalSupply = await stellarGetTotalSupply(assetID); 33 | sumSingleBalance(balances, "peggedUSD", totalSupply, "issued", false); 34 | return balances; 35 | }; 36 | } 37 | 38 | const adapter: PeggedIssuanceAdapter = { 39 | ...addChainExports(chainContracts), 40 | stellar: { 41 | minted: stellarMinted("BENJI-GBHNGLLIE3KWGKCHIKMHJ5HVZHYIK7WTBE4QF5PLAKL4CJGSEU7HZIW5"), 42 | }, 43 | }; 44 | 45 | export default adapter; 46 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/frax-price-index/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x5ca135cb8527d76e932f34b5145575f9d8cbe08e"], pegType: 'peggedVAR' 4 | }, 5 | era: { 6 | issued: ["0xD405617DB7473b0A3158356Be7bC9EbEc6D88b85"], pegType: 'peggedVAR' 7 | }, 8 | }; 9 | 10 | import { addChainExports } from "../helper/getSupply"; 11 | const adapter = addChainExports(chainContracts); 12 | export default adapter; 13 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/fx-rusd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: [ 4 | "0x65D72AA8DA931F047169112fcf34f52DbaAE7D18", 5 | "0x9216272158F563488FfC36AFB877acA2F265C560", 6 | "0x50B4DC15b34E31671c9cA40F9eb05D7eBd6b13f9", 7 | ], 8 | }, 9 | }; 10 | 11 | import { addChainExports } from "../helper/getSupply"; 12 | const adapter = addChainExports(chainContracts); 13 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/fxusd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: [ 4 | "0x085780639CC2cACd35E474e71f4d000e2405d8f6", 5 | "0xD6B8162e2fb9F3EFf09bb8598ca0C8958E33A23D", 6 | "0xa87F04c9743Fd1933F82bdDec9692e9D97673769", 7 | ], 8 | }, 9 | }; 10 | 11 | import { addChainExports } from "../helper/getSupply"; 12 | const adapter = addChainExports(chainContracts); 13 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/gai-stablecoin/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | manta: { 3 | issued: ["0xcd91716ef98798A85E79048B78287B13ae6b99b2"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/gemini-dollar/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x056fd409e1d7a124bd7017459dfea2f387b6d5cd"], 4 | }, 5 | wan: { 6 | bridgedFromETH: ["0xcF422327dDaAa409C2976d01131d8a3457F03251"], 7 | }, 8 | }; 9 | 10 | 11 | import { addChainExports } from "../helper/getSupply"; 12 | const adapter = addChainExports(chainContracts); 13 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/gho/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x40D16FC0246aD3160Ccc09B8D0D3A2cD28aE6C2f"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/glo-dollar/index.ts: -------------------------------------------------------------------------------- 1 | import { addChainExports } from "../helper/getSupply"; 2 | import { sumSingleBalance } from "../helper/generalUtil"; 3 | import { 4 | Balances, 5 | ChainBlocks, 6 | PeggedIssuanceAdapter, ChainContracts, 7 | } from "../peggedAsset.type"; 8 | import { getTotalSupply as stellarGetTotalSupply } from "../helper/stellar"; 9 | 10 | const chainContracts: ChainContracts = { 11 | ethereum: { 12 | issued: ["0x4F604735c1cF31399C6E711D5962b2B3E0225AD3"], 13 | }, 14 | polygon: { 15 | issued: ["0x4F604735c1cF31399C6E711D5962b2B3E0225AD3"], 16 | }, 17 | optimism: { 18 | issued: ["0x4F604735c1cF31399C6E711D5962b2B3E0225AD3"], 19 | }, 20 | celo: { 21 | issued: ["0x4F604735c1cF31399C6E711D5962b2B3E0225AD3"], 22 | }, 23 | arbitrum: { 24 | issued: ["0x4F604735c1cF31399C6E711D5962b2B3E0225AD3"], 25 | }, 26 | base: { 27 | issued: ["0x4F604735c1cF31399C6E711D5962b2B3E0225AD3"], 28 | }, 29 | vechain: { 30 | issued: ["0x29c630cce4ddb23900f5fe66ab55e488c15b9f5e"] 31 | } 32 | } 33 | 34 | async function stellarMinted(assetID: string) { 35 | return async function ( 36 | _timestamp: number, 37 | _ethBlock: number, 38 | _chainBlocks: ChainBlocks 39 | ) { 40 | let balances = {} as Balances; 41 | const totalSupply = await stellarGetTotalSupply(assetID); 42 | sumSingleBalance(balances, "peggedUSD", totalSupply, "issued", false); 43 | return balances; 44 | }; 45 | } 46 | 47 | const adapter: PeggedIssuanceAdapter = { 48 | ...addChainExports(chainContracts), 49 | stellar: { 50 | minted: stellarMinted("USDGLO:GBBS25EGYQPGEZCGCFBKG4OAGFXU6DSOQBGTHELLJT3HZXZJ34HWS6XV"), 51 | }, 52 | }; 53 | 54 | export default adapter; 55 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/grai/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x15f74458aE0bFdAA1a96CA1aa779D715Cc1Eefe4"], 4 | }, 5 | optimism: { 6 | issued: ["0x894134a25a5faC1c2C26F1d8fBf05111a3CB9487"], 7 | }, 8 | arbitrum: { 9 | issued: ["0x894134a25a5faC1c2C26F1d8fBf05111a3CB9487"], 10 | }, 11 | era: { 12 | issued: ["0x5FC44E95eaa48F9eB84Be17bd3aC66B6A82Af709"], 13 | }, 14 | polygon_zkevm: { 15 | issued: ["0xCA68ad4EE5c96871EC6C6dac2F714a8437A3Fe66"], 16 | }, 17 | mantle: { 18 | issued: ["0x894134a25a5faC1c2C26F1d8fBf05111a3CB9487"], 19 | }, 20 | linea: { 21 | issued: ["0x894134a25a5faC1c2C26F1d8fBf05111a3CB9487"], 22 | }, 23 | }; 24 | 25 | import { addChainExports } from "../helper/getSupply"; 26 | const adapter = addChainExports(chainContracts); 27 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/gyroscope-gyd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0xe07f9d810a48ab5c3c914ba3ca53af14e4491e8a"], 4 | }, 5 | polygon: { 6 | issued: ["0x37b8E1152fB90A867F3dccA6e8d537681B04705E"] 7 | } 8 | } 9 | 10 | import { addChainExports } from "../helper/getSupply"; 11 | const adapter = addChainExports(chainContracts); 12 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/hashnote-usyc/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x136471a34f6ef19fe571effc1ca711fdb8e49f2b"], 4 | }, 5 | }; 6 | 7 | // the USYC listing is flagged as doublecounted: true since 97% of it's supply sits in the Usual USD0 treasury: https://etherscan.io/address/0xdd82875f0840aad58a455a70b88eed9f59cec7c7 with a tiny amount also held in zoth zeusd 8 | 9 | import { addChainExports } from "../helper/getSupply"; 10 | const adapter = addChainExports(chainContracts); 11 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/hedera-swiss-franc/index.ts: -------------------------------------------------------------------------------- 1 | const axios = require("axios"); 2 | const retry = require("async-retry"); 3 | import { 4 | Balances, 5 | ChainBlocks, 6 | PeggedIssuanceAdapter, 7 | } from "../peggedAsset.type"; 8 | 9 | async function hederaMinted() { 10 | return async function ( 11 | _timestamp: number, 12 | _ethBlock: number, 13 | _chainBlocks: ChainBlocks 14 | ) { 15 | const issuance = await retry( 16 | async (_bail: any) => 17 | await axios.get( 18 | "https://mainnet-public.mirrornode.hedera.com/api/v1/tokens/0.0.6070123" 19 | ) 20 | ); 21 | const supply = issuance?.data?.total_supply; 22 | let balance = supply / 10 ** 8; 23 | return { peggedCHF: balance }; 24 | }; 25 | } 26 | 27 | 28 | const adapter: PeggedIssuanceAdapter = { 29 | hedera: { 30 | minted: hederaMinted(), 31 | unreleased: async () => ({}), 32 | }, 33 | }; 34 | 35 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/hedge-usd/index.ts: -------------------------------------------------------------------------------- 1 | import { PeggedIssuanceAdapter } from "../peggedAsset.type"; 2 | import { solanaMintedOrBridged } from "../helper/getSupply"; 3 | 4 | const adapter: PeggedIssuanceAdapter = { 5 | solana: { 6 | minted: solanaMintedOrBridged([ 7 | "9iLH8T7zoWhY7sBmj1WK9ENbWdS1nL8n9wAxaeRitTa6", 8 | ]), 9 | }, 10 | }; 11 | 12 | export default adapter; 13 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/helio-protocol-hay/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | bsc: { 3 | issued: "0x0782b6d8c4551B9760e74c0545a9bCD90bdc41E5", 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/helper/algorand.js: -------------------------------------------------------------------------------- 1 | // documentation: https://developer.algorand.org/docs/get-details/indexer/?from_query=curl#sdk-client-instantiations 2 | 3 | const axios = require('axios') 4 | const { getApplicationAddress } = require('./algorandUtils/address') 5 | const { RateLimiter } = require("limiter"); 6 | 7 | const axiosObj = axios.create({ 8 | baseURL: 'https://mainnet-idx.algonode.cloud', 9 | timeout: 300000, 10 | }) 11 | 12 | const indexerLimiter = new RateLimiter({ tokensPerInterval: 10, interval: "second" }); 13 | 14 | async function lookupApplications(appId) { 15 | return (await axiosObj.get(`/v2/applications/${appId}`)).data 16 | } 17 | 18 | async function lookupAccountByID(appId) { 19 | return (await axiosObj.get(`/v2/accounts/${appId}`)).data 20 | } 21 | 22 | async function searchAccounts({ appId, limit = 1000, nexttoken, }) { 23 | const response = (await axiosObj.get('/v2/accounts', { 24 | params: { 25 | 'application-id': appId, 26 | limit, 27 | next: nexttoken 28 | } 29 | })) 30 | return response.data 31 | } 32 | 33 | const withLimiter = (fn, tokensToRemove = 1) => async (...args) => { 34 | await indexerLimiter.removeTokens(tokensToRemove); 35 | return fn(...args); 36 | } 37 | 38 | module.exports = { 39 | getApplicationAddress, 40 | lookupApplications: withLimiter(lookupApplications), 41 | lookupAccountByID: withLimiter(lookupAccountByID), 42 | searchAccounts: withLimiter(searchAccounts), 43 | } 44 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/helper/getBlock.js: -------------------------------------------------------------------------------- 1 | const sdk = require("@defillama/sdk"); 2 | const retry = require("async-retry"); 3 | const axios = require("axios"); 4 | 5 | async function getBlock(timestamp, chain, chainBlocks, undefinedOk = false) { 6 | if ( 7 | chainBlocks?.[chain] !== undefined || 8 | (process.env.HISTORICAL === undefined && undefinedOk) 9 | ) { 10 | return chainBlocks[chain]; 11 | } else { 12 | if (chain === "celo") { 13 | return Number( 14 | ( 15 | await retry( 16 | async (bail) => 17 | await axios.get( 18 | "https://explorer.celo.org/api?module=block&action=getblocknobytime×tamp=" + 19 | timestamp + 20 | "&closest=before" 21 | ) 22 | ) 23 | ).data.result.blockNumber 24 | ); 25 | } 26 | return sdk.api.util 27 | .lookupBlock(timestamp, { chain }) 28 | .then((blockData) => blockData.block); 29 | } 30 | } 31 | 32 | module.exports = { 33 | getBlock, 34 | }; 35 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/helper/getTimestampAtStartOfHour.ts: -------------------------------------------------------------------------------- 1 | export const getTimestampAtStartOfHour = (timestamp = Date.now() / 1000) => { 2 | const date = new Date(timestamp * 1000); 3 | var date_utc = Date.UTC( 4 | date.getUTCFullYear(), 5 | date.getUTCMonth(), 6 | date.getUTCDate(), 7 | date.getUTCHours(), 8 | date.getUTCMinutes(), 9 | date.getUTCSeconds() 10 | ); 11 | var startOfDay = Number(new Date(date_utc)); 12 | var timestamp = startOfDay / 1000; 13 | return Math.floor(timestamp / 3600) * 3600; 14 | }; 15 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/helper/http.js: -------------------------------------------------------------------------------- 1 | const retryModule = require('async-retry') 2 | 3 | async function retry(func){ 4 | return retryModule(func, { 5 | retries:3 6 | }) 7 | } 8 | 9 | const axios = require("axios") 10 | const COVALENT_KEY = 'ckey_72cd3b74b4a048c9bc671f7c5a6' 11 | 12 | async function get(endpoint) { 13 | return (await retry(async _ => await axios.get(endpoint))).data 14 | } 15 | 16 | async function post(endpoint, body) { 17 | return (await axios.post(endpoint, body)).data 18 | } 19 | 20 | 21 | async function covalentGetTokens(address, chain = 'ethereum') { 22 | let chainId 23 | switch(chain) { 24 | case 'ethereum': chainId = 1; break; 25 | default: throw new Error('Missing chain to chain id mapping!!!') 26 | } 27 | const { 28 | data: { items } 29 | } = await get(`https://api.covalenthq.com/v1/${chainId}/address/${address}/balances_v2/?&key=${COVALENT_KEY}`) 30 | return items 31 | } 32 | 33 | module.exports = { 34 | get, 35 | post, 36 | covalentGetTokens, 37 | } -------------------------------------------------------------------------------- /src/adapters/peggedAssets/helper/kava.ts: -------------------------------------------------------------------------------- 1 | const sdk = require('@defillama/sdk') 2 | 3 | export async function getTotalSupply(address: string) { 4 | const api = new sdk.ChainApi({ chain: 'kava' }) 5 | const supply = await api.call({ abi: 'erc20:totalSupply', target: address}) 6 | const decimals = await api.call({ abi: 'erc20:decimals', target: address}) 7 | return supply / 10 ** decimals; 8 | } 9 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/helper/mixin.ts: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | const retry = require("async-retry"); 3 | import { Balances, ChainBlocks } from "../peggedAsset.type"; 4 | import { sumSingleBalance } from "./generalUtil"; 5 | 6 | const fetchMixinSupply = async (assetId: string) => { 7 | const res = await retry( 8 | async (_bail: any) => 9 | await axios.get(`https://api.mixin.one/network/assets/${assetId}`) 10 | ); 11 | return +res.data.data.amount; 12 | }; 13 | 14 | export const mixinSupply = async ( 15 | assetIds: string[], 16 | bridgedFromChain: string 17 | ) => { 18 | return async function ( 19 | _timestamp: number, 20 | _ethBlock: number, 21 | _chainBlocks: ChainBlocks 22 | ) { 23 | let balances = {} as Balances; 24 | 25 | for (let assetId of assetIds) { 26 | const supply = await fetchMixinSupply(assetId); 27 | console.info(`mixin success ${assetId} supply: ${supply}`); 28 | sumSingleBalance( 29 | balances, 30 | "peggedUSD", 31 | supply, 32 | assetId, 33 | false, 34 | bridgedFromChain 35 | ); 36 | } 37 | return balances; 38 | }; 39 | }; 40 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/helper/near.js: -------------------------------------------------------------------------------- 1 | const axios = require("axios") 2 | const endpoint = "https://rpc.mainnet.near.org"; 3 | 4 | async function call(contract, method, args = {}) { 5 | const result = await axios.post(endpoint, { 6 | jsonrpc: "2.0", 7 | id: "1", 8 | method: "query", 9 | params: { 10 | request_type: "call_function", 11 | finality: "final", 12 | account_id: contract, 13 | method_name: method, 14 | args_base64: Buffer.from(JSON.stringify(args)).toString("base64"), 15 | }, 16 | }); 17 | if (result.data.error) { 18 | throw new Error(`${result.data.error.message}: ${result.data.error.data}`); 19 | } 20 | return JSON.parse(Buffer.from(result.data.result.result).toString()); 21 | } 22 | 23 | module.exports = { 24 | call, 25 | }; 26 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/helper/ontology.ts: -------------------------------------------------------------------------------- 1 | const axios = require("axios"); 2 | const retry = require("async-retry"); 3 | const BigNumber = require("bignumber.js"); 4 | 5 | export async function getTotalSupply(address: string, tokenType: string) { 6 | const supplyRes = await retry( 7 | async (_bail: any) => 8 | await axios.get( 9 | `https://explorer.ont.io/v2/tokens/${tokenType}/${address}` 10 | ) 11 | ); 12 | const bnSupply = new BigNumber(supplyRes?.data?.result?.total_supply); 13 | 14 | return bnSupply.toNumber(); 15 | } 16 | 17 | export async function getBalance( 18 | address: string, 19 | tokenType: string, 20 | owner: string 21 | ) { 22 | const balancesRes = await axios.get( 23 | `https://explorer.ont.io/v2/addresses/${owner}/${tokenType}/balances` 24 | ) 25 | const filteredBalances = balancesRes?.data?.result?.filter( 26 | (balance: any) => balance.contract_hash === address 27 | ); 28 | if (!filteredBalances[0]?.balance) return 0 29 | 30 | const bnBalance = new BigNumber(filteredBalances[0]?.balance); 31 | 32 | return bnBalance.toNumber(); 33 | } 34 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/helper/polynetwork.ts: -------------------------------------------------------------------------------- 1 | const axios = require("axios"); 2 | const retry = require("async-retry"); 3 | 4 | export async function getTotalBridged( 5 | chainID: number, 6 | chainName: string, 7 | assetName: string 8 | ) { 9 | const res = await retry( 10 | async (_bail: any) => 11 | await axios.get( 12 | `https://explorer.poly.network/api/v1/gettransferstatistic?chain=${chainID}` 13 | ) 14 | ); 15 | const chainInfo = res?.data?.chain_transfer_statistics?.filter( 16 | (obj: any) => obj.chainname === chainName 17 | ); 18 | const assetInfo = chainInfo?.[0]?.asset_transfer_statistics?.filter( 19 | (obj: any) => obj.name === assetName 20 | ); 21 | return parseInt(assetInfo?.[0]?.amount); 22 | } 23 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/helper/solana.js: -------------------------------------------------------------------------------- 1 | const axios = require("axios"); 2 | 3 | const endpoint = process.env.SOLANA_RPC ?? "https://api.mainnet-beta.solana.com"; 4 | 5 | async function getTokenSupply(token) { 6 | const tokenSupply = await axios.post(endpoint, { 7 | jsonrpc: "2.0", 8 | id: 1, 9 | method: "getTokenSupply", 10 | params: [token], 11 | }); 12 | return tokenSupply.data.result.value.uiAmount; 13 | } 14 | 15 | async function getTokenBalance(token, account) { 16 | const tokenBalance = await axios.post(endpoint, { 17 | jsonrpc: "2.0", 18 | id: 1, 19 | method: "getTokenAccountsByOwner", 20 | params: [ 21 | account, 22 | { 23 | mint: token, 24 | }, 25 | { 26 | encoding: "jsonParsed", 27 | }, 28 | ], 29 | }); 30 | return tokenBalance.data.result.value.reduce( 31 | (total, account) => 32 | total + account.account.data.parsed.info.tokenAmount.uiAmount, 33 | 0 34 | ); 35 | } 36 | 37 | module.exports = { 38 | getTokenSupply, 39 | getTokenBalance, 40 | endpoint 41 | }; 42 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/helper/stellar.ts: -------------------------------------------------------------------------------- 1 | const axios = require("axios"); 2 | const retry = require("async-retry"); 3 | 4 | const stellarExpertEndpoint = (assetID: string): string => 5 | `https://api.stellar.expert/explorer/public/asset/${assetID.replace(":", "-")}`; 6 | 7 | export async function getAsset(assetID: string) { 8 | // assetID is concatenation of the assetCode and assetIssuer, separated by a colon 9 | const asset = await retry( 10 | async (_bail: any) => 11 | await axios.get(stellarExpertEndpoint(assetID)) 12 | ); 13 | const data = asset.data; 14 | return data; 15 | } 16 | 17 | export async function getTotalSupply(assetID: string) { 18 | // assetID is concatenation of the assetCode and assetIssuer, separated by a colon 19 | const asset = await getAsset(assetID); 20 | const decimals = 7; 21 | const supply = asset?.supply; 22 | return supply / 10 ** decimals; 23 | } 24 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/helper/sui.ts: -------------------------------------------------------------------------------- 1 | import { graph } from "@defillama/sdk"; 2 | import http from "../helper/http"; 3 | 4 | interface CallOptions { 5 | withMetadata?: boolean; 6 | } 7 | 8 | export const endpoint = (): string => "https://fullnode.mainnet.sui.io/"; 9 | export const graphEndpoint = (): string => "https://sui-mainnet.mystenlabs.com/graphql"; 10 | 11 | export async function getObject(objectId: string): Promise { 12 | return ( 13 | await call("sui_getObject", [ 14 | objectId, 15 | { 16 | showType: true, 17 | showOwner: true, 18 | showContent: true, 19 | }, 20 | ]) 21 | ).content; 22 | } 23 | 24 | export async function call( 25 | method: string, 26 | params: any, 27 | { withMetadata = false }: CallOptions = {} 28 | ): Promise { 29 | if (!Array.isArray(params)) params = [params]; 30 | const { result } = await http.post(endpoint(), { 31 | jsonrpc: "2.0", 32 | id: 1, 33 | method, 34 | params, 35 | }); 36 | return withMetadata ? result : result.data; 37 | } 38 | 39 | 40 | export async function getTokenSupply(token: string) { 41 | const query = `{ 42 | coinMetadata(coinType:"${token}") { 43 | decimals 44 | symbol 45 | supply 46 | } 47 | }` 48 | const { coinMetadata: { supply, decimals } } = await graph.request(graphEndpoint(), query) 49 | return supply / 10 ** decimals 50 | } -------------------------------------------------------------------------------- /src/adapters/peggedAssets/helper/tezos.ts: -------------------------------------------------------------------------------- 1 | const axios = require("axios"); 2 | const retry = require("async-retry"); 3 | const BigNumber = require("bignumber.js"); 4 | 5 | export async function getTotalSupply(contract: string, decimals?: number) { 6 | const res = await retry( 7 | async (_bail: any) => 8 | await axios.get(`https://api.tzkt.io/v1/tokens?contract=${contract}`) 9 | ); 10 | 11 | const supply = new BigNumber(res?.data?.[0]?.totalSupply); 12 | const metadataDecimals = new BigNumber(res?.data?.[0]?.metadata?.decimals); 13 | 14 | const d = decimals ? decimals : metadataDecimals; 15 | 16 | return supply.div(10 ** d).toNumber(); 17 | } 18 | 19 | export async function getBalance( 20 | address: string, 21 | tokenID: string, 22 | decimals?: number 23 | ) { 24 | const res = await retry( 25 | async (_bail: any) => 26 | await axios.get( 27 | `https://api.tzkt.io/v1/tokens/balances?account=${address}&token.id=${tokenID}` 28 | ) 29 | ); 30 | 31 | const supply = new BigNumber(res?.data?.[0]?.balance); 32 | const metadataDecimals = new BigNumber( 33 | res?.data?.[0]?.token?.metadata?.decimals 34 | ); 35 | 36 | const d = decimals ? decimals : metadataDecimals; 37 | 38 | return supply.div(10 ** d).toNumber(); 39 | } 40 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/helper/tron.js: -------------------------------------------------------------------------------- 1 | const sdk = require('@defillama/sdk') 2 | const api = new sdk.ChainApi({ chain: 'tron'}) 3 | 4 | async function getTotalSupply(token) { 5 | const supply = await api.call({ target: token, abi: 'erc20:totalSupply' }) 6 | const decimals = await api.call({ target: token, abi: 'erc20:decimals' }) 7 | return supply / 10 ** decimals; 8 | } 9 | 10 | async function getTokenBalance(token, account) { 11 | const balance = await api.call({ target: token, abi: 'erc20:balanceOf', params: [account]}) 12 | const decimals = await api.call({ target: token, abi: 'erc20:decimals' }) 13 | return balance / 10 ** decimals; 14 | } 15 | 16 | module.exports = { 17 | getTokenBalance, 18 | getTotalSupply, 19 | }; 20 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/hex-dollar-coin/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | pulse: { 3 | issued: ["0x1fe0319440a672526916c232eaee4808254bdb00"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/hex-trust-usdx/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x7a486f809c952a6f8dec8cb0ff68173f2b8ed56c"], 4 | }, 5 | flare: { 6 | issued: ["0x4A771Cc1a39FDd8AA08B8EA51F7Fd412e73B3d2B"], 7 | }, 8 | songbird: { 9 | issued: ["0x4A771Cc1a39FDd8AA08B8EA51F7Fd412e73B3d2B"], 10 | }, 11 | }; 12 | 13 | import { addChainExports } from "../helper/getSupply"; 14 | const adapter = addChainExports(chainContracts); 15 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/high-yield-usd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0xaCdf0DBA4B9839b96221a8487e9ca660a48212be"], 4 | }, 5 | base: { 6 | issued: ["0xCc7FF230365bD730eE4B352cC2492CEdAC49383e"], 7 | }, 8 | }; 9 | 10 | import { addChainExports } from "../helper/getSupply"; 11 | const adapter = addChainExports(chainContracts); 12 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/honey-3/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | berachain: { 3 | issued: ["0xfcbd14dc51f0a4d49d5e53c2e0950e0bc26d0dce"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/hydt/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | bsc: { 3 | issued: ["0x9810512Be701801954449408966c630595D0cD51"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; 10 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/hyperstable/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | hyperliquid: { 3 | issued: ["0x8ff0dd9f9c40a0d76ef1bcfaf5f98c1610c74bd8"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/inter-stable-token/index.ts: -------------------------------------------------------------------------------- 1 | import { sumSingleBalance } from "../helper/generalUtil"; 2 | import { osmosisSupply } from "../helper/getSupply"; 3 | import { 4 | Balances, 5 | ChainBlocks, 6 | PeggedIssuanceAdapter, ChainContracts, 7 | } from "../peggedAsset.type"; 8 | const axios = require("axios"); 9 | const retry = require("async-retry"); 10 | 11 | 12 | const chainContracts: ChainContracts = { 13 | osmosis: { 14 | bridgedFromAgoric: [ 15 | "ibc/92BE0717F4678905E53F4E45B2DED18BC0CB97BF1F8B6A25AFEDF3D5A879B4D5", 16 | ], 17 | }, 18 | }; 19 | 20 | async function agoricMinted(decimals: number) { 21 | return async function ( 22 | _timestamp: number, 23 | _ethBlock: number, 24 | _chainBlocks: ChainBlocks 25 | ) { 26 | let balances = {} as Balances; 27 | const res = await retry( 28 | async (_bail: any) => 29 | await axios.get( 30 | "https://rest.cosmos.directory/agoric/cosmos/bank/v1beta1/supply/by_denom?denom=uist" 31 | ) 32 | ); 33 | const istInfo = res?.data?.amount; 34 | const supply = istInfo?.amount / 10 ** decimals; 35 | sumSingleBalance(balances, "peggedUSD", supply, "issued", false); 36 | return balances; 37 | }; 38 | } 39 | 40 | const adapter: PeggedIssuanceAdapter = { 41 | agoric: { 42 | minted: agoricMinted(6), 43 | }, 44 | osmosis: { 45 | agoric: osmosisSupply( 46 | chainContracts.osmosis.bridgedFromAgoric, 47 | 6, 48 | "Agoric" 49 | ), 50 | }, 51 | }; 52 | 53 | export default adapter; 54 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/interest-protocol/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x2A54bA2964C8Cd459Dc568853F79813a60761B58"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/international-stable-currency/index.ts: -------------------------------------------------------------------------------- 1 | const sdk = require("@defillama/sdk"); 2 | import { PeggedIssuanceAdapter } from "../peggedAsset.type"; 3 | import { solanaMintedOrBridged } from "../helper/getSupply"; 4 | 5 | const chainContracts = { 6 | solana: { 7 | issued: ["J9BcrQfX4p9D1bvLzRNCbMDv8f44a9LFdeqNE4Yk2WMD"], 8 | }, 9 | }; 10 | 11 | const adapter: PeggedIssuanceAdapter = { 12 | solana: { 13 | minted: solanaMintedOrBridged(chainContracts.solana.issued, "peggedVAR"), 14 | unreleased: async () => ({}), 15 | }, 16 | }; 17 | 18 | export default adapter; 19 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/iron-bank-euro/index.ts: -------------------------------------------------------------------------------- 1 | 2 | const chainContracts = { 3 | ethereum: { 4 | issued: ["0x96E61422b6A9bA0e068B6c5ADd4fFaBC6a4aae27"], pegType: 'peggedEUR', 5 | reserves: ["0x0D5Dc686d0a2ABBfDaFDFb4D0533E886517d4E83"], // multisig 6 | }, 7 | }; 8 | 9 | import { addChainExports } from "../helper/getSupply"; 10 | const adapter = addChainExports(chainContracts); 11 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/iusd/index.ts: -------------------------------------------------------------------------------- 1 | import { 2 | PeggedIssuanceAdapter, 3 | ChainBlocks, 4 | Balances, ChainContracts, 5 | } from "../peggedAsset.type"; 6 | import { sumSingleBalance } from "../helper/generalUtil"; 7 | import { getTotalSupply } from "../helper/cardano"; 8 | 9 | const assetIDs = { 10 | cardano: { 11 | issued: [ 12 | "f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b6988069555344", 13 | ], 14 | }, 15 | }; 16 | 17 | async function getCardanoSupply() { 18 | return async function ( 19 | _timestamp: number, 20 | _ethBlock: number, 21 | _chainBlocks: ChainBlocks 22 | ) { 23 | let balances = {} as Balances; 24 | const supply = await getTotalSupply(assetIDs.cardano.issued[0]); 25 | sumSingleBalance(balances, "peggedUSD", supply, "issued", false); 26 | return balances; 27 | }; 28 | } 29 | 30 | const adapter: PeggedIssuanceAdapter = { 31 | cardano: { 32 | minted: getCardanoSupply(), 33 | }, 34 | }; 35 | 36 | export default adapter; 37 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/jpy-coin/index.ts: -------------------------------------------------------------------------------- 1 | // The amounts minted on chains and in bridge contracts seem to have no relation to each other. 2 | // Adapter treats each chain separately, subtracts the gnosis multisig address as unreleased, except for ethereum where it also subtracts the large amounts in bridge contracts. 3 | const chainContracts = { 4 | ethereum: { 5 | issued: ["0x2370f9d504c7a6e775bf6e14b3f12846b594cd53"], 6 | unreleased: [ 7 | "0x7a7f371abcab225c8d78341ebabae991f2e18828", // gnosis safe 8 | "0x40ec5b33f54e0e8a33a975908c5ba1c14e5bbbdf", // polygon bridge 9 | "0x4e67df0f232c3bc985f8a63326d80ce3d9a40400", // shiden bridge 10 | "0x88ad09518695c6c3712ac10a214be5109a655671", // gnosis bridge 11 | ], 12 | }, 13 | avax: { 14 | issued: ["0x431d5dff03120afa4bdf332c61a6e1766ef37bdb"], 15 | unreleased: ["0x7a96b7cf21f543e6d20159112fb7a9e66de4ff4f"], 16 | }, 17 | polygon: { 18 | issued: ["0x431D5dfF03120AFA4bDf332c61A6e1766eF37BDB"], 19 | unreleased: ["0x7a7F371aBCab225C8d78341eBabAE991F2e18828"], 20 | }, 21 | shiden: { 22 | issued: ["0x431d5dff03120afa4bdf332c61a6e1766ef37bdb"], 23 | unreleased: ["0xb30B58386F51881024231b06470E6ed6Fe5bD725"], 24 | }, 25 | astar: { 26 | issued: ["0x431d5dff03120afa4bdf332c61a6e1766ef37bdb"], 27 | unreleased: ["0x572BCbBFbd19d6D7D0c80660151a48da6331be2c"], // not sure if this is correct 28 | }, 29 | xdai: { 30 | issued: ["0x431D5dfF03120AFA4bDf332c61A6e1766eF37BDB"], 31 | unreleased: ["0xa312f84607Efb1D200C313859156ccC3500189b6"], 32 | }, 33 | } 34 | 35 | import { addChainExports } from "../helper/getSupply"; 36 | const adapter = addChainExports(chainContracts, undefined, { pegType: "peggedJPY", }); 37 | export default adapter; 38 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/knox-dollar/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | arbitrum: { 3 | issued: ["0x0BBF664D46becc28593368c97236FAa0fb397595"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/kolibri-usd/index.ts: -------------------------------------------------------------------------------- 1 | const sdk = require("@defillama/sdk"); 2 | import { sumSingleBalance } from "../helper/generalUtil"; 3 | import { 4 | ChainBlocks, 5 | PeggedIssuanceAdapter, 6 | Balances, ChainContracts, 7 | } from "../peggedAsset.type"; 8 | import { getTotalSupply as tezosGetTotalSupply } from "../helper/tezos"; 9 | 10 | 11 | const chainContracts: ChainContracts = { 12 | tezos: { 13 | issued: ["KT1K9gCRgaLRFKTErYt1wVxA3Frb9FjasjTV"], 14 | }, 15 | }; 16 | 17 | async function tezosMinted(tokenID: string) { 18 | return async function ( 19 | _timestamp: number, 20 | _ethBlock: number, 21 | _chainBlocks: ChainBlocks 22 | ) { 23 | let balances = {} as Balances; 24 | const totalSupply = await tezosGetTotalSupply(tokenID); 25 | sumSingleBalance(balances, "peggedUSD", totalSupply, "issued", false); 26 | return balances; 27 | }; 28 | } 29 | 30 | const adapter: PeggedIssuanceAdapter = { 31 | tezos: { 32 | minted: tezosMinted(chainContracts.tezos.issued[0]), 33 | }, 34 | }; 35 | 36 | export default adapter; 37 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/legacy-bold/index.ts: -------------------------------------------------------------------------------- 1 | import { addChainExports } from "../helper/getSupply"; 2 | 3 | const chainContracts = { 4 | ethereum: { 5 | issued: ["0xb01dd87b29d187f3e3a4bf6cdaebfb97f3d9ab98"], 6 | }, 7 | base: { 8 | bridgedFromETH: ["0x087c440f251ff6cfe62b86dde1be558b95b4bb9b"], 9 | }, 10 | arbitrum: { 11 | bridgedFromETH: ["0x087c440f251ff6cfe62b86dde1be558b95b4bb9b"], 12 | }, 13 | optimism: { 14 | bridgedFromETH: ["0x087c440f251ff6cfe62b86dde1be558b95b4bb9b"], 15 | }, 16 | scroll: { 17 | bridgedFromETH: ["0x087c440f251ff6cfe62b86dde1be558b95b4bb9b"], 18 | }, 19 | avax: { 20 | bridgedFromETH: ["0x087c440f251ff6cfe62b86dde1be558b95b4bb9b"], 21 | }, 22 | }; 23 | 24 | const adapter = addChainExports(chainContracts); 25 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/let-s-get-hai/index.ts: -------------------------------------------------------------------------------- 1 | 2 | const chainContracts = { 3 | optimism: { 4 | issued: ["0x10398abc267496e49106b07dd6be13364d10dc71"], 5 | }, 6 | }; 7 | 8 | import { addChainExports } from "../helper/getSupply"; 9 | const adapter = addChainExports(chainContracts); 10 | export default adapter; 11 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/level-usd/index.ts: -------------------------------------------------------------------------------- 1 | import { addChainExports } from "../helper/getSupply"; 2 | 3 | const chainContracts = { 4 | ethereum: { 5 | issued: ["0x7c1156e515aa1a2e851674120074968c905aaf37"], 6 | }, 7 | }; 8 | 9 | const adapter = addChainExports(chainContracts); 10 | export default adapter; 11 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/lift-dollar/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0xbdC7c08592Ee4aa51D06C27Ee23D5087D65aDbcD"], 4 | }, 5 | arbitrum: { 6 | issued: ["0x7F850b0aB1988Dd17B69aC564c1E2857949e4dEe"] 7 | } 8 | }; 9 | 10 | import { addChainExports } from "../helper/getSupply"; 11 | const adapter = addChainExports(chainContracts); 12 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/liquid-loans-usdl/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | pulse: { 3 | issued: ["0x0deed1486bc52aa0d3e6f8849cec5add6598a162"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/liquity-bold/index.ts: -------------------------------------------------------------------------------- 1 | import { addChainExports } from "../helper/getSupply"; 2 | 3 | const chainContracts = { 4 | ethereum: { 5 | issued: ["0x6440f144b7e50D6a8439336510312d2F54beB01D"], 6 | }, 7 | base: { 8 | bridgedFromETH: ["0x03569CC076654F82679C4BA2124D64774781B01D"], 9 | }, 10 | arbitrum: { 11 | bridgedFromETH: ["0x03569CC076654F82679C4BA2124D64774781B01D"], 12 | }, 13 | optimism: { 14 | bridgedFromETH: ["0x03569CC076654F82679C4BA2124D64774781B01D"], 15 | }, 16 | scroll: { 17 | bridgedFromETH: ["0x03569CC076654F82679C4BA2124D64774781B01D"], 18 | }, 19 | avax: { 20 | bridgedFromETH: ["0x03569CC076654F82679C4BA2124D64774781B01D"], 21 | }, 22 | }; 23 | 24 | const adapter = addChainExports(chainContracts); 25 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/liquity-usd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x5f98805a4e8be255a32880fdec7f6728c6568ba0"], 4 | }, 5 | polygon: { 6 | bridgedFromETH: ["0x23001f892c0C82b79303EDC9B9033cD190BB21c7"], 7 | }, 8 | optimism: { 9 | bridgedFromETH: ["0xc40F949F8a4e094D1b49a23ea9241D289B7b2819"], 10 | }, 11 | bsc: { 12 | bridgedFromETH: ["0x181002D60d504d30a39601Ae13Af3191cb102580"], // celer 13 | }, 14 | avax: { 15 | bridgedFromETH: ["0xDA0019E7e50Ee4990440b1aa5dFFCAC6E27Ee27B"], // celer 16 | }, 17 | fantom: { 18 | bridgedFromETH: ["0x16365b45EB269B5B5dACB34B4a15399Ec79b95eB"], // celer 19 | }, 20 | arbitrum: { 21 | bridgedFromETH: ["0x93b346b6BC2548dA6A1E7d98E9a421B42541425b"], 22 | }, 23 | polygon_zkevm: { 24 | bridgedFromETH: ["0x01E9A866c361eAd20Ab4e838287DD464dc67A50e"], 25 | }, 26 | era: { 27 | bridgeOnETH: ["0xD7f9f54194C633F36CCD5F3da84ad4a1c38cB2cB"], 28 | bridgedFromETH: ["0x503234f203fc7eb888eec8513210612a43cf6115"], 29 | }, 30 | scroll: { 31 | bridgedFromETH: [ 32 | "0xeDEAbc3A1e7D21fE835FFA6f83a710c70BB1a051", // LUSD 33 | ], 34 | }, 35 | }; 36 | import { addChainExports } from "../helper/getSupply"; 37 | const adapter = addChainExports(chainContracts); 38 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/m-by-m^0/index.ts: -------------------------------------------------------------------------------- 1 | import { addChainExports } from "../helper/getSupply"; 2 | 3 | const chainContracts = { 4 | ethereum: { 5 | issued: ["0x866A2BF4E572CbcF37D5071A7a58503Bfb36be1b"], 6 | }, 7 | }; 8 | 9 | const adapter = addChainExports(chainContracts); 10 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/magma-wen/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | iotex: { 3 | issued: ["0x6C0bf4b53696b5434A0D21C7D13Aa3cbF754913E"], 4 | }, 5 | }; 6 | 7 | 8 | import { addChainExports } from "../helper/getSupply"; 9 | const adapter = addChainExports(chainContracts); 10 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/mead-2/index.ts: -------------------------------------------------------------------------------- 1 | 2 | const chainContracts = { 3 | berachain: { 4 | issued: ["0xedb5180661f56077292c92ab40b1ac57a279a396"], 5 | }, 6 | }; 7 | 8 | import { addChainExports } from "../helper/getSupply"; 9 | const adapter = addChainExports(chainContracts); 10 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/meme-dollar/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: "0x02814F435dD04e254Be7ae69F61FCa19881a780D", 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/moneta/index.ts: -------------------------------------------------------------------------------- 1 | import { 2 | PeggedIssuanceAdapter, 3 | Balances, 4 | } from "../peggedAsset.type"; 5 | import { sumSingleBalance } from "../helper/generalUtil"; 6 | import { addressesUtxosAssetAll, getScriptsDatum } from "../helper/cardano"; 7 | 8 | async function getCardanoSupply() { 9 | let balances = {} as Balances; 10 | const usdm_count_nft_asset = "e319d8e6629ff7991c8ae4f8aec2e0f10463ebdf29b57d26d34914f65553444d5f434f554e54" 11 | const count_address = "addr1wyl82v9qy06hsz50hqqdy0u6xw9hdewy7twjahgek2tpp7c0qajez" 12 | const utxo = (await addressesUtxosAssetAll(count_address, usdm_count_nft_asset))[0] 13 | const datum_hash = utxo.data_hash 14 | const datum = await getScriptsDatum(datum_hash) 15 | const total_value_locked = datum.json_value.fields[0].int / 1_000_000 16 | sumSingleBalance(balances, "peggedUSD", total_value_locked, "issued", false); 17 | 18 | return balances; 19 | } 20 | 21 | const adapter: PeggedIssuanceAdapter = { 22 | cardano: { 23 | minted: getCardanoSupply, 24 | }, 25 | }; 26 | 27 | export default adapter; 28 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/moremoney-usd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | avax: { 3 | issued: ["0x0f577433Bf59560Ef2a79c124E9Ff99fCa258948"], 4 | }, 5 | }; 6 | import { addChainExports } from "../helper/getSupply"; 7 | const adapter = addChainExports(chainContracts); 8 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/move-dollar/index.ts: -------------------------------------------------------------------------------- 1 | const sdk = require("@defillama/sdk"); 2 | import { 3 | ChainBlocks, 4 | PeggedIssuanceAdapter, 5 | } from "../peggedAsset.type"; 6 | const axios = require("axios"); 7 | const retry = require("async-retry"); 8 | 9 | async function modCirculating() { 10 | return async function ( 11 | _timestamp: number, 12 | _ethBlock: number, 13 | _chainBlocks: ChainBlocks 14 | ) { 15 | const issuance = await retry( 16 | async (_bail: any) => 17 | await axios.get( 18 | "https://app.thala.fi/api/coingecko-integration/mod-circulating-supply" 19 | ) 20 | ); 21 | const tokens = issuance.data.result; 22 | const balance = Number(tokens); 23 | return { peggedUSD: balance }; 24 | }; 25 | } 26 | 27 | const adapter: PeggedIssuanceAdapter = { 28 | aptos: { 29 | minted: modCirculating(), 30 | }, 31 | }; 32 | 33 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/musd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0xe2f2a5c287993345a840db3b0845fbc70f5935a5"], 4 | }, 5 | xdai: { 6 | bridgedFromETH: ["0x7300AaFC0Ef0d47Daeb850f8b6a1931b40aCab33"], 7 | }, 8 | polygon: { 9 | issued: ["0xE840B73E5287865EEc17d250bFb1536704B43B21"], 10 | }, 11 | }; 12 | 13 | import { addChainExports } from "../helper/getSupply"; 14 | const adapter = addChainExports(chainContracts); 15 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/myusd/index.ts: -------------------------------------------------------------------------------- 1 | import { 2 | PeggedIssuanceAdapter, 3 | ChainBlocks, 4 | Balances, ChainContracts, 5 | } from "../peggedAsset.type"; 6 | import { sumSingleBalance } from "../helper/generalUtil"; 7 | import { getTotalSupply } from "../helper/cardano"; 8 | 9 | const assetIDs = { 10 | cardano: { 11 | issued: [ 12 | "92776616f1f32c65a173392e4410a3d8c39dcf6ef768c73af164779c4d79555344", 13 | ], 14 | }, 15 | }; 16 | 17 | async function getCardanoSupply() { 18 | return async function ( 19 | _timestamp: number, 20 | _ethBlock: number, 21 | _chainBlocks: ChainBlocks 22 | ) { 23 | let balances = {} as Balances; 24 | const supply = await getTotalSupply(assetIDs.cardano.issued[0]); 25 | sumSingleBalance(balances, "peggedUSD", supply, "issued", false); 26 | return balances; 27 | }; 28 | } 29 | 30 | const adapter: PeggedIssuanceAdapter = { 31 | cardano: { 32 | minted: getCardanoSupply(), 33 | }, 34 | }; 35 | 36 | export default adapter; 37 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/nars/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | polygon: { 3 | issued: "0x65517425ac3ce259a34400bb67ceb39ff3ddc0bd", 4 | unreleased: ["0x8388A0f91875e74Dc4705Abf2C9bBDD1bD40C585"], pegType: "peggedARS", 5 | }, 6 | }; 7 | 8 | 9 | import { addChainExports } from "../helper/getSupply"; 10 | const adapter = addChainExports(chainContracts); 11 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/nexus-usd/index.ts: -------------------------------------------------------------------------------- 1 | 2 | const chainContracts = { 3 | ethereum: { 4 | issued: ["0x1B84765dE8B7566e4cEAF4D0fD3c5aF52D3DdE4F"], 5 | }, 6 | bsc: { 7 | bridgedFromETH: ["0x23b891e5c62e0955ae2bd185990103928ab817b3"], 8 | }, 9 | polygon: { 10 | bridgedFromETH: ["0xb6c473756050de474286bed418b77aeac39b02af"], 11 | }, 12 | avax: { 13 | bridgedFromETH: ["0xcfc37a6ab183dd4aed08c204d1c2773c0b1bdf46"], 14 | }, 15 | arbitrum: { 16 | bridgedFromETH: ["0x2913e812cf0dcca30fb28e6cac3d2dcff4497688"], 17 | }, 18 | fantom: { 19 | bridgedFromETH: ["0xed2a7edd7413021d440b09d654f3b87712abab66"], 20 | }, 21 | harmony: { 22 | bridgedFromETH: ["0xed2a7edd7413021d440b09d654f3b87712abab66"], 23 | }, 24 | boba: { 25 | bridgedFromETH: ["0x6b4712ae9797c199edd44f897ca09bc57628a1cf"], 26 | }, 27 | optimism: { 28 | bridgedFromETH: ["0x67c10c397dd0ba417329543c1a40eb48aaa7cd00"], 29 | }, 30 | cronos: { 31 | bridgedFromETH: ["0x396c9c192dd323995346632581bef92a31ac623b"], 32 | }, 33 | metis: { 34 | bridgedFromETH: ["0x961318fc85475e125b99cc9215f62679ae5200ab"], 35 | }, 36 | dfk: { 37 | bridgedFromETH: ["0x52285d426120ab91f378b3df4a15a036a62200ae"], 38 | }, 39 | aurora: { 40 | bridgedFromETH: ["0x07379565cD8B0CaE7c60Dc78e7f601b34AF2A21c"], 41 | }, 42 | }; 43 | 44 | import { addChainExports } from "../helper/getSupply"; 45 | const adapter = addChainExports(chainContracts); 46 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/nexus/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x92211b6B68a39F4f68E722f3A3A4810A2Ebc8383"], 4 | }, 5 | arbitrum: { 6 | issued: ["0x773fAf6B9424abFc199cc28A5320C3C2d151E3bF"], 7 | }, 8 | }; 9 | 10 | 11 | import { addChainExports } from "../helper/getSupply"; 12 | const adapter = addChainExports(chainContracts); 13 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/noon-usn/index.ts: -------------------------------------------------------------------------------- 1 | const sdk = require("@defillama/sdk"); 2 | import { 3 | ChainBlocks, 4 | PeggedIssuanceAdapter, 5 | Balances, ChainContracts, 6 | } from "../peggedAsset.type"; 7 | import { sumSingleBalance } from "../helper/generalUtil"; 8 | 9 | const chainContracts : ChainContracts = { 10 | ethereum: { 11 | issued: ["0xdA67B4284609d2d48e5d10cfAc411572727dc1eD"], 12 | }, 13 | era: { 14 | issued: ["0x0469d9d1dE0ee58fA1153ef00836B9BbCb84c0B6"] 15 | }, 16 | sophon: { 17 | issued: ["0xC1AA99c3881B26901aF70738A7C217dc32536d36"] 18 | } 19 | }; 20 | 21 | async function chainMinted(chain: string, decimals: number) { 22 | return async function ( 23 | _timestamp: number, 24 | _ethBlock: number, 25 | _chainBlocks: ChainBlocks 26 | ) { 27 | let balances = {} as Balances; 28 | for (let issued of chainContracts[chain].issued) { 29 | const totalSupply = ( 30 | await sdk.api.abi.call({ 31 | abi: "erc20:totalSupply", 32 | target: issued, 33 | block: _chainBlocks?.[chain], 34 | chain: chain, 35 | }) 36 | ).output; 37 | sumSingleBalance( 38 | balances, 39 | "peggedUSD", 40 | totalSupply / 10 ** decimals, 41 | "issued", 42 | false 43 | ); 44 | } 45 | return balances; 46 | }; 47 | } 48 | 49 | const adapter: PeggedIssuanceAdapter = { 50 | ethereum: { 51 | minted: chainMinted("ethereum", 18), 52 | }, 53 | era: { 54 | minted: chainMinted("era", 18), 55 | }, 56 | sophon: { 57 | minted: chainMinted("sophon", 18), 58 | }, 59 | }; 60 | 61 | export default adapter; 62 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/nostra-uno/abi.ts: -------------------------------------------------------------------------------- 1 | export const starknetTotalSupplyAbi = { 2 | name: "total_supply", 3 | type: "function", 4 | inputs: [], 5 | outputs: [ 6 | { 7 | type: "core::integer::u256", 8 | }, 9 | ], 10 | state_mutability: "view", 11 | }; 12 | 13 | export const starknetBalanceOfAbi = { 14 | name: "balance_of", 15 | type: "function", 16 | inputs: [ 17 | { 18 | type: "core::starknet::contract_address::ContractAddress", 19 | name: "owner", 20 | }, 21 | ], 22 | outputs: [ 23 | { 24 | type: "core::integer::u256", 25 | }, 26 | ], 27 | state_mutability: "view", 28 | }; 29 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/note/index.ts: -------------------------------------------------------------------------------- 1 | const sdk = require("@defillama/sdk"); 2 | import { sumSingleBalance } from "../helper/generalUtil"; 3 | import { 4 | ChainBlocks, 5 | PeggedIssuanceAdapter, 6 | Balances, ChainContracts, 7 | } from "../peggedAsset.type"; 8 | 9 | 10 | const chainContracts: ChainContracts = { 11 | canto: { 12 | issued: ["0xEe602429Ef7eCe0a13e4FfE8dBC16e101049504C"], // cNote address; cNote and NOTE should be 1 to 1(?) 13 | reserve: ["0x4F6DCfa2F69AF7350AAc48D3a3d5B8D03b5378AA"], 14 | }, 15 | }; 16 | 17 | async function cantoCirculating(chain: string, decimals: number) { 18 | return async function ( 19 | _timestamp: number, 20 | _ethBlock: number, 21 | _chainBlocks: ChainBlocks 22 | ) { 23 | let balances = {} as Balances; 24 | const totalSupply = ( 25 | await sdk.api.abi.call({ 26 | abi: "erc20:totalSupply", 27 | target: chainContracts[chain].issued[0], 28 | block: _chainBlocks?.[chain], 29 | chain: chain, 30 | }) 31 | ).output; 32 | sumSingleBalance( 33 | balances, 34 | "peggedUSD", 35 | totalSupply / 10 ** decimals, 36 | "issued", 37 | false 38 | ); 39 | return balances; 40 | }; 41 | } 42 | 43 | const adapter: PeggedIssuanceAdapter = { 44 | canto: { 45 | minted: cantoCirculating("canto", 18), 46 | }, 47 | }; 48 | 49 | export default adapter; 50 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/nxusd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | avax: { 3 | issued: ["0xf14f4ce569cb3679e99d5059909e23b07bd2f387"], 4 | unreleased: ["0x0b1f9c2211f77ec3fa2719671c5646cf6e59b775"], 5 | }, 6 | polygon: { 7 | issued: ["0xf955a6694C6F5629f5Ecd514094B3bd450b59000"], 8 | unreleased: ["0x7195d3A344106b877F8D5f62CA570Fd25D43D180"], 9 | }, 10 | }; 11 | 12 | import { addChainExports } from "../helper/getSupply"; 13 | const adapter = addChainExports(chainContracts); 14 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/offshift-anonusd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x5a7E6C8204A1359DB9AAcab7bA5Fc309B7981eFd"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; 10 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/openeden-open-dollar/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x8238884Ec9668Ef77B90C6dfF4D1a9F4F4823BFe"], 4 | }, 5 | base: { 6 | issued: ["0xaD55aebc9b8c03FC43cd9f62260391c13c23e7c0"], 7 | }, 8 | }; 9 | import { addChainExports } from "../helper/getSupply"; 10 | const adapter = addChainExports(chainContracts); 11 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/opus-cash/abi.ts: -------------------------------------------------------------------------------- 1 | export const starknetTotalSupplyAbi = { 2 | name: "total_supply", 3 | type: "function", 4 | inputs: [], 5 | outputs: [ 6 | { 7 | type: "core::integer::u256", 8 | }, 9 | ], 10 | state_mutability: "view", 11 | }; 12 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/opus-cash/index.ts: -------------------------------------------------------------------------------- 1 | import { sumSingleBalance } from "../helper/generalUtil"; 2 | import { call } from "../helper/starknet"; 3 | import { 4 | Balances, 5 | ChainBlocks, 6 | PeggedIssuanceAdapter, 7 | } from "../peggedAsset.type"; 8 | import { starknetTotalSupplyAbi } from "./abi"; 9 | 10 | const chainContracts = { 11 | starknet: { 12 | issued: "0x0498edfaf50ca5855666a700c25dd629d577eb9afccdf3b5977aec79aee55ada", 13 | }, 14 | }; 15 | 16 | async function starknetMinted(_chain: string, decimals: number) { 17 | return async function ( 18 | _timestamp: number, 19 | _ethBlock: number, 20 | _chainBlocks: ChainBlocks 21 | ) { 22 | let balances = {} as Balances; 23 | const totalSupply = await call({ target: chainContracts.starknet.issued, abi: starknetTotalSupplyAbi, }); 24 | 25 | sumSingleBalance(balances, "peggedUSD", totalSupply.toString() / 10 ** decimals, "issued", false,); 26 | 27 | return balances; 28 | }; 29 | } 30 | 31 | const adapter: PeggedIssuanceAdapter = { 32 | starknet: { 33 | minted: starknetMinted("starknet", 18), 34 | }, 35 | }; 36 | 37 | export default adapter; 38 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/orby-network-usc-stablecoin/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | cronos: { 3 | issued: ["0xD42E078ceA2bE8D03cd9dFEcC1f0d28915Edea78"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/origin-dollar/index.ts: -------------------------------------------------------------------------------- 1 | 2 | const chainContracts = { 3 | ethereum: { 4 | issued: ["0x2a8e1e676ec238d8a992307b495b45b3feaa5e86"], 5 | }, 6 | }; 7 | 8 | import { addChainExports } from "../helper/getSupply"; 9 | const adapter = addChainExports(chainContracts); 10 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/orki-usd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | swellchain: { 3 | issued: ["0x0000bAa0b1678229863c0A941C1056b83a1955F5"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/overnight-dai/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | arbitrum: { 3 | issued: ["0xeb8E93A0c7504Bffd8A8fFa56CD754c63aAeBFe8"], 4 | }, 5 | optimism: { 6 | issued: ["0x970D50d09F3a656b43E11B0D45241a84e3a6e011"], 7 | }, 8 | base: { 9 | issued: ["0x65a2508C429a6078a7BC2f7dF81aB575BD9D9275"], 10 | }, 11 | }; 12 | 13 | import { addChainExports } from "../helper/getSupply"; 14 | const adapter = addChainExports(chainContracts); 15 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/pago-linea-usdcb/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | rsk: { 3 | issued: ["0xaa5dc2ea0e056fc962f48ab25547d66d3586ee8a"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; 10 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/pando-usd/index.ts: -------------------------------------------------------------------------------- 1 | const sdk = require("@defillama/sdk"); 2 | import { sumSingleBalance } from "../helper/generalUtil"; 3 | import { 4 | ChainBlocks, 5 | PeggedIssuanceAdapter, 6 | Balances, 7 | } from "../peggedAsset.type"; 8 | const axios = require("axios"); 9 | const retry = require("async-retry"); 10 | 11 | async function pusdMinted() { 12 | return async function ( 13 | _timestamp: number, 14 | _ethBlock: number, 15 | _chainBlocks: ChainBlocks 16 | ) { 17 | let balances = {} as Balances; 18 | const res = await retry( 19 | async (_bail: any) => 20 | await axios.get("https://leaf-api.pando.im/api/cats") 21 | ); 22 | const ret = res.data; 23 | let sum = 0.0; 24 | for (let ix = 0; ix < ret.data.collaterals.length; ix++) { 25 | const collateral = ret.data.collaterals[ix]; 26 | sum += parseFloat(collateral.art) * parseFloat(collateral.rate); 27 | } 28 | sumSingleBalance(balances, "peggedUSD", sum, "issued", false); 29 | return balances; 30 | }; 31 | } 32 | 33 | const adapter: PeggedIssuanceAdapter = { 34 | mixin: { 35 | minted: pusdMinted(), 36 | }, 37 | }; 38 | 39 | export default adapter; 40 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/parallel-usd/index.ts: -------------------------------------------------------------------------------- 1 | import { addChainExports } from "../helper/getSupply"; 2 | import {ChainContracts, 3 | } from "../peggedAsset.type"; 4 | 5 | const chainContracts:ChainContracts = { 6 | ethereum: { 7 | issued: ["0x571f54D23cDf2211C83E9A0CbD92AcA36c48Fa02"], 8 | }, 9 | polygon: { 10 | issued: ["0x8054d4D130C3A84852f379424Bcac75673a7486B"], 11 | }, 12 | }; 13 | 14 | const adapter = addChainExports(chainContracts); 15 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/parrot-usd/index.ts: -------------------------------------------------------------------------------- 1 | const sdk = require("@defillama/sdk"); 2 | import { PeggedIssuanceAdapter } from "../peggedAsset.type"; 3 | import { solanaMintedOrBridged } from "../helper/getSupply"; 4 | 5 | const chainContracts = { 6 | solana: { 7 | issued: ["Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"], 8 | }, 9 | }; 10 | 11 | const adapter: PeggedIssuanceAdapter = { 12 | solana: { 13 | minted: solanaMintedOrBridged(chainContracts.solana.issued), 14 | }, 15 | }; 16 | 17 | export default adapter; 18 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/paxos-standard/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x8E870D67F660D95d5be530380D0eC0bd388289E1"], 4 | }, 5 | bsc: { 6 | bridgedFromETH: ["0xb3c11196A4f3b1da7c23d9FB0A3dDE9c6340934F"], 7 | }, 8 | linea: { 9 | bridgedFromETH: ["0xd2bc272EA0154A93bf00191c8a1DB23E67643EC5"], 10 | }, 11 | }; 12 | import { addChainExports } from "../helper/getSupply"; 13 | const adapter = addChainExports(chainContracts); 14 | export default adapter; 15 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/paypal-usd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x6c3ea9036406852006290770BEdFcAbA0e23A0e8"], 4 | }, 5 | solana: { 6 | issued: ["2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo"], 7 | }, 8 | berachain: { 9 | bridgedFromETH: ["0x688e72142674041f8f6Af4c808a4045cA1D6aC82"], 10 | }, 11 | flow: { 12 | bridgedFromETH: ["0x2aaBea2058b5aC2D339b163C6Ab6f2b6d53aabED"], 13 | }, 14 | plume_mainnet: { 15 | bridgedFromETH: ["0xe9e8330a71912F03E54E7D93795acD9a56f070Aa"], 16 | }, 17 | }; 18 | 19 | import { addChainExports } from "../helper/getSupply"; 20 | const adapter = addChainExports(chainContracts, undefined, { decimals: 6}); 21 | export default adapter; 22 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/peg-eusd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0xd585aaafa2b58b1cd75092b51ade9fa4ce52f247"], 4 | }, 5 | arbitrum: { 6 | issued: ["0xdce765f021410B3266aA0053c93Cb4535F1e12e0"], 7 | }, 8 | }; 9 | import { addChainExports } from "../helper/getSupply"; 10 | const adapter = addChainExports(chainContracts); 11 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/peggedAsset.type.ts: -------------------------------------------------------------------------------- 1 | import { BridgeID } from "../../peggedData/bridgeData"; 2 | 3 | export type ChainBlocks = { 4 | [x: string]: number; 5 | }; 6 | 7 | export type PeggedAssetType = 8 | | "peggedUSD" 9 | | "peggedVAR" 10 | | "peggedEUR" 11 | | "peggedSGD" 12 | | "peggedJPY" 13 | | "peggedCNY" 14 | | "peggedUAH" 15 | | "peggedARS" 16 | | "peggedGBP" 17 | | "peggedCAD" 18 | | "peggedTRY" 19 | | "peggedCHF" 20 | | "peggedGOLD" //not used 21 | | "peggedCOP" 22 | | "peggedREAL" 23 | | "peggedRUB" 24 | | "peggedAUD"; 25 | 26 | type StringNumber = string; 27 | type PeggedBalances = { 28 | [peggedAssetType: string]: StringNumber | number; 29 | }; 30 | type BridgeBalances = { 31 | [bridgeID in BridgeID]: { 32 | [source: string]: { 33 | amount: StringNumber | number; 34 | }; 35 | }; 36 | }; 37 | export type Balances = PeggedBalances & { 38 | bridges?: BridgeBalances; 39 | }; 40 | 41 | export type Fetch = ( 42 | timestamp: number, 43 | ethBlock: number, 44 | chainBlocks: ChainBlocks 45 | ) => Promise; 46 | 47 | export type PeggedIssuanceAdapter = { 48 | [chain: string]: { 49 | // minted: Promise | (() => Promise<{}>) | undefined; 50 | // unreleased: Promise | (() => Promise<{}>) | undefined; 51 | [bridgedFrom: string]: Fetch | Promise | (() => Promise<{}>) | any; 52 | }; 53 | }; 54 | 55 | export type ChainContracts = { 56 | [chain: string]: { 57 | [contract: string]: string[]; 58 | }; 59 | }; 60 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/phase-dollar/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | base: { 3 | issued: ["0xbe92452bb46485AF3308e6d77786bFBE3557808d"], 4 | }, 5 | }; 6 | import { addChainExports } from "../helper/getSupply"; 7 | const adapter = addChainExports(chainContracts); 8 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/pinto/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | base: { 3 | issued: ["0xb170000aeeFa790fa61D6e837d1035906839a3c8"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/platypus-usd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | avax: { 3 | issued: ["0xdaCDe03d7Ab4D81fEDdc3a20fAA89aBAc9072CE2"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/plume-usd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | plume_mainnet: { 3 | issued: ["0xdddD73F5Df1F0DC31373357beAC77545dC5A6f3F"], 4 | pegType: "peggedUSD", 5 | }, 6 | }; 7 | 8 | import { addChainExports } from "../helper/getSupply"; 9 | const adapter = addChainExports(chainContracts); 10 | export default adapter; 11 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/powercity-pxdc/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | pulse: { 3 | issued: ["0xeB6b7932Da20c6D7B3a899D5887d86dfB09A6408"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/prisma-mkusd/index.ts: -------------------------------------------------------------------------------- 1 | 2 | const chainContracts = { 3 | ethereum: { 4 | issued: ["0x4591dbff62656e7859afe5e45f6f47d3669fbb28"], 5 | }, 6 | }; 7 | 8 | import { addChainExports } from "../helper/getSupply"; 9 | const adapter = addChainExports(chainContracts); 10 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/prismalrt-ultra/index.ts: -------------------------------------------------------------------------------- 1 | 2 | const chainContracts = { 3 | ethereum: { 4 | issued: ["0x35282d87011f87508D457F08252Bc5bFa52E10A0"], 5 | }, 6 | }; 7 | 8 | import { addChainExports } from "../helper/getSupply"; 9 | const adapter = addChainExports(chainContracts); 10 | export default adapter; 11 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/psy/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | arbitrum: { 3 | issued: "0x63d4dc5376cfb48a885a165cd97ba208b87881c7", 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/pusd-2/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x466a756e9a7401b5e2444a3fcb3c2c12fbea0a54"], 4 | unreleased: ["0x51c2cef9efa48e08557a361b52db34061c025a1b"], 5 | }, 6 | }; 7 | 8 | import { addChainExports } from "../helper/getSupply"; 9 | const adapter = addChainExports(chainContracts); 10 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/quantoz-eurd/index.ts: -------------------------------------------------------------------------------- 1 | const sdk = require("@defillama/sdk"); 2 | import { sumSingleBalance } from "../helper/generalUtil"; 3 | import { 4 | ChainBlocks, 5 | PeggedIssuanceAdapter, 6 | Balances, ChainContracts, 7 | } from "../peggedAsset.type"; 8 | const axios = require("axios"); 9 | const retry = require("async-retry"); 10 | 11 | async function algorandMinted() { 12 | return async function ( 13 | _timestamp: number, 14 | _ethBlock: number, 15 | _chainBlocks: ChainBlocks 16 | ) { 17 | let balances = {} as Balances; 18 | const supplyRes = await retry( 19 | async (_bail: any) => 20 | await axios.get( 21 | "https://mainnet-idx.algonode.cloud/v2/assets/1221682136" 22 | ) 23 | ); 24 | const supply = supplyRes.data.asset.params.total; 25 | 26 | const reserveRes = await retry( 27 | async (_bail: any) => 28 | await axios.get( 29 | "https://mainnet-idx.algonode.cloud/v2/accounts/R2LPJRKONXXURMO6F65VHGCXPKAZM4GGDC5KH5VZ2W3ZFIZYQRAQT7GLM4" 30 | ) 31 | ); 32 | 33 | const reserveAccount = reserveRes.data.account.assets.filter( 34 | (asset: any) => asset["asset-id"] === 1221682136 35 | ); 36 | const reserves = reserveAccount[0].amount; 37 | 38 | const balance = (supply - reserves) / 10 ** 2; 39 | 40 | sumSingleBalance(balances, "peggedEUR", balance, "issued", false); 41 | return balances; 42 | }; 43 | } 44 | 45 | const adapter: PeggedIssuanceAdapter = { 46 | algorand: { 47 | minted: algorandMinted(), 48 | }, 49 | }; 50 | 51 | export default adapter; 52 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/quantoz-eurq/index.ts: -------------------------------------------------------------------------------- 1 | const sdk = require("@defillama/sdk"); 2 | import { sumSingleBalance } from "../helper/generalUtil"; 3 | import { 4 | ChainBlocks, 5 | PeggedIssuanceAdapter, 6 | Balances, ChainContracts, 7 | } from "../peggedAsset.type"; 8 | const axios = require("axios"); 9 | const retry = require("async-retry"); 10 | 11 | async function algorandMinted() { 12 | return async function ( 13 | _timestamp: number, 14 | _ethBlock: number, 15 | _chainBlocks: ChainBlocks 16 | ) { 17 | let balances = {} as Balances; 18 | const supplyRes = await retry( 19 | async (_bail: any) => 20 | await axios.get( 21 | "https://mainnet-idx.algonode.cloud/v2/assets/2768422954" 22 | ) 23 | ); 24 | const supply = supplyRes.data.asset.params.total; 25 | 26 | const reserveRes = await retry( 27 | async (_bail: any) => 28 | await axios.get( 29 | "https://mainnet-idx.algonode.cloud/v2/accounts/3PJ3E3D6XI7YWMJAUX6WDCHWZ4GC2WHTAQIWJBYVJ326LM2I6NSMSLGCDY" 30 | ) 31 | ); 32 | 33 | const reserveAccount = reserveRes.data.account.assets.filter( 34 | (asset: any) => asset["asset-id"] === 2768422954 35 | ); 36 | const reserves = reserveAccount[0].amount; 37 | 38 | const balance = (supply - reserves) / 10 ** 6; 39 | 40 | sumSingleBalance(balances, "peggedEUR", balance, "issued", false); 41 | return balances; 42 | }; 43 | } 44 | 45 | const adapter: PeggedIssuanceAdapter = { 46 | algorand: { 47 | minted: algorandMinted(), 48 | }, 49 | }; 50 | 51 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/quantoz-usdq/index.ts: -------------------------------------------------------------------------------- 1 | const sdk = require("@defillama/sdk"); 2 | import { sumSingleBalance } from "../helper/generalUtil"; 3 | import { 4 | ChainBlocks, 5 | PeggedIssuanceAdapter, 6 | Balances, ChainContracts, 7 | } from "../peggedAsset.type"; 8 | const axios = require("axios"); 9 | const retry = require("async-retry"); 10 | 11 | async function algorandMinted() { 12 | return async function ( 13 | _timestamp: number, 14 | _ethBlock: number, 15 | _chainBlocks: ChainBlocks 16 | ) { 17 | let balances = {} as Balances; 18 | const supplyRes = await retry( 19 | async (_bail: any) => 20 | await axios.get( 21 | "https://mainnet-idx.algonode.cloud/v2/assets/2768603795" 22 | ) 23 | ); 24 | const supply = supplyRes.data.asset.params.total; 25 | 26 | const reserveRes = await retry( 27 | async (_bail: any) => 28 | await axios.get( 29 | "https://mainnet-idx.algonode.cloud/v2/accounts/3PJ3E3D6XI7YWMJAUX6WDCHWZ4GC2WHTAQIWJBYVJ326LM2I6NSMSLGCDY" 30 | ) 31 | ); 32 | 33 | const reserveAccount = reserveRes.data.account.assets.filter( 34 | (asset: any) => asset["asset-id"] === 2768603795 35 | ); 36 | const reserves = reserveAccount[0].amount; 37 | 38 | const balance = (supply - reserves) / 10 ** 6; 39 | 40 | sumSingleBalance(balances, "peggedUSD", balance, "issued", false); 41 | return balances; 42 | }; 43 | } 44 | 45 | const adapter: PeggedIssuanceAdapter = { 46 | algorand: { 47 | minted: algorandMinted(), 48 | }, 49 | }; 50 | 51 | export default adapter; 52 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/quill-usd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | scroll: { 3 | issued: [ 4 | // "0x6F2A1A886Dbf8E36C4fa9F25a517861A930fBF3A", // old address 5 | "0xdb9e8f82d6d45fff803161f2a5f75543972b229a" // new address 6 | ], 7 | } 8 | }; 9 | 10 | import { addChainExports } from "../helper/getSupply"; 11 | const adapter = addChainExports(chainContracts); 12 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/r/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x183015a9bA6fF60230fdEaDc3F43b3D788b13e21"], 4 | unreleased: ["0x2ba26baE6dF1153e29813d7f926143f9c94402f3"], 5 | }, 6 | base: { 7 | issued: ["0xafb2820316e7bc5ef78d295ab9b8bb2257534576"], 8 | }, 9 | }; 10 | 11 | import { addChainExports } from "../helper/getSupply"; 12 | const adapter = addChainExports(chainContracts); 13 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/redeemable/index.ts: -------------------------------------------------------------------------------- 1 | import { 2 | PeggedIssuanceAdapter, 3 | ChainBlocks, 4 | Balances, ChainContracts, 5 | } from "../peggedAsset.type"; 6 | import { sumSingleBalance } from "../helper/generalUtil"; 7 | import { getTotalSupply } from "../helper/cardano"; 8 | 9 | const assetIDs = { 10 | cardano: { 11 | issued: [ 12 | "cd5b9dd91319edbb19477ad00cbef673a221e70a17ef043951fc678652656465656d61626c65", 13 | ], 14 | }, 15 | }; 16 | 17 | async function getCardanoSupply() { 18 | return async function ( 19 | _timestamp: number, 20 | _ethBlock: number, 21 | _chainBlocks: ChainBlocks 22 | ) { 23 | let balances = {} as Balances; 24 | const supply = await getTotalSupply(assetIDs.cardano.issued[0]); 25 | sumSingleBalance(balances, "peggedUSD", supply, "issued", false); 26 | return balances; 27 | }; 28 | } 29 | 30 | const adapter: PeggedIssuanceAdapter = { 31 | cardano: { 32 | minted: getCardanoSupply(), 33 | }, 34 | }; 35 | 36 | export default adapter; 37 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/reserve/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x196f4727526ea7fb1e17b2071b3d8eaa38486988"], 4 | }, 5 | xdai: { 6 | bridgedFromETH: ["0xD9C31db155a48f3d7304De85EC7AB7B705659bE9"], 7 | }, 8 | }; 9 | 10 | import { addChainExports } from "../helper/getSupply"; 11 | const adapter = addChainExports(chainContracts); 12 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/reservoir-stablecoin/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x09d4214c03d01f49544c0448dbe3a27f768f2b34"], 4 | } 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/resolv-usr/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x66a1e37c9b0eaddca17d3662d6c05f4decf3e110"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/resupply-usd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x57ab1e0003f623289cd798b1824be09a793e4bec"], 4 | }, 5 | }; 6 | 7 | 8 | import { addChainExports } from "../helper/getSupply"; 9 | const adapter = addChainExports(chainContracts); 10 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/revenue-generating-usd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x78da5799CF427Fee11e9996982F4150eCe7a99A7"], 4 | }, 5 | base: { 6 | bridgedFromETH: ["0x8E5E9DF4F0EA39aE5270e79bbABFCc34203A3470"], 7 | }, 8 | arbitrum: { 9 | bridgedFromETH: ["0x96a993f06951b01430523d0d5590192d650ebf3e"], 10 | }, 11 | } 12 | 13 | import { addChainExports } from "../helper/getSupply"; 14 | const adapter = addChainExports(chainContracts); 15 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/rings-scusd/index.ts: -------------------------------------------------------------------------------- 1 | 2 | const chainContracts = { 3 | sonic: { 4 | issued: ["0xd3DCe716f3eF535C5Ff8d041c1A41C3bd89b97aE"], 5 | }, 6 | }; 7 | 8 | import { addChainExports } from "../helper/getSupply"; 9 | const adapter = addChainExports(chainContracts); 10 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/ripple-usd/index.ts: -------------------------------------------------------------------------------- 1 | import { sumSingleBalance } from "../helper/generalUtil"; 2 | import { addChainExports } from "../helper/getSupply"; 3 | import { Balances, ChainContracts, ChainBlocks, PeggedIssuanceAdapter } from "../peggedAsset.type"; 4 | const axios = require("axios"); 5 | const retry = require("async-retry"); 6 | 7 | const NODE_URL = "https://xrplcluster.com"; 8 | 9 | export async function rippleMinted( 10 | _timestamp: number, 11 | _ethBlock: number, 12 | _chainBlocks: ChainBlocks 13 | ): Promise { 14 | const balances = {} as Balances; 15 | 16 | const address = "rMxCKbEDwqr76QuheSUMdEGf4B9xJ8m5De"; 17 | const tokenCurrency = "524C555344000000000000000000000000000000"; 18 | 19 | const payload = { 20 | method: "gateway_balances", 21 | params: [ 22 | { 23 | account: address, 24 | ledger_index: "validated", 25 | }, 26 | ], 27 | }; 28 | 29 | const res = await retry(async (_bail: any) => axios.post(NODE_URL, payload)); 30 | 31 | const supplyStr = res.data.result.obligations[tokenCurrency]; 32 | const supply = parseFloat(supplyStr); 33 | 34 | sumSingleBalance(balances, "peggedUSD", supply, "issued"); 35 | 36 | return balances; 37 | } 38 | 39 | const chainContracts: ChainContracts = { 40 | ethereum: { 41 | issued: ["0x8292bb45bf1ee4d140127049757c2e0ff06317ed"], 42 | }, 43 | }; 44 | 45 | const adapter: PeggedIssuanceAdapter = { 46 | ...addChainExports(chainContracts, undefined), 47 | 48 | ripple: { 49 | minted: rippleMinted, 50 | }, 51 | }; 52 | 53 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/sable-coin/index.ts: -------------------------------------------------------------------------------- 1 | 2 | const chainContracts = { 3 | bsc: { 4 | issued: ["0x0c6Ed1E73BA73B8441868538E210ebD5DD240FA0"], 5 | }, 6 | base: { 7 | issued: ["0xecf3e9B8ccb6F4A6EFD68058FD706561c1727031"], 8 | }, 9 | }; 10 | 11 | import { addChainExports } from "../helper/getSupply"; 12 | const adapter = addChainExports(chainContracts); 13 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/satoshi-stablecoin/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = 2 | { 3 | bevm: { 4 | issued: [ 5 | "0xF2692468666E459D87052f68aE474E36C1a34fbB", // V1 6 | "0x2031c8848775a5EFB7cfF2A4EdBE3F04c50A1478", // V2 7 | ], 8 | }, 9 | btr: { 10 | issued: [ 11 | "0xa1e63CB2CE698CfD3c2Ac6704813e3b870FEDADf", // V1 12 | "0xba50dDac6B2F5482cA064EFAc621E0C7c0f6A783", // V2 13 | ], 14 | }, 15 | bob: { 16 | issued: [ 17 | "0x78Fea795cBFcC5fFD6Fb5B845a4f53d25C283bDB", // V1 18 | "0xecf21b335B41f9d5A89f6186A99c19a3c467871f", // V2 19 | ], 20 | }, 21 | bsquared: { 22 | issued: [ 23 | "0x62b4B8F5a03e40b9dAAf95c7A6214969406e28c3", // V1 24 | "0x8dD8b12d55C73c08294664a5915475eD1c8b1F6f", // V2 25 | ], 26 | }, 27 | bsc: { 28 | issued: [ 29 | "0xb4818BB69478730EF4e33Cc068dD94278e2766cB", // V2 30 | ], 31 | }, 32 | hemi: { 33 | issued: [ 34 | "0xb4818BB69478730EF4e33Cc068dD94278e2766cB", // V2 35 | ], 36 | }, 37 | base: { 38 | issued: [ 39 | "0x70654AaD8B7734dc319d0C3608ec7B32e03FA162", // V2 40 | ], 41 | }, 42 | arbitrum: { 43 | issued: [ 44 | "0xb4818BB69478730EF4e33Cc068dD94278e2766cB", // V2 45 | ], 46 | }, 47 | }; 48 | 49 | import { addChainExports } from "../helper/getSupply"; 50 | const adapter = addChainExports(chainContracts); 51 | export default adapter; 52 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/savvy-usd/index.ts: -------------------------------------------------------------------------------- 1 | 2 | const chainContracts = { 3 | arbitrum: { 4 | issued: ["0xF202Ab403Cd7E90197ec0f010ee897E283037706"], 5 | }, 6 | }; 7 | 8 | import { addChainExports } from "../helper/getSupply"; 9 | const adapter = addChainExports(chainContracts); 10 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/schuman-europ/index.ts: -------------------------------------------------------------------------------- 1 | const sdk = require("@defillama/sdk"); 2 | import { sumSingleBalance } from "../helper/generalUtil"; 3 | import { 4 | ChainBlocks, 5 | PeggedIssuanceAdapter, 6 | Balances, ChainContracts, 7 | } from "../peggedAsset.type"; 8 | 9 | 10 | const chainContracts: ChainContracts = { 11 | ethereum: { 12 | issued: ["0x888883b5F5D21fb10Dfeb70e8f9722B9FB0E5E51"], 13 | }, 14 | polygon: { 15 | issued: ["0x888883b5F5D21fb10Dfeb70e8f9722B9FB0E5E51"], 16 | }, 17 | }; 18 | 19 | async function chainMinted(chain: string, decimals: number) { 20 | return async function ( 21 | _timestamp: number, 22 | _ethBlock: number, 23 | _chainBlocks: ChainBlocks 24 | ) { 25 | let balances = {} as Balances; 26 | for (let issued of chainContracts[chain].issued) { 27 | const totalSupply = ( 28 | await sdk.api.abi.call({ 29 | abi: "erc20:totalSupply", 30 | target: issued, 31 | block: _chainBlocks?.[chain], 32 | chain: chain, 33 | }) 34 | ).output; 35 | sumSingleBalance( 36 | balances, 37 | "peggedEUR", 38 | totalSupply / 10 ** decimals, 39 | "issued", 40 | false 41 | ); 42 | } 43 | return balances; 44 | }; 45 | } 46 | 47 | const adapter: PeggedIssuanceAdapter = { 48 | ethereum: { 49 | minted: chainMinted("ethereum", 6), 50 | }, 51 | polygon: { 52 | minted: chainMinted("polygon", 6), 53 | }, 54 | }; 55 | 56 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/sdai/index.ts: -------------------------------------------------------------------------------- 1 | 2 | const chainContracts = { 3 | xdai: { 4 | issued: ["0xaf204776c7245bF4147c2612BF6e5972Ee483701"], 5 | }, 6 | }; 7 | 8 | import { addChainExports } from "../helper/getSupply"; 9 | const adapter = addChainExports(chainContracts); 10 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/seur/index.ts: -------------------------------------------------------------------------------- 1 | 2 | const chainContracts = { 3 | ethereum: { 4 | issued: ["0xd71ecff9342a5ced620049e616c5035f1db98620"], 5 | }, 6 | optimism: { 7 | issued: ["0xFBc4198702E81aE77c06D58f81b629BDf36f0a71"], 8 | }, 9 | }; 10 | 11 | import { addChainExports } from "../helper/getSupply"; 12 | const adapter = addChainExports(chainContracts, undefined, { pegType: "peggedEUR" }); 13 | export default adapter; 14 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/sigmausd/index.ts: -------------------------------------------------------------------------------- 1 | import { sumSingleBalance } from "../helper/generalUtil"; 2 | import { 3 | ChainBlocks, 4 | PeggedIssuanceAdapter, 5 | Balances, ChainContracts, 6 | } from "../peggedAsset.type"; 7 | const axios = require("axios"); 8 | const retry = require("async-retry"); 9 | 10 | 11 | const chainContracts: ChainContracts = {}; 12 | 13 | // There appears to be no explorer API that can give total supply; this endpoint was provided by dev. 14 | async function ergoMinted(decimals: number) { 15 | return async function ( 16 | _timestamp: number, 17 | _ethBlock: number, 18 | _chainBlocks: ChainBlocks 19 | ) { 20 | let balances = {} as Balances; 21 | const res = await retry( 22 | async (_bail: any) => 23 | await axios.get("https://api.ergo.watch/sigmausd/state") 24 | ); 25 | const supply = res.data.circ_sigusd / 10 ** decimals; 26 | sumSingleBalance(balances, "peggedUSD", supply, "issued", false); 27 | return balances; 28 | }; 29 | } 30 | 31 | const adapter: PeggedIssuanceAdapter = { 32 | ergo: { 33 | minted: ergoMinted(0), 34 | }, 35 | }; 36 | 37 | export default adapter; 38 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/silk/index.ts: -------------------------------------------------------------------------------- 1 | import { sumSingleBalance } from "../helper/generalUtil"; 2 | import { 3 | ChainBlocks, 4 | PeggedIssuanceAdapter, 5 | Balances, ChainContracts, 6 | } from "../peggedAsset.type"; 7 | const axios = require("axios"); 8 | const retry = require("async-retry"); 9 | 10 | // There appears to be no explorer API that can give total supply; this endpoint was provided by dev. 11 | async function silkMinted(decimals: number) { 12 | return async function ( 13 | _timestamp: number, 14 | _ethBlock: number, 15 | _chainBlocks: ChainBlocks 16 | ) { 17 | let balances = {} as Balances; 18 | const res = await retry( 19 | async (_bail: any) => 20 | await axios.get( 21 | "https://ruvzuawwz7.execute-api.us-east-1.amazonaws.com/prod-analytics-v1/silk" 22 | ) 23 | ); 24 | const totalSupply = res?.data?.totalUsd; 25 | const supply = totalSupply / 10 ** decimals; 26 | sumSingleBalance(balances, "peggedVAR", supply, "issued", false); 27 | return balances; 28 | }; 29 | } 30 | 31 | const adapter: PeggedIssuanceAdapter = { 32 | secret: { 33 | minted: silkMinted(0), 34 | }, 35 | }; 36 | 37 | export default adapter; 38 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/societe-generale-forge-eurcv/config.ts: -------------------------------------------------------------------------------- 1 | import {ChainContracts} from "../peggedAsset.type"; 2 | 3 | export const chainContracts: ChainContracts = { 4 | ethereum: { 5 | issued: ["0x5F7827FDeb7c20b443265Fc2F40845B715385Ff2"], 6 | unreleased: ["0xc98Cb9F53e20AFbbeb75Caf6456eD52D5d7903f6", "0x7dE0bbdfCd4A6a956F149bEFcca30D6B5Bc5DA69"], // Operation registrar 7 | }, 8 | solana: { 9 | issued: ["DghpMkatCiUsofbTmid3M3kAbDTPqDwKiYHnudXeGG52"], // mainnet token 10 | unreleased: ["4N1WwAaSukn7YtRKRArA3Ntp4CfcB1nCiqCDGEjEBhEj", "5tg4qRdiXJ7XxYd6KK4UnnNvxgHJqfBUygPqZLwSnhnt"], // Operation registrar 11 | } 12 | } -------------------------------------------------------------------------------- /src/adapters/peggedAssets/solayer-usd/index.ts: -------------------------------------------------------------------------------- 1 | import { PeggedIssuanceAdapter } from "../peggedAsset.type"; 2 | import { solanaMintedOrBridged } from "../helper/getSupply"; 3 | 4 | const adapter: PeggedIssuanceAdapter = { 5 | solana: { 6 | minted: solanaMintedOrBridged([ 7 | "susdabGDNbhrnCa6ncrYo81u4s9GM8ecK2UwMyZiq4X", 8 | ]), 9 | }, 10 | }; 11 | 12 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/solomon-usdv/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | solana: { 3 | issued: ["Ex5DaKYMCN6QWFA4n67TmMwsH8MJV68RX6YXTmVM532C"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts, undefined, { decimals: 9 }); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/sovryn-dollar/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | rsk: { 3 | issued: ["0xc1411567d2670e24d9c4daaa7cda95686e1250aa"], 4 | }, 5 | }; 6 | import { addChainExports } from "../helper/getSupply"; 7 | const adapter = addChainExports(chainContracts); 8 | export default adapter; 9 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/sperax-usd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | arbitrum: { 3 | issued: ["0xd74f5255d557944cf7dd0e45ff521520002d5748"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/spiceusd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | avax: { 3 | issued: ["0xab05b04743e0aeaf9d2ca81e5d3b8385e4bf961e"], 4 | }, 5 | ethereum: { 6 | issued: ["0x45fdb1b92a649fb6a64ef1511d3ba5bf60044838"], 7 | unreleased: ["0xe85131becf5298db58d60e5d628f2c927c7f88cc"], 8 | }, 9 | polygon: { 10 | issued: ["0x2f1b1662a895c6ba01a99dcaf56778e7d77e5609"], 11 | }, 12 | bsc: { 13 | issued: ["0xde7d1ce109236b12809c45b23d22f30dba0ef424"], 14 | }, 15 | } 16 | 17 | import { addChainExports } from "../helper/getSupply"; 18 | const adapter = addChainExports(chainContracts); 19 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/stabl-fi/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | polygon: { 3 | issued: [ 4 | "0x80487b4f8f70e793a81a42367c225ee0b94315df", 5 | "0x5D066D022EDE10eFa2717eD3D79f22F949F8C175", 6 | ], 7 | }, 8 | } 9 | 10 | import { addChainExports } from "../helper/getSupply"; 11 | const adapter = addChainExports(chainContracts); 12 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/stable-jack-ausd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | avax: { 3 | issued: ["0xaBe7a9dFDA35230ff60D1590a929aE0644c47DC1"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; 10 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/stablr-euro/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x50753CfAf86c094925Bf976f218D043f8791e408", "0xdaC306D72f48dbaD805a11CBf7A512A277C084C9"], 4 | }, 5 | solana: { 6 | issued: ["HViRSvsTpwubWHevjSPxNB22Fg3kdzXtedfQXmMoHtoZ"], 7 | } 8 | }; 9 | import { addChainExports } from "../helper/getSupply"; 10 | const adapter = addChainExports(chainContracts, undefined, {pegType: "peggedEUR"}); 11 | export default adapter; 12 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/stablr-usd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x7B43E3875440B44613DC3bC08E7763e6Da63C8f8"], 4 | }, 5 | }; 6 | import { addChainExports } from "../helper/getSupply"; 7 | const adapter = addChainExports(chainContracts, undefined, {pegType: "peggedUSD"}); 8 | export default adapter; 9 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/standx-dusd/index.ts: -------------------------------------------------------------------------------- 1 | import { ChainApi } from '@defillama/sdk'; 2 | import { sumSingleBalance } from "../helper/generalUtil"; 3 | import { getApi, solanaMintedOrBridged } from "../helper/getSupply"; 4 | import { Balances, PeggedIssuanceAdapter } from "../peggedAsset.type"; 5 | 6 | function chainMinted(chain: string, address: string) { 7 | return async function (_api: ChainApi) { 8 | const api = await getApi(chain, _api) 9 | let balances = {} as Balances; 10 | const issued = await api.multiCall({ abi: "erc20:totalSupply", calls: [{ target: address }] }) 11 | const decimals = await api.multiCall({ abi: "erc20:decimals", calls: [{ target: address }] }) 12 | 13 | for (let i = 0; i < issued.length; i++) 14 | sumSingleBalance(balances, "peggedUSD", issued[i] / 10 ** decimals[i], "issued", false); 15 | 16 | return balances; 17 | }; 18 | } 19 | 20 | const adapter: PeggedIssuanceAdapter = { 21 | solana: { 22 | minted: solanaMintedOrBridged([ 23 | "DUSDt4AeLZHWYmcXnVGYdgAzjtzU5mXUVnTMdnSzAttM", 24 | ]), 25 | }, 26 | bsc: { 27 | minted: chainMinted("bsc", "0xaf44A1E76F56eE12ADBB7ba8acD3CbD474888122"), 28 | }, 29 | }; 30 | 31 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/star/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | arbitrum: { 3 | issued: ["0xC19669A405067927865B40Ea045a2baabbbe57f5"], 4 | }, 5 | polygon: { 6 | issued: ["0xC19669A405067927865B40Ea045a2baabbbe57f5"], 7 | }, 8 | base: { 9 | issued: ["0xC19669A405067927865B40Ea045a2baabbbe57f5"], 10 | }, 11 | } 12 | 13 | import { addChainExports } from "../helper/getSupply"; 14 | const adapter = addChainExports(chainContracts); 15 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/syusd/index.ts: -------------------------------------------------------------------------------- 1 | import { addChainExports } from "../helper/getSupply"; 2 | import { PeggedIssuanceAdapter } from "../peggedAsset.type"; 3 | 4 | const chainContracts = { 5 | sei: { 6 | issued: ["0x059A6b0bA116c63191182a0956cF697d0d2213eC"], 7 | } 8 | }; 9 | 10 | const adapter: PeggedIssuanceAdapter = { 11 | ...addChainExports(chainContracts), 12 | }; 13 | 14 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/tbill/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0xad6250f0bd49f7a1eb11063af2ce9f25b9597b0f"], 4 | }, 5 | } 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/thestandard-usd/index.ts: -------------------------------------------------------------------------------- 1 | import { addChainExports } from "../helper/getSupply"; 2 | import { PeggedIssuanceAdapter } from "../peggedAsset.type"; 3 | 4 | const adapter: PeggedIssuanceAdapter = { 5 | ...addChainExports({ 6 | arbitrum: { 7 | issued: ["0x2Ea0bE86990E8Dac0D09e4316Bb92086F304622d"] 8 | } 9 | }) 10 | } 11 | 12 | export default adapter; 13 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/three-usd/index.ts: -------------------------------------------------------------------------------- 1 | const sdk = require("@defillama/sdk"); 2 | import { sumSingleBalance } from "../helper/generalUtil"; 3 | import { 4 | ChainBlocks, 5 | PeggedIssuanceAdapter, 6 | Balances, ChainContracts, 7 | } from "../peggedAsset.type"; 8 | const axios = require("axios"); 9 | const retry = require("async-retry"); 10 | 11 | 12 | const chainContracts: ChainContracts = { 13 | karura: { 14 | issued: ["0x0000000000000000000300000000000000000001"], 15 | }, 16 | }; 17 | 18 | async function karuraMinted(address: string, decimals: number) { 19 | return async function ( 20 | _timestamp: number, 21 | _ethBlock: number, 22 | _chainBlocks: ChainBlocks 23 | ) { 24 | let balances = {} as Balances; 25 | const res = await retry( 26 | async (_bail: any) => 27 | await axios.get( 28 | `https://blockscout.karura.network/api?module=token&action=getToken&contractaddress=getToken&contractaddress=${address}` 29 | ) 30 | ); 31 | const supply = res.data.result.totalSupply / 10 ** decimals; 32 | sumSingleBalance(balances, "peggedUSD", supply, "issued", false); 33 | return balances; 34 | }; 35 | } 36 | 37 | const adapter: PeggedIssuanceAdapter = { 38 | karura: { 39 | minted: karuraMinted(chainContracts.karura.issued[0], 12), 40 | }, 41 | }; 42 | 43 | export default adapter; 44 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/threshold-usd/index.ts: -------------------------------------------------------------------------------- 1 | import { 2 | PeggedIssuanceAdapter, 3 | Balances, 4 | } from "../peggedAsset.type"; 5 | import { sumSingleBalance } from "../helper/generalUtil"; 6 | import { ChainApi } from "@defillama/sdk"; 7 | 8 | const chainContracts = { 9 | ethereum: { 10 | issued: ["0xcfc5bd99915aaa815401c5a41a927ab7a38d29cf"], 11 | pcvContracts: [ 12 | "0x097f1ee62E63aCFC3Bf64c1a61d96B3771dd06cB", // Protocol Controlled Value tBTC Collateral 13 | "0x1a4739509F50E683927472b03e251e36d07DD872", // Protocol Controlled Value ETH Collateral 14 | ], 15 | }, 16 | }; 17 | 18 | async function ethereumMinted() { 19 | return async function (api: ChainApi) { 20 | let balances = {} as Balances; 21 | const totalSupply = await api.call({ abi: "erc20:totalSupply", target: chainContracts.ethereum.issued[0], }) 22 | sumSingleBalance(balances, "peggedUSD", totalSupply / 1e18, "issued", false); 23 | return balances; 24 | }; 25 | } 26 | 27 | async function ethereumUnreleased() { 28 | return async function (api: ChainApi) { 29 | let balances = {} as Balances; 30 | const debts = await api.multiCall({ abi: 'uint256:debtToPay', calls: chainContracts.ethereum.pcvContracts}) 31 | for (const debt of debts) 32 | sumSingleBalance(balances, "peggedUSD", debt / 1e18) 33 | return balances; 34 | }; 35 | } 36 | 37 | const adapter: PeggedIssuanceAdapter = { 38 | ethereum: { 39 | minted: ethereumMinted(), 40 | unreleased: ethereumUnreleased(), 41 | }, 42 | }; 43 | 44 | export default adapter; 45 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/tor/index.ts: -------------------------------------------------------------------------------- 1 | // TOR has a Multichain bridge to Ethereum, BSC, and Avax, but their contract addresses have not been found. 2 | // Their Discord did not help provide them. 3 | const chainContracts = { 4 | fantom: { 5 | issued: ["0x74e23df9110aa9ea0b6ff2faee01e740ca1c642e"], 6 | }, 7 | }; 8 | 9 | import { addChainExports } from "../helper/getSupply"; 10 | const adapter = addChainExports(chainContracts); 11 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/tren-debt-token/index.ts: -------------------------------------------------------------------------------- 1 | //const sdk = require("@defillama/sdk"); 2 | 3 | /*const chainContracts = { 4 | arbitrum: { 5 | minted: "0xD4fe6e1e37dfCf35E9EEb54D4cca149d1c10239f", 6 | curvePool: "0x2b2e23b7c1b0de9040011b860cc575650d0817f7", 7 | }, 8 | ethereum: { 9 | bridgedFromArbitrum: "0xe9766D6aed0A73255f95ACC1F263156e746B70ba", 10 | }, 11 | };*/ 12 | 13 | 14 | 15 | const chainContracts = { 16 | arbitrum: { 17 | issued: ["0xD4fe6e1e37dfCf35E9EEb54D4cca149d1c10239f"], 18 | }, 19 | }; 20 | 21 | import { addChainExports } from "../helper/getSupply"; 22 | const adapter = addChainExports(chainContracts); 23 | export default adapter; 24 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/uaht/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | polygon: { 3 | issued: ["0x0d9447e16072b636b4a1e8f2b8c644e58f3eaa6a"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts, undefined, { pegType: 'peggedUAH' }); 9 | export default adapter; 10 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/usc-2/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x38547d918b9645f2d94336b6b61aeb08053e142c"], 4 | } 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/usd-balance/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | fantom: { 3 | issued: ["0x6Fc9383486c163fA48becdEC79d6058f984f62cA"], 4 | unreleased: [ 5 | "0xa3b52d5a6d2f8932a5cd921e09da840092349d71", // DAO treasury 6 | "0x34f93b12ca2e13c6e64f45cfa36eabadd0ba30fc", // DAO multisig 7 | ], 8 | }, 9 | }; 10 | 11 | import { addChainExports } from "../helper/getSupply"; 12 | const adapter = addChainExports(chainContracts); 13 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/usd-rif/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | rsk: { 3 | issued: ["0x3a15461d8ae0f0fb5fa2629e9da7d66a794a6e37"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; 10 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/usd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | polygon: { 3 | issued: ["0x236eec6359fb44cce8f97e99387aa7f8cd5cde1f"], 4 | }, 5 | bsc: { 6 | issued: ["0xe80772Eaf6e2E18B651F160Bc9158b2A5caFCA65"], 7 | }, 8 | arbitrum: { 9 | issued: ["0xe80772Eaf6e2E18B651F160Bc9158b2A5caFCA65"], 10 | }, 11 | optimism: { 12 | issued: ["0x73cb180bf0521828d8849bc8CF2B920918e23032"], 13 | }, 14 | era: { 15 | issued: ["0x8E86e46278518EFc1C5CEd245cBA2C7e3ef11557"], 16 | }, 17 | avax: { 18 | issued: ["0xe80772Eaf6e2E18B651F160Bc9158b2A5caFCA65"], 19 | }, 20 | linea: { 21 | issued: ["0xB79DD08EA68A908A97220C76d19A6aA9cBDE4376"], 22 | }, 23 | base: { 24 | issued: ["0xB79DD08EA68A908A97220C76d19A6aA9cBDE4376"], 25 | }, 26 | blast: { 27 | issued: [ 28 | "0x4fEE793d435c6D2c10C135983BB9d6D4fC7B9BBd", 29 | "0x870a8F46b62B8BDeda4c02530C1750CddF2ED32e", 30 | ], 31 | }, 32 | }; 33 | 34 | import { addChainExports } from "../helper/getSupply"; 35 | const adapter = addChainExports(chainContracts); 36 | export default adapter; 37 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/usd1-wlfi/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | bsc: { 3 | issued: ["0x8d0D000Ee44948FC98c9B98A4FA4921476f08B0d"], 4 | }, 5 | ethereum: { 6 | issued: ["0x8d0D000Ee44948FC98c9B98A4FA4921476f08B0d"], 7 | }, 8 | }; 9 | 10 | import { addChainExports } from "../helper/getSupply"; 11 | const adapter = addChainExports(chainContracts); 12 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/usd2/index.ts: -------------------------------------------------------------------------------- 1 | const Pact = require("pact-lang-api"); 2 | const creationTime = () => Math.round(new Date().getTime() / 1000) - 10; 3 | import { sumSingleBalance } from "../helper/generalUtil"; 4 | import { PeggedIssuanceAdapter, Balances } from "../peggedAsset.type"; 5 | 6 | let net = `https://api.chainweb.com/chainweb/0.0/mainnet01/chain/1/pact`; 7 | 8 | async function supplyMinted() { 9 | return async function () { 10 | let balances = {} as Balances; 11 | 12 | let usd2supply: any; 13 | let totalSupply: any; 14 | 15 | let data = await Pact.fetch.local( 16 | { 17 | pactCode: `(lago.USD2-wrapper.return-supply "lago.USD2") `, 18 | meta: Pact.lang.mkMeta("", "1", 0.01, 100000000, 28800, creationTime()), 19 | }, 20 | net 21 | ); 22 | if (data.result.status === "success") { 23 | usd2supply = parseFloat(data.result.data); 24 | } 25 | 26 | totalSupply = usd2supply; 27 | 28 | sumSingleBalance(balances, "peggedUSD", totalSupply, "issued", false); 29 | return balances; 30 | }; 31 | } 32 | 33 | const adapter: PeggedIssuanceAdapter = { 34 | kadena: { 35 | minted: supplyMinted(), 36 | }, 37 | }; 38 | 39 | export default adapter; 40 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/usdb/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | blast: { 3 | issued: ["0x4300000000000000000000000000000000000003"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; 10 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/usdfc/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | filecoin: { 3 | issued: ["0x80B98d3aa09ffff255c3ba4A241111Ff1262F045"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/usdh/index.ts: -------------------------------------------------------------------------------- 1 | const sdk = require("@defillama/sdk"); 2 | import { PeggedIssuanceAdapter } from "../peggedAsset.type"; 3 | import { solanaMintedOrBridged } from "../helper/getSupply"; 4 | 5 | const chainContracts = { 6 | solana: { 7 | issued: ["USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"], 8 | }, 9 | }; 10 | 11 | const adapter: PeggedIssuanceAdapter = { 12 | solana: { 13 | minted: solanaMintedOrBridged(chainContracts.solana.issued), 14 | }, 15 | }; 16 | 17 | export default adapter; 18 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/usdlemma/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | arbitrum: { 3 | issued: ["0xdb41ab644AbcA7f5ac579A5Cf2F41e606C2d6abc"], 4 | }, 5 | optimism: { 6 | issued: ["0x96F2539d3684dbde8B3242A51A73B66360a5B541"], 7 | }, 8 | }; 9 | 10 | import { addChainExports } from "../helper/getSupply"; 11 | const adapter = addChainExports(chainContracts); 12 | export default adapter; 13 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/usdm/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: "0x59d9356e565ab3a36dd77763fc0d87feaf85508c", 4 | }, 5 | polygon: { 6 | issued: "0x59d9356e565ab3a36dd77763fc0d87feaf85508c", 7 | }, 8 | base: { 9 | issued: "0x59d9356e565ab3a36dd77763fc0d87feaf85508c", 10 | }, 11 | optimism: { 12 | issued: "0x59d9356e565ab3a36dd77763fc0d87feaf85508c", 13 | }, 14 | arbitrum: { 15 | issued: "0x59d9356e565ab3a36dd77763fc0d87feaf85508c", 16 | }, 17 | era: { 18 | issued: "0x7715c206A14Ac93Cb1A6c0316A6E5f8aD7c9Dc31", 19 | }, 20 | }; 21 | 22 | 23 | import { addChainExports } from "../helper/getSupply"; 24 | const adapter = addChainExports(chainContracts); 25 | export default adapter; 26 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/usdp/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x1456688345527be1f37e9e627da0837d6f08c925"], 4 | }, 5 | xdai: { 6 | bridgedFromETH: ["0xFe7ed09C4956f7cdb54eC4ffCB9818Db2D7025b8"], 7 | }, 8 | bsc: { 9 | issued: ["0xDACD011A71f8c9619642bf482f1D4CeB338cfFCf"], 10 | }, 11 | fantom: { 12 | issued: ["0x3129aC70c738D398d1D74c87EAB9483FD56D16f8"], 13 | }, 14 | }; 15 | 16 | import { addChainExports } from "../helper/getSupply"; 17 | const adapter = addChainExports(chainContracts); 18 | export default adapter; 19 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/usds/index.ts: -------------------------------------------------------------------------------- 1 | import { addChainExports,solanaMintedOrBridged } from "../helper/getSupply"; 2 | import { PeggedIssuanceAdapter } from "../peggedAsset.type"; 3 | 4 | const chainContracts = { 5 | ethereum: { 6 | issued: ["0xdC035D45d973E3EC169d2276DDab16f1e407384F"], 7 | }, 8 | base: { 9 | issued: ["0x820c137fa70c8691f0e44dc420a5e53c168921dc"], 10 | }, 11 | arbitrum: { 12 | bridgedFromETH: ["0x6491c05A82219b8D1479057361ff1654749b876b"], 13 | }, 14 | }; 15 | 16 | 17 | const adapter: PeggedIssuanceAdapter = { 18 | ...addChainExports(chainContracts), 19 | 20 | solana: { 21 | ethereum: solanaMintedOrBridged(["USDSwr9ApdHk5bvJKMjzff41FfuX8bSxdKcR81vTwcA"]), 22 | }, 23 | }; 24 | 25 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/usdtb/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: "0xC139190F447e929f090Edeb554D95AbB8b18aC1C", 4 | }, 5 | }; 6 | 7 | 8 | import { addChainExports } from "../helper/getSupply"; 9 | const adapter = addChainExports(chainContracts); 10 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/usdtez/index.ts: -------------------------------------------------------------------------------- 1 | const sdk = require("@defillama/sdk"); 2 | import { sumSingleBalance } from "../helper/generalUtil"; 3 | import { 4 | ChainBlocks, 5 | PeggedIssuanceAdapter, 6 | Balances, ChainContracts, 7 | } from "../peggedAsset.type"; 8 | import { getTotalSupply as tezosGetTotalSupply } from "../helper/tezos"; 9 | 10 | 11 | const chainContracts: ChainContracts = { 12 | tezos: { 13 | issued: ["KT1LN4LPSqTMS7Sd2CJw4bbDGRkMv2t68Fy9"], 14 | }, 15 | }; 16 | 17 | async function tezosMinted(tokenID: string) { 18 | return async function ( 19 | _timestamp: number, 20 | _ethBlock: number, 21 | _chainBlocks: ChainBlocks 22 | ) { 23 | let balances = {} as Balances; 24 | const totalSupply = await tezosGetTotalSupply(tokenID); 25 | sumSingleBalance(balances, "peggedUSD", totalSupply, "issued", false); 26 | return balances; 27 | }; 28 | } 29 | 30 | const adapter: PeggedIssuanceAdapter = { 31 | tezos: { 32 | minted: tezosMinted(chainContracts.tezos.issued[0]), 33 | }, 34 | }; 35 | 36 | export default adapter; 37 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/usdtplus/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | bsc: { 3 | issued: ["0x5335E87930b410b8C5BB4D43c3360ACa15ec0C8C"], 4 | }, 5 | linea: { 6 | issued: ["0x1E1F509963A6D33e169D9497b11c7DbFe73B7F13"], 7 | }, 8 | arbitrum: { 9 | issued: ["0xb1084db8D3C05CEbd5FA9335dF95EE4b8a0edc30"], 10 | }, 11 | }; 12 | 13 | import { addChainExports } from "../helper/getSupply"; 14 | const adapter = addChainExports(chainContracts); 15 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/usdw/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethpow: { 3 | issued: ["0x520A36eE3aa0b506288915f91Fb4BBB23d09a7D7"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/usdx-money-usdx/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0xf3527ef8dE265eAa3716FB312c12847bFBA66Cef"], 4 | }, 5 | bsc: { 6 | issued: ["0xf3527ef8dE265eAa3716FB312c12847bFBA66Cef"], 7 | }, 8 | arbitrum: { 9 | issued: ["0xf3527ef8dE265eAa3716FB312c12847bFBA66Cef"], 10 | }, 11 | }; 12 | import { addChainExports } from "../helper/getSupply"; 13 | const adapter = addChainExports(chainContracts); 14 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/usdx/index.ts: -------------------------------------------------------------------------------- 1 | const sdk = require("@defillama/sdk"); 2 | import { sumSingleBalance } from "../helper/generalUtil"; 3 | import { 4 | ChainBlocks, 5 | PeggedIssuanceAdapter, 6 | Balances, ChainContracts, 7 | } from "../peggedAsset.type"; 8 | const axios = require("axios"); 9 | const retry = require("async-retry"); 10 | 11 | 12 | const chainContracts: ChainContracts = {}; 13 | 14 | // If there is any Mintscan (or other) API that can be used, it should replace this. 15 | async function kavaMinted() { 16 | return async function ( 17 | _timestamp: number, 18 | _ethBlock: number, 19 | _chainBlocks: ChainBlocks 20 | ) { 21 | let balances = {} as Balances; 22 | const res = await retry( 23 | async (_bail: any) => 24 | await axios.get("https://api.kava.io/vesting/circulatingsupplyusdx") 25 | ); 26 | const supply = res.data; 27 | sumSingleBalance(balances, "peggedUSD", supply, "issued", false); 28 | return balances; 29 | }; 30 | } 31 | 32 | const adapter: PeggedIssuanceAdapter = { 33 | kava: { 34 | minted: kavaMinted(), 35 | }, 36 | }; 37 | 38 | export default adapter; 39 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/usk/index.ts: -------------------------------------------------------------------------------- 1 | import { sumSingleBalance } from "../helper/generalUtil"; 2 | import { osmosisSupply } from "../helper/getSupply"; 3 | import { 4 | Balances, 5 | ChainBlocks, 6 | PeggedIssuanceAdapter, ChainContracts, 7 | } from "../peggedAsset.type"; 8 | const axios = require("axios"); 9 | const retry = require("async-retry"); 10 | 11 | 12 | const chainContracts: ChainContracts = { 13 | osmosis: { 14 | bridgedFromKujira: [ 15 | "ibc/44492EAB24B72E3FB59B9FA619A22337FB74F95D8808FE6BC78CC0E6C18DC2EC", 16 | ], 17 | }, 18 | }; 19 | 20 | // There appears to be no explorer API that can give total supply; this endpoint was provided by dev. 21 | async function kujiraMinted(decimals: number) { 22 | return async function ( 23 | _timestamp: number, 24 | _ethBlock: number, 25 | _chainBlocks: ChainBlocks 26 | ) { 27 | let balances = {} as Balances; 28 | const res = await retry( 29 | async (_bail: any) => 30 | await axios.get( 31 | "https://rest.cosmos.directory/kujira/cosmos/bank/v1beta1/supply/by_denom?denom=factory%2Fkujira1qk00h5atutpsv900x202pxx42npjr9thg58dnqpa72f2p7m2luase444a7%2Fuusk" 32 | ) 33 | ); 34 | const uskInfo = res?.data?.amount; 35 | const supply = uskInfo?.amount / 10 ** decimals; 36 | sumSingleBalance(balances, "peggedUSD", supply, "issued", false); 37 | return balances; 38 | }; 39 | } 40 | 41 | const adapter: PeggedIssuanceAdapter = { 42 | kujira: { 43 | minted: kujiraMinted(6), 44 | }, 45 | osmosis: { 46 | kujira: osmosisSupply( 47 | chainContracts.osmosis.bridgedFromKujira, 48 | 6, 49 | "Kujira" 50 | ), 51 | }, 52 | }; 53 | 54 | export default adapter; 55 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/usn/index.ts: -------------------------------------------------------------------------------- 1 | const sdk = require("@defillama/sdk"); 2 | import { sumSingleBalance } from "../helper/generalUtil"; 3 | import { 4 | ChainBlocks, 5 | PeggedIssuanceAdapter, 6 | Balances, ChainContracts, 7 | } from "../peggedAsset.type"; 8 | import { call } from "../helper/near"; 9 | import { bridgedSupply } from "../helper/getSupply"; 10 | 11 | 12 | const chainContracts: ChainContracts = { 13 | near: { 14 | issued: ["usn"], 15 | }, 16 | aurora: { 17 | bridgedFromNear: ["0x5183e1B1091804BC2602586919E6880ac1cf2896"], 18 | }, 19 | }; 20 | 21 | async function chainMinted(chain: string, decimals: number) { 22 | return async function ( 23 | _timestamp: number, 24 | _ethBlock: number, 25 | _chainBlocks: ChainBlocks 26 | ) { 27 | let balances = {} as Balances; 28 | for (let issued of chainContracts[chain].issued) { 29 | const totalSupply = await call(issued, "ft_total_supply"); 30 | 31 | sumSingleBalance( 32 | balances, 33 | "peggedUSD", 34 | totalSupply / 10 ** decimals, 35 | "issued", 36 | false 37 | ); 38 | } 39 | return balances; 40 | }; 41 | } 42 | 43 | const adapter: PeggedIssuanceAdapter = { 44 | near: { 45 | minted: chainMinted("near", 18), 46 | }, 47 | aurora: { 48 | near: bridgedSupply("aurora", 18, chainContracts.aurora.bridgedFromNear), 49 | }, 50 | }; 51 | 52 | export default adapter; 53 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/usual-usd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x73A15FeD60Bf67631dC6cd7Bc5B6e8da8190aCF5"], 4 | }, 5 | arbitrum: { 6 | issued: ["0x35f1C5cB7Fb977E669fD244C567Da99d8a3a6850"], 7 | }, 8 | }; 9 | import { addChainExports } from "../helper/getSupply"; 10 | const adapter = addChainExports(chainContracts); 11 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/uxd-stablecoin/index.ts: -------------------------------------------------------------------------------- 1 | const sdk = require("@defillama/sdk"); 2 | import { PeggedIssuanceAdapter } from "../peggedAsset.type"; 3 | import { solanaMintedOrBridged } from "../helper/getSupply"; 4 | 5 | const chainContracts = { 6 | solana: { 7 | issued: ["7kbnvuGBxxj8AG9qp8Scn56muWGaRaFqxg1FsRp3PaFT"], 8 | }, 9 | }; 10 | 11 | const adapter: PeggedIssuanceAdapter = { 12 | solana: { 13 | minted: solanaMintedOrBridged(chainContracts.solana.issued), 14 | }, 15 | }; 16 | 17 | export default adapter; 18 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/vai/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | bsc: { 3 | issued: ["0x4bd17003473389a42daf6a0a729f6fdb328bbbd7"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; 10 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/vdollar-finance/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x677ddbd918637E5F2c79e164D402454dE7dA8619"], 4 | }, 5 | base: { 6 | bridgedFromETH: ["0x0937876EFd6C4101Be68cd89ba58D5Ecf0d53A64"], 7 | }, 8 | hemi: { 9 | bridgedFromETH: ["0x7A06C4AeF988e7925575C50261297a946aD204A8"], 10 | }, 11 | }; 12 | 13 | import { addChainExports } from "../helper/getSupply"; 14 | const adapter = addChainExports(chainContracts); 15 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/vesta-stable/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | arbitrum: { 3 | issued: ["0x64343594ab9b56e99087bfa6f2335db24c2d1f17"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; 10 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/web-3-dollar/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x0d86883FAf4FfD7aEb116390af37746F45b6f378"], 4 | }, 5 | base: { 6 | bridgedFromETH: ["0xEFb97aaF77993922aC4be4Da8Fbc9A2425322677"], 7 | }, 8 | }; 9 | 10 | import { addChainExports } from "../helper/getSupply"; 11 | const adapter = addChainExports(chainContracts); 12 | export default adapter; 13 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/worldwide-usd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x7Cd017ca5ddb86861FA983a34b5F495C6F898c41"], 4 | }, 5 | polygon: { 6 | issued: ["0x7Cd017ca5ddb86861FA983a34b5F495C6F898c41"], 7 | }, 8 | }; 9 | 10 | import { addChainExports } from "../helper/getSupply"; 11 | const adapter = addChainExports(chainContracts); 12 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/xbanking-usde/index.ts: -------------------------------------------------------------------------------- 1 | const sdk = require("@defillama/sdk"); 2 | import { PeggedIssuanceAdapter } from "../peggedAsset.type"; 3 | import { solanaMintedOrBridged } from "../helper/getSupply"; 4 | 5 | const chainContracts = { 6 | solana: { 7 | issued: ["8dt9fQhoRKuWCSAsYweG2UMF3rbcG9xzNCTWXXSmdmEi"], 8 | }, 9 | }; 10 | 11 | const adapter: PeggedIssuanceAdapter = { 12 | solana: { 13 | minted: solanaMintedOrBridged(chainContracts.solana.issued), 14 | }, 15 | }; 16 | 17 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/xusd-babelfish/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | rsk: { 3 | issued: ["0xb5999795be0ebb5bab23144aa5fd6a02d080299f"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/yala-stablecoin/index.ts: -------------------------------------------------------------------------------- 1 | import { solanaMintedOrBridged, addChainExports } from "../helper/getSupply"; 2 | import { PeggedIssuanceAdapter, ChainContracts } from "../peggedAsset.type"; 3 | 4 | const chainContracts: ChainContracts = { 5 | ethereum: { 6 | issued: ["0xE868084cf08F3c3db11f4B73a95473762d9463f7"], 7 | }, 8 | solana: { 9 | issued: ["YUYAiJo8KVbnc6Fb6h3MnH2VGND4uGWDH4iLnw7DLEu"], 10 | }, 11 | }; 12 | 13 | const adapterSolana: PeggedIssuanceAdapter = { 14 | solana: { 15 | minted: solanaMintedOrBridged(chainContracts.solana.issued), 16 | }, 17 | }; 18 | 19 | const adapterOthers = addChainExports(chainContracts); 20 | 21 | const adapter = { ...adapterOthers, ...adapterSolana }; 22 | 23 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/ylds/index.ts: -------------------------------------------------------------------------------- 1 | const sdk = require("@defillama/sdk"); 2 | import { cosmosSupply } from "../helper/getSupply"; 3 | import { PeggedIssuanceAdapter } from "../peggedAsset.type"; 4 | 5 | function provenanceSupply() { 6 | return cosmosSupply("provenance", ['uylds.fcc'], 6, '', 'peggedUSD'); 7 | } 8 | 9 | // Use `addChainExports` to generate the final adapter with combined logic 10 | const adapter: PeggedIssuanceAdapter = { 11 | provenance: { 12 | minted: provenanceSupply() 13 | }, 14 | }; 15 | 16 | export default adapter; 17 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/youves-uusd/index.ts: -------------------------------------------------------------------------------- 1 | const sdk = require("@defillama/sdk"); 2 | import { sumSingleBalance } from "../helper/generalUtil"; 3 | import { 4 | ChainBlocks, 5 | PeggedIssuanceAdapter, 6 | Balances, ChainContracts, 7 | } from "../peggedAsset.type"; 8 | import { getTotalSupply as tezosGetTotalSupply } from "../helper/tezos"; 9 | 10 | 11 | const chainContracts: ChainContracts = { 12 | tezos: { 13 | issued: ["KT1XRPEPXbZK25r3Htzp2o1x7xdMMmfocKNW"], 14 | }, 15 | }; 16 | 17 | async function tezosMinted(tokenID: string) { 18 | return async function ( 19 | _timestamp: number, 20 | _ethBlock: number, 21 | _chainBlocks: ChainBlocks 22 | ) { 23 | let balances = {} as Balances; 24 | const totalSupply = await tezosGetTotalSupply(tokenID); 25 | sumSingleBalance(balances, "peggedUSD", totalSupply, "issued", false); 26 | return balances; 27 | }; 28 | } 29 | 30 | const adapter: PeggedIssuanceAdapter = { 31 | tezos: { 32 | minted: tezosMinted(chainContracts.tezos.issued[0]), 33 | }, 34 | }; 35 | 36 | export default adapter; 37 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/yusd-stablecoin/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | avax: { 3 | issued: ["0x111111111111ed1d73f860f57b2798b683f2d325"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/zkusd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | era: { 3 | issued: ["0xfc7e56298657b002b3e656400e746b7212912757"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/zoth-zeusd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x7DC9748DA8E762e569F9269f48F69A1a9F8Ea761"], 4 | }, 5 | metis: { 6 | bridgedFromETH: ["0x2d3D1a6982840Dd88bC2380Fd557F8A9D5e27a77"], 7 | }, 8 | manta: { 9 | bridgedFromETH: ["0x7DC9748DA8E762e569F9269f48F69A1a9F8Ea761"], 10 | }, 11 | avax: { 12 | bridgedFromETH: ["0x7DC9748DA8E762e569F9269f48F69A1a9F8Ea761"], 13 | }, 14 | }; 15 | 16 | 17 | import { addChainExports } from "../helper/getSupply"; 18 | const adapter = addChainExports(chainContracts, undefined, { decimals: 6}); 19 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/zun-eth/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0xc2e660C62F72c2ad35AcE6DB78a616215E2F2222"], 4 | }, 5 | }; 6 | import { addChainExports } from "../helper/getSupply"; 7 | const adapter = addChainExports(chainContracts, undefined, { pegType: 'peggedVAR' }); 8 | export default adapter; 9 | -------------------------------------------------------------------------------- /src/adapters/peggedAssets/zun-usd/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0x8C0D76C9B18779665475F3E212D9Ca1Ed6A1A0e6"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/adapters/peggedAssets/zunami-protocol/index.ts: -------------------------------------------------------------------------------- 1 | const chainContracts = { 2 | ethereum: { 3 | issued: ["0xb40b6608B2743E691C9B54DdBDEe7bf03cd79f1c"], 4 | }, 5 | }; 6 | 7 | import { addChainExports } from "../helper/getSupply"; 8 | const adapter = addChainExports(chainContracts); 9 | export default adapter; -------------------------------------------------------------------------------- /src/alertOutdated.ts: -------------------------------------------------------------------------------- 1 | import { wrapScheduledLambda } from "./utils/shared/wrap"; 2 | import peggedAssets from "./peggedData/peggedData"; 3 | import { getLastRecord } from "./utils/getLastRecord"; 4 | import { getCurrentUnixTimestamp } from "./utils/date"; 5 | import { sendMessage } from "./utils/discord"; 6 | 7 | const handler = async () => { 8 | const now = getCurrentUnixTimestamp(); 9 | const outdated = ( 10 | await Promise.all( 11 | peggedAssets.map(async (asset) => { 12 | const last = await getLastRecord(`hourlyPeggedBalances#${asset.id}`); 13 | if (last?.SK < now - 5 * 3600) { 14 | return { 15 | name: asset.name, 16 | hoursAgo: (now - last?.SK) / 3600, 17 | }; 18 | } 19 | return null; 20 | }) 21 | ) 22 | ).filter((a) => a !== null); 23 | if (outdated.length > 0) { 24 | await sendMessage( 25 | outdated 26 | .map((a) => `${a!.name} - ${a!.hoursAgo.toFixed(2)} hours ago`) 27 | .join("\n"), 28 | process.env.OUTDATED_WEBHOOK! 29 | ); 30 | } 31 | }; 32 | 33 | export default wrapScheduledLambda(handler); 34 | -------------------------------------------------------------------------------- /src/cli/buildRequires.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DefiLlama/peggedassets-server/2cf0bc73dcbeaaf8a248033670b0d687754b5300/src/cli/buildRequires.ts -------------------------------------------------------------------------------- /src/config.ts: -------------------------------------------------------------------------------- 1 | import { successResponse, wrap, IResponse } from "./utils/shared"; 2 | import peggedAssets from "./peggedData/peggedData"; 3 | import sluggifyPegged from "./peggedAssets/utils/sluggifyPegged"; 4 | 5 | const handler = async ( 6 | _event: AWSLambda.APIGatewayEvent 7 | ): Promise => { 8 | let response: any = Object.fromEntries( 9 | peggedAssets.map((pegged) => [sluggifyPegged(pegged), pegged.id]) 10 | ); 11 | return successResponse(response, 10 * 60); // 10 mins cache 12 | }; 13 | 14 | export default wrap(handler); 15 | -------------------------------------------------------------------------------- /src/constants.ts: -------------------------------------------------------------------------------- 1 | export const baseIconsUrl = "https://icons.llama.fi"; 2 | -------------------------------------------------------------------------------- /src/fallback.test.ts: -------------------------------------------------------------------------------- 1 | import fallback from "./fallback"; 2 | 3 | describe("snapshot of error provided", () => { 4 | it("executes as expected", async () => { 5 | const response = await fallback({ 6 | headers: {}, 7 | } as any); 8 | expect(response).toMatchSnapshot(); 9 | }); 10 | }); 11 | -------------------------------------------------------------------------------- /src/fallback.ts: -------------------------------------------------------------------------------- 1 | import { IResponse, wrap, errorResponse } from "./utils/shared"; 2 | 3 | const handler = async ( 4 | _event: AWSLambda.APIGatewayEvent 5 | ): Promise => { 6 | const response = errorResponse({ 7 | message: "This endpoint doesn't exist", 8 | } as any); 9 | 10 | return response; 11 | }; 12 | 13 | export default wrap(handler); 14 | -------------------------------------------------------------------------------- /src/getRates.ts: -------------------------------------------------------------------------------- 1 | import { successResponse, wrap, IResponse } from "./utils/shared"; 2 | const axios = require("axios"); 3 | 4 | export async function craftRatesResponse() { 5 | const rates = await ( 6 | await axios.get( 7 | `https://llama-stablecoins-data.s3.eu-central-1.amazonaws.com/rates/2mo` 8 | ) 9 | )?.data; 10 | 11 | return rates; 12 | } 13 | 14 | const handler = async ( 15 | _event: AWSLambda.APIGatewayEvent 16 | ): Promise => { 17 | const chainData = await craftRatesResponse(); 18 | return successResponse(chainData, 10 * 60); // 10 mins cache 19 | }; 20 | 21 | export default wrap(handler); 22 | -------------------------------------------------------------------------------- /src/getStablecoinPrices.ts: -------------------------------------------------------------------------------- 1 | import { successResponse, wrap, IResponse } from "./utils/shared"; 2 | import { getHistoricalValues } from "./utils/shared/dynamodb"; 3 | import { 4 | getLastRecord, 5 | dailyPeggedPrices, 6 | hourlyPeggedPrices, 7 | } from "./peggedAssets/utils/getLastRecord"; 8 | import { secondsInHour } from "./utils/date"; 9 | 10 | export async function craftStablecoinPricesResponse() { 11 | const historicalPeggedPrices = await getHistoricalValues(dailyPeggedPrices); 12 | 13 | const lastPrices = await getLastRecord(hourlyPeggedPrices); 14 | 15 | const lastDailyItem = 16 | historicalPeggedPrices[historicalPeggedPrices.length - 1]; 17 | if ( 18 | lastPrices !== undefined && 19 | lastPrices.SK > lastDailyItem.SK && 20 | lastDailyItem.SK + secondsInHour * 25 > lastPrices.SK 21 | ) { 22 | lastPrices.SK = lastDailyItem.SK; 23 | historicalPeggedPrices[historicalPeggedPrices.length - 1] = lastPrices; 24 | } 25 | 26 | let response = historicalPeggedPrices 27 | ?.map((item) => 28 | typeof item === "object" 29 | ? { 30 | date: item.SK, 31 | prices: item.prices, 32 | } 33 | : { prices: undefined } 34 | ) 35 | .filter((item) => item.prices !== undefined); 36 | 37 | return response; 38 | } 39 | 40 | const handler = async ( 41 | _event: AWSLambda.APIGatewayEvent 42 | ): Promise => { 43 | const chainData = await craftStablecoinPricesResponse(); 44 | return successResponse(chainData, 30 * 60); // 30 mins cache 45 | }; 46 | 47 | export default wrap(handler); 48 | -------------------------------------------------------------------------------- /src/peggedAssets/storePeggedAssets/errorDb.ts: -------------------------------------------------------------------------------- 1 | export function executeAndIgnoreErrors(_sql: string, _values: any) {} 2 | -------------------------------------------------------------------------------- /src/peggedAssets/storePeggedAssets/testStorePegged.ts: -------------------------------------------------------------------------------- 1 | import iterate from "./storePegged"; 2 | 3 | const test = async () => { 4 | await iterate([1, 5, 38, 44]); 5 | console.log("finished"); 6 | }; 7 | 8 | test(); 9 | -------------------------------------------------------------------------------- /src/peggedAssets/utils/getLastRecord.ts: -------------------------------------------------------------------------------- 1 | import dynamodb from "../../utils/shared/dynamodb"; 2 | 3 | export function getLastRecord(PK: string) { 4 | return dynamodb 5 | .query({ 6 | ExpressionAttributeValues: { 7 | ":pk": PK, 8 | }, 9 | KeyConditionExpression: "PK = :pk", 10 | Limit: 1, 11 | ScanIndexForward: false, 12 | }) 13 | .then((res) => res.Items?.[0]); 14 | } 15 | 16 | export const hourlyPeggedBalances = (protocolId: string) => 17 | `hourlyPeggedBalances#${protocolId}`; 18 | export const dailyPeggedBalances = (protocolId: string) => 19 | `dailyPeggedBalances#${protocolId}`; 20 | export const dailyPeggedPrices = "dailyPeggedPrices"; 21 | export const hourlyPeggedPrices = "hourlyPeggedPrices"; 22 | export const historicalRates = "historicalRates"; 23 | -------------------------------------------------------------------------------- /src/peggedAssets/utils/importAdapter.ts: -------------------------------------------------------------------------------- 1 | import { PeggedAsset } from "../../peggedData/types"; 2 | import * as peggedAdapters from "../../adapters/peggedAssets"; 3 | 4 | export function importAdapter(asset: PeggedAsset) { 5 | let key =asset.gecko_id 6 | if (asset.id === '121') key = 'psy' // special case for psy since it is not on coingecko 7 | return (peggedAdapters as any)["default"][key]; 8 | } 9 | -------------------------------------------------------------------------------- /src/peggedAssets/utils/sluggifyPegged.ts: -------------------------------------------------------------------------------- 1 | import type { PeggedAsset } from "../../peggedData/peggedData"; 2 | 3 | export default (pegged: PeggedAsset) => 4 | pegged.name.toLowerCase().split(" ").join("-").split("'").join(""); 5 | -------------------------------------------------------------------------------- /src/peggedData/backfilledChains.ts: -------------------------------------------------------------------------------- 1 | const backfilledChains = [ 2 | "ethereum", 3 | "bsc", 4 | "avax", 5 | "arbitrum", 6 | "optimism", 7 | "fantom", 8 | "polygon", 9 | "xdai", 10 | "celo", 11 | "harmony", 12 | "moonriver", 13 | "aztec", 14 | "loopring", 15 | "starknet", 16 | "zksync", 17 | "boba", 18 | "metis", 19 | "moonbeam", 20 | "syscoin", 21 | "okexchain", 22 | "iotex", 23 | "heco", 24 | ]; 25 | 26 | export default backfilledChains; 27 | -------------------------------------------------------------------------------- /src/peggedData/types.ts: -------------------------------------------------------------------------------- 1 | type PegType = 2 | | "peggedUSD" //dollar 3 | | "peggedVAR" //variable 4 | | "peggedEUR" //europe/euro 5 | | "peggedSGD" //singapora 6 | | "peggedJPY" //japan 7 | | "peggedCNY" //china 8 | | "peggedUAH" //ukraine 9 | | "peggedARS" //ARGENTINE 10 | | "peggedGBP" //GB 11 | | "peggedCAD" //canadian dollar 12 | | "peggedTRY" //Turkish lira 13 | | "peggedXAU" //Gold this is not used 14 | | "peggedCHF" //Swiss franc 15 | | "peggedCOP" //colombian peso 16 | | "peggedREAL"//brazilian real 17 | | "peggedRUB" //russian ruble 18 | | "peggedAUD"; //Australian currency 19 | 20 | type PegMechanism = "algorithmic" | "fiat-backed" | "crypto-backed"; 21 | 22 | export type PriceSource = 23 | | "chainlink" 24 | | "uniswap" 25 | | "dexscreener" 26 | | "curve" 27 | | "coingecko" 28 | | "birdeye" 29 | | "kucoin" 30 | | "defillama" 31 | | "kaddex"; 32 | 33 | export type PeggedAsset = { 34 | id: string; 35 | name: string; 36 | address: string; 37 | symbol: string; 38 | url: string; 39 | description: string; 40 | mintRedeemDescription: string; 41 | onCoinGecko: string; 42 | gecko_id: string; 43 | cmcId: string; 44 | pegType: PegType; 45 | pegMechanism: PegMechanism; 46 | priceSource: PriceSource; 47 | auditLinks: string[]; 48 | twitter: string; 49 | wiki: string; 50 | delisted?: boolean; 51 | deadFrom?: string; 52 | doublecounted?: boolean; 53 | deprecated?: boolean; 54 | }; 55 | 56 | type Bridge = { 57 | name: string; 58 | link?: string; 59 | }; 60 | 61 | export type BridgeInfo = { 62 | [bridgeID: string]: Bridge; 63 | }; 64 | -------------------------------------------------------------------------------- /src/setupTestEnv.js: -------------------------------------------------------------------------------- 1 | process.env.tableName = `test-table` -------------------------------------------------------------------------------- /src/storePeggedAssets.ts: -------------------------------------------------------------------------------- 1 | import storePeggedAssets from "./peggedAssets/storePeggedAssets/storePegged"; 2 | import { wrapScheduledLambda } from "./utils/shared/wrap"; 3 | import dynamodb from "./utils/shared/dynamodb"; 4 | 5 | async function setEnvSecrets() { 6 | try { 7 | const { Item } = await dynamodb.getEnvSecrets(); 8 | Object.entries(Item as any).forEach(([key, value]: any) => { 9 | if (key !== "PK" && key !== "SK") process.env[key] = value; 10 | }); 11 | } catch (e) { 12 | console.log("Unable to get env secrets: ", e); 13 | } 14 | } 15 | 16 | const handler = async (event: any) => { 17 | await setEnvSecrets(); 18 | await storePeggedAssets(event.peggedIndexes); 19 | }; 20 | 21 | export default wrapScheduledLambda(handler); 22 | -------------------------------------------------------------------------------- /src/testGetPeggedChart.ts: -------------------------------------------------------------------------------- 1 | import { craftChartsResponse } from "./getStablecoinChart"; 2 | 3 | const response = craftChartsResponse("ethereum", undefined); 4 | -------------------------------------------------------------------------------- /src/testGetPeggeds.ts: -------------------------------------------------------------------------------- 1 | import { craftProtocolsResponse } from "./getPeggeds"; 2 | 3 | const test = async () => { 4 | let res = await craftProtocolsResponse(true, true); 5 | console.log(res); 6 | }; 7 | 8 | test(); 9 | -------------------------------------------------------------------------------- /src/testStorePeggedPrices.ts: -------------------------------------------------------------------------------- 1 | import peggedAssets from "./peggedData/peggedData"; 2 | import getCurrentPeggedPrice, { getPrices } from "./adapters/peggedAssets/prices"; 3 | 4 | type Prices = { 5 | [coinGeckoId: string]: Number | null; 6 | }; 7 | 8 | const test = async () => { 9 | let prices = {} as Prices; 10 | let pricePromises = peggedAssets.map(async (pegged) => { 11 | const price = await getCurrentPeggedPrice( 12 | pegged.gecko_id, 13 | pegged.priceSource 14 | ); 15 | console.log(pegged.gecko_id); 16 | prices[pegged.gecko_id] = price; 17 | }); 18 | await Promise.all(pricePromises); 19 | console.log(JSON.stringify(prices)); 20 | }; 21 | 22 | const test2 = async () => { 23 | const tokens = peggedAssets.map((pegged) =>pegged.gecko_id); 24 | await getPrices(peggedAssets).then((res) => { 25 | tokens.forEach((token) => { 26 | if (!res[token]) { 27 | console.log(token, "not found"); 28 | } 29 | }) 30 | }) 31 | return; 32 | }; 33 | 34 | test2().then(() => process.exit(0)); 35 | -------------------------------------------------------------------------------- /src/triggerStorePegged.ts: -------------------------------------------------------------------------------- 1 | import { wrapScheduledLambda } from "./utils/shared/wrap"; 2 | import peggedAssets from "./peggedData/peggedData"; 3 | import invokeLambda from "./utils/shared/invokeLambda"; 4 | 5 | function timeout(ms: number) { 6 | return new Promise((resolve) => setTimeout(resolve, ms)); 7 | } 8 | 9 | function shuffleArray(array: number[]) { 10 | for (let i = array.length - 1; i > 0; i--) { 11 | const j = Math.floor(Math.random() * (i + 1)); 12 | [array[i], array[j]] = [array[j], array[i]]; 13 | } 14 | } 15 | 16 | const step = 5; 17 | const handler = async () => { 18 | const peggedIndexes = Array.from(Array(peggedAssets.length).keys()); 19 | shuffleArray(peggedIndexes); 20 | for (let i = 0; i < peggedAssets.length; i += step) { 21 | const event = { 22 | peggedIndexes: peggedIndexes.slice(i, i + step), 23 | }; 24 | await Promise.all([ 25 | invokeLambda(`llama-stablecoins-dev-storePeggedAssets`, event), 26 | timeout(1000), 27 | ]); 28 | } 29 | }; 30 | 31 | export default wrapScheduledLambda(handler); 32 | -------------------------------------------------------------------------------- /src/types.ts: -------------------------------------------------------------------------------- 1 | import { BridgeID } from "./peggedData/bridgeData"; 2 | 3 | export interface TokenPrices { 4 | [token: string]: { 5 | usd: number; 6 | }; 7 | } 8 | 9 | type PeggedBalances = { 10 | [peggedAssetType: string]: number | null; 11 | }; 12 | export type BridgeBalances = { 13 | [bridgeID in BridgeID]: { 14 | [source: string]: { 15 | amount: number; 16 | }; 17 | }; 18 | }; 19 | export type PeggedTokenBalance = PeggedBalances & { 20 | bridges?: BridgeBalances; 21 | }; 22 | 23 | export type TokensValueLocked = { 24 | [tokenSymbolOrName: string]: number; 25 | }; 26 | 27 | export type tvlsObject = { 28 | [chain: string]: T; 29 | }; 30 | 31 | export type PeggedAssetIssuance = { 32 | [chain: string]: { 33 | [issuanceType: string]: PeggedTokenBalance; 34 | }; 35 | }; 36 | 37 | export type StoredPeggedAssetIssuance = { 38 | [chain: string]: 39 | | { 40 | [issuanceType: string]: PeggedTokenBalance; 41 | } 42 | | string 43 | | number; 44 | }; 45 | -------------------------------------------------------------------------------- /src/utils/date.test.ts: -------------------------------------------------------------------------------- 1 | import { 2 | getTimestampAtStartOfDay, 3 | getDay, 4 | getClosestDayStartTimestamp, 5 | } from "./date"; 6 | 7 | test("getTimestampAtStartOfDay", () => { 8 | expect(getTimestampAtStartOfDay(1631772242)).toBe(1631750400); 9 | }); 10 | 11 | test("getDay", () => { 12 | const start = 1631750400; 13 | for (let ts = start; ts < start + 24 * 3600; ts + 3600) { 14 | expect(getDay(ts)).toBe(getDay(start)); 15 | } 16 | expect(getDay(start + 25 * 3600)).not.toBe(getDay(start)); 17 | }); 18 | 19 | test("getClosestDayStartTimestamp", () => { 20 | expect(getClosestDayStartTimestamp(1631750400 - 1)).toBe(1631750400); 21 | expect(getClosestDayStartTimestamp(1631750400 + 1)).toBe(1631750400); 22 | expect(getClosestDayStartTimestamp(1631793104)).toBe(1631750400); 23 | }); 24 | -------------------------------------------------------------------------------- /src/utils/discord.ts: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | 3 | export async function sendMessage( 4 | message: string, 5 | webhookUrl: string, 6 | formatted = true 7 | ) { 8 | const formattedMessage = formatted ? "```\n" + message + "\n```" : message; // Put it into a code block to prevent the format from getting messed up 9 | if (formattedMessage.length >= 2000) { 10 | const lines = message.split("\n"); 11 | if (lines.length <= 2) { 12 | throw new Error("Lines are too long, reaching infinite recursivity"); 13 | } 14 | const mid = Math.round(lines.length / 2); 15 | await sendMessage(lines.slice(0, mid).join("\n"), webhookUrl); 16 | await sendMessage(lines.slice(mid).join("\n"), webhookUrl); 17 | return; 18 | } 19 | // Example: https://gist.github.com/dragonwocky/ea61c8d21db17913a43da92efe0de634 20 | // Docs: https://gist.github.com/dragonwocky/ea61c8d21db17913a43da92efe0de634 21 | await axios.post(`${webhookUrl}?wait=true`, { 22 | content: formattedMessage, 23 | }) 24 | } 25 | -------------------------------------------------------------------------------- /src/utils/error.ts: -------------------------------------------------------------------------------- 1 | import * as Sentry from "@sentry/serverless"; 2 | 3 | export function reportError(message: string, protocolName: string) { 4 | const scope = new Sentry.Scope(); 5 | scope.setTag("protocol", protocolName); 6 | const error = new Error(message); 7 | error.name = message; 8 | Sentry.AWSLambda.captureException(error, scope); 9 | } 10 | 11 | export function reportErrorObject(error: Error, tag: string, value: string) { 12 | const scope = new Sentry.Scope(); 13 | scope.setTag(tag, value); 14 | Sentry.AWSLambda.captureException(error, scope); 15 | } 16 | 17 | export const PUT_DAILY_VOLUME_ERROR = "PUT_DAILY_VOLUME"; 18 | 19 | export function reportDexVolumeError({ 20 | id, 21 | timestamp, 22 | category, 23 | message, 24 | }: { 25 | id: number; 26 | timestamp: number; 27 | category: string; 28 | message: string; 29 | }) { 30 | const scope = new Sentry.Scope(); 31 | const errorName = `${id}-${timestamp}-${category}`; 32 | scope.setTag("dexvolume", id); 33 | const error = new Error(message); 34 | error.name = errorName; 35 | Sentry.AWSLambda.captureException(error, scope); 36 | throw error; 37 | } 38 | -------------------------------------------------------------------------------- /src/utils/fetchPrices.ts: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | 3 | let prices: any 4 | 5 | export async function fetchPrices(peggedPrices?: any): Promise { 6 | if (prices) return prices 7 | if (peggedPrices) { 8 | prices = peggedPrices 9 | } else { 10 | prices = await axios( 11 | "https://llama-stablecoins-data.s3.eu-central-1.amazonaws.com/peggedPrices.json" 12 | ) 13 | .then((res: any) => res.data) 14 | .catch(() => { 15 | console.error("Could not fetch pegged prices"); 16 | }); 17 | } 18 | return prices ?? {} 19 | } -------------------------------------------------------------------------------- /src/utils/getLastRecord.ts: -------------------------------------------------------------------------------- 1 | import dynamodb from "./shared/dynamodb"; 2 | 3 | export function getLastRecord(PK: string) { 4 | return dynamodb 5 | .query({ 6 | ExpressionAttributeValues: { 7 | ":pk": PK, 8 | }, 9 | KeyConditionExpression: "PK = :pk", 10 | Limit: 1, 11 | ScanIndexForward: false, 12 | }) 13 | .then((res) => res.Items?.[0]); 14 | } 15 | 16 | export const hourlyTvl = (protocolId: string) => `hourlyTvl#${protocolId}`; 17 | export const hourlyTokensTvl = (protocolId: string) => 18 | `hourlyTokensTvl#${protocolId}`; 19 | export const hourlyUsdTokensTvl = (protocolId: string) => 20 | `hourlyUsdTokensTvl#${protocolId}`; 21 | export const hourlyRawTokensTvl = (protocolId: string) => 22 | `hourlyRawTokensTvl#${protocolId}`; 23 | export const dailyTvl = (protocolId: string) => `dailyTvl#${protocolId}`; 24 | export const dailyTokensTvl = (protocolId: string) => 25 | `dailyTokensTvl#${protocolId}`; 26 | export const dailyUsdTokensTvl = (protocolId: string) => 27 | `dailyUsdTokensTvl#${protocolId}`; 28 | export const dailyRawTokensTvl = (protocolId: string) => 29 | `dailyRawTokensTvl#${protocolId}`; 30 | -------------------------------------------------------------------------------- /src/utils/normalizeChains.test.ts: -------------------------------------------------------------------------------- 1 | import { getChainDisplayName, addToChains } from "./normalizeChain"; 2 | 3 | const tests = [ 4 | ["gochain", "GoChain"], 5 | ["ethereum", "Ethereum"], 6 | ["ethereum-staking", "Ethereum-staking"], 7 | ["hpb-borrowed", "HPB-borrowed"], 8 | ["staking", "staking"], 9 | ]; 10 | 11 | test("getChainDisplayName", () => { 12 | tests.forEach((t) => expect(getChainDisplayName(t[0], false)).toBe(t[1])); 13 | }); 14 | 15 | test("getChainDisplayName useNewChainNames", () => { 16 | expect(getChainDisplayName("bsc", false)).toBe("Binance"); 17 | expect(getChainDisplayName("bsc", true)).toBe("BSC"); 18 | }); 19 | 20 | test("addToChains", () => { 21 | const chains = [] as string[]; 22 | addToChains(chains, "Ethereum"); 23 | expect(chains).toEqual(["Ethereum"]); 24 | addToChains(chains, "Ethereum-borrowed"); 25 | expect(chains).toEqual(["Ethereum"]); 26 | addToChains(chains, "BSC-staking"); 27 | expect(chains).toEqual(["Ethereum", "BSC"]); 28 | addToChains(chains, "Heco"); 29 | expect(chains).toEqual(["Ethereum", "BSC", "Heco"]); 30 | }); 31 | -------------------------------------------------------------------------------- /src/utils/s3.ts: -------------------------------------------------------------------------------- 1 | import aws from "aws-sdk"; 2 | import type { Readable } from "stream"; 3 | 4 | export const datasetBucket = "llama-stablecoins-data"; 5 | 6 | function next21Minutedate() { 7 | const dt = new Date(); 8 | dt.setHours(dt.getHours() + 1); 9 | dt.setMinutes(21); 10 | return dt; 11 | } 12 | 13 | export async function store( 14 | filename: string, 15 | body: string | Readable | Buffer, 16 | hourlyCache = false, 17 | compressed = true 18 | ) { 19 | await new aws.S3() 20 | .upload({ 21 | Bucket: datasetBucket, 22 | Key: filename, 23 | Body: body, 24 | ACL: "public-read", 25 | ...(hourlyCache && { 26 | Expires: next21Minutedate(), 27 | ...(compressed && { 28 | ContentEncoding: "br", 29 | }), 30 | ContentType: "application/json", 31 | }), 32 | }) 33 | .promise(); 34 | } 35 | 36 | export async function storeDataset( 37 | filename: string, 38 | body: string, 39 | ContentType = "text/csv" 40 | ) { 41 | await new aws.S3() 42 | .upload({ 43 | Bucket: datasetBucket, 44 | Key: `temp/${filename}`, 45 | Body: body, 46 | ACL: "public-read", 47 | ContentType, 48 | }) 49 | .promise(); 50 | } 51 | -------------------------------------------------------------------------------- /src/utils/shared/coingeckoLocks.ts: -------------------------------------------------------------------------------- 1 | const locks = [] as ((value: unknown) => void)[]; 2 | export function getCoingeckoLock() { 3 | return new Promise((resolve) => { 4 | locks.push(resolve); 5 | }); 6 | } 7 | export function releaseCoingeckoLock() { 8 | const firstLock = locks.shift(); 9 | if (firstLock !== undefined) { 10 | firstLock(null); 11 | } 12 | } 13 | // Rate limit is 100 calls/min for coingecko's API 14 | // So we'll release one every 0.6 seconds to match it 15 | export function setTimer(timeBetweenTicks: number = 600) { 16 | const timer = setInterval(() => { 17 | releaseCoingeckoLock(); 18 | }, timeBetweenTicks); 19 | return timer; 20 | } 21 | -------------------------------------------------------------------------------- /src/utils/shared/getRecordClosestToTimestamp.ts: -------------------------------------------------------------------------------- 1 | import dynamodb from "./dynamodb"; 2 | 3 | export default async function getTVLOfRecordClosestToTimestamp( 4 | PK: string, 5 | timestamp: number, 6 | searchWidth: number 7 | ) { 8 | return dynamodb 9 | .query({ 10 | ExpressionAttributeValues: { 11 | ":pk": PK, 12 | ":begin": timestamp - searchWidth, 13 | ":end": timestamp + searchWidth, 14 | }, 15 | KeyConditionExpression: "PK = :pk AND SK BETWEEN :begin AND :end", 16 | }) 17 | .then((records) => { 18 | if (records.Items == undefined || records.Items.length == 0) { 19 | return { 20 | SK: undefined, 21 | }; 22 | } 23 | let closest = records.Items[0]; 24 | for (const item of records.Items.slice(1)) { 25 | if (Math.abs(item.SK - timestamp) < Math.abs(closest.SK - timestamp)) { 26 | closest = item; 27 | } 28 | } 29 | return closest; 30 | }); 31 | } 32 | -------------------------------------------------------------------------------- /src/utils/shared/index.ts: -------------------------------------------------------------------------------- 1 | export { default as wrap } from "./wrap"; 2 | export * from "./lambda-response"; 3 | -------------------------------------------------------------------------------- /src/utils/shared/invokeLambda.ts: -------------------------------------------------------------------------------- 1 | import aws from "aws-sdk"; 2 | 3 | export default async function invokeLambda(functioName: string, event: any) { 4 | return new Promise((resolve, _reject) => { 5 | new aws.Lambda().invoke( 6 | { 7 | FunctionName: functioName, 8 | InvocationType: "Event", 9 | Payload: JSON.stringify(event, null, 2), // pass params 10 | }, 11 | function (error, data) { 12 | console.log(error, data); 13 | resolve(data); 14 | } 15 | ); 16 | }); 17 | } 18 | -------------------------------------------------------------------------------- /src/utils/shared/lambda-response.test.ts: -------------------------------------------------------------------------------- 1 | import { errorResponse } from "./lambda-response"; 2 | 3 | test("errorResponse works with both field and without", () => { 4 | expect(errorResponse({ message: "supp" })).toMatchInlineSnapshot(` 5 | Object { 6 | "body": "{\\"message\\":\\"supp\\",\\"field\\":\\"email\\"}", 7 | "headers": Object { 8 | "Access-Control-Allow-Origin": "*", 9 | "Content-Type": "application/json", 10 | }, 11 | "statusCode": 400, 12 | } 13 | `); 14 | expect(errorResponse({ message: "supp" }).body).toEqual( 15 | JSON.stringify({ 16 | message: "supp", 17 | }) 18 | ); 19 | }); 20 | -------------------------------------------------------------------------------- /src/utils/shared/parseRequestBody.test.ts: -------------------------------------------------------------------------------- 1 | import parseRequestBody from "./parseRequestBody"; 2 | 3 | test("invalid json body is rejected", () => { 4 | expect(() => { 5 | parseRequestBody("fake"); 6 | }).toThrowErrorMatchingInlineSnapshot( 7 | `"Message body is not a valid JSON object"` 8 | ); 9 | }); 10 | 11 | test("parsed JSON object is returned", () => { 12 | expect(parseRequestBody('{"a":"b"}')).toEqual({ 13 | a: "b", 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /src/utils/shared/parseRequestBody.ts: -------------------------------------------------------------------------------- 1 | export default function (rawBody: null | string): any { 2 | if (rawBody === null) { 3 | throw new Error("No message body was provided"); 4 | } 5 | let body; 6 | try { 7 | body = JSON.parse(rawBody); 8 | } catch (e) { 9 | throw new Error("Message body is not a valid JSON object"); 10 | } 11 | return body; 12 | } 13 | -------------------------------------------------------------------------------- /src/utils/shared/sleep.ts: -------------------------------------------------------------------------------- 1 | export default function sleep(ms: number) { 2 | return new Promise((resolve) => setTimeout(resolve, ms)); 3 | } 4 | -------------------------------------------------------------------------------- /src/utils/shared/wrap.ts: -------------------------------------------------------------------------------- 1 | import * as Sentry from "@sentry/serverless"; 2 | import { IResponse, credentialsCorsHeaders } from "./lambda-response"; 3 | 4 | type Event = 5 | | AWSLambda.APIGatewayEvent 6 | | { 7 | source: string; 8 | }; 9 | 10 | function wrap( 11 | lambdaFunc: (event: AWSLambda.APIGatewayEvent) => Promise 12 | ): ( 13 | event: Event, 14 | context?: any, 15 | callback?: any 16 | ) => Promise | void { 17 | const handler = async (event: Event) => { 18 | if ("source" in event) { 19 | if (event.source === "serverless-plugin-warmup") { 20 | return "pinged"; 21 | } 22 | throw new Error("Unexpected source"); 23 | } 24 | return lambdaFunc(event).then((response) => ({ 25 | ...response, 26 | headers: { 27 | ...response.headers, 28 | ...credentialsCorsHeaders(), 29 | }, 30 | })); 31 | }; 32 | return Sentry.AWSLambda.wrapHandler(handler); 33 | } 34 | 35 | export default wrap; 36 | 37 | export function wrapScheduledLambda( 38 | lambdaFunc: (event: any, context: AWSLambda.Context) => Promise 39 | ): ( 40 | event: void, 41 | context?: any, 42 | callback?: any 43 | ) => Promise | void { 44 | return Sentry.AWSLambda.wrapHandler(lambdaFunc); 45 | } 46 | -------------------------------------------------------------------------------- /src/utils/wrapOrRedirect.ts: -------------------------------------------------------------------------------- 1 | import { datasetBucket, storeDataset } from "./s3"; 2 | import { successResponse } from "./shared"; 3 | 4 | function buildRedirect(filename: string, cache?: number) { 5 | return { 6 | statusCode: 307, 7 | body: "", 8 | headers: { 9 | Location: `https://${datasetBucket}.s3.eu-central-1.amazonaws.com/temp/${filename}`, 10 | ...(cache !== undefined 11 | ? { 12 | "Cache-Control": `max-age=${cache}`, 13 | } 14 | : {}), 15 | }, 16 | }; 17 | } 18 | 19 | export async function wrapResponseOrRedirect(response: any, cache: number) { 20 | const jsonData = JSON.stringify(response); 21 | const dataLength = Buffer.byteLength(jsonData, "utf8"); 22 | 23 | if (dataLength < 5.5e6) { 24 | return successResponse(response, cache); 25 | } else { 26 | const filename = `stablecoin-${response.name}.json`; 27 | 28 | await storeDataset(filename, jsonData, "application/json"); 29 | 30 | return buildRedirect(filename, 10 * 60); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "ts-node": { 3 | "compilerOptions": { 4 | "module": "commonjs" 5 | } 6 | }, 7 | "compilerOptions": { 8 | "target": "es2019", 9 | "skipLibCheck": false, 10 | "esModuleInterop": true, 11 | "allowSyntheticDefaultImports": true, 12 | "strict": true, 13 | "forceConsistentCasingInFileNames": true, 14 | "module": "esnext", 15 | "moduleResolution": "node", 16 | "resolveJsonModule": true, 17 | "noEmit": false, 18 | "jsx": "preserve", 19 | "allowJs": true, 20 | "noImplicitThis": false, 21 | "noUnusedLocals": false, 22 | "noUnusedParameters": true, 23 | "lib": ["ES2019"], 24 | "types": ["node"] 25 | }, 26 | "include": ["src"], 27 | "exclude": ["src/setupTestEnv.js"] 28 | } 29 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const slsw = require('serverless-webpack-fixed'); 2 | const path = require('path'); 3 | 4 | module.exports = { 5 | entry: slsw.lib.entries, 6 | target: 'node', 7 | mode: slsw.lib.webpack.isLocal ? 'development' : 'production', 8 | module: { 9 | rules: [ 10 | { 11 | test: /\.ts$/, 12 | use: 'ts-loader', 13 | include: path.resolve(__dirname, "src"), 14 | exclude: /node_modules/, 15 | }, 16 | { 17 | test: /\.js$/, 18 | include: __dirname, 19 | exclude: /node_modules/, 20 | use: { 21 | loader: 'babel-loader', 22 | }, 23 | }, 24 | { 25 | test: /\.mjs$/, 26 | resolve: { mainFields: ["default"] } 27 | } 28 | ], 29 | }, 30 | resolve: { 31 | extensions: ['.ts', '.js', '.json'], 32 | alias: { 33 | 'bignumber.js$': 'bignumber.js/bignumber.js', 34 | } 35 | } 36 | }; 37 | --------------------------------------------------------------------------------