Skip to content

Commit

Permalink
Merge pull request #14 from MeanBoyCousin/v1.1.0
Browse files Browse the repository at this point in the history
V1.1.0
  • Loading branch information
MeanBoyCousin authored May 28, 2024
2 parents d119886 + bec7a96 commit 5ab3ad6
Show file tree
Hide file tree
Showing 19 changed files with 67 additions and 59 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ jobs:
- name: Build package
run: yarn build

- name: Clean package.json
run: |
echo "$(jq 'del(.scripts, .devDependencies)' package.json)" > package.json
shell: bash

- name: Create release
id: create_release
uses: actions/create-release@v1
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,10 @@
- Change log notes are now appended to releases.
- Added `tsx` as a missing dev dependency.
- Users can now hot swap between sub-accounts.

## 1.1.0

- Scripts and dev dependencies are now cleaned from package.json before building the package.
- README updates.
- Mainnet contracts now up to date.
- No longer mocking contract addresses and API URL.
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<img alt="100x Logo" src="https://app.100x.finance/brand/100x-bg-blue.webp" />
<img alt="100x Logo" src="https://app.100x.finance/brand/100x-trade-perps.webp" />
</p>

![Build](https://img.shields.io/github/actions/workflow/status/MeanBoyCousin/100xClient/release.yml?style=flat-square&label=Build&color=%234177f6&link=https://github.com/MeanBoyCousin/100xClient/actions/workflows/release.yml)
Expand Down Expand Up @@ -32,12 +32,12 @@ const Client = new HundredXClient(MY_PRIVATE_KEY)

The client can also accept a configuration object as the second parameter.

| Key | Type | Default | Description |
|--------------|------------------------|--------------------------------|---------------------------------------------------------------------------|
| debug | boolean | false | Used to enable debug mode when running the client for additional logging. |
| environment | 'testnet' \| 'mainnet' | 'testnet' | Specify the environment you wish to trade in. |
| rpc | string | Blast RPC based on environment | Specify a custom RPC url to used. |
| subAccountId | number | 1 | Specify a sub-account ID to use. This can be from 1-255. |
| Key | Type | Default | Description |
|--------------|--------------------------|--------------------------------|---------------------------------------------------------------------------|
| debug | `boolean` | `false` | Used to enable debug mode when running the client for additional logging. |
| environment | `'testnet' \| 'mainnet'` | `'testnet'` | Specify the environment you wish to trade in. |
| rpc | `string` | `Blast RPC based on environment` | Specify a custom RPC url to used. |
| subAccountId | `number` | `1` | Specify a sub-account ID to use. This can be from 1-255. |

```ts
import HundredXClient from '100x-client'
Expand Down Expand Up @@ -88,14 +88,14 @@ if (success) {

A series of useful enums can be imported from `100x-client/enums` and used to help match against responses or compose payloads.

| Name | Values | Description |
|--------------|----------------------------------------------------------------------------------------|------------------------------------------------------|
| Environment | MAINNET \| TESTNET | The environment to use when initialising the client. |
| Interval | '1M' \| '5M' \| '15M' \| '30M' \| '1H' \| '2H' \| '4H' \| '8H' \| '1D' \| '3D' \| '1W' | The interval to use when fetching K-line data. |
| MarginAssets | USDB | Symbol values of supported margin assets. |
| OrderStatus | CANCELLED \| EXPIRED \| FILLED \| OPEN \| PENDING \| REJECTED | Defines the possible states an order can be in. |
| OrderType | LIMIT \| LIMIT_MAKER \| MARKET | Order types for building order payloads. |
| TimeInForce | GTC \| FOK \| IOC | Time in force values for building order payloads. |
| Name | Values | Description |
|--------------|------------------------------------------------------------------------------------------|------------------------------------------------------|
| Environment | `MAINNET \| TESTNET` | The environment to use when initialising the client. |
| Interval | `'1M' \| '5M' \| '15M' \| '30M' \| '1H' \| '2H' \| '4H' \| '8H' \| '1D' \| '3D' \| '1W'` | The interval to use when fetching K-line data. |
| MarginAssets | `USDB` | Symbol values of supported margin assets. |
| OrderStatus | `CANCELLED \| EXPIRED \| FILLED \| OPEN \| PENDING \| REJECTED` | Defines the possible states an order can be in. |
| OrderType | `LIMIT \| LIMIT_MAKER \| MARKET` | Order types for building order payloads. |
| TimeInForce | `GTC \| FOK \| IOC` | Time in force values for building order payloads. |

### Further support

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "100x-client",
"version": "1.0.3",
"version": "1.1.0",
"description": "A TypesScript SDK for the 100x exchange API.",
"keywords": [
"100x",
Expand Down
12 changes: 6 additions & 6 deletions src/__tests__/__snapshots__/client.init.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ HundredXClient {
"cancelOrder": [Function],
"cancelOrders": [Function],
"chain": 168587773,
"ciaoAddress": "0x63bD0ca355Cfc117F5176E5eF3e34A6D60081937",
"ciaoAddress": "0x0c3b9472b3923cfe199bae24b5f5bd75fad2bae9",
"deposit": [Function],
"domain": {
"chainId": 168587773n,
"name": "100x",
"verifyingContract": "0x65CbB566D1A6E60107c0c7888761de1AdFa1ccC0",
"verifyingContract": "0x02ca4fcb63e2d3c89fa20d86ccdcfc540c683545",
"version": "0.0.0",
},
"environment": "testnet",
Expand All @@ -46,7 +46,7 @@ HundredXClient {
"privateKey": "0xa608cd43cbc3d59bc51443f475b96a4654e956d6cc91783598a8e76a34000174",
"rpc": "https://test-rpc.quiknode.pro",
"subAccountId": 2,
"verifierAddress": "0x65CbB566D1A6E60107c0c7888761de1AdFa1ccC0",
"verifierAddress": "0x02ca4fcb63e2d3c89fa20d86ccdcfc540c683545",
"withdraw": [Function],
}
`;
Expand All @@ -69,12 +69,12 @@ HundredXClient {
"cancelOrder": [Function],
"cancelOrders": [Function],
"chain": 168587773,
"ciaoAddress": "0x63bD0ca355Cfc117F5176E5eF3e34A6D60081937",
"ciaoAddress": "0x0c3b9472b3923cfe199bae24b5f5bd75fad2bae9",
"deposit": [Function],
"domain": {
"chainId": 168587773n,
"name": "100x",
"verifyingContract": "0x65CbB566D1A6E60107c0c7888761de1AdFa1ccC0",
"verifyingContract": "0x02ca4fcb63e2d3c89fa20d86ccdcfc540c683545",
"version": "0.0.0",
},
"environment": "testnet",
Expand All @@ -93,7 +93,7 @@ HundredXClient {
"privateKey": "0xa608cd43cbc3d59bc51443f475b96a4654e956d6cc91783598a8e76a34000174",
"rpc": "https://sepolia.blast.io",
"subAccountId": 1,
"verifierAddress": "0x65CbB566D1A6E60107c0c7888761de1AdFa1ccC0",
"verifierAddress": "0x02ca4fcb63e2d3c89fa20d86ccdcfc540c683545",
"withdraw": [Function],
}
`;
10 changes: 5 additions & 5 deletions src/__tests__/client.account-data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('The HundredXClient', () => {
).toEqual(address)
expect(call).toMatchInlineSnapshot(`
[
"https://api.ciaobella.dev/v1/balances?account=0xb47B0b1e44B932Ae9Bb01817E7010A553A965Ea8&signature=0xeeeabb738b08cce6097a3a64289cf90fc4d5802c4b49c8050f879654d7d3d0061fea6f9dbcf18b2eedf5e26778a24fb64cf41ab05be615a57891112e6348e0231c&subAccountId=1",
"https://api.staging.100x.finance/v1/balances?account=0xb47B0b1e44B932Ae9Bb01817E7010A553A965Ea8&signature=0x4868fc61daa6b85c0beb6ea6a4fbf48eb697dd0b2fbd90e146c237a1038d37f8759a8d059b98d5c5971ac377bf5306888953f07f25724240ec510b3e6927da871b&subAccountId=1",
undefined,
]
`)
Expand Down Expand Up @@ -105,7 +105,7 @@ describe('The HundredXClient', () => {
).toEqual(address)
expect(call).toMatchInlineSnapshot(`
[
"https://api.ciaobella.dev/v1/positionRisk?account=0xb47B0b1e44B932Ae9Bb01817E7010A553A965Ea8&signature=0xeeeabb738b08cce6097a3a64289cf90fc4d5802c4b49c8050f879654d7d3d0061fea6f9dbcf18b2eedf5e26778a24fb64cf41ab05be615a57891112e6348e0231c&subAccountId=1",
"https://api.staging.100x.finance/v1/positionRisk?account=0xb47B0b1e44B932Ae9Bb01817E7010A553A965Ea8&signature=0x4868fc61daa6b85c0beb6ea6a4fbf48eb697dd0b2fbd90e146c237a1038d37f8759a8d059b98d5c5971ac377bf5306888953f07f25724240ec510b3e6927da871b&subAccountId=1",
undefined,
]
`)
Expand Down Expand Up @@ -157,7 +157,7 @@ describe('The HundredXClient', () => {

expect(call).toMatchInlineSnapshot(`
[
"https://api.ciaobella.dev/v1/positionRisk?account=0xb47B0b1e44B932Ae9Bb01817E7010A553A965Ea8&signature=0xeeeabb738b08cce6097a3a64289cf90fc4d5802c4b49c8050f879654d7d3d0061fea6f9dbcf18b2eedf5e26778a24fb64cf41ab05be615a57891112e6348e0231c&subAccountId=1&symbol=blastperp",
"https://api.staging.100x.finance/v1/positionRisk?account=0xb47B0b1e44B932Ae9Bb01817E7010A553A965Ea8&signature=0x4868fc61daa6b85c0beb6ea6a4fbf48eb697dd0b2fbd90e146c237a1038d37f8759a8d059b98d5c5971ac377bf5306888953f07f25724240ec510b3e6927da871b&subAccountId=1&symbol=blastperp",
undefined,
]
`)
Expand Down Expand Up @@ -235,7 +235,7 @@ describe('The HundredXClient', () => {
).toEqual(address)
expect(call).toMatchInlineSnapshot(`
[
"https://api.ciaobella.dev/v1/openOrders?account=0xb47B0b1e44B932Ae9Bb01817E7010A553A965Ea8&signature=0xeeeabb738b08cce6097a3a64289cf90fc4d5802c4b49c8050f879654d7d3d0061fea6f9dbcf18b2eedf5e26778a24fb64cf41ab05be615a57891112e6348e0231c&subAccountId=1",
"https://api.staging.100x.finance/v1/openOrders?account=0xb47B0b1e44B932Ae9Bb01817E7010A553A965Ea8&signature=0x4868fc61daa6b85c0beb6ea6a4fbf48eb697dd0b2fbd90e146c237a1038d37f8759a8d059b98d5c5971ac377bf5306888953f07f25724240ec510b3e6927da871b&subAccountId=1",
undefined,
]
`)
Expand Down Expand Up @@ -295,7 +295,7 @@ describe('The HundredXClient', () => {

expect(call).toMatchInlineSnapshot(`
[
"https://api.ciaobella.dev/v1/openOrders?account=0xb47B0b1e44B932Ae9Bb01817E7010A553A965Ea8&signature=0xeeeabb738b08cce6097a3a64289cf90fc4d5802c4b49c8050f879654d7d3d0061fea6f9dbcf18b2eedf5e26778a24fb64cf41ab05be615a57891112e6348e0231c&subAccountId=1&symbol=blastperp",
"https://api.staging.100x.finance/v1/openOrders?account=0xb47B0b1e44B932Ae9Bb01817E7010A553A965Ea8&signature=0x4868fc61daa6b85c0beb6ea6a4fbf48eb697dd0b2fbd90e146c237a1038d37f8759a8d059b98d5c5971ac377bf5306888953f07f25724240ec510b3e6927da871b&subAccountId=1&symbol=blastperp",
undefined,
]
`)
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/client.init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('The HundredXClient', () => {
[
"https://api.100x.finance/v1/referral/add-referee",
{
"body": "{"account":"0xb47B0b1e44B932Ae9Bb01817E7010A553A965Ea8","code":"kickflip","signature":"0x5da080cbf906558a2642b7642572b3a5c75966e2bf3f9a8c5b86e77ef7b6395c3557266aa6971790d65f3c791d68e7894285f18bf16cecf5b9b06b53715fc1d21b"}",
"body": "{"account":"0xb47B0b1e44B932Ae9Bb01817E7010A553A965Ea8","code":"kickflip","signature":"0x0bf1266ca5b8542e07d2258e5532613f96dd6ddeedaccb4b3166016711bbd0ad600674fc14fb86b985d79f188928822286f1de586e108824d72dc3fbda49783e1c"}",
"method": "POST",
},
]
Expand Down
24 changes: 12 additions & 12 deletions src/__tests__/client.orders.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ describe('The HundredXClient', () => {
).toEqual(address)
expect(call).toMatchInlineSnapshot(`
[
"https://api.ciaobella.dev/v1/order",
"https://api.staging.100x.finance/v1/order",
{
"body": "{"expiration":1712421760000,"nonce":17098297600000000,"price":"3536240000000000000000","quantity":"1000000000000000","signature":"0x90c49b3eaef966462164fbb2d47f97eff274501ceff38f2c70586983d6c66e5e409497f66435feb0dcc5c3528bbca95c099090104375ca4c66ab41edd8e58f341c","account":"0xb47B0b1e44B932Ae9Bb01817E7010A553A965Ea8","isBuy":true,"orderType":2,"productId":1002,"subAccountId":1,"timeInForce":1}",
"body": "{"expiration":1712421760000,"nonce":17098297600000000,"price":"3536240000000000000000","quantity":"1000000000000000","signature":"0xe54009ca1e888a7d98316371517662db4c59e9264d62b364f1030b893cecf60b3c895ac45d4c86793399cdfae7e4759c2414af7ebc2fe80b7a0e907e8771fb551b","account":"0xb47B0b1e44B932Ae9Bb01817E7010A553A965Ea8","isBuy":true,"orderType":2,"productId":1002,"subAccountId":1,"timeInForce":1}",
"method": "POST",
},
]
Expand Down Expand Up @@ -119,9 +119,9 @@ describe('The HundredXClient', () => {
).toEqual(address)
expect(call).toMatchInlineSnapshot(`
[
"https://api.ciaobella.dev/v1/order",
"https://api.staging.100x.finance/v1/order",
{
"body": "{"expiration":1800000000000,"nonce":123,"price":"3450000000000000000000","quantity":"1000000000000000","signature":"0x1c434d24e714578f6f1966b0adf9cfbe574381c0c9d49b6d2c454e2db7b3825944e22d72d44acdc3aeec2d4b6642e73eb89c42b7582a568ce46b7f21859a38811b","account":"0xb47B0b1e44B932Ae9Bb01817E7010A553A965Ea8","isBuy":true,"orderType":0,"productId":1002,"subAccountId":1,"timeInForce":2}",
"body": "{"expiration":1800000000000,"nonce":123,"price":"3450000000000000000000","quantity":"1000000000000000","signature":"0x76ebeb862bc07200a55ebec586f1715acb88f77ae18865fd57cd34352471eeaf70082bcfe24200e0abef682fe1f96c9d1649f1156c6ae920ebe542e93316e9e61c","account":"0xb47B0b1e44B932Ae9Bb01817E7010A553A965Ea8","isBuy":true,"orderType":0,"productId":1002,"subAccountId":1,"timeInForce":2}",
"method": "POST",
},
]
Expand Down Expand Up @@ -344,9 +344,9 @@ describe('The HundredXClient', () => {
).toEqual(address)
expect(call).toMatchInlineSnapshot(`
[
"https://api.ciaobella.dev/v1/order",
"https://api.staging.100x.finance/v1/order",
{
"body": "{"account":"0xb47B0b1e44B932Ae9Bb01817E7010A553A965Ea8","orderId":"0x3505c6219b1f51cf216e432b153f8637c1fa9342520bd7c780bd80dafe0eed94","productId":1002,"subAccountId":1,"signature":"0x398240c7e0542ab55b4a49ea8ad11808938365923bd7e8fc42c8d101f121c228057b6e234bfc3e330432ab0a87a21d7704d790e4611f9f6069d1929eb0071a031b"}",
"body": "{"account":"0xb47B0b1e44B932Ae9Bb01817E7010A553A965Ea8","orderId":"0x3505c6219b1f51cf216e432b153f8637c1fa9342520bd7c780bd80dafe0eed94","productId":1002,"subAccountId":1,"signature":"0x84e59cbf2142640295e93c68c0ec00757a26b6d3ada13a052abb29e9aa0d9f902834784f187c6a316d03b4bb15b535584ae2498407d14a17028185694b12139a1b"}",
"method": "DELETE",
},
]
Expand Down Expand Up @@ -446,9 +446,9 @@ describe('The HundredXClient', () => {
).toEqual(address)
expect(call).toMatchInlineSnapshot(`
[
"https://api.ciaobella.dev/v1/openOrders",
"https://api.staging.100x.finance/v1/openOrders",
{
"body": "{"account":"0xb47B0b1e44B932Ae9Bb01817E7010A553A965Ea8","productId":1002,"subAccountId":1,"signature":"0x1a33343cdbbf084b254929943d818903e4ee8cd7be6f15bd42ad8938c4a2279561ab5dc19998163196b7963d10b30f2fce9d47968050cbc2bfb4bbafd184276a1c"}",
"body": "{"account":"0xb47B0b1e44B932Ae9Bb01817E7010A553A965Ea8","productId":1002,"subAccountId":1,"signature":"0x2ad1ed1080d97172760ea6474dd1eb76742f5333f106e62219dbb64282964d9f395815055519ed4f37c2f55b475568240ac51eca27e077b3d8157c3c0da2c5961c"}",
"method": "DELETE",
},
]
Expand Down Expand Up @@ -521,9 +521,9 @@ describe('The HundredXClient', () => {
).toEqual(address)
expect(call).toMatchInlineSnapshot(`
[
"https://api.ciaobella.dev/v1/order/cancel-and-replace",
"https://api.staging.100x.finance/v1/order/cancel-and-replace",
{
"body": "{"idToCancel":"0x08d4079c501e5fbb2153c7fe785ea4648ffcdac411d93511edcb5b18aecc158f","newOrder":{"expiration":1712421760000,"nonce":17098297600000000,"price":"3455000000000000000000","quantity":"1000000000000000","signature":"0x6235832ac08693d6cfaba12a4ae9918eabf3ec057500e15c632f0dca7eaa0b1c419353fa8368ec6f009c085683575fa8a8057223fa267e350c0284e33f181e011c","account":"0xb47B0b1e44B932Ae9Bb01817E7010A553A965Ea8","isBuy":true,"orderType":1,"productId":1002,"subAccountId":1,"timeInForce":0}}",
"body": "{"idToCancel":"0x08d4079c501e5fbb2153c7fe785ea4648ffcdac411d93511edcb5b18aecc158f","newOrder":{"expiration":1712421760000,"nonce":17098297600000000,"price":"3455000000000000000000","quantity":"1000000000000000","signature":"0x6a076f90627354d3d58647d6f53aaf7f75aaf7539f51112176efccc3f6e370fb7fd28aa4f8c9075b8c5f1454958286b585bfb532123608430623264abb8bf76b1c","account":"0xb47B0b1e44B932Ae9Bb01817E7010A553A965Ea8","isBuy":true,"orderType":1,"productId":1002,"subAccountId":1,"timeInForce":0}}",
"method": "POST",
},
]
Expand Down Expand Up @@ -591,9 +591,9 @@ describe('The HundredXClient', () => {
).toEqual(address)
expect(call).toMatchInlineSnapshot(`
[
"https://api.ciaobella.dev/v1/order/cancel-and-replace",
"https://api.staging.100x.finance/v1/order/cancel-and-replace",
{
"body": "{"idToCancel":"0x08d4079c501e5fbb2153c7fe785ea4648ffcdac411d93511edcb5b18aecc158f","newOrder":{"expiration":1800000000000,"nonce":123,"price":"3455000000000000000000","quantity":"1000000000000000","signature":"0xa1662d22629d41396666676ba99f9de7575c9003e7c8bc9e70b95c9bdbec38762c889af2a97ce7ed4305860f2ade24489746a6d7fc3ca8f1ea7a53f98d607e8a1c","account":"0xb47B0b1e44B932Ae9Bb01817E7010A553A965Ea8","isBuy":true,"orderType":1,"productId":1002,"subAccountId":1,"timeInForce":0}}",
"body": "{"idToCancel":"0x08d4079c501e5fbb2153c7fe785ea4648ffcdac411d93511edcb5b18aecc158f","newOrder":{"expiration":1800000000000,"nonce":123,"price":"3455000000000000000000","quantity":"1000000000000000","signature":"0xe2a84fbf510c19c1ce9b48e0b76f404a1d387751601bd50714a2e2a3ac81eddc5d7d4810a426a8ce34dc420c608faeb6ced75dbbd89ddf90ab72c8552779091f1c","account":"0xb47B0b1e44B932Ae9Bb01817E7010A553A965Ea8","isBuy":true,"orderType":1,"productId":1002,"subAccountId":1,"timeInForce":0}}",
"method": "POST",
},
]
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/client.withdraw.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ describe('The HundredXClient withdraw function', () => {
).toEqual(address)
expect(call).toMatchInlineSnapshot(`
[
"https://api.ciaobella.dev/v1/withdraw",
"https://api.staging.100x.finance/v1/withdraw",
{
"body": "{"account":"0xb47B0b1e44B932Ae9Bb01817E7010A553A965Ea8","asset":"0x79a59c326c715ac2d31c169c85d1232319e341ce","subAccountId":1,"nonce":17098297600000000,"quantity":"100000000000000000000","signature":"0x114822252331056162f0d4c5d7c703dd14aec0b2cc01c28bbdead3963735c68660ad5d2868e8f8f88e98855cab9caa4eb48f9da05308b6c11100d1d8f6c227df1c"}",
"body": "{"account":"0xb47B0b1e44B932Ae9Bb01817E7010A553A965Ea8","asset":"0x79a59c326c715ac2d31c169c85d1232319e341ce","subAccountId":1,"nonce":17098297600000000,"quantity":"100000000000000000000","signature":"0x03e35e3d0557f7a14f7631b699f7253449882705642e51debacd08df78bf03843419e37d4ce776cf319fc022277ea861fc229b14f42d03ebb18d094ccb2b22ff1c"}",
"method": "POST",
},
]
Expand Down
2 changes: 1 addition & 1 deletion src/constants/__tests__/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('The API_URL constant', () => {
expect(API_URL).toMatchInlineSnapshot(`
{
"mainnet": "https://api.100x.finance/v1",
"testnet": "https://api.ciaobella.dev/v1",
"testnet": "https://api.staging.100x.finance/v1",
}
`)
})
Expand Down
Loading

0 comments on commit 5ab3ad6

Please sign in to comment.