polygon

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2024 License: BlueOak-1.0.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	MainnetChainID = 137
	TestnetChainID = 80001 // Mumbai
	SimnetChainID  = 90001
)

These are the chain IDs of the various polygon network.

View Source
const (
	PolygonBipID = 966
)

Variables

View Source
var (
	// ChainIDs is a map of the network name to it's chain ID.
	ChainIDs = map[dex.Network]int64{
		dex.Mainnet: MainnetChainID,
		dex.Testnet: TestnetChainID,
		dex.Simnet:  SimnetChainID,
	}

	// Called BorTestChainConfig in maticnetwork/bor/params/config.go
	AmoyChainConfig = &params.ChainConfig{
		ChainID:             big.NewInt(80002),
		HomesteadBlock:      big.NewInt(0),
		DAOForkBlock:        nil,
		DAOForkSupport:      true,
		EIP150Block:         big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(0),
		MuirGlacierBlock:    big.NewInt(0),
		BerlinBlock:         big.NewInt(0),
		LondonBlock:         big.NewInt(73100),
	}

	// BorMainnetChainConfig is the genesis block of the Bor Mainnet network.
	// This is a copy of the genesis block from
	// https://github.com/maticnetwork/bor/blob/891ec7fef619cac0a796e3e29d5b2d4c095bdd9b/params/config.go#L395.
	BorMainnetChainConfig = &params.ChainConfig{
		ChainID:             big.NewInt(137),
		HomesteadBlock:      big.NewInt(0),
		DAOForkBlock:        nil,
		DAOForkSupport:      true,
		EIP150Block:         big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(3395000),
		MuirGlacierBlock:    big.NewInt(3395000),
		BerlinBlock:         big.NewInt(14750000),
		LondonBlock:         big.NewInt(23850000),
	}
)
View Source
var (
	UnitInfo = dex.UnitInfo{
		AtomicUnit: "gwei",
		Conventional: dex.Denomination{
			Unit:             "POL",
			ConversionFactor: 1e9,
		},
		Alternatives: []dex.Denomination{
			{
				Unit:             "Szabos",
				ConversionFactor: 1e6,
			},
			{
				Unit:             "Finneys",
				ConversionFactor: 1e3,
			},
		},
		FeeRateDenom: "gas",
	}

	VersionedGases = map[uint32]*dexeth.Gases{
		0: v0Gases,
	}

	ContractAddresses = map[uint32]map[dex.Network]common.Address{
		0: {
			dex.Mainnet: common.HexToAddress("0xd45e648D97Beb2ee0045E5e91d1C2C751Cd0Bc00"),
			dex.Testnet: common.HexToAddress("0x73bc803A2604b2c58B8680c3CE1b14489842EF16"),
			dex.Simnet:  common.HexToAddress(""),
		},
	}

	MultiBalanceAddresses = map[dex.Network]common.Address{
		dex.Mainnet: common.HexToAddress("0x23d8203d8E3c839F359bcC85BFB71cf0d707EDF0"),
		dex.Testnet: common.HexToAddress("0xa958d5B8a3a29E3f5f41742Fbb939A0dd93EB418"),
	}

	Tokens = map[uint32]*dexeth.Token{
			// contains filtered or unexported fields
	}

	TokenUSDC = &dexeth.Token{
		EVMFactor: new(int64),
		Token: &dex.Token{
			ParentID: PolygonBipID,
			Name:     "USDC",
			UnitInfo: dex.UnitInfo{
				AtomicUnit: "µUSD",
				Conventional: dex.Denomination{
					Unit:             "USDC",
					ConversionFactor: 1e6,
				},
				Alternatives: []dex.Denomination{
					{
						Unit:             "cents",
						ConversionFactor: 1e2,
					},
				},
				FeeRateDenom: "gas",
			},
		},
		NetTokens: map[dex.Network]*dexeth.NetToken{
			dex.Mainnet: {
				Address: common.HexToAddress("0x3c499c542cef5e3811e1192ce70d8cc03d5c3359"),
				SwapContracts: map[uint32]*dexeth.SwapContract{
					0: {

						Address: common.HexToAddress("0x1C152f7f91E03BcA4B0000Be9f694A62A9548e7B"),
						Gas: dexeth.Gases{

							Swap:    244_212,
							SwapAdd: 146_368,

							Redeem:    102_731,
							RedeemAdd: 41_109,

							Refund: 83_587,

							Approve: 78_215,

							Transfer: 85_150,
						},
					},
				},
			},
			dex.Testnet: {
				Address: common.HexToAddress("0x41E94Eb019C0762f9Bfcf9Fb1E58725BfB0e7582"),
				SwapContracts: map[uint32]*dexeth.SwapContract{
					0: {

						Address: common.HexToAddress("0xca70D818ffff2Cd235Ab90b4fec3e6394014D294"),
						Gas: dexeth.Gases{

							Swap:    244_376,
							SwapAdd: 146_368,

							Redeem:    100_397,
							RedeemAdd: 41_117,

							Refund: 90_558,

							Approve: 76_224,

							Transfer: 82_816,
						},
					},
				},
			},
			dex.Simnet: {
				Address: common.Address{},
				SwapContracts: map[uint32]*dexeth.SwapContract{
					0: {
						Address: common.Address{},
						Gas: dexeth.Gases{
							Swap:      223_163,
							SwapAdd:   146_399,
							Redeem:    82_121,
							RedeemAdd: 41_113,
							Refund:    62_527,
							Approve:   58_180,
							Transfer:  64_539,
						},
					},
				},
			},
		},
	}

	TokenUSDT = &dexeth.Token{
		EVMFactor: new(int64),
		Token: &dex.Token{
			ParentID: PolygonBipID,
			Name:     "Tether",
			UnitInfo: dex.UnitInfo{
				AtomicUnit: "microUSD",
				Conventional: dex.Denomination{
					Unit:             "USDT",
					ConversionFactor: 1e6,
				},
			},
		},
		NetTokens: map[dex.Network]*dexeth.NetToken{
			dex.Mainnet: {
				Address: common.HexToAddress("0xc2132D05D31c914a87C6611C10748AEb04B58e8F"),
				SwapContracts: map[uint32]*dexeth.SwapContract{
					0: {

						Address: common.HexToAddress("0x97a53fEF7854f4CB846F2eaCCf847229F1E10e4f"),

						Gas: dexeth.Gases{
							Swap:      235_661,
							SwapAdd:   146_368,
							Redeem:    122_032,
							RedeemAdd: 61_117,
							Refund:    82_059,
							Approve:   67_693,
							Transfer:  74_451,
						},
					},
				},
			},
			dex.Simnet: {
				Address: common.Address{},
				SwapContracts: map[uint32]*dexeth.SwapContract{
					0: {
						Address: common.Address{},
						Gas: dexeth.Gases{
							Swap:      223_163,
							SwapAdd:   146_399,
							Redeem:    82_121,
							RedeemAdd: 41_113,
							Refund:    62_527,
							Approve:   58_180,
							Transfer:  64_539,
						},
					},
				},
			},
		},
	}

	// TokenWETH is for Wrapped ETH.
	TokenWETH = &dexeth.Token{
		Token: &dex.Token{
			ParentID: PolygonBipID,
			Name:     "Wrapped Ether",
			UnitInfo: dex.UnitInfo{
				AtomicUnit: "gwei",
				Conventional: dex.Denomination{
					Unit:             "WETH",
					ConversionFactor: 1e9,
				},
				Alternatives: []dex.Denomination{
					{
						Unit:             "Szabos",
						ConversionFactor: 1e6,
					},
					{
						Unit:             "Finneys",
						ConversionFactor: 1e3,
					},
				},
				FeeRateDenom: "gas",
			},
		},
		NetTokens: map[dex.Network]*dexeth.NetToken{
			dex.Mainnet: {
				Address: common.HexToAddress("0x7ceb23fd6bc0add59e62ac25578270cff1b9f619"),
				SwapContracts: map[uint32]*dexeth.SwapContract{
					0: {

						Address: common.HexToAddress("0x878dF60d47Afa9C665dFaDCB6BF4e303C080032f"),
						Gas: dexeth.Gases{

							Swap:    206_499,
							SwapAdd: 146_403,

							Redeem:    104_800,
							RedeemAdd: 41_117,

							Refund: 65_460,

							Approve: 56_054,

							Transfer: 67_483,
						},
					},
				},
			},
		},
	}

	// TokenWBTC is for Wrapped BTC.
	TokenWBTC = &dexeth.Token{
		EVMFactor: new(int64),
		Token: &dex.Token{
			ParentID: PolygonBipID,
			Name:     "Wrapped Bitcoin",
			UnitInfo: dex.UnitInfo{
				AtomicUnit: "Sats",
				Conventional: dex.Denomination{
					Unit:             "WBTC",
					ConversionFactor: 1e8,
				},
				Alternatives: []dex.Denomination{
					{
						Unit:             "mWBTC",
						ConversionFactor: 1e5,
					},
					{
						Unit:             "µWBTC",
						ConversionFactor: 1e2,
					},
				},
				FeeRateDenom: "gas",
			},
		},
		NetTokens: map[dex.Network]*dexeth.NetToken{
			dex.Mainnet: {
				Address: common.HexToAddress("0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6"),
				SwapContracts: map[uint32]*dexeth.SwapContract{
					0: {

						Address: common.HexToAddress("0x625B7Ecd21B25b0808c4221dA281CD3A82f8b797"),
						Gas: dexeth.Gases{

							Swap:    235_661,
							SwapAdd: 146_368,

							Redeem:    110_032,
							RedeemAdd: 41_117,

							Refund: 82_063,

							Approve: 67_693,

							Transfer: 74_451,
						},
					},
				},
			},
		},
	}
)

Functions

func DefaultAmoyGenesisBlock

func DefaultAmoyGenesisBlock() *core.Genesis

DefaultAmoyGenesisBlock returns the Mumbai network genesis block. See: https://github.com/maticnetwork/bor/blob/46f93b1f9415c8778d6e5ea2f3fad440f4572ba5/core/genesis.go#L616

func DefaultBorMainnetGenesisBlock

func DefaultBorMainnetGenesisBlock() *core.Genesis

DefaultBorMainnet returns the Bor Mainnet network gensis block. See: https://github.com/maticnetwork/bor/blob/891ec7fef619cac0a796e3e29d5b2d4c095bdd9b/core/genesis.go#L509

func MaybeReadSimnetAddrs

func MaybeReadSimnetAddrs()

MaybeReadSimnetAddrs attempts to read the info files generated by the eth simnet harness to populate swap contract and token addresses in ContractAddresses and Tokens.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL