@sonarwatch/portfolio-plugins 0.14.126 → 0.14.127

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/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [0.14.127](https://github.com/sonarwatch/portfolio/compare/plugins-0.14.126...plugins-0.14.127) (2025-02-24)
6
+
7
+
8
+
5
9
  ## [0.14.126](https://github.com/sonarwatch/portfolio/compare/plugins-0.14.125...plugins-0.14.126) (2025-02-24)
6
10
 
7
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonarwatch/portfolio-plugins",
3
- "version": "0.14.126",
3
+ "version": "0.14.127",
4
4
  "type": "commonjs",
5
5
  "types": "./src/index.d.ts",
6
6
  "peerDependencies": {
@@ -20,3 +20,4 @@ export declare const marketsKey = "markets";
20
20
  export declare const reservesKey = "reserves";
21
21
  export declare const airdropStaticsS1: AirdropStatics;
22
22
  export declare const airdropStaticsS2: AirdropStatics;
23
+ export declare const limitOrderProgramId: PublicKey;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.airdropStaticsS2 = exports.airdropStaticsS1 = exports.reservesKey = exports.marketsKey = exports.lendingConfigs = exports.mainMarket = exports.elevationGroupsKey = exports.farmsKey = exports.farmProgramId = exports.klendProgramId = exports.allocationApiUrl = exports.programId = exports.kmnoDecimals = exports.kmnoMint = exports.platform = exports.platformId = void 0;
3
+ exports.limitOrderProgramId = exports.airdropStaticsS2 = exports.airdropStaticsS1 = exports.reservesKey = exports.marketsKey = exports.lendingConfigs = exports.mainMarket = exports.elevationGroupsKey = exports.farmsKey = exports.farmProgramId = exports.klendProgramId = exports.allocationApiUrl = exports.programId = exports.kmnoDecimals = exports.kmnoMint = exports.platform = exports.platformId = void 0;
4
4
  const web3_js_1 = require("@solana/web3.js");
5
5
  exports.platformId = 'kamino';
6
6
  exports.platform = {
@@ -155,4 +155,5 @@ exports.airdropStaticsS2 = {
155
155
  image: 'https://sonar.watch/img/platforms/kamino.webp',
156
156
  name: 'S2',
157
157
  };
158
+ exports.limitOrderProgramId = new web3_js_1.PublicKey('LiMoM9rMhrdYrfzUCxQppvxCSG1FcrUK9G8uLq4A1GF');
158
159
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kamino/constants.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAK/B,QAAA,UAAU,GAAG,QAAQ,CAAC;AACtB,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,qCAAqC,kBAAU,OAAO;IAC7D,OAAO,EAAE,yBAAyB;IAClC,WAAW,EAAE,uBAAuB;CACrC,CAAC;AAEW,QAAA,QAAQ,GAAG,6CAA6C,CAAC;AACzD,QAAA,YAAY,GAAG,CAAC,CAAC;AACjB,QAAA,SAAS,GAAG,IAAI,mBAAS,CACpC,8CAA8C,CAC/C,CAAC;AAEW,QAAA,gBAAgB,GAC3B,iDAAiD,CAAC;AAEvC,QAAA,cAAc,GAAG,IAAI,mBAAS,CACzC,6CAA6C,CAC9C,CAAC;AACW,QAAA,aAAa,GAAG,IAAI,mBAAS,CACxC,8CAA8C,CAC/C,CAAC;AACW,QAAA,QAAQ,GAAG,OAAO,CAAC;AACnB,QAAA,kBAAkB,GAAG,gBAAgB,CAAC;AACtC,QAAA,UAAU,GAAG,8CAA8C,CAAC;AAE5D,QAAA,cAAc,GAAqC,IAAI,GAAG,CAAC;IACtE;QACE,8CAA8C;QAC9C;YACE,IAAI,EAAE,aAAa;YACnB,aAAa,EAAE;gBACb;oBACE,6CAA6C;oBAC7C,6CAA6C;iBAC9C;gBACD;oBACE,8CAA8C;oBAC9C,6CA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QAAA,UAAU,GAAG,SAAS,CAAC;AACvB,QAAA,WAAW,GAAG,UAAU,CAAC;AACzB,QAAA,gBAAgB,GAAmB;IAC9C,UAAU,EAAE,aAAa;IACzB,QAAQ,EAAE,aAAa;IACvB,EAAE,EAAE,WAAW;IACf,WAAW,EAAE,QAAQ;IACrB,WAAW,EAAE,6BAA6B;IAC1C,SAAS,EAAE,oCAAoC;IAC/C,KAAK,EAAE,+CAA+C;IACtD,IAAI,EAAE,IAAI;CACX,CAAC;AACW,QAAA,gBAAgB,GAAmB;IAC9C,UAAU,EAAE,aAAa;IACzB,QAAQ,EAAE,SAAS;IACnB,EAAE,EAAE,WAAW;IACf,WAAW,EAAE,QAAQ;IACrB,WAAW,EAAE,6BAA6B;IAC1C,SAAS,EAAE,6CAA6C;IACxD,KAAK,EAAE,+CAA+C;IACtD,IAAI,EAAE,IAAI;CACX,CAAC"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kamino/constants.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAK/B,QAAA,UAAU,GAAG,QAAQ,CAAC;AACtB,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,qCAAqC,kBAAU,OAAO;IAC7D,OAAO,EAAE,yBAAyB;IAClC,WAAW,EAAE,uBAAuB;CACrC,CAAC;AAEW,QAAA,QAAQ,GAAG,6CAA6C,CAAC;AACzD,QAAA,YAAY,GAAG,CAAC,CAAC;AACjB,QAAA,SAAS,GAAG,IAAI,mBAAS,CACpC,8CAA8C,CAC/C,CAAC;AAEW,QAAA,gBAAgB,GAC3B,iDAAiD,CAAC;AAEvC,QAAA,cAAc,GAAG,IAAI,mBAAS,CACzC,6CAA6C,CAC9C,CAAC;AACW,QAAA,aAAa,GAAG,IAAI,mBAAS,CACxC,8CAA8C,CAC/C,CAAC;AACW,QAAA,QAAQ,GAAG,OAAO,CAAC;AACnB,QA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,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC;IAC7E,CAAC,8CAA8C,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC;IAC3E;QACE,8CAA8C;QAC9C;YACE,IAAI,EAAE,aAAa;YACnB,aAAa,EAAE;gBACb;oBACE,8CAA8C;oBAC9C,6CAA6C;iBAC9C;aACF;SACF;KACF;CACF,CAAC,CAAC;AAEU,QAAA,UAAU,GAAG,SAAS,CAAC;AACvB,QAAA,WAAW,GAAG,UAAU,CAAC;AACzB,QAAA,gBAAgB,GAAmB;IAC9C,UAAU,EAAE,aAAa;IACzB,QAAQ,EAAE,aAAa;IACvB,EAAE,EAAE,WAAW;IACf,WAAW,EAAE,QAAQ;IACrB,WAAW,EAAE,6BAA6B;IAC1C,SAAS,EAAE,oCAAoC;IAC/C,KAAK,EAAE,+CAA+C;IACtD,IAAI,EAAE,IAAI;CACX,CAAC;AACW,QAAA,gBAAgB,GAAmB;IAC9C,UAAU,EAAE,aAAa;IACzB,QAAQ,EAAE,SAAS;IACnB,EAAE,EAAE,WAAW;IACf,WAAW,EAAE,QAAQ;IACrB,WAAW,EAAE,6BAA6B;IAC1C,SAAS,EAAE,6CAA6C;IACxD,KAAK,EAAE,+CAA+C;IACtD,IAAI,EAAE,IAAI;CACX,CAAC;AAEW,QAAA,mBAAmB,GAAG,IAAI,mBAAS,CAC9C,6CAA6C,CAC9C,CAAC"}
@@ -12,8 +12,14 @@ const marketsJob_1 = __importDefault(require("./marketsJob"));
12
12
  const lendsFetcher_1 = __importDefault(require("./lendsFetcher"));
13
13
  const farmsFetcher_1 = __importDefault(require("./farmsFetcher"));
14
14
  const s1AirdropFetcher_1 = require("./s1AirdropFetcher");
15
+ const ordersFetcher_1 = __importDefault(require("./ordersFetcher"));
15
16
  exports.platforms = [constants_1.platform];
16
17
  exports.jobs = [poolsJob_1.default, reservesJob_1.default, farmsJob_1.default, marketsJob_1.default];
17
- exports.fetchers = [lendsFetcher_1.default, farmsFetcher_1.default, s1AirdropFetcher_1.fetcher];
18
+ exports.fetchers = [
19
+ lendsFetcher_1.default,
20
+ farmsFetcher_1.default,
21
+ s1AirdropFetcher_1.fetcher,
22
+ ordersFetcher_1.default,
23
+ ];
18
24
  exports.airdropFetchers = [s1AirdropFetcher_1.airdropFetcher];
19
25
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kamino/index.ts"],"names":[],"mappings":";;;;;;AAIA,2CAAuC;AACvC,0DAAkC;AAClC,0DAAkC;AAClC,gEAAwC;AACxC,8DAAsC;AACtC,kEAA0C;AAC1C,kEAA0C;AAC1C,yDAG4B;AAEf,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU,CAAC,kBAAQ,EAAE,qBAAW,EAAE,kBAAQ,EAAE,oBAAU,CAAC,CAAC;AAC5D,QAAA,QAAQ,GAAc,CAAC,sBAAY,EAAE,sBAAY,EAAE,0BAAS,CAAC,CAAC;AAC9D,QAAA,eAAe,GAAqB,CAAC,iCAAgB,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kamino/index.ts"],"names":[],"mappings":";;;;;;AAIA,2CAAuC;AACvC,0DAAkC;AAClC,0DAAkC;AAClC,gEAAwC;AACxC,8DAAsC;AACtC,kEAA0C;AAC1C,kEAA0C;AAC1C,yDAG4B;AAC5B,oEAA4C;AAE/B,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU,CAAC,kBAAQ,EAAE,qBAAW,EAAE,kBAAQ,EAAE,oBAAU,CAAC,CAAC;AAC5D,QAAA,QAAQ,GAAc;IACjC,sBAAY;IACZ,sBAAY;IACZ,0BAAS;IACT,uBAAa;CACd,CAAC;AACW,QAAA,eAAe,GAAqB,CAAC,iCAAgB,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Fetcher } from '../../Fetcher';
2
+ declare const fetcher: Fetcher;
3
+ export default fetcher;
@@ -0,0 +1,78 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
13
+ const constants_1 = require("./constants");
14
+ const clients_1 = require("../../utils/clients");
15
+ const solana_1 = require("../../utils/solana");
16
+ const ElementRegistry_1 = require("../../utils/elementbuilder/ElementRegistry");
17
+ const order_1 = require("./structs/order");
18
+ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
19
+ const client = (0, clients_1.getClientSolana)();
20
+ const accounts = yield (0, solana_1.getParsedProgramAccounts)(client, order_1.orderStruct, constants_1.limitOrderProgramId, [
21
+ {
22
+ memcmp: {
23
+ offset: 0,
24
+ bytes: 'PXZJQQ2HEmx',
25
+ },
26
+ },
27
+ {
28
+ memcmp: {
29
+ offset: 40,
30
+ bytes: owner,
31
+ },
32
+ },
33
+ {
34
+ dataSize: 424,
35
+ },
36
+ ]);
37
+ if (!accounts)
38
+ return [];
39
+ const elementRegistry = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.solana, constants_1.platformId);
40
+ accounts.forEach((account) => {
41
+ const element = elementRegistry.addElementTrade({
42
+ label: 'LimitOrder',
43
+ ref: account.pubkey,
44
+ });
45
+ element.setTrade({
46
+ inputAsset: {
47
+ address: account.inputMint,
48
+ amount: account.remainingInputAmount,
49
+ },
50
+ outputAsset: {
51
+ address: account.outputMint,
52
+ amount: account.filledOutputAmount,
53
+ },
54
+ initialInputAmount: account.initialInputAmount,
55
+ expectedOutputAmount: account.expectedOutputAmount,
56
+ withdrawnOutputAmount: 0,
57
+ });
58
+ if (account.tipAmount.isPositive()) {
59
+ const tipElement = elementRegistry.addElementMultiple({
60
+ label: 'Rewards',
61
+ ref: account.pubkey,
62
+ link: `https://swap.kamino.finance/swap`,
63
+ });
64
+ tipElement.addAsset({
65
+ address: portfolio_core_1.solanaNativeAddress,
66
+ amount: account.tipAmount,
67
+ });
68
+ }
69
+ });
70
+ return elementRegistry.getElements(cache);
71
+ });
72
+ const fetcher = {
73
+ id: `${constants_1.platformId}-orders`,
74
+ networkId: portfolio_core_1.NetworkId.solana,
75
+ executor,
76
+ };
77
+ exports.default = fetcher;
78
+ //# sourceMappingURL=ordersFetcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ordersFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kamino/ordersFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAA4E;AAG5E,2CAA8D;AAC9D,iDAAsD;AACtD,+CAA8D;AAC9D,gFAA6E;AAC7E,2CAA8C;AAE9C,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,MAAM,QAAQ,GAAG,MAAM,IAAA,iCAAwB,EAC7C,MAAM,EACN,mBAAW,EACX,+BAAmB,EACnB;QACE;YACE,MAAM,EAAE;gBACN,MAAM,EAAE,CAAC;gBACT,KAAK,EAAE,aAAa;aACrB;SACF;QACD;YACE,MAAM,EAAE;gBACN,MAAM,EAAE,EAAE;gBACV,KAAK,EAAE,KAAK;aACb;SACF;QACD;YACE,QAAQ,EAAE,GAAG;SACd;KACF,CACF,CAAC;IACF,IAAI,CAAC,QAAQ;Q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,kBAAe,OAAO,CAAC"}
@@ -0,0 +1,30 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="@drift-labs/sdk/node_modules/@solana/web3.js" />
3
+ /// <reference types="jito-ts/node_modules/@solana/web3.js" />
4
+ import { PublicKey } from '@solana/web3.js';
5
+ import BigNumber from 'bignumber.js';
6
+ import { BeetStruct } from '@metaplex-foundation/beet';
7
+ export type Order = {
8
+ buffer: Buffer;
9
+ globalConfig: PublicKey;
10
+ maker: PublicKey;
11
+ inputMint: PublicKey;
12
+ inputMintProgramId: PublicKey;
13
+ outputMint: PublicKey;
14
+ outputMintProgramId: PublicKey;
15
+ initialInputAmount: BigNumber;
16
+ expectedOutputAmount: BigNumber;
17
+ remainingInputAmount: BigNumber;
18
+ filledOutputAmount: BigNumber;
19
+ tipAmount: BigNumber;
20
+ numberOfFills: BigNumber;
21
+ orderType: number;
22
+ status: number;
23
+ inVaultBump: number;
24
+ flashIxLock: number;
25
+ padding0: number[];
26
+ lastUpdatedTimestamp: BigNumber;
27
+ flashStartTakerOutputBalance: BigNumber;
28
+ padding: BigNumber[];
29
+ };
30
+ export declare const orderStruct: BeetStruct<Order, Partial<Order>>;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.orderStruct = void 0;
4
+ const beet_1 = require("@metaplex-foundation/beet");
5
+ const beet_solana_1 = require("@metaplex-foundation/beet-solana");
6
+ const solana_1 = require("../../../utils/solana");
7
+ exports.orderStruct = new beet_1.BeetStruct([
8
+ ['buffer', (0, solana_1.blob)(8)],
9
+ ['globalConfig', beet_solana_1.publicKey],
10
+ ['maker', beet_solana_1.publicKey],
11
+ ['inputMint', beet_solana_1.publicKey],
12
+ ['inputMintProgramId', beet_solana_1.publicKey],
13
+ ['outputMint', beet_solana_1.publicKey],
14
+ ['outputMintProgramId', beet_solana_1.publicKey],
15
+ ['initialInputAmount', solana_1.u64],
16
+ ['expectedOutputAmount', solana_1.u64],
17
+ ['remainingInputAmount', solana_1.u64],
18
+ ['filledOutputAmount', solana_1.u64],
19
+ ['tipAmount', solana_1.u64],
20
+ ['numberOfFills', solana_1.u64],
21
+ ['orderType', beet_1.u8],
22
+ ['status', beet_1.u8],
23
+ ['inVaultBump', beet_1.u8],
24
+ ['flashIxLock', beet_1.u8],
25
+ ['padding0', (0, beet_1.uniformFixedSizeArray)(beet_1.u8, 4)],
26
+ ['lastUpdatedTimestamp', solana_1.u64],
27
+ ['flashStartTakerOutputBalance', solana_1.u64],
28
+ ['padding', (0, beet_1.uniformFixedSizeArray)(solana_1.u64, 19)],
29
+ ], (args) => args);
30
+ //# sourceMappingURL=order.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"order.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/kamino/structs/order.ts"],"names":[],"mappings":";;;AAEA,oDAImC;AACnC,kEAA6D;AAC7D,kDAAkD;AA0BrC,QAAA,WAAW,GAAG,IAAI,iBAAU,CACvC;IACE,CAAC,QAAQ,EAAE,IAAA,aAAI,EAAC,CAAC,CAAC,CAAC;IACnB,CAAC,cAAc,EAAE,uBAAS,CAAC;IAC3B,CAAC,OAAO,EAAE,uBAAS,CAAC;IACpB,CAAC,WAAW,EAAE,uBAAS,CAAC;IACxB,CAAC,oBAAoB,EAAE,uBAAS,CAAC;IACjC,CAAC,YAAY,EAAE,uBAAS,CAAC;IACzB,CAAC,qBAAqB,EAAE,uBAAS,CAAC;IAClC,CAAC,oBAAoB,EAAE,YAAG,CAAC;IAC3B,CAAC,sBAAsB,EAAE,YAAG,CAAC;IAC7B,CAAC,sBAAsB,EAAE,YAAG,CAAC;IAC7B,CAAC,oBAAoB,EAAE,YAAG,CAAC;IAC3B,CAAC,WAAW,EAAE,YAAG,CAAC;IAClB,CAAC,eAAe,EAAE,YAAG,CAAC;IACtB,CAAC,WAAW,EAAE,SAAE,CAAC;IACjB,CAAC,QAAQ,EAAE,SAAE,CAAC;IACd,CAAC,aAAa,EAAE,SAAE,CAAC;IACnB,CAAC,aAAa,EAAE,SAAE,CAAC;IACnB,CAAC,UAAU,EAAE,IAAA,4BAAqB,EAAC,SAAE,EAAE,CAAC,CAAC,CAAC;IAC1C,CAAC,sBAAsB,EAAE,YAAG,CAAC;IAC7B,CAAC,8BAA8B,EAAE,YAAG,CAAC;IACrC,CAAC,SAAS,EAAE,IAAA,4BAAqB,EAAC,YAAG,EAAE,EAAE,CAAC,CAAC;CAC5C,EACD,CAAC,IAAI,EAAE,EAAE,CAAC,IAAa,CACxB,CAAC"}
@@ -5,3 +5,4 @@ import { PublicKey } from '@solana/web3.js';
5
5
  export declare const platformId = "triad";
6
6
  export declare const platform: Platform;
7
7
  export declare const programId: PublicKey;
8
+ export declare const marketsCacheKey = "markets";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.programId = exports.platform = exports.platformId = void 0;
3
+ exports.marketsCacheKey = exports.programId = exports.platform = exports.platformId = void 0;
4
4
  const web3_js_1 = require("@solana/web3.js");
5
5
  exports.platformId = 'triad';
6
6
  exports.platform = {
@@ -11,4 +11,5 @@ exports.platform = {
11
11
  twitter: 'https://x.com/triadfi',
12
12
  };
13
13
  exports.programId = new web3_js_1.PublicKey('TRDwq3BN4mP3m9KsuNUWSN6QDff93VKGSwE95Jbr9Ss');
14
+ exports.marketsCacheKey = 'markets';
14
15
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/triad/constants.ts"],"names":[],"mappings":";;;AACA,6CAA4C;AAE/B,QAAA,UAAU,GAAG,OAAO,CAAC;AACrB,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,8CAA8C;IACrD,OAAO,EAAE,yBAAyB;IAClC,OAAO,EAAE,uBAAuB;CACjC,CAAC;AAEW,QAAA,SAAS,GAAG,IAAI,mBAAS,CACpC,6CAA6C,CAC9C,CAAC"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/triad/constants.ts"],"names":[],"mappings":";;;AACA,6CAA4C;AAE/B,QAAA,UAAU,GAAG,OAAO,CAAC;AACrB,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,8CAA8C;IACrD,OAAO,EAAE,yBAAyB;IAClC,OAAO,EAAE,uBAAuB;CACjC,CAAC;AAEW,QAAA,SAAS,GAAG,IAAI,mBAAS,CACpC,6CAA6C,CAC9C,CAAC;AAEW,QAAA,eAAe,GAAG,SAAS,CAAC"}
@@ -0,0 +1,4 @@
1
+ import BigNumber from 'bignumber.js';
2
+ import { ParsedAccount } from '../../utils/solana';
3
+ import { MarketV2, Order } from './structs';
4
+ export declare const calculatePnL: (market: ParsedAccount<MarketV2> | undefined, order: Order) => 0 | BigNumber;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.calculatePnL = void 0;
7
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
8
+ const structs_1 = require("./structs");
9
+ const calculatePnL = (market, order) => {
10
+ if (!market || order.price.isZero())
11
+ return 0;
12
+ const marketPrice = new bignumber_js_1.default(order.direction === structs_1.OrderDirection.Hype
13
+ ? market.hype_price
14
+ : market.flop_price);
15
+ const currentLiquidity = new bignumber_js_1.default(order.direction === structs_1.OrderDirection.Hype
16
+ ? market.hype_liquidity
17
+ : market.flop_liquidity).shiftedBy(-6);
18
+ const payout = order.total_shares.shiftedBy(-6).multipliedBy(marketPrice);
19
+ const impactFactor = payout.dividedBy(currentLiquidity.shiftedBy(6).plus(1));
20
+ const priceImpact = Math.min(impactFactor.multipliedBy(0.16).toNumber(), 0.5);
21
+ const takerFee = 1.042;
22
+ const orderPriceWithImpact = marketPrice
23
+ .multipliedBy(1 - priceImpact)
24
+ .dividedBy(takerFee);
25
+ return order.total_shares
26
+ .shiftedBy(-6)
27
+ .multipliedBy(orderPriceWithImpact)
28
+ .minus(order.total_amount);
29
+ };
30
+ exports.calculatePnL = calculatePnL;
31
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/triad/helpers.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AAErC,uCAA4D;AAErD,MAAM,YAAY,GAAG,CAC1B,MAA2C,EAC3C,KAAY,EACZ,EAAE;IACF,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE;QAAE,OAAO,CAAC,CAAC;IAE9C,MAAM,WAAW,GAAG,IAAI,sBAAS,CAC/B,KAAK,CAAC,SAAS,KAAK,wBAAc,CAAC,IAAI;QACrC,CAAC,CAAC,MAAM,CAAC,UAAU;QACnB,CAAC,CAAC,MAAM,CAAC,UAAU,CACtB,CAAC;IAEF,MAAM,gBAAgB,GAAG,IAAI,sBAAS,CACpC,KAAK,CAAC,SAAS,KAAK,wBAAc,CAAC,IAAI;QACrC,CAAC,CAAC,MAAM,CAAC,cAAc;QACvB,CAAC,CAAC,MAAM,CAAC,cAAc,CAC1B,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAEhB,MAAM,MAAM,GAAG,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;IAE1E,MAAM,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7E,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,GAAG,CAAC,CAAC;IAE9E,MAAM,QAAQ,GAAG,KAAK,CAAC;IAEvB,MAAM,oBAAoB,GAAG,WAAW;SACrC,YAAY,CAAC,CAAC,GAAG,WAAW,CAAC;SAC7B,SAAS,CAAC,QAAQ,CAAC,CAAC;IAEvB,OAAO,KAAK,CAAC,YAAY;SACtB,SAAS,CAAC,CAAC,CAAC,CAAC;SACb,YAAY,CAAC,oBAAoB,CAAC;SAClC,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;AAC/B,CAAC,CAAC;AAjCW,QAAA,YAAY,gBAiCvB"}
@@ -6,7 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.fetchers = exports.jobs = exports.platforms = void 0;
7
7
  const constants_1 = require("./constants");
8
8
  const stakingFetcher_1 = __importDefault(require("./stakingFetcher"));
9
+ const marketsFetcher_1 = __importDefault(require("./marketsFetcher"));
10
+ const marketsJob_1 = __importDefault(require("./marketsJob"));
9
11
  exports.platforms = [constants_1.platform];
10
- exports.jobs = [];
11
- exports.fetchers = [stakingFetcher_1.default];
12
+ exports.jobs = [marketsJob_1.default];
13
+ exports.fetchers = [stakingFetcher_1.default, marketsFetcher_1.default];
12
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/triad/index.ts"],"names":[],"mappings":";;;;;;AAGA,2CAAuC;AACvC,sEAA8C;AAEjC,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU,EAAE,CAAC;AACjB,QAAA,QAAQ,GAAc,CAAC,wBAAc,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/triad/index.ts"],"names":[],"mappings":";;;;;;AAGA,2CAAuC;AACvC,sEAA8C;AAC9C,sEAA8C;AAC9C,8DAAsC;AAEzB,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU,CAAC,oBAAU,CAAC,CAAC;AAC3B,QAAA,QAAQ,GAAc,CAAC,wBAAc,EAAE,wBAAc,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Fetcher } from '../../Fetcher';
2
+ declare const fetcher: Fetcher;
3
+ export default fetcher;
@@ -0,0 +1,108 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
13
+ const constants_1 = require("./constants");
14
+ const clients_1 = require("../../utils/clients");
15
+ const solana_1 = require("../../utils/solana");
16
+ const structs_1 = require("./structs");
17
+ const ElementRegistry_1 = require("../../utils/elementbuilder/ElementRegistry");
18
+ const MemoizedCache_1 = require("../../utils/misc/MemoizedCache");
19
+ const helpers_1 = require("./helpers");
20
+ const marketsMemo = new MemoizedCache_1.MemoizedCache(constants_1.marketsCacheKey, {
21
+ prefix: constants_1.platformId,
22
+ networkId: portfolio_core_1.NetworkId.solana,
23
+ });
24
+ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
25
+ const connection = (0, clients_1.getClientSolana)();
26
+ const accounts = yield (0, solana_1.getParsedProgramAccounts)(connection, structs_1.userTradeV2Struct, constants_1.programId, [
27
+ {
28
+ memcmp: {
29
+ bytes: 'S3hFCmKfRYh',
30
+ offset: 0,
31
+ },
32
+ },
33
+ {
34
+ memcmp: {
35
+ bytes: owner,
36
+ offset: 9,
37
+ },
38
+ },
39
+ {
40
+ dataSize: 1064,
41
+ },
42
+ ]);
43
+ if (accounts.length === 0)
44
+ return [];
45
+ const markets = yield marketsMemo.getItem(cache);
46
+ if (!markets)
47
+ throw new Error('Markets not cached');
48
+ const elementRegistry = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.solana, constants_1.platformId);
49
+ accounts.forEach((acc) => {
50
+ acc.orders.forEach((order) => {
51
+ if (order.status === structs_1.OrderStatus.Init)
52
+ return;
53
+ const market = markets.find((m) => m && m.market_id.toString() === order.market_id.toString());
54
+ if (!market)
55
+ return;
56
+ const element = elementRegistry.addElementMultiple({
57
+ label: 'Deposit',
58
+ ref: acc.pubkey,
59
+ sourceRefs: [
60
+ {
61
+ name: 'Market',
62
+ address: market.pubkey.toString(),
63
+ },
64
+ ],
65
+ link: `https://app.triadfi.co/market/${market.market_id.toString()}`,
66
+ name: `${(0, solana_1.u8ArrayToString)(market.question)} ${structs_1.OrderDirection[order.direction]}`,
67
+ });
68
+ // bet is over
69
+ if (market.winning_direction !== structs_1.WinningDirection.None) {
70
+ if ((market.winning_direction === structs_1.WinningDirection.Hype &&
71
+ order.direction === structs_1.OrderDirection.Hype) ||
72
+ (market.winning_direction === structs_1.WinningDirection.Flop &&
73
+ order.direction === structs_1.OrderDirection.Flop)) {
74
+ // win
75
+ element.addAsset({
76
+ address: market.mint,
77
+ amount: order.total_shares,
78
+ attributes: {
79
+ isClaimable: true,
80
+ },
81
+ });
82
+ }
83
+ }
84
+ else {
85
+ // bet is running
86
+ element.addAsset({
87
+ address: market.mint,
88
+ amount: order.total_amount,
89
+ });
90
+ element.addAsset({
91
+ address: market.mint,
92
+ amount: (0, helpers_1.calculatePnL)(market, order),
93
+ attributes: {
94
+ tags: ['PnL'],
95
+ },
96
+ });
97
+ }
98
+ });
99
+ });
100
+ return elementRegistry.getElements(cache);
101
+ });
102
+ const fetcher = {
103
+ id: `${constants_1.platformId}-markets`,
104
+ networkId: portfolio_core_1.NetworkId.solana,
105
+ executor,
106
+ };
107
+ exports.default = fetcher;
108
+ //# sourceMappingURL=marketsFetcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marketsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/triad/marketsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AAEvD,2CAAqE;AAErE,iDAAsD;AACtD,+CAI4B;AAC5B,uCAMmB;AACnB,gFAA6E;AAC7E,kEAA+D;AAC/D,uCAAyC;AAEzC,MAAM,WAAW,GAAG,IAAI,6BAAa,CACnC,2BAAe,EACf;IACE,MAAM,EAAE,sBAAU;IAClB,SAAS,EAAE,0BAAS,CAAC,MAAM;CAC5B,CACF,CAAC;AAEF,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,UAAU,GAAG,IAAA,yBAAe,GAAE,CAAC;IAErC,MAAM,QAAQ,GAAG,MAAM,IAAA,iCAAwB,EAC7C,UAAU,EACV,2BAAiB,EACjB,qBAAS,EACT;QACE;YACE,MAAM,EAAE;gBACN,KAAK,EAAE,aAAa;gBACpB,MAAM,EAAE,CAAC;aACV;SACF;QACD;YACE,MAAM,EAAE;gBACN,KAAK,EAAE,KAAK;gBACZ,MAAM,EAAE,CAAC;aACV;SACF;QACD;YACE,QAAQ,EAAE,IAAI;SACf;KACF,CACF,CAAC;IACF,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAErC,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACjD,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;IAEpD,MAAM,eAAe,GAAG,IAAI,iCAAe,CAAC,0BAAS,CAAC,MAAM,EAAE,sBAAU,C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,CAAC;wBACf,OAAO,EAAE,MAAM,CAAC,IAAI;wBACpB,MAAM,EAAE,KAAK,CAAC,YAAY;wBAC1B,UAAU,EAAE;4BACV,WAAW,EAAE,IAAI;yBAClB;qBACF,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,iBAAiB;gBACjB,OAAO,CAAC,QAAQ,CAAC;oBACf,OAAO,EAAE,MAAM,CAAC,IAAI;oBACpB,MAAM,EAAE,KAAK,CAAC,YAAY;iBAC3B,CAAC,CAAC;gBAEH,OAAO,CAAC,QAAQ,CAAC;oBACf,OAAO,EAAE,MAAM,CAAC,IAAI;oBACpB,MAAM,EAAE,IAAA,sBAAY,EAAC,MAAM,EAAE,KAAK,CAAC;oBACnC,UAAU,EAAE;wBACV,IAAI,EAAE,CAAC,KAAK,CAAC;qBACd;iBACF,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,UAAU;IAC3B,SAAS,EAAE,0BAAS,CAAC,MAAM;IAC3B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Job } from '../../Job';
2
+ declare const job: Job;
3
+ export default job;
@@ -0,0 +1,41 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
13
+ const constants_1 = require("./constants");
14
+ const solana_1 = require("../../utils/solana");
15
+ const clients_1 = require("../../utils/clients");
16
+ const structs_1 = require("./structs");
17
+ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
18
+ const connection = (0, clients_1.getClientSolana)();
19
+ const markets = yield (0, solana_1.getParsedProgramAccounts)(connection, structs_1.marketV2Struct, constants_1.programId, [
20
+ {
21
+ memcmp: {
22
+ bytes: '5ZDUFgFupuY',
23
+ offset: 0,
24
+ },
25
+ },
26
+ {
27
+ dataSize: 400,
28
+ },
29
+ ]);
30
+ yield cache.setItem(constants_1.marketsCacheKey, markets, {
31
+ prefix: constants_1.platformId,
32
+ networkId: portfolio_core_1.NetworkId.solana,
33
+ });
34
+ });
35
+ const job = {
36
+ id: `${constants_1.platformId}-markets`,
37
+ executor,
38
+ labels: ['normal'],
39
+ };
40
+ exports.default = job;
41
+ //# sourceMappingURL=marketsJob.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marketsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/triad/marketsJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AAGvD,2CAAqE;AACrE,+CAA8D;AAC9D,iDAAsD;AACtD,uCAA2C;AAE3C,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,UAAU,GAAG,IAAA,yBAAe,GAAE,CAAC;IAErC,MAAM,OAAO,GAAG,MAAM,IAAA,iCAAwB,EAC5C,UAAU,EACV,wBAAc,EACd,qBAAS,EACT;QACE;YACE,MAAM,EAAE;gBACN,KAAK,EAAE,aAAa;gBACpB,MAAM,EAAE,CAAC;aACV;SACF;QACD;YACE,QAAQ,EAAE,GAAG;SACd;KACF,CACF,CAAC;IAEF,MAAM,KAAK,CAAC,OAAO,CAAC,2BAAe,EAAE,OAAO,EAAE;QAC5C,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0BAAS,CAAC,MAAM;KAC5B,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AACF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,UAAU;IAC3B,QAAQ;IACR,MAAM,EAAE,CAAC,QAAQ,CAAC;CACnB,CAAC;AACF,kBAAe,GAAG,CAAC"}
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="@drift-labs/sdk/node_modules/@solana/web3.js" />
3
3
  /// <reference types="jito-ts/node_modules/@solana/web3.js" />
4
- import { FixableBeetStruct } from '@metaplex-foundation/beet';
4
+ import { BeetStruct } from '@metaplex-foundation/beet';
5
5
  import { PublicKey } from '@solana/web3.js';
6
6
  import BigNumber from 'bignumber.js';
7
7
  export type StakeV2 = {
@@ -20,4 +20,77 @@ export type StakeV2 = {
20
20
  available: BigNumber;
21
21
  amount: BigNumber;
22
22
  };
23
- export declare const stakeV2Struct: FixableBeetStruct<StakeV2, Partial<StakeV2>>;
23
+ export declare const stakeV2Struct: BeetStruct<StakeV2, Partial<StakeV2>>;
24
+ export declare enum OrderStatus {
25
+ Init = 0,
26
+ Open = 1,
27
+ Closed = 2
28
+ }
29
+ export declare enum OrderDirection {
30
+ Hype = 0,
31
+ Flop = 1
32
+ }
33
+ export declare enum OrderType {
34
+ Market = 0,
35
+ Limit = 1
36
+ }
37
+ export type Order = {
38
+ ts: BigNumber;
39
+ order_id: BigNumber;
40
+ question_id: BigNumber;
41
+ market_id: BigNumber;
42
+ status: OrderStatus;
43
+ price: BigNumber;
44
+ total_amount: BigNumber;
45
+ total_shares: BigNumber;
46
+ type: OrderType;
47
+ direction: OrderDirection;
48
+ user_nonce: BigNumber;
49
+ padding: number[];
50
+ };
51
+ export declare const orderStruct: BeetStruct<Order, Partial<Order>>;
52
+ export type UserTrade = {
53
+ buffer: Buffer;
54
+ bump: number;
55
+ authority: PublicKey;
56
+ total_deposits: BigNumber;
57
+ total_withdraws: BigNumber;
58
+ opened_orders: BigNumber;
59
+ orders: Order[];
60
+ };
61
+ export declare const userTradeV2Struct: BeetStruct<UserTrade, Partial<UserTrade>>;
62
+ export declare enum WinningDirection {
63
+ None = 0,
64
+ Hype = 1,
65
+ Flop = 2,
66
+ Draw = 3
67
+ }
68
+ export type MarketV2 = {
69
+ buffer: Buffer;
70
+ bump: number;
71
+ authority: PublicKey;
72
+ market_id: BigNumber;
73
+ hype_price: BigNumber;
74
+ flop_price: BigNumber;
75
+ hype_liquidity: BigNumber;
76
+ flop_liquidity: BigNumber;
77
+ hype_shares: BigNumber;
78
+ flop_shares: BigNumber;
79
+ volume: BigNumber;
80
+ mint: PublicKey;
81
+ update_ts: BigNumber;
82
+ opened_orders: BigNumber;
83
+ next_order_id: BigNumber;
84
+ fee_bps: BigNumber;
85
+ nft_holders_fee_available: BigNumber;
86
+ nft_holders_fee_claimed: BigNumber;
87
+ market_fee_available: BigNumber;
88
+ market_fee_claimed: BigNumber;
89
+ is_allowed_to_payout: boolean;
90
+ market_start: boolean;
91
+ market_end: boolean;
92
+ question: number[];
93
+ winning_direction: WinningDirection;
94
+ market_liquidity_at_start: BigNumber[];
95
+ };
96
+ export declare const marketV2Struct: BeetStruct<MarketV2, Partial<MarketV2>>;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.stakeV2Struct = void 0;
3
+ exports.marketV2Struct = exports.WinningDirection = exports.userTradeV2Struct = exports.orderStruct = exports.OrderType = exports.OrderDirection = exports.OrderStatus = exports.stakeV2Struct = void 0;
4
4
  const beet_1 = require("@metaplex-foundation/beet");
5
5
  const beet_solana_1 = require("@metaplex-foundation/beet-solana");
6
6
  const solana_1 = require("../../utils/solana");
7
- exports.stakeV2Struct = new beet_1.FixableBeetStruct([
7
+ exports.stakeV2Struct = new beet_1.BeetStruct([
8
8
  ['buffer', (0, solana_1.blob)(8)],
9
9
  ['bump', beet_1.u8],
10
10
  ['authority', beet_solana_1.publicKey],
@@ -20,4 +20,78 @@ exports.stakeV2Struct = new beet_1.FixableBeetStruct([
20
20
  ['available', solana_1.u64],
21
21
  ['amount', solana_1.u64],
22
22
  ], (args) => args);
23
+ var OrderStatus;
24
+ (function (OrderStatus) {
25
+ OrderStatus[OrderStatus["Init"] = 0] = "Init";
26
+ OrderStatus[OrderStatus["Open"] = 1] = "Open";
27
+ OrderStatus[OrderStatus["Closed"] = 2] = "Closed";
28
+ })(OrderStatus || (exports.OrderStatus = OrderStatus = {}));
29
+ var OrderDirection;
30
+ (function (OrderDirection) {
31
+ OrderDirection[OrderDirection["Hype"] = 0] = "Hype";
32
+ OrderDirection[OrderDirection["Flop"] = 1] = "Flop";
33
+ })(OrderDirection || (exports.OrderDirection = OrderDirection = {}));
34
+ var OrderType;
35
+ (function (OrderType) {
36
+ OrderType[OrderType["Market"] = 0] = "Market";
37
+ OrderType[OrderType["Limit"] = 1] = "Limit";
38
+ })(OrderType || (exports.OrderType = OrderType = {}));
39
+ exports.orderStruct = new beet_1.BeetStruct([
40
+ ['ts', solana_1.i64],
41
+ ['order_id', solana_1.u64],
42
+ ['question_id', solana_1.u64],
43
+ ['market_id', solana_1.u64],
44
+ ['status', beet_1.i8],
45
+ ['price', solana_1.u64],
46
+ ['total_amount', solana_1.u64],
47
+ ['total_shares', solana_1.u64],
48
+ ['type', beet_1.u8],
49
+ ['direction', beet_1.u8],
50
+ ['user_nonce', beet_1.u32],
51
+ ['padding', (0, beet_1.uniformFixedSizeArray)(beet_1.u8, 28)],
52
+ ], (args) => args);
53
+ exports.userTradeV2Struct = new beet_1.BeetStruct([
54
+ ['buffer', (0, solana_1.blob)(8)],
55
+ ['bump', beet_1.u8],
56
+ ['authority', beet_solana_1.publicKey],
57
+ ['total_deposits', solana_1.u64],
58
+ ['total_withdraws', solana_1.u64],
59
+ ['opened_orders', solana_1.u64],
60
+ ['orders', (0, beet_1.uniformFixedSizeArray)(exports.orderStruct, 10)],
61
+ ], (args) => args);
62
+ var WinningDirection;
63
+ (function (WinningDirection) {
64
+ WinningDirection[WinningDirection["None"] = 0] = "None";
65
+ WinningDirection[WinningDirection["Hype"] = 1] = "Hype";
66
+ WinningDirection[WinningDirection["Flop"] = 2] = "Flop";
67
+ WinningDirection[WinningDirection["Draw"] = 3] = "Draw";
68
+ })(WinningDirection || (exports.WinningDirection = WinningDirection = {}));
69
+ exports.marketV2Struct = new beet_1.BeetStruct([
70
+ ['buffer', (0, solana_1.blob)(8)],
71
+ ['bump', beet_1.u8],
72
+ ['authority', beet_solana_1.publicKey],
73
+ ['market_id', solana_1.u64],
74
+ ['hype_price', solana_1.u64],
75
+ ['flop_price', solana_1.u64],
76
+ ['hype_liquidity', solana_1.u64],
77
+ ['flop_liquidity', solana_1.u64],
78
+ ['hype_shares', solana_1.u64],
79
+ ['flop_shares', solana_1.u64],
80
+ ['volume', solana_1.u64],
81
+ ['mint', beet_solana_1.publicKey],
82
+ ['update_ts', solana_1.i64],
83
+ ['opened_orders', solana_1.u64],
84
+ ['next_order_id', solana_1.u64],
85
+ ['fee_bps', beet_1.u16],
86
+ ['nft_holders_fee_available', solana_1.u64],
87
+ ['nft_holders_fee_claimed', solana_1.u64],
88
+ ['market_fee_available', solana_1.u64],
89
+ ['market_fee_claimed', solana_1.u64],
90
+ ['is_allowed_to_payout', beet_1.bool],
91
+ ['market_start', solana_1.i64],
92
+ ['market_end', solana_1.i64],
93
+ ['question', (0, beet_1.uniformFixedSizeArray)(beet_1.u8, 80)],
94
+ ['winning_direction', beet_1.u8],
95
+ ['market_liquidity_at_start', solana_1.u64],
96
+ ], (args) => args);
23
97
  //# sourceMappingURL=structs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"structs.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/triad/structs.ts"],"names":[],"mappings":";;;AAAA,oDAKmC;AACnC,kEAA6D;AAG7D,+CAAoD;AAmBvC,QAAA,aAAa,GAAG,IAAI,wBAAiB,CAChD;IACE,CAAC,QAAQ,EAAE,IAAA,aAAI,EAAC,CAAC,CAAC,CAAC;IACnB,CAAC,MAAM,EAAE,SAAE,CAAC;IACZ,CAAC,WAAW,EAAE,uBAAS,CAAC;IACxB,CAAC,SAAS,EAAE,YAAG,CAAC;IAChB,CAAC,aAAa,EAAE,YAAG,CAAC;IACpB,CAAC,YAAY,EAAE,YAAG,CAAC;IACnB,CAAC,MAAM,EAAE,IAAA,4BAAqB,EAAC,SAAE,EAAE,EAAE,CAAC,CAAC;IACvC,CAAC,MAAM,EAAE,uBAAS,CAAC;IACnB,CAAC,OAAO,EAAE,WAAI,CAAC;IACf,CAAC,aAAa,EAAE,uBAAS,CAAC;IAC1B,CAAC,YAAY,EAAE,YAAG,CAAC;IACnB,CAAC,SAAS,EAAE,YAAG,CAAC;IAChB,CAAC,WAAW,EAAE,YAAG,CAAC;IAClB,CAAC,QAAQ,EAAE,YAAG,CAAC;CAChB,EACD,CAAC,IAAI,EAAE,EAAE,CAAC,IAAe,CAC1B,CAAC"}
1
+ {"version":3,"file":"structs.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/triad/structs.ts"],"names":[],"mappings":";;;AAAA,oDAQmC;AACnC,kEAA6D;AAG7D,+CAAoD;AAmBvC,QAAA,aAAa,GAAG,IAAI,iBAAU,CACzC;IACE,CAAC,QAAQ,EAAE,IAAA,aAAI,EAAC,CAAC,CAAC,CAAC;IACnB,CAAC,MAAM,EAAE,SAAE,CAAC;IACZ,CAAC,WAAW,EAAE,uBAAS,CAAC;IACxB,CAAC,SAAS,EAAE,YAAG,CAAC;IAChB,CAAC,aAAa,EAAE,YAAG,CAAC;IACpB,CAAC,YAAY,EAAE,YAAG,CAAC;IACnB,CAAC,MAAM,EAAE,IAAA,4BAAqB,EAAC,SAAE,EAAE,EAAE,CAAC,CAAC;IACvC,CAAC,MAAM,EAAE,uBAAS,CAAC;IACnB,CAAC,OAAO,EAAE,WAAI,CAA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