Skip to content

Commit

Permalink
feat: support gravity
Browse files Browse the repository at this point in the history
  • Loading branch information
hanguyenk committed Dec 29, 2023
1 parent 7efa527 commit b0b3e89
Show file tree
Hide file tree
Showing 17 changed files with 3,698 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package shared

import (
"context"
"encoding/json"
"math/big"
"time"

graphqlpkg "github.com/KyberNetwork/kyberswap-dex-lib/pkg/util/graphql"
"github.com/goccy/go-json"
"github.com/machinebox/graphql"
)

Expand Down
34 changes: 34 additions & 0 deletions pkg/liquidity-source/gravity/abis.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package gravity

Check failure on line 1 in pkg/liquidity-source/gravity/abis.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

: # github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/gravity [github.com/KyberNetwork/kyberswap-dex-lib/pkg/liquidity-source/gravity.test]

import (
"bytes"

"github.com/ethereum/go-ethereum/accounts/abi"
)

var (
uniswapV2PairABI abi.ABI
uniswapV2FactoryABI abi.ABI
)

func init() {
builder := []struct {
ABI *abi.ABI
data []byte
}{
{
&uniswapV2PairABI, pairABIJson,
},
{
&uniswapV2FactoryABI, factoryABIJson,
},
}

for _, b := range builder {
var err error
*b.ABI, err = abi.JSON(bytes.NewReader(b.data))
if err != nil {
panic(err)
}
}
}
193 changes: 193 additions & 0 deletions pkg/liquidity-source/gravity/abis/UniswapV2Factory.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
[
{
"inputs": [
{
"internalType": "address",
"name": "_feeToSetter",
"type": "address"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "token0",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "token1",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "pair",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "PairCreated",
"type": "event"
},
{
"constant": true,
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "allPairs",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "allPairsLength",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "address",
"name": "tokenA",
"type": "address"
},
{
"internalType": "address",
"name": "tokenB",
"type": "address"
}
],
"name": "createPair",
"outputs": [
{
"internalType": "address",
"name": "pair",
"type": "address"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "feeTo",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "feeToSetter",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
},
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "getPair",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "address",
"name": "_feeTo",
"type": "address"
}
],
"name": "setFeeTo",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "address",
"name": "_feeToSetter",
"type": "address"
}
],
"name": "setFeeToSetter",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
}
]
Loading

0 comments on commit b0b3e89

Please sign in to comment.