Aavegotchi baazaar

From modbender/skill-library-mcp · View interactive version

Aavegotchi baazaar is an AI agent skill from the GitHub repository modbender/skill-library-mcp. > View, add, and execute Aavegotchi Baazaar listings on Base mainnet (8453). Buy with GHST directly or buy with USDC using swapAndBuy*. Safety-first: dryRun defaults true (simulate with cast call; only broadcast with cast send when dryRun=false / DRY_RUN=0).

How to use this skill

Skill file

Safety Rules

Shell Input Safety (Avoid RCE)

This skill includes shell commands. Treat any value you copy from a user or an external source (subgraph responses, chat messages, etc.) as untrusted.

Rules:

Allowlisted command templates:

Quick validators (replace the placeholder values):

python3 - <<'PY'
import re

listing_id = "<LISTING_ID>"  # digits only
token_contract = "<TOKEN_CONTRACT_ADDRESS>"  # 0x + 40 hex chars
price_in_wei = "<PRICE_IN_WEI>"  # digits only

if not re.fullmatch(r"[0-9]+", listing_id):
    raise SystemExit("LISTING_ID must be base-10 digits only")
if not re.fullmatch(r"0x[a-fA-F0-9]{40}", token_contract):
    raise SystemExit("TOKEN_CONTRACT_ADDRESS must be a 0x + 40-hex address")
if not re.fullmatch(r"[0-9]+", price_in_wei):
    raise SystemExit("PRICE_IN_WEI must be base-10 digits only")

print("ok")
PY

Required Setup

Required env vars:

Hardcoded Base mainnet constants (override via env if needed):

export BASE_MAINNET_RPC="${BASE_MAINNET_RPC:-https://mainnet.base.org}"
export DIAMOND="${DIAMOND:-0xA99c4B08201F2913Db8D28e71d020c4298F29dBF}"
export GHST="${GHST:-0xcD2F22236DD9Dfe2356D7C543161D4d260FD9BcB}"
export USDC="${USDC:-0x833589fCD6eDb6E08f4c7C32D4f71b54BDA02913}"
export SUBGRAPH_URL_CANONICAL="https://api.goldsky.com/api/public/project_cmh3flagm0001r4p25foufjtt/subgraphs/aavegotchi-core-base/prod/gn"
export SUBGRAPH_URL="${SUBGRAPH_URL:-$SUBGRAPH_URL_CANONICAL}"
export COINGECKO_SIMPLE_PRICE_URL="${COINGECKO_SIMPLE_PRICE_URL:-https://api.coingecko.com/api/v3/simple/price?ids=aavegotchi&vs_currencies=usd}"

Optional env vars:

Notes:

Network Endpoint Allowlist

Only call these HTTPS endpoints:

Refuse non-allowlisted endpoints:

test "$SUBGRAPH_URL" = "$SUBGRAPH_URL_CANONICAL" || { echo "Refusing non-allowlisted SUBGRAPH_URL"; exit 1; }
test "$COINGECKO_SIMPLE_PRICE_URL" = "https://api.coingecko.com/api/v3/simple/price?ids=aavegotchi&vs_currencies=usd" || { echo "Refusing non-allowlisted CoinGecko URL"; exit 1; }

View Listings (Subgraph)

Subgraph endpoint (Goldsky):

Get ERC721 listing by id:

curl -s "$SUBGRAPH_URL" -H 'content-type: application/json' --data '{
  "query":"query($id: ID!){ erc721Listing(id:$id){ id category erc721TokenAddress tokenId seller priceInWei cancelled timeCreated timePurchased } }",
  "variables":{"id":"1"}
}'

Get ERC1155 listing by id:

curl -s "$SUBGRAPH_URL" -H 'content-type: application/json' --data '{
  "query":"query($id: ID!){ erc1155Listing(id:$id){ id category erc1155TokenAddress erc1155TypeId quantity seller priceInWei cancelled sold timeCreated } }",
  "variables":{"id":"1"}
}'

Find active listings:

Example (active ERC721, newest first):

curl -s "$SUBGRAPH_URL" -H 'content-type: application/json' --data '{
  "query":"query{ erc721Listings(first:20, orderBy:timeCreated, orderDirection:desc, where:{cancelled:false, timePurchased:\"0\"}){ id erc721TokenAddress tokenId priceInWei seller timeCreated } }"
}'

Example (active ERC1155, newest first):

curl -s "$SUBGRAPH_URL" -H 'content-type: application/json' --data '{
  "query":"query{ erc1155Listings(first:20, orderBy:timeCreated, orderDirection:desc, where:{cancelled:false, sold:false}){ id erc1155TokenAddress erc1155TypeId quantity priceInWei seller timeCreated } }"
}'

Execute Listing (Buy With GHST)

Onchain methods (Diamond):

Total cost:

Before buying:

  1. Fetch listing details from the subgraph (id, token contract address, tokenId/typeId, quantity, priceInWei).
  2. Check GHST balance/allowance and prepare approvals if needed (see references/recipes.md).

Dry-run (simulate) ERC721 buy:

~/.foundry/bin/cast call "$DIAMOND" \
  'executeERC721ListingToRecipient(uint256,address,uint256,uint256,address)' \
  "<LISTING_ID>" "<ERC721_TOKEN_ADDRESS>" "<PRICE_IN_WEI>" "<TOKEN_ID>" "${RECIPIENT_ADDRESS:-$FROM_ADDRESS}" \
  --from "$FROM_ADDRESS" \
  --rpc-url "${BASE_MAINNET_RPC:-https://mainnet.base.org}"

Broadcast (real) ERC721 buy (only when explicitly instructed):

test "${DRY_RUN:-1}" = "0" || { echo "Refusing broadcast: DRY_RUN must be 0"; exit 1; }
test "${BROADCAST_CONFIRM:-}" = "CONFIRM_SEND" || { echo "Refusing broadcast: set BROADCAST_CONFIRM=CONFIRM_SEND after explicit user confirmation"; exit 1; }
~/.foundry/bin/cast send "$DIAMOND" \
  'executeERC721ListingToRecipient(uint256,address,uint256,uint256,address)' \
  "<LISTING_ID>" "<ERC721_TOKEN_ADDRESS>" "<PRICE_IN_WEI>" "<TOKEN_ID>" "${RECIPIENT_ADDRESS:-$FROM_ADDRESS}" \
  --private-key "$PRIVATE_KEY" \
  --rpc-url "${BASE_MAINNET_RPC:-https://mainnet.base.org}"
unset BROADCAST_CONFIRM

Dry-run (simulate) ERC1155 buy:

~/.foundry/bin/cast call "$DIAMOND" \
  'executeERC1155ListingToRecipient(uint256,address,uint256,uint256,uint256,address)' \
  "<LISTING_ID>" "<ERC1155_TOKEN_ADDRESS>" "<TYPE_ID>" "<QUANTITY>" "<PRICE_IN_WEI>" "${RECIPIENT_ADDRESS:-$FROM_ADDRESS}" \
  --from "$FROM_ADDRESS" \
  --rpc-url "${BASE_MAINNET_RPC:-https://mainnet.base.org}"

Broadcast (real) ERC1155 buy (only when explicitly instructed):

test "${DRY_RUN:-1}" = "0" || { echo "Refusing broadcast: DRY_RUN must be 0"; exit 1; }
test "${BROADCAST_CONFIRM:-}" = "CONFIRM_SEND" || { echo "Refusing broadcast: set BROADCAST_CONFIRM=CONFIRM_SEND after explicit user confirmation"; exit 1; }
~/.foundry/bin/cast send "$DIAMOND" \
  'executeERC1155ListingToRecipient(uint256,address,uint256,uint256,uint256,address)' \
  "<LISTING_ID>" "<ERC1155_TOKEN_ADDRESS>" "<TYPE_ID>" "<QUANTITY>" "<PRICE_IN_WEI>" "${RECIPIENT_ADDRESS:-$FROM_ADDRESS}" \
  --private-key "$PRIVATE_KEY" \
  --rpc-url "${BASE_MAINNET_RPC:-https://mainnet.base.org}"
unset BROADCAST_CONFIRM

Execute Listing (Buy With USDC swapAndBuy*)

Onchain methods (Diamond):

Required computed args:

Before buying:

  1. Fetch listing details from the subgraph (and compute totalCostGhstWei).
  2. Compute swapAmount in USDC base units (integer, rounded up).
  3. Ensure USDC allowance to the Diamond is at least swapAmount (see references/recipes.md).

Dry-run (simulate) ERC721 USDC swap+buy:

~/.foundry/bin/cast call "$DIAMOND" \
  'swapAndBuyERC721(address,uint256,uint256,uint256,uint256,address,uint256,uint256,address)' \
  "$USDC" "<SWAP_AMOUNT_USDC_6DP>" "<MIN_GHST_OUT_GHST_WEI>" "<SWAP_DEADLINE_UNIX>" "<LISTING_ID>" "<ERC721_TOKEN_ADDRESS>" "<PRICE_IN_WEI>" "<TOKEN_ID>" "${RECIPIENT_ADDRESS:-$FROM_ADDRESS}" \
  --from "$FROM_ADDRESS" \
  --rpc-url "${BASE_MAINNET_RPC:-https://mainnet.base.org}"

Dry-run (simulate) ERC1155 USDC swap+buy:

~/.foundry/bin/cast call "$DIAMOND" \
  'swapAndBuyERC1155(address,uint256,uint256,uint256,uint256,address,uint256,uint256,uint256,address)' \
  "$USDC" "<SWAP_AMOUNT_USDC_6DP>" "<MIN_GHST_OUT_GHST_WEI>" "<SWAP_DEADLINE_UNIX>" "<LISTING_ID>" "<ERC1155_TOKEN_ADDRESS>" "<TYPE_ID>" "<QUANTITY>" "<PRICE_IN_WEI>" "${RECIPIENT_ADDRESS:-$FROM_ADDRESS}" \
  --from "$FROM_ADDRESS" \
  --rpc-url "${BASE_MAINNET_RPC:-https://mainnet.base.org}"

Broadcast (real) ERC721 swap+buy (only when explicitly instructed):

test "${DRY_RUN:-1}" = "0" || { echo "Refusing broadcast: DRY_RUN must be 0"; exit 1; }
test "${BROADCAST_CONFIRM:-}" = "CONFIRM_SEND" || { echo "Refusing broadcast: set BROADCAST_CONFIRM=CONFIRM_SEND after explicit user confirmation"; exit 1; }
~/.foundry/bin/cast send "$DIAMOND" \
  'swapAndBuyERC721(address,uint256,uint256,uint256,uint256,address,uint256,uint256,address)' \
  "$USDC" "<SWAP_AMOUNT_USDC_6DP>" "<MIN_GHST_OUT_GHST_WEI>" "<SWAP_DEADLINE_UNIX>" "<LISTING_ID>" "<ERC721_TOKEN_ADDRESS>" "<PRICE_IN_WEI>" "<TOKEN_ID>" "${RECIPIENT_ADDRESS:-$FROM_ADDRESS}" \
  --private-key "$PRIVATE_KEY" \
  --rpc-url "${BASE_MAINNET_RPC:-https://mainnet.base.org}"
unset BROADCAST_CONFIRM

Broadcast (real) ERC1155 swap+buy (only when explicitly instructed):

test "${DRY_RUN:-1}" = "0" || { echo "Refusing broadcast: DRY_RUN must be 0"; exit 1; }
test "${BROADCAST_CONFIRM:-}" = "CONFIRM_SEND" || { echo "Refusing broadcast: set BROADCAST_CONFIRM=CONFIRM_SEND after explicit user confirmation"; exit 1; }
~/.foundry/bin/cast send "$DIAMOND" \
  'swapAndBuyERC1155(address,uint256,uint256,uint256,uint256,address,uint256,uint256,uint256,address)' \
  "$USDC" "<SWAP_AMOUNT_USDC_6DP>" "<MIN_GHST_OUT_GHST_WEI>" "<SWAP_DEADLINE_UNIX>" "<LISTING_ID>" "<ERC1155_TOKEN_ADDRESS>" "<TYPE_ID>" "<QUANTITY>" "<PRICE_IN_WEI>" "${RECIPIENT_ADDRESS:-$FROM_ADDRESS}" \
  --private-key "$PRIVATE_KEY" \
  --rpc-url "${BASE_MAINNET_RPC:-https://mainnet.base.org}"
unset BROADCAST_CONFIRM

Add Listing

Onchain methods (Diamond):

Steps:

  1. Check listing fee:
  1. Ensure the NFT contract has setApprovalForAll($DIAMOND,true) (ERC721/1155) before listing.
  2. Submit the listing tx (simulate with cast call when dryRun=true, broadcast with cast send only when explicitly instructed).
  3. After listing, find the newest listingId via the subgraph for seller=$FROM_ADDRESS ordered by timeCreated desc and confirm it matches token/typeId.

ERC721 list (simulate):

~/.foundry/bin/cast call "$DIAMOND" \
  'addERC721Listing(address,uint256,uint256,uint256)' \
  "<ERC721_TOKEN_ADDRESS>" "<TOKEN_ID>" "<CATEGORY>" "<PRICE_IN_WEI>" \
  --from "$FROM_ADDRESS" \
  --rpc-url "${BASE_MAINNET_RPC:-https://mainnet.base.org}"

ERC1155 list (simulate):

~/.foundry/bin/cast call "$DIAMOND" \
  'setERC1155Listing(address,uint256,uint256,uint256,uint256)' \
  "<ERC1155_TOKEN_ADDRESS>" "<TYPE_ID>" "<QUANTITY>" "<CATEGORY>" "<PRICE_IN_WEI>" \
  --from "$FROM_ADDRESS" \
  --rpc-url "${BASE_MAINNET_RPC:-https://mainnet.base.org}"

Common Failure Modes

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.