From 438ed201aaff20949cb01e28be0b4a8f0951ddaf Mon Sep 17 00:00:00 2001 From: xiaoch05 Date: Tue, 10 Oct 2023 20:25:32 +0800 Subject: [PATCH] add zksync & native token --- apollo/.env.test | 1 + apollo/src/lnbridgev20/transfer.service.ts | 99 +++++++++++++++++-- .../abis/LnDefaultBridge.json | 98 +++++++----------- subgraph/ln-default-bridge/generate.sh | 2 - subgraph/ln-default-bridge/package.json | 9 +- .../abis/LnOppositeBridge.json | 37 +++++++ subgraph/ln-opposite-bridge/package.json | 8 +- 7 files changed, 175 insertions(+), 79 deletions(-) diff --git a/apollo/.env.test b/apollo/.env.test index 41df3b8b..282bcfc8 100644 --- a/apollo/.env.test +++ b/apollo/.env.test @@ -22,4 +22,5 @@ LN_MANTLE_DEFAULT_ENDPOINT = https://thegraph-g2.darwinia.network/helix/subgraph LN_MANTLE_OPPOSITE_ENDPOINT = https://thegraph-g2.darwinia.network/helix/subgraphs/name/lnopposite/mantlegoerli LN_ARBITRUM_DEFAULT_ENDPOINT = https://thegraph-g2.darwinia.network/helix/subgraphs/name/lndefault/arbigoerli LN_ARBITRUM_OPPOSITE_ENDPOINT = https://thegraph-g2.darwinia.network/helix/subgraphs/name/lnopposite/arbigoerli +LN_ZKSYNC_DEFAULT_ENDPOINT = https://thegraph-g2.darwinia.network/helix/subgraphs/name/lndefault/zkgoerli diff --git a/apollo/src/lnbridgev20/transfer.service.ts b/apollo/src/lnbridgev20/transfer.service.ts index be655757..291d861f 100644 --- a/apollo/src/lnbridgev20/transfer.service.ts +++ b/apollo/src/lnbridgev20/transfer.service.ts @@ -29,6 +29,9 @@ export class TransferService extends BaseTransferServiceT2 { private readonly lnArbitrumOppositeEndpoint = this.configService.get( 'LN_ARBITRUM_OPPOSITE_ENDPOINT' ); + private readonly lnZkSyncDefaultEndpoint = this.configService.get( + 'LN_ZKSYNC_DEFAULT_ENDPOINT' + ); formalChainTransfers: PartnerT2[] = []; @@ -49,6 +52,12 @@ export class TransferService extends BaseTransferServiceT2 { symbol: 'USDT', address: '0x2303e4d55BF16a897Cb5Ab71c6225399509d9314', protocolFee: 100000000000000000000, + decimals: 6, + }, + { + symbol: 'ETH', + address: '0x0000000000000000000000000000000000000000', + protocolFee: 1000000000000000, decimals: 18, }, ], @@ -69,6 +78,18 @@ export class TransferService extends BaseTransferServiceT2 { symbol: 'USDT', address: '0x2303e4d55BF16a897Cb5Ab71c6225399509d9314', protocolFee: 100000000000000000000, + decimals: 6, + }, + { + symbol: 'ETH', + address: '0x0000000000000000000000000000000000000000', + protocolFee: 1000000000000000, + decimals: 18, + }, + { + symbol: 'MNT', + address: '0xc1dc2d65a2243c22344e725677a3e3bebd26e604', + protocolFee: 1000000000000000, decimals: 18, }, ], @@ -83,7 +104,7 @@ export class TransferService extends BaseTransferServiceT2 { symbol: 'USDC', address: '0x39de82e1d9b8f62e11022fc3fc127a82f93fe47e', protocolFee: 100000000, - decimals: 6, + decimals: 18, }, { symbol: 'USDT', @@ -91,6 +112,12 @@ export class TransferService extends BaseTransferServiceT2 { protocolFee: 100000000000000000000, decimals: 18, }, + { + symbol: 'ETH', + address: '0x0000000000000000000000000000000000000000', + protocolFee: 1000000000000000, + decimals: 18, + }, ], }, { @@ -103,7 +130,7 @@ export class TransferService extends BaseTransferServiceT2 { symbol: 'USDC', address: '0x39de82e1d9b8f62e11022fc3fc127a82f93fe47e', protocolFee: 100000000, - decimals: 6, + decimals: 18, }, { symbol: 'USDT', @@ -111,6 +138,12 @@ export class TransferService extends BaseTransferServiceT2 { protocolFee: 100000000000000000000, decimals: 18, }, + { + symbol: 'ETH', + address: '0x0000000000000000000000000000000000000000', + protocolFee: 1000000000000000, + decimals: 18, + }, ], }, { @@ -123,7 +156,7 @@ export class TransferService extends BaseTransferServiceT2 { symbol: 'USDC', address: '0x0258eb547bfed540ed17843658c018569fe1e328', protocolFee: 100000000, - decimals: 6, + decimals: 18, }, { symbol: 'USDT', @@ -131,6 +164,12 @@ export class TransferService extends BaseTransferServiceT2 { protocolFee: 100000000000000000000, decimals: 18, }, + { + symbol: 'MNT', + address: '0x0000000000000000000000000000000000000000', + protocolFee: 1000000000000000, + decimals: 18, + }, ], }, { @@ -143,7 +182,7 @@ export class TransferService extends BaseTransferServiceT2 { symbol: 'USDC', address: '0x0258eb547bfed540ed17843658c018569fe1e328', protocolFee: 100000000, - decimals: 6, + decimals: 18, }, { symbol: 'USDT', @@ -151,6 +190,12 @@ export class TransferService extends BaseTransferServiceT2 { protocolFee: 100000000000000000000, decimals: 18, }, + { + symbol: 'MNT', + address: '0x0000000000000000000000000000000000000000', + protocolFee: 1000000000000000, + decimals: 18, + }, ], }, { @@ -163,13 +208,19 @@ export class TransferService extends BaseTransferServiceT2 { symbol: 'USDC', address: '0xb5e028f980df5533cb0e8f04530b76637383d993', protocolFee: 100000000, - decimals: 6, + decimals: 18, }, { symbol: 'USDT', address: '0xbc1a2f123dc9cd2ec8d3ce42ef16c28f3c9ba686', protocolFee: 100000000, - decimals: 6, + decimals: 18, + }, + { + symbol: 'ETH', + address: '0x0000000000000000000000000000000000000000', + protocolFee: 1000000000000000, + decimals: 18, }, ], }, @@ -183,13 +234,45 @@ export class TransferService extends BaseTransferServiceT2 { symbol: 'USDC', address: '0xb5e028f980df5533cb0e8f04530b76637383d993', protocolFee: 100000000, - decimals: 6, + decimals: 18, }, { symbol: 'USDT', address: '0xbc1a2f123dc9cd2ec8d3ce42ef16c28f3c9ba686', protocolFee: 100000000, - decimals: 6, + decimals: 18, + }, + { + symbol: 'ETH', + address: '0x0000000000000000000000000000000000000000', + protocolFee: 1000000000000000, + decimals: 18, + }, + ], + }, + { + chainId: 280, + chain: 'zksync-goerli', + url: this.lnZkSyncDefaultEndpoint, + bridge: 'default', + symbols: [ + { + symbol: 'USDC', + address: '0xae60e005c560e869a2bad271e38e3c9d78381aff', + protocolFee: 100000000, + decimals: 18, + }, + { + symbol: 'USDT', + address: '0xb5372ed3bb2cba63e7908066ac10ee94d30ea839', + protocolFee: 100000000, + decimals: 18, + }, + { + symbol: 'ETH', + address: '0x0000000000000000000000000000000000000000', + protocolFee: 1000000000000000, + decimals: 18, }, ], }, diff --git a/subgraph/ln-default-bridge/abis/LnDefaultBridge.json b/subgraph/ln-default-bridge/abis/LnDefaultBridge.json index bb790ed2..e7443249 100644 --- a/subgraph/ln-default-bridge/abis/LnDefaultBridge.json +++ b/subgraph/ln-default-bridge/abis/LnDefaultBridge.json @@ -283,67 +283,6 @@ "name": "TokenLocked", "type": "event" }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "remoteChainId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "transferId", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "address", - "name": "provider", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "sourceToken", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "targetToken", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint112", - "name": "amount", - "type": "uint112" - }, - { - "indexed": false, - "internalType": "uint112", - "name": "fee", - "type": "uint112" - }, - { - "indexed": false, - "internalType": "uint32", - "name": "timestamp", - "type": "uint64" - }, - { - "indexed": false, - "internalType": "address", - "name": "receiver", - "type": "address" - } - ], - "name": "TokenLocked", - "type": "event" - }, { "anonymous": false, "inputs": [ @@ -407,6 +346,43 @@ "name": "WithdrawMarginRequest", "type": "event" }, + { + "inputs": [ + { + "internalType": "address", + "name": "appAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "enable", + "type": "bool" + } + ], + "name": "authoriseAppCaller", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "callerWhiteList", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [], "name": "dao", diff --git a/subgraph/ln-default-bridge/generate.sh b/subgraph/ln-default-bridge/generate.sh index f24b5d47..9d614240 100644 --- a/subgraph/ln-default-bridge/generate.sh +++ b/subgraph/ln-default-bridge/generate.sh @@ -25,8 +25,6 @@ dataSources: eventHandlers: - event: TokenLocked(uint256,bytes32,address,address,address,uint112,uint112,uint32,address) handler: handleTokenLocked - - event: TokenLocked(uint256,bytes32,address,address,address,uint112,uint112,uint64,address) - handler: handleTokenLocked - event: LnProviderUpdated(uint256,address,address,address,uint112,uint8) handler: handleLnProviderUpdated - event: TransferFilled(bytes32,address) diff --git a/subgraph/ln-default-bridge/package.json b/subgraph/ln-default-bridge/package.json index b309d273..2e283427 100644 --- a/subgraph/ln-default-bridge/package.json +++ b/subgraph/ln-default-bridge/package.json @@ -4,10 +4,11 @@ "scripts": { "codegen": "graph codegen", "build": "graph build", - "build-goerli": "sh generate.sh goerli 0x54cc9716905ba8ebdD01E6364125cA338Cd0054E 9658728 && graph codegen && graph build", - "build-arbitrum": "sh generate.sh arbigoerli 0x54cc9716905ba8ebdD01E6364125cA338Cd0054E 40151409 && graph codegen && graph build", - "build-linea": "sh generate.sh lineagoerli 0x54cc9716905ba8ebdD01E6364125cA338Cd0054E 1494962 && graph codegen && graph build", - "build-mantle": "sh generate.sh mantlegoerli 0x54cc9716905ba8ebdD01E6364125cA338Cd0054E 19685918 && graph codegen && graph build", + "build-goerli": "sh generate.sh goerli 0x258F81A0B59e0fD84604E3e9fc1b70718927c239 9840927 && graph codegen && graph build", + "build-arbitrum": "sh generate.sh arbigoerli 0x258F81A0B59e0fD84604E3e9fc1b70718927c239 46729061 && graph codegen && graph build", + "build-linea": "sh generate.sh lineagoerli 0x258F81A0B59e0fD84604E3e9fc1b70718927c239 1693292 && graph codegen && graph build", + "build-mantle": "sh generate.sh mantlegoerli 0x258F81A0B59e0fD84604E3e9fc1b70718927c239 23288903 && graph codegen && graph build", + "build-zkgoerli": "sh generate.sh zkgoerli 0x77300647Ac7D751fc1b5B5F8ffA9f63337F2D264 12510285 && graph codegen && graph build", "create-remote": "graph create --access-token ${KEY} --node https://thegraph-g2.darwinia.network/helix/deploy/ lndefault/${NETWORK}", "deploy-remote": "graph deploy --access-token $KEY --node https://thegraph-g2.darwinia.network/helix/deploy/ --ipfs http://g2.generic.darwinia.network:5001/ lndefault/$NETWORK" }, diff --git a/subgraph/ln-opposite-bridge/abis/LnOppositeBridge.json b/subgraph/ln-opposite-bridge/abis/LnOppositeBridge.json index 5ee9b489..c9dd80c0 100644 --- a/subgraph/ln-opposite-bridge/abis/LnOppositeBridge.json +++ b/subgraph/ln-opposite-bridge/abis/LnOppositeBridge.json @@ -315,6 +315,43 @@ "name": "WithdrawMarginRequest", "type": "event" }, + { + "inputs": [ + { + "internalType": "address", + "name": "appAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "enable", + "type": "bool" + } + ], + "name": "authoriseAppCaller", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "callerWhiteList", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [], "name": "dao", diff --git a/subgraph/ln-opposite-bridge/package.json b/subgraph/ln-opposite-bridge/package.json index b0d56ec3..12f370a3 100644 --- a/subgraph/ln-opposite-bridge/package.json +++ b/subgraph/ln-opposite-bridge/package.json @@ -4,10 +4,10 @@ "scripts": { "codegen": "graph codegen", "build": "graph build", - "build-goerli": "sh generate.sh goerli 0x79e6f452f1e491a7aF0382FA0a6EF9368691960D 9658728 && graph codegen && graph build", - "build-arbitrum": "sh generate.sh arbigoerli 0x79e6f452f1e491a7aF0382FA0a6EF9368691960D 40151409 && graph codegen && graph build", - "build-linea": "sh generate.sh lineagoerli 0x79e6f452f1e491a7aF0382FA0a6EF9368691960D 1494962 && graph codegen && graph build", - "build-mantle": "sh generate.sh mantlegoerli 0x79e6f452f1e491a7aF0382FA0a6EF9368691960D 19685918 && graph codegen && graph build", + "build-goerli": "sh generate.sh goerli 0xe8d97E5B87fCA75FE33f9C0278470C975485675C 9840925 && graph codegen && graph build", + "build-arbitrum": "sh generate.sh arbigoerli 0xe8d97E5B87fCA75FE33f9C0278470C975485675C 46728946 && graph codegen && graph build", + "build-linea": "sh generate.sh lineagoerli 0xe8d97E5B87fCA75FE33f9C0278470C975485675C 1693290 && graph codegen && graph build", + "build-mantle": "sh generate.sh mantlegoerli 0xe8d97E5B87fCA75FE33f9C0278470C975485675C 19685918 && graph codegen && graph build", "create-remote": "graph create --access-token $KEY --node https://thegraph-g2.darwinia.network/helix/deploy/ lnopposite/$NETWORK", "deploy-remote": "graph deploy --access-token $KEY --node https://thegraph-g2.darwinia.network/helix/deploy/ --ipfs http://g2.generic.darwinia.network:5001/ lnopposite/$NETWORK" },