diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000..138eca47 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +23.9.0 \ No newline at end of file diff --git a/Algebra/package.json b/Algebra/package.json index 4e25222a..ba271159 100644 --- a/Algebra/package.json +++ b/Algebra/package.json @@ -11,6 +11,7 @@ "deploy-local": "graph deploy cryptoalgebra/algebra --debug --ipfs http://localhost:5001 --node http://127.0.0.1:8020", "deploy": "graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ --access-token iliaazhel/integral-core subgraph.yaml", "deploy-dev": "graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ --access-token a3f47169869d4585a475d0d1d10a4062 iliaazhel/fuzzyswap subgraph.yaml", + "deploy-goldsky": "goldsky subgraph deploy poap-subgraph-core/devnet-28.7.2025 --path .", "create": "graph create cryptoalgebra/info --node https://api.thegraph.com/create/" }, "devDependencies": { diff --git a/Algebra/src/mappings/position-manager.ts b/Algebra/src/mappings/position-manager.ts index 7da04d76..01f637f4 100644 --- a/Algebra/src/mappings/position-manager.ts +++ b/Algebra/src/mappings/position-manager.ts @@ -10,6 +10,7 @@ import { Position, PositionSnapshot, Token} from '../types/schema' import { ADDRESS_ZERO, factoryContract, ZERO_BD, ZERO_BI, pools_list} from '../utils/constants' import { Address, BigInt, ethereum } from '@graphprotocol/graph-ts' import { convertTokenToDecimal, loadTransaction } from '../utils' +import {getOrCreateToken} from "../utils/token"; @@ -117,8 +118,8 @@ export function handleIncreaseLiquidity(event: IncreaseLiquidity): void { return } - let token0 = Token.load(position.token0) - let token1 = Token.load(position.token1) + let token0 = getOrCreateToken(Address.fromString(position.token0)) + let token1 = getOrCreateToken(Address.fromString(position.token1)) diff --git a/Algebra/src/utils/constants.ts b/Algebra/src/utils/constants.ts index feb5c338..76650f93 100644 --- a/Algebra/src/utils/constants.ts +++ b/Algebra/src/utils/constants.ts @@ -4,7 +4,7 @@ import { Factory as FactoryContract } from '../types/templates/Pool/Factory' export const ADDRESS_ZERO = '0x0000000000000000000000000000000000000000' -export const FACTORY_ADDRESS = '0xd7cB0E0692f2D55A17bA81c1fE5501D66774fC4A' +export const FACTORY_ADDRESS = '0x8F32501837F1E354CA84Fa74C194da1411A200a7' export const FEE_DENOMINATOR = BigDecimal.fromString('1000000') export let ZERO_BI = BigInt.fromI32(0) diff --git a/Algebra/src/utils/pricing.ts b/Algebra/src/utils/pricing.ts index d8edc10c..8e88de4c 100644 --- a/Algebra/src/utils/pricing.ts +++ b/Algebra/src/utils/pricing.ts @@ -5,14 +5,14 @@ import { BigDecimal, BigInt } from '@graphprotocol/graph-ts' import { exponentToBigDecimal, safeDiv } from '../utils/index' const WMatic_ADDRESS = '0xb3b3cbed8243682845c2ff23ea1fd48e6144e34f' -const USDC_WMatic_03_POOL = '0x5b66a95f9e9340aa17d9926942cb624d82e6dbed' +const USDC_WMatic_03_POOL = '0x66177ab4ab19a48fc25339a07fc14cf5c62ec33e' // token where amounts should contribute to tracked volume and liquidity // usually tokens that many tokens are paired with s export let WHITELIST_TOKENS: string[] = [ '0xb3b3cbed8243682845c2ff23ea1fd48e6144e34f', // WMATIC - '0xbb0ab77cf6e08f03e4cceabba163860cd1848df7', // USDC - '0x5aefba317baba46eaf98fd6f381d07673bca6467', // USDT + '0x0ea98bf8ff474639f6cbeb4c4bdd1ba74aa9a4a4', // USDC + '0x5aefba317baba46eaf98fd6f381d07673bca6467', // USDT '0x49a390a3dfd2d01389f799965f3af5961f87d228' ] @@ -21,7 +21,7 @@ let MINIMUM_Matic_LOCKED = BigDecimal.fromString('0') let Q192 = Math.pow(2, 192) let STABLE_COINS: string[] = [ - '0xbb0ab77cf6e08f03e4cceabba163860cd1848df7', // USDC + '0x0ea98bf8ff474639f6cbeb4c4bdd1ba74aa9a4a4', // USDC '0xabac6f23fdf1313fc2e9c9244f666157ccd32990' // SUDT ] diff --git a/Algebra/src/utils/token.ts b/Algebra/src/utils/token.ts index 8039dbad..93841427 100644 --- a/Algebra/src/utils/token.ts +++ b/Algebra/src/utils/token.ts @@ -3,9 +3,74 @@ import { ERC20 } from '../types/Factory/ERC20' import { ERC20SymbolBytes } from '../types/Factory/ERC20SymbolBytes' import { ERC20NameBytes } from '../types/Factory/ERC20NameBytes' import { StaticTokenDefinition } from './staticTokenDefinition' -import { BigInt, Address } from '@graphprotocol/graph-ts' +import {BigInt, Address, BigDecimal} from '@graphprotocol/graph-ts' import { isNullEthValue } from '.' +import {Token} from "../types/schema"; +const ZERO_BI = BigInt.fromI32(0) +const ZERO_BD = BigDecimal.fromString("0") +export function getOrCreateToken(tokenAddress: Address): Token | null { + let tokenId = tokenAddress.toHexString() + let token = Token.load(tokenId) + + if (token == null) { + token = new Token(tokenId) + + // Bind the contract to call methods + let contract = ERC20.bind(tokenAddress) + + // Fetch symbol + let symbol = "unknown" + let symbolResult = contract.try_symbol() + if (!symbolResult.reverted) { + symbol = symbolResult.value + } + token.symbol = symbol + + // Fetch name + let name = "unknown" + let nameResult = contract.try_name() + if (!nameResult.reverted) { + name = nameResult.value + } + token.name = name + + // Fetch total supply + let totalSupply = ZERO_BI + let totalSupplyResult = contract.try_totalSupply() + if (!totalSupplyResult.reverted) { + totalSupply = totalSupplyResult.value + } + token.totalSupply = totalSupply + + // Fetch decimals - bail if null + let decimalsResult = contract.try_decimals() + if (decimalsResult.reverted) { + token.decimals = BigInt.fromI32(18); + } + else { + token.decimals = BigInt.fromI32(decimalsResult.value) + } + + // Initialize zero/default fields + token.derivedMatic = ZERO_BD + token.volume = ZERO_BD + token.volumeUSD = ZERO_BD + token.untrackedVolumeUSD = ZERO_BD + token.feesUSD = ZERO_BD + token.totalValueLocked = ZERO_BD + token.totalValueLockedUSD = ZERO_BD + token.totalValueLockedUSDUntracked = ZERO_BD + token.txCount = ZERO_BI + token.poolCount = ZERO_BI + token.whitelistPools = [] + + // Save the new token entity + token.save() + } + + return token +} export function fetchTokenSymbol(tokenAddress: Address): string { let contract = ERC20.bind(tokenAddress) diff --git a/Algebra/subgraph.yaml b/Algebra/subgraph.yaml index c75a5852..c2ea086c 100644 --- a/Algebra/subgraph.yaml +++ b/Algebra/subgraph.yaml @@ -7,9 +7,9 @@ dataSources: name: Factory network: avalanche-testnet source: - address: '0xd7cB0E0692f2D55A17bA81c1fE5501D66774fC4A' + address: '0x8F32501837F1E354CA84Fa74C194da1411A200a7' abi: Factory - startBlock: 40201026 + startBlock: 40995881 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -40,9 +40,9 @@ dataSources: name: NonfungiblePositionManager network: avalanche-testnet source: - address: '0xB4F9b6b019E75CBe51af4425b2Fc12797e2Ee2a1' + address: '0xdca7f48C88D6B466CEec70261bc68E64c5b1fDDF' abi: NonfungiblePositionManager - startBlock: 40201026 + startBlock: 40995881 mapping: kind: ethereum/events apiVersion: 0.0.6 diff --git a/AlgebraFarming/subgraph.yaml b/AlgebraFarming/subgraph.yaml index 8a0c7513..2101b6a1 100644 --- a/AlgebraFarming/subgraph.yaml +++ b/AlgebraFarming/subgraph.yaml @@ -7,9 +7,9 @@ dataSources: name: NonfungiblePositionManager network: avalanche-testnet source: - address: '0xB4F9b6b019E75CBe51af4425b2Fc12797e2Ee2a1' + address: '0x8a4179FEA7CC44a4B142Aa6f46c382a4279e0aAe' abi: NonfungiblePositionManager - startBlock: 40201026 + startBlock: 40995881 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -38,9 +38,9 @@ dataSources: name: EternalFarming network: avalanche-testnet source: - address: '0x658E287E9C820484f5808f687dC4863B552de37D' + address: '0x95781e8d537D661Ae8264ae3069B92E5c80aCF34' abi: EternalFarming - startBlock: 40201026 + startBlock: 40995881 mapping: kind: ethereum/events apiVersion: 0.0.6 diff --git a/blocklytics/subgraph.yaml b/blocklytics/subgraph.yaml index 4a59e488..9ddfad43 100644 --- a/blocklytics/subgraph.yaml +++ b/blocklytics/subgraph.yaml @@ -10,7 +10,7 @@ dataSources: source: address: "0x0ddff327ddf7fe838e3e63d02001ef23ad1ede8e" abi: ConverterRegistryContract - startBlock: 40201026 + startBlock: 40995881 mapping: kind: ethereum/events apiVersion: 0.0.6 diff --git a/node_modules/.yarn-integrity b/node_modules/.yarn-integrity new file mode 100644 index 00000000..63b2ffe0 --- /dev/null +++ b/node_modules/.yarn-integrity @@ -0,0 +1,12 @@ +{ + "systemParams": "darwin-arm64-127", + "modulesFolders": [ + "node_modules" + ], + "flags": [], + "linkedModules": [], + "topLevelPatterns": [], + "lockfileEntries": {}, + "files": [], + "artifacts": {} +} \ No newline at end of file diff --git a/update_addresses.sh b/update_addresses.sh new file mode 100644 index 00000000..83ee2059 --- /dev/null +++ b/update_addresses.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# Usage: VERSION_TO_DEPLOY=30.6.2025 ./update_addresses.sh input.json + +if [ "$#" -ne 1 ]; then + echo "Usage: VERSION_TO_DEPLOY= $0 " + exit 1 +fi + +if [ -z "$VERSION_TO_DEPLOY" ]; then + echo "❌ VERSION_TO_DEPLOY env variable is not set" + exit 1 +fi + +JSON_FILE="$1" +CONSTANTS_FILE="Algebra/src/utils/constants.ts" +SUBGRAPH_FILE="Algebra/subgraph.yaml" +PACKAGE_FILE="Algebra/package.json" + +# Extract addresses from JSON +FACTORY=$(jq -r '.factory' "$JSON_FILE") +NONFUNGIBLE_POSITION_MANAGER=$(jq -r '.nonfungiblePositionManager' "$JSON_FILE") + +# === constants.ts === +sed -i '' -E "s|export const FACTORY_ADDRESS = '0x[a-fA-F0-9]{40}'|export const FACTORY_ADDRESS = '$FACTORY'|" "$CONSTANTS_FILE" + +# === subgraph.yaml === +sed -i '' -E "/name: Factory/ { + N;N;N;N; + s/address: '0x[a-fA-F0-9]{40}'/address: '$FACTORY'/ +}" "$SUBGRAPH_FILE" + +sed -i '' -E "/name: NonfungiblePositionManager/ { + N;N;N;N; + s/address: '0x[a-fA-F0-9]{40}'/address: '$NONFUNGIBLE_POSITION_MANAGER'/ +}" "$SUBGRAPH_FILE" + +# === package.json === +# Replace anything after poap-subgraph-core/ and before --path +sed -i '' -E "s|(poap-subgraph-core/)[^ ]+|\1${VERSION_TO_DEPLOY}|" "$PACKAGE_FILE" + +echo "✅ All updates applied successfully." diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 00000000..fb57ccd1 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,4 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + +