diff --git a/subgraphs/exchange-stableswap/arb/abis/PriceLens0.json b/subgraphs/exchange-stableswap/arb/abis/PriceLens0.json index a6cb7b27..e07809ae 100644 --- a/subgraphs/exchange-stableswap/arb/abis/PriceLens0.json +++ b/subgraphs/exchange-stableswap/arb/abis/PriceLens0.json @@ -1,121 +1,132 @@ [ { - "type": "constructor", "inputs": [ - { "name": "nativePriceAggregator", "type": "address", "internalType": "address" }, - { "name": "wnative", "type": "address", "internalType": "address" } + { "internalType": "address", "name": "nativePriceAggregator", "type": "address" }, + { "internalType": "address", "name": "wnative", "type": "address" } ], - "stateMutability": "nonpayable" + "stateMutability": "nonpayable", + "type": "constructor" + }, + { "inputs": [], "name": "IncorrectBaseAddress", "type": "error" }, + { "inputs": [], "name": "IncorrectChainlinkPrice", "type": "error" }, + { "inputs": [], "name": "IncorrectSourceAddress", "type": "error" }, + { "inputs": [], "name": "UnknowPrice", "type": "error" }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "user", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "token", "type": "address" }, + { "indexed": true, "internalType": "enum PriceLens0.SourceType", "name": "sourceType", "type": "uint8" }, + { "indexed": false, "internalType": "address", "name": "sourceAddress", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "baseAddress", "type": "address" } + ], + "name": "UpdateSource", + "type": "event" }, { - "type": "function", - "name": "DECIMALS", "inputs": [], - "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], - "stateMutability": "view" + "name": "DECIMALS", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" }, { - "type": "function", - "name": "_nativePriceAggregator", "inputs": [], - "outputs": [{ "name": "", "type": "address", "internalType": "address" }], - "stateMutability": "view" + "name": "_nativePriceAggregator", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" }, { - "type": "function", - "name": "_wnative", "inputs": [], - "outputs": [{ "name": "", "type": "address", "internalType": "address" }], - "stateMutability": "view" + "name": "_wnative", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" }, { - "type": "function", + "inputs": [{ "internalType": "address", "name": "token", "type": "address" }], "name": "getNativePrice", - "inputs": [{ "name": "token", "type": "address", "internalType": "address" }], - "outputs": [{ "name": "nativePrice", "type": "uint256", "internalType": "uint256" }], - "stateMutability": "view" + "outputs": [{ "internalType": "uint256", "name": "nativePrice", "type": "uint256" }], + "stateMutability": "view", + "type": "function" }, { - "type": "function", + "inputs": [{ "internalType": "address", "name": "token", "type": "address" }], "name": "getUsd", - "inputs": [{ "name": "token", "type": "address", "internalType": "address" }], - "outputs": [{ "name": "price", "type": "uint256", "internalType": "uint256" }], - "stateMutability": "view" + "outputs": [{ "internalType": "uint256", "name": "price", "type": "uint256" }], + "stateMutability": "view", + "type": "function" }, { - "type": "function", - "name": "owner", "inputs": [], - "outputs": [{ "name": "", "type": "address", "internalType": "address" }], - "stateMutability": "view" + "name": "owner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" }, { - "type": "function", + "inputs": [{ "internalType": "address", "name": "nativePriceAggregator", "type": "address" }], "name": "setNativePriceAggregator", - "inputs": [{ "name": "nativePriceAggregator", "type": "address", "internalType": "address" }], "outputs": [], - "stateMutability": "nonpayable" + "stateMutability": "nonpayable", + "type": "function" }, { - "type": "function", - "name": "setSource", "inputs": [ - { "name": "token", "type": "address", "internalType": "address" }, - { "name": "sourceType", "type": "uint8", "internalType": "enum PriceLens0.SourceType" }, - { "name": "sourceAddress", "type": "address", "internalType": "address" }, - { "name": "baseAddress", "type": "address", "internalType": "address" } + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "enum PriceLens0.SourceType", "name": "sourceType", "type": "uint8" }, + { "internalType": "address", "name": "sourceAddress", "type": "address" }, + { "internalType": "address", "name": "baseAddress", "type": "address" } ], + "name": "setSource", "outputs": [], - "stateMutability": "nonpayable" + "stateMutability": "nonpayable", + "type": "function" }, { - "type": "function", - "name": "setSourceList", "inputs": [ { - "name": "sourceList", - "type": "tuple[]", - "internalType": "struct PriceLens0.SourceList[]", "components": [ - { "name": "token", "type": "address", "internalType": "address" }, - { "name": "sourceType", "type": "uint8", "internalType": "enum PriceLens0.SourceType" }, - { "name": "sourceAddress", "type": "address", "internalType": "address" }, - { "name": "baseAddress", "type": "address", "internalType": "address" } - ] + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "enum PriceLens0.SourceType", "name": "sourceType", "type": "uint8" }, + { "internalType": "address", "name": "sourceAddress", "type": "address" }, + { "internalType": "address", "name": "baseAddress", "type": "address" } + ], + "internalType": "struct PriceLens0.SourceList[]", + "name": "sourceList", + "type": "tuple[]" } ], + "name": "setSourceList", "outputs": [], - "stateMutability": "nonpayable" + "stateMutability": "nonpayable", + "type": "function" }, { - "type": "function", + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], "name": "sources", - "inputs": [{ "name": "", "type": "address", "internalType": "address" }], "outputs": [ - { "name": "sourceType", "type": "uint8", "internalType": "enum PriceLens0.SourceType" }, - { "name": "sourceAddress", "type": "address", "internalType": "address" }, - { "name": "baseAddress", "type": "address", "internalType": "address" } + { "internalType": "enum PriceLens0.SourceType", "name": "sourceType", "type": "uint8" }, + { "internalType": "address", "name": "sourceAddress", "type": "address" }, + { "internalType": "address", "name": "baseAddress", "type": "address" } ], - "stateMutability": "view" + "stateMutability": "view", + "type": "function" }, { - "type": "function", + "inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }], "name": "transferOwnership", - "inputs": [{ "name": "newOwner", "type": "address", "internalType": "address" }], "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "event", - "name": "OwnershipTransferred", - "inputs": [ - { "name": "user", "type": "address", "indexed": true, "internalType": "address" }, - { "name": "newOwner", "type": "address", "indexed": true, "internalType": "address" } - ], - "anonymous": false - }, - { "type": "error", "name": "IncorrectBaseAddress", "inputs": [] }, - { "type": "error", "name": "IncorrectChainlinkPrice", "inputs": [] }, - { "type": "error", "name": "IncorrectSourceAddress", "inputs": [] }, - { "type": "error", "name": "UnknowPrice", "inputs": [] } + "stateMutability": "nonpayable", + "type": "function" + } ] diff --git a/subgraphs/exchange-stableswap/arb/mappings/utils/index.ts b/subgraphs/exchange-stableswap/arb/mappings/utils/index.ts index 87aa95c1..02cefdca 100644 --- a/subgraphs/exchange-stableswap/arb/mappings/utils/index.ts +++ b/subgraphs/exchange-stableswap/arb/mappings/utils/index.ts @@ -19,7 +19,9 @@ export let PENDLE_ADDRESS = "0x0c880f6761F1af8d9Aa9C466984b80DAb9a8c9e8"; //When new factory was deployed, and SC address into list export let FACTORIES: string[] = [STABLESWAP_FACTORY_ADDRESS]; -export let priceLensContract = PriceLens0.bind(Address.fromString("0x6234d989583520565d00131948c1fb7c4ebb691d")); +export let PRICE_LENS_ADDRESS = "0xe604940c06df1b6a9851f8e8d8d22468cb932e38"; + +export let priceLensContract = PriceLens0.bind(Address.fromString(PRICE_LENS_ADDRESS)); export let USDT_ADDR = Address.fromString(USDT_ADDRESS); export let USDC_ADDR = Address.fromString(USDC_ADDRESS); diff --git a/subgraphs/exchange-stableswap/arb/mappings/utils/pricing.ts b/subgraphs/exchange-stableswap/arb/mappings/utils/pricing.ts index 894f5906..696b0fdd 100644 --- a/subgraphs/exchange-stableswap/arb/mappings/utils/pricing.ts +++ b/subgraphs/exchange-stableswap/arb/mappings/utils/pricing.ts @@ -13,7 +13,6 @@ import { WETH_ADDR, PENDLE_ADDR, USDC_ADDR, - PENDLE_ADDRESS, priceLensContract, convertTokenToDecimal, BIG_INT_6, @@ -63,8 +62,8 @@ let WHITELIST: string[] = [ // WETH_ADDRESS, // USDT_ADDRESS, // USDC_ADDRESS, - PENDLE_ADDRESS, - "0xB688BA096b7Bb75d7841e47163Cd12D18B36A5bF", // mPENDLE + // PENDLE_ADDRESS, + // "0xB688BA096b7Bb75d7841e47163Cd12D18B36A5bF", // mPENDLE ]; // minimum liquidity for price to get tracked @@ -107,9 +106,6 @@ export function findBnbPerToken(token: Token): BigDecimal { if (Address.fromString(token.id).equals(USDC_ADDR)) { return getPairTokenPrice(USDC_WETH_V3_PAIR, false); } - if (Address.fromString(token.id).equals(PENDLE_ADDR)) { - return getPairTokenPrice(PENDLE_WETH_V3_PAIR, true); - } // loop through whitelist and check if paired with any for (let i = 0; i < WHITELIST.length; ++i) { if (Address.fromString(token.id).equals(Address.fromString(WHITELIST[i]))) { @@ -132,10 +128,16 @@ export function findBnbPerToken(token: Token): BigDecimal { } } let tokenBNBPrice = priceLensContract.try_getNativePrice(Address.fromString(token.id)); + if (!tokenBNBPrice.reverted) { return convertTokenToDecimal(tokenBNBPrice.value, BIG_INT_6); } + // backward compatibility before price lens + if (Address.fromString(token.id).equals(PENDLE_ADDR)) { + return getPairTokenPrice(PENDLE_WETH_V3_PAIR, true); + } + return BIG_DECIMAL_ZERO; // nothing was found return 0 } diff --git a/subgraphs/exchange-stableswap/arb/subgraph.yaml b/subgraphs/exchange-stableswap/arb/subgraph.yaml index 58bfa8f4..095f48bb 100644 --- a/subgraphs/exchange-stableswap/arb/subgraph.yaml +++ b/subgraphs/exchange-stableswap/arb/subgraph.yaml @@ -69,6 +69,8 @@ templates: file: ./abis/PairV3.json - name: ERC20 file: ./abis/ERC20.json + - name: PriceLens0 + file: ./abis/PriceLens0.json eventHandlers: - event: AddLiquidity(indexed address,uint256[2],uint256[2],uint256,uint256) handler: handleAddLiquidity @@ -106,6 +108,8 @@ templates: file: ./abis/PairV3.json - name: ERC20 file: ./abis/ERC20.json + - name: PriceLens0 + file: ./abis/PriceLens0.json eventHandlers: - event: AddLiquidity(indexed address,uint256[3],uint256[3],uint256,uint256) handler: handleTriAddLiquidity diff --git a/subgraphs/exchange-stableswap/bsc/abis/PriceLens0.json b/subgraphs/exchange-stableswap/bsc/abis/PriceLens0.json index a6cb7b27..e07809ae 100644 --- a/subgraphs/exchange-stableswap/bsc/abis/PriceLens0.json +++ b/subgraphs/exchange-stableswap/bsc/abis/PriceLens0.json @@ -1,121 +1,132 @@ [ { - "type": "constructor", "inputs": [ - { "name": "nativePriceAggregator", "type": "address", "internalType": "address" }, - { "name": "wnative", "type": "address", "internalType": "address" } + { "internalType": "address", "name": "nativePriceAggregator", "type": "address" }, + { "internalType": "address", "name": "wnative", "type": "address" } ], - "stateMutability": "nonpayable" + "stateMutability": "nonpayable", + "type": "constructor" + }, + { "inputs": [], "name": "IncorrectBaseAddress", "type": "error" }, + { "inputs": [], "name": "IncorrectChainlinkPrice", "type": "error" }, + { "inputs": [], "name": "IncorrectSourceAddress", "type": "error" }, + { "inputs": [], "name": "UnknowPrice", "type": "error" }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "user", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "token", "type": "address" }, + { "indexed": true, "internalType": "enum PriceLens0.SourceType", "name": "sourceType", "type": "uint8" }, + { "indexed": false, "internalType": "address", "name": "sourceAddress", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "baseAddress", "type": "address" } + ], + "name": "UpdateSource", + "type": "event" }, { - "type": "function", - "name": "DECIMALS", "inputs": [], - "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], - "stateMutability": "view" + "name": "DECIMALS", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" }, { - "type": "function", - "name": "_nativePriceAggregator", "inputs": [], - "outputs": [{ "name": "", "type": "address", "internalType": "address" }], - "stateMutability": "view" + "name": "_nativePriceAggregator", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" }, { - "type": "function", - "name": "_wnative", "inputs": [], - "outputs": [{ "name": "", "type": "address", "internalType": "address" }], - "stateMutability": "view" + "name": "_wnative", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" }, { - "type": "function", + "inputs": [{ "internalType": "address", "name": "token", "type": "address" }], "name": "getNativePrice", - "inputs": [{ "name": "token", "type": "address", "internalType": "address" }], - "outputs": [{ "name": "nativePrice", "type": "uint256", "internalType": "uint256" }], - "stateMutability": "view" + "outputs": [{ "internalType": "uint256", "name": "nativePrice", "type": "uint256" }], + "stateMutability": "view", + "type": "function" }, { - "type": "function", + "inputs": [{ "internalType": "address", "name": "token", "type": "address" }], "name": "getUsd", - "inputs": [{ "name": "token", "type": "address", "internalType": "address" }], - "outputs": [{ "name": "price", "type": "uint256", "internalType": "uint256" }], - "stateMutability": "view" + "outputs": [{ "internalType": "uint256", "name": "price", "type": "uint256" }], + "stateMutability": "view", + "type": "function" }, { - "type": "function", - "name": "owner", "inputs": [], - "outputs": [{ "name": "", "type": "address", "internalType": "address" }], - "stateMutability": "view" + "name": "owner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" }, { - "type": "function", + "inputs": [{ "internalType": "address", "name": "nativePriceAggregator", "type": "address" }], "name": "setNativePriceAggregator", - "inputs": [{ "name": "nativePriceAggregator", "type": "address", "internalType": "address" }], "outputs": [], - "stateMutability": "nonpayable" + "stateMutability": "nonpayable", + "type": "function" }, { - "type": "function", - "name": "setSource", "inputs": [ - { "name": "token", "type": "address", "internalType": "address" }, - { "name": "sourceType", "type": "uint8", "internalType": "enum PriceLens0.SourceType" }, - { "name": "sourceAddress", "type": "address", "internalType": "address" }, - { "name": "baseAddress", "type": "address", "internalType": "address" } + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "enum PriceLens0.SourceType", "name": "sourceType", "type": "uint8" }, + { "internalType": "address", "name": "sourceAddress", "type": "address" }, + { "internalType": "address", "name": "baseAddress", "type": "address" } ], + "name": "setSource", "outputs": [], - "stateMutability": "nonpayable" + "stateMutability": "nonpayable", + "type": "function" }, { - "type": "function", - "name": "setSourceList", "inputs": [ { - "name": "sourceList", - "type": "tuple[]", - "internalType": "struct PriceLens0.SourceList[]", "components": [ - { "name": "token", "type": "address", "internalType": "address" }, - { "name": "sourceType", "type": "uint8", "internalType": "enum PriceLens0.SourceType" }, - { "name": "sourceAddress", "type": "address", "internalType": "address" }, - { "name": "baseAddress", "type": "address", "internalType": "address" } - ] + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "enum PriceLens0.SourceType", "name": "sourceType", "type": "uint8" }, + { "internalType": "address", "name": "sourceAddress", "type": "address" }, + { "internalType": "address", "name": "baseAddress", "type": "address" } + ], + "internalType": "struct PriceLens0.SourceList[]", + "name": "sourceList", + "type": "tuple[]" } ], + "name": "setSourceList", "outputs": [], - "stateMutability": "nonpayable" + "stateMutability": "nonpayable", + "type": "function" }, { - "type": "function", + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], "name": "sources", - "inputs": [{ "name": "", "type": "address", "internalType": "address" }], "outputs": [ - { "name": "sourceType", "type": "uint8", "internalType": "enum PriceLens0.SourceType" }, - { "name": "sourceAddress", "type": "address", "internalType": "address" }, - { "name": "baseAddress", "type": "address", "internalType": "address" } + { "internalType": "enum PriceLens0.SourceType", "name": "sourceType", "type": "uint8" }, + { "internalType": "address", "name": "sourceAddress", "type": "address" }, + { "internalType": "address", "name": "baseAddress", "type": "address" } ], - "stateMutability": "view" + "stateMutability": "view", + "type": "function" }, { - "type": "function", + "inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }], "name": "transferOwnership", - "inputs": [{ "name": "newOwner", "type": "address", "internalType": "address" }], "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "event", - "name": "OwnershipTransferred", - "inputs": [ - { "name": "user", "type": "address", "indexed": true, "internalType": "address" }, - { "name": "newOwner", "type": "address", "indexed": true, "internalType": "address" } - ], - "anonymous": false - }, - { "type": "error", "name": "IncorrectBaseAddress", "inputs": [] }, - { "type": "error", "name": "IncorrectChainlinkPrice", "inputs": [] }, - { "type": "error", "name": "IncorrectSourceAddress", "inputs": [] }, - { "type": "error", "name": "UnknowPrice", "inputs": [] } + "stateMutability": "nonpayable", + "type": "function" + } ] diff --git a/subgraphs/exchange-stableswap/bsc/subgraph.yaml b/subgraphs/exchange-stableswap/bsc/subgraph.yaml index 665ad564..8638b507 100644 --- a/subgraphs/exchange-stableswap/bsc/subgraph.yaml +++ b/subgraphs/exchange-stableswap/bsc/subgraph.yaml @@ -73,6 +73,8 @@ templates: file: ./abis/Pair.json - name: PairV3 file: ./abis/PairV3.json + - name: PriceLens0 + file: ./abis/PriceLens0.json eventHandlers: - event: AddLiquidity(indexed address,uint256[2],uint256[2],uint256,uint256) handler: handleAddLiquidity @@ -108,6 +110,8 @@ templates: file: ./abis/Pair.json - name: PairV3 file: ./abis/PairV3.json + - name: PriceLens0 + file: ./abis/PriceLens0.json eventHandlers: - event: AddLiquidity(indexed address,uint256[2],uint256[2],uint256,uint256) handler: handleAddLiquidity @@ -143,6 +147,8 @@ templates: file: ./abis/Pair.json - name: PairV3 file: ./abis/PairV3.json + - name: PriceLens0 + file: ./abis/PriceLens0.json eventHandlers: - event: AddLiquidity(indexed address,uint256[3],uint256[3],uint256,uint256) handler: handleTriAddLiquidity