flash-sdk 11.11.4 → 11.11.5-alpha.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/dist/MarketAccount.d.ts +2 -2
- package/dist/OraclePrice.d.ts +0 -1
- package/dist/OrderAccount.d.ts +0 -1
- package/dist/PerpetualsClient.d.ts +245 -4396
- package/dist/PerpetualsClient.js +107 -187
- package/dist/PoolAccount.d.ts +0 -1
- package/dist/PoolConfig.json +6 -6
- package/dist/PoolDataClient.d.ts +0 -1
- package/dist/PositionAccount.d.ts +0 -1
- package/dist/TokenStakeAccount.d.ts +0 -1
- package/dist/TokenVaultAccount.d.ts +0 -1
- package/dist/ViewHelper.js +8 -5
- package/dist/backupOracle.js +4 -4
- package/dist/constants/index.d.ts +0 -1
- package/dist/idl/perpetuals.d.ts +26232 -13443
- package/dist/idl/perpetuals.js +0 -18151
- package/dist/idl/perpetuals.json +30940 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/generated.d.ts +2272 -0
- package/dist/types/generated.js +2 -0
- package/dist/types/index.d.ts +46 -157
- package/dist/types/index.js +35 -20
- package/dist/utils/IdlCoder.d.ts +3 -2
- package/dist/utils/IdlCoder.js +21 -9
- package/dist/utils/alt.js +5 -6
- package/dist/utils/anchorCpiEvents.d.ts +1 -2
- package/dist/utils/anchorCpiEvents.js +14 -10
- package/dist/utils/index.js +6 -6
- package/dist/utils/rpc.js +9 -9
- package/package.json +3 -2
package/dist/types/index.d.ts
CHANGED
|
@@ -1,206 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
import { MethodsNamespace, IdlTypes, IdlAccounts, BN, IdlEvents } from "@coral-xyz/anchor";
|
|
3
|
-
import { Perpetuals } from "../idl/perpetuals";
|
|
1
|
+
import { BN } from "@coral-xyz/anchor";
|
|
4
2
|
import { OraclePrice } from "../OraclePrice";
|
|
3
|
+
export * from "./generated";
|
|
4
|
+
import { Custody as GeneratedCustody, Market as GeneratedMarket, Pool as GeneratedPool, Position as GeneratedPosition, Order as GeneratedOrder, Perpetuals as GeneratedPerpetuals, Referral as GeneratedReferral, Whitelist as GeneratedWhitelist, FlpStake as GeneratedFlpStake, TokenVault as GeneratedTokenVault, TokenStake as GeneratedTokenStake, ProtocolVault as GeneratedProtocolVault } from "./generated";
|
|
5
5
|
export type PositionSide = "long" | "short";
|
|
6
|
-
export type
|
|
7
|
-
export type
|
|
8
|
-
export type
|
|
9
|
-
export type
|
|
10
|
-
export type
|
|
11
|
-
export type
|
|
12
|
-
export type
|
|
13
|
-
export type
|
|
14
|
-
export type
|
|
15
|
-
export type
|
|
16
|
-
export type
|
|
17
|
-
export type
|
|
18
|
-
export type
|
|
19
|
-
export type SetPositionPriceImpactParams = Types["SetPositionPriceImpactParams"];
|
|
20
|
-
export type AmountAndFee = Types["AmountAndFee"];
|
|
21
|
-
export type NewPositionPricesAndFee = Types["NewPositionPricesAndFee"];
|
|
22
|
-
export type PriceAndFee = Types["PriceAndFee"];
|
|
23
|
-
export type ProfitAndLoss = Types["ProfitAndLoss"];
|
|
24
|
-
export type SwapAmountAndFees = Types["SwapAmountAndFees"];
|
|
25
|
-
export type RatioFee = Types["RatioFees"];
|
|
26
|
-
export type PermissionlessPythCache = Types["PermissionlessPythCache"];
|
|
27
|
-
export type BackupOracle = Types["BackupOracle"];
|
|
28
|
-
export type MarketPermissions = Types["MarketPermissions"];
|
|
29
|
-
export type ContractOraclePrice = Types["OraclePrice"];
|
|
30
|
-
export type StakeStats = Types["StakeStats"];
|
|
31
|
-
export type CompoundingStats = Types["CompoundingStats"];
|
|
32
|
-
export type VoltageStats = Types["VoltageStats"];
|
|
33
|
-
export type LimitOrder = Types["LimitOrder"];
|
|
34
|
-
export type TriggerOrder = Types["TriggerOrder"];
|
|
35
|
-
export type Assets = Types["Assets"];
|
|
36
|
-
export type FeesStats = Types["FeesStats"];
|
|
37
|
-
export type PositionStats = Types["PositionStats"];
|
|
38
|
-
export type BorrowRateState = Types["BorrowRateState"];
|
|
39
|
-
export type TokenPermissions = Types["TokenPermissions"];
|
|
40
|
-
export type InternalPrice = Types["InternalPrice"];
|
|
41
|
-
export type InternalEmaPrice = Types["InternalEmaPrice"];
|
|
42
|
-
export type Custody = Accounts["custody"];
|
|
43
|
-
export type Market = Accounts["market"];
|
|
44
|
-
export type Pool = Accounts["pool"];
|
|
45
|
-
export type Position = Accounts["position"];
|
|
46
|
-
export type Order = Accounts["order"];
|
|
47
|
-
export type PerpetualsAccount = Accounts["perpetuals"];
|
|
48
|
-
export type Referral = Accounts["referral"];
|
|
49
|
-
export type Trading = Accounts["trading"];
|
|
50
|
-
export type Whitelist = Accounts["whitelist"];
|
|
51
|
-
export type FlpStake = Accounts["flpStake"];
|
|
52
|
-
export type TokenVault = Accounts["tokenVault"];
|
|
53
|
-
export type TokenStake = Accounts["tokenStake"];
|
|
54
|
-
export type ProtocolVault = Accounts["protocolVault"];
|
|
55
|
-
export type AddCollateralLog = Events["AddCollateralLog"];
|
|
56
|
-
export type AddLiquidityLog = Events["AddLiquidityLog"];
|
|
57
|
-
export type ClosePositionLog = Events["ClosePositionLog"];
|
|
58
|
-
export type DecreaseSizeLog = Events["DecreaseSizeLog"];
|
|
59
|
-
export type LiquidateLog = Events["LiquidateLog"];
|
|
60
|
-
export type IncreaseSizeLog = Events["IncreaseSizeLog"];
|
|
61
|
-
export type OpenPositionLog = Events["OpenPositionLog"];
|
|
62
|
-
export type RemoveCollateralLog = Events["RemoveCollateralLog"];
|
|
63
|
-
export type RemoveLiquidityLog = Events["RemoveLiquidityLog"];
|
|
64
|
-
export type SwapLog = Events["SwapLog"];
|
|
65
|
-
export type AddCollateralLogV2 = Events["AddCollateralLogV2"];
|
|
66
|
-
export type ClosePositionLogV2 = Events["ClosePositionLogV2"];
|
|
67
|
-
export type DecreaseSizeLogV2 = Events["DecreaseSizeLogV2"];
|
|
68
|
-
export type LiquidateLogV2 = Events["LiquidateLogV2"];
|
|
69
|
-
export type IncreaseSizeLogV2 = Events["IncreaseSizeLogV2"];
|
|
70
|
-
export type OpenPositionLogV2 = Events["OpenPositionLogV2"];
|
|
71
|
-
export type RemoveCollateralLogV2 = Events["RemoveCollateralLogV2"];
|
|
72
|
-
export type AddCollateralLogV3 = Events["AddCollateralLogV3"];
|
|
73
|
-
export type ClosePositionLogV3 = Events["ClosePositionLogV3"];
|
|
74
|
-
export type DecreaseSizeLogV3 = Events["DecreaseSizeLogV3"];
|
|
75
|
-
export type LiquidateLogV3 = Events["LiquidateLogV3"];
|
|
76
|
-
export type IncreaseSizeLogV3 = Events["IncreaseSizeLogV3"];
|
|
77
|
-
export type OpenPositionLogV3 = Events["OpenPositionLogV3"];
|
|
78
|
-
export type RemoveCollateralLogV3 = Events["RemoveCollateralLogV3"];
|
|
79
|
-
export type IncreaseSizeLogV4 = Events["IncreaseSizeLogV4"];
|
|
80
|
-
export type OpenPositionLogV4 = Events["OpenPositionLogV4"];
|
|
81
|
-
export type ExecuteLimitOrderLogV2 = Events["ExecuteLimitOrderLogV2"];
|
|
82
|
-
export type ExecuteLimitWithSwapLogV2 = Events["ExecuteLimitWithSwapLogV2"];
|
|
83
|
-
export type SwapAndOpenLogV2 = Events["SwapAndOpenLogV2"];
|
|
84
|
-
export type AddLiquidityLogV2 = Events["AddLiquidityLogV2"];
|
|
85
|
-
export type RemoveLiquidityLogV2 = Events["RemoveLiquidityLogV2"];
|
|
86
|
-
export type AddCompoundingLiquidityLog = Events["AddCompoundingLiquidityLog"];
|
|
87
|
-
export type AddLiquidityAndStakeLog = Events["AddLiquidityAndStakeLog"];
|
|
88
|
-
export type DepositStakeLog = Events["DepositStakeLog"];
|
|
89
|
-
export type MigrateStakeLog = Events["MigrateStakeLog"];
|
|
90
|
-
export type RefreshStakeLog = Events["RefreshStakeLog"];
|
|
91
|
-
export type RefreshStakeUserLog = Events["RefreshStakeUserLog"];
|
|
92
|
-
export type CompoundingFeesLog = Events["CompoundingFeesLog"];
|
|
93
|
-
export type RemoveCompoundingLiquidityLog = Events["RemoveCompoundingLiquidityLog"];
|
|
94
|
-
export type SwapFeeInternalLog = Events["SwapFeeInternalLog"];
|
|
95
|
-
export type UnstakeInstantLog = Events["UnstakeInstantLog"];
|
|
96
|
-
export type UnstakeRequestLog = Events["UnstakeRequestLog"];
|
|
97
|
-
export type WithdrawStakeLog = Events["WithdrawStakeLog"];
|
|
98
|
-
export type EditLimitOrderLog = Events["EditLimitOrderLog"];
|
|
99
|
-
export type EditTriggerOrderLog = Events["EditTriggerOrderLog"];
|
|
100
|
-
export type ExecuteLimitOrderLog = Events["ExecuteLimitOrderLog"];
|
|
101
|
-
export type ExecuteTriggerOrderLog = Events["ExecuteTriggerOrderLog"];
|
|
102
|
-
export type PlaceLimitOrderLog = Events["PlaceLimitOrderLog"];
|
|
103
|
-
export type PlaceTriggerOrderLog = Events["PlaceTriggerOrderLog"];
|
|
104
|
-
export type CancelLimitOrderLog = Events["CancelLimitOrderLog"];
|
|
105
|
-
export type CancelTriggerOrderLog = Events["CancelTriggerOrderLog"];
|
|
106
|
-
export type ExecuteLimitWithSwapLog = Events["ExecuteLimitWithSwapLog"];
|
|
107
|
-
export type ExecuteTriggerWithSwapLog = Events["ExecuteTriggerWithSwapLog"];
|
|
108
|
-
export type SwapAndOpenLog = Events["SwapAndOpenLog"];
|
|
109
|
-
export type CloseAndSwapLog = Events["CloseAndSwapLog"];
|
|
110
|
-
export type SwapAndAddCollateralLog = Events["SwapAndAddCollateralLog"];
|
|
111
|
-
export type RemoveCollateralAndSwapLog = Events["RemoveCollateralAndSwapLog"];
|
|
112
|
-
export type CancelUnstakeTokenRequestLog = Events["CancelUnstakeTokenRequestLog"];
|
|
113
|
-
export type DepositTokenStakeLog = Events["DepositTokenStakeLog"];
|
|
114
|
-
export type UnstakeTokenInstantLog = Events["UnstakeTokenInstantLog"];
|
|
115
|
-
export type UnstakeTokenRequestLog = Events["UnstakeTokenRequestLog"];
|
|
116
|
-
export type WithdrawTokenLog = Events["WithdrawTokenLog"];
|
|
117
|
-
export type DistributeTokenRewardLog = Events["DistributeTokenRewardLog"];
|
|
118
|
-
export type SetTokenRewardLog = Events["SetTokenRewardLog"];
|
|
119
|
-
export type CollectTokenRewardLog = Events["CollectTokenRewardLog"];
|
|
120
|
-
export type CollectRevenueLog = Events["CollectRevenueLog"];
|
|
121
|
-
export type MoveProtocolFeesLog = Events["MoveProtocolFeesLog"];
|
|
122
|
-
export type AddCollateralLogUSDv1 = Events["AddCollateralLogUSDv1"];
|
|
123
|
-
export type CloseAndSwapLogUSDv1 = Events["CloseAndSwapLogUSDv1"];
|
|
124
|
-
export type ClosePositionLogUSDv1 = Events["ClosePositionLogUSDv1"];
|
|
125
|
-
export type DecreaseSizeLogUSDv1 = Events["DecreaseSizeLogUSDv1"];
|
|
126
|
-
export type ExecuteLimitOrderLogUSDv1 = Events["ExecuteLimitOrderLogUSDv1"];
|
|
127
|
-
export type ExecuteLimitWithSwapLogUSDv1 = Events["ExecuteLimitWithSwapLogUSDv1"];
|
|
128
|
-
export type ExecuteTriggerOrderLogUSDv1 = Events["ExecuteTriggerOrderLogUSDv1"];
|
|
129
|
-
export type ExecuteTriggerWithSwapLogUSDv1 = Events["ExecuteTriggerWithSwapLogUSDv1"];
|
|
130
|
-
export type IncreaseSizeLogUSDv1 = Events["IncreaseSizeLogUSDv1"];
|
|
131
|
-
export type LiquidateLogUSDv1 = Events["LiquidateLogUSDv1"];
|
|
132
|
-
export type OpenPositionLogUSDv1 = Events["OpenPositionLogUSDv1"];
|
|
133
|
-
export type RemoveCollateralAndSwapLogUSDv1 = Events["RemoveCollateralAndSwapLogUSDv1"];
|
|
134
|
-
export type RemoveCollateralLogUSDv1 = Events["RemoveCollateralLogUSDv1"];
|
|
135
|
-
export type SwapAndAddCollateralLogUSDv1 = Events["SwapAndAddCollateralLogUSDv1"];
|
|
136
|
-
export type SwapAndOpenLogUSDv1 = Events["SwapAndOpenLogUSDv1"];
|
|
137
|
-
export type MigratePositionLog = Events["MigratePositionLog"];
|
|
138
|
-
export type SwapFeeInternalLogV3 = Events["SwapFeeInternalLogV3"];
|
|
139
|
-
export type SettleRebatesLog = Events["SettleRebatesLog"];
|
|
140
|
-
export type CollectRebateLog = Events["CollectRebateLog"];
|
|
141
|
-
export type VoltagePointsLog = Events["VoltagePointsLog"];
|
|
142
|
-
export type ReferralRebateLog = Events["ReferralRebateLog"];
|
|
6
|
+
export type Custody = GeneratedCustody;
|
|
7
|
+
export type Market = GeneratedMarket;
|
|
8
|
+
export type Pool = GeneratedPool;
|
|
9
|
+
export type Position = GeneratedPosition;
|
|
10
|
+
export type Order = GeneratedOrder;
|
|
11
|
+
export type PerpetualsAccount = GeneratedPerpetuals;
|
|
12
|
+
export type Referral = GeneratedReferral;
|
|
13
|
+
export type Whitelist = GeneratedWhitelist;
|
|
14
|
+
export type Trading = Record<string, never>;
|
|
15
|
+
export type FlpStake = GeneratedFlpStake;
|
|
16
|
+
export type TokenVault = GeneratedTokenVault;
|
|
17
|
+
export type TokenStake = GeneratedTokenStake;
|
|
18
|
+
export type ProtocolVault = GeneratedProtocolVault;
|
|
143
19
|
export declare function isVariant(object: any, type: string): any;
|
|
144
20
|
export declare function isOneOfVariant(object: any, types: string[]): any;
|
|
145
21
|
export declare class Privilege {
|
|
146
22
|
static None: {
|
|
147
|
-
none:
|
|
23
|
+
none: any;
|
|
148
24
|
};
|
|
149
25
|
static Stake: {
|
|
150
|
-
stake:
|
|
26
|
+
stake: any;
|
|
151
27
|
};
|
|
152
28
|
static Referral: {
|
|
153
|
-
referral:
|
|
29
|
+
referral: any;
|
|
154
30
|
};
|
|
155
31
|
}
|
|
156
32
|
export declare class Side {
|
|
157
33
|
static None: {
|
|
158
|
-
none:
|
|
34
|
+
none: any;
|
|
159
35
|
};
|
|
160
36
|
static Long: {
|
|
161
|
-
long:
|
|
37
|
+
long: any;
|
|
162
38
|
};
|
|
163
39
|
static Short: {
|
|
164
|
-
short:
|
|
40
|
+
short: any;
|
|
165
41
|
};
|
|
166
42
|
}
|
|
167
43
|
export declare class OracleType {
|
|
168
44
|
static None: {
|
|
169
|
-
none:
|
|
45
|
+
none: any;
|
|
170
46
|
};
|
|
171
47
|
static Test: {
|
|
172
|
-
test:
|
|
48
|
+
test: any;
|
|
173
49
|
};
|
|
174
50
|
static Pyth: {
|
|
175
|
-
pyth:
|
|
51
|
+
pyth: any;
|
|
176
52
|
};
|
|
177
53
|
}
|
|
178
54
|
export declare class FeesMode {
|
|
179
55
|
static Fixed: {
|
|
180
|
-
fixed:
|
|
56
|
+
fixed: any;
|
|
181
57
|
};
|
|
182
58
|
static Linear: {
|
|
183
|
-
linear:
|
|
59
|
+
linear: any;
|
|
184
60
|
};
|
|
185
61
|
}
|
|
186
62
|
export declare class FeesAction {
|
|
187
63
|
static AddLiquidity: {
|
|
188
|
-
addLiquidity:
|
|
64
|
+
addLiquidity: any;
|
|
189
65
|
};
|
|
190
66
|
static RemoveLiquidity: {
|
|
191
|
-
removeLiquidity:
|
|
67
|
+
removeLiquidity: any;
|
|
192
68
|
};
|
|
193
69
|
static SwapIn: {
|
|
194
|
-
swapIn:
|
|
70
|
+
swapIn: any;
|
|
195
71
|
};
|
|
196
72
|
static SwapOut: {
|
|
197
|
-
swapOut:
|
|
73
|
+
swapOut: any;
|
|
198
74
|
};
|
|
199
75
|
static StableSwapIn: {
|
|
200
|
-
stableSwapIn:
|
|
76
|
+
stableSwapIn: any;
|
|
201
77
|
};
|
|
202
78
|
static StableSwapOut: {
|
|
203
|
-
stableSwapOut:
|
|
79
|
+
stableSwapOut: any;
|
|
204
80
|
};
|
|
205
81
|
}
|
|
206
82
|
export declare const DEFAULT_POSITION: Position;
|
|
@@ -256,3 +132,16 @@ export interface RemoveLiquidityAmountAndFee {
|
|
|
256
132
|
tokenAmountOut: BN;
|
|
257
133
|
fee: BN;
|
|
258
134
|
}
|
|
135
|
+
import { RatioFees } from "./generated";
|
|
136
|
+
export type RatioFee = RatioFees;
|
|
137
|
+
export interface BackupOracle {
|
|
138
|
+
price: BN;
|
|
139
|
+
expo: number;
|
|
140
|
+
conf: BN;
|
|
141
|
+
emaPrice: BN;
|
|
142
|
+
publishTime: BN;
|
|
143
|
+
}
|
|
144
|
+
export interface PermissionlessPythCache {
|
|
145
|
+
backupCache: BackupOracle[];
|
|
146
|
+
}
|
|
147
|
+
export type VoltageStats = Record<string, never>;
|
package/dist/types/index.js
CHANGED
|
@@ -1,62 +1,77 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_POSITION = exports.FeesAction = exports.FeesMode = exports.OracleType = exports.Side = exports.Privilege =
|
|
17
|
+
exports.DEFAULT_POSITION = exports.FeesAction = exports.FeesMode = exports.OracleType = exports.Side = exports.Privilege = void 0;
|
|
18
|
+
exports.isVariant = isVariant;
|
|
19
|
+
exports.isOneOfVariant = isOneOfVariant;
|
|
4
20
|
var web3_js_1 = require("@solana/web3.js");
|
|
5
21
|
var constants_1 = require("../constants");
|
|
22
|
+
__exportStar(require("./generated"), exports);
|
|
6
23
|
function isVariant(object, type) {
|
|
7
24
|
return object.hasOwnProperty(type);
|
|
8
25
|
}
|
|
9
|
-
exports.isVariant = isVariant;
|
|
10
26
|
function isOneOfVariant(object, types) {
|
|
11
27
|
return types.reduce(function (result, type) {
|
|
12
28
|
return result || object.hasOwnProperty(type);
|
|
13
29
|
}, false);
|
|
14
30
|
}
|
|
15
|
-
exports.isOneOfVariant = isOneOfVariant;
|
|
16
31
|
var Privilege = (function () {
|
|
17
32
|
function Privilege() {
|
|
18
33
|
}
|
|
19
|
-
Privilege.None = { none:
|
|
20
|
-
Privilege.Stake = { stake:
|
|
21
|
-
Privilege.Referral = { referral:
|
|
34
|
+
Privilege.None = { none: undefined };
|
|
35
|
+
Privilege.Stake = { stake: undefined };
|
|
36
|
+
Privilege.Referral = { referral: undefined };
|
|
22
37
|
return Privilege;
|
|
23
38
|
}());
|
|
24
39
|
exports.Privilege = Privilege;
|
|
25
40
|
var Side = (function () {
|
|
26
41
|
function Side() {
|
|
27
42
|
}
|
|
28
|
-
Side.None = { none:
|
|
29
|
-
Side.Long = { long:
|
|
30
|
-
Side.Short = { short:
|
|
43
|
+
Side.None = { none: undefined };
|
|
44
|
+
Side.Long = { long: undefined };
|
|
45
|
+
Side.Short = { short: undefined };
|
|
31
46
|
return Side;
|
|
32
47
|
}());
|
|
33
48
|
exports.Side = Side;
|
|
34
49
|
var OracleType = (function () {
|
|
35
50
|
function OracleType() {
|
|
36
51
|
}
|
|
37
|
-
OracleType.None = { none:
|
|
38
|
-
OracleType.Test = { test:
|
|
39
|
-
OracleType.Pyth = { pyth:
|
|
52
|
+
OracleType.None = { none: undefined };
|
|
53
|
+
OracleType.Test = { test: undefined };
|
|
54
|
+
OracleType.Pyth = { pyth: undefined };
|
|
40
55
|
return OracleType;
|
|
41
56
|
}());
|
|
42
57
|
exports.OracleType = OracleType;
|
|
43
58
|
var FeesMode = (function () {
|
|
44
59
|
function FeesMode() {
|
|
45
60
|
}
|
|
46
|
-
FeesMode.Fixed = { fixed:
|
|
47
|
-
FeesMode.Linear = { linear:
|
|
61
|
+
FeesMode.Fixed = { fixed: undefined };
|
|
62
|
+
FeesMode.Linear = { linear: undefined };
|
|
48
63
|
return FeesMode;
|
|
49
64
|
}());
|
|
50
65
|
exports.FeesMode = FeesMode;
|
|
51
66
|
var FeesAction = (function () {
|
|
52
67
|
function FeesAction() {
|
|
53
68
|
}
|
|
54
|
-
FeesAction.AddLiquidity = { addLiquidity:
|
|
55
|
-
FeesAction.RemoveLiquidity = { removeLiquidity:
|
|
56
|
-
FeesAction.SwapIn = { swapIn:
|
|
57
|
-
FeesAction.SwapOut = { swapOut:
|
|
58
|
-
FeesAction.StableSwapIn = { stableSwapIn:
|
|
59
|
-
FeesAction.StableSwapOut = { stableSwapOut:
|
|
69
|
+
FeesAction.AddLiquidity = { addLiquidity: undefined };
|
|
70
|
+
FeesAction.RemoveLiquidity = { removeLiquidity: undefined };
|
|
71
|
+
FeesAction.SwapIn = { swapIn: undefined };
|
|
72
|
+
FeesAction.SwapOut = { swapOut: undefined };
|
|
73
|
+
FeesAction.StableSwapIn = { stableSwapIn: undefined };
|
|
74
|
+
FeesAction.StableSwapOut = { stableSwapOut: undefined };
|
|
60
75
|
return FeesAction;
|
|
61
76
|
}());
|
|
62
77
|
exports.FeesAction = FeesAction;
|
package/dist/utils/IdlCoder.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Layout } from 'buffer-layout';
|
|
2
|
-
import {
|
|
2
|
+
import { IdlTypeDef } from '@coral-xyz/anchor/dist/cjs/idl';
|
|
3
3
|
export declare class IdlCoder {
|
|
4
4
|
static fieldLayout(field: {
|
|
5
5
|
name?: string;
|
|
6
|
-
|
|
6
|
+
type: any;
|
|
7
|
+
}, types?: IdlTypeDef[]): Layout;
|
|
7
8
|
static typeDefLayout(typeDef: IdlTypeDef, types?: IdlTypeDef[], name?: string): Layout;
|
|
8
9
|
}
|
package/dist/utils/IdlCoder.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
@@ -87,7 +97,8 @@ var IdlCoder = (function () {
|
|
|
87
97
|
case 'string': {
|
|
88
98
|
return borsh.str(fieldName);
|
|
89
99
|
}
|
|
90
|
-
case 'publicKey':
|
|
100
|
+
case 'publicKey':
|
|
101
|
+
case 'pubkey': {
|
|
91
102
|
return borsh.publicKey(fieldName);
|
|
92
103
|
}
|
|
93
104
|
default: {
|
|
@@ -104,7 +115,8 @@ var IdlCoder = (function () {
|
|
|
104
115
|
}, types), fieldName);
|
|
105
116
|
}
|
|
106
117
|
else if ('defined' in field.type) {
|
|
107
|
-
var
|
|
118
|
+
var definedType = field.type.defined;
|
|
119
|
+
var defined_1 = typeof definedType === 'string' ? definedType : definedType.name;
|
|
108
120
|
if (types === undefined) {
|
|
109
121
|
throw new anchor_1.IdlError('User defined types not provided');
|
|
110
122
|
}
|
package/dist/utils/alt.js
CHANGED
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
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 =
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -36,7 +36,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.
|
|
39
|
+
exports.createLookupTable = createLookupTable;
|
|
40
|
+
exports.addAddressesToTable = addAddressesToTable;
|
|
41
|
+
exports.getAddressesInTable = getAddressesInTable;
|
|
40
42
|
var web3_js_1 = require("@solana/web3.js");
|
|
41
43
|
function createLookupTable(authority, payer, connection) {
|
|
42
44
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -62,7 +64,6 @@ function createLookupTable(authority, payer, connection) {
|
|
|
62
64
|
});
|
|
63
65
|
});
|
|
64
66
|
}
|
|
65
|
-
exports.createLookupTable = createLookupTable;
|
|
66
67
|
function addAddressesToTable(authority, payer, lookUpTableAddress, addressesToAdd) {
|
|
67
68
|
return __awaiter(this, void 0, void 0, function () {
|
|
68
69
|
var addAddressesInstruction;
|
|
@@ -77,7 +78,6 @@ function addAddressesToTable(authority, payer, lookUpTableAddress, addressesToAd
|
|
|
77
78
|
});
|
|
78
79
|
});
|
|
79
80
|
}
|
|
80
|
-
exports.addAddressesToTable = addAddressesToTable;
|
|
81
81
|
function getAddressesInTable(connection, lookUpTableAddress) {
|
|
82
82
|
return __awaiter(this, void 0, void 0, function () {
|
|
83
83
|
var lookupTableAccount;
|
|
@@ -93,4 +93,3 @@ function getAddressesInTable(connection, lookUpTableAddress) {
|
|
|
93
93
|
});
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
|
-
exports.getAddressesInTable = getAddressesInTable;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Event, EventCoder, web3 } from "@coral-xyz/anchor";
|
|
3
|
-
export declare function getAndValidateEvent(previousProgram: web3.PublicKey, currentProgram: web3.PublicKey, eventAuthority: web3.PublicKey, eventCoder: EventCoder, ixData:
|
|
2
|
+
export declare function getAndValidateEvent(previousProgram: web3.PublicKey, currentProgram: web3.PublicKey, eventAuthority: web3.PublicKey, eventCoder: EventCoder, ixData: Uint8Array): Event;
|
|
4
3
|
export declare const getCpiEventsFromTransaction: (response: web3.VersionedTransactionResponse) => Promise<Event[]>;
|
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
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 =
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -35,27 +35,31 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
38
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.getCpiEventsFromTransaction =
|
|
42
|
+
exports.getCpiEventsFromTransaction = void 0;
|
|
43
|
+
exports.getAndValidateEvent = getAndValidateEvent;
|
|
40
44
|
var anchor_1 = require("@coral-xyz/anchor");
|
|
41
|
-
var
|
|
45
|
+
var perpetuals_json_1 = __importDefault(require("../idl/perpetuals.json"));
|
|
42
46
|
var bytes_1 = require("@coral-xyz/anchor/dist/cjs/utils/bytes");
|
|
43
47
|
function getAndValidateEvent(previousProgram, currentProgram, eventAuthority, eventCoder, ixData) {
|
|
44
|
-
var eventTag =
|
|
45
|
-
|
|
48
|
+
var eventTag = new Uint8Array([0x1d, 0x9a, 0xcb, 0x51, 0x2e, 0xa5, 0x45, 0xe4].reverse());
|
|
49
|
+
var ixTag = ixData.slice(0, 8);
|
|
50
|
+
if (ixTag.length !== eventTag.length || !ixTag.every(function (val, i) { return val === eventTag[i]; })) {
|
|
46
51
|
throw new Error("Invalid CPI Event: Event tag mismatch");
|
|
47
52
|
}
|
|
48
53
|
var expectedAuthority = anchor_1.web3.PublicKey.findProgramAddressSync([Buffer.from("__event_authority")], currentProgram)[0];
|
|
49
54
|
if (expectedAuthority.toString() !== eventAuthority.toString()) {
|
|
50
55
|
throw new Error("Invalid CPI Event: Event authority does not match");
|
|
51
56
|
}
|
|
52
|
-
var event = eventCoder.decode(bytes_1.base64.encode(ixData.slice(8)));
|
|
57
|
+
var event = eventCoder.decode(bytes_1.base64.encode(Buffer.from(ixData.slice(8))));
|
|
53
58
|
if (!event) {
|
|
54
59
|
throw new Error("Invalid CPI Event: Failed to decode event");
|
|
55
60
|
}
|
|
56
61
|
return event;
|
|
57
62
|
}
|
|
58
|
-
exports.getAndValidateEvent = getAndValidateEvent;
|
|
59
63
|
var getCpiEventsFromTransaction = function (response) { return __awaiter(void 0, void 0, void 0, function () {
|
|
60
64
|
var instructions, innerInstructions, accounts, eventCoder, events, _loop_1, _i, innerInstructions_1, packet;
|
|
61
65
|
var _a, _b;
|
|
@@ -65,12 +69,12 @@ var getCpiEventsFromTransaction = function (response) { return __awaiter(void 0,
|
|
|
65
69
|
accounts = response.transaction.message.staticAccountKeys
|
|
66
70
|
.concat((_a = response.meta.loadedAddresses.writable) !== null && _a !== void 0 ? _a : [])
|
|
67
71
|
.concat((_b = response.meta.loadedAddresses.readonly) !== null && _b !== void 0 ? _b : []);
|
|
68
|
-
eventCoder = new anchor_1.BorshEventCoder(
|
|
72
|
+
eventCoder = new anchor_1.BorshEventCoder(perpetuals_json_1.default);
|
|
69
73
|
events = [];
|
|
70
74
|
_loop_1 = function (packet) {
|
|
71
75
|
var previousProgram = accounts[instructions[packet.index].programIdIndex];
|
|
72
76
|
packet.instructions.forEach(function (instruction, indexofInnerIns) {
|
|
73
|
-
var bytes = bytes_1.bs58.decode(instruction.data);
|
|
77
|
+
var bytes = new Uint8Array(bytes_1.bs58.decode(instruction.data));
|
|
74
78
|
var currentProgram = accounts[instruction.programIdIndex];
|
|
75
79
|
var eventAuthority = accounts[instruction.accounts[0]];
|
|
76
80
|
try {
|
package/dist/utils/index.js
CHANGED
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
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 =
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -39,7 +39,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.checkedDecimalDiv = exports.checkedDecimalMul = exports.checkedDecimalCeilMul = exports.checkedCeilDiv = exports.scaleToExponent = exports.
|
|
42
|
+
exports.checkedDecimalDiv = exports.checkedDecimalMul = exports.checkedDecimalCeilMul = exports.checkedCeilDiv = exports.scaleToExponent = exports.validateNumberString = exports.uiDecimalsToNative = exports.getUnixTs = void 0;
|
|
43
|
+
exports.toUiDecimalsOldSDK = toUiDecimalsOldSDK;
|
|
44
|
+
exports.nativeToUiDecimals = nativeToUiDecimals;
|
|
45
|
+
exports.checkIfAccountExists = checkIfAccountExists;
|
|
43
46
|
var bn_js_1 = __importDefault(require("bn.js"));
|
|
44
47
|
var constants_1 = require("../constants");
|
|
45
48
|
var bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
@@ -89,7 +92,6 @@ function toUiDecimalsOldSDK(nativeAmount, decimals, precision, commaSeperated) {
|
|
|
89
92
|
return r;
|
|
90
93
|
}
|
|
91
94
|
}
|
|
92
|
-
exports.toUiDecimalsOldSDK = toUiDecimalsOldSDK;
|
|
93
95
|
var uiDecimalsToNative = function (amountUi, decimals) {
|
|
94
96
|
var valueBigNumber = (new bignumber_js_1.default(amountUi)).multipliedBy(new bignumber_js_1.default(Math.pow(10, decimals)));
|
|
95
97
|
return new bn_js_1.default(valueBigNumber.toFixed(0, bignumber_js_1.default.ROUND_DOWN));
|
|
@@ -137,7 +139,6 @@ function nativeToUiDecimals(nativeAmount, decimals, precision, commaSeperated) {
|
|
|
137
139
|
return r;
|
|
138
140
|
}
|
|
139
141
|
}
|
|
140
|
-
exports.nativeToUiDecimals = nativeToUiDecimals;
|
|
141
142
|
function checkIfAccountExists(account, connection) {
|
|
142
143
|
return __awaiter(this, void 0, void 0, function () {
|
|
143
144
|
var bal;
|
|
@@ -157,7 +158,6 @@ function checkIfAccountExists(account, connection) {
|
|
|
157
158
|
});
|
|
158
159
|
});
|
|
159
160
|
}
|
|
160
|
-
exports.checkIfAccountExists = checkIfAccountExists;
|
|
161
161
|
var scaleToExponent = function (arg, exponent, target_exponent) {
|
|
162
162
|
if (target_exponent.eq(exponent)) {
|
|
163
163
|
return arg;
|