yamaswap-sdk
Version:
ETF SDK for Solana and Evm
766 lines (761 loc) • 24.2 kB
text/typescript
import * as anchor from '@coral-xyz/anchor';
import { PublicKey, Connection } from '@solana/web3.js';
import { A as AnchorWallet, E as ETFCreateParams, b as ETFCreateResult, M as MintETFTokenParams, c as MintETFResult, a as ETFBurnParams } from './params-D5pUAaOi.mjs';
/**
* Program IDL in camelCase format in order to be used in JS/TS.
*
* Note that this is only a type helper and is not the actual IDL. The original
* IDL can be found at `target/idl/iswap.json`.
*/
type Iswap = {
"address": "dXgZyuguvD2m5G5385XkdokZBryUoSE6LbNJeWiFiN5";
"metadata": {
"name": "iswap";
"version": "0.1.0";
"spec": "0.1.0";
"description": "Created with Anchor";
};
"instructions": [
{
"name": "close";
"discriminator": [
98,
165,
201,
177,
108,
65,
206,
96
];
"accounts": [
{
"name": "payer";
"writable": true;
"signer": true;
},
{
"name": "iswap";
"writable": true;
}
];
"args": [];
},
{
"name": "decrement";
"discriminator": [
106,
227,
168,
59,
248,
27,
150,
101
];
"accounts": [
{
"name": "iswap";
"writable": true;
}
];
"args": [];
},
{
"name": "etfBurn";
"discriminator": [
185,
203,
114,
195,
129,
70,
235,
23
];
"accounts": [
{
"name": "etfTokenInfo";
"pda": {
"seeds": [
{
"kind": "const";
"value": [
101,
116,
102,
95,
116,
111,
107,
101,
110,
95,
118,
51
];
},
{
"kind": "account";
"path": "etfTokenMintAccount";
}
];
};
},
{
"name": "etfTokenMintAccount";
"writable": true;
},
{
"name": "etfTokenAta";
"writable": true;
"pda": {
"seeds": [
{
"kind": "account";
"path": "authority";
},
{
"kind": "const";
"value": [
6,
221,
246,
225,
215,
101,
161,
147,
217,
203,
225,
70,
206,
235,
121,
172,
28,
180,
133,
237,
95,
91,
55,
145,
58,
140,
245,
133,
126,
255,
0,
169
];
},
{
"kind": "account";
"path": "etfTokenMintAccount";
}
];
"program": {
"kind": "const";
"value": [
140,
151,
37,
143,
78,
36,
137,
241,
187,
61,
16,
41,
20,
142,
13,
131,
11,
90,
19,
153,
218,
255,
16,
132,
4,
142,
123,
216,
219,
233,
248,
89
];
};
};
},
{
"name": "authority";
"writable": true;
"signer": true;
},
{
"name": "tokenProgram";
"address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
},
{
"name": "associatedTokenProgram";
"address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
},
{
"name": "systemProgram";
"address": "11111111111111111111111111111111";
}
];
"args": [
{
"name": "lamports";
"type": "u64";
}
];
},
{
"name": "etfCreate";
"discriminator": [
0,
81,
62,
85,
242,
37,
4,
245
];
"accounts": [
{
"name": "etfTokenInfo";
"writable": true;
"pda": {
"seeds": [
{
"kind": "const";
"value": [
101,
116,
102,
95,
116,
111,
107,
101,
110,
95,
118,
51
];
},
{
"kind": "account";
"path": "etfTokenMintAccount";
}
];
};
},
{
"name": "metadataAccount";
"writable": true;
"pda": {
"seeds": [
{
"kind": "const";
"value": [
109,
101,
116,
97,
100,
97,
116,
97
];
},
{
"kind": "account";
"path": "tokenMetadataProgram";
},
{
"kind": "account";
"path": "etfTokenMintAccount";
}
];
"program": {
"kind": "account";
"path": "tokenMetadataProgram";
};
};
},
{
"name": "etfTokenMintAccount";
"writable": true;
"pda": {
"seeds": [
{
"kind": "const";
"value": [
101,
116,
102,
95,
116,
111,
107,
101,
110,
95,
118,
51
];
},
{
"kind": "arg";
"path": "args.symbol";
}
];
};
},
{
"name": "rent";
"address": "SysvarRent111111111111111111111111111111111";
},
{
"name": "authority";
"writable": true;
"signer": true;
},
{
"name": "tokenMetadataProgram";
"address": "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s";
},
{
"name": "tokenProgram";
"address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
},
{
"name": "systemProgram";
"address": "11111111111111111111111111111111";
}
];
"args": [
{
"name": "args";
"type": {
"defined": {
"name": "etfTokenArgs";
};
};
}
];
},
{
"name": "etfMint";
"discriminator": [
253,
102,
37,
173,
154,
46,
245,
224
];
"accounts": [
{
"name": "etfTokenInfo";
"pda": {
"seeds": [
{
"kind": "const";
"value": [
101,
116,
102,
95,
116,
111,
107,
101,
110,
95,
118,
51
];
},
{
"kind": "account";
"path": "etfTokenMintAccount";
}
];
};
},
{
"name": "etfTokenMintAccount";
"writable": true;
},
{
"name": "etfTokenAta";
"writable": true;
"pda": {
"seeds": [
{
"kind": "account";
"path": "authority";
},
{
"kind": "const";
"value": [
6,
221,
246,
225,
215,
101,
161,
147,
217,
203,
225,
70,
206,
235,
121,
172,
28,
180,
133,
237,
95,
91,
55,
145,
58,
140,
245,
133,
126,
255,
0,
169
];
},
{
"kind": "account";
"path": "etfTokenMintAccount";
}
];
"program": {
"kind": "const";
"value": [
140,
151,
37,
143,
78,
36,
137,
241,
187,
61,
16,
41,
20,
142,
13,
131,
11,
90,
19,
153,
218,
255,
16,
132,
4,
142,
123,
216,
219,
233,
248,
89
];
};
};
},
{
"name": "authority";
"writable": true;
"signer": true;
},
{
"name": "tokenProgram";
"address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
},
{
"name": "associatedTokenProgram";
"address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
},
{
"name": "systemProgram";
"address": "11111111111111111111111111111111";
}
];
"args": [
{
"name": "lamports";
"type": "u64";
}
];
},
{
"name": "increment";
"discriminator": [
11,
18,
104,
9,
104,
174,
59,
33
];
"accounts": [
{
"name": "iswap";
"writable": true;
}
];
"args": [];
},
{
"name": "initialize";
"discriminator": [
175,
175,
109,
31,
13,
152,
155,
237
];
"accounts": [
{
"name": "payer";
"writable": true;
"signer": true;
},
{
"name": "iswap";
"writable": true;
"signer": true;
},
{
"name": "systemProgram";
"address": "11111111111111111111111111111111";
}
];
"args": [];
},
{
"name": "set";
"discriminator": [
198,
51,
53,
241,
116,
29,
126,
194
];
"accounts": [
{
"name": "iswap";
"writable": true;
}
];
"args": [
{
"name": "value";
"type": "u8";
}
];
}
];
"accounts": [
{
"name": "etfToken";
"discriminator": [
187,
90,
26,
73,
137,
112,
105,
60
];
},
{
"name": "iswap";
"discriminator": [
228,
5,
227,
43,
35,
87,
170,
87
];
}
];
"errors": [
{
"code": 6000;
"name": "invalidAccounts";
"msg": "Lack of necessary accounts";
},
{
"code": 6001;
"name": "insufficientBalance";
"msg": "Insufficient balance";
}
];
"types": [
{
"name": "etfAsset";
"type": {
"kind": "struct";
"fields": [
{
"name": "token";
"type": "pubkey";
},
{
"name": "weight";
"type": "u16";
}
];
};
},
{
"name": "etfToken";
"type": {
"kind": "struct";
"fields": [
{
"name": "mintAccount";
"type": "pubkey";
},
{
"name": "creator";
"type": "pubkey";
},
{
"name": "createAt";
"type": "i64";
},
{
"name": "description";
"type": "string";
},
{
"name": "assets";
"type": {
"vec": {
"defined": {
"name": "etfAsset";
};
};
};
}
];
};
},
{
"name": "etfTokenArgs";
"type": {
"kind": "struct";
"fields": [
{
"name": "name";
"type": "string";
},
{
"name": "symbol";
"type": "string";
},
{
"name": "description";
"type": "string";
},
{
"name": "url";
"type": "string";
},
{
"name": "assets";
"type": {
"vec": {
"defined": {
"name": "etfAsset";
};
};
};
}
];
};
},
{
"name": "iswap";
"type": {
"kind": "struct";
"fields": [
{
"name": "count";
"type": "u8";
}
];
};
}
];
};
interface ETFInfo {
etfCoreAddress: PublicKey;
creator: string;
description: string;
assets: Array<{
token: PublicKey;
weight: number;
}>;
}
declare class ETFQueries {
private client;
constructor(client: DexClient);
getETFInfo(etfAddress: PublicKey): Promise<ETFInfo | string>;
getETFBalance(etfAddress: PublicKey, ownerAddress: PublicKey): Promise<number>;
}
declare class DexClient {
connection: Connection;
readonly program: anchor.Program<Iswap>;
readonly queries: ETFQueries;
private readonly wallet;
constructor(connection: Connection, wallet: AnchorWallet, provider: anchor.AnchorProvider);
createETF(params: ETFCreateParams): Promise<ETFCreateResult>;
purchaseETF(params: MintETFTokenParams): Promise<MintETFResult>;
burnETF(params: ETFBurnParams): Promise<MintETFResult>;
}
export { DexClient as D, type ETFInfo as E };