@reyaxyz/api-sdk 0.135.0 → 0.136.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/README.md +1 -1
- package/dist/clients/modules/lottery/index.js +74 -7
- package/dist/clients/modules/lottery/index.js.map +1 -1
- package/dist/clients/modules/lottery/types.js +3 -0
- package/dist/clients/modules/lottery/types.js.map +1 -0
- package/dist/clients/types.js +1 -0
- package/dist/clients/types.js.map +1 -1
- package/dist/types/clients/modules/lottery/index.d.ts +4 -1
- package/dist/types/clients/modules/lottery/index.d.ts.map +1 -1
- package/dist/types/clients/modules/lottery/types.d.ts +16 -0
- package/dist/types/clients/modules/lottery/types.d.ts.map +1 -0
- package/dist/types/clients/types.d.ts +1 -0
- package/dist/types/clients/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/clients/modules/lottery/index.ts +76 -1
- package/src/clients/modules/lottery/types.ts +17 -0
- package/src/clients/types.ts +1 -0
package/README.md
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
|
|
7
7
|
| Statements | Branches | Functions | Lines |
|
|
8
8
|
| --------------------------- | ----------------------- | ------------------------- | ----------------- |
|
|
9
|
-
|  |  |  |  |
|
|
10
10
|
|
|
@@ -53,15 +53,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
53
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
54
|
var common_1 = require("@reyaxyz/common");
|
|
55
55
|
var constants_1 = require("./constants");
|
|
56
|
-
var
|
|
57
|
-
__extends(
|
|
58
|
-
function
|
|
56
|
+
var LotteryClient = /** @class */ (function (_super) {
|
|
57
|
+
__extends(LotteryClient, _super);
|
|
58
|
+
function LotteryClient(serviceEnvironment, host) {
|
|
59
59
|
var _this = _super.call(this, host) || this;
|
|
60
60
|
_this.serviceEnvironment = 'test';
|
|
61
61
|
_this.serviceEnvironment = serviceEnvironment;
|
|
62
62
|
return _this;
|
|
63
63
|
}
|
|
64
|
-
|
|
64
|
+
LotteryClient.prototype.getLotteryPotBalance = function () {
|
|
65
65
|
return __awaiter(this, void 0, void 0, function () {
|
|
66
66
|
var lotteryPotOwnerAddress, lotteryPotAccountId, contributionFromReya, uri, lotteryPotMarginAccountData;
|
|
67
67
|
return __generator(this, function (_a) {
|
|
@@ -79,7 +79,7 @@ var AccountClient = /** @class */ (function (_super) {
|
|
|
79
79
|
});
|
|
80
80
|
});
|
|
81
81
|
};
|
|
82
|
-
|
|
82
|
+
LotteryClient.prototype.getNumberOfLotteryTickets = function (walletAddress) {
|
|
83
83
|
return __awaiter(this, void 0, void 0, function () {
|
|
84
84
|
return __generator(this, function (_a) {
|
|
85
85
|
// todo: p1: add implementation
|
|
@@ -88,7 +88,74 @@ var AccountClient = /** @class */ (function (_super) {
|
|
|
88
88
|
});
|
|
89
89
|
});
|
|
90
90
|
};
|
|
91
|
-
|
|
91
|
+
LotteryClient.prototype.getLotteryWinners = function () {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
93
|
+
var r;
|
|
94
|
+
return __generator(this, function (_a) {
|
|
95
|
+
r = Math.random();
|
|
96
|
+
if (r < 0.5) {
|
|
97
|
+
return [2 /*return*/, {
|
|
98
|
+
winners: [
|
|
99
|
+
{
|
|
100
|
+
address: (0, common_1.convertToAddress)('0xF8F6B70a36f4398f0853a311dC6699Aba8333Cc1'),
|
|
101
|
+
amount: 70,
|
|
102
|
+
place: 1,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
address: (0, common_1.convertToAddress)('0xaE173a960084903b1d278Ff9E3A81DeD82275556'),
|
|
106
|
+
amount: 20,
|
|
107
|
+
place: 2,
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
address: (0, common_1.convertToAddress)('0x1Fe50318e5E3165742eDC9c4a15d997bDB935Eb9'),
|
|
111
|
+
amount: 10,
|
|
112
|
+
place: 3,
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
executor: {
|
|
116
|
+
address: (0, common_1.convertToAddress)('0x95222290dd7278aa3ddd389cc1e1d165cc4bafe5'),
|
|
117
|
+
timestampMs: 1728389136000,
|
|
118
|
+
},
|
|
119
|
+
}];
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
return [2 /*return*/, null];
|
|
123
|
+
}
|
|
124
|
+
return [2 /*return*/];
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
LotteryClient.prototype.selectLotteryWinners = function () {
|
|
129
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
130
|
+
return __generator(this, function (_a) {
|
|
131
|
+
// todo: this is a mock
|
|
132
|
+
return [2 /*return*/, {
|
|
133
|
+
winners: [
|
|
134
|
+
{
|
|
135
|
+
address: (0, common_1.convertToAddress)('0xF8F6B70a36f4398f0853a311dC6699Aba8333Cc1'),
|
|
136
|
+
amount: 70,
|
|
137
|
+
place: 1,
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
address: (0, common_1.convertToAddress)('0xaE173a960084903b1d278Ff9E3A81DeD82275556'),
|
|
141
|
+
amount: 20,
|
|
142
|
+
place: 2,
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
address: (0, common_1.convertToAddress)('0x1Fe50318e5E3165742eDC9c4a15d997bDB935Eb9'),
|
|
146
|
+
amount: 10,
|
|
147
|
+
place: 3,
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
executor: {
|
|
151
|
+
address: (0, common_1.convertToAddress)('0x95222290dd7278aa3ddd389cc1e1d165cc4bafe5'),
|
|
152
|
+
timestampMs: 1728389136000,
|
|
153
|
+
},
|
|
154
|
+
}];
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
return LotteryClient;
|
|
92
159
|
}(common_1.RestClient));
|
|
93
|
-
exports.default =
|
|
160
|
+
exports.default = LotteryClient;
|
|
94
161
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/lottery/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/lottery/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAKyB;AACzB,yCAA8C;AAG9C;IAA2C,iCAAU;IAEnD,uBAAY,kBAAsC,EAAE,IAAY;QAC9D,YAAA,MAAK,YAAC,IAAI,CAAC,SAAC;QAFN,wBAAkB,GAAuB,MAAM,CAAC;QAGtD,KAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;;IAC/C,CAAC;IAEK,4CAAoB,GAA1B;;;;;;wBACQ,sBAAsB,GAC1B,2BAAe,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,OAAO,CAAC;wBAC7C,mBAAmB,GACvB,2BAAe,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,eAAe,CAAC;wBACrD,oBAAoB,GAAW,KAAK,CAAC;wBAErC,GAAG,GAAG,wBAAiB,sBAAsB,4BAAkB,mBAAmB,CAAE,CAAC;wBAEzF,qBAAM,IAAI,CAAC,GAAG,CAAsB,GAAG,CAAC,EAAA;;wBADpC,2BAA2B,GAC/B,SAAwC;wBAC1C,sBAAO,2BAA2B,CAAC,YAAY,GAAG,oBAAoB,EAAC;;;;KACxE;IAEK,iDAAyB,GAA/B,UAAgC,aAAqB;;;gBACnD,+BAA+B;gBAC/B,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;gBAC3B,sBAAO,CAAC,EAAC;;;KACV;IAEK,yCAAiB,GAAvB;;;;gBAEQ,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;gBACxB,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;oBACZ,sBAAO;4BACL,OAAO,EAAE;gCACP;oCACE,OAAO,EAAE,IAAA,yBAAgB,EACvB,4CAA4C,CAC7C;oCACD,MAAM,EAAE,EAAE;oCACV,KAAK,EAAE,CAAC;iCACT;gCACD;oCACE,OAAO,EAAE,IAAA,yBAAgB,EACvB,4CAA4C,CAC7C;oCACD,MAAM,EAAE,EAAE;oCACV,KAAK,EAAE,CAAC;iCACT;gCACD;oCACE,OAAO,EAAE,IAAA,yBAAgB,EACvB,4CAA4C,CAC7C;oCACD,MAAM,EAAE,EAAE;oCACV,KAAK,EAAE,CAAC;iCACT;6BACF;4BACD,QAAQ,EAAE;gCACR,OAAO,EAAE,IAAA,yBAAgB,EACvB,4CAA4C,CAC7C;gCACD,WAAW,EAAE,aAAa;6BAC3B;yBACF,EAAC;gBACJ,CAAC;qBAAM,CAAC;oBACN,sBAAO,IAAI,EAAC;gBACd,CAAC;;;;KACF;IAEK,4CAAoB,GAA1B;;;gBACE,uBAAuB;gBACvB,sBAAO;wBACL,OAAO,EAAE;4BACP;gCACE,OAAO,EAAE,IAAA,yBAAgB,EACvB,4CAA4C,CAC7C;gCACD,MAAM,EAAE,EAAE;gCACV,KAAK,EAAE,CAAC;6BACT;4BACD;gCACE,OAAO,EAAE,IAAA,yBAAgB,EACvB,4CAA4C,CAC7C;gCACD,MAAM,EAAE,EAAE;gCACV,KAAK,EAAE,CAAC;6BACT;4BACD;gCACE,OAAO,EAAE,IAAA,yBAAgB,EACvB,4CAA4C,CAC7C;gCACD,MAAM,EAAE,EAAE;gCACV,KAAK,EAAE,CAAC;6BACT;yBACF;wBACD,QAAQ,EAAE;4BACR,OAAO,EAAE,IAAA,yBAAgB,EAAC,4CAA4C,CAAC;4BACvE,WAAW,EAAE,aAAa;yBAC3B;qBACF,EAAC;;;KACH;IACH,oBAAC;AAAD,CAAC,AAlGD,CAA2C,mBAAU,GAkGpD","sourcesContent":["import {\n RestClient,\n MarginAccountEntity,\n ServiceEnvironment,\n convertToAddress,\n} from '@reyaxyz/common';\nimport { LOTTERY_CONFIGS } from './constants';\nimport { LotteryWinnersResult } from './types';\n\nexport default class LotteryClient extends RestClient {\n private serviceEnvironment: ServiceEnvironment = 'test';\n constructor(serviceEnvironment: ServiceEnvironment, host: string) {\n super(host);\n this.serviceEnvironment = serviceEnvironment;\n }\n\n async getLotteryPotBalance(): Promise<number> {\n const lotteryPotOwnerAddress: string =\n LOTTERY_CONFIGS[this.serviceEnvironment].address;\n const lotteryPotAccountId: MarginAccountEntity['id'] =\n LOTTERY_CONFIGS[this.serviceEnvironment].marginAccountId;\n const contributionFromReya: number = 20000;\n\n const uri = `/api/accounts/${lotteryPotOwnerAddress}/marginAccount/${lotteryPotAccountId}`;\n const lotteryPotMarginAccountData: MarginAccountEntity =\n await this.get<MarginAccountEntity>(uri);\n return lotteryPotMarginAccountData.totalBalance + contributionFromReya;\n }\n\n async getNumberOfLotteryTickets(walletAddress: string): Promise<number> {\n // todo: p1: add implementation\n console.log(walletAddress);\n return 1;\n }\n\n async getLotteryWinners(): Promise<LotteryWinnersResult | null> {\n // todo: this is a mock\n const r = Math.random();\n if (r < 0.5) {\n return {\n winners: [\n {\n address: convertToAddress(\n '0xF8F6B70a36f4398f0853a311dC6699Aba8333Cc1',\n ),\n amount: 70,\n place: 1,\n },\n {\n address: convertToAddress(\n '0xaE173a960084903b1d278Ff9E3A81DeD82275556',\n ),\n amount: 20,\n place: 2,\n },\n {\n address: convertToAddress(\n '0x1Fe50318e5E3165742eDC9c4a15d997bDB935Eb9',\n ),\n amount: 10,\n place: 3,\n },\n ],\n executor: {\n address: convertToAddress(\n '0x95222290dd7278aa3ddd389cc1e1d165cc4bafe5',\n ),\n timestampMs: 1728389136000,\n },\n };\n } else {\n return null;\n }\n }\n\n async selectLotteryWinners(): Promise<LotteryWinnersResult> {\n // todo: this is a mock\n return {\n winners: [\n {\n address: convertToAddress(\n '0xF8F6B70a36f4398f0853a311dC6699Aba8333Cc1',\n ),\n amount: 70,\n place: 1,\n },\n {\n address: convertToAddress(\n '0xaE173a960084903b1d278Ff9E3A81DeD82275556',\n ),\n amount: 20,\n place: 2,\n },\n {\n address: convertToAddress(\n '0x1Fe50318e5E3165742eDC9c4a15d997bDB935Eb9',\n ),\n amount: 10,\n place: 3,\n },\n ],\n executor: {\n address: convertToAddress('0x95222290dd7278aa3ddd389cc1e1d165cc4bafe5'),\n timestampMs: 1728389136000,\n },\n };\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/lottery/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Address } from '@reyaxyz/common';\n\ntype WinnerData = {\n address: Address;\n amount: number;\n place: number;\n};\n\ntype ExecutorData = {\n address: Address;\n timestampMs: number;\n};\n\nexport type LotteryWinnersResult = {\n winners: WinnerData[];\n executor: ExecutorData;\n};\n"]}
|
package/dist/clients/types.js
CHANGED
|
@@ -46,4 +46,5 @@ __exportStar(require("./modules/depth-chart.simulation/types"), exports);
|
|
|
46
46
|
__exportStar(require("./modules/deposit-passive-pool.simulation/types"), exports);
|
|
47
47
|
__exportStar(require("./modules/isolated-order.simulation/types"), exports);
|
|
48
48
|
__exportStar(require("./modules/rage-trade/types"), exports);
|
|
49
|
+
__exportStar(require("./modules/lottery/types"), exports);
|
|
49
50
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qDAAqD;AACrD,0CA8ByB;AA5BvB,2GAAA,iBAAiB,OAAA;AAYjB,qGAAA,WAAW,OAAA;AACX,2GAAA,iBAAiB,OAAA;AAGjB,8GAAA,oBAAoB,OAAA;AACpB,yHAAA,+BAA+B,OAAA;AAE/B,oIAAA,0CAA0C,OAAA;AAG1C,6HAAA,mCAAmC,OAAA;AAEnC,uHAAA,6BAA6B,OAAA;AAG7B,8GAAA,oBAAoB,OAAA;AAEtB,0DAAwC;AACxC,qEAAmD;AACnD,qDAAmC;AACnC,0DAAwC;AACxC,yDAAuC;AACvC,mEAAiD;AACjD,wDAAsC;AACtC,iFAA+D;AAC/D,4EAA0D;AAC1D,kFAAgE;AAChE,6EAA2D;AAC3D,yEAAuD;AACvD,mFAAiE;AACjE,yFAAuE;AACvE,8EAA4D;AAC5D,+DAA6C;AAC7C,yEAAuD;AACvD,kFAAgE;AAChE,4EAA0D;AAC1D,6DAA2C","sourcesContent":["// reexporting what we want to share with integrators\nexport {\n Candle,\n CandlesResolution,\n MarketEntity,\n LpTransactionHistoryEntity,\n TradingHistoryEntity,\n PositionHistoryEntity,\n PositionEntity,\n TransactionHistoryType,\n MarginAccountTransactionHistoryType,\n MarginAccountTransactionHistoryEntity,\n MarginAccountEntity,\n LpPositionEntity,\n LpPoolEntity,\n ReyaChainId,\n MoneyInOutChainId,\n GetLpPoolPerformanceChartDataResult,\n GetLpPoolBalanceChartDataResult,\n LpBalanceGranularity,\n MarginAccountBalanceGranularity,\n GetMarginAccountBalanceChartDataResult,\n MarginAccountCollateralsBalanceGranularity,\n GetMarginAccountCollateralsBalanceChartDataResult,\n GetAllMarginAccountsBalanceChartDataResult,\n AllMarginAccountsBalanceGranularity,\n GetFundingRateChartDataResult,\n FundingRateHistoryGranularity,\n MoneyInOutConfigurationPerTokenName,\n UnifiedConditionalOrderType,\n ConditionalOrderType,\n} from '@reyaxyz/common';\nexport * from './modules/account/types';\nexport * from './modules/conditional-orders/types';\nexport * from './modules/lp/types';\nexport * from './modules/markets/types';\nexport * from './modules/tokens/types';\nexport * from './modules/trade.simulation/types';\nexport * from './modules/owner/types';\nexport * from './modules/deposit-existing-MA.simulation/types';\nexport * from './modules/deposit-new-MA.simulation/types';\nexport * from './modules/deposit-passive-pool.simulation/types';\nexport * from './modules/edit-collateral.simulation/types';\nexport * from './modules/withdraw-MA.simulation/types';\nexport * from './modules/withdraw-passive-pool.simulation/types';\nexport * from './modules/transfer-margin-between-MAs.simulation/types';\nexport * from './modules/transfer-MA-Pool.simulation/types';\nexport * from './modules/funding-rate/types';\nexport * from './modules/depth-chart.simulation/types';\nexport * from './modules/deposit-passive-pool.simulation/types';\nexport * from './modules/isolated-order.simulation/types';\nexport * from './modules/rage-trade/types';\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qDAAqD;AACrD,0CA8ByB;AA5BvB,2GAAA,iBAAiB,OAAA;AAYjB,qGAAA,WAAW,OAAA;AACX,2GAAA,iBAAiB,OAAA;AAGjB,8GAAA,oBAAoB,OAAA;AACpB,yHAAA,+BAA+B,OAAA;AAE/B,oIAAA,0CAA0C,OAAA;AAG1C,6HAAA,mCAAmC,OAAA;AAEnC,uHAAA,6BAA6B,OAAA;AAG7B,8GAAA,oBAAoB,OAAA;AAEtB,0DAAwC;AACxC,qEAAmD;AACnD,qDAAmC;AACnC,0DAAwC;AACxC,yDAAuC;AACvC,mEAAiD;AACjD,wDAAsC;AACtC,iFAA+D;AAC/D,4EAA0D;AAC1D,kFAAgE;AAChE,6EAA2D;AAC3D,yEAAuD;AACvD,mFAAiE;AACjE,yFAAuE;AACvE,8EAA4D;AAC5D,+DAA6C;AAC7C,yEAAuD;AACvD,kFAAgE;AAChE,4EAA0D;AAC1D,6DAA2C;AAC3C,0DAAwC","sourcesContent":["// reexporting what we want to share with integrators\nexport {\n Candle,\n CandlesResolution,\n MarketEntity,\n LpTransactionHistoryEntity,\n TradingHistoryEntity,\n PositionHistoryEntity,\n PositionEntity,\n TransactionHistoryType,\n MarginAccountTransactionHistoryType,\n MarginAccountTransactionHistoryEntity,\n MarginAccountEntity,\n LpPositionEntity,\n LpPoolEntity,\n ReyaChainId,\n MoneyInOutChainId,\n GetLpPoolPerformanceChartDataResult,\n GetLpPoolBalanceChartDataResult,\n LpBalanceGranularity,\n MarginAccountBalanceGranularity,\n GetMarginAccountBalanceChartDataResult,\n MarginAccountCollateralsBalanceGranularity,\n GetMarginAccountCollateralsBalanceChartDataResult,\n GetAllMarginAccountsBalanceChartDataResult,\n AllMarginAccountsBalanceGranularity,\n GetFundingRateChartDataResult,\n FundingRateHistoryGranularity,\n MoneyInOutConfigurationPerTokenName,\n UnifiedConditionalOrderType,\n ConditionalOrderType,\n} from '@reyaxyz/common';\nexport * from './modules/account/types';\nexport * from './modules/conditional-orders/types';\nexport * from './modules/lp/types';\nexport * from './modules/markets/types';\nexport * from './modules/tokens/types';\nexport * from './modules/trade.simulation/types';\nexport * from './modules/owner/types';\nexport * from './modules/deposit-existing-MA.simulation/types';\nexport * from './modules/deposit-new-MA.simulation/types';\nexport * from './modules/deposit-passive-pool.simulation/types';\nexport * from './modules/edit-collateral.simulation/types';\nexport * from './modules/withdraw-MA.simulation/types';\nexport * from './modules/withdraw-passive-pool.simulation/types';\nexport * from './modules/transfer-margin-between-MAs.simulation/types';\nexport * from './modules/transfer-MA-Pool.simulation/types';\nexport * from './modules/funding-rate/types';\nexport * from './modules/depth-chart.simulation/types';\nexport * from './modules/deposit-passive-pool.simulation/types';\nexport * from './modules/isolated-order.simulation/types';\nexport * from './modules/rage-trade/types';\nexport * from './modules/lottery/types';\n"]}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { RestClient, ServiceEnvironment } from '@reyaxyz/common';
|
|
2
|
-
|
|
2
|
+
import { LotteryWinnersResult } from './types';
|
|
3
|
+
export default class LotteryClient extends RestClient {
|
|
3
4
|
private serviceEnvironment;
|
|
4
5
|
constructor(serviceEnvironment: ServiceEnvironment, host: string);
|
|
5
6
|
getLotteryPotBalance(): Promise<number>;
|
|
6
7
|
getNumberOfLotteryTickets(walletAddress: string): Promise<number>;
|
|
8
|
+
getLotteryWinners(): Promise<LotteryWinnersResult | null>;
|
|
9
|
+
selectLotteryWinners(): Promise<LotteryWinnersResult>;
|
|
7
10
|
}
|
|
8
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/lottery/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAEV,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/lottery/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAEV,kBAAkB,EAEnB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE/C,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU;IACnD,OAAO,CAAC,kBAAkB,CAA8B;gBAC5C,kBAAkB,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM;IAK1D,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC;IAavC,yBAAyB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAMjE,iBAAiB,IAAI,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAwCzD,oBAAoB,IAAI,OAAO,CAAC,oBAAoB,CAAC;CAgC5D"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Address } from '@reyaxyz/common';
|
|
2
|
+
type WinnerData = {
|
|
3
|
+
address: Address;
|
|
4
|
+
amount: number;
|
|
5
|
+
place: number;
|
|
6
|
+
};
|
|
7
|
+
type ExecutorData = {
|
|
8
|
+
address: Address;
|
|
9
|
+
timestampMs: number;
|
|
10
|
+
};
|
|
11
|
+
export type LotteryWinnersResult = {
|
|
12
|
+
winners: WinnerData[];
|
|
13
|
+
executor: ExecutorData;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/lottery/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,KAAK,UAAU,GAAG;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,QAAQ,EAAE,YAAY,CAAC;CACxB,CAAC"}
|
|
@@ -19,4 +19,5 @@ export * from './modules/depth-chart.simulation/types';
|
|
|
19
19
|
export * from './modules/deposit-passive-pool.simulation/types';
|
|
20
20
|
export * from './modules/isolated-order.simulation/types';
|
|
21
21
|
export * from './modules/rage-trade/types';
|
|
22
|
+
export * from './modules/lottery/types';
|
|
22
23
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/types.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EACN,iBAAiB,EACjB,YAAY,EACZ,0BAA0B,EAC1B,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,EACd,sBAAsB,EACtB,mCAAmC,EACnC,qCAAqC,EACrC,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,mCAAmC,EACnC,+BAA+B,EAC/B,oBAAoB,EACpB,+BAA+B,EAC/B,sCAAsC,EACtC,0CAA0C,EAC1C,iDAAiD,EACjD,0CAA0C,EAC1C,mCAAmC,EACnC,6BAA6B,EAC7B,6BAA6B,EAC7B,mCAAmC,EACnC,2BAA2B,EAC3B,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,cAAc,yBAAyB,CAAC;AACxC,cAAc,oCAAoC,CAAC;AACnD,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC;AACtC,cAAc,gDAAgD,CAAC;AAC/D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,iDAAiD,CAAC;AAChE,cAAc,4CAA4C,CAAC;AAC3D,cAAc,wCAAwC,CAAC;AACvD,cAAc,kDAAkD,CAAC;AACjE,cAAc,wDAAwD,CAAC;AACvE,cAAc,6CAA6C,CAAC;AAC5D,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wCAAwC,CAAC;AACvD,cAAc,iDAAiD,CAAC;AAChE,cAAc,2CAA2C,CAAC;AAC1D,cAAc,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/types.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EACN,iBAAiB,EACjB,YAAY,EACZ,0BAA0B,EAC1B,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,EACd,sBAAsB,EACtB,mCAAmC,EACnC,qCAAqC,EACrC,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,mCAAmC,EACnC,+BAA+B,EAC/B,oBAAoB,EACpB,+BAA+B,EAC/B,sCAAsC,EACtC,0CAA0C,EAC1C,iDAAiD,EACjD,0CAA0C,EAC1C,mCAAmC,EACnC,6BAA6B,EAC7B,6BAA6B,EAC7B,mCAAmC,EACnC,2BAA2B,EAC3B,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,cAAc,yBAAyB,CAAC;AACxC,cAAc,oCAAoC,CAAC;AACnD,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC;AACtC,cAAc,gDAAgD,CAAC;AAC/D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,iDAAiD,CAAC;AAChE,cAAc,4CAA4C,CAAC;AAC3D,cAAc,wCAAwC,CAAC;AACvD,cAAc,kDAAkD,CAAC;AACjE,cAAc,wDAAwD,CAAC;AACvE,cAAc,6CAA6C,CAAC;AAC5D,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wCAAwC,CAAC;AACvD,cAAc,iDAAiD,CAAC;AAChE,cAAc,2CAA2C,CAAC;AAC1D,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/api-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.136.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"generate:coverage-badges": "npx istanbul-badges-readme --silent"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@reyaxyz/common": "0.208.
|
|
36
|
+
"@reyaxyz/common": "0.208.2",
|
|
37
37
|
"@simplewebauthn/types": "^10.0.0",
|
|
38
38
|
"axios": "^1.6.2",
|
|
39
39
|
"bignumber.js": "^9.1.2",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"ws": "^8.16.0"
|
|
43
43
|
},
|
|
44
44
|
"packageManager": "pnpm@8.3.1",
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "91db661046062f5b41055f9f2c36876e12cca2fb",
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/ws": "8.5.10"
|
|
48
48
|
}
|
|
@@ -2,10 +2,12 @@ import {
|
|
|
2
2
|
RestClient,
|
|
3
3
|
MarginAccountEntity,
|
|
4
4
|
ServiceEnvironment,
|
|
5
|
+
convertToAddress,
|
|
5
6
|
} from '@reyaxyz/common';
|
|
6
7
|
import { LOTTERY_CONFIGS } from './constants';
|
|
8
|
+
import { LotteryWinnersResult } from './types';
|
|
7
9
|
|
|
8
|
-
export default class
|
|
10
|
+
export default class LotteryClient extends RestClient {
|
|
9
11
|
private serviceEnvironment: ServiceEnvironment = 'test';
|
|
10
12
|
constructor(serviceEnvironment: ServiceEnvironment, host: string) {
|
|
11
13
|
super(host);
|
|
@@ -30,4 +32,77 @@ export default class AccountClient extends RestClient {
|
|
|
30
32
|
console.log(walletAddress);
|
|
31
33
|
return 1;
|
|
32
34
|
}
|
|
35
|
+
|
|
36
|
+
async getLotteryWinners(): Promise<LotteryWinnersResult | null> {
|
|
37
|
+
// todo: this is a mock
|
|
38
|
+
const r = Math.random();
|
|
39
|
+
if (r < 0.5) {
|
|
40
|
+
return {
|
|
41
|
+
winners: [
|
|
42
|
+
{
|
|
43
|
+
address: convertToAddress(
|
|
44
|
+
'0xF8F6B70a36f4398f0853a311dC6699Aba8333Cc1',
|
|
45
|
+
),
|
|
46
|
+
amount: 70,
|
|
47
|
+
place: 1,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
address: convertToAddress(
|
|
51
|
+
'0xaE173a960084903b1d278Ff9E3A81DeD82275556',
|
|
52
|
+
),
|
|
53
|
+
amount: 20,
|
|
54
|
+
place: 2,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
address: convertToAddress(
|
|
58
|
+
'0x1Fe50318e5E3165742eDC9c4a15d997bDB935Eb9',
|
|
59
|
+
),
|
|
60
|
+
amount: 10,
|
|
61
|
+
place: 3,
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
executor: {
|
|
65
|
+
address: convertToAddress(
|
|
66
|
+
'0x95222290dd7278aa3ddd389cc1e1d165cc4bafe5',
|
|
67
|
+
),
|
|
68
|
+
timestampMs: 1728389136000,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
} else {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async selectLotteryWinners(): Promise<LotteryWinnersResult> {
|
|
77
|
+
// todo: this is a mock
|
|
78
|
+
return {
|
|
79
|
+
winners: [
|
|
80
|
+
{
|
|
81
|
+
address: convertToAddress(
|
|
82
|
+
'0xF8F6B70a36f4398f0853a311dC6699Aba8333Cc1',
|
|
83
|
+
),
|
|
84
|
+
amount: 70,
|
|
85
|
+
place: 1,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
address: convertToAddress(
|
|
89
|
+
'0xaE173a960084903b1d278Ff9E3A81DeD82275556',
|
|
90
|
+
),
|
|
91
|
+
amount: 20,
|
|
92
|
+
place: 2,
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
address: convertToAddress(
|
|
96
|
+
'0x1Fe50318e5E3165742eDC9c4a15d997bDB935Eb9',
|
|
97
|
+
),
|
|
98
|
+
amount: 10,
|
|
99
|
+
place: 3,
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
executor: {
|
|
103
|
+
address: convertToAddress('0x95222290dd7278aa3ddd389cc1e1d165cc4bafe5'),
|
|
104
|
+
timestampMs: 1728389136000,
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
}
|
|
33
108
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Address } from '@reyaxyz/common';
|
|
2
|
+
|
|
3
|
+
type WinnerData = {
|
|
4
|
+
address: Address;
|
|
5
|
+
amount: number;
|
|
6
|
+
place: number;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type ExecutorData = {
|
|
10
|
+
address: Address;
|
|
11
|
+
timestampMs: number;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type LotteryWinnersResult = {
|
|
15
|
+
winners: WinnerData[];
|
|
16
|
+
executor: ExecutorData;
|
|
17
|
+
};
|
package/src/clients/types.ts
CHANGED
|
@@ -50,3 +50,4 @@ export * from './modules/depth-chart.simulation/types';
|
|
|
50
50
|
export * from './modules/deposit-passive-pool.simulation/types';
|
|
51
51
|
export * from './modules/isolated-order.simulation/types';
|
|
52
52
|
export * from './modules/rage-trade/types';
|
|
53
|
+
export * from './modules/lottery/types';
|