Compare commits

..
Author SHA1 Message Date
dependabot[bot] cd51c513d7 build(deps): bump actions/checkout from 5 to 6
Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-24 22:23:04 +00:00
9 changed files with 10 additions and 92 deletions

No files matched your search

+1 -1
View File
@@ -14,7 +14,7 @@ jobs:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v2.5.0
uses: dependabot/fetch-metadata@v2.4.0
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
@@ -15,7 +15,7 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
ref: ${{ github.head_ref }}
+1 -1
View File
@@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
+1 -1
View File
@@ -31,7 +31,7 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v5
uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
+3 -8
View File
@@ -1,5 +1,5 @@
{
"name": "moltox/laravel-bitunix-api",
"name": "mahdimsr/laravel-bitunix-api",
"description": "composer package for using bitunix api trading",
"keywords": [
"msr",
@@ -13,17 +13,12 @@
"name": "mahdi mansouri",
"email": "mahdi.msr4@gmail.com",
"role": "Developer"
},
{
"name": "Maik Mueller ",
"email": "mueller.maik1@gmail.com",
"role": "Developer"
}
],
"require": {
"php": "^8.4",
"spatie/laravel-package-tools": "^1.16",
"illuminate/contracts": "^10.0||^11.0||^12.0||^13.0"
"illuminate/contracts": "^11.0||^12.0||^10.0"
},
"require-dev": {
"laravel/pint": "^1.14",
@@ -74,7 +69,7 @@
}
}
},
"version": "1.2.2",
"version": "1.1.0",
"minimum-stability": "stable",
"prefer-stable": true
}
-13
View File
@@ -1,13 +0,0 @@
<?php
namespace Msr\LaravelBitunixApi\Contracts;
interface RateLimiterContract
{
public function throttle(
string $bucket,
string $identity,
int $maxRequests,
float $perSeconds
): void;
}
+3 -1
View File
@@ -305,8 +305,10 @@ class LaravelBitunixApi implements ChangeLeverageRequestContract, ChangeMarginMo
$body['slStopType'] = $slStopType;
}
return $this->getPrivateFutureClient([], $body)->post('tpsl/position/place_order', [
$response = $this->getPrivateFutureClient([], $body)->post('tpsl/position/place_order', [
'json' => $body,
]);
return $response;
}
}
-9
View File
@@ -3,7 +3,6 @@
namespace Msr\LaravelBitunixApi;
use Msr\LaravelBitunixApi\Commands\LaravelBitunixApiCommand;
use Msr\LaravelBitunixApi\Contracts\RateLimiterContract;
use Msr\LaravelBitunixApi\Requests\ChangeLeverageRequestContract;
use Msr\LaravelBitunixApi\Requests\ChangeMarginModeRequestContract;
use Msr\LaravelBitunixApi\Requests\FlashClosePositionRequestContract;
@@ -14,10 +13,8 @@ use Msr\LaravelBitunixApi\Requests\GetTradingPairsRequestContract;
use Msr\LaravelBitunixApi\Requests\PlaceOrderRequestContract;
use Msr\LaravelBitunixApi\Requests\PlacePositionTpSlOrderRequestContract;
use Msr\LaravelBitunixApi\Requests\PlaceTpSlOrderRequestContract;
use Msr\LaravelBitunixApi\Support\CacheRateLimiter;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;
use Illuminate\Contracts\Cache\Factory as CacheFactory;
class LaravelBitunixApiServiceProvider extends PackageServiceProvider
{
@@ -50,11 +47,5 @@ class LaravelBitunixApiServiceProvider extends PackageServiceProvider
$this->app->bind(PlaceTpSlOrderRequestContract::class, LaravelBitunixApi::class);
$this->app->bind(PlacePositionTpSlOrderRequestContract::class, LaravelBitunixApi::class);
$this->app->bind(GetTradingPairsRequestContract::class, LaravelBitunixApi::class);
$this->app->bind(RateLimiterContract::class, function ($app) {
return new CacheRateLimiter(
$app->make(CacheFactory::class)->store()
);
});
}
}
-57
View File
@@ -1,57 +0,0 @@
<?php
namespace Msr\LaravelBitunixApi\Support;
use Illuminate\Contracts\Cache\Repository;
use Msr\LaravelBitunixApi\Contracts\RateLimiterContract;
class CacheRateLimiter implements RateLimiterContract
{
public function __construct(
protected Repository $cache,
) {
}
public function throttle(
string $bucket,
string $identity,
int $maxRequests,
float $perSeconds
): void {
if ($maxRequests <= 0 || $perSeconds <= 0) {
return;
}
$cacheKey = $this->makeCacheKey($bucket, $identity);
$minIntervalMicroseconds = (int) (($perSeconds / $maxRequests) * 1_000_000);
$lastRequestAt = $this->cache->get($cacheKey);
if (is_numeric($lastRequestAt)) {
$elapsedMicroseconds = (int) ((microtime(true) - (float) $lastRequestAt) * 1_000_000);
if ($elapsedMicroseconds < $minIntervalMicroseconds) {
$sleepMicroseconds = $minIntervalMicroseconds - $elapsedMicroseconds;
if ($sleepMicroseconds > 0) {
usleep($sleepMicroseconds);
}
}
}
$this->cache->put(
$cacheKey,
microtime(true),
now()->addSeconds((int) max(1, ceil($perSeconds * 2)))
);
}
protected function makeCacheKey(string $bucket, string $identity): string
{
return sprintf(
'laravel_bitunix_api:rate_limit:%s:%s',
$bucket,
sha1($identity)
);
}
}