Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate four-meme #732

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
188 changes: 188 additions & 0 deletions pkg/liquidity-source/four-meme/abis.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
package fourmeme

import (
"bytes"

"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
"github.com/samber/lo"
)

var (
erc20ABI abi.ABI
tokenManagerABI abi.ABI
tokenManager2ABI abi.ABI
tokenManagerHelperABI abi.ABI
)

func init() {
builder := []struct {
ABI *abi.ABI
data []byte
}{
{
&tokenManagerABI, tokenManagerABIJson,
},
{
&tokenManager2ABI, tokenManager2ABIJson,
},
{
&tokenManagerHelperABI, tokenManagerHelperABIJson,
},
}

for _, b := range builder {
var err error
*b.ABI, err = abi.JSON(bytes.NewReader(b.data))
if err != nil {
panic(err)
}
}

// https://www.notion.so/kybernetwork/four-meme-reverse-engineer-19d26751887e80119fc9d113074b2365?pvs=4#19d26751887e80488cf8e96d0d41794c

// method for query templates
tokenManager2ABI.Methods["_templates"] = abi.Method{
Inputs: abi.Arguments{
{
Name: "",
Type: lo.Must(abi.NewType("uint256", "", nil)),
},
},
Outputs: abi.Arguments{
{
Name: "",
Type: lo.Must(abi.NewType("address", "", nil)),
},
{
Name: "",
Type: lo.Must(abi.NewType("uint256", "", nil)),
},
{
Name: "",
Type: lo.Must(abi.NewType("uint256", "", nil)),
},
{
Name: "",
Type: lo.Must(abi.NewType("uint256", "", nil)),
},
{
Name: "",
Type: lo.Must(abi.NewType("uint256", "", nil)),
},
{
Name: "minTradeFee",
Type: lo.Must(abi.NewType("uint256", "", nil)),
},
},
}

// method for query tradingHalted
tokenManager2ABI.Methods["tradingHalted"] = abi.Method{
ID: common.Hex2Bytes("088c5d0b"),
Inputs: abi.Arguments{},
Outputs: abi.Arguments{
{
Name: "",
Type: lo.Must(abi.NewType("bool", "", nil)),
},
},
}

// method for query tokenTxFee
tokenManager2ABI.Methods["tokenTxFee"] = abi.Method{
ID: common.Hex2Bytes("9f266331"),
Inputs: abi.Arguments{
{
Name: "",
Type: lo.Must(abi.NewType("address", "", nil)),
},
},
Outputs: abi.Arguments{
{
Name: "tokenTxFee",
Type: lo.Must(abi.NewType("uint256", "", nil)),
},
{
Name: "",
Type: lo.Must(abi.NewType("uint256", "", nil)),
},
{
Name: "",
Type: lo.Must(abi.NewType("uint256", "", nil)),
},
{
Name: "",
Type: lo.Must(abi.NewType("uint256", "", nil)),
},
{
Name: "",
Type: lo.Must(abi.NewType("uint256", "", nil)),
},
},
}

tokenManager2ABI.Methods["tokenData"] = abi.Method{
ID: common.Hex2Bytes("e684626b"),
Inputs: abi.Arguments{
{
Name: "",
Type: lo.Must(abi.NewType("address", "", nil)),
},
},
Outputs: abi.Arguments{
{
Name: "token",
Type: lo.Must(abi.NewType("address", "", nil)),
},
{
Name: "raisedToken",
Type: lo.Must(abi.NewType("address", "", nil)),
},
{
Name: "templateId",
Type: lo.Must(abi.NewType("uint256", "", nil)),
},
{
Name: "field3",
Type: lo.Must(abi.NewType("uint256", "", nil)),
},
{
Name: "maxOffers",
Type: lo.Must(abi.NewType("uint256", "", nil)),
},
{
Name: "maxFunds",
Type: lo.Must(abi.NewType("uint256", "", nil)),
},
{
Name: "LaunchTime",
Type: lo.Must(abi.NewType("uint256", "", nil)),
},
{
Name: "Offers",
Type: lo.Must(abi.NewType("uint256", "", nil)),
},
{
Name: "Funds",
Type: lo.Must(abi.NewType("uint256", "", nil)),
},
{
Name: "Price",
Type: lo.Must(abi.NewType("uint256", "", nil)),
},
{
Name: "field10",
Type: lo.Must(abi.NewType("uint256", "", nil)),
},
{
Name: "field11",
Type: lo.Must(abi.NewType("uint256", "", nil)),
},
{
Name: "TradingDisabled",
Type: lo.Must(abi.NewType("uint256", "", nil)),
},
},
}
}
208 changes: 208 additions & 0 deletions pkg/liquidity-source/four-meme/abis/TokenManager.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
[
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "creator",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "token",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "requestId",
"type": "uint256"
},
{
"indexed": false,
"internalType": "string",
"name": "name",
"type": "string"
},
{
"indexed": false,
"internalType": "string",
"name": "symbol",
"type": "string"
},
{
"indexed": false,
"internalType": "uint256",
"name": "totalSupply",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "launchTime",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "launchFee",
"type": "uint256"
}
],
"name": "TokenCreate",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "token",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "account",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "tokenAmount",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "etherAmount",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "fee",
"type": "uint256"
}
],
"name": "TokenPurchase",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "token",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "account",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "tokenAmount",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "etherAmount",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "fee",
"type": "uint256"
}
],
"name": "TokenSale",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "token",
"type": "address"
}
],
"name": "TradeStop",
"type": "event"
},
{
"inputs": [
{
"internalType": "address",
"name": "tokenAddress",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "maxFunds",
"type": "uint256"
}
],
"name": "purchaseToken",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "tokenAddress",
"type": "address"
},
{
"internalType": "uint256",
"name": "funds",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "minAmount",
"type": "uint256"
}
],
"name": "purchaseTokenAMAP",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "tokenAddress",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "saleToken",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
Loading
Loading