@symmetry-hq/temp-v3-sdk 0.0.2 → 0.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/dist/src/index.d.ts +8 -4
- package/dist/src/index.js +9 -9
- package/dist/src/instructions/automation/rebalanceSwap.js +2 -2
- package/dist/src/instructions/management/addBounty.js +1 -2
- package/dist/src/instructions/management/admin.js +1 -2
- package/dist/src/instructions/management/createBasket.js +2 -2
- package/dist/src/instructions/management/edit.js +3 -3
- package/dist/src/instructions/management/luts.js +4 -5
- package/dist/src/instructions/user/deposit.js +5 -5
- package/dist/src/instructions/user/withdraw.js +3 -3
- package/dist/src/layouts/basket.d.ts +11 -5
- package/dist/src/layouts/basket.js +2 -2
- package/dist/src/layouts/config.d.ts +0 -1
- package/dist/src/layouts/config.js +3 -6
- package/dist/src/layouts/fraction.d.ts +2 -2
- package/dist/src/layouts/fraction.js +2 -2
- package/dist/src/layouts/intents/bounty.d.ts +2 -2
- package/dist/src/layouts/intents/bounty.js +2 -2
- package/dist/src/layouts/intents/intent.d.ts +2 -9
- package/dist/src/layouts/intents/intent.js +0 -1
- package/dist/src/layouts/intents/rebalanceIntent.d.ts +3 -2
- package/dist/src/layouts/oracle.d.ts +18 -4
- package/dist/src/layouts/oracle.js +21 -1
- package/dist/src/states/basket.d.ts +3 -2
- package/dist/src/states/basket.js +15 -3
- package/dist/src/states/intents/intent.d.ts +2 -7
- package/dist/src/states/intents/intent.js +12 -16
- package/dist/src/states/intents/rebalanceIntent.d.ts +1 -0
- package/dist/src/states/intents/rebalanceIntent.js +14 -2
- package/dist/src/states/oracles/oracle.d.ts +3 -3
- package/dist/src/states/oracles/oracle.js +11 -5
- package/dist/src/states/oracles/raydiumCpmmOracle.d.ts +4 -2
- package/dist/src/states/oracles/raydiumCpmmOracle.js +10 -3
- package/dist/test.js +19 -6
- package/package.json +1 -1
- package/src/index.ts +26 -10
- package/src/instructions/automation/rebalanceSwap.ts +2 -2
- package/src/instructions/management/addBounty.ts +1 -2
- package/src/instructions/management/admin.ts +1 -2
- package/src/instructions/management/createBasket.ts +2 -2
- package/src/instructions/management/edit.ts +3 -3
- package/src/instructions/management/luts.ts +4 -5
- package/src/instructions/user/deposit.ts +5 -5
- package/src/instructions/user/withdraw.ts +3 -3
- package/src/layouts/basket.ts +13 -5
- package/src/layouts/config.ts +2 -6
- package/src/layouts/fraction.ts +4 -4
- package/src/layouts/intents/bounty.ts +4 -4
- package/src/layouts/intents/intent.ts +2 -10
- package/src/layouts/intents/rebalanceIntent.ts +4 -3
- package/src/layouts/oracle.ts +22 -5
- package/src/states/basket.ts +19 -5
- package/src/states/intents/intent.ts +12 -20
- package/src/states/intents/rebalanceIntent.ts +15 -3
- package/src/states/oracles/oracle.ts +13 -9
- package/src/states/oracles/raydiumCpmmOracle.ts +11 -2
- package/test.ts +20 -7
package/dist/src/index.d.ts
CHANGED
|
@@ -4,12 +4,15 @@ import { Basket } from './layouts/basket';
|
|
|
4
4
|
import { Fraction } from './layouts/fraction';
|
|
5
5
|
import { EditData, HostFees, Intent, MetadataParams, TaskType } from './layouts/intents/intent';
|
|
6
6
|
import { RebalanceIntent } from './layouts/intents/rebalanceIntent';
|
|
7
|
+
import { BasketFilter } from './states/basket';
|
|
8
|
+
import { IntentFilter } from './states/intents/intent';
|
|
9
|
+
import { RebalanceIntentFilter } from './states/intents/rebalanceIntent';
|
|
7
10
|
import { VersionedTxs, Wallet } from './txUtils';
|
|
8
11
|
export declare const COMPUTE_UNITS = 1000000;
|
|
9
12
|
export declare const PRIORITY_FEE = 100000;
|
|
10
13
|
export declare const JUPITER_API_KEY = "https://quote-api.jup.ag/v6/";
|
|
11
14
|
export declare const MAX_JUPITER_ACCOUNTS = 35;
|
|
12
|
-
export declare class
|
|
15
|
+
export declare class SymmetryCore {
|
|
13
16
|
private sdkParams;
|
|
14
17
|
constructor(params: {
|
|
15
18
|
connection: Connection;
|
|
@@ -22,9 +25,9 @@ export declare class BasketsSdk {
|
|
|
22
25
|
getBasket(params: {
|
|
23
26
|
basket: PublicKey;
|
|
24
27
|
}): Promise<Basket>;
|
|
25
|
-
fetchAllBaskets(): Promise<Basket[]>;
|
|
26
|
-
fetchAllIntents(): Promise<Intent[]>;
|
|
27
|
-
fetchAllRebalanceIntents(): Promise<RebalanceIntent[]>;
|
|
28
|
+
fetchAllBaskets(filters: BasketFilter[]): Promise<Basket[]>;
|
|
29
|
+
fetchAllIntents(filters: IntentFilter[]): Promise<Intent[]>;
|
|
30
|
+
fetchAllRebalanceIntents(filters: RebalanceIntentFilter[]): Promise<RebalanceIntent[]>;
|
|
28
31
|
createBasketTx(params: {
|
|
29
32
|
creator: PublicKey;
|
|
30
33
|
host: PublicKey;
|
|
@@ -51,3 +54,4 @@ export declare class BasketsSdk {
|
|
|
51
54
|
wallet: Wallet;
|
|
52
55
|
}): Promise<TransactionSignature[]>;
|
|
53
56
|
}
|
|
57
|
+
export { Basket, BasketFilter, Intent, IntentFilter, RebalanceIntent, RebalanceIntentFilter };
|
package/dist/src/index.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.SymmetryCore = exports.MAX_JUPITER_ACCOUNTS = exports.JUPITER_API_KEY = exports.PRIORITY_FEE = exports.COMPUTE_UNITS = void 0;
|
|
13
13
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
14
14
|
const web3_js_1 = require("@solana/web3.js");
|
|
15
15
|
const constants_1 = require("./constants");
|
|
@@ -24,7 +24,7 @@ exports.COMPUTE_UNITS = 1000000;
|
|
|
24
24
|
exports.PRIORITY_FEE = 100000;
|
|
25
25
|
exports.JUPITER_API_KEY = "https://quote-api.jup.ag/v6/";
|
|
26
26
|
exports.MAX_JUPITER_ACCOUNTS = 35;
|
|
27
|
-
class
|
|
27
|
+
class SymmetryCore {
|
|
28
28
|
constructor(params) {
|
|
29
29
|
var _a, _b, _c, _d;
|
|
30
30
|
this.sdkParams = {
|
|
@@ -46,21 +46,21 @@ class BasketsSdk {
|
|
|
46
46
|
return basketState;
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
-
fetchAllBaskets() {
|
|
49
|
+
fetchAllBaskets(filters) {
|
|
50
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
-
const baskets = yield (0, basket_1.fetchBaskets)(this.sdkParams.connection,
|
|
51
|
+
const baskets = yield (0, basket_1.fetchBaskets)(this.sdkParams.connection, filters);
|
|
52
52
|
return baskets;
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
|
-
fetchAllIntents() {
|
|
55
|
+
fetchAllIntents(filters) {
|
|
56
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
const intents = yield (0, intent_1.fetchIntents)(this.sdkParams.connection,
|
|
57
|
+
const intents = yield (0, intent_1.fetchIntents)(this.sdkParams.connection, filters);
|
|
58
58
|
return intents;
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
|
-
fetchAllRebalanceIntents() {
|
|
61
|
+
fetchAllRebalanceIntents(filters) {
|
|
62
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
const rebalanceIntents = yield (0, rebalanceIntent_1.fetchRebalanceIntents)(this.sdkParams.connection,
|
|
63
|
+
const rebalanceIntents = yield (0, rebalanceIntent_1.fetchRebalanceIntents)(this.sdkParams.connection, filters);
|
|
64
64
|
return rebalanceIntents;
|
|
65
65
|
});
|
|
66
66
|
}
|
|
@@ -196,4 +196,4 @@ class BasketsSdk {
|
|
|
196
196
|
});
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
-
exports.
|
|
199
|
+
exports.SymmetryCore = SymmetryCore;
|
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.rebalanceSwapIx = rebalanceSwapIx;
|
|
4
4
|
const web3_js_1 = require("@solana/web3.js");
|
|
5
5
|
const pda_1 = require("../pda");
|
|
6
|
-
const system_1 = require("@coral-xyz/anchor/dist/cjs/native/system");
|
|
7
6
|
const spl_token_1 = require("@solana/spl-token");
|
|
8
7
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
9
8
|
const constants_1 = require("../../constants");
|
|
9
|
+
const web3_js_2 = require("@solana/web3.js");
|
|
10
10
|
const REBALANCE_SWAP_DISCRIMINATOR = Buffer.from([101, 122, 61, 201, 21, 165, 177, 213]);
|
|
11
11
|
function rebalanceSwapIx(params) {
|
|
12
12
|
const { keeper, basket, mintFrom, mintTo, amount, side } = params;
|
|
@@ -25,7 +25,7 @@ function rebalanceSwapIx(params) {
|
|
|
25
25
|
{ pubkey: keeperToATA, isWritable: true, isSigner: false },
|
|
26
26
|
{ pubkey: basketFromATA, isWritable: true, isSigner: false },
|
|
27
27
|
{ pubkey: basketToATA, isWritable: true, isSigner: false },
|
|
28
|
-
{ pubkey:
|
|
28
|
+
{ pubkey: web3_js_2.SystemProgram.programId, isWritable: false, isSigner: false },
|
|
29
29
|
{ pubkey: spl_token_1.TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
30
30
|
{ pubkey: spl_token_1.TOKEN_2022_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
31
31
|
{ pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addBountyIx = addBountyIx;
|
|
4
4
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
5
|
-
const system_1 = require("@coral-xyz/anchor/dist/cjs/native/system");
|
|
6
5
|
const spl_token_1 = require("@solana/spl-token");
|
|
7
6
|
const web3_js_1 = require("@solana/web3.js");
|
|
8
7
|
const constants_1 = require("../../constants");
|
|
@@ -26,7 +25,7 @@ function addBountyIx(params) {
|
|
|
26
25
|
{ pubkey: bountyVault, isSigner: false, isWritable: true },
|
|
27
26
|
{ pubkey: bountyVaultAta, isSigner: false, isWritable: true },
|
|
28
27
|
{ pubkey: globalConfig, isSigner: false, isWritable: false },
|
|
29
|
-
{ pubkey:
|
|
28
|
+
{ pubkey: web3_js_1.SystemProgram.programId, isSigner: false, isWritable: false },
|
|
30
29
|
{ pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
31
30
|
{ pubkey: spl_token_1.TOKEN_2022_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
32
31
|
{ pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createGlobalConfigIx = createGlobalConfigIx;
|
|
4
4
|
exports.editGlobalConfigIx = editGlobalConfigIx;
|
|
5
|
-
const system_1 = require("@coral-xyz/anchor/dist/cjs/native/system");
|
|
6
5
|
const web3_js_1 = require("@solana/web3.js");
|
|
7
6
|
const constants_1 = require("../../constants");
|
|
8
7
|
const config_1 = require("../../layouts/config");
|
|
@@ -16,7 +15,7 @@ function createGlobalConfigIx(params) {
|
|
|
16
15
|
const keys = [
|
|
17
16
|
{ pubkey: admin, isSigner: true, isWritable: true },
|
|
18
17
|
{ pubkey: globalConfig, isSigner: false, isWritable: true },
|
|
19
|
-
{ pubkey:
|
|
18
|
+
{ pubkey: web3_js_1.SystemProgram.programId, isSigner: false, isWritable: false },
|
|
20
19
|
{ pubkey: web3_js_1.SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false },
|
|
21
20
|
];
|
|
22
21
|
return new web3_js_1.TransactionInstruction({
|
|
@@ -63,8 +63,8 @@ function createBasketIx(params) {
|
|
|
63
63
|
Buffer.from(seed),
|
|
64
64
|
Buffer.from(new anchor_1.BN(slot).toArray("le", 8)),
|
|
65
65
|
host.toBuffer(),
|
|
66
|
-
Buffer.from(startPrice.
|
|
67
|
-
Buffer.from(startPrice.
|
|
66
|
+
Buffer.from(startPrice.high.toArray("le", 8)),
|
|
67
|
+
Buffer.from(startPrice.low.toArray("le", 8)),
|
|
68
68
|
hostFeesBuffer,
|
|
69
69
|
(0, pda_1.serializeString)(metadataParams.name),
|
|
70
70
|
(0, pda_1.serializeString)(metadataParams.symbol),
|
|
@@ -8,9 +8,9 @@ const web3_js_1 = require("@solana/web3.js");
|
|
|
8
8
|
const constants_1 = require("../../constants");
|
|
9
9
|
const pda_1 = require("../pda");
|
|
10
10
|
const spl_token_1 = require("@solana/spl-token");
|
|
11
|
-
const system_1 = require("@coral-xyz/anchor/dist/cjs/native/system");
|
|
12
11
|
const config_1 = require("../../layouts/config");
|
|
13
12
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
13
|
+
const web3_js_2 = require("@solana/web3.js");
|
|
14
14
|
const EDIT_PRIVATE_BASKET_SETTINGS_DISCRIMINATOR = Buffer.from([202, 54, 138, 17, 3, 104, 128, 229]);
|
|
15
15
|
const CREATE_EDIT_BASKET_INTENT_DISCRIMINATOR = Buffer.from([82, 150, 58, 227, 153, 129, 20, 30]);
|
|
16
16
|
const EDIT_BASKET_DISCRIMINATOR = Buffer.from([156, 31, 4, 39, 248, 29, 55, 220]);
|
|
@@ -135,7 +135,7 @@ function createEditBasketIntentIx(params) {
|
|
|
135
135
|
{ pubkey: managerBountyATA, isSigner: false, isWritable: true },
|
|
136
136
|
{ pubkey: bountyVault, isSigner: false, isWritable: true },
|
|
137
137
|
{ pubkey: bountyVaultATA, isSigner: false, isWritable: true },
|
|
138
|
-
{ pubkey:
|
|
138
|
+
{ pubkey: web3_js_2.SystemProgram.programId, isSigner: false, isWritable: false },
|
|
139
139
|
{ pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
140
140
|
{ pubkey: spl_token_1.TOKEN_2022_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
141
141
|
{ pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
@@ -167,7 +167,7 @@ function editBasketIx(params) {
|
|
|
167
167
|
{ pubkey: managerBountyATA, isSigner: false, isWritable: true },
|
|
168
168
|
{ pubkey: bountyVault, isSigner: false, isWritable: true },
|
|
169
169
|
{ pubkey: bountyVaultATA, isSigner: false, isWritable: true },
|
|
170
|
-
{ pubkey:
|
|
170
|
+
{ pubkey: web3_js_2.SystemProgram.programId, isSigner: false, isWritable: false },
|
|
171
171
|
{ pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
172
172
|
{ pubkey: spl_token_1.TOKEN_2022_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
173
173
|
{ pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
@@ -5,7 +5,6 @@ exports.extendBasketLookupTablesIx = extendBasketLookupTablesIx;
|
|
|
5
5
|
exports.overwriteBasketLookupTablesIx = overwriteBasketLookupTablesIx;
|
|
6
6
|
exports.closeDeactivatedLookupTableIx = closeDeactivatedLookupTableIx;
|
|
7
7
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
8
|
-
const system_1 = require("@coral-xyz/anchor/dist/cjs/native/system");
|
|
9
8
|
const web3_js_1 = require("@solana/web3.js");
|
|
10
9
|
const constants_1 = require("../../constants");
|
|
11
10
|
const pda_1 = require("../pda");
|
|
@@ -31,7 +30,7 @@ function createBasketLookupTablesInstruction(params) {
|
|
|
31
30
|
{ pubkey: newTempLookupTableInfo0, isSigner: false, isWritable: true },
|
|
32
31
|
{ pubkey: newTempLookupTableInfo1, isSigner: false, isWritable: true },
|
|
33
32
|
{ pubkey: constants_1.ADDRESS_LOOKUP_TABLE_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
34
|
-
{ pubkey:
|
|
33
|
+
{ pubkey: web3_js_1.SystemProgram.programId, isSigner: false, isWritable: false },
|
|
35
34
|
];
|
|
36
35
|
return new web3_js_1.TransactionInstruction({
|
|
37
36
|
keys,
|
|
@@ -46,7 +45,7 @@ function extendBasketLookupTablesIx(params) {
|
|
|
46
45
|
{ pubkey: params.tempLookupTable0, isWritable: true, isSigner: false },
|
|
47
46
|
{ pubkey: params.tempLookupTable1, isWritable: true, isSigner: false },
|
|
48
47
|
{ pubkey: constants_1.ADDRESS_LOOKUP_TABLE_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
49
|
-
{ pubkey:
|
|
48
|
+
{ pubkey: web3_js_1.SystemProgram.programId, isWritable: false, isSigner: false },
|
|
50
49
|
];
|
|
51
50
|
return new web3_js_1.TransactionInstruction({
|
|
52
51
|
keys,
|
|
@@ -62,7 +61,7 @@ function overwriteBasketLookupTablesIx(params) {
|
|
|
62
61
|
{ pubkey: params.tempLookupTable1, isWritable: true, isSigner: false },
|
|
63
62
|
{ pubkey: params.activeLookupTable0, isWritable: true, isSigner: false },
|
|
64
63
|
{ pubkey: params.activeLookupTable1, isWritable: true, isSigner: false },
|
|
65
|
-
{ pubkey:
|
|
64
|
+
{ pubkey: web3_js_1.SystemProgram.programId, isWritable: false, isSigner: false },
|
|
66
65
|
];
|
|
67
66
|
return new web3_js_1.TransactionInstruction({
|
|
68
67
|
keys,
|
|
@@ -78,7 +77,7 @@ function closeDeactivatedLookupTableIx(params) {
|
|
|
78
77
|
{ pubkey: params.lookupTable, isWritable: true, isSigner: false },
|
|
79
78
|
{ pubkey: lookupTableInfo, isWritable: true, isSigner: false },
|
|
80
79
|
{ pubkey: constants_1.ADDRESS_LOOKUP_TABLE_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
81
|
-
{ pubkey:
|
|
80
|
+
{ pubkey: web3_js_1.SystemProgram.programId, isWritable: false, isSigner: false },
|
|
82
81
|
];
|
|
83
82
|
return new web3_js_1.TransactionInstruction({
|
|
84
83
|
keys,
|
|
@@ -11,8 +11,8 @@ const anchor_1 = require("@coral-xyz/anchor");
|
|
|
11
11
|
const constants_1 = require("../../constants");
|
|
12
12
|
const pda_1 = require("../pda");
|
|
13
13
|
const spl_token_1 = require("@solana/spl-token");
|
|
14
|
-
const system_1 = require("@coral-xyz/anchor/dist/cjs/native/system");
|
|
15
14
|
const web3_js_2 = require("@solana/web3.js");
|
|
15
|
+
const web3_js_3 = require("@solana/web3.js");
|
|
16
16
|
const CREATE_USER_REBALANCE_INTENT_ACCOUNT = Buffer.from([212, 23, 1, 46, 192, 87, 74, 196]);
|
|
17
17
|
const RESIZE_REBALANCE_INTENT_HANDLER = Buffer.from([71, 204, 243, 183, 209, 118, 111, 94]);
|
|
18
18
|
const CREATE_DEPOSIT_STATE_DISCRIMINATOR = Buffer.from([66, 42, 217, 222, 49, 159, 36, 188]);
|
|
@@ -32,7 +32,7 @@ function createUserRebalanceIntentIx(params) {
|
|
|
32
32
|
{ pubkey: globalConfig, isSigner: false, isWritable: true },
|
|
33
33
|
{ pubkey: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY, isSigner: false, isWritable: false },
|
|
34
34
|
{ pubkey: web3_js_1.SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false },
|
|
35
|
-
{ pubkey:
|
|
35
|
+
{ pubkey: web3_js_3.SystemProgram.programId, isSigner: false, isWritable: false }
|
|
36
36
|
];
|
|
37
37
|
const data = CREATE_USER_REBALANCE_INTENT_ACCOUNT;
|
|
38
38
|
return new web3_js_2.TransactionInstruction({
|
|
@@ -83,7 +83,7 @@ function depositStateIx(params) {
|
|
|
83
83
|
{ pubkey: buyerBountyAta, isSigner: false, isWritable: true },
|
|
84
84
|
{ pubkey: bountyVault, isSigner: false, isWritable: true },
|
|
85
85
|
{ pubkey: bountyVaultAta, isSigner: false, isWritable: true },
|
|
86
|
-
{ pubkey:
|
|
86
|
+
{ pubkey: web3_js_3.SystemProgram.programId, isSigner: false, isWritable: false },
|
|
87
87
|
{ pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
88
88
|
{ pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
89
89
|
// { pubkey: rebalanceIntent, isSigner: false, isWritable: true } // remaining accounts
|
|
@@ -107,7 +107,7 @@ function depositTokensIx(params) {
|
|
|
107
107
|
{ pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
108
108
|
{ pubkey: spl_token_1.TOKEN_2022_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
109
109
|
{ pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
110
|
-
{ pubkey:
|
|
110
|
+
{ pubkey: web3_js_3.SystemProgram.programId, isSigner: false, isWritable: false },
|
|
111
111
|
];
|
|
112
112
|
// remaining accounts
|
|
113
113
|
contributions.forEach((contribution) => {
|
|
@@ -158,7 +158,7 @@ function mintBasketIx(params) {
|
|
|
158
158
|
{ pubkey: spl_token_1.TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
159
159
|
{ pubkey: spl_token_1.TOKEN_2022_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
160
160
|
{ pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isWritable: false, isSigner: false },
|
|
161
|
-
{ pubkey:
|
|
161
|
+
{ pubkey: web3_js_3.SystemProgram.programId, isWritable: false, isSigner: false },
|
|
162
162
|
];
|
|
163
163
|
return new web3_js_2.TransactionInstruction({
|
|
164
164
|
keys,
|
|
@@ -6,8 +6,8 @@ const constants_1 = require("../../constants");
|
|
|
6
6
|
const spl_token_1 = require("@solana/spl-token");
|
|
7
7
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
8
8
|
const pda_1 = require("../pda");
|
|
9
|
-
const system_1 = require("@coral-xyz/anchor/dist/cjs/native/system");
|
|
10
9
|
const web3_js_1 = require("@solana/web3.js");
|
|
10
|
+
const web3_js_2 = require("@solana/web3.js");
|
|
11
11
|
const CREATE_WITHDRAW_STATE_DISCRIMINATOR = Buffer.from([161, 45, 253, 59, 110, 240, 65, 3]);
|
|
12
12
|
const REDEEM_TOKENS_DISCRIMINATOR = Buffer.from([83, 49, 112, 2, 105, 193, 106, 126]);
|
|
13
13
|
function createWithdrawStateIx(params) {
|
|
@@ -40,7 +40,7 @@ function createWithdrawStateIx(params) {
|
|
|
40
40
|
{ pubkey: sellerBountyAta, isSigner: false, isWritable: true },
|
|
41
41
|
{ pubkey: bountyVault, isSigner: false, isWritable: true },
|
|
42
42
|
{ pubkey: bountyVaultAta, isSigner: false, isWritable: true },
|
|
43
|
-
{ pubkey:
|
|
43
|
+
{ pubkey: web3_js_2.SystemProgram.programId, isSigner: false, isWritable: false },
|
|
44
44
|
{ pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
45
45
|
{ pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
46
46
|
{ pubkey: rebalanceIntent, isSigner: false, isWritable: false } // remaining accounts
|
|
@@ -62,7 +62,7 @@ function redeemTokensIx(params) {
|
|
|
62
62
|
{ pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
63
63
|
{ pubkey: spl_token_1.TOKEN_2022_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
64
64
|
{ pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
65
|
-
{ pubkey:
|
|
65
|
+
{ pubkey: web3_js_2.SystemProgram.programId, isSigner: false, isWritable: false },
|
|
66
66
|
];
|
|
67
67
|
// remaining accounts
|
|
68
68
|
params.tokenMints.forEach((mint) => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { BN } from
|
|
2
|
-
import { PublicKey } from
|
|
3
|
-
import {
|
|
4
|
-
import { Fraction } from
|
|
5
|
-
import {
|
|
1
|
+
import { BN } from '@coral-xyz/anchor';
|
|
2
|
+
import { PublicKey } from '@solana/web3.js';
|
|
3
|
+
import { BasketSettings } from './config';
|
|
4
|
+
import { Fraction } from './fraction';
|
|
5
|
+
import { OracleAggregator } from './oracle';
|
|
6
6
|
export declare const MAX_SUPPORTED_TOKENS_PER_BASKET: number;
|
|
7
7
|
export interface BasketFees {
|
|
8
8
|
symmetryFees: BN;
|
|
@@ -23,6 +23,11 @@ export interface Asset {
|
|
|
23
23
|
oracleAggregator: OracleAggregator;
|
|
24
24
|
}
|
|
25
25
|
export declare const AssetLayout: any;
|
|
26
|
+
export interface Metadata {
|
|
27
|
+
symbol: string;
|
|
28
|
+
name: string;
|
|
29
|
+
uri: string;
|
|
30
|
+
}
|
|
26
31
|
export interface Basket {
|
|
27
32
|
version: number;
|
|
28
33
|
seedArray: number[];
|
|
@@ -37,5 +42,6 @@ export interface Basket {
|
|
|
37
42
|
writeVersion: BN;
|
|
38
43
|
numTokens: number;
|
|
39
44
|
composition: Asset[];
|
|
45
|
+
metadata?: Metadata;
|
|
40
46
|
}
|
|
41
47
|
export declare const BasketLayout: any;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BasketLayout = exports.AssetLayout = exports.LookupTablesLayout = exports.BasketFeesLayout = exports.MAX_SUPPORTED_TOKENS_PER_BASKET = void 0;
|
|
4
4
|
const borsh_1 = require("@coral-xyz/borsh");
|
|
5
|
-
const oracle_1 = require("./oracle");
|
|
6
|
-
const fraction_1 = require("./fraction");
|
|
7
5
|
const config_1 = require("./config");
|
|
6
|
+
const fraction_1 = require("./fraction");
|
|
7
|
+
const oracle_1 = require("./oracle");
|
|
8
8
|
exports.MAX_SUPPORTED_TOKENS_PER_BASKET = 100;
|
|
9
9
|
;
|
|
10
10
|
exports.BasketFeesLayout = (0, borsh_1.struct)([
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GlobalConfigLayout = exports.BasketSettingsLayout = exports.MetadataSettingsLayout = exports.LpSettingsLayout = exports.AutomationSettingsLayout = exports.ManagerSettingsLayout = exports.FeeSettingsLayout = exports.ScheduleSettingsLayout = exports.
|
|
3
|
+
exports.GlobalConfigLayout = exports.BasketSettingsLayout = exports.MetadataSettingsLayout = exports.LpSettingsLayout = exports.AutomationSettingsLayout = exports.ManagerSettingsLayout = exports.FeeSettingsLayout = exports.ScheduleSettingsLayout = exports.BasketType = exports.MAX_URI_LENGTH = exports.MAX_NAME_LENGTH = exports.MAX_SYMBOL_LENGTH = exports.MAX_MANAGERS_PER_BASKET = void 0;
|
|
4
4
|
const borsh_1 = require("@coral-xyz/borsh");
|
|
5
5
|
const fraction_1 = require("./fraction");
|
|
6
6
|
const bounty_1 = require("./intents/bounty");
|
|
@@ -14,9 +14,6 @@ var BasketType;
|
|
|
14
14
|
BasketType[BasketType["Public"] = 1] = "Public";
|
|
15
15
|
})(BasketType || (exports.BasketType = BasketType = {}));
|
|
16
16
|
;
|
|
17
|
-
exports.BasketTypeLayout = (0, borsh_1.struct)([
|
|
18
|
-
(0, borsh_1.u8)('basketType'),
|
|
19
|
-
]);
|
|
20
17
|
;
|
|
21
18
|
exports.ScheduleSettingsLayout = (0, borsh_1.struct)([
|
|
22
19
|
(0, borsh_1.u64)('cycleDuration'),
|
|
@@ -30,6 +27,7 @@ exports.ScheduleSettingsLayout = (0, borsh_1.struct)([
|
|
|
30
27
|
]);
|
|
31
28
|
;
|
|
32
29
|
exports.FeeSettingsLayout = (0, borsh_1.struct)([
|
|
30
|
+
(0, borsh_1.u64)('modificationDelay'),
|
|
33
31
|
(0, borsh_1.u16)('hostDepositFeeBps'),
|
|
34
32
|
(0, borsh_1.u16)('hostManagementFeeBps'),
|
|
35
33
|
(0, borsh_1.u16)('hostPerformanceFeeBps'),
|
|
@@ -41,7 +39,6 @@ exports.FeeSettingsLayout = (0, borsh_1.struct)([
|
|
|
41
39
|
(0, borsh_1.u16)('managersPerformanceFeeBps'),
|
|
42
40
|
(0, borsh_1.u16)('basketDepositFeeBps'),
|
|
43
41
|
(0, borsh_1.u16)('basketWithdrawFeeBps'),
|
|
44
|
-
(0, borsh_1.u64)('modificationDelay'),
|
|
45
42
|
]);
|
|
46
43
|
exports.ManagerSettingsLayout = (0, borsh_1.struct)([
|
|
47
44
|
(0, borsh_1.array)((0, borsh_1.publicKey)(), exports.MAX_MANAGERS_PER_BASKET, 'managers'),
|
|
@@ -76,7 +73,7 @@ exports.MetadataSettingsLayout = (0, borsh_1.struct)([
|
|
|
76
73
|
exports.BasketSettingsLayout = (0, borsh_1.struct)([
|
|
77
74
|
(0, borsh_1.publicKey)('creator'),
|
|
78
75
|
(0, borsh_1.publicKey)('host'),
|
|
79
|
-
|
|
76
|
+
(0, borsh_1.u8)('basketType'),
|
|
80
77
|
fraction_1.FractionLayout.replicate('startPrice'),
|
|
81
78
|
(0, borsh_1.u64)('activeRebalance'),
|
|
82
79
|
(0, borsh_1.u64)('activeDeposits'),
|
|
@@ -10,9 +10,9 @@ export declare const BountyScheduleLayout: any;
|
|
|
10
10
|
export interface Bounty {
|
|
11
11
|
bountyDepositor: PublicKey;
|
|
12
12
|
bountyMint: PublicKey;
|
|
13
|
-
bountyTotal: BN;
|
|
14
|
-
bountyLeft: BN;
|
|
15
13
|
bountyPerPriceUpdateTask: BountySchedule;
|
|
16
14
|
bountyPerTask: BountySchedule;
|
|
15
|
+
bountyTotal: BN;
|
|
16
|
+
bountyLeft: BN;
|
|
17
17
|
}
|
|
18
18
|
export declare const BountyLayout: any;
|
|
@@ -12,8 +12,8 @@ exports.BountyScheduleLayout = (0, borsh_1.struct)([
|
|
|
12
12
|
exports.BountyLayout = (0, borsh_1.struct)([
|
|
13
13
|
(0, borsh_1.publicKey)('bountyDepositor'),
|
|
14
14
|
(0, borsh_1.publicKey)('bountyMint'),
|
|
15
|
+
exports.BountyScheduleLayout.replicate('bountyPerPriceUpdateTask'),
|
|
16
|
+
exports.BountyScheduleLayout.replicate('bountyPerTask'),
|
|
15
17
|
(0, borsh_1.u64)('bountyTotal'),
|
|
16
18
|
(0, borsh_1.u64)('bountyLeft'),
|
|
17
|
-
exports.BountyScheduleLayout.replicate('bountyPerPriceUpdateTask'),
|
|
18
|
-
exports.BountyScheduleLayout.replicate('bountyPerTask')
|
|
19
19
|
]);
|
|
@@ -10,15 +10,6 @@ export declare enum IntentStatus {
|
|
|
10
10
|
Reverted = 2,
|
|
11
11
|
Completed = 3
|
|
12
12
|
}
|
|
13
|
-
export interface ParsedIntent {
|
|
14
|
-
manager: PublicKey;
|
|
15
|
-
status: IntentStatus;
|
|
16
|
-
activationTimestamp: BN;
|
|
17
|
-
basket: PublicKey;
|
|
18
|
-
bounty: Bounty;
|
|
19
|
-
taskType: TaskType;
|
|
20
|
-
taskData: EditData;
|
|
21
|
-
}
|
|
22
13
|
export interface Intent {
|
|
23
14
|
manager: PublicKey;
|
|
24
15
|
status: IntentStatus;
|
|
@@ -27,6 +18,8 @@ export interface Intent {
|
|
|
27
18
|
bounty: Bounty;
|
|
28
19
|
taskType: TaskType;
|
|
29
20
|
taskData: number[];
|
|
21
|
+
parsedTaskData?: EditData;
|
|
22
|
+
ownAddress?: PublicKey;
|
|
30
23
|
}
|
|
31
24
|
export declare const IntentLayout: any;
|
|
32
25
|
export interface HostFees {
|
|
@@ -2,7 +2,7 @@ import { BN } from "@coral-xyz/anchor";
|
|
|
2
2
|
import { PublicKey } from "@solana/web3.js";
|
|
3
3
|
import { Fraction } from "../fraction";
|
|
4
4
|
import { Bounty } from "./bounty";
|
|
5
|
-
import {
|
|
5
|
+
import { OraclePriceOnChain } from "../oracle";
|
|
6
6
|
export declare enum RebalanceType {
|
|
7
7
|
Deposit = 0,
|
|
8
8
|
Withdraw = 1,
|
|
@@ -23,7 +23,7 @@ export interface TokenAuction {
|
|
|
23
23
|
mint: PublicKey;
|
|
24
24
|
amount: BN;
|
|
25
25
|
targetAmount: BN;
|
|
26
|
-
price:
|
|
26
|
+
price: OraclePriceOnChain;
|
|
27
27
|
keepToken: number;
|
|
28
28
|
}
|
|
29
29
|
export declare const TokenAuctionLayout: any;
|
|
@@ -52,5 +52,6 @@ export interface RebalanceIntent {
|
|
|
52
52
|
finishPriceUpdateTask: TaskCompletion;
|
|
53
53
|
mintBasketTask: TaskCompletion;
|
|
54
54
|
tokenSettlementTasks: TaskCompletion[];
|
|
55
|
+
ownAddress?: PublicKey;
|
|
55
56
|
}
|
|
56
57
|
export declare const RebalanceIntentLayout: any;
|
|
@@ -2,14 +2,28 @@ import { BN } from "@coral-xyz/anchor";
|
|
|
2
2
|
import { Fraction } from "./fraction";
|
|
3
3
|
export declare const MAX_ORACLES_PER_TOKEN = 4;
|
|
4
4
|
export declare const MAX_ACCOUNTS_PER_ORACLE = 4;
|
|
5
|
-
export interface
|
|
5
|
+
export interface OraclePriceOnChain {
|
|
6
6
|
price: Fraction;
|
|
7
7
|
conf: Fraction;
|
|
8
8
|
updateTime: BN;
|
|
9
9
|
}
|
|
10
10
|
export declare const OraclePriceLayout: any;
|
|
11
|
+
export declare enum OracleType {
|
|
12
|
+
Example = 0,
|
|
13
|
+
Pyth = 1,
|
|
14
|
+
RaydiumCllm = 2,
|
|
15
|
+
RaydiumCpmm = 3
|
|
16
|
+
}
|
|
17
|
+
export declare enum Quote {
|
|
18
|
+
Usdc = 0,
|
|
19
|
+
Wsol = 1
|
|
20
|
+
}
|
|
21
|
+
export declare enum Side {
|
|
22
|
+
Base = 0,
|
|
23
|
+
Quote = 1
|
|
24
|
+
}
|
|
11
25
|
export interface OracleSettings {
|
|
12
|
-
oracleType:
|
|
26
|
+
oracleType: OracleType;
|
|
13
27
|
numRequiredAccounts: number;
|
|
14
28
|
weight: number;
|
|
15
29
|
isRequired: number;
|
|
@@ -21,8 +35,8 @@ export interface OracleSettings {
|
|
|
21
35
|
tokenDecimals: number;
|
|
22
36
|
twapSecondsAgo: BN;
|
|
23
37
|
twapSecondarySecondsAgo: BN;
|
|
24
|
-
quote:
|
|
25
|
-
side:
|
|
38
|
+
quote: Quote;
|
|
39
|
+
side: Side;
|
|
26
40
|
}
|
|
27
41
|
export declare const OracleSettingsLayout: any;
|
|
28
42
|
export interface OracleData {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OracleAggregatorLayout = exports.OracleDataLayout = exports.OracleSettingsLayout = exports.OraclePriceLayout = exports.MAX_ACCOUNTS_PER_ORACLE = exports.MAX_ORACLES_PER_TOKEN = void 0;
|
|
3
|
+
exports.OracleAggregatorLayout = exports.OracleDataLayout = exports.OracleSettingsLayout = exports.Side = exports.Quote = exports.OracleType = exports.OraclePriceLayout = exports.MAX_ACCOUNTS_PER_ORACLE = exports.MAX_ORACLES_PER_TOKEN = void 0;
|
|
4
4
|
const borsh_1 = require("@coral-xyz/borsh");
|
|
5
5
|
const fraction_1 = require("./fraction");
|
|
6
6
|
exports.MAX_ORACLES_PER_TOKEN = 4;
|
|
@@ -11,6 +11,26 @@ exports.OraclePriceLayout = (0, borsh_1.struct)([
|
|
|
11
11
|
fraction_1.FractionLayout.replicate('conf'),
|
|
12
12
|
(0, borsh_1.u64)('updateTime'),
|
|
13
13
|
]);
|
|
14
|
+
var OracleType;
|
|
15
|
+
(function (OracleType) {
|
|
16
|
+
OracleType[OracleType["Example"] = 0] = "Example";
|
|
17
|
+
OracleType[OracleType["Pyth"] = 1] = "Pyth";
|
|
18
|
+
OracleType[OracleType["RaydiumCllm"] = 2] = "RaydiumCllm";
|
|
19
|
+
OracleType[OracleType["RaydiumCpmm"] = 3] = "RaydiumCpmm";
|
|
20
|
+
})(OracleType || (exports.OracleType = OracleType = {}));
|
|
21
|
+
;
|
|
22
|
+
var Quote;
|
|
23
|
+
(function (Quote) {
|
|
24
|
+
Quote[Quote["Usdc"] = 0] = "Usdc";
|
|
25
|
+
Quote[Quote["Wsol"] = 1] = "Wsol";
|
|
26
|
+
})(Quote || (exports.Quote = Quote = {}));
|
|
27
|
+
;
|
|
28
|
+
var Side;
|
|
29
|
+
(function (Side) {
|
|
30
|
+
Side[Side["Base"] = 0] = "Base";
|
|
31
|
+
Side[Side["Quote"] = 1] = "Quote";
|
|
32
|
+
})(Side || (exports.Side = Side = {}));
|
|
33
|
+
;
|
|
14
34
|
exports.OracleSettingsLayout = (0, borsh_1.struct)([
|
|
15
35
|
(0, borsh_1.u8)('oracleType'),
|
|
16
36
|
(0, borsh_1.u8)('numRequiredAccounts'),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Connection, PublicKey } from
|
|
2
|
-
import { Basket } from
|
|
1
|
+
import { Connection, PublicKey } from '@solana/web3.js';
|
|
2
|
+
import { Basket } from '../layouts/basket';
|
|
3
|
+
export declare function decodeBasket(dataWithoutDiscriminator: Buffer): Basket;
|
|
3
4
|
export declare function fetchBasket(connection: Connection, basketAddress: PublicKey): Promise<Basket>;
|
|
4
5
|
export interface BasketFilter {
|
|
5
6
|
filterType: "host" | "creator";
|
|
@@ -9,17 +9,29 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.decodeBasket = decodeBasket;
|
|
12
13
|
exports.fetchBasket = fetchBasket;
|
|
13
14
|
exports.fetchBaskets = fetchBaskets;
|
|
14
|
-
const basket_1 = require("../layouts/basket");
|
|
15
15
|
const constants_1 = require("../constants");
|
|
16
|
+
const basket_1 = require("../layouts/basket");
|
|
17
|
+
function decodeBasket(dataWithoutDiscriminator) {
|
|
18
|
+
let basket = basket_1.BasketLayout.decode(dataWithoutDiscriminator);
|
|
19
|
+
let metadataSettings = basket.settings.metadataSettings;
|
|
20
|
+
let metadata = {
|
|
21
|
+
symbol: Buffer.from(metadataSettings.symbol.slice(0, metadataSettings.symbolLength)).toString(),
|
|
22
|
+
name: Buffer.from(metadataSettings.name.slice(0, metadataSettings.nameLength)).toString(),
|
|
23
|
+
uri: Buffer.from(metadataSettings.uri.slice(0, metadataSettings.uriLength)).toString()
|
|
24
|
+
};
|
|
25
|
+
basket.composition = basket.composition.slice(0, basket.numTokens);
|
|
26
|
+
return Object.assign(Object.assign({}, basket), { metadata: metadata });
|
|
27
|
+
}
|
|
16
28
|
function fetchBasket(connection, basketAddress) {
|
|
17
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
30
|
const basketAi = yield connection.getAccountInfo(basketAddress);
|
|
19
31
|
if (!basketAi) {
|
|
20
32
|
throw new Error("Basket not found");
|
|
21
33
|
}
|
|
22
|
-
return
|
|
34
|
+
return decodeBasket(basketAi.data.slice(8));
|
|
23
35
|
});
|
|
24
36
|
}
|
|
25
37
|
function fetchBaskets(connection, filters) {
|
|
@@ -48,7 +60,7 @@ function fetchBaskets(connection, filters) {
|
|
|
48
60
|
filters: accountFilters,
|
|
49
61
|
encoding: 'base64'
|
|
50
62
|
});
|
|
51
|
-
const baskets = accounts.map(account =>
|
|
63
|
+
const baskets = accounts.map(account => decodeBasket(account.account.data.slice(8)));
|
|
52
64
|
return baskets;
|
|
53
65
|
});
|
|
54
66
|
}
|