@triadxyz/triad-protocol 0.5.3-beta.devnet → 0.5.4-beta.devnet
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/index.d.ts +3 -5
- package/dist/index.js +17 -9
- package/dist/{test.js → local-test.js} +2 -2
- package/dist/stake.d.ts +14 -13
- package/dist/stake.js +51 -87
- package/dist/trade.d.ts +17 -0
- package/dist/trade.js +77 -0
- package/dist/types/idl_triad_protocol.json +312 -201
- package/dist/types/index.d.ts +1 -14
- package/dist/types/stake.d.ts +0 -4
- package/dist/types/trade.d.ts +22 -0
- package/dist/types/trade.js +2 -0
- package/dist/types/triad_protocol.d.ts +1487 -527
- package/dist/utils/constants.d.ts +5 -3
- package/dist/utils/constants.js +6 -4
- package/package.json +2 -3
- package/dist/ticker.d.ts +0 -33
- package/dist/ticker.js +0 -43
- package/dist/vault.d.ts +0 -48
- package/dist/vault.js +0 -44
- /package/dist/{test.d.ts → local-test.d.ts} +0 -0
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { PublicKey } from '@solana/web3.js';
|
|
2
2
|
export declare const STAKE_VAULT_NAME = "Triad Share 1";
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
3
|
+
export declare const TRD_DECIMALS = 6;
|
|
4
|
+
export declare const VERIFIER: PublicKey;
|
|
5
|
+
export declare const TRD_MINT: PublicKey;
|
|
6
|
+
export declare const TRIAD_ADMIN: PublicKey;
|
package/dist/utils/constants.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
3
|
+
exports.TRIAD_ADMIN = exports.TRD_MINT = exports.VERIFIER = exports.TRD_DECIMALS = exports.STAKE_VAULT_NAME = void 0;
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
5
5
|
exports.STAKE_VAULT_NAME = 'Triad Share 1';
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
6
|
+
exports.TRD_DECIMALS = 6;
|
|
7
|
+
exports.VERIFIER = new web3_js_1.PublicKey('42n6BHufivUKrb5Bi6tXbMZvM8NHovrDLX1Rt5w2a919');
|
|
8
|
+
exports.TRD_MINT = new web3_js_1.PublicKey('t3DohmswhKk94PPbPYwA6ZKACyY3y5kbcqeQerAJjmV');
|
|
9
|
+
exports.TRIAD_ADMIN = new web3_js_1.PublicKey('82ppCojm3yrEKgdpH8B5AmBJTU1r1uAWXFWhxvPs9UCR');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@triadxyz/triad-protocol",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4-beta.devnet",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
"clean": "rimraf dist",
|
|
9
9
|
"build": "yarn run clean && tsc",
|
|
10
10
|
"prepublishOnly": "yarn build",
|
|
11
|
-
"
|
|
12
|
-
"test": "rimraf dist && tsc && node ./dist/test.js"
|
|
11
|
+
"test": "rimraf dist && tsc && node ./dist/local-test.ts"
|
|
13
12
|
},
|
|
14
13
|
"publishConfig": {
|
|
15
14
|
"access": "public"
|
package/dist/ticker.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/// <reference types="bn.js" />
|
|
2
|
-
import { AnchorProvider, Program } from '@coral-xyz/anchor';
|
|
3
|
-
import { PublicKey } from '@solana/web3.js';
|
|
4
|
-
import { TriadProtocol } from './types/triad_protocol';
|
|
5
|
-
export default class Ticker {
|
|
6
|
-
program: Program<TriadProtocol>;
|
|
7
|
-
provider: AnchorProvider;
|
|
8
|
-
constructor(program: Program<TriadProtocol>, provider: AnchorProvider);
|
|
9
|
-
/**
|
|
10
|
-
* Get all tickers
|
|
11
|
-
*/
|
|
12
|
-
getTickers(): Promise<import("@coral-xyz/anchor").ProgramAccount<{
|
|
13
|
-
initTs: import("bn.js");
|
|
14
|
-
updatedTs: import("bn.js");
|
|
15
|
-
bump: number;
|
|
16
|
-
authority: PublicKey;
|
|
17
|
-
name: string;
|
|
18
|
-
protocolProgramId: PublicKey;
|
|
19
|
-
price: import("bn.js");
|
|
20
|
-
vault: PublicKey;
|
|
21
|
-
}>[]>;
|
|
22
|
-
/**
|
|
23
|
-
* Create a new ticker
|
|
24
|
-
* @param name - The ticker's name
|
|
25
|
-
* @param token mint - Token mint for the ticker (e.g. USDC)
|
|
26
|
-
*
|
|
27
|
-
*/
|
|
28
|
-
createTicker({ name, tokenMint }: {
|
|
29
|
-
name: string;
|
|
30
|
-
protocolProgramId: PublicKey;
|
|
31
|
-
tokenMint: PublicKey;
|
|
32
|
-
}): Promise<string>;
|
|
33
|
-
}
|
package/dist/ticker.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
class Ticker {
|
|
13
|
-
constructor(program, provider) {
|
|
14
|
-
this.provider = provider;
|
|
15
|
-
this.program = program;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Get all tickers
|
|
19
|
-
*/
|
|
20
|
-
getTickers() {
|
|
21
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
return this.program.account.ticker.all();
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Create a new ticker
|
|
27
|
-
* @param name - The ticker's name
|
|
28
|
-
* @param token mint - Token mint for the ticker (e.g. USDC)
|
|
29
|
-
*
|
|
30
|
-
*/
|
|
31
|
-
createTicker({ name, tokenMint }) {
|
|
32
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
return this.program.methods
|
|
34
|
-
.createTicker({ name })
|
|
35
|
-
.accounts({
|
|
36
|
-
signer: this.provider.wallet.publicKey,
|
|
37
|
-
payerTokenMint: tokenMint
|
|
38
|
-
})
|
|
39
|
-
.rpc();
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.default = Ticker;
|
package/dist/vault.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/// <reference types="bn.js" />
|
|
2
|
-
import { AnchorProvider, BN, Program } from '@coral-xyz/anchor';
|
|
3
|
-
import { PublicKey } from '@solana/web3.js';
|
|
4
|
-
import { TriadProtocol } from './types/triad_protocol';
|
|
5
|
-
export default class Vault {
|
|
6
|
-
program: Program<TriadProtocol>;
|
|
7
|
-
provider: AnchorProvider;
|
|
8
|
-
constructor(program: Program<TriadProtocol>, provider: AnchorProvider);
|
|
9
|
-
/**
|
|
10
|
-
* Get all vaults
|
|
11
|
-
*/
|
|
12
|
-
getVaults(): Promise<import("@coral-xyz/anchor").ProgramAccount<{
|
|
13
|
-
bump: number;
|
|
14
|
-
authority: PublicKey;
|
|
15
|
-
name: string;
|
|
16
|
-
tokenAccount: PublicKey;
|
|
17
|
-
tickerAddress: PublicKey;
|
|
18
|
-
totalDeposited: BN;
|
|
19
|
-
totalWithdrawn: BN;
|
|
20
|
-
initTs: BN;
|
|
21
|
-
netDeposits: BN;
|
|
22
|
-
netWithdraws: BN;
|
|
23
|
-
longBalance: BN;
|
|
24
|
-
shortBalance: BN;
|
|
25
|
-
longPositionsOpened: BN;
|
|
26
|
-
shortPositionsOpened: BN;
|
|
27
|
-
}>[]>;
|
|
28
|
-
/**
|
|
29
|
-
* Get vault by ticker Address
|
|
30
|
-
*/
|
|
31
|
-
getVaultByTickerAddress(tickerAddress: PublicKey): Promise<{
|
|
32
|
-
tvl: number;
|
|
33
|
-
bump: number;
|
|
34
|
-
authority: PublicKey;
|
|
35
|
-
name: string;
|
|
36
|
-
tokenAccount: PublicKey;
|
|
37
|
-
tickerAddress: PublicKey;
|
|
38
|
-
totalDeposited: BN;
|
|
39
|
-
totalWithdrawn: BN;
|
|
40
|
-
initTs: BN;
|
|
41
|
-
netDeposits: BN;
|
|
42
|
-
netWithdraws: BN;
|
|
43
|
-
longBalance: BN;
|
|
44
|
-
shortBalance: BN;
|
|
45
|
-
longPositionsOpened: BN;
|
|
46
|
-
shortPositionsOpened: BN;
|
|
47
|
-
}>;
|
|
48
|
-
}
|
package/dist/vault.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const helpers_1 = require("./utils/helpers");
|
|
13
|
-
const spl_token_1 = require("@solana/spl-token");
|
|
14
|
-
class Vault {
|
|
15
|
-
constructor(program, provider) {
|
|
16
|
-
this.provider = provider;
|
|
17
|
-
this.program = program;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Get all vaults
|
|
21
|
-
*/
|
|
22
|
-
getVaults() {
|
|
23
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
return this.program.account.vault.all();
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Get vault by ticker Address
|
|
29
|
-
*/
|
|
30
|
-
getVaultByTickerAddress(tickerAddress) {
|
|
31
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
const VaultPDA = (0, helpers_1.getVaultAddressSync)(this.program.programId, tickerAddress);
|
|
33
|
-
try {
|
|
34
|
-
const vault = yield this.program.account.vault.fetch(VaultPDA);
|
|
35
|
-
const tokenAcc = yield (0, spl_token_1.getAccount)(this.provider.connection, vault.tokenAccount);
|
|
36
|
-
return Object.assign(Object.assign({}, vault), { tvl: (0, helpers_1.formatNumber)(tokenAcc.amount) });
|
|
37
|
-
}
|
|
38
|
-
catch (e) {
|
|
39
|
-
throw new Error(e);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.default = Vault;
|
|
File without changes
|