Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
23.9.0
1 change: 1 addition & 0 deletions Algebra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
5 changes: 3 additions & 2 deletions Algebra/src/mappings/position-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";



Expand Down Expand Up @@ -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))



Expand Down
2 changes: 1 addition & 1 deletion Algebra/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions Algebra/src/utils/pricing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
]

Expand All @@ -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
]

Expand Down
67 changes: 66 additions & 1 deletion Algebra/src/utils/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions Algebra/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions AlgebraFarming/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion blocklytics/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dataSources:
source:
address: "0x0ddff327ddf7fe838e3e63d02001ef23ad1ede8e"
abi: ConverterRegistryContract
startBlock: 40201026
startBlock: 40995881
mapping:
kind: ethereum/events
apiVersion: 0.0.6
Expand Down
12 changes: 12 additions & 0 deletions node_modules/.yarn-integrity

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions update_addresses.sh
Original file line number Diff line number Diff line change
@@ -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=<version> $0 <input.json>"
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."
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1