flash-sdk 1.0.2 → 1.0.4
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/lib/CustodyAccount.d.ts +3 -1
- package/lib/OraclePrice.d.ts +0 -1
- package/lib/PerpetualsClient.d.ts +4 -3
- package/lib/PerpetualsClient.js +56 -25
- package/lib/PoolAccount.d.ts +1 -2
- package/lib/PoolDisplayData.d.ts +0 -1
- package/lib/PositionAccount.d.ts +2 -2
- package/lib/PositionAccount.js +0 -1
- package/lib/client/src/PerpetualsClient.d.ts +6 -8
- package/lib/client/src/PerpetualsClient.js +55 -25
- package/lib/client/src/index.d.ts +2 -1
- package/lib/client/src/index.js +3 -1
- package/lib/client/src/target/types/limit_order_cpi.d.ts +130 -0
- package/lib/client/src/target/types/limit_order_cpi.js +132 -0
- package/lib/constants/index.d.ts +0 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/index.d.ts +0 -1
- package/package.json +1 -1
- package/readme.md +23 -3
- package/src/CustodyAccount.ts +3 -1
- package/src/PerpetualsClient.ts +62 -32
- package/src/PoolAccount.ts +1 -1
- package/src/PositionAccount.ts +2 -1
- package/src/target/idl/perpetuals.json +0 -3537
- package/src/target/types/limit_order_cpi.js +132 -0
- package/src/target/types/limit_order_cpi.ts +259 -0
- package/src/types/index.ts +3 -3
package/lib/CustodyAccount.d.ts
CHANGED
@@ -2,7 +2,7 @@ import { PublicKey } from "@solana/web3.js";
|
|
2
2
|
import { Assets, FeesStats, Custody, Fees, PricingParams, TradeStats, Permissions, BorrowRateParams, OracleParams, VolumeStats, PositionStats, BorrowRateState, Side } from "./types";
|
3
3
|
import { PositionAccount } from "./PositionAccount";
|
4
4
|
import BN from "bn.js";
|
5
|
-
export declare class CustodyAccount {
|
5
|
+
export declare class CustodyAccount implements Custody {
|
6
6
|
publicKey: PublicKey;
|
7
7
|
pool: PublicKey;
|
8
8
|
mint: PublicKey;
|
@@ -21,6 +21,8 @@ export declare class CustodyAccount {
|
|
21
21
|
longPositions: PositionStats;
|
22
22
|
shortPositions: PositionStats;
|
23
23
|
borrowRateState: BorrowRateState;
|
24
|
+
bump: number;
|
25
|
+
tokenAccountBump: number;
|
24
26
|
constructor(publicKey: PublicKey, parseData: Custody);
|
25
27
|
static from(publicKey: PublicKey, parseData: Custody): CustodyAccount;
|
26
28
|
updateCustodyData(custody: Custody): void;
|
package/lib/OraclePrice.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Program, AnchorProvider, BN } from "@coral-xyz/anchor";
|
2
|
-
import { PublicKey
|
2
|
+
import { PublicKey } from "@solana/web3.js";
|
3
3
|
import { PoolAccount } from "./PoolAccount";
|
4
4
|
import { BorrowRateParams, Fees, OracleParams, Permissions, Position, PositionSide, PricingParams, TokenRatios } from "./types";
|
5
5
|
import { OraclePrice } from "./OraclePrice";
|
@@ -8,7 +8,8 @@ import { Perpetuals } from "./target/types/perpetuals";
|
|
8
8
|
export declare class PerpetualsClient {
|
9
9
|
provider: AnchorProvider;
|
10
10
|
program: Program<Perpetuals>;
|
11
|
-
admin:
|
11
|
+
admin: PublicKey;
|
12
|
+
programId: PublicKey;
|
12
13
|
multisig: {
|
13
14
|
publicKey: PublicKey;
|
14
15
|
bump: number;
|
@@ -21,7 +22,7 @@ export declare class PerpetualsClient {
|
|
21
22
|
publicKey: PublicKey;
|
22
23
|
bump: number;
|
23
24
|
};
|
24
|
-
constructor(
|
25
|
+
constructor(provider: AnchorProvider, programId: PublicKey);
|
25
26
|
findProgramAddress: (label: string, extraSeeds?: any) => {
|
26
27
|
publicKey: PublicKey;
|
27
28
|
bump: number;
|
package/lib/PerpetualsClient.js
CHANGED
@@ -42,11 +42,31 @@ var web3_js_1 = require("@solana/web3.js");
|
|
42
42
|
var spl_token_1 = require("@solana/spl-token");
|
43
43
|
var js_sha256_1 = require("js-sha256");
|
44
44
|
var bs58_1 = require("bs58");
|
45
|
-
var fs_1 = require("fs");
|
46
45
|
var PositionAccount_1 = require("./PositionAccount");
|
47
|
-
|
46
|
+
var perpetuals_1 = require("./target/types/perpetuals");
|
47
|
+
/* USEAGE
|
48
|
+
|
49
|
+
UI ---
|
50
|
+
provider = from phatom
|
51
|
+
|
52
|
+
client = new PerpetualsClient(provider, user.pubkey , programId);
|
53
|
+
|
54
|
+
BOT cli --------
|
55
|
+
|
56
|
+
provider = await getProvider(new DefaultWallet(DEFAULT_PERPS_USER));
|
57
|
+
|
58
|
+
AnchorProvider.local(clusterUrl, {
|
59
|
+
commitment: "confirmed",
|
60
|
+
preflightCommitment: "confirmed",
|
61
|
+
skipPreflight: true
|
62
|
+
});
|
63
|
+
process.env["ANCHOR_WALLET"] = adminKeyPath;
|
64
|
+
|
65
|
+
client = new PerpetualsClient(provider, DEFAULT_PERPS_USER.pubkey , programId);
|
66
|
+
|
67
|
+
*/
|
48
68
|
var PerpetualsClient = /** @class */ (function () {
|
49
|
-
function PerpetualsClient(
|
69
|
+
function PerpetualsClient(provider, programId) {
|
50
70
|
var _this = this;
|
51
71
|
this.findProgramAddress = function (label, extraSeeds) {
|
52
72
|
if (extraSeeds === void 0) { extraSeeds = null; }
|
@@ -335,11 +355,11 @@ var PerpetualsClient = /** @class */ (function () {
|
|
335
355
|
minSignatures: minSignatures,
|
336
356
|
})
|
337
357
|
.accounts({
|
338
|
-
admin: this.admin
|
358
|
+
admin: this.admin,
|
339
359
|
multisig: this.multisig.publicKey,
|
340
360
|
})
|
341
361
|
.remainingAccounts(adminMetas)
|
342
|
-
.signers([this.admin])
|
362
|
+
// .signers([this.admin])
|
343
363
|
.rpc()];
|
344
364
|
case 2:
|
345
365
|
_a.sent();
|
@@ -361,7 +381,7 @@ var PerpetualsClient = /** @class */ (function () {
|
|
361
381
|
case 0: return [4 /*yield*/, this.program.methods
|
362
382
|
.addPool({ name: name })
|
363
383
|
.accounts({
|
364
|
-
admin: this.
|
384
|
+
admin: this.provider.wallet.publicKey,
|
365
385
|
multisig: this.multisig.publicKey,
|
366
386
|
transferAuthority: this.authority.publicKey,
|
367
387
|
perpetuals: this.perpetuals.publicKey,
|
@@ -371,7 +391,7 @@ var PerpetualsClient = /** @class */ (function () {
|
|
371
391
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
372
392
|
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
373
393
|
})
|
374
|
-
.signers([this.admin])
|
394
|
+
// .signers([this.admin])
|
375
395
|
.rpc()
|
376
396
|
.catch(function (err) {
|
377
397
|
console.error(err);
|
@@ -389,14 +409,14 @@ var PerpetualsClient = /** @class */ (function () {
|
|
389
409
|
case 0: return [4 /*yield*/, this.program.methods
|
390
410
|
.removePool({})
|
391
411
|
.accounts({
|
392
|
-
admin: this.admin
|
412
|
+
admin: this.admin,
|
393
413
|
multisig: this.multisig.publicKey,
|
394
414
|
transferAuthority: this.authority.publicKey,
|
395
415
|
perpetuals: this.perpetuals.publicKey,
|
396
416
|
pool: this.getPoolKey(name),
|
397
417
|
systemProgram: web3_js_1.SystemProgram.programId,
|
398
418
|
})
|
399
|
-
.signers([this.admin])
|
419
|
+
// .signers([this.admin])
|
400
420
|
.rpc()
|
401
421
|
.catch(function (err) {
|
402
422
|
console.error(err);
|
@@ -430,7 +450,7 @@ var PerpetualsClient = /** @class */ (function () {
|
|
430
450
|
ratios: ratios,
|
431
451
|
})
|
432
452
|
.accounts({
|
433
|
-
admin: this.admin
|
453
|
+
admin: this.admin,
|
434
454
|
multisig: this.multisig.publicKey,
|
435
455
|
transferAuthority: this.authority.publicKey,
|
436
456
|
perpetuals: this.perpetuals.publicKey,
|
@@ -442,7 +462,7 @@ var PerpetualsClient = /** @class */ (function () {
|
|
442
462
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
443
463
|
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
444
464
|
})
|
445
|
-
.signers([this.admin])
|
465
|
+
// .signers([this.admin])
|
446
466
|
.rpc()
|
447
467
|
.catch(function (err) {
|
448
468
|
console.error(err);
|
@@ -479,7 +499,7 @@ var PerpetualsClient = /** @class */ (function () {
|
|
479
499
|
ratios: ratios,
|
480
500
|
})
|
481
501
|
.accounts({
|
482
|
-
admin: this.admin
|
502
|
+
admin: this.admin,
|
483
503
|
multisig: this.multisig.publicKey,
|
484
504
|
transferAuthority: this.authority.publicKey,
|
485
505
|
perpetuals: this.perpetuals.publicKey,
|
@@ -491,7 +511,7 @@ var PerpetualsClient = /** @class */ (function () {
|
|
491
511
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
492
512
|
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
493
513
|
})
|
494
|
-
.signers([this.admin])
|
514
|
+
// .signers([this.admin])
|
495
515
|
.rpc()
|
496
516
|
.catch(function (err) {
|
497
517
|
console.error(err);
|
@@ -510,7 +530,7 @@ var PerpetualsClient = /** @class */ (function () {
|
|
510
530
|
case 0: return [4 /*yield*/, this.program.methods
|
511
531
|
.removeCustody({ ratios: ratios })
|
512
532
|
.accounts({
|
513
|
-
admin: this.admin
|
533
|
+
admin: this.admin,
|
514
534
|
multisig: this.multisig.publicKey,
|
515
535
|
transferAuthority: this.authority.publicKey,
|
516
536
|
perpetuals: this.perpetuals.publicKey,
|
@@ -520,7 +540,7 @@ var PerpetualsClient = /** @class */ (function () {
|
|
520
540
|
systemProgram: web3_js_1.SystemProgram.programId,
|
521
541
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
522
542
|
})
|
523
|
-
.signers([this.admin])
|
543
|
+
// .signers([this.admin])
|
524
544
|
.rpc()
|
525
545
|
.catch(function (err) {
|
526
546
|
console.error(err);
|
@@ -538,13 +558,13 @@ var PerpetualsClient = /** @class */ (function () {
|
|
538
558
|
case 0: return [4 /*yield*/, this.program.methods
|
539
559
|
.upgradeCustody({})
|
540
560
|
.accounts({
|
541
|
-
admin: this.admin
|
561
|
+
admin: this.admin,
|
542
562
|
multisig: this.multisig.publicKey,
|
543
563
|
pool: this.getPoolKey(poolName),
|
544
564
|
custody: this.getCustodyKey(poolName, tokenMint),
|
545
565
|
systemProgram: web3_js_1.SystemProgram.programId,
|
546
566
|
})
|
547
|
-
.signers([this.admin])
|
567
|
+
// .signers([this.admin])
|
548
568
|
.rpc()
|
549
569
|
.catch(function (err) {
|
550
570
|
console.error(err);
|
@@ -993,14 +1013,25 @@ var PerpetualsClient = /** @class */ (function () {
|
|
993
1013
|
}
|
994
1014
|
});
|
995
1015
|
}); };
|
996
|
-
this.provider =
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
});
|
1001
|
-
|
1002
|
-
this.
|
1003
|
-
|
1016
|
+
// this.provider = AnchorProvider.local(clusterUrl, {
|
1017
|
+
// commitment: "confirmed",
|
1018
|
+
// preflightCommitment: "confirmed",
|
1019
|
+
// skipPreflight: true
|
1020
|
+
// });
|
1021
|
+
// setProvider(this.provider);
|
1022
|
+
this.provider = provider;
|
1023
|
+
(0, anchor_1.setProvider)(provider);
|
1024
|
+
// const idl = JSON.parse( fs.readFileSync("./target/idl/perpetuals.json", "utf8"));
|
1025
|
+
// const idl = JSON.parse(IDL);
|
1026
|
+
// const program = new anchor.Program(idl, programId, provider);
|
1027
|
+
this.program = new anchor_1.Program(perpetuals_1.IDL, programId);
|
1028
|
+
//this.program = workspace.Perpetuals as Program<Perpetuals>;
|
1029
|
+
console.log("client constructor programID : ", this.program.programId.toBase58());
|
1030
|
+
// this.admin = Keypair.fromSecretKey(
|
1031
|
+
// new Uint8Array(JSON.parse(readFileSync(adminKey).toString()))
|
1032
|
+
// );
|
1033
|
+
this.admin = this.provider.wallet.publicKey;
|
1034
|
+
console.log("admin:", this.admin.toBase58());
|
1004
1035
|
this.multisig = this.findProgramAddress("multisig");
|
1005
1036
|
this.authority = this.findProgramAddress("transfer_authority");
|
1006
1037
|
this.perpetuals = this.findProgramAddress("perpetuals");
|
package/lib/PoolAccount.d.ts
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
/// <reference types="bn.js" />
|
2
1
|
import { BN } from "@coral-xyz/anchor";
|
3
2
|
import { AumCalcMode, Pool, Side, TokenRatios } from "./types";
|
4
3
|
import { PublicKey } from "@solana/web3.js";
|
5
4
|
import { CustodyAccount } from "./CustodyAccount";
|
6
5
|
import { OraclePrice } from "./OraclePrice";
|
7
6
|
import { PositionAccount } from "./PositionAccount";
|
8
|
-
export declare class PoolAccount {
|
7
|
+
export declare class PoolAccount implements Pool {
|
9
8
|
publicKey: PublicKey;
|
10
9
|
name: string;
|
11
10
|
custodies: PublicKey[];
|
package/lib/PoolDisplayData.d.ts
CHANGED
package/lib/PositionAccount.d.ts
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
/// <reference types="bn.js" />
|
2
1
|
import { BN } from "@coral-xyz/anchor";
|
3
2
|
import { PublicKey } from "@solana/web3.js";
|
4
3
|
import { Position, Side } from "./types";
|
5
|
-
export declare class PositionAccount {
|
4
|
+
export declare class PositionAccount implements Position {
|
6
5
|
publicKey: PublicKey;
|
7
6
|
owner: PublicKey;
|
8
7
|
pool: PublicKey;
|
@@ -18,6 +17,7 @@ export declare class PositionAccount {
|
|
18
17
|
cumulativeInterestSnapshot: BN;
|
19
18
|
lockedAmount: BN;
|
20
19
|
collateralAmount: BN;
|
20
|
+
bump: number;
|
21
21
|
constructor(publicKey: PublicKey, parseData: Position);
|
22
22
|
static from(publicKey: PublicKey, parseData: Position): PositionAccount;
|
23
23
|
updatePositionData(position: Position): void;
|
package/lib/PositionAccount.js
CHANGED
@@ -50,7 +50,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
50
|
exports.PositionAccount = void 0;
|
51
51
|
var anchor_1 = require("@coral-xyz/anchor");
|
52
52
|
var PositionAccount = /** @class */ (function () {
|
53
|
-
// extra
|
54
53
|
function PositionAccount(publicKey, parseData) {
|
55
54
|
this.publicKey = publicKey;
|
56
55
|
Object.assign(this, parseData);
|
@@ -1,16 +1,15 @@
|
|
1
|
-
/// <reference types="bn.js" />
|
2
|
-
/// <reference types="node" />
|
3
1
|
import { Program, AnchorProvider, BN } from "@coral-xyz/anchor";
|
4
|
-
import { PublicKey
|
2
|
+
import { PublicKey } from "@solana/web3.js";
|
5
3
|
import { PoolAccount } from "./PoolAccount";
|
6
4
|
import { BorrowRateParams, Fees, OracleParams, Permissions, Position, PositionSide, PricingParams, TokenRatios } from "./types";
|
7
5
|
import { OraclePrice } from "./OraclePrice";
|
8
|
-
import CustodyAccount from "./CustodyAccount";
|
9
|
-
import { Perpetuals } from "
|
6
|
+
import { CustodyAccount } from "./CustodyAccount";
|
7
|
+
import { Perpetuals } from "./target/types/perpetuals";
|
10
8
|
export declare class PerpetualsClient {
|
11
9
|
provider: AnchorProvider;
|
12
10
|
program: Program<Perpetuals>;
|
13
|
-
admin:
|
11
|
+
admin: PublicKey;
|
12
|
+
programId: PublicKey;
|
14
13
|
multisig: {
|
15
14
|
publicKey: PublicKey;
|
16
15
|
bump: number;
|
@@ -23,7 +22,7 @@ export declare class PerpetualsClient {
|
|
23
22
|
publicKey: PublicKey;
|
24
23
|
bump: number;
|
25
24
|
};
|
26
|
-
constructor(
|
25
|
+
constructor(provider: AnchorProvider, programId: PublicKey);
|
27
26
|
findProgramAddress: (label: string, extraSeeds?: any) => {
|
28
27
|
publicKey: PublicKey;
|
29
28
|
bump: number;
|
@@ -1937,4 +1936,3 @@ export declare class PerpetualsClient {
|
|
1937
1936
|
getSwapAmountAndFees: (poolName: string, tokenMintIn: PublicKey, tokenMintOut: PublicKey, amountIn: BN) => Promise<any>;
|
1938
1937
|
getAum: (poolName: string) => Promise<any>;
|
1939
1938
|
}
|
1940
|
-
//# sourceMappingURL=PerpetualsClient.d.ts.map
|
@@ -42,10 +42,31 @@ var web3_js_1 = require("@solana/web3.js");
|
|
42
42
|
var spl_token_1 = require("@solana/spl-token");
|
43
43
|
var js_sha256_1 = require("js-sha256");
|
44
44
|
var bs58_1 = require("bs58");
|
45
|
-
var fs_1 = require("fs");
|
46
45
|
var PositionAccount_1 = require("./PositionAccount");
|
46
|
+
var perpetuals_1 = require("../../target/types/perpetuals");
|
47
|
+
/* USEAGE
|
48
|
+
|
49
|
+
UI ---
|
50
|
+
provider = from phatom
|
51
|
+
|
52
|
+
client = new PerpetualsClient(provider, user.pubkey , programId);
|
53
|
+
|
54
|
+
BOT cli --------
|
55
|
+
|
56
|
+
provider = await getProvider(new DefaultWallet(DEFAULT_PERPS_USER));
|
57
|
+
|
58
|
+
AnchorProvider.local(clusterUrl, {
|
59
|
+
commitment: "confirmed",
|
60
|
+
preflightCommitment: "confirmed",
|
61
|
+
skipPreflight: true
|
62
|
+
});
|
63
|
+
process.env["ANCHOR_WALLET"] = adminKeyPath;
|
64
|
+
|
65
|
+
client = new PerpetualsClient(provider, DEFAULT_PERPS_USER.pubkey , programId);
|
66
|
+
|
67
|
+
*/
|
47
68
|
var PerpetualsClient = /** @class */ (function () {
|
48
|
-
function PerpetualsClient(
|
69
|
+
function PerpetualsClient(provider, programId) {
|
49
70
|
var _this = this;
|
50
71
|
this.findProgramAddress = function (label, extraSeeds) {
|
51
72
|
if (extraSeeds === void 0) { extraSeeds = null; }
|
@@ -334,11 +355,11 @@ var PerpetualsClient = /** @class */ (function () {
|
|
334
355
|
minSignatures: minSignatures,
|
335
356
|
})
|
336
357
|
.accounts({
|
337
|
-
admin: this.admin
|
358
|
+
admin: this.admin,
|
338
359
|
multisig: this.multisig.publicKey,
|
339
360
|
})
|
340
361
|
.remainingAccounts(adminMetas)
|
341
|
-
.signers([this.admin])
|
362
|
+
// .signers([this.admin])
|
342
363
|
.rpc()];
|
343
364
|
case 2:
|
344
365
|
_a.sent();
|
@@ -360,7 +381,7 @@ var PerpetualsClient = /** @class */ (function () {
|
|
360
381
|
case 0: return [4 /*yield*/, this.program.methods
|
361
382
|
.addPool({ name: name })
|
362
383
|
.accounts({
|
363
|
-
admin: this.
|
384
|
+
admin: this.provider.wallet.publicKey,
|
364
385
|
multisig: this.multisig.publicKey,
|
365
386
|
transferAuthority: this.authority.publicKey,
|
366
387
|
perpetuals: this.perpetuals.publicKey,
|
@@ -370,7 +391,7 @@ var PerpetualsClient = /** @class */ (function () {
|
|
370
391
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
371
392
|
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
372
393
|
})
|
373
|
-
.signers([this.admin])
|
394
|
+
// .signers([this.admin])
|
374
395
|
.rpc()
|
375
396
|
.catch(function (err) {
|
376
397
|
console.error(err);
|
@@ -388,14 +409,14 @@ var PerpetualsClient = /** @class */ (function () {
|
|
388
409
|
case 0: return [4 /*yield*/, this.program.methods
|
389
410
|
.removePool({})
|
390
411
|
.accounts({
|
391
|
-
admin: this.admin
|
412
|
+
admin: this.admin,
|
392
413
|
multisig: this.multisig.publicKey,
|
393
414
|
transferAuthority: this.authority.publicKey,
|
394
415
|
perpetuals: this.perpetuals.publicKey,
|
395
416
|
pool: this.getPoolKey(name),
|
396
417
|
systemProgram: web3_js_1.SystemProgram.programId,
|
397
418
|
})
|
398
|
-
.signers([this.admin])
|
419
|
+
// .signers([this.admin])
|
399
420
|
.rpc()
|
400
421
|
.catch(function (err) {
|
401
422
|
console.error(err);
|
@@ -429,7 +450,7 @@ var PerpetualsClient = /** @class */ (function () {
|
|
429
450
|
ratios: ratios,
|
430
451
|
})
|
431
452
|
.accounts({
|
432
|
-
admin: this.admin
|
453
|
+
admin: this.admin,
|
433
454
|
multisig: this.multisig.publicKey,
|
434
455
|
transferAuthority: this.authority.publicKey,
|
435
456
|
perpetuals: this.perpetuals.publicKey,
|
@@ -441,7 +462,7 @@ var PerpetualsClient = /** @class */ (function () {
|
|
441
462
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
442
463
|
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
443
464
|
})
|
444
|
-
.signers([this.admin])
|
465
|
+
// .signers([this.admin])
|
445
466
|
.rpc()
|
446
467
|
.catch(function (err) {
|
447
468
|
console.error(err);
|
@@ -478,7 +499,7 @@ var PerpetualsClient = /** @class */ (function () {
|
|
478
499
|
ratios: ratios,
|
479
500
|
})
|
480
501
|
.accounts({
|
481
|
-
admin: this.admin
|
502
|
+
admin: this.admin,
|
482
503
|
multisig: this.multisig.publicKey,
|
483
504
|
transferAuthority: this.authority.publicKey,
|
484
505
|
perpetuals: this.perpetuals.publicKey,
|
@@ -490,7 +511,7 @@ var PerpetualsClient = /** @class */ (function () {
|
|
490
511
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
491
512
|
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
492
513
|
})
|
493
|
-
.signers([this.admin])
|
514
|
+
// .signers([this.admin])
|
494
515
|
.rpc()
|
495
516
|
.catch(function (err) {
|
496
517
|
console.error(err);
|
@@ -509,7 +530,7 @@ var PerpetualsClient = /** @class */ (function () {
|
|
509
530
|
case 0: return [4 /*yield*/, this.program.methods
|
510
531
|
.removeCustody({ ratios: ratios })
|
511
532
|
.accounts({
|
512
|
-
admin: this.admin
|
533
|
+
admin: this.admin,
|
513
534
|
multisig: this.multisig.publicKey,
|
514
535
|
transferAuthority: this.authority.publicKey,
|
515
536
|
perpetuals: this.perpetuals.publicKey,
|
@@ -519,7 +540,7 @@ var PerpetualsClient = /** @class */ (function () {
|
|
519
540
|
systemProgram: web3_js_1.SystemProgram.programId,
|
520
541
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
521
542
|
})
|
522
|
-
.signers([this.admin])
|
543
|
+
// .signers([this.admin])
|
523
544
|
.rpc()
|
524
545
|
.catch(function (err) {
|
525
546
|
console.error(err);
|
@@ -537,13 +558,13 @@ var PerpetualsClient = /** @class */ (function () {
|
|
537
558
|
case 0: return [4 /*yield*/, this.program.methods
|
538
559
|
.upgradeCustody({})
|
539
560
|
.accounts({
|
540
|
-
admin: this.admin
|
561
|
+
admin: this.admin,
|
541
562
|
multisig: this.multisig.publicKey,
|
542
563
|
pool: this.getPoolKey(poolName),
|
543
564
|
custody: this.getCustodyKey(poolName, tokenMint),
|
544
565
|
systemProgram: web3_js_1.SystemProgram.programId,
|
545
566
|
})
|
546
|
-
.signers([this.admin])
|
567
|
+
// .signers([this.admin])
|
547
568
|
.rpc()
|
548
569
|
.catch(function (err) {
|
549
570
|
console.error(err);
|
@@ -992,14 +1013,24 @@ var PerpetualsClient = /** @class */ (function () {
|
|
992
1013
|
}
|
993
1014
|
});
|
994
1015
|
}); };
|
995
|
-
this.provider =
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
});
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1016
|
+
// this.provider = AnchorProvider.local(clusterUrl, {
|
1017
|
+
// commitment: "confirmed",
|
1018
|
+
// preflightCommitment: "confirmed",
|
1019
|
+
// skipPreflight: true
|
1020
|
+
// });
|
1021
|
+
// setProvider(this.provider);
|
1022
|
+
(0, anchor_1.setProvider)(provider);
|
1023
|
+
// const idl = JSON.parse( fs.readFileSync("./target/idl/perpetuals.json", "utf8"));
|
1024
|
+
// const idl = JSON.parse(IDL);
|
1025
|
+
// const program = new anchor.Program(idl, programId, provider);
|
1026
|
+
this.program = new anchor_1.Program(perpetuals_1.IDL, programId);
|
1027
|
+
//this.program = workspace.Perpetuals as Program<Perpetuals>;
|
1028
|
+
console.log("client constructor programID : ", this.program.programId.toBase58());
|
1029
|
+
// this.admin = Keypair.fromSecretKey(
|
1030
|
+
// new Uint8Array(JSON.parse(readFileSync(adminKey).toString()))
|
1031
|
+
// );
|
1032
|
+
this.admin = this.provider.wallet.publicKey;
|
1033
|
+
console.log("admin:", this.admin.toBase58());
|
1003
1034
|
this.multisig = this.findProgramAddress("multisig");
|
1004
1035
|
this.authority = this.findProgramAddress("transfer_authority");
|
1005
1036
|
this.perpetuals = this.findProgramAddress("perpetuals");
|
@@ -1010,4 +1041,3 @@ var PerpetualsClient = /** @class */ (function () {
|
|
1010
1041
|
return PerpetualsClient;
|
1011
1042
|
}());
|
1012
1043
|
exports.PerpetualsClient = PerpetualsClient;
|
1013
|
-
//# sourceMappingURL=PerpetualsClient.js.map
|
package/lib/client/src/index.js
CHANGED
@@ -20,5 +20,7 @@ __exportStar(require("./PositionAccount"), exports);
|
|
20
20
|
__exportStar(require("./OraclePrice"), exports);
|
21
21
|
__exportStar(require("./constants"), exports);
|
22
22
|
__exportStar(require("./types"), exports);
|
23
|
+
__exportStar(require("./utils"), exports);
|
23
24
|
__exportStar(require("./PerpetualsClient"), exports);
|
24
|
-
|
25
|
+
__exportStar(require("./PoolConfig"), exports);
|
26
|
+
// export { default as PoolConfigJson } from "./PoolConfig.json";
|
@@ -0,0 +1,130 @@
|
|
1
|
+
export type LimitOrderCpi = {
|
2
|
+
"version": "0.1.0";
|
3
|
+
"name": "limit_order_cpi";
|
4
|
+
"instructions": [
|
5
|
+
{
|
6
|
+
"name": "processMarketOrder";
|
7
|
+
"accounts": [
|
8
|
+
{
|
9
|
+
"name": "keeper";
|
10
|
+
"isMut": true;
|
11
|
+
"isSigner": true;
|
12
|
+
},
|
13
|
+
{
|
14
|
+
"name": "pdaAccount";
|
15
|
+
"isMut": true;
|
16
|
+
"isSigner": false;
|
17
|
+
},
|
18
|
+
{
|
19
|
+
"name": "pdaTokenVault";
|
20
|
+
"isMut": true;
|
21
|
+
"isSigner": false;
|
22
|
+
},
|
23
|
+
{
|
24
|
+
"name": "transferAuthority";
|
25
|
+
"isMut": false;
|
26
|
+
"isSigner": false;
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"name": "perpetuals";
|
30
|
+
"isMut": false;
|
31
|
+
"isSigner": false;
|
32
|
+
},
|
33
|
+
{
|
34
|
+
"name": "pool";
|
35
|
+
"isMut": true;
|
36
|
+
"isSigner": false;
|
37
|
+
},
|
38
|
+
{
|
39
|
+
"name": "position";
|
40
|
+
"isMut": true;
|
41
|
+
"isSigner": false;
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"name": "custody";
|
45
|
+
"isMut": true;
|
46
|
+
"isSigner": false;
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"name": "custodyOracleAccount";
|
50
|
+
"isMut": false;
|
51
|
+
"isSigner": false;
|
52
|
+
},
|
53
|
+
{
|
54
|
+
"name": "custodyTokenAccount";
|
55
|
+
"isMut": true;
|
56
|
+
"isSigner": false;
|
57
|
+
},
|
58
|
+
{
|
59
|
+
"name": "systemProgram";
|
60
|
+
"isMut": false;
|
61
|
+
"isSigner": false;
|
62
|
+
},
|
63
|
+
{
|
64
|
+
"name": "tokenProgram";
|
65
|
+
"isMut": false;
|
66
|
+
"isSigner": false;
|
67
|
+
},
|
68
|
+
{
|
69
|
+
"name": "flashProgram";
|
70
|
+
"isMut": false;
|
71
|
+
"isSigner": false;
|
72
|
+
}
|
73
|
+
];
|
74
|
+
"args": [
|
75
|
+
{
|
76
|
+
"name": "params";
|
77
|
+
"type": {
|
78
|
+
"defined": "OpenPositionParams";
|
79
|
+
};
|
80
|
+
}
|
81
|
+
];
|
82
|
+
}
|
83
|
+
];
|
84
|
+
"types": [
|
85
|
+
{
|
86
|
+
"name": "OpenPositionParams";
|
87
|
+
"type": {
|
88
|
+
"kind": "struct";
|
89
|
+
"fields": [
|
90
|
+
{
|
91
|
+
"name": "price";
|
92
|
+
"type": "u64";
|
93
|
+
},
|
94
|
+
{
|
95
|
+
"name": "collateral";
|
96
|
+
"type": "u64";
|
97
|
+
},
|
98
|
+
{
|
99
|
+
"name": "size";
|
100
|
+
"type": "u64";
|
101
|
+
},
|
102
|
+
{
|
103
|
+
"name": "side";
|
104
|
+
"type": {
|
105
|
+
"defined": "Side";
|
106
|
+
};
|
107
|
+
}
|
108
|
+
];
|
109
|
+
};
|
110
|
+
},
|
111
|
+
{
|
112
|
+
"name": "Side";
|
113
|
+
"type": {
|
114
|
+
"kind": "enum";
|
115
|
+
"variants": [
|
116
|
+
{
|
117
|
+
"name": "None";
|
118
|
+
},
|
119
|
+
{
|
120
|
+
"name": "Long";
|
121
|
+
},
|
122
|
+
{
|
123
|
+
"name": "Short";
|
124
|
+
}
|
125
|
+
];
|
126
|
+
};
|
127
|
+
}
|
128
|
+
];
|
129
|
+
};
|
130
|
+
export declare const IDL: LimitOrderCpi;
|