@hodlmarkets/sdk 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 +121 -0
- package/dist/accounts.cjs +1893 -0
- package/dist/accounts.cjs.map +1 -0
- package/dist/accounts.d.cts +9 -0
- package/dist/accounts.d.ts +9 -0
- package/dist/accounts.js +1885 -0
- package/dist/accounts.js.map +1 -0
- package/dist/client.cjs +2161 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +44 -0
- package/dist/client.d.ts +44 -0
- package/dist/client.js +2155 -0
- package/dist/client.js.map +1 -0
- package/dist/constants.cjs +68 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.d.cts +62 -0
- package/dist/constants.d.ts +62 -0
- package/dist/constants.js +50 -0
- package/dist/constants.js.map +1 -0
- package/dist/errors.cjs +43 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.cts +8 -0
- package/dist/errors.d.ts +8 -0
- package/dist/errors.js +39 -0
- package/dist/errors.js.map +1 -0
- package/dist/events.cjs +1923 -0
- package/dist/events.cjs.map +1 -0
- package/dist/events.d.cts +20 -0
- package/dist/events.d.ts +20 -0
- package/dist/events.js +1913 -0
- package/dist/events.js.map +1 -0
- package/dist/index.cjs +2357 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +2302 -0
- package/dist/index.js.map +1 -0
- package/dist/instructions.cjs +2022 -0
- package/dist/instructions.cjs.map +1 -0
- package/dist/instructions.d.cts +38 -0
- package/dist/instructions.d.ts +38 -0
- package/dist/instructions.js +2012 -0
- package/dist/instructions.js.map +1 -0
- package/dist/math.cjs +98 -0
- package/dist/math.cjs.map +1 -0
- package/dist/math.d.cts +58 -0
- package/dist/math.d.ts +58 -0
- package/dist/math.js +85 -0
- package/dist/math.js.map +1 -0
- package/dist/pda.cjs +52 -0
- package/dist/pda.cjs.map +1 -0
- package/dist/pda.d.cts +10 -0
- package/dist/pda.d.ts +10 -0
- package/dist/pda.js +41 -0
- package/dist/pda.js.map +1 -0
- package/dist/transaction.cjs +37 -0
- package/dist/transaction.cjs.map +1 -0
- package/dist/transaction.d.cts +11 -0
- package/dist/transaction.d.ts +11 -0
- package/dist/transaction.js +34 -0
- package/dist/transaction.js.map +1 -0
- package/dist/types.cjs +4 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +153 -0
- package/dist/types.d.ts +153 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +96 -0
package/dist/pda.cjs
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var web3_js = require('@solana/web3.js');
|
|
4
|
+
var BN = require('bn.js');
|
|
5
|
+
|
|
6
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
+
|
|
8
|
+
var BN__default = /*#__PURE__*/_interopDefault(BN);
|
|
9
|
+
|
|
10
|
+
// src/pda.ts
|
|
11
|
+
new web3_js.PublicKey("hodLrUfwyK3Z7Td5hdZhyojyznG1rqbHVex11y5s4yG");
|
|
12
|
+
new web3_js.PublicKey("EFAquDGAHjkoPB6TGKVibD3BYhbFXNDjuXKpiBHdYzji");
|
|
13
|
+
new BN__default.default("30000000000");
|
|
14
|
+
new BN__default.default("1000000000000000");
|
|
15
|
+
new BN__default.default("100000000");
|
|
16
|
+
var SEEDS = {
|
|
17
|
+
POOL: Buffer.from("pool"),
|
|
18
|
+
VAULT_AUTHORITY: Buffer.from("vault_authority"),
|
|
19
|
+
SOL_VAULT: Buffer.from("sol_vault"),
|
|
20
|
+
POSITION: Buffer.from("position"),
|
|
21
|
+
PROTOCOL_FEES: Buffer.from("protocol_fees"),
|
|
22
|
+
EVENT_AUTHORITY: Buffer.from("__event_authority")
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// src/pda.ts
|
|
26
|
+
function getPoolStatePDA(mint, programId) {
|
|
27
|
+
return web3_js.PublicKey.findProgramAddressSync([SEEDS.POOL, mint.toBuffer()], programId);
|
|
28
|
+
}
|
|
29
|
+
function getVaultAuthorityPDA(poolState, programId) {
|
|
30
|
+
return web3_js.PublicKey.findProgramAddressSync([SEEDS.VAULT_AUTHORITY, poolState.toBuffer()], programId);
|
|
31
|
+
}
|
|
32
|
+
function getSolVaultPDA(poolState, programId) {
|
|
33
|
+
return web3_js.PublicKey.findProgramAddressSync([SEEDS.SOL_VAULT, poolState.toBuffer()], programId);
|
|
34
|
+
}
|
|
35
|
+
function getPositionPDA(poolState, owner, programId) {
|
|
36
|
+
return web3_js.PublicKey.findProgramAddressSync([SEEDS.POSITION, poolState.toBuffer(), owner.toBuffer()], programId);
|
|
37
|
+
}
|
|
38
|
+
function getProtocolFeesPDA(programId) {
|
|
39
|
+
return web3_js.PublicKey.findProgramAddressSync([SEEDS.PROTOCOL_FEES], programId);
|
|
40
|
+
}
|
|
41
|
+
function getEventAuthorityPDA(programId) {
|
|
42
|
+
return web3_js.PublicKey.findProgramAddressSync([SEEDS.EVENT_AUTHORITY], programId);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
exports.getEventAuthorityPDA = getEventAuthorityPDA;
|
|
46
|
+
exports.getPoolStatePDA = getPoolStatePDA;
|
|
47
|
+
exports.getPositionPDA = getPositionPDA;
|
|
48
|
+
exports.getProtocolFeesPDA = getProtocolFeesPDA;
|
|
49
|
+
exports.getSolVaultPDA = getSolVaultPDA;
|
|
50
|
+
exports.getVaultAuthorityPDA = getVaultAuthorityPDA;
|
|
51
|
+
//# sourceMappingURL=pda.cjs.map
|
|
52
|
+
//# sourceMappingURL=pda.cjs.map
|
package/dist/pda.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/constants.ts","../src/pda.ts"],"names":["PublicKey","BN"],"mappings":";;;;;;;;;;AAK0B,IAAIA,iBAAA,CAAU,6CAA6C;AACnD,IAAIA,iBAAA,CAAU,8CAA8C;AAEnE,IAAIC,mBAAA,CAAG,aAAa;AACnB,IAAIA,mBAAA,CAAG,kBAAkB;AACpB,IAAIA,mBAAA,CAAG,WAAW;AAG5C,IAAM,KAAA,GAAQ;AAAA,EACnB,IAAA,EAAM,MAAA,CAAO,IAAA,CAAK,MAAM,CAAA;AAAA,EACxB,eAAA,EAAiB,MAAA,CAAO,IAAA,CAAK,iBAAiB,CAAA;AAAA,EAC9C,SAAA,EAAW,MAAA,CAAO,IAAA,CAAK,WAAW,CAAA;AAAA,EAClC,QAAA,EAAU,MAAA,CAAO,IAAA,CAAK,UAAU,CAAA;AAAA,EAChC,aAAA,EAAe,MAAA,CAAO,IAAA,CAAK,eAAe,CAAA;AAAA,EAC1C,eAAA,EAAiB,MAAA,CAAO,IAAA,CAAK,mBAAmB;AAClD,CAAA;;;ACjBO,SAAS,eAAA,CAAgB,MAAiB,SAAA,EAA2C;AAC1F,EAAA,OAAOD,iBAAAA,CAAU,uBAAuB,CAAC,KAAA,CAAM,MAAM,IAAA,CAAK,QAAA,EAAU,CAAA,EAAG,SAAS,CAAA;AAClF;AAEO,SAAS,oBAAA,CAAqB,WAAsB,SAAA,EAA2C;AACpG,EAAA,OAAOA,iBAAAA,CAAU,uBAAuB,CAAC,KAAA,CAAM,iBAAiB,SAAA,CAAU,QAAA,EAAU,CAAA,EAAG,SAAS,CAAA;AAClG;AAEO,SAAS,cAAA,CAAe,WAAsB,SAAA,EAA2C;AAC9F,EAAA,OAAOA,iBAAAA,CAAU,uBAAuB,CAAC,KAAA,CAAM,WAAW,SAAA,CAAU,QAAA,EAAU,CAAA,EAAG,SAAS,CAAA;AAC5F;AAEO,SAAS,cAAA,CAAe,SAAA,EAAsB,KAAA,EAAkB,SAAA,EAA2C;AAChH,EAAA,OAAOA,iBAAAA,CAAU,sBAAA,CAAuB,CAAC,KAAA,CAAM,QAAA,EAAU,SAAA,CAAU,QAAA,EAAS,EAAG,KAAA,CAAM,QAAA,EAAU,CAAA,EAAG,SAAS,CAAA;AAC7G;AAEO,SAAS,mBAAmB,SAAA,EAA2C;AAC5E,EAAA,OAAOA,kBAAU,sBAAA,CAAuB,CAAC,KAAA,CAAM,aAAa,GAAG,SAAS,CAAA;AAC1E;AAEO,SAAS,qBAAqB,SAAA,EAA2C;AAC9E,EAAA,OAAOA,kBAAU,sBAAA,CAAuB,CAAC,KAAA,CAAM,eAAe,GAAG,SAAS,CAAA;AAC5E","file":"pda.cjs","sourcesContent":["import { PublicKey } from '@solana/web3.js'\nimport BN from 'bn.js'\n\nexport const BPS_DENOMINATOR = 10_000\n\nexport const PROGRAM_ID = new PublicKey('hodLrUfwyK3Z7Td5hdZhyojyznG1rqbHVex11y5s4yG')\nexport const PROTOCOL_AUTHORITY = new PublicKey('EFAquDGAHjkoPB6TGKVibD3BYhbFXNDjuXKpiBHdYzji')\n\nexport const VIRTUAL_SOL = new BN('30000000000')\nexport const TOTAL_SUPPLY = new BN('1000000000000000')\nexport const PROTOCOL_MINT_FEE = new BN('100000000')\nexport const DECIMALS = 6\n\nexport const SEEDS = {\n POOL: Buffer.from('pool'),\n VAULT_AUTHORITY: Buffer.from('vault_authority'),\n SOL_VAULT: Buffer.from('sol_vault'),\n POSITION: Buffer.from('position'),\n PROTOCOL_FEES: Buffer.from('protocol_fees'),\n EVENT_AUTHORITY: Buffer.from('__event_authority'),\n} as const\n\nexport const MAINNET_CONFIG = {\n programId: PROGRAM_ID,\n virtualSol: VIRTUAL_SOL,\n protocolAuthority: PROTOCOL_AUTHORITY,\n protocolMintFee: PROTOCOL_MINT_FEE,\n decimals: DECIMALS,\n totalSupply: TOTAL_SUPPLY,\n} as const\n\nexport const DEVNET_CONFIG = {\n programId: PROGRAM_ID,\n virtualSol: VIRTUAL_SOL,\n protocolAuthority: PROTOCOL_AUTHORITY,\n protocolMintFee: PROTOCOL_MINT_FEE,\n decimals: DECIMALS,\n totalSupply: TOTAL_SUPPLY,\n} as const\n\n/** Trade fee in basis points (25 bps = 0.25%). Only applies after vest_duration has passed. */\nexport const TRADE_FEE_BPS = 25\n\n/** Allowed vest duration modes (in seconds). The program only accepts these values. */\nexport const VEST_DURATION = {\n ONE_MINUTE: 60,\n TEN_MINUTES: 600,\n} as const\n\nexport type VestDuration = typeof VEST_DURATION[keyof typeof VEST_DURATION]\n\nexport const LIMITS = {\n NAME: { min: 1, max: 32 },\n SYMBOL: { min: 1, max: 16 },\n URI: { min: 10, max: 100 },\n DESCRIPTION: { min: 0, max: 200 },\n} as const\n","import { PublicKey } from '@solana/web3.js'\nimport { SEEDS } from './constants'\n\nexport function getPoolStatePDA(mint: PublicKey, programId: PublicKey): [PublicKey, number] {\n return PublicKey.findProgramAddressSync([SEEDS.POOL, mint.toBuffer()], programId)\n}\n\nexport function getVaultAuthorityPDA(poolState: PublicKey, programId: PublicKey): [PublicKey, number] {\n return PublicKey.findProgramAddressSync([SEEDS.VAULT_AUTHORITY, poolState.toBuffer()], programId)\n}\n\nexport function getSolVaultPDA(poolState: PublicKey, programId: PublicKey): [PublicKey, number] {\n return PublicKey.findProgramAddressSync([SEEDS.SOL_VAULT, poolState.toBuffer()], programId)\n}\n\nexport function getPositionPDA(poolState: PublicKey, owner: PublicKey, programId: PublicKey): [PublicKey, number] {\n return PublicKey.findProgramAddressSync([SEEDS.POSITION, poolState.toBuffer(), owner.toBuffer()], programId)\n}\n\nexport function getProtocolFeesPDA(programId: PublicKey): [PublicKey, number] {\n return PublicKey.findProgramAddressSync([SEEDS.PROTOCOL_FEES], programId)\n}\n\nexport function getEventAuthorityPDA(programId: PublicKey): [PublicKey, number] {\n return PublicKey.findProgramAddressSync([SEEDS.EVENT_AUTHORITY], programId)\n}\n"]}
|
package/dist/pda.d.cts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PublicKey } from '@solana/web3.js';
|
|
2
|
+
|
|
3
|
+
declare function getPoolStatePDA(mint: PublicKey, programId: PublicKey): [PublicKey, number];
|
|
4
|
+
declare function getVaultAuthorityPDA(poolState: PublicKey, programId: PublicKey): [PublicKey, number];
|
|
5
|
+
declare function getSolVaultPDA(poolState: PublicKey, programId: PublicKey): [PublicKey, number];
|
|
6
|
+
declare function getPositionPDA(poolState: PublicKey, owner: PublicKey, programId: PublicKey): [PublicKey, number];
|
|
7
|
+
declare function getProtocolFeesPDA(programId: PublicKey): [PublicKey, number];
|
|
8
|
+
declare function getEventAuthorityPDA(programId: PublicKey): [PublicKey, number];
|
|
9
|
+
|
|
10
|
+
export { getEventAuthorityPDA, getPoolStatePDA, getPositionPDA, getProtocolFeesPDA, getSolVaultPDA, getVaultAuthorityPDA };
|
package/dist/pda.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PublicKey } from '@solana/web3.js';
|
|
2
|
+
|
|
3
|
+
declare function getPoolStatePDA(mint: PublicKey, programId: PublicKey): [PublicKey, number];
|
|
4
|
+
declare function getVaultAuthorityPDA(poolState: PublicKey, programId: PublicKey): [PublicKey, number];
|
|
5
|
+
declare function getSolVaultPDA(poolState: PublicKey, programId: PublicKey): [PublicKey, number];
|
|
6
|
+
declare function getPositionPDA(poolState: PublicKey, owner: PublicKey, programId: PublicKey): [PublicKey, number];
|
|
7
|
+
declare function getProtocolFeesPDA(programId: PublicKey): [PublicKey, number];
|
|
8
|
+
declare function getEventAuthorityPDA(programId: PublicKey): [PublicKey, number];
|
|
9
|
+
|
|
10
|
+
export { getEventAuthorityPDA, getPoolStatePDA, getPositionPDA, getProtocolFeesPDA, getSolVaultPDA, getVaultAuthorityPDA };
|
package/dist/pda.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { PublicKey } from '@solana/web3.js';
|
|
2
|
+
import BN from 'bn.js';
|
|
3
|
+
|
|
4
|
+
// src/pda.ts
|
|
5
|
+
new PublicKey("hodLrUfwyK3Z7Td5hdZhyojyznG1rqbHVex11y5s4yG");
|
|
6
|
+
new PublicKey("EFAquDGAHjkoPB6TGKVibD3BYhbFXNDjuXKpiBHdYzji");
|
|
7
|
+
new BN("30000000000");
|
|
8
|
+
new BN("1000000000000000");
|
|
9
|
+
new BN("100000000");
|
|
10
|
+
var SEEDS = {
|
|
11
|
+
POOL: Buffer.from("pool"),
|
|
12
|
+
VAULT_AUTHORITY: Buffer.from("vault_authority"),
|
|
13
|
+
SOL_VAULT: Buffer.from("sol_vault"),
|
|
14
|
+
POSITION: Buffer.from("position"),
|
|
15
|
+
PROTOCOL_FEES: Buffer.from("protocol_fees"),
|
|
16
|
+
EVENT_AUTHORITY: Buffer.from("__event_authority")
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// src/pda.ts
|
|
20
|
+
function getPoolStatePDA(mint, programId) {
|
|
21
|
+
return PublicKey.findProgramAddressSync([SEEDS.POOL, mint.toBuffer()], programId);
|
|
22
|
+
}
|
|
23
|
+
function getVaultAuthorityPDA(poolState, programId) {
|
|
24
|
+
return PublicKey.findProgramAddressSync([SEEDS.VAULT_AUTHORITY, poolState.toBuffer()], programId);
|
|
25
|
+
}
|
|
26
|
+
function getSolVaultPDA(poolState, programId) {
|
|
27
|
+
return PublicKey.findProgramAddressSync([SEEDS.SOL_VAULT, poolState.toBuffer()], programId);
|
|
28
|
+
}
|
|
29
|
+
function getPositionPDA(poolState, owner, programId) {
|
|
30
|
+
return PublicKey.findProgramAddressSync([SEEDS.POSITION, poolState.toBuffer(), owner.toBuffer()], programId);
|
|
31
|
+
}
|
|
32
|
+
function getProtocolFeesPDA(programId) {
|
|
33
|
+
return PublicKey.findProgramAddressSync([SEEDS.PROTOCOL_FEES], programId);
|
|
34
|
+
}
|
|
35
|
+
function getEventAuthorityPDA(programId) {
|
|
36
|
+
return PublicKey.findProgramAddressSync([SEEDS.EVENT_AUTHORITY], programId);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { getEventAuthorityPDA, getPoolStatePDA, getPositionPDA, getProtocolFeesPDA, getSolVaultPDA, getVaultAuthorityPDA };
|
|
40
|
+
//# sourceMappingURL=pda.js.map
|
|
41
|
+
//# sourceMappingURL=pda.js.map
|
package/dist/pda.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/constants.ts","../src/pda.ts"],"names":["PublicKey"],"mappings":";;;;AAK0B,IAAI,SAAA,CAAU,6CAA6C;AACnD,IAAI,SAAA,CAAU,8CAA8C;AAEnE,IAAI,EAAA,CAAG,aAAa;AACnB,IAAI,EAAA,CAAG,kBAAkB;AACpB,IAAI,EAAA,CAAG,WAAW;AAG5C,IAAM,KAAA,GAAQ;AAAA,EACnB,IAAA,EAAM,MAAA,CAAO,IAAA,CAAK,MAAM,CAAA;AAAA,EACxB,eAAA,EAAiB,MAAA,CAAO,IAAA,CAAK,iBAAiB,CAAA;AAAA,EAC9C,SAAA,EAAW,MAAA,CAAO,IAAA,CAAK,WAAW,CAAA;AAAA,EAClC,QAAA,EAAU,MAAA,CAAO,IAAA,CAAK,UAAU,CAAA;AAAA,EAChC,aAAA,EAAe,MAAA,CAAO,IAAA,CAAK,eAAe,CAAA;AAAA,EAC1C,eAAA,EAAiB,MAAA,CAAO,IAAA,CAAK,mBAAmB;AAClD,CAAA;;;ACjBO,SAAS,eAAA,CAAgB,MAAiB,SAAA,EAA2C;AAC1F,EAAA,OAAOA,SAAAA,CAAU,uBAAuB,CAAC,KAAA,CAAM,MAAM,IAAA,CAAK,QAAA,EAAU,CAAA,EAAG,SAAS,CAAA;AAClF;AAEO,SAAS,oBAAA,CAAqB,WAAsB,SAAA,EAA2C;AACpG,EAAA,OAAOA,SAAAA,CAAU,uBAAuB,CAAC,KAAA,CAAM,iBAAiB,SAAA,CAAU,QAAA,EAAU,CAAA,EAAG,SAAS,CAAA;AAClG;AAEO,SAAS,cAAA,CAAe,WAAsB,SAAA,EAA2C;AAC9F,EAAA,OAAOA,SAAAA,CAAU,uBAAuB,CAAC,KAAA,CAAM,WAAW,SAAA,CAAU,QAAA,EAAU,CAAA,EAAG,SAAS,CAAA;AAC5F;AAEO,SAAS,cAAA,CAAe,SAAA,EAAsB,KAAA,EAAkB,SAAA,EAA2C;AAChH,EAAA,OAAOA,SAAAA,CAAU,sBAAA,CAAuB,CAAC,KAAA,CAAM,QAAA,EAAU,SAAA,CAAU,QAAA,EAAS,EAAG,KAAA,CAAM,QAAA,EAAU,CAAA,EAAG,SAAS,CAAA;AAC7G;AAEO,SAAS,mBAAmB,SAAA,EAA2C;AAC5E,EAAA,OAAOA,UAAU,sBAAA,CAAuB,CAAC,KAAA,CAAM,aAAa,GAAG,SAAS,CAAA;AAC1E;AAEO,SAAS,qBAAqB,SAAA,EAA2C;AAC9E,EAAA,OAAOA,UAAU,sBAAA,CAAuB,CAAC,KAAA,CAAM,eAAe,GAAG,SAAS,CAAA;AAC5E","file":"pda.js","sourcesContent":["import { PublicKey } from '@solana/web3.js'\nimport BN from 'bn.js'\n\nexport const BPS_DENOMINATOR = 10_000\n\nexport const PROGRAM_ID = new PublicKey('hodLrUfwyK3Z7Td5hdZhyojyznG1rqbHVex11y5s4yG')\nexport const PROTOCOL_AUTHORITY = new PublicKey('EFAquDGAHjkoPB6TGKVibD3BYhbFXNDjuXKpiBHdYzji')\n\nexport const VIRTUAL_SOL = new BN('30000000000')\nexport const TOTAL_SUPPLY = new BN('1000000000000000')\nexport const PROTOCOL_MINT_FEE = new BN('100000000')\nexport const DECIMALS = 6\n\nexport const SEEDS = {\n POOL: Buffer.from('pool'),\n VAULT_AUTHORITY: Buffer.from('vault_authority'),\n SOL_VAULT: Buffer.from('sol_vault'),\n POSITION: Buffer.from('position'),\n PROTOCOL_FEES: Buffer.from('protocol_fees'),\n EVENT_AUTHORITY: Buffer.from('__event_authority'),\n} as const\n\nexport const MAINNET_CONFIG = {\n programId: PROGRAM_ID,\n virtualSol: VIRTUAL_SOL,\n protocolAuthority: PROTOCOL_AUTHORITY,\n protocolMintFee: PROTOCOL_MINT_FEE,\n decimals: DECIMALS,\n totalSupply: TOTAL_SUPPLY,\n} as const\n\nexport const DEVNET_CONFIG = {\n programId: PROGRAM_ID,\n virtualSol: VIRTUAL_SOL,\n protocolAuthority: PROTOCOL_AUTHORITY,\n protocolMintFee: PROTOCOL_MINT_FEE,\n decimals: DECIMALS,\n totalSupply: TOTAL_SUPPLY,\n} as const\n\n/** Trade fee in basis points (25 bps = 0.25%). Only applies after vest_duration has passed. */\nexport const TRADE_FEE_BPS = 25\n\n/** Allowed vest duration modes (in seconds). The program only accepts these values. */\nexport const VEST_DURATION = {\n ONE_MINUTE: 60,\n TEN_MINUTES: 600,\n} as const\n\nexport type VestDuration = typeof VEST_DURATION[keyof typeof VEST_DURATION]\n\nexport const LIMITS = {\n NAME: { min: 1, max: 32 },\n SYMBOL: { min: 1, max: 16 },\n URI: { min: 10, max: 100 },\n DESCRIPTION: { min: 0, max: 200 },\n} as const\n","import { PublicKey } from '@solana/web3.js'\nimport { SEEDS } from './constants'\n\nexport function getPoolStatePDA(mint: PublicKey, programId: PublicKey): [PublicKey, number] {\n return PublicKey.findProgramAddressSync([SEEDS.POOL, mint.toBuffer()], programId)\n}\n\nexport function getVaultAuthorityPDA(poolState: PublicKey, programId: PublicKey): [PublicKey, number] {\n return PublicKey.findProgramAddressSync([SEEDS.VAULT_AUTHORITY, poolState.toBuffer()], programId)\n}\n\nexport function getSolVaultPDA(poolState: PublicKey, programId: PublicKey): [PublicKey, number] {\n return PublicKey.findProgramAddressSync([SEEDS.SOL_VAULT, poolState.toBuffer()], programId)\n}\n\nexport function getPositionPDA(poolState: PublicKey, owner: PublicKey, programId: PublicKey): [PublicKey, number] {\n return PublicKey.findProgramAddressSync([SEEDS.POSITION, poolState.toBuffer(), owner.toBuffer()], programId)\n}\n\nexport function getProtocolFeesPDA(programId: PublicKey): [PublicKey, number] {\n return PublicKey.findProgramAddressSync([SEEDS.PROTOCOL_FEES], programId)\n}\n\nexport function getEventAuthorityPDA(programId: PublicKey): [PublicKey, number] {\n return PublicKey.findProgramAddressSync([SEEDS.EVENT_AUTHORITY], programId)\n}\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var web3_js = require('@solana/web3.js');
|
|
4
|
+
|
|
5
|
+
// src/transaction.ts
|
|
6
|
+
async function buildTransaction(connection, instructions, payer, opts = {}) {
|
|
7
|
+
const cuLimit = opts.computeUnits ?? 2e5;
|
|
8
|
+
const priorityFee = opts.priorityFee ?? 1e3;
|
|
9
|
+
const computeIxs = [
|
|
10
|
+
web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: cuLimit }),
|
|
11
|
+
web3_js.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: priorityFee })
|
|
12
|
+
];
|
|
13
|
+
const { blockhash } = await connection.getLatestBlockhash("confirmed");
|
|
14
|
+
const message = new web3_js.TransactionMessage({
|
|
15
|
+
payerKey: payer,
|
|
16
|
+
recentBlockhash: blockhash,
|
|
17
|
+
instructions: [...computeIxs, ...instructions]
|
|
18
|
+
}).compileToV0Message();
|
|
19
|
+
return new web3_js.VersionedTransaction(message);
|
|
20
|
+
}
|
|
21
|
+
async function sendTransaction(connection, tx, opts = {}) {
|
|
22
|
+
const sig = await connection.sendTransaction(tx, {
|
|
23
|
+
skipPreflight: opts.skipPreflight ?? false,
|
|
24
|
+
maxRetries: 3
|
|
25
|
+
});
|
|
26
|
+
const latestBlockhash = await connection.getLatestBlockhash("confirmed");
|
|
27
|
+
await connection.confirmTransaction({
|
|
28
|
+
signature: sig,
|
|
29
|
+
...latestBlockhash
|
|
30
|
+
}, "confirmed");
|
|
31
|
+
return sig;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
exports.buildTransaction = buildTransaction;
|
|
35
|
+
exports.sendTransaction = sendTransaction;
|
|
36
|
+
//# sourceMappingURL=transaction.cjs.map
|
|
37
|
+
//# sourceMappingURL=transaction.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/transaction.ts"],"names":["ComputeBudgetProgram","TransactionMessage","VersionedTransaction"],"mappings":";;;;;AAeA,eAAsB,iBACpB,UAAA,EACA,YAAA,EACA,KAAA,EACA,IAAA,GAAkB,EAAC,EACY;AAC/B,EAAA,MAAM,OAAA,GAAU,KAAK,YAAA,IAAgB,GAAA;AACrC,EAAA,MAAM,WAAA,GAAc,KAAK,WAAA,IAAe,GAAA;AAExC,EAAA,MAAM,UAAA,GAAuC;AAAA,IAC3CA,4BAAA,CAAqB,mBAAA,CAAoB,EAAE,KAAA,EAAO,SAAS,CAAA;AAAA,IAC3DA,4BAAA,CAAqB,mBAAA,CAAoB,EAAE,aAAA,EAAe,aAAa;AAAA,GACzE;AAEA,EAAA,MAAM,EAAE,SAAA,EAAU,GAAI,MAAM,UAAA,CAAW,mBAAmB,WAAW,CAAA;AAErE,EAAA,MAAM,OAAA,GAAU,IAAIC,0BAAA,CAAmB;AAAA,IACrC,QAAA,EAAU,KAAA;AAAA,IACV,eAAA,EAAiB,SAAA;AAAA,IACjB,YAAA,EAAc,CAAC,GAAG,UAAA,EAAY,GAAG,YAAY;AAAA,GAC9C,EAAE,kBAAA,EAAmB;AAEtB,EAAA,OAAO,IAAIC,6BAAqB,OAAO,CAAA;AACzC;AAEA,eAAsB,eAAA,CACpB,UAAA,EACA,EAAA,EACA,IAAA,GAAkB,EAAC,EACF;AACjB,EAAA,MAAM,GAAA,GAAM,MAAM,UAAA,CAAW,eAAA,CAAgB,EAAA,EAAI;AAAA,IAC/C,aAAA,EAAe,KAAK,aAAA,IAAiB,KAAA;AAAA,IACrC,UAAA,EAAY;AAAA,GACb,CAAA;AACD,EAAA,MAAM,eAAA,GAAkB,MAAM,UAAA,CAAW,kBAAA,CAAmB,WAAW,CAAA;AACvE,EAAA,MAAM,WAAW,kBAAA,CAAmB;AAAA,IAClC,SAAA,EAAW,GAAA;AAAA,IACX,GAAG;AAAA,KACF,WAAW,CAAA;AACd,EAAA,OAAO,GAAA;AACT","file":"transaction.cjs","sourcesContent":["import {\n Connection,\n PublicKey,\n TransactionInstruction,\n TransactionMessage,\n VersionedTransaction,\n ComputeBudgetProgram,\n} from '@solana/web3.js'\n\nexport interface TxOptions {\n priorityFee?: number // microlamports per CU\n computeUnits?: number\n skipPreflight?: boolean\n}\n\nexport async function buildTransaction(\n connection: Connection,\n instructions: TransactionInstruction[],\n payer: PublicKey,\n opts: TxOptions = {},\n): Promise<VersionedTransaction> {\n const cuLimit = opts.computeUnits ?? 200_000\n const priorityFee = opts.priorityFee ?? 1_000\n\n const computeIxs: TransactionInstruction[] = [\n ComputeBudgetProgram.setComputeUnitLimit({ units: cuLimit }),\n ComputeBudgetProgram.setComputeUnitPrice({ microLamports: priorityFee }),\n ]\n\n const { blockhash } = await connection.getLatestBlockhash('confirmed')\n\n const message = new TransactionMessage({\n payerKey: payer,\n recentBlockhash: blockhash,\n instructions: [...computeIxs, ...instructions],\n }).compileToV0Message()\n\n return new VersionedTransaction(message)\n}\n\nexport async function sendTransaction(\n connection: Connection,\n tx: VersionedTransaction,\n opts: TxOptions = {},\n): Promise<string> {\n const sig = await connection.sendTransaction(tx, {\n skipPreflight: opts.skipPreflight ?? false,\n maxRetries: 3,\n })\n const latestBlockhash = await connection.getLatestBlockhash('confirmed')\n await connection.confirmTransaction({\n signature: sig,\n ...latestBlockhash,\n }, 'confirmed')\n return sig\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Connection, TransactionInstruction, PublicKey, VersionedTransaction } from '@solana/web3.js';
|
|
2
|
+
|
|
3
|
+
interface TxOptions {
|
|
4
|
+
priorityFee?: number;
|
|
5
|
+
computeUnits?: number;
|
|
6
|
+
skipPreflight?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare function buildTransaction(connection: Connection, instructions: TransactionInstruction[], payer: PublicKey, opts?: TxOptions): Promise<VersionedTransaction>;
|
|
9
|
+
declare function sendTransaction(connection: Connection, tx: VersionedTransaction, opts?: TxOptions): Promise<string>;
|
|
10
|
+
|
|
11
|
+
export { type TxOptions, buildTransaction, sendTransaction };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Connection, TransactionInstruction, PublicKey, VersionedTransaction } from '@solana/web3.js';
|
|
2
|
+
|
|
3
|
+
interface TxOptions {
|
|
4
|
+
priorityFee?: number;
|
|
5
|
+
computeUnits?: number;
|
|
6
|
+
skipPreflight?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare function buildTransaction(connection: Connection, instructions: TransactionInstruction[], payer: PublicKey, opts?: TxOptions): Promise<VersionedTransaction>;
|
|
9
|
+
declare function sendTransaction(connection: Connection, tx: VersionedTransaction, opts?: TxOptions): Promise<string>;
|
|
10
|
+
|
|
11
|
+
export { type TxOptions, buildTransaction, sendTransaction };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ComputeBudgetProgram, TransactionMessage, VersionedTransaction } from '@solana/web3.js';
|
|
2
|
+
|
|
3
|
+
// src/transaction.ts
|
|
4
|
+
async function buildTransaction(connection, instructions, payer, opts = {}) {
|
|
5
|
+
const cuLimit = opts.computeUnits ?? 2e5;
|
|
6
|
+
const priorityFee = opts.priorityFee ?? 1e3;
|
|
7
|
+
const computeIxs = [
|
|
8
|
+
ComputeBudgetProgram.setComputeUnitLimit({ units: cuLimit }),
|
|
9
|
+
ComputeBudgetProgram.setComputeUnitPrice({ microLamports: priorityFee })
|
|
10
|
+
];
|
|
11
|
+
const { blockhash } = await connection.getLatestBlockhash("confirmed");
|
|
12
|
+
const message = new TransactionMessage({
|
|
13
|
+
payerKey: payer,
|
|
14
|
+
recentBlockhash: blockhash,
|
|
15
|
+
instructions: [...computeIxs, ...instructions]
|
|
16
|
+
}).compileToV0Message();
|
|
17
|
+
return new VersionedTransaction(message);
|
|
18
|
+
}
|
|
19
|
+
async function sendTransaction(connection, tx, opts = {}) {
|
|
20
|
+
const sig = await connection.sendTransaction(tx, {
|
|
21
|
+
skipPreflight: opts.skipPreflight ?? false,
|
|
22
|
+
maxRetries: 3
|
|
23
|
+
});
|
|
24
|
+
const latestBlockhash = await connection.getLatestBlockhash("confirmed");
|
|
25
|
+
await connection.confirmTransaction({
|
|
26
|
+
signature: sig,
|
|
27
|
+
...latestBlockhash
|
|
28
|
+
}, "confirmed");
|
|
29
|
+
return sig;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { buildTransaction, sendTransaction };
|
|
33
|
+
//# sourceMappingURL=transaction.js.map
|
|
34
|
+
//# sourceMappingURL=transaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/transaction.ts"],"names":[],"mappings":";;;AAeA,eAAsB,iBACpB,UAAA,EACA,YAAA,EACA,KAAA,EACA,IAAA,GAAkB,EAAC,EACY;AAC/B,EAAA,MAAM,OAAA,GAAU,KAAK,YAAA,IAAgB,GAAA;AACrC,EAAA,MAAM,WAAA,GAAc,KAAK,WAAA,IAAe,GAAA;AAExC,EAAA,MAAM,UAAA,GAAuC;AAAA,IAC3C,oBAAA,CAAqB,mBAAA,CAAoB,EAAE,KAAA,EAAO,SAAS,CAAA;AAAA,IAC3D,oBAAA,CAAqB,mBAAA,CAAoB,EAAE,aAAA,EAAe,aAAa;AAAA,GACzE;AAEA,EAAA,MAAM,EAAE,SAAA,EAAU,GAAI,MAAM,UAAA,CAAW,mBAAmB,WAAW,CAAA;AAErE,EAAA,MAAM,OAAA,GAAU,IAAI,kBAAA,CAAmB;AAAA,IACrC,QAAA,EAAU,KAAA;AAAA,IACV,eAAA,EAAiB,SAAA;AAAA,IACjB,YAAA,EAAc,CAAC,GAAG,UAAA,EAAY,GAAG,YAAY;AAAA,GAC9C,EAAE,kBAAA,EAAmB;AAEtB,EAAA,OAAO,IAAI,qBAAqB,OAAO,CAAA;AACzC;AAEA,eAAsB,eAAA,CACpB,UAAA,EACA,EAAA,EACA,IAAA,GAAkB,EAAC,EACF;AACjB,EAAA,MAAM,GAAA,GAAM,MAAM,UAAA,CAAW,eAAA,CAAgB,EAAA,EAAI;AAAA,IAC/C,aAAA,EAAe,KAAK,aAAA,IAAiB,KAAA;AAAA,IACrC,UAAA,EAAY;AAAA,GACb,CAAA;AACD,EAAA,MAAM,eAAA,GAAkB,MAAM,UAAA,CAAW,kBAAA,CAAmB,WAAW,CAAA;AACvE,EAAA,MAAM,WAAW,kBAAA,CAAmB;AAAA,IAClC,SAAA,EAAW,GAAA;AAAA,IACX,GAAG;AAAA,KACF,WAAW,CAAA;AACd,EAAA,OAAO,GAAA;AACT","file":"transaction.js","sourcesContent":["import {\n Connection,\n PublicKey,\n TransactionInstruction,\n TransactionMessage,\n VersionedTransaction,\n ComputeBudgetProgram,\n} from '@solana/web3.js'\n\nexport interface TxOptions {\n priorityFee?: number // microlamports per CU\n computeUnits?: number\n skipPreflight?: boolean\n}\n\nexport async function buildTransaction(\n connection: Connection,\n instructions: TransactionInstruction[],\n payer: PublicKey,\n opts: TxOptions = {},\n): Promise<VersionedTransaction> {\n const cuLimit = opts.computeUnits ?? 200_000\n const priorityFee = opts.priorityFee ?? 1_000\n\n const computeIxs: TransactionInstruction[] = [\n ComputeBudgetProgram.setComputeUnitLimit({ units: cuLimit }),\n ComputeBudgetProgram.setComputeUnitPrice({ microLamports: priorityFee }),\n ]\n\n const { blockhash } = await connection.getLatestBlockhash('confirmed')\n\n const message = new TransactionMessage({\n payerKey: payer,\n recentBlockhash: blockhash,\n instructions: [...computeIxs, ...instructions],\n }).compileToV0Message()\n\n return new VersionedTransaction(message)\n}\n\nexport async function sendTransaction(\n connection: Connection,\n tx: VersionedTransaction,\n opts: TxOptions = {},\n): Promise<string> {\n const sig = await connection.sendTransaction(tx, {\n skipPreflight: opts.skipPreflight ?? false,\n maxRetries: 3,\n })\n const latestBlockhash = await connection.getLatestBlockhash('confirmed')\n await connection.confirmTransaction({\n signature: sig,\n ...latestBlockhash,\n }, 'confirmed')\n return sig\n}\n"]}
|
package/dist/types.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"types.cjs"}
|
package/dist/types.d.cts
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { PublicKey } from '@solana/web3.js';
|
|
2
|
+
import BN from 'bn.js';
|
|
3
|
+
|
|
4
|
+
interface SdkConfig {
|
|
5
|
+
programId: PublicKey;
|
|
6
|
+
virtualSol: BN;
|
|
7
|
+
protocolAuthority: PublicKey;
|
|
8
|
+
protocolMintFee: BN;
|
|
9
|
+
decimals: number;
|
|
10
|
+
totalSupply: BN;
|
|
11
|
+
}
|
|
12
|
+
interface PoolMetadata {
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
version: number;
|
|
16
|
+
}
|
|
17
|
+
interface PoolState {
|
|
18
|
+
authority: PublicKey;
|
|
19
|
+
mint: PublicKey;
|
|
20
|
+
tokenVault: PublicKey;
|
|
21
|
+
vaultAuthority: PublicKey;
|
|
22
|
+
solVault: PublicKey;
|
|
23
|
+
totalPositions: BN;
|
|
24
|
+
creationTimestamp: BN;
|
|
25
|
+
lastUpdateTimestamp: BN;
|
|
26
|
+
metadata: PoolMetadata;
|
|
27
|
+
vestDuration: BN;
|
|
28
|
+
nextPositionNumber: BN;
|
|
29
|
+
vammActive: boolean;
|
|
30
|
+
vammRealSol: BN;
|
|
31
|
+
vammTokens: BN;
|
|
32
|
+
vammK: BN;
|
|
33
|
+
tokensSold: BN;
|
|
34
|
+
tokensReservedForClaims: BN;
|
|
35
|
+
bumpVaultAuth: number;
|
|
36
|
+
bumpPool: number;
|
|
37
|
+
}
|
|
38
|
+
interface Position {
|
|
39
|
+
owner: PublicKey;
|
|
40
|
+
pool: PublicKey;
|
|
41
|
+
tradableTokens: BN;
|
|
42
|
+
vaultedTokens: BN;
|
|
43
|
+
solSpent: BN;
|
|
44
|
+
tokensTransferred: BN;
|
|
45
|
+
entryTimestamp: BN;
|
|
46
|
+
initialVaulted: BN;
|
|
47
|
+
positionNumber: BN;
|
|
48
|
+
lastUpdateTimestamp: BN;
|
|
49
|
+
}
|
|
50
|
+
interface BuyParams {
|
|
51
|
+
solAmount: BN;
|
|
52
|
+
minTokensOut: BN;
|
|
53
|
+
}
|
|
54
|
+
interface SellParams {
|
|
55
|
+
tokenAmount: BN;
|
|
56
|
+
minSolOut: BN;
|
|
57
|
+
sellPercentage?: number;
|
|
58
|
+
}
|
|
59
|
+
interface CreateTokenParams {
|
|
60
|
+
name: string;
|
|
61
|
+
symbol: string;
|
|
62
|
+
uri: string;
|
|
63
|
+
poolDescription: string;
|
|
64
|
+
vestDuration: BN;
|
|
65
|
+
}
|
|
66
|
+
interface TokenPurchasedEvent {
|
|
67
|
+
buyer: PublicKey;
|
|
68
|
+
pool: PublicKey;
|
|
69
|
+
mint: PublicKey;
|
|
70
|
+
solAmount: BN;
|
|
71
|
+
tokensReceived: BN;
|
|
72
|
+
vammRealSol: BN;
|
|
73
|
+
vammTokens: BN;
|
|
74
|
+
tokensSold: BN;
|
|
75
|
+
position: PublicKey;
|
|
76
|
+
positionNumber: BN;
|
|
77
|
+
vestDuration: BN;
|
|
78
|
+
unlockTimeSeconds: BN;
|
|
79
|
+
tradableTokens: BN;
|
|
80
|
+
vaultedTokens: BN;
|
|
81
|
+
solSpent: BN;
|
|
82
|
+
tokensTransferred: BN;
|
|
83
|
+
initialVaulted: BN;
|
|
84
|
+
timestamp: BN;
|
|
85
|
+
}
|
|
86
|
+
interface TokenSoldEvent {
|
|
87
|
+
seller: PublicKey;
|
|
88
|
+
pool: PublicKey;
|
|
89
|
+
mint: PublicKey;
|
|
90
|
+
tokenAmount: BN;
|
|
91
|
+
solReceived: BN;
|
|
92
|
+
vammRealSol: BN;
|
|
93
|
+
vammTokens: BN;
|
|
94
|
+
tokensSold: BN;
|
|
95
|
+
position: PublicKey;
|
|
96
|
+
positionNumber: BN;
|
|
97
|
+
vestDuration: BN;
|
|
98
|
+
unlockTimeSeconds: BN;
|
|
99
|
+
tradableTokens: BN;
|
|
100
|
+
vaultedTokens: BN;
|
|
101
|
+
solSpent: BN;
|
|
102
|
+
tokensTransferred: BN;
|
|
103
|
+
initialVaulted: BN;
|
|
104
|
+
timestamp: BN;
|
|
105
|
+
}
|
|
106
|
+
interface TokenCreatedEvent {
|
|
107
|
+
mint: PublicKey;
|
|
108
|
+
pool: PublicKey;
|
|
109
|
+
creator: PublicKey;
|
|
110
|
+
name: string;
|
|
111
|
+
symbol: string;
|
|
112
|
+
totalSupply: BN;
|
|
113
|
+
initialK: BN;
|
|
114
|
+
vammTokens: BN;
|
|
115
|
+
vestDuration: BN;
|
|
116
|
+
creationTimestamp: BN;
|
|
117
|
+
}
|
|
118
|
+
interface AccrualClaimedEvent {
|
|
119
|
+
owner: PublicKey;
|
|
120
|
+
pool: PublicKey;
|
|
121
|
+
position: PublicKey;
|
|
122
|
+
tokensClaimed: BN;
|
|
123
|
+
newTradableTokens: BN;
|
|
124
|
+
remainingVaultedTokens: BN;
|
|
125
|
+
tokensTransferred: BN;
|
|
126
|
+
initialVaulted: BN;
|
|
127
|
+
timestamp: BN;
|
|
128
|
+
}
|
|
129
|
+
interface PositionClosedEvent {
|
|
130
|
+
owner: PublicKey;
|
|
131
|
+
pool: PublicKey;
|
|
132
|
+
position: PublicKey;
|
|
133
|
+
rentReclaimed: BN;
|
|
134
|
+
timestamp: BN;
|
|
135
|
+
}
|
|
136
|
+
type HodlEvent = {
|
|
137
|
+
name: 'tokenPurchased';
|
|
138
|
+
data: TokenPurchasedEvent;
|
|
139
|
+
} | {
|
|
140
|
+
name: 'tokenSold';
|
|
141
|
+
data: TokenSoldEvent;
|
|
142
|
+
} | {
|
|
143
|
+
name: 'tokenCreated';
|
|
144
|
+
data: TokenCreatedEvent;
|
|
145
|
+
} | {
|
|
146
|
+
name: 'accrualClaimed';
|
|
147
|
+
data: AccrualClaimedEvent;
|
|
148
|
+
} | {
|
|
149
|
+
name: 'positionClosed';
|
|
150
|
+
data: PositionClosedEvent;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export type { AccrualClaimedEvent, BuyParams, CreateTokenParams, HodlEvent, PoolMetadata, PoolState, Position, PositionClosedEvent, SdkConfig, SellParams, TokenCreatedEvent, TokenPurchasedEvent, TokenSoldEvent };
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { PublicKey } from '@solana/web3.js';
|
|
2
|
+
import BN from 'bn.js';
|
|
3
|
+
|
|
4
|
+
interface SdkConfig {
|
|
5
|
+
programId: PublicKey;
|
|
6
|
+
virtualSol: BN;
|
|
7
|
+
protocolAuthority: PublicKey;
|
|
8
|
+
protocolMintFee: BN;
|
|
9
|
+
decimals: number;
|
|
10
|
+
totalSupply: BN;
|
|
11
|
+
}
|
|
12
|
+
interface PoolMetadata {
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
version: number;
|
|
16
|
+
}
|
|
17
|
+
interface PoolState {
|
|
18
|
+
authority: PublicKey;
|
|
19
|
+
mint: PublicKey;
|
|
20
|
+
tokenVault: PublicKey;
|
|
21
|
+
vaultAuthority: PublicKey;
|
|
22
|
+
solVault: PublicKey;
|
|
23
|
+
totalPositions: BN;
|
|
24
|
+
creationTimestamp: BN;
|
|
25
|
+
lastUpdateTimestamp: BN;
|
|
26
|
+
metadata: PoolMetadata;
|
|
27
|
+
vestDuration: BN;
|
|
28
|
+
nextPositionNumber: BN;
|
|
29
|
+
vammActive: boolean;
|
|
30
|
+
vammRealSol: BN;
|
|
31
|
+
vammTokens: BN;
|
|
32
|
+
vammK: BN;
|
|
33
|
+
tokensSold: BN;
|
|
34
|
+
tokensReservedForClaims: BN;
|
|
35
|
+
bumpVaultAuth: number;
|
|
36
|
+
bumpPool: number;
|
|
37
|
+
}
|
|
38
|
+
interface Position {
|
|
39
|
+
owner: PublicKey;
|
|
40
|
+
pool: PublicKey;
|
|
41
|
+
tradableTokens: BN;
|
|
42
|
+
vaultedTokens: BN;
|
|
43
|
+
solSpent: BN;
|
|
44
|
+
tokensTransferred: BN;
|
|
45
|
+
entryTimestamp: BN;
|
|
46
|
+
initialVaulted: BN;
|
|
47
|
+
positionNumber: BN;
|
|
48
|
+
lastUpdateTimestamp: BN;
|
|
49
|
+
}
|
|
50
|
+
interface BuyParams {
|
|
51
|
+
solAmount: BN;
|
|
52
|
+
minTokensOut: BN;
|
|
53
|
+
}
|
|
54
|
+
interface SellParams {
|
|
55
|
+
tokenAmount: BN;
|
|
56
|
+
minSolOut: BN;
|
|
57
|
+
sellPercentage?: number;
|
|
58
|
+
}
|
|
59
|
+
interface CreateTokenParams {
|
|
60
|
+
name: string;
|
|
61
|
+
symbol: string;
|
|
62
|
+
uri: string;
|
|
63
|
+
poolDescription: string;
|
|
64
|
+
vestDuration: BN;
|
|
65
|
+
}
|
|
66
|
+
interface TokenPurchasedEvent {
|
|
67
|
+
buyer: PublicKey;
|
|
68
|
+
pool: PublicKey;
|
|
69
|
+
mint: PublicKey;
|
|
70
|
+
solAmount: BN;
|
|
71
|
+
tokensReceived: BN;
|
|
72
|
+
vammRealSol: BN;
|
|
73
|
+
vammTokens: BN;
|
|
74
|
+
tokensSold: BN;
|
|
75
|
+
position: PublicKey;
|
|
76
|
+
positionNumber: BN;
|
|
77
|
+
vestDuration: BN;
|
|
78
|
+
unlockTimeSeconds: BN;
|
|
79
|
+
tradableTokens: BN;
|
|
80
|
+
vaultedTokens: BN;
|
|
81
|
+
solSpent: BN;
|
|
82
|
+
tokensTransferred: BN;
|
|
83
|
+
initialVaulted: BN;
|
|
84
|
+
timestamp: BN;
|
|
85
|
+
}
|
|
86
|
+
interface TokenSoldEvent {
|
|
87
|
+
seller: PublicKey;
|
|
88
|
+
pool: PublicKey;
|
|
89
|
+
mint: PublicKey;
|
|
90
|
+
tokenAmount: BN;
|
|
91
|
+
solReceived: BN;
|
|
92
|
+
vammRealSol: BN;
|
|
93
|
+
vammTokens: BN;
|
|
94
|
+
tokensSold: BN;
|
|
95
|
+
position: PublicKey;
|
|
96
|
+
positionNumber: BN;
|
|
97
|
+
vestDuration: BN;
|
|
98
|
+
unlockTimeSeconds: BN;
|
|
99
|
+
tradableTokens: BN;
|
|
100
|
+
vaultedTokens: BN;
|
|
101
|
+
solSpent: BN;
|
|
102
|
+
tokensTransferred: BN;
|
|
103
|
+
initialVaulted: BN;
|
|
104
|
+
timestamp: BN;
|
|
105
|
+
}
|
|
106
|
+
interface TokenCreatedEvent {
|
|
107
|
+
mint: PublicKey;
|
|
108
|
+
pool: PublicKey;
|
|
109
|
+
creator: PublicKey;
|
|
110
|
+
name: string;
|
|
111
|
+
symbol: string;
|
|
112
|
+
totalSupply: BN;
|
|
113
|
+
initialK: BN;
|
|
114
|
+
vammTokens: BN;
|
|
115
|
+
vestDuration: BN;
|
|
116
|
+
creationTimestamp: BN;
|
|
117
|
+
}
|
|
118
|
+
interface AccrualClaimedEvent {
|
|
119
|
+
owner: PublicKey;
|
|
120
|
+
pool: PublicKey;
|
|
121
|
+
position: PublicKey;
|
|
122
|
+
tokensClaimed: BN;
|
|
123
|
+
newTradableTokens: BN;
|
|
124
|
+
remainingVaultedTokens: BN;
|
|
125
|
+
tokensTransferred: BN;
|
|
126
|
+
initialVaulted: BN;
|
|
127
|
+
timestamp: BN;
|
|
128
|
+
}
|
|
129
|
+
interface PositionClosedEvent {
|
|
130
|
+
owner: PublicKey;
|
|
131
|
+
pool: PublicKey;
|
|
132
|
+
position: PublicKey;
|
|
133
|
+
rentReclaimed: BN;
|
|
134
|
+
timestamp: BN;
|
|
135
|
+
}
|
|
136
|
+
type HodlEvent = {
|
|
137
|
+
name: 'tokenPurchased';
|
|
138
|
+
data: TokenPurchasedEvent;
|
|
139
|
+
} | {
|
|
140
|
+
name: 'tokenSold';
|
|
141
|
+
data: TokenSoldEvent;
|
|
142
|
+
} | {
|
|
143
|
+
name: 'tokenCreated';
|
|
144
|
+
data: TokenCreatedEvent;
|
|
145
|
+
} | {
|
|
146
|
+
name: 'accrualClaimed';
|
|
147
|
+
data: AccrualClaimedEvent;
|
|
148
|
+
} | {
|
|
149
|
+
name: 'positionClosed';
|
|
150
|
+
data: PositionClosedEvent;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export type { AccrualClaimedEvent, BuyParams, CreateTokenParams, HodlEvent, PoolMetadata, PoolState, Position, PositionClosedEvent, SdkConfig, SellParams, TokenCreatedEvent, TokenPurchasedEvent, TokenSoldEvent };
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"types.js"}
|
package/package.json
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hodlmarkets/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Solana program SDK for the HODL token launchpad/trading platform",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"main": "./dist/index.cjs",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./client": {
|
|
16
|
+
"types": "./dist/client.d.ts",
|
|
17
|
+
"import": "./dist/client.js",
|
|
18
|
+
"require": "./dist/client.cjs"
|
|
19
|
+
},
|
|
20
|
+
"./pda": {
|
|
21
|
+
"types": "./dist/pda.d.ts",
|
|
22
|
+
"import": "./dist/pda.js",
|
|
23
|
+
"require": "./dist/pda.cjs"
|
|
24
|
+
},
|
|
25
|
+
"./instructions": {
|
|
26
|
+
"types": "./dist/instructions.d.ts",
|
|
27
|
+
"import": "./dist/instructions.js",
|
|
28
|
+
"require": "./dist/instructions.cjs"
|
|
29
|
+
},
|
|
30
|
+
"./accounts": {
|
|
31
|
+
"types": "./dist/accounts.d.ts",
|
|
32
|
+
"import": "./dist/accounts.js",
|
|
33
|
+
"require": "./dist/accounts.cjs"
|
|
34
|
+
},
|
|
35
|
+
"./math": {
|
|
36
|
+
"types": "./dist/math.d.ts",
|
|
37
|
+
"import": "./dist/math.js",
|
|
38
|
+
"require": "./dist/math.cjs"
|
|
39
|
+
},
|
|
40
|
+
"./events": {
|
|
41
|
+
"types": "./dist/events.d.ts",
|
|
42
|
+
"import": "./dist/events.js",
|
|
43
|
+
"require": "./dist/events.cjs"
|
|
44
|
+
},
|
|
45
|
+
"./transaction": {
|
|
46
|
+
"types": "./dist/transaction.d.ts",
|
|
47
|
+
"import": "./dist/transaction.js",
|
|
48
|
+
"require": "./dist/transaction.cjs"
|
|
49
|
+
},
|
|
50
|
+
"./errors": {
|
|
51
|
+
"types": "./dist/errors.d.ts",
|
|
52
|
+
"import": "./dist/errors.js",
|
|
53
|
+
"require": "./dist/errors.cjs"
|
|
54
|
+
},
|
|
55
|
+
"./types": {
|
|
56
|
+
"types": "./dist/types.d.ts",
|
|
57
|
+
"import": "./dist/types.js",
|
|
58
|
+
"require": "./dist/types.cjs"
|
|
59
|
+
},
|
|
60
|
+
"./constants": {
|
|
61
|
+
"types": "./dist/constants.d.ts",
|
|
62
|
+
"import": "./dist/constants.js",
|
|
63
|
+
"require": "./dist/constants.cjs"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"files": [
|
|
67
|
+
"dist"
|
|
68
|
+
],
|
|
69
|
+
"license": "MIT",
|
|
70
|
+
"scripts": {
|
|
71
|
+
"build": "tsup",
|
|
72
|
+
"build:watch": "tsup --watch",
|
|
73
|
+
"typecheck": "tsc --noEmit",
|
|
74
|
+
"test": "vitest run",
|
|
75
|
+
"test:watch": "vitest",
|
|
76
|
+
"prepublishOnly": "npm run build"
|
|
77
|
+
},
|
|
78
|
+
"peerDependencies": {
|
|
79
|
+
"@coral-xyz/anchor": ">=0.30.0",
|
|
80
|
+
"@solana/spl-token": ">=0.4.0",
|
|
81
|
+
"@solana/web3.js": ">=1.95.0",
|
|
82
|
+
"bn.js": ">=5.0.0"
|
|
83
|
+
},
|
|
84
|
+
"devDependencies": {
|
|
85
|
+
"@coral-xyz/anchor": "0.32.1",
|
|
86
|
+
"@solana/spl-token": "0.4.9",
|
|
87
|
+
"@solana/web3.js": "1.95.8",
|
|
88
|
+
"@types/bn.js": "^5.1.6",
|
|
89
|
+
"@types/node": "^22.10.0",
|
|
90
|
+
"bn.js": "^5.2.1",
|
|
91
|
+
"fast-check": "^4.6.0",
|
|
92
|
+
"tsup": "^8.3.0",
|
|
93
|
+
"typescript": "^5.7.0",
|
|
94
|
+
"vitest": "^2.1.9"
|
|
95
|
+
}
|
|
96
|
+
}
|