hedge-web3 0.2.20 → 0.2.24

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.
Files changed (57) hide show
  1. package/declarations/Constants.d.ts +15 -0
  2. package/declarations/idl/pyth.d.ts +44 -24
  3. package/declarations/idl/switchboard.d.ts +47 -0
  4. package/declarations/idl/vault.d.ts +857 -157
  5. package/declarations/index.d.ts +26 -20
  6. package/declarations/instructions/closeLiquidationPoolPosition.d.ts +2 -2
  7. package/declarations/instructions/createReferralAccount.d.ts +17 -0
  8. package/declarations/instructions/createUserReferralAccount.d.ts +5 -0
  9. package/declarations/instructions/depositLiquidationPool.d.ts +2 -2
  10. package/declarations/instructions/loanVault.d.ts +2 -2
  11. package/declarations/instructions/psmEditAccount.d.ts +12 -0
  12. package/declarations/instructions/psmMintUsh.d.ts +2 -2
  13. package/declarations/instructions/psmRedeemUsh.d.ts +2 -2
  14. package/declarations/instructions/referralClaimFees.d.ts +16 -0
  15. package/declarations/instructions/transferVault.d.ts +3 -17
  16. package/declarations/instructions/updateReferralAccount.d.ts +13 -0
  17. package/declarations/instructions/updateReferralState.d.ts +20 -0
  18. package/declarations/instructions/updateVaultType.d.ts +1 -0
  19. package/declarations/state/VaultAccount.d.ts +2 -1
  20. package/lib/Constants.js +36 -1
  21. package/lib/idl/pyth.js +44 -24
  22. package/lib/idl/switchboard.js +49 -0
  23. package/lib/idl/vault.js +850 -150
  24. package/lib/index.js +26 -20
  25. package/lib/instructions/closeLiquidationPoolPosition.js +16 -3
  26. package/lib/instructions/createReferralAccount.js +80 -0
  27. package/lib/instructions/createUserReferralAccount.js +61 -0
  28. package/lib/instructions/depositLiquidationPool.js +16 -5
  29. package/lib/instructions/loanVault.js +16 -3
  30. package/lib/instructions/psmEditAccount.js +60 -0
  31. package/lib/instructions/psmMintUsh.js +14 -3
  32. package/lib/instructions/psmRedeemUsh.js +14 -3
  33. package/lib/instructions/referralClaimFees.js +84 -0
  34. package/lib/instructions/transferVault.js +10 -24
  35. package/lib/instructions/updateReferralAccount.js +50 -0
  36. package/lib/instructions/updateReferralState.js +57 -0
  37. package/lib/instructions/updateVaultType.js +10 -9
  38. package/package.json +1 -1
  39. package/src/Constants.ts +42 -0
  40. package/src/idl/pyth.ts +88 -48
  41. package/src/idl/switchboard.ts +93 -0
  42. package/src/idl/vault.ts +1762 -362
  43. package/src/index.ts +28 -24
  44. package/src/instructions/closeLiquidationPoolPosition.ts +25 -1
  45. package/src/instructions/createReferralAccount.ts +127 -0
  46. package/src/instructions/createUserReferralAccount.ts +86 -0
  47. package/src/instructions/depositLiquidationPool.ts +24 -4
  48. package/src/instructions/loanVault.ts +20 -1
  49. package/src/instructions/{psmEditAccount.rs → psmEditAccount.ts} +0 -0
  50. package/src/instructions/psmMintUsh.ts +20 -1
  51. package/src/instructions/psmRedeemUsh.ts +20 -1
  52. package/src/instructions/referralClaimFees.ts +159 -0
  53. package/src/instructions/transferVault.ts +21 -58
  54. package/src/instructions/updateReferralAccount.ts +77 -0
  55. package/src/instructions/updateReferralState.ts +93 -0
  56. package/src/instructions/updateVaultType.ts +3 -0
  57. package/src/state/VaultAccount.ts +1 -1
@@ -14,40 +14,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.transferVaultInstruction = exports.transferVault = void 0;
16
16
  const web3_js_1 = require("@solana/web3.js");
17
- const Constants_1 = require("../Constants");
18
17
  const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
19
- function transferVault(program, provider, payer, vaultTypeAccount, oracleInfoAccount, config) {
18
+ function transferVault(program, provider, payer, vaultPublicKey, vaultSystemStatePublicKey, vaultTypeAccount, newOwner) {
20
19
  return __awaiter(this, void 0, void 0, function* () {
21
- const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
22
- const transaction = new web3_js_1.Transaction().add(yield transferVaultInstruction(program, vaultSystemStatePublicKey, payer.publicKey, vaultTypeAccount, oracleInfoAccount, config));
23
- yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer]);
24
- return vaultSystemStatePublicKey;
20
+ const history = web3_js_1.Keypair.generate();
21
+ const transaction = new web3_js_1.Transaction().add(yield transferVaultInstruction(vaultPublicKey, vaultSystemStatePublicKey, vaultTypeAccount, history.publicKey, payer.publicKey, program, newOwner));
22
+ yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer, history]);
23
+ return vaultPublicKey;
25
24
  });
26
25
  }
27
26
  exports.transferVault = transferVault;
28
- function transferVaultInstruction(program, vaultSystemStatePublicKey, payerPublicKey, vaultTypeAccount, oracleInfoAccount, vaultTypeConfig) {
29
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
27
+ function transferVaultInstruction(vaultPublickey, vaultSystemStatePublicKey, vaultTypeAccount, historyPublicKey, vaultOwner, program, newOwner) {
30
28
  return __awaiter(this, void 0, void 0, function* () {
31
- const config = {
32
- maxDebtExtended: (_a = vaultTypeConfig.maxDebtExtended) !== null && _a !== void 0 ? _a : null,
33
- minDebtPerVault: (_b = vaultTypeConfig.minDebtPerVault) !== null && _b !== void 0 ? _b : null,
34
- loanInitFee: (_c = vaultTypeConfig.loanInitFee) !== null && _c !== void 0 ? _c : null,
35
- emergencyModeThreshold: (_d = vaultTypeConfig.emergencyModeThreshold) !== null && _d !== void 0 ? _d : null,
36
- oracleChainlink: (_e = vaultTypeConfig.oracleChainlink) !== null && _e !== void 0 ? _e : null,
37
- oraclePyth: (_f = vaultTypeConfig.oraclePyth) !== null && _f !== void 0 ? _f : null,
38
- oracleSwitchboard: (_g = vaultTypeConfig.oracleSwitchboard) !== null && _g !== void 0 ? _g : null,
39
- deprecated: (_h = vaultTypeConfig.deprecated) !== null && _h !== void 0 ? _h : null,
40
- priorityPyth: (_j = vaultTypeConfig.priorityPyth) !== null && _j !== void 0 ? _j : null,
41
- priorityChainlink: (_k = vaultTypeConfig.priorityChainlink) !== null && _k !== void 0 ? _k : null,
42
- prioritySwitchboard: (_l = vaultTypeConfig.prioritySwitchboard) !== null && _l !== void 0 ? _l : null,
43
- };
44
29
  return yield program.methods
45
- .updateVaultType(config)
30
+ .transferVault(newOwner)
46
31
  .accounts({
47
- payer: payerPublicKey,
32
+ vault: vaultPublickey,
48
33
  vaultSystemState: vaultSystemStatePublicKey,
49
34
  vaultType: vaultTypeAccount,
50
- oracleInfoAccount: oracleInfoAccount,
35
+ history: historyPublicKey,
36
+ vaultOwner: vaultOwner,
51
37
  })
52
38
  .instruction();
53
39
  });
@@ -0,0 +1,50 @@
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 __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.updateReferralAccountInstruction = exports.updateReferralAccount = void 0;
16
+ const web3_js_1 = require("@solana/web3.js");
17
+ const Constants_1 = require("../Constants");
18
+ const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
19
+ function updateReferralAccount(program, provider, payer, referrer, config) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
22
+ const referralAccountPublicKey = yield (0, Constants_1.getReferralAccountPublicKey)(referrer);
23
+ const transaction = new web3_js_1.Transaction().add(yield updateReferralAccountInstruction(program, vaultSystemStatePublicKey, referralAccountPublicKey, payer.publicKey, config));
24
+ yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer]);
25
+ return referralAccountPublicKey;
26
+ });
27
+ }
28
+ exports.updateReferralAccount = updateReferralAccount;
29
+ function updateReferralAccountInstruction(program, vaultSystemStatePublicKey, referralAccountPublicKey, payerPublicKey, referralAccountConfig) {
30
+ var _a, _b, _c, _d, _e;
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ const config = {
33
+ setupCut: (_a = referralAccountConfig.setupCut) !== null && _a !== void 0 ? _a : null,
34
+ stabilityCut: (_b = referralAccountConfig.stabilityCut) !== null && _b !== void 0 ? _b : null,
35
+ referredUserDiscount: (_c = referralAccountConfig.referredUserDiscount) !== null && _c !== void 0 ? _c : null,
36
+ psmCut: (_d = referralAccountConfig.psmCut) !== null && _d !== void 0 ? _d : null,
37
+ hdgThreshold: (_e = referralAccountConfig.hdgThreshold) !== null && _e !== void 0 ? _e : null,
38
+ };
39
+ return yield program.methods
40
+ .updateReferralAccount(config)
41
+ .accounts({
42
+ signer: payerPublicKey,
43
+ vaultSystemState: vaultSystemStatePublicKey,
44
+ referralAccount: referralAccountPublicKey,
45
+ systemProgram: web3_js_1.SystemProgram.programId,
46
+ })
47
+ .instruction();
48
+ });
49
+ }
50
+ exports.updateReferralAccountInstruction = updateReferralAccountInstruction;
@@ -0,0 +1,57 @@
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 __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.updateReferralStateInstruction = exports.updateReferralState = void 0;
16
+ const web3_js_1 = require("@solana/web3.js");
17
+ const Constants_1 = require("../Constants");
18
+ const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
19
+ function updateReferralState(program, provider, payer, config) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
22
+ const referralStatePublicKey = yield (0, Constants_1.getReferralStatePublicKey)();
23
+ const transaction = new web3_js_1.Transaction().add(yield updateReferralStateInstruction(program, vaultSystemStatePublicKey, referralStatePublicKey, payer.publicKey, config));
24
+ yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer]);
25
+ return referralStatePublicKey;
26
+ });
27
+ }
28
+ exports.updateReferralState = updateReferralState;
29
+ function updateReferralStateInstruction(program, vaultSystemStatePublicKey, referralStatePublicKey, payerPublicKey, referralStateConfig) {
30
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ const config = {
33
+ setupCut: (_a = referralStateConfig.setupCut) !== null && _a !== void 0 ? _a : null,
34
+ stabilityCut: (_b = referralStateConfig.stabilityCut) !== null && _b !== void 0 ? _b : null,
35
+ referredUserDiscount: (_c = referralStateConfig.referredUserDiscount) !== null && _c !== void 0 ? _c : null,
36
+ psmCut: (_d = referralStateConfig.psmCut) !== null && _d !== void 0 ? _d : null,
37
+ maxSetupCut: (_e = referralStateConfig.maxSetupCut) !== null && _e !== void 0 ? _e : null,
38
+ maxReferredDiscount: (_f = referralStateConfig.maxReferredDiscount) !== null && _f !== void 0 ? _f : null,
39
+ maxStabilityCut: (_g = referralStateConfig.maxStabilityCut) !== null && _g !== void 0 ? _g : null,
40
+ maxPsmCut: (_h = referralStateConfig.maxPsmCut) !== null && _h !== void 0 ? _h : null,
41
+ hdgThreshold: (_j = referralStateConfig.hdgThreshold) !== null && _j !== void 0 ? _j : null,
42
+ hdgPsmThreshold: (_k = referralStateConfig.hdgPsmThreshold) !== null && _k !== void 0 ? _k : null,
43
+ referralPromoThreshold: (_l = referralStateConfig.referralThreshold) !== null && _l !== void 0 ? _l : null,
44
+ referralEnabled: (_m = referralStateConfig.referralEnabled) !== null && _m !== void 0 ? _m : null,
45
+ };
46
+ return yield program.methods
47
+ .updateReferralState(config)
48
+ .accounts({
49
+ signer: payerPublicKey,
50
+ vaultSystemState: vaultSystemStatePublicKey,
51
+ referralState: referralStatePublicKey,
52
+ systemProgram: web3_js_1.SystemProgram.programId,
53
+ })
54
+ .instruction();
55
+ });
56
+ }
57
+ exports.updateReferralStateInstruction = updateReferralStateInstruction;
@@ -26,20 +26,21 @@ function updateVaultType(program, provider, payer, vaultTypeAccount, oracleInfoA
26
26
  }
27
27
  exports.updateVaultType = updateVaultType;
28
28
  function updateVaultTypeStatusInstruction(program, vaultSystemStatePublicKey, payerPublicKey, vaultTypeAccount, oracleInfoAccount, vaultTypeConfig) {
29
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
29
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
30
30
  return __awaiter(this, void 0, void 0, function* () {
31
31
  const config = {
32
32
  maxDebtExtended: (_a = vaultTypeConfig.maxDebtExtended) !== null && _a !== void 0 ? _a : null,
33
33
  minDebtPerVault: (_b = vaultTypeConfig.minDebtPerVault) !== null && _b !== void 0 ? _b : null,
34
34
  loanInitFee: (_c = vaultTypeConfig.loanInitFee) !== null && _c !== void 0 ? _c : null,
35
- emergencyModeThreshold: (_d = vaultTypeConfig.emergencyModeThreshold) !== null && _d !== void 0 ? _d : null,
36
- oracleChainlink: (_e = vaultTypeConfig.oracleChainlink) !== null && _e !== void 0 ? _e : null,
37
- oraclePyth: (_f = vaultTypeConfig.oraclePyth) !== null && _f !== void 0 ? _f : null,
38
- oracleSwitchboard: (_g = vaultTypeConfig.oracleSwitchboard) !== null && _g !== void 0 ? _g : null,
39
- deprecated: (_h = vaultTypeConfig.deprecated) !== null && _h !== void 0 ? _h : null,
40
- priorityPyth: (_j = vaultTypeConfig.priorityPyth) !== null && _j !== void 0 ? _j : null,
41
- priorityChainlink: (_k = vaultTypeConfig.priorityChainlink) !== null && _k !== void 0 ? _k : null,
42
- prioritySwitchboard: (_l = vaultTypeConfig.prioritySwitchboard) !== null && _l !== void 0 ? _l : null,
35
+ interestRatePerSecond: (_d = vaultTypeConfig.interestRatePerSecond) !== null && _d !== void 0 ? _d : null,
36
+ emergencyModeThreshold: (_e = vaultTypeConfig.emergencyModeThreshold) !== null && _e !== void 0 ? _e : null,
37
+ oracleChainlink: (_f = vaultTypeConfig.oracleChainlink) !== null && _f !== void 0 ? _f : null,
38
+ oraclePyth: (_g = vaultTypeConfig.oraclePyth) !== null && _g !== void 0 ? _g : null,
39
+ oracleSwitchboard: (_h = vaultTypeConfig.oracleSwitchboard) !== null && _h !== void 0 ? _h : null,
40
+ deprecated: (_j = vaultTypeConfig.deprecated) !== null && _j !== void 0 ? _j : null,
41
+ priorityPyth: (_k = vaultTypeConfig.priorityPyth) !== null && _k !== void 0 ? _k : null,
42
+ priorityChainlink: (_l = vaultTypeConfig.priorityChainlink) !== null && _l !== void 0 ? _l : null,
43
+ prioritySwitchboard: (_m = vaultTypeConfig.prioritySwitchboard) !== null && _m !== void 0 ? _m : null,
43
44
  };
44
45
  return yield program.methods
45
46
  .updateVaultType(config)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hedge-web3",
3
- "version": "0.2.20",
3
+ "version": "0.2.24",
4
4
  "description": "Hedge Javascript Web3 API",
5
5
  "main": "lib/index.js",
6
6
  "types": "declarations/index.d.ts",
package/src/Constants.ts CHANGED
@@ -58,6 +58,48 @@ export async function getVaultSystemStatePublicKey(): Promise<PublicKey> {
58
58
  return publicKey
59
59
  }
60
60
 
61
+ /**
62
+ *
63
+ * @returns The Referral State public key
64
+ */
65
+ export async function getReferralStatePublicKey(): Promise<PublicKey> {
66
+ const [publicKey] = await PublicKey.findProgramAddress(
67
+ [enc.encode('ReferralStateV1')],
68
+ HEDGE_PROGRAM_PUBLICKEY
69
+ )
70
+ return publicKey
71
+ }
72
+
73
+ /**
74
+ *
75
+ * @returns The Referral State public key based off the owner's public key
76
+ */
77
+ export async function getReferralAccountPublicKey(
78
+ ownerPublicKey: PublicKey
79
+ ): Promise<PublicKey> {
80
+ const strToEncode = ownerPublicKey.toBuffer()//.substring(0, 28)
81
+ const [publicKey] = await PublicKey.findProgramAddress(
82
+ [enc.encode('refer_acct'), strToEncode],
83
+ HEDGE_PROGRAM_PUBLICKEY
84
+ )
85
+ return publicKey
86
+ }
87
+
88
+ /**
89
+ *
90
+ * @returns The user referral account public key based off the user's public key
91
+ */
92
+ export async function getUserReferralAccountPublicKey(
93
+ ownerPublicKey: PublicKey
94
+ ): Promise<PublicKey> {
95
+ const strToEncode = ownerPublicKey.toBuffer()//.substring(0, 28)
96
+ const [publicKey] = await PublicKey.findProgramAddress(
97
+ [enc.encode('user_ref'), strToEncode],
98
+ HEDGE_PROGRAM_PUBLICKEY
99
+ )
100
+ return publicKey
101
+ }
102
+
61
103
  /**
62
104
  *
63
105
  * @returns The HDG mint public key
package/src/idl/pyth.ts CHANGED
@@ -5,19 +5,9 @@ export type Pyth = {
5
5
  {
6
6
  "name": "initialize",
7
7
  "accounts": [
8
- {
9
- "name": "payer",
10
- "isMut": true,
11
- "isSigner": true
12
- },
13
8
  {
14
9
  "name": "price",
15
10
  "isMut": true,
16
- "isSigner": true
17
- },
18
- {
19
- "name": "systemProgram",
20
- "isMut": false,
21
11
  "isSigner": false
22
12
  }
23
13
  ],
@@ -53,27 +43,57 @@ export type Pyth = {
53
43
  ]
54
44
  }
55
45
  ],
56
- "accounts": [
46
+ "types": [
57
47
  {
58
- "name": "priceWrapper",
48
+ "name": "PriceStatus",
59
49
  "type": {
60
- "kind": "struct",
61
- "fields": [
50
+ "kind": "enum",
51
+ "variants": [
52
+ {
53
+ "name": "Unknown"
54
+ },
55
+ {
56
+ "name": "Trading"
57
+ },
62
58
  {
63
- "name": "price",
64
- "type": {
65
- "defined": "Price"
66
- }
59
+ "name": "Halted"
60
+ },
61
+ {
62
+ "name": "Auction"
67
63
  }
68
64
  ]
69
65
  }
70
- }
71
- ],
72
- "errors": [
66
+ },
67
+ {
68
+ "name": "CorpAction",
69
+ "type": {
70
+ "kind": "enum",
71
+ "variants": [
72
+ {
73
+ "name": "NoCorpAct"
74
+ }
75
+ ]
76
+ }
77
+ },
73
78
  {
74
- "code": 6000,
75
- "name": "InvalidTradingStatus",
76
- "msg": "invalid trading status"
79
+ "name": "PriceType",
80
+ "type": {
81
+ "kind": "enum",
82
+ "variants": [
83
+ {
84
+ "name": "Unknown"
85
+ },
86
+ {
87
+ "name": "Price"
88
+ },
89
+ {
90
+ "name": "TWAP"
91
+ },
92
+ {
93
+ "name": "Volatility"
94
+ }
95
+ ]
96
+ }
77
97
  }
78
98
  ]
79
99
  };
@@ -85,19 +105,9 @@ export const IDL: Pyth = {
85
105
  {
86
106
  "name": "initialize",
87
107
  "accounts": [
88
- {
89
- "name": "payer",
90
- "isMut": true,
91
- "isSigner": true
92
- },
93
108
  {
94
109
  "name": "price",
95
110
  "isMut": true,
96
- "isSigner": true
97
- },
98
- {
99
- "name": "systemProgram",
100
- "isMut": false,
101
111
  "isSigner": false
102
112
  }
103
113
  ],
@@ -133,27 +143,57 @@ export const IDL: Pyth = {
133
143
  ]
134
144
  }
135
145
  ],
136
- "accounts": [
146
+ "types": [
137
147
  {
138
- "name": "priceWrapper",
148
+ "name": "PriceStatus",
139
149
  "type": {
140
- "kind": "struct",
141
- "fields": [
150
+ "kind": "enum",
151
+ "variants": [
152
+ {
153
+ "name": "Unknown"
154
+ },
155
+ {
156
+ "name": "Trading"
157
+ },
142
158
  {
143
- "name": "price",
144
- "type": {
145
- "defined": "Price"
146
- }
159
+ "name": "Halted"
160
+ },
161
+ {
162
+ "name": "Auction"
147
163
  }
148
164
  ]
149
165
  }
150
- }
151
- ],
152
- "errors": [
166
+ },
167
+ {
168
+ "name": "CorpAction",
169
+ "type": {
170
+ "kind": "enum",
171
+ "variants": [
172
+ {
173
+ "name": "NoCorpAct"
174
+ }
175
+ ]
176
+ }
177
+ },
153
178
  {
154
- "code": 6000,
155
- "name": "InvalidTradingStatus",
156
- "msg": "invalid trading status"
179
+ "name": "PriceType",
180
+ "type": {
181
+ "kind": "enum",
182
+ "variants": [
183
+ {
184
+ "name": "Unknown"
185
+ },
186
+ {
187
+ "name": "Price"
188
+ },
189
+ {
190
+ "name": "TWAP"
191
+ },
192
+ {
193
+ "name": "Volatility"
194
+ }
195
+ ]
196
+ }
157
197
  }
158
198
  ]
159
199
  };
@@ -0,0 +1,93 @@
1
+ export type Switchboard = {
2
+ "version": "0.1.0",
3
+ "name": "switchboard",
4
+ "instructions": [
5
+ {
6
+ "name": "initialize",
7
+ "accounts": [
8
+ {
9
+ "name": "aggregator",
10
+ "isMut": true,
11
+ "isSigner": false
12
+ }
13
+ ],
14
+ "args": [
15
+ {
16
+ "name": "price",
17
+ "type": "u64"
18
+ },
19
+ {
20
+ "name": "scale",
21
+ "type": "u16"
22
+ }
23
+ ]
24
+ },
25
+ {
26
+ "name": "setPrice",
27
+ "accounts": [
28
+ {
29
+ "name": "aggregator",
30
+ "isMut": true,
31
+ "isSigner": false
32
+ }
33
+ ],
34
+ "args": [
35
+ {
36
+ "name": "price",
37
+ "type": "u64"
38
+ },
39
+ {
40
+ "name": "scale",
41
+ "type": "u16"
42
+ }
43
+ ]
44
+ }
45
+ ]
46
+ };
47
+
48
+ export const IDL: Switchboard = {
49
+ "version": "0.1.0",
50
+ "name": "switchboard",
51
+ "instructions": [
52
+ {
53
+ "name": "initialize",
54
+ "accounts": [
55
+ {
56
+ "name": "aggregator",
57
+ "isMut": true,
58
+ "isSigner": false
59
+ }
60
+ ],
61
+ "args": [
62
+ {
63
+ "name": "price",
64
+ "type": "u64"
65
+ },
66
+ {
67
+ "name": "scale",
68
+ "type": "u16"
69
+ }
70
+ ]
71
+ },
72
+ {
73
+ "name": "setPrice",
74
+ "accounts": [
75
+ {
76
+ "name": "aggregator",
77
+ "isMut": true,
78
+ "isSigner": false
79
+ }
80
+ ],
81
+ "args": [
82
+ {
83
+ "name": "price",
84
+ "type": "u64"
85
+ },
86
+ {
87
+ "name": "scale",
88
+ "type": "u16"
89
+ }
90
+ ]
91
+ }
92
+ ]
93
+ };