@exponent-labs/exponent-sdk 0.0.3
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/CHANGELOG.md +16 -0
- package/build/addressLookupTableUtil.d.ts +12 -0
- package/build/addressLookupTableUtil.js +32 -0
- package/build/addressLookupTableUtil.js.map +1 -0
- package/build/environment.d.ts +10 -0
- package/build/environment.js +13 -0
- package/build/environment.js.map +1 -0
- package/build/events.d.ts +339 -0
- package/build/events.js +231 -0
- package/build/events.js.map +1 -0
- package/build/flavors.d.ts +24 -0
- package/build/flavors.js +713 -0
- package/build/flavors.js.map +1 -0
- package/build/index.d.ts +11 -0
- package/build/index.js +45 -0
- package/build/index.js.map +1 -0
- package/build/lpPosition.d.ts +35 -0
- package/build/lpPosition.js +103 -0
- package/build/lpPosition.js.map +1 -0
- package/build/market.d.ts +567 -0
- package/build/market.js +1445 -0
- package/build/market.js.map +1 -0
- package/build/syPosition.d.ts +6 -0
- package/build/syPosition.js +115 -0
- package/build/syPosition.js.map +1 -0
- package/build/tokenUtil.d.ts +3 -0
- package/build/tokenUtil.js +23 -0
- package/build/tokenUtil.js.map +1 -0
- package/build/utils/altUtil.d.ts +8 -0
- package/build/utils/altUtil.js +35 -0
- package/build/utils/altUtil.js.map +1 -0
- package/build/utils/binSolver.d.ts +1 -0
- package/build/utils/binSolver.js +45 -0
- package/build/utils/binSolver.js.map +1 -0
- package/build/utils/binSolver.test.d.ts +1 -0
- package/build/utils/binSolver.test.js +15 -0
- package/build/utils/binSolver.test.js.map +1 -0
- package/build/utils/index.d.ts +6 -0
- package/build/utils/index.js +31 -0
- package/build/utils/index.js.map +1 -0
- package/build/utils/ix.d.ts +6 -0
- package/build/utils/ix.js +3 -0
- package/build/utils/ix.js.map +1 -0
- package/build/vault.d.ts +289 -0
- package/build/vault.js +615 -0
- package/build/vault.js.map +1 -0
- package/build/ytPosition.d.ts +86 -0
- package/build/ytPosition.js +231 -0
- package/build/ytPosition.js.map +1 -0
- package/jest.config.js +5 -0
- package/package.json +42 -0
- package/src/addressLookupTableUtil.ts +34 -0
- package/src/environment.ts +19 -0
- package/src/events.ts +595 -0
- package/src/flavors.ts +773 -0
- package/src/index.ts +11 -0
- package/src/lpPosition.ts +129 -0
- package/src/market.ts +2338 -0
- package/src/syPosition.ts +151 -0
- package/src/tokenUtil.ts +20 -0
- package/src/utils/altUtil.ts +47 -0
- package/src/utils/binSolver.test.ts +15 -0
- package/src/utils/binSolver.ts +44 -0
- package/src/utils/index.ts +32 -0
- package/src/utils/ix.ts +7 -0
- package/src/vault.ts +999 -0
- package/src/ytPosition.ts +313 -0
- package/tsconfig.json +38 -0
|
@@ -0,0 +1,567 @@
|
|
|
1
|
+
/// <reference types="bn.js" />
|
|
2
|
+
import { Program, Wallet, web3 } from "@coral-xyz/anchor";
|
|
3
|
+
import { LiquidityNetBalanceLimits, LpFarm } from "@exponent-labs/exponent-fetcher";
|
|
4
|
+
import { ExponentIx } from "@exponent-labs/exponent-ix";
|
|
5
|
+
import { Environment } from "./environment";
|
|
6
|
+
import { ExponentCore } from "@exponent-labs/exponent-idl";
|
|
7
|
+
import { BN } from "@coral-xyz/anchor";
|
|
8
|
+
import { ExponentPDA } from "@exponent-labs/exponent-pda";
|
|
9
|
+
import { Vault } from "./vault";
|
|
10
|
+
import { LiquidityAdd, MarketCalculator } from "@exponent-labs/market-math";
|
|
11
|
+
import { CpiAccountsRaw, Flavor, SyPosition } from "@exponent-labs/exponent-types";
|
|
12
|
+
import { AnchorizedPNum } from "@exponent-labs/exponent-types";
|
|
13
|
+
import { CpiAccountsRawJson } from "@exponent-labs/exponent-types";
|
|
14
|
+
export { LiquidityAdd };
|
|
15
|
+
interface Emission {
|
|
16
|
+
/** Token account that holds emission tokens */
|
|
17
|
+
escrowAccountAddress: web3.PublicKey;
|
|
18
|
+
/** Mint for the emission token */
|
|
19
|
+
mint: web3.PublicKey;
|
|
20
|
+
/** Token program ID for the emission token */
|
|
21
|
+
tokenProgramAddress: web3.PublicKey;
|
|
22
|
+
/** How many emissions have been claimed by SY holders */
|
|
23
|
+
totalClaimed: bigint;
|
|
24
|
+
/** How many emissions have been earned by the SY robot over its lifetime */
|
|
25
|
+
lastSeenTotalAccruedEmissions: bigint;
|
|
26
|
+
/** Global index for sharing out rewards to SY holders */
|
|
27
|
+
index: AnchorizedPNum;
|
|
28
|
+
}
|
|
29
|
+
export type MarketAdminAction = {
|
|
30
|
+
setStatus: [number];
|
|
31
|
+
} | {
|
|
32
|
+
setMaxLpSupply: [BN];
|
|
33
|
+
} | {
|
|
34
|
+
changeLnFeeRateRoot: [number];
|
|
35
|
+
} | {
|
|
36
|
+
changeRateScalarRoot: [number];
|
|
37
|
+
} | {
|
|
38
|
+
changeLiquidityNetBalanceLimits: {
|
|
39
|
+
maxNetBalanceChangeNegativePercentage: number;
|
|
40
|
+
maxNetBalanceChangePositivePercentage: number;
|
|
41
|
+
windowDurationSeconds: number;
|
|
42
|
+
};
|
|
43
|
+
} | {
|
|
44
|
+
removeMarketEmission: [number];
|
|
45
|
+
};
|
|
46
|
+
type MarketArgs = {
|
|
47
|
+
ptBalance: bigint;
|
|
48
|
+
syBalance: bigint;
|
|
49
|
+
lpSupply: bigint;
|
|
50
|
+
sySupply: bigint;
|
|
51
|
+
lpEscrowAmount: bigint;
|
|
52
|
+
maxLpSupply: bigint;
|
|
53
|
+
rateScalarRoot: number;
|
|
54
|
+
lnFeeRateRoot: number;
|
|
55
|
+
lastLnImpliedRate: number;
|
|
56
|
+
expirationTs: number;
|
|
57
|
+
addressLookupTable: web3.PublicKey;
|
|
58
|
+
mintSy: web3.PublicKey;
|
|
59
|
+
mintPt: web3.PublicKey;
|
|
60
|
+
vault: Vault;
|
|
61
|
+
mintLp: web3.PublicKey;
|
|
62
|
+
tokenPtEscrow: web3.PublicKey;
|
|
63
|
+
tokenSyEscrow: web3.PublicKey;
|
|
64
|
+
tokenLpEscrow: web3.PublicKey;
|
|
65
|
+
syProgram: web3.PublicKey;
|
|
66
|
+
statusFlags: number;
|
|
67
|
+
cpiAccounts: CpiAccountsRaw;
|
|
68
|
+
feeTreasurySyBps: number;
|
|
69
|
+
tokenFeeTreasurySy: web3.PublicKey;
|
|
70
|
+
isCurrentFlashSwap: boolean;
|
|
71
|
+
lpFarm: LpFarm;
|
|
72
|
+
flavor: Flavor;
|
|
73
|
+
liquidityNetBalanceLimits: LiquidityNetBalanceLimits;
|
|
74
|
+
syPosition: SyPosition;
|
|
75
|
+
emissions: {
|
|
76
|
+
trackers: {
|
|
77
|
+
tokenEscrow: web3.PublicKey;
|
|
78
|
+
lpShareIndex: number;
|
|
79
|
+
lastSeenStaged: number;
|
|
80
|
+
}[];
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
export declare class MyWallet implements Wallet {
|
|
84
|
+
readonly payer: web3.Keypair;
|
|
85
|
+
constructor(payer: web3.Keypair);
|
|
86
|
+
signTransaction<T extends web3.Transaction | web3.VersionedTransaction>(tx: T): Promise<T>;
|
|
87
|
+
signAllTransactions<T extends web3.Transaction | web3.VersionedTransaction>(txs: T[]): Promise<T[]>;
|
|
88
|
+
get publicKey(): web3.PublicKey;
|
|
89
|
+
}
|
|
90
|
+
export declare class Market {
|
|
91
|
+
state: MarketArgs;
|
|
92
|
+
selfAddress: web3.PublicKey;
|
|
93
|
+
env: Environment;
|
|
94
|
+
connection: web3.Connection;
|
|
95
|
+
coreProgram: Program<ExponentCore>;
|
|
96
|
+
xponIx: ExponentIx;
|
|
97
|
+
xponPda: ExponentPDA;
|
|
98
|
+
constructor(state: MarketArgs, selfAddress: web3.PublicKey, env: Environment, connection: web3.Connection);
|
|
99
|
+
static load(env: Environment, connection: web3.Connection, address: web3.PublicKey, vault?: Vault): Promise<Market>;
|
|
100
|
+
reload(conn?: web3.Connection): Promise<Market>;
|
|
101
|
+
/** Convert to a JSON representation */
|
|
102
|
+
toJson(): MarketJson;
|
|
103
|
+
get vault(): Vault;
|
|
104
|
+
get flavor(): Flavor;
|
|
105
|
+
get lpSupply(): bigint;
|
|
106
|
+
get syBalance(): bigint;
|
|
107
|
+
get ptBalance(): bigint;
|
|
108
|
+
get mintSy(): web3.PublicKey;
|
|
109
|
+
get mintPt(): web3.PublicKey;
|
|
110
|
+
get statusFlags(): number;
|
|
111
|
+
get mintYt(): web3.PublicKey;
|
|
112
|
+
get mintLp(): web3.PublicKey;
|
|
113
|
+
get addressLookupTable(): web3.PublicKey;
|
|
114
|
+
get syProgram(): web3.PublicKey;
|
|
115
|
+
get cpiAccounts(): CpiAccountsRaw;
|
|
116
|
+
get marketEmissions(): {
|
|
117
|
+
trackers: {
|
|
118
|
+
tokenEscrow: web3.PublicKey;
|
|
119
|
+
lpShareIndex: number;
|
|
120
|
+
lastSeenStaged: number;
|
|
121
|
+
}[];
|
|
122
|
+
};
|
|
123
|
+
get emissions(): Emission[];
|
|
124
|
+
/** Get the escrow token account addresses for the emissions, in order */
|
|
125
|
+
get emissionTokenAccounts(): web3.PublicKey[];
|
|
126
|
+
/** Pass-through SY account owned by the market */
|
|
127
|
+
get tokenSyEscrow(): web3.PublicKey;
|
|
128
|
+
/** SY account that holds treasury SY fees from PT trading */
|
|
129
|
+
get tokenFeeTreasurySy(): web3.PublicKey;
|
|
130
|
+
/** Market liquidity for PT */
|
|
131
|
+
get tokenPtEscrow(): web3.PublicKey;
|
|
132
|
+
get tokenLpEscrow(): web3.PublicKey;
|
|
133
|
+
get currentSyExchangeRate(): number;
|
|
134
|
+
/** Special account for event emit self-cpi */
|
|
135
|
+
get eventAuthority(): web3.PublicKey;
|
|
136
|
+
get currentPtPriceInSy(): number;
|
|
137
|
+
get currentPtPriceInAsset(): number;
|
|
138
|
+
get ptDiscount(): number;
|
|
139
|
+
get lpPriceInAsset(): number;
|
|
140
|
+
get secondsRemaining(): number;
|
|
141
|
+
get absolutePtYield(): number;
|
|
142
|
+
/** Annualize a rate given the number of seconds remaining until maturity */
|
|
143
|
+
static annualize(r: number, secondsRemaining: number): number;
|
|
144
|
+
/** Annualized PT fixed rate */
|
|
145
|
+
get ptApr(): number;
|
|
146
|
+
/** The fee rate taken off of trade fees (typically around 20%) expressed as a BPS number */
|
|
147
|
+
get feeTreasuryBps(): number;
|
|
148
|
+
/** The fee rate on assets when trading PT
|
|
149
|
+
* Expressed as a rational number
|
|
150
|
+
* eg 0.01 = 1%
|
|
151
|
+
*/
|
|
152
|
+
get feeRatePtTrade(): number;
|
|
153
|
+
/** The fee rate taken off of trade fees (typically around 20%) expressed as a rational number */
|
|
154
|
+
get feeTreasuryRate(): number;
|
|
155
|
+
/** Calculate amonut of LP tokens to expect for tokens in */
|
|
156
|
+
lpOutForTokensIn(syInIntent: bigint, ptInIntent: bigint): LiquidityAdd;
|
|
157
|
+
marketCalculator(): MarketCalculator;
|
|
158
|
+
/** Deposit a pair of tokens as liquidity to the market
|
|
159
|
+
* Adds PT & SY from the `depositor` to the market
|
|
160
|
+
*
|
|
161
|
+
* Due to unforeseeable slippage, the PT & SY amounts intended are effectively the maximum amounts
|
|
162
|
+
* The minimum LP tokens to receive is specified by `minLpOut`
|
|
163
|
+
*
|
|
164
|
+
* The token accounts themselves are optional, and will be derived from the depositor's wallet if not provided
|
|
165
|
+
*/
|
|
166
|
+
ixDepositLiquidity({ ptInIntent, syInIntent, minLpOut, depositor, ptSrc, sySrc, lpDst, }: {
|
|
167
|
+
/** Intended (maximum) amount of PT in */
|
|
168
|
+
ptInIntent: bigint;
|
|
169
|
+
/** Intended (maximum) amount of SY in */
|
|
170
|
+
syInIntent: bigint;
|
|
171
|
+
/** Minimum LP tokens out */
|
|
172
|
+
minLpOut: bigint;
|
|
173
|
+
depositor: web3.PublicKey;
|
|
174
|
+
ptSrc?: web3.PublicKey;
|
|
175
|
+
sySrc?: web3.PublicKey;
|
|
176
|
+
lpDst?: web3.PublicKey;
|
|
177
|
+
}): Promise<web3.TransactionInstruction>;
|
|
178
|
+
ixModifyMarketSetting({ signer, adminAction }: {
|
|
179
|
+
signer: web3.PublicKey;
|
|
180
|
+
adminAction: MarketAdminAction;
|
|
181
|
+
}): Promise<web3.TransactionInstruction>;
|
|
182
|
+
ixModifyFarm({ newRate, untilTimestamp, signer, farmMint, farmTokenProgram, farmTokenSrc, }: {
|
|
183
|
+
newRate: bigint;
|
|
184
|
+
untilTimestamp: number;
|
|
185
|
+
signer: web3.PublicKey;
|
|
186
|
+
farmMint: web3.PublicKey;
|
|
187
|
+
farmTokenProgram: web3.PublicKey;
|
|
188
|
+
farmTokenSrc?: web3.PublicKey;
|
|
189
|
+
}): Promise<web3.TransactionInstruction>;
|
|
190
|
+
/**
|
|
191
|
+
* Redeem LP tokens for PT & SY (liquidity removal)
|
|
192
|
+
*
|
|
193
|
+
* The lpIn is exactly the amount of LP tokens to burn
|
|
194
|
+
* The minimum PT & SY out are specified by minPtOut & minSyOut
|
|
195
|
+
* The transaction may fail due to unforeseeable slippage on the redemption rate
|
|
196
|
+
*
|
|
197
|
+
* The token accounts themselves are optional, and will be derived from the withdrawer's wallet if not provided
|
|
198
|
+
*/
|
|
199
|
+
ixWithdrawLiquidity({ lpIn, withdrawer, minPtOut, minSyOut, ptDst, syDst, lpSrc, }: {
|
|
200
|
+
lpIn: bigint;
|
|
201
|
+
withdrawer: web3.PublicKey;
|
|
202
|
+
minPtOut: bigint;
|
|
203
|
+
minSyOut: bigint;
|
|
204
|
+
ptDst?: web3.PublicKey;
|
|
205
|
+
syDst?: web3.PublicKey;
|
|
206
|
+
lpSrc?: web3.PublicKey;
|
|
207
|
+
}): Promise<{
|
|
208
|
+
ixs: web3.TransactionInstruction[];
|
|
209
|
+
setupIxs: web3.TransactionInstruction[];
|
|
210
|
+
}>;
|
|
211
|
+
/** Buy PT with SY
|
|
212
|
+
*
|
|
213
|
+
* The trader is the account that sends the SY
|
|
214
|
+
* The amountPt is the exact amount of PT the trader intends to buy
|
|
215
|
+
* The syConstraint is the maximum amount of SY the trader is willing to spend
|
|
216
|
+
*
|
|
217
|
+
* The token accounts themselves are optional, and will be derived from the trader's wallet if not provided
|
|
218
|
+
*/
|
|
219
|
+
ixBuyPt({ trader, amountPt, maxSySpend, tokenPt, tokenSy, }: {
|
|
220
|
+
trader: web3.PublicKey;
|
|
221
|
+
amountPt: bigint;
|
|
222
|
+
maxSySpend: bigint;
|
|
223
|
+
tokenPt?: web3.PublicKey;
|
|
224
|
+
tokenSy?: web3.PublicKey;
|
|
225
|
+
}): Promise<{
|
|
226
|
+
ixs: web3.TransactionInstruction[];
|
|
227
|
+
setupIxs: web3.TransactionInstruction[];
|
|
228
|
+
}>;
|
|
229
|
+
/**
|
|
230
|
+
* Sell PT for SY
|
|
231
|
+
* The trader is the account that sends the PT
|
|
232
|
+
* The amountPt is the exact amount of PT the trader intends to sell
|
|
233
|
+
* The minSyReceive is the minimum amount of SY the trader is willing to receive
|
|
234
|
+
*
|
|
235
|
+
* The token accounts themselves are optional, and will be derived from the trader's wallet if not provided
|
|
236
|
+
*/
|
|
237
|
+
ixSellPt({ trader, amountPt, minSyReceive, tokenPt, tokenSy, }: {
|
|
238
|
+
trader: web3.PublicKey;
|
|
239
|
+
amountPt: bigint;
|
|
240
|
+
minSyReceive: bigint;
|
|
241
|
+
tokenPt?: web3.PublicKey;
|
|
242
|
+
tokenSy?: web3.PublicKey;
|
|
243
|
+
}): Promise<{
|
|
244
|
+
ixs: web3.TransactionInstruction[];
|
|
245
|
+
setupIxs: web3.TransactionInstruction[];
|
|
246
|
+
}>;
|
|
247
|
+
ixTradePt({ trader, traderPt, syConstraint, isBuy, tokenPt, tokenSy, }: {
|
|
248
|
+
trader: web3.PublicKey;
|
|
249
|
+
traderPt: bigint;
|
|
250
|
+
syConstraint: bigint;
|
|
251
|
+
isBuy: boolean;
|
|
252
|
+
tokenPt?: web3.PublicKey;
|
|
253
|
+
tokenSy?: web3.PublicKey;
|
|
254
|
+
}): Promise<{
|
|
255
|
+
ixs: web3.TransactionInstruction[];
|
|
256
|
+
setupIxs: web3.TransactionInstruction[];
|
|
257
|
+
}>;
|
|
258
|
+
/** Sell YT for SY
|
|
259
|
+
*
|
|
260
|
+
* The trader is the account that sends the YT
|
|
261
|
+
*
|
|
262
|
+
* The amountYt is the exact amount of YT the trader intends to sell
|
|
263
|
+
*
|
|
264
|
+
* The minSyOut is the minimum amount of SY the trader is willing to receive
|
|
265
|
+
*
|
|
266
|
+
* The token accounts themselves are optional, and will be derived from the trader's wallet if not provided
|
|
267
|
+
*/
|
|
268
|
+
ixSellYt({ trader, ytIn, minSyOut, ytSrc, ptSrc, syDst, }: {
|
|
269
|
+
trader: web3.PublicKey;
|
|
270
|
+
ytIn: bigint;
|
|
271
|
+
minSyOut: bigint;
|
|
272
|
+
ytSrc?: web3.PublicKey;
|
|
273
|
+
ptSrc?: web3.PublicKey;
|
|
274
|
+
syDst?: web3.PublicKey;
|
|
275
|
+
}): Promise<{
|
|
276
|
+
ixs: web3.TransactionInstruction[];
|
|
277
|
+
setupIxs: web3.TransactionInstruction[];
|
|
278
|
+
}>;
|
|
279
|
+
/** Buy YT with SY
|
|
280
|
+
*
|
|
281
|
+
* The trader is the account that sends the SY
|
|
282
|
+
*
|
|
283
|
+
* The ytOut is the exact amount of YT the trader intends to buy
|
|
284
|
+
*
|
|
285
|
+
* The maxSyIn is the maximum amount of SY the trader is willing to spend
|
|
286
|
+
*
|
|
287
|
+
* The token accounts themselves are optional, and will be derived from the trader's wallet if not provided
|
|
288
|
+
*/
|
|
289
|
+
ixBuyYt({ trader, ytOut, maxSyIn, ytTrader, ptTrader, syTrader, }: {
|
|
290
|
+
trader: web3.PublicKey;
|
|
291
|
+
ytOut: bigint;
|
|
292
|
+
maxSyIn: bigint;
|
|
293
|
+
ytTrader?: web3.PublicKey;
|
|
294
|
+
ptTrader?: web3.PublicKey;
|
|
295
|
+
syTrader?: web3.PublicKey;
|
|
296
|
+
}): Promise<{
|
|
297
|
+
ixs: web3.TransactionInstruction[];
|
|
298
|
+
setupIxs: web3.TransactionInstruction[];
|
|
299
|
+
}>;
|
|
300
|
+
ixInitLpPosition({ owner, feePayer }: {
|
|
301
|
+
owner: web3.PublicKey;
|
|
302
|
+
feePayer?: web3.PublicKey;
|
|
303
|
+
}): Promise<web3.TransactionInstruction>;
|
|
304
|
+
/** Deposit LP tokens into the farming module to earn rewards */
|
|
305
|
+
ixDepositLp({ owner, amount, lpSrc }: {
|
|
306
|
+
owner: web3.PublicKey;
|
|
307
|
+
amount: bigint;
|
|
308
|
+
lpSrc?: web3.PublicKey;
|
|
309
|
+
}): Promise<web3.TransactionInstruction>;
|
|
310
|
+
/** Withdraw LP tokens from the farming module */
|
|
311
|
+
ixWithdrawLp({ owner, amount, lpDst }: {
|
|
312
|
+
owner: web3.PublicKey;
|
|
313
|
+
amount: bigint;
|
|
314
|
+
lpDst?: web3.PublicKey;
|
|
315
|
+
}): Promise<web3.TransactionInstruction>;
|
|
316
|
+
ixWrapperCollectInterest({ claimer, tokenSyDst }: {
|
|
317
|
+
claimer: web3.PublicKey;
|
|
318
|
+
tokenSyDst?: web3.PublicKey;
|
|
319
|
+
}): Promise<{
|
|
320
|
+
ixs: web3.TransactionInstruction[];
|
|
321
|
+
setupIxs: web3.TransactionInstruction[];
|
|
322
|
+
}>;
|
|
323
|
+
ixWrapperBuyPt({ owner, ptOut, maxBaseIn, tokenSyTrader, tokenPtTrader, tokenBaseTrader, }: {
|
|
324
|
+
owner: web3.PublicKey;
|
|
325
|
+
ptOut: bigint;
|
|
326
|
+
maxBaseIn: bigint;
|
|
327
|
+
tokenSyTrader?: web3.PublicKey;
|
|
328
|
+
tokenPtTrader?: web3.PublicKey;
|
|
329
|
+
tokenBaseTrader?: web3.PublicKey;
|
|
330
|
+
}): Promise<{
|
|
331
|
+
ixs: web3.TransactionInstruction[];
|
|
332
|
+
setupIxs: web3.TransactionInstruction[];
|
|
333
|
+
}>;
|
|
334
|
+
ixWrapperSellPt({ owner, amount, minBaseOut, tokenSyTrader, tokenPtTrader, tokenBaseTrader, }: {
|
|
335
|
+
owner: web3.PublicKey;
|
|
336
|
+
amount: bigint;
|
|
337
|
+
minBaseOut: bigint;
|
|
338
|
+
tokenSyTrader?: web3.PublicKey;
|
|
339
|
+
tokenPtTrader?: web3.PublicKey;
|
|
340
|
+
tokenBaseTrader?: web3.PublicKey;
|
|
341
|
+
}): Promise<{
|
|
342
|
+
ixs: web3.TransactionInstruction[];
|
|
343
|
+
setupIxs: web3.TransactionInstruction[];
|
|
344
|
+
}>;
|
|
345
|
+
ixWrapperBuyYt({ owner, ytOut, maxBaseIn, tokenSyTrader, tokenPtTrader, tokenYtTrader, tokenBaseTrader, }: {
|
|
346
|
+
owner: web3.PublicKey;
|
|
347
|
+
ytOut: bigint;
|
|
348
|
+
maxBaseIn: bigint;
|
|
349
|
+
tokenSyTrader?: web3.PublicKey;
|
|
350
|
+
tokenPtTrader?: web3.PublicKey;
|
|
351
|
+
tokenYtTrader?: web3.PublicKey;
|
|
352
|
+
tokenBaseTrader?: web3.PublicKey;
|
|
353
|
+
}): Promise<{
|
|
354
|
+
ixs: web3.TransactionInstruction[];
|
|
355
|
+
setupIxs: web3.TransactionInstruction[];
|
|
356
|
+
}>;
|
|
357
|
+
ixWrapperSellYt({ owner, amount, minBaseOut, tokenBaseTrader, tokenSyTrader, tokenYtTrader, tokenPtTrader, }: {
|
|
358
|
+
owner: web3.PublicKey;
|
|
359
|
+
amount: bigint;
|
|
360
|
+
minBaseOut: bigint;
|
|
361
|
+
tokenBaseTrader?: web3.PublicKey;
|
|
362
|
+
tokenSyTrader?: web3.PublicKey;
|
|
363
|
+
tokenYtTrader?: web3.PublicKey;
|
|
364
|
+
tokenPtTrader?: web3.PublicKey;
|
|
365
|
+
}): Promise<{
|
|
366
|
+
ixs: web3.TransactionInstruction[];
|
|
367
|
+
setupIxs: web3.TransactionInstruction[];
|
|
368
|
+
}>;
|
|
369
|
+
ixCollectMarketEmission({ owner, emissionIndex, emissionDst, }: {
|
|
370
|
+
owner: web3.PublicKey;
|
|
371
|
+
emissionIndex: number;
|
|
372
|
+
emissionDst?: web3.PublicKey;
|
|
373
|
+
}): Promise<{
|
|
374
|
+
ixs: web3.TransactionInstruction[];
|
|
375
|
+
setupIxs: web3.TransactionInstruction[];
|
|
376
|
+
}>;
|
|
377
|
+
/** Provide liquidity from a base asset - and receive YT and LP tokens in return */
|
|
378
|
+
ixProvideLiquidityNoPriceImpact({ depositor, amountBase, minLpOut, tokenSyDepositor, tokenYtDepositor, tokenPtDepositor, tokenBaseDepositor, tokenLpDepositor, }: {
|
|
379
|
+
depositor: web3.PublicKey;
|
|
380
|
+
amountBase: bigint;
|
|
381
|
+
minLpOut: bigint;
|
|
382
|
+
tokenSyDepositor?: web3.PublicKey;
|
|
383
|
+
tokenYtDepositor?: web3.PublicKey;
|
|
384
|
+
tokenPtDepositor?: web3.PublicKey;
|
|
385
|
+
tokenBaseDepositor?: web3.PublicKey;
|
|
386
|
+
tokenLpDepositor?: web3.PublicKey;
|
|
387
|
+
}): Promise<{
|
|
388
|
+
ixs: web3.TransactionInstruction[];
|
|
389
|
+
setupIxs: web3.TransactionInstruction[];
|
|
390
|
+
}>;
|
|
391
|
+
ixProvideLiquidityBase({ depositor, amountBase, minLpOut, externalPtToBuy, externalSyConstraint, tokenSyDepositor, tokenYtDepositor, tokenPtDepositor, tokenBaseDepositor, tokenLpDepositor, }: {
|
|
392
|
+
depositor: web3.PublicKey;
|
|
393
|
+
amountBase: bigint;
|
|
394
|
+
minLpOut: bigint;
|
|
395
|
+
externalPtToBuy: bigint;
|
|
396
|
+
externalSyConstraint: bigint;
|
|
397
|
+
tokenSyDepositor?: web3.PublicKey;
|
|
398
|
+
tokenYtDepositor?: web3.PublicKey;
|
|
399
|
+
tokenPtDepositor?: web3.PublicKey;
|
|
400
|
+
tokenBaseDepositor?: web3.PublicKey;
|
|
401
|
+
tokenLpDepositor?: web3.PublicKey;
|
|
402
|
+
}): Promise<{
|
|
403
|
+
ixs: web3.TransactionInstruction[];
|
|
404
|
+
setupIxs: web3.TransactionInstruction[];
|
|
405
|
+
}>;
|
|
406
|
+
ixProvideLiquidityClassic({ depositor, amountBase, amountPt, minLpOut, tokenSyDepositor, tokenYtDepositor, tokenPtDepositor, tokenBaseDepositor, tokenLpDepositor, }: {
|
|
407
|
+
depositor: web3.PublicKey;
|
|
408
|
+
amountBase: bigint;
|
|
409
|
+
amountPt: bigint;
|
|
410
|
+
minLpOut: bigint;
|
|
411
|
+
tokenSyDepositor?: web3.PublicKey;
|
|
412
|
+
tokenYtDepositor?: web3.PublicKey;
|
|
413
|
+
tokenPtDepositor?: web3.PublicKey;
|
|
414
|
+
tokenBaseDepositor?: web3.PublicKey;
|
|
415
|
+
tokenLpDepositor?: web3.PublicKey;
|
|
416
|
+
}): Promise<{
|
|
417
|
+
ixs: web3.TransactionInstruction[];
|
|
418
|
+
setupIxs: web3.TransactionInstruction[];
|
|
419
|
+
}>;
|
|
420
|
+
ixWithdrawLiquidityToBase({ owner, amountLp, minBaseOut, tokenSyWithdrawer, tokenYtWithdrawer, tokenPtWithdrawer, tokenBaseWithdrawer, tokenLpWithdrawer, }: {
|
|
421
|
+
owner: web3.PublicKey;
|
|
422
|
+
amountLp: bigint;
|
|
423
|
+
minBaseOut: bigint;
|
|
424
|
+
tokenSyWithdrawer?: web3.PublicKey;
|
|
425
|
+
tokenYtWithdrawer?: web3.PublicKey;
|
|
426
|
+
tokenPtWithdrawer?: web3.PublicKey;
|
|
427
|
+
tokenBaseWithdrawer?: web3.PublicKey;
|
|
428
|
+
tokenLpWithdrawer?: web3.PublicKey;
|
|
429
|
+
}): Promise<{
|
|
430
|
+
ixs: web3.TransactionInstruction[];
|
|
431
|
+
setupIxs: web3.TransactionInstruction[];
|
|
432
|
+
}>;
|
|
433
|
+
ixWithdrawLiquidityClassic({ owner, amountLp, minBaseOut, tokenSyWithdrawer, tokenYtWithdrawer, tokenPtWithdrawer, tokenBaseWithdrawer, tokenLpWithdrawer, }: {
|
|
434
|
+
owner: web3.PublicKey;
|
|
435
|
+
amountLp: bigint;
|
|
436
|
+
minBaseOut: bigint;
|
|
437
|
+
tokenSyWithdrawer?: web3.PublicKey;
|
|
438
|
+
tokenYtWithdrawer?: web3.PublicKey;
|
|
439
|
+
tokenPtWithdrawer?: web3.PublicKey;
|
|
440
|
+
tokenBaseWithdrawer?: web3.PublicKey;
|
|
441
|
+
tokenLpWithdrawer?: web3.PublicKey;
|
|
442
|
+
}): Promise<{
|
|
443
|
+
ixs: web3.TransactionInstruction[];
|
|
444
|
+
setupIxs: web3.TransactionInstruction[];
|
|
445
|
+
}>;
|
|
446
|
+
claimFarmEmissions({ owner, mint, tokenProgram, tokenDst, }: {
|
|
447
|
+
owner: web3.PublicKey;
|
|
448
|
+
mint: web3.PublicKey;
|
|
449
|
+
tokenProgram: web3.PublicKey;
|
|
450
|
+
tokenDst?: web3.PublicKey;
|
|
451
|
+
}): Promise<{
|
|
452
|
+
ixs: web3.TransactionInstruction[];
|
|
453
|
+
setupIxs: web3.TransactionInstruction[];
|
|
454
|
+
}>;
|
|
455
|
+
ixAddStandaloneEmission({ signer, emissionMint, emissionTokenProgram, altAddresses, cpiAccounts, }: {
|
|
456
|
+
signer: web3.PublicKey;
|
|
457
|
+
emissionMint: web3.PublicKey;
|
|
458
|
+
emissionTokenProgram?: web3.PublicKey;
|
|
459
|
+
altAddresses: web3.PublicKey[];
|
|
460
|
+
cpiAccounts: CpiAccountsRaw;
|
|
461
|
+
}): Promise<{
|
|
462
|
+
extendAddressLookupTableExtensionAccounts: web3.PublicKey[];
|
|
463
|
+
addMarketEmissionIx: web3.TransactionInstruction;
|
|
464
|
+
}>;
|
|
465
|
+
addFarm({ signer, farmMint, farmRewardTokenProgram, emissionsRate, untilTimestamp, farmRewardSrc, feePayer, }: {
|
|
466
|
+
signer: web3.PublicKey;
|
|
467
|
+
farmMint: web3.PublicKey;
|
|
468
|
+
farmRewardTokenProgram: web3.PublicKey;
|
|
469
|
+
emissionsRate: number;
|
|
470
|
+
untilTimestamp: number;
|
|
471
|
+
farmRewardSrc?: web3.PublicKey;
|
|
472
|
+
feePayer?: web3.PublicKey;
|
|
473
|
+
}): Promise<{
|
|
474
|
+
ixs: web3.TransactionInstruction[];
|
|
475
|
+
}>;
|
|
476
|
+
/** Calculate available liquidity for PT trades
|
|
477
|
+
* @param is_buy - true if buying PT with SY, false if selling PT for SY
|
|
478
|
+
* @param size_pt - amount of PT to trade (in PT decimals)
|
|
479
|
+
* @returns amount of PT that can be traded given current liquidity
|
|
480
|
+
*/
|
|
481
|
+
liquidityAvailable(is_buy: boolean, size_pt: bigint): bigint;
|
|
482
|
+
}
|
|
483
|
+
export type MarketJson = {
|
|
484
|
+
/** The market's public key */
|
|
485
|
+
address: string;
|
|
486
|
+
/** The market's address lookup table public key */
|
|
487
|
+
addressLookupTable: string;
|
|
488
|
+
/** The market's SY escrow account public key - this is a pass-through account which moves SY between an end-user and the SY program where it is deposited and withdrawn from */
|
|
489
|
+
tokenSyEscrow: string;
|
|
490
|
+
/** The market's PT escrow account public key - this account holds the market's PT liquidity*/
|
|
491
|
+
tokenPtEscrow: string;
|
|
492
|
+
/** The market's LP escrow account public key - this account holds the market's LP tokens which are used to farm rewards */
|
|
493
|
+
tokenLpEscrow: string;
|
|
494
|
+
/** Token account that holds the market's SY fees */
|
|
495
|
+
treasurySyTokenAccount: string;
|
|
496
|
+
/** The market's LP supply */
|
|
497
|
+
lpSupply: string;
|
|
498
|
+
/** The SY program ID */
|
|
499
|
+
syProgram: string;
|
|
500
|
+
mintPt: string;
|
|
501
|
+
mintSy: string;
|
|
502
|
+
mintLp: string;
|
|
503
|
+
/** The market's PT balance */
|
|
504
|
+
ptBalance: string;
|
|
505
|
+
/** The market's SY balance */
|
|
506
|
+
syBalance: string;
|
|
507
|
+
/** The market's LP escrow amount */
|
|
508
|
+
lpEscrowAmount: string;
|
|
509
|
+
/** The market's current SY rate */
|
|
510
|
+
currentSyRate: number;
|
|
511
|
+
/** The market's expiration timestamp */
|
|
512
|
+
expirationTs: number;
|
|
513
|
+
/** The market's expiration date */
|
|
514
|
+
expirationDate: string;
|
|
515
|
+
/** The number of seconds remaining until the market expires */
|
|
516
|
+
secondsRemaining: number;
|
|
517
|
+
/** The market's maximum LP supply */
|
|
518
|
+
maxLpSupply: string;
|
|
519
|
+
lnFeeRateRoot: number;
|
|
520
|
+
rateScalarRoot: number;
|
|
521
|
+
feeTreasurySyBps: number;
|
|
522
|
+
lastLnImpliedRate: number;
|
|
523
|
+
/** The current rate scalar, taking into account the time decay*/
|
|
524
|
+
currentRateScalar: number;
|
|
525
|
+
/** The current rate anchor that preserves the last implied rate */
|
|
526
|
+
currentRateAnchor: number;
|
|
527
|
+
/** How many SY are required to buy 1 PT */
|
|
528
|
+
currentPtPriceInSy: number;
|
|
529
|
+
/** How many assets are required to buy 1 PT */
|
|
530
|
+
currentPtPriceInAsset: number;
|
|
531
|
+
/** Proportion of PT in terms of assets */
|
|
532
|
+
proportionPtInAsset: number;
|
|
533
|
+
/** Proportion of PT in terms of SY */
|
|
534
|
+
proportionPtInSy: number;
|
|
535
|
+
/** Current fee rate */
|
|
536
|
+
currentFeeRate: number;
|
|
537
|
+
/** CPI accounts */
|
|
538
|
+
cpiAccounts: CpiAccountsRawJson;
|
|
539
|
+
/** Annualized yield for PT */
|
|
540
|
+
ptApr: number;
|
|
541
|
+
/** Emission tokens */
|
|
542
|
+
emissions: {
|
|
543
|
+
trackers: {
|
|
544
|
+
tokenEscrow: string;
|
|
545
|
+
lpShareIndex: number;
|
|
546
|
+
lastSeenStaged: number;
|
|
547
|
+
}[];
|
|
548
|
+
};
|
|
549
|
+
liquidityNetBalanceLimits: {
|
|
550
|
+
windowStartTimestamp: number;
|
|
551
|
+
windowStartNetBalance: string;
|
|
552
|
+
maxNetBalanceChangeNegativePercentage: number;
|
|
553
|
+
maxNetBalanceChangePositivePercentage: number;
|
|
554
|
+
windowDurationSeconds: number;
|
|
555
|
+
};
|
|
556
|
+
lpFarm: {
|
|
557
|
+
lastSeenTimestamp: number;
|
|
558
|
+
farmEmissions: {
|
|
559
|
+
mint: string;
|
|
560
|
+
/** Tokens per second */
|
|
561
|
+
tokenRate: string;
|
|
562
|
+
expiryTimestamp: number;
|
|
563
|
+
/** Index for converting LP shares into earned emissions */
|
|
564
|
+
index: string;
|
|
565
|
+
}[];
|
|
566
|
+
};
|
|
567
|
+
};
|