diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 482bddd1..baf46d52 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -17,6 +17,7 @@ on: - governance-staking - magicswap - smol + - memecoins version: description: Subgraph version required: true diff --git a/package-lock.json b/package-lock.json index 23b93b21..8f7785da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5591,10 +5591,6 @@ "resolved": "subgraphs/magicswap", "link": true }, - "node_modules/magicswap-exchange": { - "resolved": "subgraphs/magicswap-exchange", - "link": true - }, "node_modules/make-error": { "version": "1.3.6", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", @@ -5624,6 +5620,10 @@ "safe-buffer": "^5.1.2" } }, + "node_modules/memecoins": { + "resolved": "subgraphs/memecoins", + "link": true + }, "node_modules/merge-options": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/merge-options/-/merge-options-3.0.4.tgz", @@ -7862,6 +7862,11 @@ "license": "MIT" }, "subgraphs/magicswap-exchange": { + "version": "1.0.0", + "extraneous": true, + "license": "MIT" + }, + "subgraphs/memecoins": { "version": "1.0.0", "license": "MIT" }, diff --git a/packages/config/src/arbitrum-sepolia.json b/packages/config/src/arbitrum-sepolia.json index b7593819..f7c6e029 100644 --- a/packages/config/src/arbitrum-sepolia.json +++ b/packages/config/src/arbitrum-sepolia.json @@ -67,6 +67,8 @@ "transmolgrifier_address": "0x4489eee4b7218a74d516396c2f3ee6eba54f0773", "transmolgrifier_start_block": 6249003, "smol_renderer_address": "0x79973af48c424de5f199a7c0369c5e9cdeb493fc", + "meme_presale_address": "0xCb7CB8450f41C2169DA05C653e7350Bff6769297", + "meme_presale_start_block": 81571350, "magicswapv1_start_block": 654981, "magicswapv1_uniswapv2_factory_address": "0x9b58fc8c7B224Ae8479DA7E6eD37CA4Ac58099a9", diff --git a/subgraphs/memecoins/abis/MemePresale.json b/subgraphs/memecoins/abis/MemePresale.json new file mode 100644 index 00000000..b592d599 --- /dev/null +++ b/subgraphs/memecoins/abis/MemePresale.json @@ -0,0 +1,527 @@ +[ + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "_fakemagic", + "type": "address" + }, + { + "internalType": "address", + "name": "_teamwallet", + "type": "address" + }, + { + "internalType": "contract INftVaultFactory", + "name": "_factory", + "type": "address" + }, + { + "internalType": "contract IMagicSwapV2Router", + "name": "_router", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "targetMagicToRaise", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "presalePrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "magicRaised", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalsupply", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "graduated", + "type": "bool" + }, + { + "internalType": "contract IERC1155", + "name": "memecoin", + "type": "address" + } + ], + "indexed": false, + "internalType": "struct PRESALE.PresaleInfo", + "name": "presaleinfo", + "type": "tuple" + } + ], + "name": "BuySell", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "targetMagicToRaise", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "presalePrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "magicRaised", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalsupply", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "graduated", + "type": "bool" + }, + { + "internalType": "contract IERC1155", + "name": "memecoin", + "type": "address" + } + ], + "indexed": false, + "internalType": "struct PRESALE.PresaleInfo", + "name": "presaleinfo", + "type": "tuple" + } + ], + "name": "Graduation", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "indexed": false, + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "indexed": false, + "internalType": "string", + "name": "uri", + "type": "string" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "targetMagicToRaise", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "presalePrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "magicRaised", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalsupply", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "graduated", + "type": "bool" + }, + { + "internalType": "contract IERC1155", + "name": "memecoin", + "type": "address" + } + ], + "indexed": false, + "internalType": "struct PRESALE.PresaleInfo", + "name": "presaleinfo", + "type": "tuple" + } + ], + "name": "MemeMade", + "type": "event" + }, + { + "inputs": [], + "name": "TARGETMCAP", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_memeCoinAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_spendAmountMagic", + "type": "uint256" + } + ], + "name": "buyPresaleMagic", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_memeCoinAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amountNftToBuy", + "type": "uint256" + } + ], + "name": "buyPresaleNFT", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getMagicPriceUSD", + "outputs": [ + { + "internalType": "uint256", + "name": "magicprice", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_memeCoinAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amountOfMagicToSpend", + "type": "uint256" + } + ], + "name": "getQuoteMagic", + "outputs": [ + { + "internalType": "uint256", + "name": "totalroundeddown", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "leftovermagic", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_memeCoinAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amountOfNftToBuy", + "type": "uint256" + } + ], + "name": "getQuoteNft", + "outputs": [ + { + "internalType": "uint256", + "name": "totalmagic", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "lastdeploy", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "onERC1155BatchReceived", + "outputs": [ + { + "internalType": "bytes4", + "name": "", + "type": "bytes4" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "onERC1155Received", + "outputs": [ + { + "internalType": "bytes4", + "name": "", + "type": "bytes4" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "presaleinfo", + "outputs": [ + { + "internalType": "uint256", + "name": "targetMagicToRaise", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "presalePrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "magicRaised", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "totalsupply", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "graduated", + "type": "bool" + }, + { + "internalType": "contract IERC1155", + "name": "memecoin", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_memeCoinAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_desiredAmountMagic", + "type": "uint256" + } + ], + "name": "sellPresaleMagic", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_memeCoinAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_sellAmountNFT", + "type": "uint256" + } + ], + "name": "sellPresaleNFT", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "_name", + "type": "string" + }, + { + "internalType": "string", + "name": "_symbol", + "type": "string" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "internalType": "string", + "name": "_uri", + "type": "string" + } + ], + "name": "startPresale", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "teamwallet", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } +] \ No newline at end of file diff --git a/subgraphs/memecoins/package.json b/subgraphs/memecoins/package.json new file mode 100644 index 00000000..46c8667a --- /dev/null +++ b/subgraphs/memecoins/package.json @@ -0,0 +1,10 @@ +{ + "name": "memecoins", + "version": "1.0.0", + "description": "Subgraph that powers Memecoins", + "license": "MIT", + "scripts": { + "generate:dev": "npm run prepare:arbitrum-sepolia --prefix=../../packages/constants && mustache ../../node_modules/@treasure/subgraph-config/src/arbitrum-sepolia.json template.yaml > subgraph.yaml && graph codegen", + "generate:prod": "npm run prepare:arbitrum --prefix=../../packages/constants && mustache ../../node_modules/@treasure/subgraph-config/src/arbitrum.json template.yaml > subgraph.yaml && graph codegen" + } +} diff --git a/subgraphs/memecoins/schema.graphql b/subgraphs/memecoins/schema.graphql new file mode 100644 index 00000000..0cf0395b --- /dev/null +++ b/subgraphs/memecoins/schema.graphql @@ -0,0 +1,20 @@ +enum Gender { + Unset + Male + Female +} + +type MemePresale @entity { + id: Bytes! + + name: String + symbol: String + uri: String + amount: BigInt! + + targetMagicToRaise: BigInt! + presalePrice: BigInt! + magicRaised: BigInt! + totalsupply: BigInt! + graduated: Boolean! +} diff --git a/subgraphs/memecoins/src/mapping.ts b/subgraphs/memecoins/src/mapping.ts new file mode 100644 index 00000000..08ef0866 --- /dev/null +++ b/subgraphs/memecoins/src/mapping.ts @@ -0,0 +1,19 @@ +import { MemeMade } from "../generated/Meme Presale/MemePresale"; +import { MemePresale } from "../generated/schema"; + +export function handleMemeMade(event: MemeMade): void { + const params = event.params; + const memePresale = new MemePresale(params.presaleinfo.memecoin); + + memePresale.name = params.name; + memePresale.symbol = params.symbol; + memePresale.uri = params.uri; + memePresale.amount = params.amount; + memePresale.targetMagicToRaise = params.presaleinfo.targetMagicToRaise; + memePresale.presalePrice = params.presaleinfo.presalePrice; + memePresale.magicRaised = params.presaleinfo.magicRaised; + memePresale.totalsupply = params.presaleinfo.totalsupply; + memePresale.graduated = params.presaleinfo.graduated; + + memePresale.save(); +} diff --git a/subgraphs/memecoins/template.yaml b/subgraphs/memecoins/template.yaml new file mode 100644 index 00000000..667ee5d3 --- /dev/null +++ b/subgraphs/memecoins/template.yaml @@ -0,0 +1,24 @@ +specVersion: 0.0.4 +schema: + file: ./schema.graphql +dataSources: + - name: Meme Presale + kind: ethereum/contract + network: {{ network }} + source: + address: "{{ meme_presale_address }}" + abi: MemePresale + startBlock: {{ meme_presale_start_block }} + mapping: + kind: ethereum/events + apiVersion: 0.0.6 + language: wasm/assemblyscript + entities: + - Trait + abis: + - name: MemePresale + file: ./abis/MemePresale.json + eventHandlers: + - event: MemeMade(string,string,string,uint256,(uint256,uint256,uint256,uint256,bool,address)) + handler: handleMemeMade + file: ./src/mapping.ts