mirror of
https://github.com/alexgo-io/DefiLlama-Adapters.git
synced 2026-04-30 05:45:32 +08:00
ArthSwap v3 (#9273)
* fix staking * add arthswap v3 * fix core assets * code refactor --------- Co-authored-by: g1nt0ki <99907941+g1nt0ki@users.noreply.github.com>
This commit is contained in:
5
projects/arthswap-v3/index.js
Normal file
5
projects/arthswap-v3/index.js
Normal file
@@ -0,0 +1,5 @@
|
||||
const { uniV3Export } = require('../helper/uniswapV3')
|
||||
module.exports = uniV3Export({
|
||||
astar: { factory: '0x69E92b56e4BF4C0FFa2cFB087c7EA47E846a7244', fromBlock: 3957189, },
|
||||
astrzk: { factory: '0xAeaaf0e2c81Af264101B9129C00F4440cCF0F720', fromBlock: 179999, },
|
||||
})
|
||||
@@ -1,31 +1,12 @@
|
||||
const ADDRESSES = require('../helper/coreAssets.json')
|
||||
const { getUniTVL } = require("../helper/unknownTokens");
|
||||
const { stakingPricedLP } = require("../helper/staking");
|
||||
const { staking } = require("../helper/staking");
|
||||
|
||||
const FACTORIES = "0xA9473608514457b4bF083f9045fA63ae5810A03E";
|
||||
|
||||
const TOKENS = {
|
||||
ARSW: ADDRESSES.astar.ARSW,
|
||||
};
|
||||
|
||||
const STAKING_CONTRACTS = {
|
||||
astar: "0x42d175a498Cb517Ad29d055ea7DcFD3D99045404",
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
timetravel: true,
|
||||
methodology: "Arthswap Tvl Calculation",
|
||||
misrepresentedTokens: true,
|
||||
astar: {
|
||||
tvl: getUniTVL({
|
||||
factory: FACTORIES,
|
||||
useDefaultCoreAssets: true,
|
||||
}),
|
||||
staking: stakingPricedLP(
|
||||
STAKING_CONTRACTS.astar,
|
||||
TOKENS.ARSW,
|
||||
"astar",
|
||||
"0x50497E7181eB9e8CcD70a9c44FB997742149482a",
|
||||
"arthswap"
|
||||
),
|
||||
tvl: getUniTVL({ factory: FACTORIES, useDefaultCoreAssets: true, }),
|
||||
staking: staking('0x42d175a498Cb517Ad29d055ea7DcFD3D99045404', '0xde2578edec4669ba7f41c5d5d2386300bcea4678'),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -531,6 +531,7 @@
|
||||
"BUSDbs": "5RpUwQ8wtdPCZHhu6MERp2RGrpobsbZ6MH5dDHkUjs2"
|
||||
},
|
||||
"astar": {
|
||||
"WASTR_1": "0xaeaaf0e2c81af264101b9129c00f4440ccf0f720",
|
||||
"WASTR": "0xecc867de9f5090f55908aaa1352950b9eed390cd",
|
||||
"WETH": "0x81ecac0d6be0550a00ff064a4f9dd2400585fe9c",
|
||||
"WBTC": "0xad543f18cff85c77e140e3e5e3c3392f6ba9d5ca",
|
||||
@@ -540,7 +541,6 @@
|
||||
"USDC": "0x6a2d262d56735dba19dd70682b39f6be9a931d98",
|
||||
"USDT": "0x3795c36e7d12a8c252a20c5a7b455f7c57b60283",
|
||||
"nativeUSDT": "0xffffffff000000000000000000000001000007c0",
|
||||
"ARSW": "0xde2578edec4669ba7f41c5d5d2386300bcea4678",
|
||||
"DOT": "0xffffffffffffffffffffffffffffffffffffffff",
|
||||
"DAI": "0x6de33698e9e9b787e09d3bd7771ef63557e148bb",
|
||||
"MUUU": "0xc5bcac31cf55806646017395ad119af2441aee37",
|
||||
@@ -565,6 +565,16 @@
|
||||
"vDOT": "0xFfFfFfff00000000000000010000000000000008",
|
||||
"ASTR": "0xffffffff00000000000000010000000000000010"
|
||||
},
|
||||
"astarzk": {
|
||||
"WETH": "0xe9cc37904875b459fa5d0fe37680d36f1ed55e38",
|
||||
"USDC": "0xa8ce8aee21bc2a48a5ef670afcc9274c7bbbc035",
|
||||
"USDT": "0x1e4a5963abfd975d8c9021ce480b42188849d41d",
|
||||
"WBTC": "0xea034fb02eb1808c2cc3adbc15f447b93cbe08e1",
|
||||
"DAI": "0xc5015b9d9161dca7e18e32f6f25c4ad850731fd4",
|
||||
"MATIC": "0xa2036f0538221a77a3937f1379699f44945018d0",
|
||||
"wstETH": "0x5d8cff95d7a57c0bf50b30b43c7cc0d52825d4a9",
|
||||
"weETH": "0xcd68dff4415358c35a28f96fd5bf7083b22de1d6"
|
||||
},
|
||||
"cardano": {
|
||||
"ADA": "ADA"
|
||||
},
|
||||
|
||||
32
test.js
32
test.js
@@ -4,9 +4,9 @@ const handleError = require('./utils/handleError')
|
||||
process.on('unhandledRejection', handleError)
|
||||
process.on('uncaughtException', handleError)
|
||||
|
||||
const { ENV_KEYS } = require("./projects/helper/env");
|
||||
const path = require("path");
|
||||
require("dotenv").config();
|
||||
const { ENV_KEYS } = require("./projects/helper/env");
|
||||
const { util: {
|
||||
blocks: { getCurrentBlocks },
|
||||
humanizeNumber: { humanizeNumber },
|
||||
@@ -29,24 +29,6 @@ if (process.env.LLAMA_SANITIZE)
|
||||
delete process.env[key]
|
||||
})
|
||||
|
||||
const locks = [];
|
||||
function getCoingeckoLock() {
|
||||
return new Promise((resolve) => {
|
||||
locks.push(resolve);
|
||||
});
|
||||
}
|
||||
function releaseCoingeckoLock() {
|
||||
const firstLock = locks.shift();
|
||||
if (firstLock !== undefined) {
|
||||
firstLock(null);
|
||||
}
|
||||
}
|
||||
// Rate limit is 50 calls/min for coingecko's API
|
||||
// So we'll release one every 1.2 seconds to match it
|
||||
setInterval(() => {
|
||||
releaseCoingeckoLock();
|
||||
}, 2000);
|
||||
const maxCoingeckoRetries = 5;
|
||||
|
||||
async function getTvl(
|
||||
unixTimestamp,
|
||||
@@ -58,7 +40,6 @@ async function getTvl(
|
||||
tvlFunction,
|
||||
isFetchFunction,
|
||||
storedKey,
|
||||
knownTokenPrices
|
||||
) {
|
||||
if (!isFetchFunction) {
|
||||
const chain = storedKey.split('-')[0]
|
||||
@@ -66,14 +47,7 @@ async function getTvl(
|
||||
const api = new sdk.ChainApi({ chain, block: chainBlocks[chain], timestamp: unixTimestamp, })
|
||||
let tvlBalances = await tvlFunction(unixTimestamp, ethBlock, chainBlocks, { api, chain, block, storedKey });
|
||||
if (!tvlBalances && Object.keys(api.getBalances()).length) tvlBalances = api.getBalances()
|
||||
const tvlResults = await computeTVL(
|
||||
tvlBalances,
|
||||
"now",
|
||||
false,
|
||||
knownTokenPrices,
|
||||
getCoingeckoLock,
|
||||
maxCoingeckoRetries
|
||||
);
|
||||
const tvlResults = await computeTVL(tvlBalances, "now");
|
||||
await diplayUnknownTable({ tvlResults, storedKey, tvlBalances, })
|
||||
usdTvls[storedKey] = tvlResults.usdTvl;
|
||||
tokensBalances[storedKey] = tvlResults.tokenBalances;
|
||||
@@ -170,7 +144,6 @@ sdk.api.abi.call = async (...args) => {
|
||||
tvlFunction,
|
||||
tvlFunctionIsFetch,
|
||||
storedKey,
|
||||
knownTokenPrices
|
||||
);
|
||||
let keyToAddChainBalances = tvlType;
|
||||
if (tvlType === "tvl" || tvlType === "fetch") {
|
||||
@@ -201,7 +174,6 @@ sdk.api.abi.call = async (...args) => {
|
||||
mainTvlIsFetch ? module.fetch : module.tvl,
|
||||
mainTvlIsFetch,
|
||||
"tvl",
|
||||
knownTokenPrices
|
||||
);
|
||||
tvlPromises.push(mainTvlPromise);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user