@@ -21,6 +21,9 @@ import { Pool } from '@model'
2121import { Context , EvmBatchProcessor , defineProcessor , joinProcessors , logFilter } from '@originprotocol/squid-utils'
2222import { baseAddresses } from '@utils/addresses-base'
2323
24+ /** Strip null bytes that some contracts return from bytes32 storage. PostgreSQL rejects \0 in text. */
25+ const clean = ( s : string ) => s . replace ( / \0 / g, '' )
26+
2427/**
2528 * For curve data refer to the AddressProvider:
2629 * https://docs.curve.fi/integration/address-provider/?h=addressprovider
@@ -226,15 +229,15 @@ export const createCurveStableProcessor = (params: { address: string; from: numb
226229 // Handle meta pool
227230 const poolContract = new stableSwapMetaNgAbi . Contract ( ctx , block . header , poolAddress )
228231 const [ name , symbol , coins ] = await Promise . all ( [
229- poolContract . name ( ) ,
230- poolContract . symbol ( ) ,
232+ poolContract . name ( ) . then ( clean ) ,
233+ poolContract . symbol ( ) . then ( clean ) ,
231234 factory . get_coins ( poolAddress ) ,
232235 ] )
233236 const [ symbols , decimals ] = await Promise . all ( [
234237 Promise . all (
235238 coins . map ( async ( coin ) => {
236239 const tokenContract = new erc20Abi . Contract ( ctx , block . header , coin )
237- return tokenContract . symbol ( )
240+ return tokenContract . symbol ( ) . then ( clean )
238241 } ) ,
239242 ) ,
240243 Promise . all (
@@ -264,15 +267,15 @@ export const createCurveStableProcessor = (params: { address: string; from: numb
264267 // Handle plain pool
265268 const poolContract = new stableSwapNgAbi . Contract ( ctx , block . header , poolAddress )
266269 const [ name , symbol , coins ] = await Promise . all ( [
267- poolContract . name ( ) ,
268- poolContract . symbol ( ) ,
270+ poolContract . name ( ) . then ( clean ) ,
271+ poolContract . symbol ( ) . then ( clean ) ,
269272 factory . get_coins ( poolAddress ) ,
270273 ] )
271274 const [ symbols , decimals ] = await Promise . all ( [
272275 Promise . all (
273276 coins . map ( async ( coin ) => {
274277 const tokenContract = new erc20Abi . Contract ( ctx , block . header , coin )
275- return tokenContract . symbol ( )
278+ return tokenContract . symbol ( ) . then ( clean )
276279 } ) ,
277280 ) ,
278281 Promise . all (
@@ -329,7 +332,7 @@ export const createCurveTwoCryptoProcessor = (params: { address: string; from: n
329332 Promise . all (
330333 data . coins . map ( async ( coin ) => {
331334 const tokenContract = new erc20Abi . Contract ( ctx , block . header , coin )
332- return tokenContract . symbol ( )
335+ return tokenContract . symbol ( ) . then ( clean )
333336 } ) ,
334337 ) ,
335338 Promise . all (
@@ -343,8 +346,8 @@ export const createCurveTwoCryptoProcessor = (params: { address: string; from: n
343346 id : `${ ctx . chain . id } :${ data . pool } ` ,
344347 chainId : ctx . chain . id ,
345348 address : data . pool ,
346- name : data . name ,
347- symbol : data . symbol ,
349+ name : clean ( data . name ) ,
350+ symbol : clean ( data . symbol ) ,
348351 createdAtBlock : block . header . height ,
349352 createdAt : new Date ( block . header . timestamp ) ,
350353 tokens : data . coins . map ( ( coin ) => coin . toLowerCase ( ) ) ,
@@ -384,7 +387,7 @@ export const createCurveTriCryptoProcessor = (params: { address: string; from: n
384387 Promise . all (
385388 data . coins . map ( async ( coin ) => {
386389 const tokenContract = new erc20Abi . Contract ( ctx , block . header , coin )
387- return tokenContract . symbol ( )
390+ return tokenContract . symbol ( ) . then ( clean )
388391 } ) ,
389392 ) ,
390393 Promise . all (
@@ -398,8 +401,8 @@ export const createCurveTriCryptoProcessor = (params: { address: string; from: n
398401 id : `${ ctx . chain . id } :${ data . pool } ` ,
399402 chainId : ctx . chain . id ,
400403 address : data . pool ,
401- name : data . name ,
402- symbol : data . symbol ,
404+ name : clean ( data . name ) ,
405+ symbol : clean ( data . symbol ) ,
403406 createdAtBlock : block . header . height ,
404407 createdAt : new Date ( block . header . timestamp ) ,
405408 tokens : data . coins . map ( ( coin ) => coin . toLowerCase ( ) ) ,
@@ -439,10 +442,10 @@ export const createSwapxPairProcessor = (params: { address: string; from: number
439442 const token1Contract = new erc20Abi . Contract ( ctx , block . header , data . token1 )
440443 const poolContract = new erc20Abi . Contract ( ctx , block . header , data . pair )
441444 const [ name , symbol , symbol0 , symbol1 , decimals0 , decimals1 ] = await Promise . all ( [
442- poolContract . name ( ) ,
443- poolContract . symbol ( ) ,
444- token0Contract . symbol ( ) ,
445- token1Contract . symbol ( ) ,
445+ poolContract . name ( ) . then ( clean ) ,
446+ poolContract . symbol ( ) . then ( clean ) ,
447+ token0Contract . symbol ( ) . then ( clean ) ,
448+ token1Contract . symbol ( ) . then ( clean ) ,
446449 token0Contract . decimals ( ) ,
447450 token1Contract . decimals ( ) ,
448451 ] )
@@ -491,8 +494,8 @@ export const createAlgebraProcessor = (params: { address: string; from: number }
491494 const token1Contract = new erc20Abi . Contract ( ctx , block . header , data . token1 )
492495 const poolContract = new algebraPoolAbi . Contract ( ctx , block . header , data . pool )
493496 const [ symbol0 , symbol1 , decimals0 , decimals1 , tickSpacing ] = await Promise . all ( [
494- token0Contract . symbol ( ) ,
495- token1Contract . symbol ( ) ,
497+ token0Contract . symbol ( ) . then ( clean ) ,
498+ token1Contract . symbol ( ) . then ( clean ) ,
496499 token0Contract . decimals ( ) ,
497500 token1Contract . decimals ( ) ,
498501 poolContract . tickSpacing ( ) ,
@@ -550,8 +553,8 @@ export const createAeroProcessor = () => {
550553 let symbol0 : string , symbol1 : string , decimals0 : number , decimals1 : number
551554 try {
552555 ; [ symbol0 , symbol1 , decimals0 , decimals1 ] = await Promise . all ( [
553- token0Contract . symbol ( ) ,
554- token1Contract . symbol ( ) ,
556+ token0Contract . symbol ( ) . then ( clean ) ,
557+ token1Contract . symbol ( ) . then ( clean ) ,
555558 token0Contract . decimals ( ) ,
556559 token1Contract . decimals ( ) ,
557560 ] )
@@ -585,8 +588,8 @@ export const createAeroProcessor = () => {
585588 let symbol0 : string , symbol1 : string , decimals0 : number , decimals1 : number
586589 try {
587590 ; [ symbol0 , symbol1 , decimals0 , decimals1 ] = await Promise . all ( [
588- token0Contract . symbol ( ) ,
589- token1Contract . symbol ( ) ,
591+ token0Contract . symbol ( ) . then ( clean ) ,
592+ token1Contract . symbol ( ) . then ( clean ) ,
590593 token0Contract . decimals ( ) ,
591594 token1Contract . decimals ( ) ,
592595 ] )
@@ -648,8 +651,8 @@ export const createMetropolisProcessor = () => {
648651 const token0Contract = new erc20Abi . Contract ( ctx , block . header , data . token0 )
649652 const token1Contract = new erc20Abi . Contract ( ctx , block . header , data . token1 )
650653 const [ symbol0 , symbol1 , decimals0 , decimals1 ] = await Promise . all ( [
651- token0Contract . symbol ( ) ,
652- token1Contract . symbol ( ) ,
654+ token0Contract . symbol ( ) . then ( clean ) ,
655+ token1Contract . symbol ( ) . then ( clean ) ,
653656 token0Contract . decimals ( ) ,
654657 token1Contract . decimals ( ) ,
655658 ] )
@@ -673,8 +676,8 @@ export const createMetropolisProcessor = () => {
673676 const token0Contract = new erc20Abi . Contract ( ctx , block . header , data . tokenX )
674677 const token1Contract = new erc20Abi . Contract ( ctx , block . header , data . tokenY )
675678 const [ symbol0 , symbol1 , decimals0 , decimals1 ] = await Promise . all ( [
676- token0Contract . symbol ( ) ,
677- token1Contract . symbol ( ) ,
679+ token0Contract . symbol ( ) . then ( clean ) ,
680+ token1Contract . symbol ( ) . then ( clean ) ,
678681 token0Contract . decimals ( ) ,
679682 token1Contract . decimals ( ) ,
680683 ] )
@@ -729,8 +732,8 @@ export const createShadowProcessor = () => {
729732 const token0Contract = new erc20Abi . Contract ( ctx , block . header , data . token0 )
730733 const token1Contract = new erc20Abi . Contract ( ctx , block . header , data . token1 )
731734 const [ symbol0 , symbol1 , decimals0 , decimals1 ] = await Promise . all ( [
732- token0Contract . symbol ( ) ,
733- token1Contract . symbol ( ) ,
735+ token0Contract . symbol ( ) . then ( clean ) ,
736+ token1Contract . symbol ( ) . then ( clean ) ,
734737 token0Contract . decimals ( ) ,
735738 token1Contract . decimals ( ) ,
736739 ] )
@@ -754,8 +757,8 @@ export const createShadowProcessor = () => {
754757 const token0Contract = new erc20Abi . Contract ( ctx , block . header , data . token0 )
755758 const token1Contract = new erc20Abi . Contract ( ctx , block . header , data . token1 )
756759 const [ symbol0 , symbol1 , decimals0 , decimals1 ] = await Promise . all ( [
757- token0Contract . symbol ( ) ,
758- token1Contract . symbol ( ) ,
760+ token0Contract . symbol ( ) . then ( clean ) ,
761+ token1Contract . symbol ( ) . then ( clean ) ,
759762 token0Contract . decimals ( ) ,
760763 token1Contract . decimals ( ) ,
761764 ] )
@@ -803,8 +806,8 @@ export const createMaverickV2Processor = (params: { address: string; from: numbe
803806 const token0Contract = new erc20Abi . Contract ( ctx , block . header , data . tokenA )
804807 const token1Contract = new erc20Abi . Contract ( ctx , block . header , data . tokenB )
805808 const [ symbol0 , symbol1 , decimals0 , decimals1 ] = await Promise . all ( [
806- token0Contract . symbol ( ) ,
807- token1Contract . symbol ( ) ,
809+ token0Contract . symbol ( ) . then ( clean ) ,
810+ token1Contract . symbol ( ) . then ( clean ) ,
808811 token0Contract . decimals ( ) ,
809812 token1Contract . decimals ( ) ,
810813 ] )
0 commit comments