From bf784348574471157d371b83eae5a1c49b86fa66 Mon Sep 17 00:00:00 2001 From: moo-onthelawn <70078372+moo-onthelawn@users.noreply.github.com> Date: Tue, 28 May 2024 10:49:35 -0400 Subject: [PATCH 1/9] bump version of abacus to unblock previous prs (#385) --- build.gradle.kts | 2 +- v4_abacus.podspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 36f46b1dd..b49e59a7f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -51,7 +51,7 @@ allprojects { } group = "exchange.dydx.abacus" -version = "1.7.32" +version = "1.7.33" repositories { google() diff --git a/v4_abacus.podspec b/v4_abacus.podspec index dcbba085b..319a1788b 100644 --- a/v4_abacus.podspec +++ b/v4_abacus.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'v4_abacus' - spec.version = '1.7.32' + spec.version = '1.7.33' spec.homepage = 'https://github.com/dydxprotocol/v4-abacus' spec.source = { :http=> ''} spec.authors = '' From ae8cb677be58461101274bb62c832320141138b6 Mon Sep 17 00:00:00 2001 From: Rui <102453770+ruixhuang@users.noreply.github.com> Date: Tue, 28 May 2024 16:12:47 -0700 Subject: [PATCH 2/9] Update bump_version_gh_action.sh --- bump_version_gh_action.sh | 54 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/bump_version_gh_action.sh b/bump_version_gh_action.sh index 069819e32..0b8b145e6 100755 --- a/bump_version_gh_action.sh +++ b/bump_version_gh_action.sh @@ -1,9 +1,61 @@ #!/bin/sh +vercomp () { + if [[ $1 == $2 ]] + then + return 0 + fi + local IFS=. + local i ver1=($1) ver2=($2) + # fill empty fields in ver1 with zeros + for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)) + do + ver1[i]=0 + done + for ((i=0; i<${#ver1[@]}; i++)) + do + if [[ -z ${ver2[i]} ]] + then + # fill empty fields in ver2 with zeros + ver2[i]=0 + fi + if ((10#${ver1[i]} > 10#${ver2[i]})) + then + return 1 + fi + if ((10#${ver1[i]} < 10#${ver2[i]})) + then + return 2 + fi + done + return 0 +} + +# Defining a temporary directory for cloning +TMP_DIR=$(mktemp -d) + +curl https://raw.githubusercontent.com/dydxprotocol/v4-abacus/main/build.gradle.kts > $TMP_DIR/build.gradle.kts + # search for the first line that starts with "version" in build.gradle.kts # get the value in the quotes VERSION=$(grep "^version = " build.gradle.kts | sed -n 's/version = "\(.*\)"/\1/p') +REPO_VERSION=$(grep "^version = " $TMP_DIR/build.gradle.kts | sed -n 's/version = "\(.*\)"/\1/p') + +# call the version comparison function + +vercomp $REPO_VERSION $VERSION + case $? in + 0) SHOULD_BUMP=true ;; + 1) SHOULD_BUMP=true ;; + 2) SHOULD_BUMP=false ;; + esac + +if [ $SHOULD_BUMP = false ]; then + echo "Repo version >= PR version... No need to bump." + exit -1 +fi + # increment the version number NEW_VERSION=$(echo $VERSION | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g') @@ -12,3 +64,5 @@ if [ -n "$NEW_VERSION" ]; then sed -i '' "s/version = \"$VERSION\"/version = \"$NEW_VERSION\"/" build.gradle.kts echo "Version bumped to $NEW_VERSION" fi + +exit 0 From 5436ef4b43502d3a336163191c06ff3654db967e Mon Sep 17 00:00:00 2001 From: Rui <102453770+ruixhuang@users.noreply.github.com> Date: Tue, 28 May 2024 16:16:20 -0700 Subject: [PATCH 3/9] Update bump_version.yml --- .github/workflows/bump_version.yml | 50 ++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/.github/workflows/bump_version.yml b/.github/workflows/bump_version.yml index f73020cf9..21326af9c 100644 --- a/.github/workflows/bump_version.yml +++ b/.github/workflows/bump_version.yml @@ -1,16 +1,13 @@ name: Bump version on PR merge on: - pull_request: - branches: - - main - types: closed + pull_request_target: + types: [opened, synchronize, reopened] permissions: contents: write jobs: update_version: - if: github.event.pull_request.merged == true runs-on: macos-latest steps: - name: checkout @@ -18,14 +15,41 @@ jobs: with: # Fetch full depth, otherwise the last step overwrites the last commit's parent, essentially removing the graph. fetch-depth: 0 - + token: ${{ secrets.BOT_PAT }} + ref: ${{ github.head_ref }} + - name: Run bump_version_gh_action.sh + id: bump-version run: | - bash ./bump_version_gh_action.sh - - name: Amend the last commit + set +e + ./bump_version_gh_action.sh + echo "bump_version_ret=$?" >> $GITHUB_OUTPUT + env: + GITHUB_TOKEN: ${{ secrets.BOT_PAT }} + + - name: Import bot's GPG key for signing commits + id: import-gpg + uses: crazy-max/ghaction-import-gpg@v6 + with: + gpg_private_key: ${{ secrets.BOT_GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.BOT_GPG_PASSPHRASE }} + #git_config_global: true + git_user_signingkey: true + git_commit_gpgsign: true + + - name: Sign commit and push changes run: | - git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" - git config --global user.name "${GITHUB_ACTOR}" - git commit -a --amend --no-edit - git push --force-with-lease - echo "Complete" + if [[ "${{ steps.bump-version.outputs.bump_version_ret }}" == "0" ]]; then + git config --global user.email ${{ steps.import-gpg.outputs.name }} + git config --global user.name ${{ steps.import-gpg.outputs.email }} + + git commit -S -m "Bump version" build.gradle.kts + git push + fi + env: + # GITHUB_TOKEN: ${{ secrets.BOT_PAT }} + GIT_AUTHOR_NAME: ${{ steps.import-gpg.outputs.name }} + GIT_AUTHOR_EMAIL: ${{ steps.import-gpg.outputs.email }} + GIT_COMMITTER_NAME: ${{ steps.import-gpg.outputs.name }} + GIT_COMMITTER_EMAIL: ${{ steps.import-gpg.outputs.email }} + From dabb8a7c65df1cba18e1f2a2fe820300668df300 Mon Sep 17 00:00:00 2001 From: Rui <102453770+ruixhuang@users.noreply.github.com> Date: Tue, 28 May 2024 16:17:59 -0700 Subject: [PATCH 4/9] Update bump_version.yml --- .github/workflows/bump_version.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bump_version.yml b/.github/workflows/bump_version.yml index 21326af9c..05c9afce0 100644 --- a/.github/workflows/bump_version.yml +++ b/.github/workflows/bump_version.yml @@ -1,4 +1,4 @@ -name: Bump version on PR merge +name: Bump version on PR on: pull_request_target: types: [opened, synchronize, reopened] From 855c9c35c601f1fbdcde309bd0d2264d3e10b470 Mon Sep 17 00:00:00 2001 From: Rui <102453770+ruixhuang@users.noreply.github.com> Date: Tue, 28 May 2024 16:35:21 -0700 Subject: [PATCH 5/9] Update bump_version_gh_action.sh --- bump_version_gh_action.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bump_version_gh_action.sh b/bump_version_gh_action.sh index 0b8b145e6..1a808e057 100755 --- a/bump_version_gh_action.sh +++ b/bump_version_gh_action.sh @@ -57,7 +57,7 @@ if [ $SHOULD_BUMP = false ]; then fi # increment the version number -NEW_VERSION=$(echo $VERSION | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g') +NEW_VERSION=$(echo $REPO_VERSION | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g') #if NEW_VERSION is not empty, replace the version in build.gradle.kts if [ -n "$NEW_VERSION" ]; then From f5489653068b4e11d6378f50e9c8320e2f5a5a05 Mon Sep 17 00:00:00 2001 From: Rui <102453770+ruixhuang@users.noreply.github.com> Date: Tue, 28 May 2024 16:51:01 -0700 Subject: [PATCH 6/9] Update bump_version_gh_action.sh --- bump_version_gh_action.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bump_version_gh_action.sh b/bump_version_gh_action.sh index 1a808e057..513531fa0 100755 --- a/bump_version_gh_action.sh +++ b/bump_version_gh_action.sh @@ -51,8 +51,8 @@ vercomp $REPO_VERSION $VERSION 2) SHOULD_BUMP=false ;; esac -if [ $SHOULD_BUMP = false ]; then - echo "Repo version >= PR version... No need to bump." +if [ $SHOULD_BUMP == false ]; then + echo "Repo version > PR version... No need to bump." exit -1 fi From a283d15ad77e5a29ea5ce00a9f92423c03597168 Mon Sep 17 00:00:00 2001 From: Rui <102453770+ruixhuang@users.noreply.github.com> Date: Tue, 28 May 2024 16:51:34 -0700 Subject: [PATCH 7/9] Update bump_version_gh_action.sh --- bump_version_gh_action.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bump_version_gh_action.sh b/bump_version_gh_action.sh index 513531fa0..d8b8e8439 100755 --- a/bump_version_gh_action.sh +++ b/bump_version_gh_action.sh @@ -52,7 +52,7 @@ vercomp $REPO_VERSION $VERSION esac if [ $SHOULD_BUMP == false ]; then - echo "Repo version > PR version... No need to bump." + echo "Repo version < PR version... No need to bump." exit -1 fi From 02646be5eaec9f628fee8353d4160f316d5fe01f Mon Sep 17 00:00:00 2001 From: aleka Date: Wed, 29 May 2024 10:32:43 -0400 Subject: [PATCH 8/9] Add equity tiers in configs output (#388) Co-authored-by: Rui <102453770+ruixhuang@users.noreply.github.com> --- build.gradle.kts | 2 +- .../exchange.dydx.abacus/output/Configs.kt | 109 +++++++++++++++++- v4_abacus.podspec | 2 +- 3 files changed, 110 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index b49e59a7f..00084403b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -51,7 +51,7 @@ allprojects { } group = "exchange.dydx.abacus" -version = "1.7.33" +version = "1.7.34" repositories { google() diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/output/Configs.kt b/src/commonMain/kotlin/exchange.dydx.abacus/output/Configs.kt index 3a5077234..bfcd7e2bd 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/output/Configs.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/output/Configs.kt @@ -6,6 +6,7 @@ import exchange.dydx.abacus.protocols.ParserProtocol import exchange.dydx.abacus.utils.IList import exchange.dydx.abacus.utils.Logger import kollections.JsExport +import kollections.iListOf import kollections.iMutableListOf import kotlinx.serialization.Serializable @@ -247,6 +248,103 @@ data class FeeTier( } } +@JsExport +@Serializable +data class EquityTiers( + val shortTermOrderEquityTiers: IList, + val statefulOrderEquityTiers: IList, +) { + companion object { + internal fun create( + existing: EquityTiers?, + parser: ParserProtocol, + data: Map<*, *>?, + ): EquityTiers? { + data?.let { + val shortTermOrderEquityTiers = parser.asNativeList(data["shortTermOrderEquityTiers"])?.let { tiers -> + create(existing?.shortTermOrderEquityTiers, parser, tiers) + } ?: iListOf() + + val statefulOrderEquityTiers = parser.asNativeList(data["statefulOrderEquityTiers"])?.let { tiers -> + create(existing?.statefulOrderEquityTiers, parser, tiers) + } ?: iListOf() + + return EquityTiers(shortTermOrderEquityTiers, statefulOrderEquityTiers) + } + + Logger.d { "Equity Tiers not valid" } + return null + } + + internal fun create( + existing: IList?, + parser: ParserProtocol, + data: List<*>? + ): IList? { + data?.let { + val equityTiers = iMutableListOf() + for (i in data.indices) { + val item = data[i] + val nextItem = data.getOrNull(i + 1) + parser.asMap(item)?.let { + val tier = existing?.getOrNull(i) + val nextTierData = parser.asMap(nextItem) + EquityTier.create(tier, parser, it, nextTierData)?.let { equityTier -> + equityTiers.add(equityTier) + } + } + } + return equityTiers + } + Logger.d { "Equity Tiers not valid" } + return null + } + } +} + +@JsExport +@Serializable +data class EquityTier( + val requiredTotalNetCollateralUSD: Double, + val nextLevelRequiredTotalNetCollateralUSD: Double?, + val maxOrders: Int, +) { + companion object { + internal fun create( + existing: EquityTier?, + parser: ParserProtocol, + data: Map<*, *>?, + nextTierData: Map<*, *>? + ): EquityTier? { + data?.let { + val requiredTotalNetCollateralUSD = parser.asDouble(data["requiredTotalNetCollateralUSD"]) + val nextLevelRequiredTotalNetCollateralUSD = nextTierData?.let { + parser.asDouble(nextTierData["requiredTotalNetCollateralUSD"]) + } + val maxOrders = parser.asInt(data["maxOrders"]) + + if (requiredTotalNetCollateralUSD != null && maxOrders != null) { + return if ( + existing?.requiredTotalNetCollateralUSD != requiredTotalNetCollateralUSD || + existing?.nextLevelRequiredTotalNetCollateralUSD != nextLevelRequiredTotalNetCollateralUSD || + existing?.maxOrders != maxOrders + ) { + EquityTier( + requiredTotalNetCollateralUSD, + nextLevelRequiredTotalNetCollateralUSD, + maxOrders, + ) + } else { + existing + } + } + } + Logger.d { "Equity Tier not valid" } + return null + } + } +} + @JsExport @Serializable data class WithdrawalGating( @@ -346,6 +444,7 @@ data class Configs( val network: NetworkConfigs?, val feeTiers: IList?, val feeDiscounts: IList?, + val equityTiers: EquityTiers?, val withdrawalGating: WithdrawalGating?, val withdrawalCapacity: WithdrawalCapacity?, ) { @@ -371,6 +470,11 @@ data class Configs( parser.asList(data["feeDiscounts"]), localizer, ) + val equityTiers = EquityTiers.create( + existing?.equityTiers, + parser, + parser.asMap(data["equityTiers"]), + ) var withdrawalGating = WithdrawalGating.create( existing?.withdrawalGating, parser, @@ -383,12 +487,14 @@ data class Configs( ) return if (existing?.network !== network || existing?.feeTiers != feeTiers || - existing?.feeDiscounts != feeDiscounts + existing?.feeDiscounts != feeDiscounts || + existing?.equityTiers != equityTiers ) { Configs( network, feeTiers, feeDiscounts, + equityTiers, withdrawalGating, withdrawalCapacity, ) @@ -399,6 +505,7 @@ data class Configs( null, null, null, + null, ) } } diff --git a/v4_abacus.podspec b/v4_abacus.podspec index 319a1788b..2e668c1f2 100644 --- a/v4_abacus.podspec +++ b/v4_abacus.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'v4_abacus' - spec.version = '1.7.33' + spec.version = '1.7.34' spec.homepage = 'https://github.com/dydxprotocol/v4-abacus' spec.source = { :http=> ''} spec.authors = '' From ffa8ff66470842b5e677186bbfec1a53c0ee2905 Mon Sep 17 00:00:00 2001 From: mobile-build-bot-git Date: Wed, 29 May 2024 15:04:24 +0000 Subject: [PATCH 9/9] Bump version --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 00084403b..2ce50ac20 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -51,7 +51,7 @@ allprojects { } group = "exchange.dydx.abacus" -version = "1.7.34" +version = "1.7.35" repositories { google()