Skip to content

Commit

Permalink
feat: add new pair coin entity
Browse files Browse the repository at this point in the history
  • Loading branch information
cdotta committed Oct 9, 2024
1 parent db2235a commit f939d47
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/config/src/arbitrum-sepolia.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
"transmolgrifier_address": "0x4489eee4b7218a74d516396c2f3ee6eba54f0773",
"transmolgrifier_start_block": 6249003,
"smol_renderer_address": "0x79973af48c424de5f199a7c0369c5e9cdeb493fc",
"meme_presale_address": "0x324d1670765cb8799ecd5271a8d595a64ed92fbf",
"meme_presale_start_block": 86641150,
"meme_presale_address": "0xC5589d3978225235e46a79Fc51E1563FBFa84062",
"meme_presale_start_block": 86999225,

"magicswapv1_start_block": 654981,
"magicswapv1_uniswapv2_factory_address": "0x9b58fc8c7B224Ae8479DA7E6eD37CA4Ac58099a9",
Expand Down
55 changes: 53 additions & 2 deletions subgraphs/memecoins/abis/MemePresale.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"inputs": [
{
"internalType": "contract IERC20",
"name": "_fakemagic",
"name": "_magic",
"type": "address"
},
{
Expand Down Expand Up @@ -255,6 +255,47 @@
"name": "MemeMade",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "_collectionAddress",
"type": "address"
},
{
"components": [
{
"internalType": "address",
"name": "lpaddress",
"type": "address"
},
{
"internalType": "address",
"name": "vaultaddress",
"type": "address"
},
{
"internalType": "bool",
"name": "approved",
"type": "bool"
},
{
"internalType": "string",
"name": "symbol",
"type": "string"
}
],
"indexed": false,
"internalType": "struct PRESALE.AltPairInfo",
"name": "alt",
"type": "tuple"
}
],
"name": "PairCoinApproved",
"type": "event"
},
{
"inputs": [],
"name": "TARGETMCAP",
Expand Down Expand Up @@ -291,6 +332,11 @@
"internalType": "bool",
"name": "approved",
"type": "bool"
},
{
"internalType": "string",
"name": "symbol",
"type": "string"
}
],
"internalType": "struct PRESALE.AltPairInfo",
Expand Down Expand Up @@ -327,6 +373,11 @@
"internalType": "bool",
"name": "approved",
"type": "bool"
},
{
"internalType": "string",
"name": "symbol",
"type": "string"
}
],
"stateMutability": "view",
Expand Down Expand Up @@ -684,4 +735,4 @@
"stateMutability": "view",
"type": "function"
}
]
]
9 changes: 9 additions & 0 deletions subgraphs/memecoins/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,12 @@ type MemePresale @entity {
pairCoin: Bytes
lpAddress: Bytes
}

type PairCoin @entity {
id: Bytes!

lpAddress: Bytes
symbol: String
vaultAddress: Bytes
approved: Boolean
}
23 changes: 22 additions & 1 deletion subgraphs/memecoins/src/mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import {
BuySell,
Graduation,
MemeMade,
PairCoinApproved,
} from "../generated/Meme Presale/MemePresale";
import { MemePresale } from "../generated/schema";
import { MemePresale, PairCoin } from "../generated/schema";

const getOrCreateMemePresale = (memecoin: Address): MemePresale => {
let memePresale = MemePresale.load(memecoin);
Expand All @@ -16,6 +17,15 @@ const getOrCreateMemePresale = (memecoin: Address): MemePresale => {
return memePresale;
};

const getOrCreatePairCoin = (pairCoinAddress: Address): PairCoin => {
let pairCoin = PairCoin.load(pairCoinAddress);
if (!pairCoin) {
pairCoin = new PairCoin(pairCoinAddress);
}

return pairCoin;
};

export function handleMemeMade(event: MemeMade): void {
const params = event.params;
const memePresale = getOrCreateMemePresale(params.presaleinfo.memecoin);
Expand Down Expand Up @@ -69,3 +79,14 @@ export function handleGraduation(event: Graduation): void {

memePresale.save();
}

export function handlePairCoinApproved(event: PairCoinApproved): void {
const params = event.params;
const pairCoin = getOrCreatePairCoin(params._collectionAddress);
pairCoin.lpAddress = params.alt.lpaddress;
pairCoin.vaultAddress = params.alt.vaultaddress;
pairCoin.approved = params.alt.approved;
pairCoin.symbol = params.alt.symbol;

pairCoin.save();
}
2 changes: 2 additions & 0 deletions subgraphs/memecoins/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ dataSources:
handler: handleBuySell
- event: Graduation(indexed address,(uint256,uint256,uint256,uint256,uint256,bool,address,address,address,bool))
handler: handleGraduation
- event: PairCoinApproved(indexed address,(address,address,bool,string))
handler: handlePairCoinApproved
file: ./src/mapping.ts

0 comments on commit f939d47

Please sign in to comment.