flash-sdk 12.0.0 → 12.0.1
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/CustodyAccount.d.ts +1 -1
- 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 +325 -4360
- package/dist/PerpetualsClient.js +1205 -558
- package/dist/PoolAccount.d.ts +0 -1
- package/dist/PoolConfig.d.ts +3 -1
- package/dist/PoolConfig.js +30 -2
- package/dist/PoolConfig.json +955 -133
- package/dist/PoolDataClient.d.ts +0 -1
- package/dist/PositionAccount.d.ts +3 -3
- package/dist/TokenStakeAccount.d.ts +0 -1
- package/dist/TokenVaultAccount.d.ts +0 -1
- package/dist/ViewHelper.d.ts +2 -1
- package/dist/ViewHelper.js +11 -8
- package/dist/backupOracle.js +27 -6
- package/dist/constants/index.d.ts +0 -1
- package/dist/idl/perpetuals.d.ts +26433 -13458
- package/dist/idl/perpetuals.js +0 -18010
- package/dist/idl/perpetuals.json +30985 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +6 -2
- package/dist/remoraTokensWithPriceIds.d.ts +13 -0
- package/dist/remoraTokensWithPriceIds.js +265 -0
- package/dist/testPublkey.d.ts +0 -0
- package/dist/testPublkey.js +0 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/generated.d.ts +2275 -0
- package/dist/types/generated.js +2 -0
- package/dist/types/index.d.ts +47 -160
- package/dist/types/index.js +22 -6
- 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 -3
- package/readme.md +37 -3
- package/dist/idl/fbnft_rewards.d.ts +0 -290
- package/dist/idl/fbnft_rewards.js +0 -292
- package/dist/idl/perp_composability.d.ts +0 -760
- package/dist/idl/perp_composability.js +0 -762
- package/dist/idl/reward_distribution.d.ts +0 -347
- package/dist/idl/reward_distribution.js +0 -349
package/dist/PoolDataClient.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="bn.js" />
|
|
2
1
|
import { BN } from "@coral-xyz/anchor";
|
|
3
2
|
import { PublicKey } from "@solana/web3.js";
|
|
4
3
|
import { ContractOraclePrice, Position } from "./types";
|
|
@@ -14,14 +13,15 @@ export declare class PositionAccount implements Position {
|
|
|
14
13
|
sizeAmount: BN;
|
|
15
14
|
lockedAmount: BN;
|
|
16
15
|
lockedUsd: BN;
|
|
17
|
-
|
|
16
|
+
priceImpactUsd: BN;
|
|
18
17
|
collateralUsd: BN;
|
|
19
18
|
unsettledValueUsd: BN;
|
|
20
19
|
unsettledFeesUsd: BN;
|
|
21
20
|
cumulativeLockFeeSnapshot: BN;
|
|
22
21
|
degenSizeUsd: BN;
|
|
23
22
|
referencePrice: ContractOraclePrice;
|
|
24
|
-
buffer: number;
|
|
23
|
+
buffer: number[];
|
|
24
|
+
priceImpactSet: number;
|
|
25
25
|
sizeDecimals: number;
|
|
26
26
|
lockedDecimals: number;
|
|
27
27
|
collateralDecimals: number;
|
package/dist/ViewHelper.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { PublicKey, RpcResponseAndContext, SimulatedTransactionResponse, Transaction } from "@solana/web3.js";
|
|
2
2
|
import { PerpetualsClient } from "./PerpetualsClient";
|
|
3
|
+
import { AddressLookupTableAccount } from "@solana/web3.js";
|
|
3
4
|
export declare class ViewHelper {
|
|
4
5
|
private perpetualsClient;
|
|
5
6
|
constructor(client: PerpetualsClient);
|
|
6
7
|
decodeLogs<T>(data: RpcResponseAndContext<SimulatedTransactionResponse>, instructionNumber: number, instructionName?: string): T | undefined;
|
|
7
|
-
simulateTransaction(transaction: Transaction, userPublicKey?: PublicKey | undefined): Promise<RpcResponseAndContext<SimulatedTransactionResponse>>;
|
|
8
|
+
simulateTransaction(transaction: Transaction, addressLookupTableAccounts: AddressLookupTableAccount[], userPublicKey?: PublicKey | undefined): Promise<RpcResponseAndContext<SimulatedTransactionResponse>>;
|
|
8
9
|
}
|
package/dist/ViewHelper.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.");
|
|
@@ -44,11 +44,14 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
44
44
|
}
|
|
45
45
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
46
|
};
|
|
47
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
48
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
|
+
};
|
|
47
50
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
51
|
exports.ViewHelper = void 0;
|
|
49
52
|
var web3_js_1 = require("@solana/web3.js");
|
|
50
53
|
var base64_1 = require("@coral-xyz/anchor/dist/cjs/utils/bytes/base64");
|
|
51
|
-
var
|
|
54
|
+
var perpetuals_json_1 = __importDefault(require("./idl/perpetuals.json"));
|
|
52
55
|
var IdlCoder_1 = require("./utils/IdlCoder");
|
|
53
56
|
var ViewHelper = (function () {
|
|
54
57
|
function ViewHelper(client) {
|
|
@@ -65,11 +68,11 @@ var ViewHelper = (function () {
|
|
|
65
68
|
throw new Error('View expected return log');
|
|
66
69
|
}
|
|
67
70
|
var returnData = (0, base64_1.decode)(returnLog.slice(returnPrefix_1.length));
|
|
68
|
-
var returnType =
|
|
71
|
+
var returnType = perpetuals_json_1.default.instructions[instructionNumber].returns;
|
|
69
72
|
if (!returnType) {
|
|
70
73
|
throw new Error('View expected return type');
|
|
71
74
|
}
|
|
72
|
-
var coder = IdlCoder_1.IdlCoder.fieldLayout({ type: returnType }, Array.from(__spreadArray(__spreadArray([], ((_a =
|
|
75
|
+
var coder = IdlCoder_1.IdlCoder.fieldLayout({ type: returnType }, Array.from(__spreadArray(__spreadArray([], ((_a = perpetuals_json_1.default.accounts) !== null && _a !== void 0 ? _a : []), true), ((_b = perpetuals_json_1.default.types) !== null && _b !== void 0 ? _b : []), true)));
|
|
73
76
|
return coder.decode(returnData);
|
|
74
77
|
}
|
|
75
78
|
else {
|
|
@@ -82,8 +85,8 @@ var ViewHelper = (function () {
|
|
|
82
85
|
console.log("decode error::", error);
|
|
83
86
|
}
|
|
84
87
|
};
|
|
85
|
-
ViewHelper.prototype.simulateTransaction = function (transaction_1) {
|
|
86
|
-
return __awaiter(this, arguments, void 0, function (transaction, userPublicKey) {
|
|
88
|
+
ViewHelper.prototype.simulateTransaction = function (transaction_1, addressLookupTableAccounts_1) {
|
|
89
|
+
return __awaiter(this, arguments, void 0, function (transaction, addressLookupTableAccounts, userPublicKey) {
|
|
87
90
|
var latestBlockhash, messageV0, transaction2;
|
|
88
91
|
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
|
89
92
|
return __generator(this, function (_a) {
|
|
@@ -97,7 +100,7 @@ var ViewHelper = (function () {
|
|
|
97
100
|
payerKey: this.perpetualsClient.provider.publicKey,
|
|
98
101
|
recentBlockhash: latestBlockhash.blockhash,
|
|
99
102
|
instructions: transaction.instructions,
|
|
100
|
-
}).compileToV0Message(
|
|
103
|
+
}).compileToV0Message(addressLookupTableAccounts);
|
|
101
104
|
transaction2 = new web3_js_1.VersionedTransaction(messageV0);
|
|
102
105
|
return [2, this.perpetualsClient.provider.connection.simulateTransaction(transaction2, { sigVerify: false, replaceRecentBlockhash: true })];
|
|
103
106
|
}
|
package/dist/backupOracle.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.");
|
|
@@ -40,12 +40,34 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
40
40
|
};
|
|
41
41
|
var _a;
|
|
42
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
-
exports.
|
|
43
|
+
exports.getBackupOracleInstruction = exports.getPythnetOraclePrices = exports.pythPriceServiceConnection = void 0;
|
|
44
|
+
exports.createBackupOracleInstruction = createBackupOracleInstruction;
|
|
44
45
|
var price_service_client_1 = require("@pythnetwork/price-service-client");
|
|
45
46
|
var web3_js_1 = require("@solana/web3.js");
|
|
46
47
|
var bn_js_1 = __importDefault(require("bn.js"));
|
|
47
48
|
var bs58_1 = __importDefault(require("bs58"));
|
|
48
49
|
var tweetnacl_1 = __importDefault(require("tweetnacl"));
|
|
50
|
+
var BACKUP_ORACLE_SIZE = 36;
|
|
51
|
+
function encodePermissionlessPythCache(cache) {
|
|
52
|
+
var backupCache = cache.backupCache;
|
|
53
|
+
var buf = Buffer.alloc(4 + backupCache.length * BACKUP_ORACLE_SIZE);
|
|
54
|
+
buf.writeUInt32LE(backupCache.length, 0);
|
|
55
|
+
var offset = 4;
|
|
56
|
+
for (var _i = 0, backupCache_1 = backupCache; _i < backupCache_1.length; _i++) {
|
|
57
|
+
var oracle = backupCache_1[_i];
|
|
58
|
+
buf.writeBigInt64LE(BigInt(oracle.price.toString()), offset);
|
|
59
|
+
offset += 8;
|
|
60
|
+
buf.writeInt32LE(oracle.expo, offset);
|
|
61
|
+
offset += 4;
|
|
62
|
+
buf.writeBigInt64LE(BigInt(oracle.conf.toString()), offset);
|
|
63
|
+
offset += 8;
|
|
64
|
+
buf.writeBigInt64LE(BigInt(oracle.emaPrice.toString()), offset);
|
|
65
|
+
offset += 8;
|
|
66
|
+
buf.writeBigInt64LE(BigInt(oracle.publishTime.toString()), offset);
|
|
67
|
+
offset += 8;
|
|
68
|
+
}
|
|
69
|
+
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
70
|
+
}
|
|
49
71
|
var API_ENDPOINT = (_a = process.env.NEXT_PUBLIC_API_ENDPOINT) !== null && _a !== void 0 ? _a : 'https://api.prod.flash.trade';
|
|
50
72
|
exports.pythPriceServiceConnection = new price_service_client_1.PriceServiceConnection('https://hermes.pyth.network', {
|
|
51
73
|
priceFeedRequestConfig: {},
|
|
@@ -88,7 +110,7 @@ var getPythnetOraclePrices = function (program, poolConfig, backupOracleSecretKe
|
|
|
88
110
|
permissionlessPythCache = {
|
|
89
111
|
backupCache: caches_1
|
|
90
112
|
};
|
|
91
|
-
message =
|
|
113
|
+
message = encodePermissionlessPythCache(permissionlessPythCache);
|
|
92
114
|
signature = tweetnacl_1.default.sign.detached(message, backupOracleAccount.secretKey);
|
|
93
115
|
preInstruction = web3_js_1.Ed25519Program.createInstructionWithPublicKey({
|
|
94
116
|
publicKey: backupOracleAccount.publicKey.toBytes(),
|
|
@@ -114,7 +136,7 @@ var getBackupOracleInstruction = function (program, poolConfig, backupOracleSecr
|
|
|
114
136
|
var permissionlessPythCache = {
|
|
115
137
|
backupCache: backupCaches
|
|
116
138
|
};
|
|
117
|
-
var message =
|
|
139
|
+
var message = encodePermissionlessPythCache(permissionlessPythCache);
|
|
118
140
|
var signature = tweetnacl_1.default.sign.detached(message, backupOracleAccount.secretKey);
|
|
119
141
|
var preInstruction = web3_js_1.Ed25519Program.createInstructionWithPublicKey({
|
|
120
142
|
publicKey: backupOracleAccount.publicKey.toBytes(),
|
|
@@ -156,4 +178,3 @@ function createBackupOracleInstruction(poolAddress_1) {
|
|
|
156
178
|
});
|
|
157
179
|
});
|
|
158
180
|
}
|
|
159
|
-
exports.createBackupOracleInstruction = createBackupOracleInstruction;
|