@reyaxyz/sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -0
- package/README.md +10 -0
- package/dist/abis/AccountModule.json +1079 -0
- package/dist/abis/ExecutionModule.json +758 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/services/encode.js +37 -0
- package/dist/services/encode.js.map +1 -0
- package/dist/services/executeTransaction.js +110 -0
- package/dist/services/executeTransaction.js.map +1 -0
- package/dist/services/lp/encode.js +29 -0
- package/dist/services/lp/encode.js.map +1 -0
- package/dist/services/lp/lp.js +70 -0
- package/dist/services/lp/lp.js.map +1 -0
- package/dist/services/lp/types.js +3 -0
- package/dist/services/lp/types.js.map +1 -0
- package/dist/services/margin-accounts/account.js +56 -0
- package/dist/services/margin-accounts/account.js.map +1 -0
- package/dist/services/margin-accounts/deposit.js +56 -0
- package/dist/services/margin-accounts/deposit.js.map +1 -0
- package/dist/services/margin-accounts/encode.js +43 -0
- package/dist/services/margin-accounts/encode.js.map +1 -0
- package/dist/services/margin-accounts/types.js +3 -0
- package/dist/services/margin-accounts/types.js.map +1 -0
- package/dist/services/margin-accounts/withdraw.js +56 -0
- package/dist/services/margin-accounts/withdraw.js.map +1 -0
- package/dist/services/orders/encode.js +25 -0
- package/dist/services/orders/encode.js.map +1 -0
- package/dist/services/orders/order.js +56 -0
- package/dist/services/orders/order.js.map +1 -0
- package/dist/services/orders/types.js +3 -0
- package/dist/services/orders/types.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/services/encode.d.ts +6 -0
- package/dist/types/services/encode.d.ts.map +1 -0
- package/dist/types/services/executeTransaction.d.ts +12 -0
- package/dist/types/services/executeTransaction.d.ts.map +1 -0
- package/dist/types/services/lp/encode.d.ts +4 -0
- package/dist/types/services/lp/encode.d.ts.map +1 -0
- package/dist/types/services/lp/lp.d.ts +4 -0
- package/dist/types/services/lp/lp.d.ts.map +1 -0
- package/dist/types/services/lp/types.d.ts +17 -0
- package/dist/types/services/lp/types.d.ts.map +1 -0
- package/dist/types/services/margin-accounts/account.d.ts +3 -0
- package/dist/types/services/margin-accounts/account.d.ts.map +1 -0
- package/dist/types/services/margin-accounts/deposit.d.ts +3 -0
- package/dist/types/services/margin-accounts/deposit.d.ts.map +1 -0
- package/dist/types/services/margin-accounts/encode.d.ts +5 -0
- package/dist/types/services/margin-accounts/encode.d.ts.map +1 -0
- package/dist/types/services/margin-accounts/types.d.ts +25 -0
- package/dist/types/services/margin-accounts/types.d.ts.map +1 -0
- package/dist/types/services/margin-accounts/withdraw.d.ts +3 -0
- package/dist/types/services/margin-accounts/withdraw.d.ts.map +1 -0
- package/dist/types/services/orders/encode.d.ts +3 -0
- package/dist/types/services/orders/encode.d.ts.map +1 -0
- package/dist/types/services/orders/order.d.ts +3 -0
- package/dist/types/services/orders/order.d.ts.map +1 -0
- package/dist/types/services/orders/types.d.ts +12 -0
- package/dist/types/services/orders/types.d.ts.map +1 -0
- package/dist/types/utils/action.d.ts +27 -0
- package/dist/types/utils/action.d.ts.map +1 -0
- package/dist/types/utils/routerCommands.d.ts +21 -0
- package/dist/types/utils/routerCommands.d.ts.map +1 -0
- package/dist/types/utils/txHelpers.d.ts +2 -0
- package/dist/types/utils/txHelpers.d.ts.map +1 -0
- package/dist/utils/action.js +22 -0
- package/dist/utils/action.js.map +1 -0
- package/dist/utils/routerCommands.js +41 -0
- package/dist/utils/routerCommands.js.map +1 -0
- package/dist/utils/txHelpers.js +8 -0
- package/dist/utils/txHelpers.js.map +1 -0
- package/package.json +36 -0
- package/src/abis/AccountModule.json +1079 -0
- package/src/abis/CoreProxy.json +206 -0
- package/src/abis/ExecutionModule.json +758 -0
- package/src/index.ts +1 -0
- package/src/services/encode.ts +72 -0
- package/src/services/executeTransaction.ts +54 -0
- package/src/services/lp/encode.ts +36 -0
- package/src/services/lp/lp.ts +47 -0
- package/src/services/lp/types.ts +18 -0
- package/src/services/margin-accounts/account.ts +21 -0
- package/src/services/margin-accounts/deposit.ts +23 -0
- package/src/services/margin-accounts/encode.ts +56 -0
- package/src/services/margin-accounts/types.ts +27 -0
- package/src/services/margin-accounts/withdraw.ts +23 -0
- package/src/services/orders/encode.ts +29 -0
- package/src/services/orders/order.ts +24 -0
- package/src/services/orders/types.ts +12 -0
- package/src/utils/action.ts +41 -0
- package/src/utils/routerCommands.ts +58 -0
- package/src/utils/txHelpers.ts +3 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.matchOrder = void 0;
|
|
40
|
+
var encode_1 = require("./encode");
|
|
41
|
+
var executeTransaction_1 = require("../executeTransaction");
|
|
42
|
+
var matchOrder = function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
43
|
+
var _a, data, value, result;
|
|
44
|
+
return __generator(this, function (_b) {
|
|
45
|
+
switch (_b.label) {
|
|
46
|
+
case 0:
|
|
47
|
+
_a = (0, encode_1.encodeMatchOrder)(params.accountId, params.orderBase, params.orderPriceLimit, params.counterpartyAccountIds, params.marketId, params.exchangeId), data = _a.calldata, value = _a.value;
|
|
48
|
+
return [4 /*yield*/, (0, executeTransaction_1.executeTransaction)(params.signer, data, value, params.chainId)];
|
|
49
|
+
case 1:
|
|
50
|
+
result = _b.sent();
|
|
51
|
+
return [2 /*return*/, result];
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}); };
|
|
55
|
+
exports.matchOrder = matchOrder;
|
|
56
|
+
//# sourceMappingURL=order.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order.js","sourceRoot":"/","sources":["services/orders/order.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,mCAA4C;AAC5C,4DAA2D;AAEpD,IAAM,UAAU,GAAG,UAAO,MAAsB;;;;;gBAE/C,KAA4B,IAAA,yBAAgB,EAChD,MAAM,CAAC,SAAS,EAChB,MAAM,CAAC,SAAS,EAChB,MAAM,CAAC,eAAe,EACtB,MAAM,CAAC,sBAAsB,EAC7B,MAAM,CAAC,QAAQ,EACf,MAAM,CAAC,UAAU,CAClB,EAPiB,IAAI,cAAA,EAAE,KAAK,WAAA,CAO3B;gBAEa,qBAAM,IAAA,uCAAkB,EACrC,MAAM,CAAC,MAAM,EACb,IAAI,EACJ,KAAK,EACL,MAAM,CAAC,OAAO,CACf,EAAA;;gBALK,MAAM,GAAG,SAKd;gBAED,sBAAO,MAAM,EAAC;;;KACf,CAAC;AAnBW,QAAA,UAAU,cAmBrB","sourcesContent":["import { MatchOrderArgs } from './types';\nimport { encodeMatchOrder } from './encode';\nimport { executeTransaction } from '../executeTransaction';\n\nexport const matchOrder = async (params: MatchOrderArgs): Promise<unknown> => {\n // @todo update type once we agree on the structure\n const { calldata: data, value } = encodeMatchOrder(\n params.accountId,\n params.orderBase,\n params.orderPriceLimit,\n params.counterpartyAccountIds,\n params.marketId,\n params.exchangeId,\n );\n\n const result = await executeTransaction(\n params.signer,\n data,\n value,\n params.chainId,\n );\n\n return result;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"/","sources":["services/orders/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Signer } from 'ethers';\n\nexport type MatchOrderArgs = {\n signer: Signer;\n chainId: number;\n accountId: number;\n orderBase: bigint;\n orderPriceLimit: bigint;\n counterpartyAccountIds: number[];\n marketId: number;\n exchangeId: number;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { MethodParameters, MultiAction } from '../utils/action';
|
|
2
|
+
export declare const encodeSingleDeposit: (token: string, amount: bigint, marketId: number, exchangeId: number, multiAction: MultiAction) => void;
|
|
3
|
+
export declare const encodeSingleWithdraw: (token: string, amount: bigint, marketId: number, exchangeId: number, multiAction: MultiAction) => void;
|
|
4
|
+
export declare const encodeSingleTrade: (counterpartyAccountIds: number[], orderBase: bigint, orderPriceLimit: bigint, marketId: number, exchangeId: number, multiAction: MultiAction) => void;
|
|
5
|
+
export declare const encodeRouterCall: (multiAction: MultiAction, accountId: number, nativeCurrencyValue: bigint) => MethodParameters;
|
|
6
|
+
//# sourceMappingURL=encode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode.d.ts","sourceRoot":"/","sources":["services/encode.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAOhE,eAAO,MAAM,mBAAmB,UACvB,MAAM,UACL,MAAM,YACJ,MAAM,cACJ,MAAM,eACL,WAAW,KACvB,IAIF,CAAC;AAEF,eAAO,MAAM,oBAAoB,UACxB,MAAM,UACL,MAAM,YACJ,MAAM,cACJ,MAAM,eACL,WAAW,KACvB,IAIF,CAAC;AAEF,eAAO,MAAM,iBAAiB,2BACJ,MAAM,EAAE,aACrB,MAAM,mBACA,MAAM,YACb,MAAM,cACJ,MAAM,eACL,WAAW,KACvB,IAeF,CAAC;AAEF,eAAO,MAAM,gBAAgB,gBACd,WAAW,aACb,MAAM,uBACI,MAAM,KAC1B,gBAUF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Signer } from 'ethers';
|
|
2
|
+
export type Transaction = {
|
|
3
|
+
from: string;
|
|
4
|
+
to: string;
|
|
5
|
+
data: string;
|
|
6
|
+
value?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function estimateGas(signer: Signer, data: string, value: string, chainId: number): Promise<Transaction & {
|
|
9
|
+
gasLimit: bigint;
|
|
10
|
+
}>;
|
|
11
|
+
export declare function executeTransaction(signer: Signer, data: string, value: string, chainId: number): Promise<import("ethers").TransactionReceipt | null>;
|
|
12
|
+
//# sourceMappingURL=executeTransaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executeTransaction.d.ts","sourceRoot":"/","sources":["services/executeTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAsB,WAAW,CAC/B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,WAAW,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAqB7C;AAED,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,uDAWhB"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { MethodParameters } from '../../utils/action';
|
|
2
|
+
export declare const encodeProvideLiquidityCall: (poolId: number, accountOwner: string, amount: number, minShares: number) => MethodParameters;
|
|
3
|
+
export declare const encodeRemoveLiquidityCall: (poolId: number, sharesAmount: number, minOut: number) => MethodParameters;
|
|
4
|
+
//# sourceMappingURL=encode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode.d.ts","sourceRoot":"/","sources":["services/lp/encode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAYtD,eAAO,MAAM,0BAA0B,WAC7B,MAAM,gBACA,MAAM,UACZ,MAAM,aACH,MAAM,KAChB,gBAMF,CAAC;AAEF,eAAO,MAAM,yBAAyB,WAC5B,MAAM,gBACA,MAAM,UACZ,MAAM,KACb,gBAMF,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ProvideLiquidityArgs, RemoveLiquidityArgs } from './types';
|
|
2
|
+
export declare const provideLiquidity: (params: ProvideLiquidityArgs) => Promise<unknown>;
|
|
3
|
+
export declare const removeLiquidity: (params: RemoveLiquidityArgs) => Promise<unknown>;
|
|
4
|
+
//# sourceMappingURL=lp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lp.d.ts","sourceRoot":"/","sources":["services/lp/lp.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEpE,eAAO,MAAM,gBAAgB,WACnB,oBAAoB,KAC3B,QAAQ,OAAO,CAiBjB,CAAC;AAEF,eAAO,MAAM,eAAe,WAClB,mBAAmB,KAC1B,QAAQ,OAAO,CAgBjB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Signer } from 'ethers';
|
|
2
|
+
export type ProvideLiquidityArgs = {
|
|
3
|
+
signer: Signer;
|
|
4
|
+
chainId: number;
|
|
5
|
+
poolId: number;
|
|
6
|
+
owner: string;
|
|
7
|
+
amount: number;
|
|
8
|
+
minShares: number;
|
|
9
|
+
};
|
|
10
|
+
export type RemoveLiquidityArgs = {
|
|
11
|
+
signer: Signer;
|
|
12
|
+
chainId: number;
|
|
13
|
+
poolId: number;
|
|
14
|
+
sharesAmount: number;
|
|
15
|
+
minOut: number;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["services/lp/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"/","sources":["services/margin-accounts/account.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,eAAO,MAAM,aAAa,WAChB,iBAAiB,KACxB,QAAQ,OAAO,CAcjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deposit.d.ts","sourceRoot":"/","sources":["services/margin-accounts/deposit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAItC,eAAO,MAAM,OAAO,WAAkB,WAAW,KAAG,QAAQ,OAAO,CAkBlE,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { MethodParameters } from '../../utils/action';
|
|
2
|
+
export declare const encodeCreateAccountCall: (accountOwner: string) => MethodParameters;
|
|
3
|
+
export declare const encodeDeposit: (accountId: number, token: string, amount: bigint, marketId: number, exchangeId: number) => MethodParameters;
|
|
4
|
+
export declare const encodeWithdraw: (accountId: number, token: string, amount: bigint, marketId: number, exchangeId: number) => MethodParameters;
|
|
5
|
+
//# sourceMappingURL=encode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode.d.ts","sourceRoot":"/","sources":["services/margin-accounts/encode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAe,MAAM,oBAAoB,CAAC;AASnE,eAAO,MAAM,uBAAuB,iBACpB,MAAM,KACnB,gBAMF,CAAC;AAEF,eAAO,MAAM,aAAa,cACb,MAAM,SACV,MAAM,UACL,MAAM,YACJ,MAAM,cACJ,MAAM,KACjB,gBAWF,CAAC;AAEF,eAAO,MAAM,cAAc,cACd,MAAM,SACV,MAAM,UACL,MAAM,YACJ,MAAM,cACJ,MAAM,KACjB,gBAWF,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Signer } from 'ethers';
|
|
2
|
+
export type CreateAccountArgs = {
|
|
3
|
+
signer: Signer;
|
|
4
|
+
chainId: number;
|
|
5
|
+
ownerAddress: string;
|
|
6
|
+
};
|
|
7
|
+
export type DepositArgs = {
|
|
8
|
+
signer: Signer;
|
|
9
|
+
chainId: number;
|
|
10
|
+
accountId: number;
|
|
11
|
+
token: string;
|
|
12
|
+
amount: bigint;
|
|
13
|
+
marketId: number;
|
|
14
|
+
exchangeId: number;
|
|
15
|
+
};
|
|
16
|
+
export type WithdrawArgs = {
|
|
17
|
+
signer: Signer;
|
|
18
|
+
chainId: number;
|
|
19
|
+
accountId: number;
|
|
20
|
+
token: string;
|
|
21
|
+
amount: bigint;
|
|
22
|
+
marketId: number;
|
|
23
|
+
exchangeId: number;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["services/margin-accounts/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withdraw.d.ts","sourceRoot":"/","sources":["services/margin-accounts/withdraw.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAIvC,eAAO,MAAM,QAAQ,WAAkB,YAAY,KAAG,QAAQ,OAAO,CAkBpE,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { MethodParameters } from '../../utils/action';
|
|
2
|
+
export declare const encodeMatchOrder: (accountId: number, orderBase: bigint, orderPriceLimit: bigint, counterpartyAccountIds: number[], marketId: number, exchangeId: number) => MethodParameters;
|
|
3
|
+
//# sourceMappingURL=encode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode.d.ts","sourceRoot":"/","sources":["services/orders/encode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAe,MAAM,oBAAoB,CAAC;AAGnE,eAAO,MAAM,gBAAgB,cAChB,MAAM,aACN,MAAM,mBACA,MAAM,0BACC,MAAM,EAAE,YACtB,MAAM,cACJ,MAAM,KACjB,gBAkBF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order.d.ts","sourceRoot":"/","sources":["services/orders/order.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAIzC,eAAO,MAAM,UAAU,WAAkB,cAAc,KAAG,QAAQ,OAAO,CAmBxE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Signer } from 'ethers';
|
|
2
|
+
export type MatchOrderArgs = {
|
|
3
|
+
signer: Signer;
|
|
4
|
+
chainId: number;
|
|
5
|
+
accountId: number;
|
|
6
|
+
orderBase: bigint;
|
|
7
|
+
orderPriceLimit: bigint;
|
|
8
|
+
counterpartyAccountIds: number[];
|
|
9
|
+
marketId: number;
|
|
10
|
+
exchangeId: number;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["services/orders/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,sBAAsB,EAAE,MAAM,EAAE,CAAC;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CommandType } from './routerCommands';
|
|
2
|
+
export type MethodParameters = {
|
|
3
|
+
/**
|
|
4
|
+
* The hex encoded calldata to perform the given operation
|
|
5
|
+
*/
|
|
6
|
+
calldata: string;
|
|
7
|
+
/**
|
|
8
|
+
* The amount of ether (wei) to send in hex.
|
|
9
|
+
*/
|
|
10
|
+
value: string;
|
|
11
|
+
};
|
|
12
|
+
export type Command = {
|
|
13
|
+
commandType: CommandType;
|
|
14
|
+
inputs: string;
|
|
15
|
+
marketId: number;
|
|
16
|
+
exchangeId: number;
|
|
17
|
+
};
|
|
18
|
+
export type SingleAction = {
|
|
19
|
+
command: Command;
|
|
20
|
+
};
|
|
21
|
+
export declare class MultiAction {
|
|
22
|
+
commands: Command[];
|
|
23
|
+
constructor();
|
|
24
|
+
get length(): number;
|
|
25
|
+
newAction(singleAction: SingleAction): void;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.d.ts","sourceRoot":"/","sources":["utils/action.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,qBAAa,WAAW;IACf,QAAQ,EAAE,OAAO,EAAE,CAAC;;IAM3B,IAAW,MAAM,IAAI,MAAM,CAE1B;IAEM,SAAS,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI;CAGnD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SingleAction } from './action';
|
|
2
|
+
/**
|
|
3
|
+
* CommandTypes
|
|
4
|
+
* @description Flags that modify a command's execution
|
|
5
|
+
* @enum {number}
|
|
6
|
+
*/
|
|
7
|
+
export declare enum CommandType {
|
|
8
|
+
DEPOSIT = 0,
|
|
9
|
+
WITHDRAW = 1,
|
|
10
|
+
MATCH_ORDER = 2,
|
|
11
|
+
PROPAGATE_CACHE_FLOW = 3
|
|
12
|
+
}
|
|
13
|
+
export type RouterCommand = {
|
|
14
|
+
type: CommandType;
|
|
15
|
+
encodedInput: string;
|
|
16
|
+
marketId: number;
|
|
17
|
+
exchangeId: number;
|
|
18
|
+
};
|
|
19
|
+
export declare function createCommand(type: CommandType, parameters: unknown[], marketId: number, exchangeId: number): RouterCommand;
|
|
20
|
+
export declare function getCommand(type: CommandType, parameters: unknown[], marketId: number, exchangeId: number): SingleAction;
|
|
21
|
+
//# sourceMappingURL=routerCommands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routerCommands.d.ts","sourceRoot":"/","sources":["utils/routerCommands.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC;;;;GAIG;AACH,oBAAY,WAAW;IACrB,OAAO,IAAA;IACP,QAAQ,IAAA;IACR,WAAW,IAAA;IACX,oBAAoB,IAAA;CACrB;AASD,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,WAAW,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,aAAa,CAC3B,IAAI,EAAE,WAAW,EACjB,UAAU,EAAE,OAAO,EAAE,EACrB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,GACjB,aAAa,CAMf;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,WAAW,EACjB,UAAU,EAAE,OAAO,EAAE,EACrB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,GACjB,YAAY,CAUd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"txHelpers.d.ts","sourceRoot":"/","sources":["utils/txHelpers.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAElD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ENCODED ACTIONS
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.MultiAction = void 0;
|
|
5
|
+
var MultiAction = /** @class */ (function () {
|
|
6
|
+
function MultiAction() {
|
|
7
|
+
this.commands = [];
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(MultiAction.prototype, "length", {
|
|
10
|
+
get: function () {
|
|
11
|
+
return this.commands.length;
|
|
12
|
+
},
|
|
13
|
+
enumerable: false,
|
|
14
|
+
configurable: true
|
|
15
|
+
});
|
|
16
|
+
MultiAction.prototype.newAction = function (singleAction) {
|
|
17
|
+
this.commands.push(singleAction.command);
|
|
18
|
+
};
|
|
19
|
+
return MultiAction;
|
|
20
|
+
}());
|
|
21
|
+
exports.MultiAction = MultiAction;
|
|
22
|
+
//# sourceMappingURL=action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.js","sourceRoot":"/","sources":["utils/action.ts"],"names":[],"mappings":";AAAA,kBAAkB;;;AA0BlB;IAGE;QACE,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;IACrB,CAAC;IAED,sBAAW,+BAAM;aAAjB;YACE,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QAC9B,CAAC;;;OAAA;IAEM,+BAAS,GAAhB,UAAiB,YAA0B;QACzC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IACH,kBAAC;AAAD,CAAC,AAdD,IAcC;AAdY,kCAAW","sourcesContent":["// ENCODED ACTIONS\n\nimport { CommandType } from './routerCommands';\n\nexport type MethodParameters = {\n /**\n * The hex encoded calldata to perform the given operation\n */\n calldata: string;\n /**\n * The amount of ether (wei) to send in hex.\n */\n value: string;\n};\n\nexport type Command = {\n commandType: CommandType;\n inputs: string;\n marketId: number;\n exchangeId: number;\n};\n\nexport type SingleAction = {\n command: Command;\n};\n\nexport class MultiAction {\n public commands: Command[];\n\n constructor() {\n this.commands = [];\n }\n\n public get length(): number {\n return this.commands.length;\n }\n\n public newAction(singleAction: SingleAction): void {\n this.commands.push(singleAction.command);\n }\n}\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getCommand = exports.createCommand = exports.CommandType = void 0;
|
|
5
|
+
var ethers_1 = require("ethers");
|
|
6
|
+
/**
|
|
7
|
+
* CommandTypes
|
|
8
|
+
* @description Flags that modify a command's execution
|
|
9
|
+
* @enum {number}
|
|
10
|
+
*/
|
|
11
|
+
var CommandType;
|
|
12
|
+
(function (CommandType) {
|
|
13
|
+
CommandType[CommandType["DEPOSIT"] = 0] = "DEPOSIT";
|
|
14
|
+
CommandType[CommandType["WITHDRAW"] = 1] = "WITHDRAW";
|
|
15
|
+
CommandType[CommandType["MATCH_ORDER"] = 2] = "MATCH_ORDER";
|
|
16
|
+
CommandType[CommandType["PROPAGATE_CACHE_FLOW"] = 3] = "PROPAGATE_CACHE_FLOW";
|
|
17
|
+
})(CommandType || (exports.CommandType = CommandType = {}));
|
|
18
|
+
var ABI_DEFINITION = (_a = {},
|
|
19
|
+
_a[CommandType.DEPOSIT] = ['address', 'uint256'],
|
|
20
|
+
_a[CommandType.WITHDRAW] = ['address', 'uint256'],
|
|
21
|
+
_a[CommandType.MATCH_ORDER] = ['uint128[]', 'bytes'],
|
|
22
|
+
_a[CommandType.PROPAGATE_CACHE_FLOW] = [],
|
|
23
|
+
_a);
|
|
24
|
+
function createCommand(type, parameters, marketId, exchangeId) {
|
|
25
|
+
var encodedInput = ethers_1.AbiCoder.defaultAbiCoder().encode(ABI_DEFINITION[type], parameters);
|
|
26
|
+
return { type: type, encodedInput: encodedInput, marketId: marketId, exchangeId: exchangeId };
|
|
27
|
+
}
|
|
28
|
+
exports.createCommand = createCommand;
|
|
29
|
+
function getCommand(type, parameters, marketId, exchangeId) {
|
|
30
|
+
var command = createCommand(type, parameters, marketId, exchangeId);
|
|
31
|
+
return {
|
|
32
|
+
command: {
|
|
33
|
+
commandType: command.type,
|
|
34
|
+
inputs: command.encodedInput,
|
|
35
|
+
marketId: command.marketId,
|
|
36
|
+
exchangeId: command.exchangeId,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
exports.getCommand = getCommand;
|
|
41
|
+
//# sourceMappingURL=routerCommands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routerCommands.js","sourceRoot":"/","sources":["utils/routerCommands.ts"],"names":[],"mappings":";;;;AAAA,iCAAkC;AAGlC;;;;GAIG;AACH,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,mDAAO,CAAA;IACP,qDAAQ,CAAA;IACR,2DAAW,CAAA;IACX,6EAAoB,CAAA;AACtB,CAAC,EALW,WAAW,2BAAX,WAAW,QAKtB;AAED,IAAM,cAAc;IAClB,GAAC,WAAW,CAAC,OAAO,IAAG,CAAC,SAAS,EAAE,SAAS,CAAC;IAC7C,GAAC,WAAW,CAAC,QAAQ,IAAG,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9C,GAAC,WAAW,CAAC,WAAW,IAAG,CAAC,WAAW,EAAE,OAAO,CAAC;IACjD,GAAC,WAAW,CAAC,oBAAoB,IAAG,EAAE;OACvC,CAAC;AASF,SAAgB,aAAa,CAC3B,IAAiB,EACjB,UAAqB,EACrB,QAAgB,EAChB,UAAkB;IAElB,IAAM,YAAY,GAAG,iBAAQ,CAAC,eAAe,EAAE,CAAC,MAAM,CACpD,cAAc,CAAC,IAAI,CAAC,EACpB,UAAU,CACX,CAAC;IACF,OAAO,EAAE,IAAI,MAAA,EAAE,YAAY,cAAA,EAAE,QAAQ,UAAA,EAAE,UAAU,YAAA,EAAE,CAAC;AACtD,CAAC;AAXD,sCAWC;AAED,SAAgB,UAAU,CACxB,IAAiB,EACjB,UAAqB,EACrB,QAAgB,EAChB,UAAkB;IAElB,IAAM,OAAO,GAAG,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;IACtE,OAAO;QACL,OAAO,EAAE;YACP,WAAW,EAAE,OAAO,CAAC,IAAI;YACzB,MAAM,EAAE,OAAO,CAAC,YAAY;YAC5B,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,UAAU,EAAE,OAAO,CAAC,UAAU;SAC/B;KACF,CAAC;AACJ,CAAC;AAfD,gCAeC","sourcesContent":["import { AbiCoder } from 'ethers';\nimport { SingleAction } from './action';\n\n/**\n * CommandTypes\n * @description Flags that modify a command's execution\n * @enum {number}\n */\nexport enum CommandType {\n DEPOSIT,\n WITHDRAW,\n MATCH_ORDER,\n PROPAGATE_CACHE_FLOW,\n}\n\nconst ABI_DEFINITION: { [key in CommandType]: string[] } = {\n [CommandType.DEPOSIT]: ['address', 'uint256'],\n [CommandType.WITHDRAW]: ['address', 'uint256'],\n [CommandType.MATCH_ORDER]: ['uint128[]', 'bytes'],\n [CommandType.PROPAGATE_CACHE_FLOW]: [], // @todo Check if correct\n};\n\nexport type RouterCommand = {\n type: CommandType;\n encodedInput: string;\n marketId: number;\n exchangeId: number;\n};\n\nexport function createCommand(\n type: CommandType,\n parameters: unknown[],\n marketId: number,\n exchangeId: number,\n): RouterCommand {\n const encodedInput = AbiCoder.defaultAbiCoder().encode(\n ABI_DEFINITION[type],\n parameters,\n );\n return { type, encodedInput, marketId, exchangeId };\n}\n\nexport function getCommand(\n type: CommandType,\n parameters: unknown[],\n marketId: number,\n exchangeId: number,\n): SingleAction {\n const command = createCommand(type, parameters, marketId, exchangeId);\n return {\n command: {\n commandType: command.type,\n inputs: command.encodedInput,\n marketId: command.marketId,\n exchangeId: command.exchangeId,\n },\n };\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getGasBuffer = void 0;
|
|
4
|
+
function getGasBuffer(value) {
|
|
5
|
+
return (value * BigInt(120)) / BigInt(100);
|
|
6
|
+
}
|
|
7
|
+
exports.getGasBuffer = getGasBuffer;
|
|
8
|
+
//# sourceMappingURL=txHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"txHelpers.js","sourceRoot":"/","sources":["utils/txHelpers.ts"],"names":[],"mappings":";;;AAAA,SAAgB,YAAY,CAAC,KAAa;IACxC,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;AAC7C,CAAC;AAFD,oCAEC","sourcesContent":["export function getGasBuffer(value: bigint): bigint {\n return (value * BigInt(120)) / BigInt(100);\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@reyaxyz/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public",
|
|
6
|
+
"registry": "https://registry.npmjs.org"
|
|
7
|
+
},
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"types": "dist/types",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"files": [
|
|
12
|
+
"src/**/*.*",
|
|
13
|
+
"dist/**/*.*",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"prebuild": "rm -rf node_modules && rm -rf dist",
|
|
18
|
+
"build": "tsc -p tsconfig.build.json",
|
|
19
|
+
"ts:check-types": "npx tsc --noEmit",
|
|
20
|
+
"ts:circular-check": "dpdm --no-output --no-tree --no-warning --exit-code circular:1 -T src/index.ts",
|
|
21
|
+
"ts:check": "pnpm ts:check-types && pnpm ts:circular-check",
|
|
22
|
+
"lint:check": "eslint '{src,demo,tests}/**/*.{ts,tsx}'",
|
|
23
|
+
"prettier:check": "npx prettier --loglevel silent --check './{src,demo,tests}/**/*.{ts,tsx}'",
|
|
24
|
+
"code-quality:check": "npx concurrently 'pnpm ts:check' 'pnpm prettier:check' 'pnpm lint:check --quiet'",
|
|
25
|
+
"lint:fix": "npx eslint --fix '{src,demo,tests}/**/*.{ts,tsx}'",
|
|
26
|
+
"prettier:fix": "npx prettier --loglevel silent --write './{src,demo,tests}/**/*.{ts,tsx}'",
|
|
27
|
+
"test": "npx jest --silent",
|
|
28
|
+
"test:coverage": "jest test --coverage",
|
|
29
|
+
"generate:coverage-badges": "npx istanbul-badges-readme --silent"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"ethers": "6.9.0"
|
|
33
|
+
},
|
|
34
|
+
"packageManager": "pnpm@8.10.4",
|
|
35
|
+
"gitHead": "12b257e116bed35f8bb69fcd44e5619715228906"
|
|
36
|
+
}
|