Skip to content

Commit

Permalink
Merge pull request #1 from alisinabh/ci
Browse files Browse the repository at this point in the history
Configure Hex package and CI actions
  • Loading branch information
alisinabh authored Feb 13, 2024
2 parents 8563b3c + 5ed6466 commit 0f12741
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 5 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "mix" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
62 changes: 62 additions & 0 deletions .github/workflows/elixir.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Elixir CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
test:
name: Test - Lint - Dialyze

runs-on: ubuntu-22.04

env:
MIX_ENV: test
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

strategy:
matrix:
otp: ['25.x', '26.x']
elixir: ['1.15', '1.16']

steps:
- uses: actions/checkout@v3

- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{matrix.otp}}
elixir-version: ${{matrix.elixir}}

- uses: actions/setup-node@v3
with:
node-version: 16

- name: Restore dependencies cache
uses: actions/cache@v3
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-

- name: Install dependencies
run: mix deps.get

- name: Run tests
run: mix coveralls.github

- name: Credo
run: mix credo --strict

- name: Dialyzer
run: mix dialyzer
3 changes: 3 additions & 0 deletions lib/uniswap/liquidity.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
defmodule Uniswap.Liquidity do
@moduledoc """
Manage Liquidity on Uniswap contracts
"""
alias Uniswap.Contracts.NonfungiblePositionManager
alias Uniswap.Liquidity.Position

Expand Down
6 changes: 3 additions & 3 deletions lib/uniswap/liquidity/math.ex
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ defmodule Uniswap.Liquidity.Math do
99
"""
@spec amount_0_for_liquidity(number, number, number) ::
float
non_neg_integer()
def amount_0_for_liquidity(liquidity, sqrt_ratio_a, sqrt_ratio_b) do
{lower_sqrt_ratio, upper_sqrt_ratio} = sort_prices(sqrt_ratio_a, sqrt_ratio_b)

Expand All @@ -159,7 +159,7 @@ defmodule Uniswap.Liquidity.Math do
199
"""
@spec amount_1_for_liquidity(number, number, number) ::
float
non_neg_integer()
def amount_1_for_liquidity(liquidity, sqrt_ratio_a, sqrt_ratio_b) do
{lower_sqrt_ratio, upper_sqrt_ratio} = sort_prices(sqrt_ratio_a, sqrt_ratio_b)

Expand Down Expand Up @@ -193,7 +193,7 @@ defmodule Uniswap.Liquidity.Math do
number,
number,
number
) :: {float, float}
) :: {non_neg_integer(), non_neg_integer()}
def amounts_for_liquidity(
liquidity,
current_sqrt_ratio,
Expand Down
55 changes: 53 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
defmodule Uniswap.MixProject do
use Mix.Project

@version "0.0.1-dev"
@source_url "https://github.com/alisinabh/elixir_uniswap"

def project do
[
app: :uniswap,
version: "0.1.0",
elixir: "~> 1.11",
start_permanent: Mix.env() == :prod,
deps: deps()
source_url: @source_url,
name: "Uniswap",
deps: deps(),
test_coverage: [tool: ExCoveralls],
preferred_cli_env: [
coveralls: :test,
"coveralls.detail": :test,
"coveralls.post": :test,
"coveralls.html": :test
],
description:
"A comprehensive Web3 library for interacting with smart contracts on Ethereum using Elixir.",
package: package(),
docs: docs(),
dialyzer: dialyzer()
]
end

Expand All @@ -18,11 +35,45 @@ defmodule Uniswap.MixProject do
]
end

defp package do
[
licenses: ["MIT"],
links: %{"GitHub" => @source_url},
maintainers: ["Alisina Bahadori"],
files: ["lib", "priv", "mix.exs", "README*", "LICENSE*", "CHANGELOG*"]
]
end

defp docs do
source_ref =
if String.ends_with?(@version, "-dev") do
"main"
else
"v#{@version}"
end

[
main: "readme",
extras: [
"README.md": [title: "Introduction"]
],
source_url: @source_url,
source_ref: source_ref
]
end

def dialyzer do
[flags: [:error_handling, :extra_return, :underspecs, :unknown, :unmatched_returns]]
end

# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:credo, "~> 1.7", only: [:dev, :test], runtime: false},
{:decimal, "~> 2.1", only: :test},
{:dialyxir, "~> 1.3", only: [:dev, :test], runtime: false},
{:ethers, "~> 0.3.0 or ~> 0.2.0"},
{:decimal, "~> 2.1", only: :test}
{:excoveralls, "~> 0.10", only: :test}
]
end
end
6 changes: 6 additions & 0 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
%{
"bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"},
"castore": {:hex, :castore, "1.0.5", "9eeebb394cc9a0f3ae56b813459f990abb0a3dedee1be6b27fdb50301930502f", [:mix], [], "hexpm", "8d7c597c3e4a64c395980882d4bca3cebb8d74197c590dc272cfd3b6a6310578"},
"credo": {:hex, :credo, "1.7.4", "68ca5cf89071511c12fd9919eb84e388d231121988f6932756596195ccf7fd35", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "9cf776d062c78bbe0f0de1ecaee183f18f2c3ec591326107989b054b7dddefc2"},
"decimal": {:hex, :decimal, "2.1.1", "5611dca5d4b2c3dd497dec8f68751f1f1a54755e8ed2a966c2633cf885973ad6", [:mix], [], "hexpm", "53cfe5f497ed0e7771ae1a475575603d77425099ba5faef9394932b35020ffcc"},
"dialyxir": {:hex, :dialyxir, "1.4.3", "edd0124f358f0b9e95bfe53a9fcf806d615d8f838e2202a9f430d59566b6b53b", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "bf2cfb75cd5c5006bec30141b131663299c661a864ec7fbbc72dfa557487a986"},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"ethereumex": {:hex, :ethereumex, "0.10.6", "6d75cac39b5b7a720b064fe48563f205d3d9784e5bde25f983dd07cf306c2a6d", [:make, :mix], [{:finch, "~> 0.16", [hex: :finch, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "58cf926239dabf8bd1fc6cf50a37b926274240b7f58ba5b235a20b5500a9a7e1"},
"ethers": {:hex, :ethers, "0.3.0", "486b711c3be2426b6d90fff35427372ad102271841f3dec940db19fe2e6d19e7", [:mix], [{:ethereumex, "~> 0.10.6", [hex: :ethereumex, repo: "hexpm", optional: false]}, {:ex_abi, "~> 0.7.0", [hex: :ex_abi, repo: "hexpm", optional: false]}, {:ex_rlp, "~> 0.6.0", [hex: :ex_rlp, repo: "hexpm", optional: false]}, {:ex_secp256k1, "~> 0.7.2", [hex: :ex_secp256k1, repo: "hexpm", optional: true]}, {:idna, "~> 6.1", [hex: :idna, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "038512dfd097288f3166609c4580a60fdf47a9de6d5474fabcf643b8d1a411e9"},
"ex_abi": {:hex, :ex_abi, "0.7.0", "4a2f83c47d98357c75862ca77fcbaa05d9199ba2888248fdb20d4f3befc3e151", [:mix], [{:ex_keccak, "~> 0.7.3", [hex: :ex_keccak, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "d35c4ef7d860fd94bcf952ab866b7639df9054c009c098ddc94cf8916d2208d6"},
"ex_keccak": {:hex, :ex_keccak, "0.7.3", "33298f97159f6b0acd28f6e96ce5ea975a0f4a19f85fe615b4f4579b88b24d06", [:mix], [{:rustler, ">= 0.0.0", [hex: :rustler, repo: "hexpm", optional: true]}, {:rustler_precompiled, "~> 0.6.1", [hex: :rustler_precompiled, repo: "hexpm", optional: false]}], "hexpm", "4c5e6d9d5f77b64ab48769a0166a9814180d40ced68ed74ce60a5174ab55b3fc"},
"ex_rlp": {:hex, :ex_rlp, "0.6.0", "985391d2356a7cb8712a4a9a2deb93f19f2fbca0323f5c1203fcaf64d077e31e", [:mix], [], "hexpm", "7135db93b861d9e76821039b60b00a6a22d2c4e751bf8c444bffe7a042f1abaf"},
"excoveralls": {:hex, :excoveralls, "0.18.0", "b92497e69465dc51bc37a6422226ee690ab437e4c06877e836f1c18daeb35da9", [:mix], [{:castore, "~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "1109bb911f3cb583401760be49c02cbbd16aed66ea9509fc5479335d284da60b"},
"file_system": {:hex, :file_system, "1.0.0", "b689cc7dcee665f774de94b5a832e578bd7963c8e637ef940cd44327db7de2cd", [:mix], [], "hexpm", "6752092d66aec5a10e662aefeed8ddb9531d79db0bc145bb8c40325ca1d8536d"},
"finch": {:hex, :finch, "0.18.0", "944ac7d34d0bd2ac8998f79f7a811b21d87d911e77a786bc5810adb75632ada4", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.3", [hex: :mint, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.4 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_pool, "~> 0.2.6 or ~> 1.0", [hex: :nimble_pool, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "69f5045b042e531e53edc2574f15e25e735b522c37e2ddb766e15b979e03aa65"},
"hpax": {:hex, :hpax, "0.1.2", "09a75600d9d8bbd064cdd741f21fc06fc1f4cf3d0fcc335e5aa19be1a7235c84", [:mix], [], "hexpm", "2c87843d5a23f5f16748ebe77969880e29809580efdaccd615cd3bed628a8c13"},
"idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"},
Expand Down

0 comments on commit 0f12741

Please sign in to comment.