@triadxyz/triad-protocol 0.1.0-beta.2 → 0.1.0

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/README.md DELETED
@@ -1,27 +0,0 @@
1
- <div align="center">
2
- <h1>Triad Protocol</h1>
3
- </div>
4
-
5
- The official Triad Protocol. trading your prefer companie in web3.
6
-
7
- ### Docs
8
-
9
- [Triad Protocol Docs](https://docs.triadfi.co/)
10
-
11
- ## Quick Setup
12
-
13
- ### Install
14
-
15
- Install these dependencies over:
16
-
17
- npm:
18
-
19
- ```shell
20
- npm install @triadxyz/triad-protocol
21
- ```
22
-
23
- yarn:
24
-
25
- ```shell
26
- yarn add @triadxyz/triad-protocol
27
- ```
package/dist/ticker.d.ts DELETED
@@ -1,18 +0,0 @@
1
- import { AnchorProvider, Program } from '@coral-xyz/anchor';
2
- import { PublicKey } from '@solana/web3.js';
3
- import { TriadProtocol } from './types/triad_protocol';
4
- export default class Ticker {
5
- program: Program<TriadProtocol>;
6
- provider: AnchorProvider;
7
- constructor(program: Program<TriadProtocol>, provider: AnchorProvider);
8
- /**
9
- * Create a new ticker
10
- * @param name - The ticker's name
11
- * @param protocolProgramId - The program ID of the protocol
12
- *
13
- */
14
- createTicker({ name, protocolProgramId }: {
15
- name: string;
16
- protocolProgramId: PublicKey;
17
- }): Promise<string>;
18
- }
package/dist/ticker.js DELETED
@@ -1,38 +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
- class Ticker {
14
- constructor(program, provider) {
15
- this.provider = provider;
16
- this.program = program;
17
- }
18
- /**
19
- * Create a new ticker
20
- * @param name - The ticker's name
21
- * @param protocolProgramId - The program ID of the protocol
22
- *
23
- */
24
- createTicker({ name, protocolProgramId }) {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- const TickerPDA = (0, helpers_1.getTickerAddressSync)(this.program.programId, protocolProgramId);
27
- const VaultPDA = (0, helpers_1.getVaultAddressSync)(this.program.programId, TickerPDA);
28
- return this.program.methods
29
- .createTicker({ name, protocolProgramId })
30
- .accounts({
31
- ticker: TickerPDA,
32
- vault: VaultPDA
33
- })
34
- .rpc();
35
- });
36
- }
37
- }
38
- exports.default = Ticker;
package/dist/vault.d.ts DELETED
File without changes
package/dist/vault.js DELETED
@@ -1,260 +0,0 @@
1
- // import { AnchorProvider, BN, Program } from '@coral-xyz/anchor'
2
- // import {
3
- // PublicKey,
4
- // TransactionInstruction,
5
- // TransactionMessage,
6
- // VersionedTransaction
7
- // } from '@solana/web3.js'
8
- // import { TriadProtocol } from './types/triad_protocol'
9
- // import {
10
- // getVaultAddressSync,
11
- // getTokenVaultAddressSync,
12
- // getVaultDepositorAddressSync,
13
- // decodeString,
14
- // encodeString,
15
- // formatNumber
16
- // } from './utils/helpers'
17
- // import { getAccount, getAssociatedTokenAddress } from '@solana/spl-token'
18
- // export default class Vault {
19
- // program: Program<TriadProtocol>
20
- // provider: AnchorProvider
21
- // constructor(program: Program<TriadProtocol>, provider: AnchorProvider) {
22
- // this.provider = provider
23
- // this.program = program
24
- // }
25
- // /**
26
- // * Create a new vault
27
- // * @param name - The vault's name
28
- // * @param mint - Token mint for the vault (e.g. USDC)
29
- // * @param maxTokens - Maximum number of tokens in the vault
30
- // * @param minDepositAmount - Minimum deposit amount
31
- // * @param profitShare - Profit share percentage
32
- // *
33
- // */
34
- // public async createVault({
35
- // name,
36
- // mint,
37
- // maxTokens,
38
- // minDepositAmount,
39
- // profitShare
40
- // }: {
41
- // name: string
42
- // mint: PublicKey
43
- // maxTokens: BN
44
- // minDepositAmount: BN
45
- // profitShare: number
46
- // }) {
47
- // const vaultName = encodeString(name)
48
- // const tickerAddress = new PublicKey('driftaiasjiasjhias')
49
- // const VaultPDA = getVaultAddressSync(this.program.programId, vaultName)
50
- // const TokenAccountPDA = getTokenVaultAddressSync(
51
- // this.program.programId,
52
- // VaultPDA
53
- // )
54
- // return this.program.methods
55
- // .createVault({
56
- // name: vaultName,
57
- // minDepositAmount,
58
- // maxTokens,
59
- // profitShare,
60
- // tickerAddress
61
- // })
62
- // .accounts({
63
- // signer: this.wallet.publicKey,
64
- // vault: VaultPDA,
65
- // tokenAccount: TokenAccountPDA,
66
- // payerTokenMint: mint
67
- // })
68
- // .rpc()
69
- // }
70
- // /**
71
- // * Get all vaults
72
- // */
73
- // async getVaults() {
74
- // const vaults = await this.program.account.vault.all()
75
- // return vaults.map((vault) => ({
76
- // name: decodeString(vault.account.name),
77
- // tokenAccount: vault.account.tokenAccount
78
- // }))
79
- // }
80
- // /**
81
- // * Get vault by name
82
- // */
83
- // public async getVaultByName(vaultName: string) {
84
- // const encodeVaultName = encodeString(vaultName)
85
- // const VaultPDA = getVaultAddressSync(
86
- // this.program.programId,
87
- // encodeVaultName
88
- // )
89
- // try {
90
- // const vault = await this.program.account.vault.fetch(VaultPDA)
91
- // const tokenAcc = await getAccount(this.connection, vault.tokenAccount)
92
- // return {
93
- // name: decodeString(vault.name),
94
- // tokenAccount: vault.tokenAccount,
95
- // tvl: formatNumber(tokenAcc.amount)
96
- // }
97
- // } catch (e) {
98
- // throw new Error(e)
99
- // }
100
- // }
101
- // /**
102
- // * Get Depositor
103
- // */
104
- // public async getDepositor(vaultName: string) {
105
- // const encodeVaultName = encodeString(vaultName)
106
- // const VaultPDA = getVaultAddressSync(
107
- // this.program.programId,
108
- // encodeVaultName
109
- // )
110
- // const DepositorPDA = getVaultDepositorAddressSync(
111
- // this.program.programId,
112
- // VaultPDA,
113
- // this.wallet.publicKey
114
- // )
115
- // try {
116
- // const depositor =
117
- // await this.program.account.vaultDepositor.fetch(DepositorPDA)
118
- // return {
119
- // authority: depositor.authority.toBase58(),
120
- // vault: depositor.vault.toBase58(),
121
- // bump: depositor.bump,
122
- // totalDeposit: formatNumber(depositor.totalDeposits),
123
- // totalWithdraws: formatNumber(depositor.totalWithdraws),
124
- // lpShares: formatNumber(depositor.lpShares),
125
- // netDeposits: formatNumber(depositor.netDeposits),
126
- // netWithdraws: formatNumber(depositor.netWithdraws)
127
- // }
128
- // } catch (e) {
129
- // throw new Error(e)
130
- // }
131
- // }
132
- // /**
133
- // * Create a new vault
134
- // * @param vault - The vault's name
135
- // * @param amount - The amount to deposit
136
- // * @param mint - Token mint for the vault (e.g. USDC)
137
- // */
138
- // public async deposit({
139
- // vault,
140
- // amount,
141
- // mint
142
- // }: {
143
- // vault: string
144
- // amount: string
145
- // mint: PublicKey
146
- // }) {
147
- // const vaultName = encodeString(vault)
148
- // const VaultPDA = getVaultAddressSync(this.program.programId, vaultName)
149
- // const VaultDepositorPDA = getVaultDepositorAddressSync(
150
- // this.program.programId,
151
- // VaultPDA,
152
- // this.wallet.publicKey
153
- // )
154
- // let hasDepositor = true
155
- // try {
156
- // await this.program.account.vaultDepositor.fetch(VaultDepositorPDA)
157
- // } catch {
158
- // hasDepositor = false
159
- // }
160
- // let ix: TransactionInstruction[] = []
161
- // if (!hasDepositor) {
162
- // const depositorIx = await this.program.methods
163
- // .createVaultDepositor({
164
- // longPositions: '',
165
- // shortPositions: ''
166
- // })
167
- // .accounts({
168
- // vault: VaultPDA,
169
- // vaultDepositor: VaultDepositorPDA
170
- // })
171
- // .instruction()
172
- // ix.push(depositorIx)
173
- // }
174
- // const VaultTokenAccountPDA = getTokenVaultAddressSync(
175
- // this.program.programId,
176
- // VaultPDA
177
- // )
178
- // const userTokenAccount = await getAssociatedTokenAddress(
179
- // mint,
180
- // this.wallet.publicKey
181
- // )
182
- // const depositIx = await this.program.methods
183
- // .deposit(new BN(amount))
184
- // .accounts({
185
- // vaultDepositor: VaultDepositorPDA,
186
- // vault: VaultPDA,
187
- // vaultTokenAccount: VaultTokenAccountPDA,
188
- // userTokenAccount
189
- // })
190
- // .instruction()
191
- // ix.push(depositIx)
192
- // const { blockhash } = await this.connection.getLatestBlockhash()
193
- // const message = new TransactionMessage({
194
- // payerKey: this.wallet.publicKey,
195
- // recentBlockhash: blockhash,
196
- // instructions: ix
197
- // }).compileToV0Message()
198
- // let tx = new VersionedTransaction(message)
199
- // tx = await this.wallet.signTransaction(tx)
200
- // return this.connection.sendRawTransaction(tx.serialize())
201
- // }
202
- // public async withdraw({
203
- // vault,
204
- // amount,
205
- // mint
206
- // }: {
207
- // vault: string
208
- // amount: string
209
- // mint: PublicKey
210
- // }) {
211
- // const vaultName = encodeString(vault)
212
- // const VaultPDA = getVaultAddressSync(this.program.programId, vaultName)
213
- // const VaultDepositorPDA = getVaultDepositorAddressSync(
214
- // this.program.programId,
215
- // VaultPDA,
216
- // this.wallet.publicKey
217
- // )
218
- // const VaultTokenAccountPDA = getTokenVaultAddressSync(
219
- // this.program.programId,
220
- // VaultPDA
221
- // )
222
- // const userTokenAccount = await getAssociatedTokenAddress(
223
- // mint,
224
- // this.wallet.publicKey
225
- // )
226
- // const ix = await this.program.methods
227
- // .withdraw(new BN(amount))
228
- // .accounts({
229
- // vaultDepositor: VaultDepositorPDA,
230
- // vault: VaultPDA,
231
- // vaultTokenAccount: VaultTokenAccountPDA,
232
- // userTokenAccount
233
- // })
234
- // .instruction()
235
- // const { blockhash } = await this.connection.getLatestBlockhash()
236
- // const message = new TransactionMessage({
237
- // payerKey: this.wallet.publicKey,
238
- // recentBlockhash: blockhash,
239
- // instructions: [ix]
240
- // }).compileToV0Message()
241
- // let tx = new VersionedTransaction(message)
242
- // tx = await this.wallet.signTransaction(tx)
243
- // return this.connection.sendRawTransaction(tx.serialize())
244
- // }
245
- // public async getHistoryByVaultDepositor() {}
246
- // public async getChatByVault(vaultName: string) {
247
- // const encodeVaultName = encodeString(vaultName)
248
- // const VaultPDA = getVaultAddressSync(
249
- // this.program.programId,
250
- // encodeVaultName
251
- // )
252
- // const charts = Array.from({ length: 1000 }, (_, i) => {
253
- // return {
254
- // t: new Date().getTime() - i * 24 * 60 * 60 * 1000,
255
- // v: Math.random() * 1000
256
- // }
257
- // })
258
- // return charts
259
- // }
260
- // }