@triadxyz/triad-protocol 0.5.2-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 +313 -202
- 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 +1488 -528
- package/dist/utils/constants.d.ts +5 -9
- package/dist/utils/constants.js +6 -10
- package/dist/utils/helpers.d.ts +0 -2
- package/dist/utils/helpers.js +2 -13
- 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,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const ATA_PROGRAM_ID = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
3
|
-
export declare const ADMIN = "";
|
|
4
|
-
export declare const VERIFIER = "42n6BHufivUKrb5Bi6tXbMZvM8NHovrDLX1Rt5w2a919";
|
|
1
|
+
import { PublicKey } from '@solana/web3.js';
|
|
5
2
|
export declare const STAKE_VAULT_NAME = "Triad Share 1";
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const NOOP_PROGRAM_ID = "noop8ytexvkpCuqbf6FB89BSuNemHtPRqaNC31GWivW";
|
|
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,13 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
exports.ATA_PROGRAM_ID = 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
|
|
6
|
-
exports.ADMIN = '';
|
|
7
|
-
exports.VERIFIER = '42n6BHufivUKrb5Bi6tXbMZvM8NHovrDLX1Rt5w2a919';
|
|
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");
|
|
8
5
|
exports.STAKE_VAULT_NAME = 'Triad Share 1';
|
|
9
|
-
exports.
|
|
10
|
-
exports.
|
|
11
|
-
exports.
|
|
12
|
-
exports.
|
|
13
|
-
exports.NOOP_PROGRAM_ID = 'noop8ytexvkpCuqbf6FB89BSuNemHtPRqaNC31GWivW';
|
|
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/dist/utils/helpers.d.ts
CHANGED
|
@@ -12,8 +12,6 @@ export declare const getStakeAddressSync: (programId: PublicKey, wallet: PublicK
|
|
|
12
12
|
export declare const getNFTRewardsAddressSync: (programId: PublicKey, stake: PublicKey) => PublicKey;
|
|
13
13
|
export declare const getATASync: (address: PublicKey, Mint: PublicKey) => PublicKey;
|
|
14
14
|
export declare const getUserAddressSync: (programId: PublicKey, wallet: PublicKey) => PublicKey;
|
|
15
|
-
export declare const getProofOreAddressSync: (wallet: PublicKey) => PublicKey;
|
|
16
|
-
export declare const configOreProgramAddressSync: () => PublicKey;
|
|
17
15
|
export declare const formatNumber: (number: bigint | BN, decimals?: number) => number;
|
|
18
16
|
export declare const formatStakeVault: (stakeVault: any) => StakeVaultResponse;
|
|
19
17
|
export declare const formatStake: (stake: any) => StakeResponse;
|
package/dist/utils/helpers.js
CHANGED
|
@@ -23,12 +23,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.calculateAPR = exports.calculateTotalMultiplier = exports.formatUser = exports.formatStake = exports.formatStakeVault = exports.formatNumber = exports.
|
|
26
|
+
exports.calculateAPR = exports.calculateTotalMultiplier = exports.formatUser = exports.formatStake = exports.formatStakeVault = exports.formatNumber = exports.getUserAddressSync = exports.getATASync = exports.getNFTRewardsAddressSync = exports.getStakeAddressSync = exports.getStakeVaultAddressSync = exports.getUserPositionAddressSync = exports.getTokenVaultAddressSync = exports.getVaultAddressSync = exports.decodeString = exports.encodeString = exports.getTickerAddressSync = void 0;
|
|
27
27
|
const stake_1 = require("./../types/stake");
|
|
28
28
|
const web3_js_1 = require("@solana/web3.js");
|
|
29
29
|
const anchor = __importStar(require("@coral-xyz/anchor"));
|
|
30
30
|
const spl_token_1 = require("@solana/spl-token");
|
|
31
|
-
const constants_1 = require("./constants");
|
|
32
31
|
const getTickerAddressSync = (programId, tickerName) => {
|
|
33
32
|
const [TickerPDA] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('ticker'), Buffer.from(tickerName)], programId);
|
|
34
33
|
return TickerPDA;
|
|
@@ -87,7 +86,7 @@ const getNFTRewardsAddressSync = (programId, stake) => {
|
|
|
87
86
|
};
|
|
88
87
|
exports.getNFTRewardsAddressSync = getNFTRewardsAddressSync;
|
|
89
88
|
const getATASync = (address, Mint) => {
|
|
90
|
-
const [ATA] = web3_js_1.PublicKey.findProgramAddressSync([address.toBytes(), spl_token_1.TOKEN_2022_PROGRAM_ID.toBytes(), Mint.toBytes()], new web3_js_1.PublicKey(
|
|
89
|
+
const [ATA] = web3_js_1.PublicKey.findProgramAddressSync([address.toBytes(), spl_token_1.TOKEN_2022_PROGRAM_ID.toBytes(), Mint.toBytes()], new web3_js_1.PublicKey(spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID));
|
|
91
90
|
return ATA;
|
|
92
91
|
};
|
|
93
92
|
exports.getATASync = getATASync;
|
|
@@ -96,16 +95,6 @@ const getUserAddressSync = (programId, wallet) => {
|
|
|
96
95
|
return StakePDA;
|
|
97
96
|
};
|
|
98
97
|
exports.getUserAddressSync = getUserAddressSync;
|
|
99
|
-
const getProofOreAddressSync = (wallet) => {
|
|
100
|
-
const [ProofPDA] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('proof'), wallet.toBuffer()], new web3_js_1.PublicKey(constants_1.ORE_PROGRAM_ID));
|
|
101
|
-
return ProofPDA;
|
|
102
|
-
};
|
|
103
|
-
exports.getProofOreAddressSync = getProofOreAddressSync;
|
|
104
|
-
const configOreProgramAddressSync = () => {
|
|
105
|
-
const [ProofPDA] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('config')], new web3_js_1.PublicKey(constants_1.ORE_PROGRAM_ID));
|
|
106
|
-
return ProofPDA;
|
|
107
|
-
};
|
|
108
|
-
exports.configOreProgramAddressSync = configOreProgramAddressSync;
|
|
109
98
|
const formatNumber = (number, decimals = 6) => {
|
|
110
99
|
return Number(number.toString()) / Math.pow(10, decimals);
|
|
111
100
|
};
|
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
|