Skip to content

Commit

Permalink
Burn Wrapper (#50)
Browse files Browse the repository at this point in the history
* update for rc7 testnet

* burnwrapper

* manually adjusted ABI to correct event names

* only handle mints
  • Loading branch information
EdNoepel authored Aug 15, 2023
1 parent 78659e2 commit 27e4f09
Show file tree
Hide file tree
Showing 7 changed files with 350 additions and 26 deletions.
246 changes: 246 additions & 0 deletions abis/BurnWrappedAjna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
[
{
"inputs": [
{
"internalType": "contract IERC20",
"name": "wrappedToken",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{ "inputs": [], "name": "InvalidWrappedToken", "type": "error" },
{ "inputs": [], "name": "UnwrapNotAllowed", "type": "error" },
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "Approval",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "from",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "to",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "Transfer",
"type": "event"
},
{
"inputs": [],
"name": "DOMAIN_SEPARATOR",
"outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "owner", "type": "address" },
{ "internalType": "address", "name": "spender", "type": "address" }
],
"name": "allowance",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "spender", "type": "address" },
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
],
"name": "approve",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "account", "type": "address" }
],
"name": "balanceOf",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
],
"name": "burn",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "account", "type": "address" },
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
],
"name": "burnFrom",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "decimals",
"outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "spender", "type": "address" },
{
"internalType": "uint256",
"name": "subtractedValue",
"type": "uint256"
}
],
"name": "decreaseAllowance",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "account", "type": "address" },
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
],
"name": "depositFor",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "spender", "type": "address" },
{ "internalType": "uint256", "name": "addedValue", "type": "uint256" }
],
"name": "increaseAllowance",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "name",
"outputs": [{ "internalType": "string", "name": "", "type": "string" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "owner", "type": "address" }
],
"name": "nonces",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "owner", "type": "address" },
{ "internalType": "address", "name": "spender", "type": "address" },
{ "internalType": "uint256", "name": "value", "type": "uint256" },
{ "internalType": "uint256", "name": "deadline", "type": "uint256" },
{ "internalType": "uint8", "name": "v", "type": "uint8" },
{ "internalType": "bytes32", "name": "r", "type": "bytes32" },
{ "internalType": "bytes32", "name": "s", "type": "bytes32" }
],
"name": "permit",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "symbol",
"outputs": [{ "internalType": "string", "name": "", "type": "string" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "totalSupply",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "to", "type": "address" },
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
],
"name": "transfer",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "from", "type": "address" },
{ "internalType": "address", "name": "to", "type": "address" },
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
],
"name": "transferFrom",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "underlying",
"outputs": [
{ "internalType": "contract IERC20", "name": "", "type": "address" }
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "", "type": "address" },
{ "internalType": "uint256", "name": "", "type": "uint256" }
],
"name": "withdrawTo",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "pure",
"type": "function"
}
]
5 changes: 4 additions & 1 deletion add-commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ graph add 0xEd6890d748e62ddbb3f80e7256Deeb2fBb853476 --abi ../contracts/forge_ou
graph add 0xaeB91e664A49829FaBf06BE35d4447938d83A271 --abi ../ecosystem-coordination/out/GrantFund.sol/GrantFund.json --contract-name GrantFund

# Goerli AjnaToken
graph add 0xaadebCF61AA7Da0573b524DE57c67aDa797D46c5 --abi ../ecosystem-coordination/out/AjnaToken.sol/AjnaToken.json --contract-name AjnaToken
graph add 0xaadebCF61AA7Da0573b524DE57c67aDa797D46c5 --abi ../ecosystem-coordination/out/AjnaToken.sol/AjnaToken.json --contract-name AjnaToken

# Goerli BurnWrapper
graph add 0xE38DFd7aB36806B882bD7332a8aE454f2273D015 --abi ../ecosystem-coordination/out/BurnWrapper.sol/BurnWrappedAjna.json --contract-name BurnWrappedAjna
2 changes: 1 addition & 1 deletion local/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.7'

services:
ajna-testnet:
image: ghcr.io/ajna-finance/ajna-testnet:rc6
image: ghcr.io/ajna-finance/ajna-testnet:rc7
ports:
- 8555:8555
container_name: ajna-testnet-devenv
Expand Down
25 changes: 20 additions & 5 deletions networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
"AjnaToken": {
"address": "0x9a96ec9B57Fb64FbC60B423d1f4da7691Bd35079",
"startBlock": 17622995
},
"BurnWrappedAjna": {
"address": "0x936Ab482d6bd111910a42849D3A51Ff80BB0A711",
"startBlock": 17913208
}
},
"goerli": {
Expand All @@ -49,6 +53,10 @@
"AjnaToken": {
"address": "0xaadebCF61AA7Da0573b524DE57c67aDa797D46c5",
"startBlock": 9297080
},
"BurnWrappedAjna": {
"address": "0xE38DFd7aB36806B882bD7332a8aE454f2273D015",
"startBlock": 9445944
}
},
"mumbai": {
Expand All @@ -75,31 +83,38 @@
"AjnaToken": {
"address": "0x5BC519744f3f0b324E3D5c031e6D18326FD0e8ce",
"startBlock": 38580888
},
"BurnWrappedAjna": {
"address": "0x0000000000000000000000000000000000000000",
"startBlock": 38580888
}
},
"ganache": {
"ERC20PoolFactory": {
"address": "0xD86c4A8b172170Da0d5C0C1F12455bA80Eaa42AD",
"address": "0x9617ABE221F9A9c492D5348be56aef4Db75A692d",
"startBlock": 0
},
"ERC721PoolFactory": {
"address": "0x9617ABE221F9A9c492D5348be56aef4Db75A692d",
"address": "0x4f05DA51eAAB00e5812c54e370fB95D4C9c51F21",
"startBlock": 0
},
"PositionManager": {
"address": "0x6c5c7fD98415168ada1930d44447790959097482",
"address": "0x6548dF23A854f72335902e58a1e59B50bb3f11F1",
"startBlock": 0
},
"RewardsManager": {
"address": "0x6548dF23A854f72335902e58a1e59B50bb3f11F1",
"address": "0xdF7403003a16c49ebA5883bB5890d474794cea5a",
"startBlock": 0
},
"GrantFund": {
"address": "0xE340B87CEd1af1AbE1CE8D617c84B7f168e3b18b",
"address": "0x0b3A0ea1Fc7207d3e3ed9973025dA9d0e8fb0F3f",
"startBlock": 0
},
"AjnaToken": {
"address": "0x25Af17eF4E2E6A4A2CE586C9D25dF87FD84D4a7d"
},
"BurnWrappedAjna": {
"address": "0xE340B87CEd1af1AbE1CE8D617c84B7f168e3b18b"
}
}
}
14 changes: 14 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,20 @@ type RedeemPosition @entity(immutable: true) {
transactionHash: Bytes!
}

# # # # # # # # # # # #
# BURN WRAPPER EVENTS #
# # # # # # # # # # # #

type BurnWrap @entity(immutable: true) {
id: Bytes!
wrapper: Bytes! # address
account: Account # null if does not already exist
amount: BigDecimal! # uint256
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}

# # # # # # # # # # # # # # #
# REWARDS MANAGER ENTITIES #
# # # # # # # # # # # # # # #
Expand Down
25 changes: 25 additions & 0 deletions src/burn-wrapped-ajna.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {
Transfer as TransferEvent
} from "../generated/BurnWrappedAjna/BurnWrappedAjna"
import { BurnWrap } from "../generated/schema"
import { ZERO_ADDRESS } from "./utils/constants"
import { addressToBytes, wadToDecimal } from "./utils/convert"

export function handleTransfer(
event: TransferEvent
): void {
if (event.params.from == ZERO_ADDRESS) {
let entity = new BurnWrap(
event.transaction.hash.concatI32(event.logIndex.toI32())
)
entity.wrapper = event.params.to
entity.account = addressToBytes(event.params.from)
entity.amount = wadToDecimal(event.params.value)

entity.blockNumber = event.block.number
entity.blockTimestamp = event.block.timestamp
entity.transactionHash = event.transaction.hash

entity.save()
}
}
Loading

0 comments on commit 27e4f09

Please sign in to comment.