@metadaoproject/futarchy 0.7.0-alpha.8 → 0.7.1-alpha.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/dist/v0.6/LaunchpadClient.js +1 -1
- package/dist/v0.6/types/price_based_performance_package.d.ts +51 -0
- package/dist/v0.6/types/price_based_performance_package.js +51 -0
- package/dist/v0.6/types/price_based_performance_package.js.map +1 -1
- package/dist/v0.7/BidWallClient.d.ts +4 -3
- package/dist/v0.7/BidWallClient.js +9 -6
- package/dist/v0.7/BidWallClient.js.map +1 -1
- package/dist/v0.7/ConditionalVaultClient.d.ts +2 -2
- package/dist/v0.7/FutarchyClient.d.ts +14 -1
- package/dist/v0.7/FutarchyClient.js +6 -1
- package/dist/v0.7/FutarchyClient.js.map +1 -1
- package/dist/v0.7/LaunchpadClient.d.ts +3 -2
- package/dist/v0.7/LaunchpadClient.js +4 -3
- package/dist/v0.7/LaunchpadClient.js.map +1 -1
- package/dist/v0.7/LiquidationClient.d.ts +315 -0
- package/dist/v0.7/LiquidationClient.js +148 -0
- package/dist/v0.7/LiquidationClient.js.map +1 -0
- package/dist/v0.7/MintGovernorClient.d.ts +346 -0
- package/dist/v0.7/MintGovernorClient.js +114 -0
- package/dist/v0.7/MintGovernorClient.js.map +1 -0
- package/dist/v0.7/PerformancePackageV2Client.d.ts +327 -0
- package/dist/v0.7/PerformancePackageV2Client.js +140 -0
- package/dist/v0.7/PerformancePackageV2Client.js.map +1 -0
- package/dist/v0.7/PriceBasedPerformancePackageClient.d.ts +16 -7
- package/dist/v0.7/constants.d.ts +3 -0
- package/dist/v0.7/constants.js +3 -0
- package/dist/v0.7/constants.js.map +1 -1
- package/dist/v0.7/index.d.ts +3 -0
- package/dist/v0.7/index.js +3 -0
- package/dist/v0.7/index.js.map +1 -1
- package/dist/v0.7/types/bid_wall.d.ts +10 -1
- package/dist/v0.7/types/bid_wall.js +10 -1
- package/dist/v0.7/types/bid_wall.js.map +1 -1
- package/dist/v0.7/types/conditional_vault.d.ts +12 -19
- package/dist/v0.7/types/conditional_vault.js +12 -19
- package/dist/v0.7/types/conditional_vault.js.map +1 -1
- package/dist/v0.7/types/futarchy.d.ts +366 -6
- package/dist/v0.7/types/futarchy.js +366 -6
- package/dist/v0.7/types/futarchy.js.map +1 -1
- package/dist/v0.7/types/index.d.ts +26 -0
- package/dist/v0.7/types/index.js +6 -0
- package/dist/v0.7/types/index.js.map +1 -1
- package/dist/v0.7/types/launchpad_v7.d.ts +328 -1
- package/dist/v0.7/types/launchpad_v7.js +328 -1
- package/dist/v0.7/types/launchpad_v7.js.map +1 -1
- package/dist/v0.7/types/liquidation.d.ts +723 -0
- package/dist/v0.7/types/liquidation.js +723 -0
- package/dist/v0.7/types/liquidation.js.map +1 -0
- package/dist/v0.7/types/mint_governor.d.ts +737 -0
- package/dist/v0.7/types/mint_governor.js +737 -0
- package/dist/v0.7/types/mint_governor.js.map +1 -0
- package/dist/v0.7/types/performance_package_v2.d.ts +1079 -0
- package/dist/v0.7/types/performance_package_v2.js +1079 -0
- package/dist/v0.7/types/performance_package_v2.js.map +1 -0
- package/dist/v0.7/types/price_based_performance_package.d.ts +88 -3
- package/dist/v0.7/types/price_based_performance_package.js +88 -3
- package/dist/v0.7/types/price_based_performance_package.js.map +1 -1
- package/dist/v0.7/utils/pda.d.ts +31 -0
- package/dist/v0.7/utils/pda.js +37 -2
- package/dist/v0.7/utils/pda.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { AnchorProvider, Program } from "@coral-xyz/anchor";
|
|
2
|
+
import BN from "bn.js";
|
|
3
|
+
import { AccountInfo, PublicKey } from "@solana/web3.js";
|
|
4
|
+
import { LiquidationProgram, LiquidationAccount, RefundRecordAccount } from "../v0.7/types/index.js";
|
|
5
|
+
export type CreateLiquidationClientParams = {
|
|
6
|
+
provider: AnchorProvider;
|
|
7
|
+
liquidationProgramId?: PublicKey;
|
|
8
|
+
};
|
|
9
|
+
export declare class LiquidationClient {
|
|
10
|
+
readonly provider: AnchorProvider;
|
|
11
|
+
readonly liquidationProgram: Program<LiquidationProgram>;
|
|
12
|
+
readonly programId: PublicKey;
|
|
13
|
+
constructor(provider: AnchorProvider, liquidationProgramId: PublicKey);
|
|
14
|
+
static createClient(createLiquidationClientParams: CreateLiquidationClientParams): LiquidationClient;
|
|
15
|
+
getProgramId(): PublicKey;
|
|
16
|
+
fetchLiquidation(liquidation: PublicKey): Promise<LiquidationAccount | null>;
|
|
17
|
+
deserializeLiquidation(accountInfo: AccountInfo<Buffer>): Promise<LiquidationAccount>;
|
|
18
|
+
fetchRefundRecord(refundRecord: PublicKey): Promise<RefundRecordAccount | null>;
|
|
19
|
+
deserializeRefundRecord(accountInfo: AccountInfo<Buffer>): Promise<RefundRecordAccount>;
|
|
20
|
+
getLiquidation({ baseMint, quoteMint, createKey, }: {
|
|
21
|
+
baseMint: PublicKey;
|
|
22
|
+
quoteMint: PublicKey;
|
|
23
|
+
createKey: PublicKey;
|
|
24
|
+
}): Promise<LiquidationAccount | null>;
|
|
25
|
+
initializeLiquidationIx({ durationSeconds, createKey, recordAuthority, liquidationAuthority, baseMint, quoteMint, payer, }: {
|
|
26
|
+
durationSeconds: number;
|
|
27
|
+
createKey: PublicKey;
|
|
28
|
+
recordAuthority: PublicKey;
|
|
29
|
+
liquidationAuthority: PublicKey;
|
|
30
|
+
baseMint: PublicKey;
|
|
31
|
+
quoteMint: PublicKey;
|
|
32
|
+
payer?: PublicKey;
|
|
33
|
+
}): import("@coral-xyz/anchor/dist/cjs/program/namespace/methods.js").MethodsBuilder<LiquidationProgram, {
|
|
34
|
+
name: "initializeLiquidation";
|
|
35
|
+
accounts: [{
|
|
36
|
+
name: "payer";
|
|
37
|
+
isMut: true;
|
|
38
|
+
isSigner: true;
|
|
39
|
+
}, {
|
|
40
|
+
name: "createKey";
|
|
41
|
+
isMut: false;
|
|
42
|
+
isSigner: true;
|
|
43
|
+
}, {
|
|
44
|
+
name: "recordAuthority";
|
|
45
|
+
isMut: false;
|
|
46
|
+
isSigner: false;
|
|
47
|
+
}, {
|
|
48
|
+
name: "liquidationAuthority";
|
|
49
|
+
isMut: false;
|
|
50
|
+
isSigner: false;
|
|
51
|
+
}, {
|
|
52
|
+
name: "baseMint";
|
|
53
|
+
isMut: false;
|
|
54
|
+
isSigner: false;
|
|
55
|
+
}, {
|
|
56
|
+
name: "quoteMint";
|
|
57
|
+
isMut: false;
|
|
58
|
+
isSigner: false;
|
|
59
|
+
}, {
|
|
60
|
+
name: "liquidation";
|
|
61
|
+
isMut: true;
|
|
62
|
+
isSigner: false;
|
|
63
|
+
}, {
|
|
64
|
+
name: "liquidationQuoteVault";
|
|
65
|
+
isMut: true;
|
|
66
|
+
isSigner: false;
|
|
67
|
+
}, {
|
|
68
|
+
name: "systemProgram";
|
|
69
|
+
isMut: false;
|
|
70
|
+
isSigner: false;
|
|
71
|
+
}, {
|
|
72
|
+
name: "tokenProgram";
|
|
73
|
+
isMut: false;
|
|
74
|
+
isSigner: false;
|
|
75
|
+
}, {
|
|
76
|
+
name: "associatedTokenProgram";
|
|
77
|
+
isMut: false;
|
|
78
|
+
isSigner: false;
|
|
79
|
+
}, {
|
|
80
|
+
name: "eventAuthority";
|
|
81
|
+
isMut: false;
|
|
82
|
+
isSigner: false;
|
|
83
|
+
}, {
|
|
84
|
+
name: "program";
|
|
85
|
+
isMut: false;
|
|
86
|
+
isSigner: false;
|
|
87
|
+
}];
|
|
88
|
+
args: [{
|
|
89
|
+
name: "args";
|
|
90
|
+
type: {
|
|
91
|
+
defined: "InitializeLiquidationArgs";
|
|
92
|
+
};
|
|
93
|
+
}];
|
|
94
|
+
} & {
|
|
95
|
+
name: "initializeLiquidation";
|
|
96
|
+
}>;
|
|
97
|
+
setRefundRecordIx({ baseAssigned, quoteRefundable, recordAuthority, liquidation, recipient, payer, }: {
|
|
98
|
+
baseAssigned: BN;
|
|
99
|
+
quoteRefundable: BN;
|
|
100
|
+
recordAuthority: PublicKey;
|
|
101
|
+
liquidation: PublicKey;
|
|
102
|
+
recipient: PublicKey;
|
|
103
|
+
payer?: PublicKey;
|
|
104
|
+
}): import("@coral-xyz/anchor/dist/cjs/program/namespace/methods.js").MethodsBuilder<LiquidationProgram, {
|
|
105
|
+
name: "setRefundRecord";
|
|
106
|
+
accounts: [{
|
|
107
|
+
name: "payer";
|
|
108
|
+
isMut: true;
|
|
109
|
+
isSigner: true;
|
|
110
|
+
}, {
|
|
111
|
+
name: "recordAuthority";
|
|
112
|
+
isMut: false;
|
|
113
|
+
isSigner: true;
|
|
114
|
+
}, {
|
|
115
|
+
name: "liquidation";
|
|
116
|
+
isMut: true;
|
|
117
|
+
isSigner: false;
|
|
118
|
+
}, {
|
|
119
|
+
name: "recipient";
|
|
120
|
+
isMut: false;
|
|
121
|
+
isSigner: false;
|
|
122
|
+
}, {
|
|
123
|
+
name: "refundRecord";
|
|
124
|
+
isMut: true;
|
|
125
|
+
isSigner: false;
|
|
126
|
+
}, {
|
|
127
|
+
name: "systemProgram";
|
|
128
|
+
isMut: false;
|
|
129
|
+
isSigner: false;
|
|
130
|
+
}, {
|
|
131
|
+
name: "eventAuthority";
|
|
132
|
+
isMut: false;
|
|
133
|
+
isSigner: false;
|
|
134
|
+
}, {
|
|
135
|
+
name: "program";
|
|
136
|
+
isMut: false;
|
|
137
|
+
isSigner: false;
|
|
138
|
+
}];
|
|
139
|
+
args: [{
|
|
140
|
+
name: "args";
|
|
141
|
+
type: {
|
|
142
|
+
defined: "SetRefundRecordArgs";
|
|
143
|
+
};
|
|
144
|
+
}];
|
|
145
|
+
} & {
|
|
146
|
+
name: "setRefundRecord";
|
|
147
|
+
}>;
|
|
148
|
+
activateLiquidationIx({ liquidationAuthority, liquidation, liquidationAuthorityQuoteAccount, quoteMint, }: {
|
|
149
|
+
liquidationAuthority: PublicKey;
|
|
150
|
+
liquidation: PublicKey;
|
|
151
|
+
liquidationAuthorityQuoteAccount?: PublicKey;
|
|
152
|
+
quoteMint: PublicKey;
|
|
153
|
+
}): import("@coral-xyz/anchor/dist/cjs/program/namespace/methods.js").MethodsBuilder<LiquidationProgram, {
|
|
154
|
+
name: "activateLiquidation";
|
|
155
|
+
accounts: [{
|
|
156
|
+
name: "liquidationAuthority";
|
|
157
|
+
isMut: false;
|
|
158
|
+
isSigner: true;
|
|
159
|
+
}, {
|
|
160
|
+
name: "liquidation";
|
|
161
|
+
isMut: true;
|
|
162
|
+
isSigner: false;
|
|
163
|
+
}, {
|
|
164
|
+
name: "liquidationAuthorityQuoteAccount";
|
|
165
|
+
isMut: true;
|
|
166
|
+
isSigner: false;
|
|
167
|
+
}, {
|
|
168
|
+
name: "liquidationQuoteVault";
|
|
169
|
+
isMut: true;
|
|
170
|
+
isSigner: false;
|
|
171
|
+
}, {
|
|
172
|
+
name: "quoteMint";
|
|
173
|
+
isMut: false;
|
|
174
|
+
isSigner: false;
|
|
175
|
+
}, {
|
|
176
|
+
name: "tokenProgram";
|
|
177
|
+
isMut: false;
|
|
178
|
+
isSigner: false;
|
|
179
|
+
}, {
|
|
180
|
+
name: "eventAuthority";
|
|
181
|
+
isMut: false;
|
|
182
|
+
isSigner: false;
|
|
183
|
+
}, {
|
|
184
|
+
name: "program";
|
|
185
|
+
isMut: false;
|
|
186
|
+
isSigner: false;
|
|
187
|
+
}];
|
|
188
|
+
args: [];
|
|
189
|
+
} & {
|
|
190
|
+
name: "activateLiquidation";
|
|
191
|
+
}>;
|
|
192
|
+
refundIx({ recipient, liquidation, baseMint, recipientBaseAccount, quoteMint, }: {
|
|
193
|
+
recipient: PublicKey;
|
|
194
|
+
liquidation: PublicKey;
|
|
195
|
+
baseMint: PublicKey;
|
|
196
|
+
recipientBaseAccount?: PublicKey;
|
|
197
|
+
quoteMint: PublicKey;
|
|
198
|
+
}): import("@coral-xyz/anchor/dist/cjs/program/namespace/methods.js").MethodsBuilder<LiquidationProgram, {
|
|
199
|
+
name: "refund";
|
|
200
|
+
accounts: [{
|
|
201
|
+
name: "recipient";
|
|
202
|
+
isMut: true;
|
|
203
|
+
isSigner: true;
|
|
204
|
+
}, {
|
|
205
|
+
name: "liquidation";
|
|
206
|
+
isMut: true;
|
|
207
|
+
isSigner: false;
|
|
208
|
+
}, {
|
|
209
|
+
name: "refundRecord";
|
|
210
|
+
isMut: true;
|
|
211
|
+
isSigner: false;
|
|
212
|
+
}, {
|
|
213
|
+
name: "recipientBaseAccount";
|
|
214
|
+
isMut: true;
|
|
215
|
+
isSigner: false;
|
|
216
|
+
}, {
|
|
217
|
+
name: "liquidationQuoteVault";
|
|
218
|
+
isMut: true;
|
|
219
|
+
isSigner: false;
|
|
220
|
+
}, {
|
|
221
|
+
name: "recipientQuoteAccount";
|
|
222
|
+
isMut: true;
|
|
223
|
+
isSigner: false;
|
|
224
|
+
}, {
|
|
225
|
+
name: "baseMint";
|
|
226
|
+
isMut: true;
|
|
227
|
+
isSigner: false;
|
|
228
|
+
}, {
|
|
229
|
+
name: "quoteMint";
|
|
230
|
+
isMut: false;
|
|
231
|
+
isSigner: false;
|
|
232
|
+
}, {
|
|
233
|
+
name: "tokenProgram";
|
|
234
|
+
isMut: false;
|
|
235
|
+
isSigner: false;
|
|
236
|
+
}, {
|
|
237
|
+
name: "associatedTokenProgram";
|
|
238
|
+
isMut: false;
|
|
239
|
+
isSigner: false;
|
|
240
|
+
}, {
|
|
241
|
+
name: "systemProgram";
|
|
242
|
+
isMut: false;
|
|
243
|
+
isSigner: false;
|
|
244
|
+
}, {
|
|
245
|
+
name: "eventAuthority";
|
|
246
|
+
isMut: false;
|
|
247
|
+
isSigner: false;
|
|
248
|
+
}, {
|
|
249
|
+
name: "program";
|
|
250
|
+
isMut: false;
|
|
251
|
+
isSigner: false;
|
|
252
|
+
}];
|
|
253
|
+
args: [];
|
|
254
|
+
} & {
|
|
255
|
+
name: "refund";
|
|
256
|
+
}>;
|
|
257
|
+
withdrawRemainingQuoteIx({ liquidationAuthority, liquidation, liquidationAuthorityQuoteAccount, quoteMint, }: {
|
|
258
|
+
liquidationAuthority: PublicKey;
|
|
259
|
+
liquidation: PublicKey;
|
|
260
|
+
liquidationAuthorityQuoteAccount?: PublicKey;
|
|
261
|
+
quoteMint: PublicKey;
|
|
262
|
+
}): import("@coral-xyz/anchor/dist/cjs/program/namespace/methods.js").MethodsBuilder<LiquidationProgram, {
|
|
263
|
+
name: "withdrawRemainingQuote";
|
|
264
|
+
accounts: [{
|
|
265
|
+
name: "liquidationAuthority";
|
|
266
|
+
isMut: false;
|
|
267
|
+
isSigner: true;
|
|
268
|
+
}, {
|
|
269
|
+
name: "liquidation";
|
|
270
|
+
isMut: true;
|
|
271
|
+
isSigner: false;
|
|
272
|
+
}, {
|
|
273
|
+
name: "liquidationQuoteVault";
|
|
274
|
+
isMut: true;
|
|
275
|
+
isSigner: false;
|
|
276
|
+
}, {
|
|
277
|
+
name: "liquidationAuthorityQuoteAccount";
|
|
278
|
+
isMut: true;
|
|
279
|
+
isSigner: false;
|
|
280
|
+
}, {
|
|
281
|
+
name: "quoteMint";
|
|
282
|
+
isMut: false;
|
|
283
|
+
isSigner: false;
|
|
284
|
+
}, {
|
|
285
|
+
name: "tokenProgram";
|
|
286
|
+
isMut: false;
|
|
287
|
+
isSigner: false;
|
|
288
|
+
}, {
|
|
289
|
+
name: "eventAuthority";
|
|
290
|
+
isMut: false;
|
|
291
|
+
isSigner: false;
|
|
292
|
+
}, {
|
|
293
|
+
name: "program";
|
|
294
|
+
isMut: false;
|
|
295
|
+
isSigner: false;
|
|
296
|
+
}];
|
|
297
|
+
args: [];
|
|
298
|
+
} & {
|
|
299
|
+
name: "withdrawRemainingQuote";
|
|
300
|
+
}>;
|
|
301
|
+
getRefundRecord({ liquidation, recipient, }: {
|
|
302
|
+
liquidation: PublicKey;
|
|
303
|
+
recipient: PublicKey;
|
|
304
|
+
}): Promise<RefundRecordAccount | null>;
|
|
305
|
+
getLiquidationAddress({ baseMint, quoteMint, createKey, }: {
|
|
306
|
+
baseMint: PublicKey;
|
|
307
|
+
quoteMint: PublicKey;
|
|
308
|
+
createKey: PublicKey;
|
|
309
|
+
}): PublicKey;
|
|
310
|
+
getRefundRecordAddress({ liquidation, recipient, }: {
|
|
311
|
+
liquidation: PublicKey;
|
|
312
|
+
recipient: PublicKey;
|
|
313
|
+
}): PublicKey;
|
|
314
|
+
getEventAuthorityAddress(): PublicKey;
|
|
315
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { Program } from "@coral-xyz/anchor";
|
|
2
|
+
import { SystemProgram } from "@solana/web3.js";
|
|
3
|
+
import { ASSOCIATED_TOKEN_PROGRAM_ID, getAssociatedTokenAddressSync, TOKEN_PROGRAM_ID, } from "@solana/spl-token";
|
|
4
|
+
import { LIQUIDATION_PROGRAM_ID } from "../v0.7/constants.js";
|
|
5
|
+
import { LiquidationIDL, } from "../v0.7/types/index.js";
|
|
6
|
+
import { getLiquidationAddr, getRefundRecordAddr, getEventAuthorityAddr, } from "../v0.7/utils/pda.js";
|
|
7
|
+
export class LiquidationClient {
|
|
8
|
+
provider;
|
|
9
|
+
liquidationProgram;
|
|
10
|
+
programId;
|
|
11
|
+
constructor(provider, liquidationProgramId) {
|
|
12
|
+
this.provider = provider;
|
|
13
|
+
this.programId = liquidationProgramId;
|
|
14
|
+
this.liquidationProgram = new Program(LiquidationIDL, liquidationProgramId, provider);
|
|
15
|
+
}
|
|
16
|
+
static createClient(createLiquidationClientParams) {
|
|
17
|
+
let { provider, liquidationProgramId } = createLiquidationClientParams;
|
|
18
|
+
return new LiquidationClient(provider, liquidationProgramId || LIQUIDATION_PROGRAM_ID);
|
|
19
|
+
}
|
|
20
|
+
getProgramId() {
|
|
21
|
+
return this.programId;
|
|
22
|
+
}
|
|
23
|
+
async fetchLiquidation(liquidation) {
|
|
24
|
+
return this.liquidationProgram.account.liquidation.fetchNullable(liquidation);
|
|
25
|
+
}
|
|
26
|
+
async deserializeLiquidation(accountInfo) {
|
|
27
|
+
return this.liquidationProgram.coder.accounts.decode("liquidation", accountInfo.data);
|
|
28
|
+
}
|
|
29
|
+
async fetchRefundRecord(refundRecord) {
|
|
30
|
+
return this.liquidationProgram.account.refundRecord.fetchNullable(refundRecord);
|
|
31
|
+
}
|
|
32
|
+
async deserializeRefundRecord(accountInfo) {
|
|
33
|
+
return this.liquidationProgram.coder.accounts.decode("refundRecord", accountInfo.data);
|
|
34
|
+
}
|
|
35
|
+
async getLiquidation({ baseMint, quoteMint, createKey, }) {
|
|
36
|
+
const liquidation = this.getLiquidationAddress({
|
|
37
|
+
baseMint,
|
|
38
|
+
quoteMint,
|
|
39
|
+
createKey,
|
|
40
|
+
});
|
|
41
|
+
return this.fetchLiquidation(liquidation);
|
|
42
|
+
}
|
|
43
|
+
initializeLiquidationIx({ durationSeconds, createKey, recordAuthority, liquidationAuthority, baseMint, quoteMint, payer = this.provider.publicKey, }) {
|
|
44
|
+
const liquidation = this.getLiquidationAddress({
|
|
45
|
+
baseMint,
|
|
46
|
+
quoteMint,
|
|
47
|
+
createKey,
|
|
48
|
+
});
|
|
49
|
+
const liquidationQuoteVault = getAssociatedTokenAddressSync(quoteMint, liquidation, true);
|
|
50
|
+
return this.liquidationProgram.methods
|
|
51
|
+
.initializeLiquidation({ durationSeconds })
|
|
52
|
+
.accounts({
|
|
53
|
+
payer,
|
|
54
|
+
createKey,
|
|
55
|
+
recordAuthority,
|
|
56
|
+
liquidationAuthority,
|
|
57
|
+
baseMint,
|
|
58
|
+
quoteMint,
|
|
59
|
+
liquidation,
|
|
60
|
+
liquidationQuoteVault,
|
|
61
|
+
systemProgram: SystemProgram.programId,
|
|
62
|
+
tokenProgram: TOKEN_PROGRAM_ID,
|
|
63
|
+
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
setRefundRecordIx({ baseAssigned, quoteRefundable, recordAuthority, liquidation, recipient, payer = this.provider.publicKey, }) {
|
|
67
|
+
const refundRecord = this.getRefundRecordAddress({
|
|
68
|
+
liquidation,
|
|
69
|
+
recipient,
|
|
70
|
+
});
|
|
71
|
+
return this.liquidationProgram.methods
|
|
72
|
+
.setRefundRecord({ baseAssigned, quoteRefundable })
|
|
73
|
+
.accounts({
|
|
74
|
+
payer,
|
|
75
|
+
recordAuthority,
|
|
76
|
+
liquidation,
|
|
77
|
+
recipient,
|
|
78
|
+
refundRecord,
|
|
79
|
+
systemProgram: SystemProgram.programId,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
activateLiquidationIx({ liquidationAuthority, liquidation, liquidationAuthorityQuoteAccount, quoteMint, }) {
|
|
83
|
+
const liquidationQuoteVault = getAssociatedTokenAddressSync(quoteMint, liquidation, true);
|
|
84
|
+
const resolvedLiquidationAuthorityQuoteAccount = liquidationAuthorityQuoteAccount ??
|
|
85
|
+
getAssociatedTokenAddressSync(quoteMint, liquidationAuthority, true);
|
|
86
|
+
return this.liquidationProgram.methods.activateLiquidation().accounts({
|
|
87
|
+
liquidationAuthority,
|
|
88
|
+
liquidation,
|
|
89
|
+
liquidationAuthorityQuoteAccount: resolvedLiquidationAuthorityQuoteAccount,
|
|
90
|
+
liquidationQuoteVault,
|
|
91
|
+
quoteMint,
|
|
92
|
+
tokenProgram: TOKEN_PROGRAM_ID,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
refundIx({ recipient, liquidation, baseMint, recipientBaseAccount, quoteMint, }) {
|
|
96
|
+
const refundRecord = this.getRefundRecordAddress({
|
|
97
|
+
liquidation,
|
|
98
|
+
recipient,
|
|
99
|
+
});
|
|
100
|
+
const resolvedRecipientBaseAccount = recipientBaseAccount ??
|
|
101
|
+
getAssociatedTokenAddressSync(baseMint, recipient, true);
|
|
102
|
+
const liquidationQuoteVault = getAssociatedTokenAddressSync(quoteMint, liquidation, true);
|
|
103
|
+
const recipientQuoteAccount = getAssociatedTokenAddressSync(quoteMint, recipient, true);
|
|
104
|
+
return this.liquidationProgram.methods.refund().accounts({
|
|
105
|
+
recipient,
|
|
106
|
+
liquidation,
|
|
107
|
+
refundRecord,
|
|
108
|
+
baseMint,
|
|
109
|
+
recipientBaseAccount: resolvedRecipientBaseAccount,
|
|
110
|
+
liquidationQuoteVault,
|
|
111
|
+
recipientQuoteAccount,
|
|
112
|
+
quoteMint,
|
|
113
|
+
tokenProgram: TOKEN_PROGRAM_ID,
|
|
114
|
+
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
115
|
+
systemProgram: SystemProgram.programId,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
withdrawRemainingQuoteIx({ liquidationAuthority, liquidation, liquidationAuthorityQuoteAccount, quoteMint, }) {
|
|
119
|
+
const liquidationQuoteVault = getAssociatedTokenAddressSync(quoteMint, liquidation, true);
|
|
120
|
+
const resolvedLiquidationAuthorityQuoteAccount = liquidationAuthorityQuoteAccount ??
|
|
121
|
+
getAssociatedTokenAddressSync(quoteMint, liquidationAuthority, true);
|
|
122
|
+
return this.liquidationProgram.methods.withdrawRemainingQuote().accounts({
|
|
123
|
+
liquidationAuthority,
|
|
124
|
+
liquidation,
|
|
125
|
+
liquidationQuoteVault,
|
|
126
|
+
liquidationAuthorityQuoteAccount: resolvedLiquidationAuthorityQuoteAccount,
|
|
127
|
+
quoteMint,
|
|
128
|
+
tokenProgram: TOKEN_PROGRAM_ID,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
async getRefundRecord({ liquidation, recipient, }) {
|
|
132
|
+
const refundRecord = this.getRefundRecordAddress({
|
|
133
|
+
liquidation,
|
|
134
|
+
recipient,
|
|
135
|
+
});
|
|
136
|
+
return this.fetchRefundRecord(refundRecord);
|
|
137
|
+
}
|
|
138
|
+
getLiquidationAddress({ baseMint, quoteMint, createKey, }) {
|
|
139
|
+
return getLiquidationAddr({ baseMint, quoteMint, createKey })[0];
|
|
140
|
+
}
|
|
141
|
+
getRefundRecordAddress({ liquidation, recipient, }) {
|
|
142
|
+
return getRefundRecordAddr({ liquidation, recipient })[0];
|
|
143
|
+
}
|
|
144
|
+
getEventAuthorityAddress() {
|
|
145
|
+
return getEventAuthorityAddr(this.programId)[0];
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=LiquidationClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LiquidationClient.js","sourceRoot":"","sources":["../../src/v0.7/LiquidationClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAA0B,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EACL,2BAA2B,EAC3B,6BAA6B,EAC7B,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAEL,cAAc,GAGf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAO9B,MAAM,OAAO,iBAAiB;IACZ,QAAQ,CAAiB;IACzB,kBAAkB,CAA8B;IAChD,SAAS,CAAY;IAErC,YAAY,QAAwB,EAAE,oBAA+B;QACnE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,oBAAoB,CAAC;QACtC,IAAI,CAAC,kBAAkB,GAAG,IAAI,OAAO,CACnC,cAAc,EACd,oBAAoB,EACpB,QAAQ,CACT,CAAC;IACJ,CAAC;IAEM,MAAM,CAAC,YAAY,CACxB,6BAA4D;QAE5D,IAAI,EAAE,QAAQ,EAAE,oBAAoB,EAAE,GAAG,6BAA6B,CAAC;QAEvE,OAAO,IAAI,iBAAiB,CAC1B,QAAQ,EACR,oBAAoB,IAAI,sBAAsB,CAC/C,CAAC;IACJ,CAAC;IAEM,YAAY;QACjB,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,gBAAgB,CAC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