@vultisig/rujira 12.0.0 → 13.0.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/CHANGELOG.md +73 -0
- package/dist/ccl/base.d.ts +17 -0
- package/dist/ccl/base.d.ts.map +1 -0
- package/dist/ccl/base.js +60 -0
- package/dist/ccl/ccl.d.ts +5 -0
- package/dist/ccl/ccl.d.ts.map +1 -0
- package/dist/ccl/ccl.js +73 -0
- package/dist/ccl/ccl.test.d.ts +2 -0
- package/dist/ccl/ccl.test.d.ts.map +1 -0
- package/dist/ccl/ccl.test.js +281 -0
- package/dist/ccl/index.d.ts +6 -0
- package/dist/ccl/index.d.ts.map +1 -0
- package/dist/ccl/index.js +5 -0
- package/dist/ccl/linear.d.ts +12 -0
- package/dist/ccl/linear.d.ts.map +1 -0
- package/dist/ccl/linear.js +47 -0
- package/dist/ccl/quadratic.d.ts +13 -0
- package/dist/ccl/quadratic.d.ts.map +1 -0
- package/dist/ccl/quadratic.js +52 -0
- package/dist/ccl/types.d.ts +29 -0
- package/dist/ccl/types.d.ts.map +1 -0
- package/dist/ccl/types.js +1 -0
- package/dist/client.d.ts +2 -2
- package/dist/client.js +2 -2
- package/dist/errors.d.ts +1 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +2 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/modules/range.d.ts +167 -0
- package/dist/modules/range.d.ts.map +1 -0
- package/dist/modules/range.js +467 -0
- package/package.json +24 -9
- package/dist/modules/perps.d.ts +0 -127
- package/dist/modules/perps.d.ts.map +0 -1
- package/dist/modules/perps.js +0 -214
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Symmetric weight: w(p) = 1 + σ·(1 - (2·(p - p_m)/Δp)²)
|
|
2
|
+
// s-space: w(s²) = C₀ + C₂·s² + C₄·s⁴
|
|
3
|
+
import { Ccl } from './base.js';
|
|
4
|
+
export class CclQuadratic extends Ccl {
|
|
5
|
+
constructor(high, low, sigma) {
|
|
6
|
+
super(high, low);
|
|
7
|
+
const pM = (high + low) / 2;
|
|
8
|
+
const deltaP = high - low;
|
|
9
|
+
if (deltaP === 0) {
|
|
10
|
+
this.c0 = 1;
|
|
11
|
+
this.c2 = 0;
|
|
12
|
+
this.c4 = 0;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
const dp2 = deltaP * deltaP;
|
|
16
|
+
this.c0 = 1 + sigma - (4 * sigma * pM * pM) / dp2;
|
|
17
|
+
this.c2 = (8 * sigma * pM) / dp2;
|
|
18
|
+
this.c4 = (-4 * sigma) / dp2;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
// Y(s) = C₀·(s-s_a) + C₂·(s³-s_a³)/3 + C₄·(s⁵-s_a⁵)/5
|
|
22
|
+
yAt(s) {
|
|
23
|
+
const s3 = s * s * s;
|
|
24
|
+
const sA3 = this.sA * this.sA * this.sA;
|
|
25
|
+
const s5 = s3 * s * s;
|
|
26
|
+
const sA5 = sA3 * this.sA * this.sA;
|
|
27
|
+
return this.c0 * (s - this.sA) + (this.c2 / 3) * (s3 - sA3) + (this.c4 / 5) * (s5 - sA5);
|
|
28
|
+
}
|
|
29
|
+
// X(s) = C₀·(1/s - 1/s_b) + C₂·(s_b - s) + C₄·(s_b³ - s³)/3
|
|
30
|
+
xAt(s) {
|
|
31
|
+
if (s === 0)
|
|
32
|
+
return 0;
|
|
33
|
+
const s3 = s * s * s;
|
|
34
|
+
const sB3 = this.sB * this.sB * this.sB;
|
|
35
|
+
return this.c0 * (1 / s - 1 / this.sB) + this.c2 * (this.sB - s) + (this.c4 / 3) * (sB3 - s3);
|
|
36
|
+
}
|
|
37
|
+
// Y'(s) = C₀ + C₂·s² + C₄·s⁴
|
|
38
|
+
yPrime(s) {
|
|
39
|
+
const s2 = s * s;
|
|
40
|
+
return this.c0 + this.c2 * s2 + this.c4 * s2 * s2;
|
|
41
|
+
}
|
|
42
|
+
// X'(s) = -C₀/s² - C₂ - C₄·s²
|
|
43
|
+
xPrime(s) {
|
|
44
|
+
const s2 = s * s;
|
|
45
|
+
if (s2 === 0)
|
|
46
|
+
return 0;
|
|
47
|
+
return -this.c0 / s2 - this.c2 - this.c4 * s2;
|
|
48
|
+
}
|
|
49
|
+
weight(p) {
|
|
50
|
+
return this.c0 + this.c2 * p + this.c4 * p * p;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type CclModel = 'quadratic' | 'linear';
|
|
2
|
+
export type CclRangeConfig = {
|
|
3
|
+
high: number;
|
|
4
|
+
low: number;
|
|
5
|
+
price: number;
|
|
6
|
+
sigma: number;
|
|
7
|
+
spread: number;
|
|
8
|
+
delta: number;
|
|
9
|
+
model?: CclModel;
|
|
10
|
+
};
|
|
11
|
+
export type CclDistributionBucket = {
|
|
12
|
+
pStart: number;
|
|
13
|
+
pEnd: number;
|
|
14
|
+
pMid: number;
|
|
15
|
+
weight: number;
|
|
16
|
+
pct: number;
|
|
17
|
+
side: 'ask' | 'bid';
|
|
18
|
+
};
|
|
19
|
+
export type CclDistribution = {
|
|
20
|
+
asks: CclDistributionBucket[];
|
|
21
|
+
bids: CclDistributionBucket[];
|
|
22
|
+
price: number;
|
|
23
|
+
askPrice: number;
|
|
24
|
+
bidPrice: number;
|
|
25
|
+
avgAskFillPrice: number;
|
|
26
|
+
avgBidFillPrice: number;
|
|
27
|
+
balanceRatio: number | null;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ccl/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,WAAW,GAAG,QAAQ,CAAA;AAE7C,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,QAAQ,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,KAAK,GAAG,KAAK,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,qBAAqB,EAAE,CAAA;IAC7B,IAAI,EAAE,qBAAqB,EAAE,CAAA;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,eAAe,EAAE,MAAM,CAAA;IACvB,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/client.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { RujiraAssets } from './modules/assets.js';
|
|
|
6
6
|
import { RujiraDeposit } from './modules/deposit.js';
|
|
7
7
|
import { RujiraGhost } from './modules/ghost.js';
|
|
8
8
|
import { RujiraOrderbook } from './modules/orderbook.js';
|
|
9
|
-
import {
|
|
9
|
+
import { RujiraRange } from './modules/range.js';
|
|
10
10
|
import { RujiraStaking } from './modules/staking.js';
|
|
11
11
|
import { RujiraSwap, type RujiraSwapOptions } from './modules/swap.js';
|
|
12
12
|
import { RujiraWithdraw } from './modules/withdraw.js';
|
|
@@ -32,7 +32,7 @@ export declare class RujiraClient {
|
|
|
32
32
|
readonly withdraw: RujiraWithdraw;
|
|
33
33
|
readonly staking: RujiraStaking;
|
|
34
34
|
readonly ghost: RujiraGhost;
|
|
35
|
-
readonly
|
|
35
|
+
readonly range: RujiraRange;
|
|
36
36
|
readonly discovery: RujiraDiscovery;
|
|
37
37
|
private queryClient;
|
|
38
38
|
private stargateClient;
|
package/dist/client.js
CHANGED
|
@@ -8,7 +8,7 @@ import { RujiraAssets } from './modules/assets.js';
|
|
|
8
8
|
import { RujiraDeposit } from './modules/deposit.js';
|
|
9
9
|
import { RujiraGhost } from './modules/ghost.js';
|
|
10
10
|
import { RujiraOrderbook } from './modules/orderbook.js';
|
|
11
|
-
import {
|
|
11
|
+
import { RujiraRange } from './modules/range.js';
|
|
12
12
|
import { RujiraStaking } from './modules/staking.js';
|
|
13
13
|
import { RujiraSwap } from './modules/swap.js';
|
|
14
14
|
import { RujiraWithdraw } from './modules/withdraw.js';
|
|
@@ -42,7 +42,7 @@ export class RujiraClient {
|
|
|
42
42
|
this.withdraw = new RujiraWithdraw(this);
|
|
43
43
|
this.staking = new RujiraStaking(this);
|
|
44
44
|
this.ghost = new RujiraGhost(this);
|
|
45
|
-
this.
|
|
45
|
+
this.range = new RujiraRange(this);
|
|
46
46
|
this.discovery = new RujiraDiscovery({
|
|
47
47
|
rpcEndpoint: this.config.rpcEndpoint,
|
|
48
48
|
debug: this.debug,
|
package/dist/errors.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export declare enum RujiraErrorCode {
|
|
|
15
15
|
INVALID_ADDRESS = "INVALID_ADDRESS",
|
|
16
16
|
INVALID_PAIR = "INVALID_PAIR",
|
|
17
17
|
INVALID_SLIPPAGE = "INVALID_SLIPPAGE",
|
|
18
|
+
INVALID_PARAMS = "INVALID_PARAMS",
|
|
18
19
|
INSUFFICIENT_BALANCE = "INSUFFICIENT_BALANCE",
|
|
19
20
|
INSUFFICIENT_GAS = "INSUFFICIENT_GAS",
|
|
20
21
|
NO_ROUTE = "NO_ROUTE",
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,oBAAY,eAAe;IAEzB,aAAa,kBAAkB;IAC/B,SAAS,cAAc;IACvB,OAAO,YAAY;IACnB,aAAa,kBAAkB;IAG/B,aAAa,kBAAkB;IAC/B,cAAc,mBAAmB;IACjC,eAAe,oBAAoB;IACnC,YAAY,iBAAiB;IAC7B,gBAAgB,qBAAqB;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,oBAAY,eAAe;IAEzB,aAAa,kBAAkB;IAC/B,SAAS,cAAc;IACvB,OAAO,YAAY;IACnB,aAAa,kBAAkB;IAG/B,aAAa,kBAAkB;IAC/B,cAAc,mBAAmB;IACjC,eAAe,oBAAoB;IACnC,YAAY,iBAAiB;IAC7B,gBAAgB,qBAAqB;IACrC,cAAc,mBAAmB;IAGjC,oBAAoB,yBAAyB;IAC7C,gBAAgB,qBAAqB;IAGrC,QAAQ,aAAa;IACrB,iBAAiB,sBAAsB;IACvC,aAAa,kBAAkB;IAC/B,qBAAqB,0BAA0B;IAG/C,eAAe,oBAAoB;IACnC,aAAa,kBAAkB;IAC/B,cAAc,mBAAmB;IACjC,oBAAoB,yBAAyB;IAG7C,cAAc,mBAAmB;IACjC,gBAAgB,qBAAqB;IACrC,SAAS,cAAc;IACvB,YAAY,iBAAiB;IAG7B,kBAAkB,uBAAuB;IACzC,cAAc,mBAAmB;IAGjC,cAAc,mBAAmB;IACjC,cAAc,mBAAmB;CAClC;AAED;;GAEG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,2CAA2C;IAC3C,SAAgB,IAAI,EAAE,eAAe,CAAA;IACrC,+BAA+B;IAC/B,SAAgB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjC,sCAAsC;IACtC,SAAgB,SAAS,EAAE,OAAO,CAAA;gBAEtB,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,SAAS,UAAQ;IAaxF;;OAEG;IACH,aAAa,IAAI,MAAM;IAIvB;;OAEG;IACH,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAUlC;AAgDD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAKxD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,WAAW,kBAAgC,GAAG,WAAW,CA6DlG"}
|
package/dist/errors.js
CHANGED
|
@@ -18,6 +18,7 @@ export var RujiraErrorCode;
|
|
|
18
18
|
RujiraErrorCode["INVALID_ADDRESS"] = "INVALID_ADDRESS";
|
|
19
19
|
RujiraErrorCode["INVALID_PAIR"] = "INVALID_PAIR";
|
|
20
20
|
RujiraErrorCode["INVALID_SLIPPAGE"] = "INVALID_SLIPPAGE";
|
|
21
|
+
RujiraErrorCode["INVALID_PARAMS"] = "INVALID_PARAMS";
|
|
21
22
|
// Balance errors
|
|
22
23
|
RujiraErrorCode["INSUFFICIENT_BALANCE"] = "INSUFFICIENT_BALANCE";
|
|
23
24
|
RujiraErrorCode["INSUFFICIENT_GAS"] = "INSUFFICIENT_GAS";
|
|
@@ -92,6 +93,7 @@ const USER_FRIENDLY_MESSAGES = {
|
|
|
92
93
|
[RujiraErrorCode.INVALID_ADDRESS]: 'Invalid address format.',
|
|
93
94
|
[RujiraErrorCode.INVALID_PAIR]: 'Trading pair not found or not supported.',
|
|
94
95
|
[RujiraErrorCode.INVALID_SLIPPAGE]: 'Invalid slippage tolerance. Must be between 0.01% and 50%.',
|
|
96
|
+
[RujiraErrorCode.INVALID_PARAMS]: 'Invalid parameters. Please check the input and try again.',
|
|
95
97
|
[RujiraErrorCode.INSUFFICIENT_BALANCE]: 'Insufficient balance for this transaction.',
|
|
96
98
|
[RujiraErrorCode.INSUFFICIENT_GAS]: 'Insufficient RUNE for gas fees.',
|
|
97
99
|
[RujiraErrorCode.NO_ROUTE]: 'No swap route available for this pair.',
|
package/dist/index.d.ts
CHANGED
|
@@ -32,12 +32,14 @@ export * from './errors.js';
|
|
|
32
32
|
export * from './types.js';
|
|
33
33
|
export type { RujiraClientOptions } from './client.js';
|
|
34
34
|
export { RujiraClient } from './client.js';
|
|
35
|
+
export type { CclDistribution, CclDistributionBucket, CclModel, CclRangeConfig } from './ccl/index.js';
|
|
36
|
+
export { CclLinear, CclQuadratic, createCcl, generateCclDistribution } from './ccl/index.js';
|
|
35
37
|
export { RujiraAssets } from './modules/assets.js';
|
|
36
38
|
export type { GhostTransactionParams, GhostVaultInfo, GhostVaultStatus } from './modules/ghost.js';
|
|
37
39
|
export { RujiraGhost } from './modules/ghost.js';
|
|
38
40
|
export { RujiraOrderbook } from './modules/orderbook.js';
|
|
39
|
-
export type {
|
|
40
|
-
export {
|
|
41
|
+
export type { RangeAnalytics, ClaimParams as RangeClaimParams, RangeConfig, CreatePositionParams as RangeCreatePositionParams, DepositParams as RangeDepositParams, FinPair as RangeFinPair, RangeMultiTransactionParams, RangePosition, RangeTransactionParams, TransferParams as RangeTransferParams, WithdrawAllParams as RangeWithdrawAllParams, WithdrawParams as RangeWithdrawParams, } from './modules/range.js';
|
|
42
|
+
export { RANGE_APR_SCALE, RANGE_CONFIG_DECIMALS, RANGE_MOIC_SCALE, RANGE_WITHDRAW_SHARE_DECIMALS, RujiraRange, } from './modules/range.js';
|
|
41
43
|
export type { StakeParams, StakeTransactionParams, StakingPosition, UnstakeParams } from './modules/staking.js';
|
|
42
44
|
export { RujiraStaking } from './modules/staking.js';
|
|
43
45
|
export { RujiraSwap } from './modules/swap.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;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AAA;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAC7D,YAAY,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -31,11 +31,11 @@ export * from './config.js';
|
|
|
31
31
|
export * from './errors.js';
|
|
32
32
|
export * from './types.js';
|
|
33
33
|
export { RujiraClient } from './client.js';
|
|
34
|
-
|
|
34
|
+
export { CclLinear, CclQuadratic, createCcl, generateCclDistribution } from './ccl/index.js';
|
|
35
35
|
export { RujiraAssets } from './modules/assets.js';
|
|
36
36
|
export { RujiraGhost } from './modules/ghost.js';
|
|
37
37
|
export { RujiraOrderbook } from './modules/orderbook.js';
|
|
38
|
-
export {
|
|
38
|
+
export { RANGE_APR_SCALE, RANGE_CONFIG_DECIMALS, RANGE_MOIC_SCALE, RANGE_WITHDRAW_SHARE_DECIMALS, RujiraRange, } from './modules/range.js';
|
|
39
39
|
export { RujiraStaking } from './modules/staking.js';
|
|
40
40
|
export { RujiraSwap } from './modules/swap.js';
|
|
41
41
|
export { VultisigRujiraProvider } from './signer/vultisig-provider.js';
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RUJI Trade Custom Concentrated Liquidity (CCL) — range positions.
|
|
3
|
+
*
|
|
4
|
+
* CCL positions live on the rujira-fin orderbook pair contract (v1.2+),
|
|
5
|
+
* NOT on the BOW AMM contract. Each position is identified by `idx` (bigint
|
|
6
|
+
* as string, scoped per pair). Users create a position with a price range
|
|
7
|
+
* (high/low), spread, skew, and fee, then the position automatically market-
|
|
8
|
+
* makes across the range, compounding and/or accruing claimable yield.
|
|
9
|
+
*
|
|
10
|
+
* Message shapes mirror the upstream rujira-ui `Range.tsx` / `RangeManage.tsx`
|
|
11
|
+
* verbatim — any drift there is load-bearing and must be updated in lockstep.
|
|
12
|
+
*
|
|
13
|
+
* @module modules/range
|
|
14
|
+
*/
|
|
15
|
+
import type { Coin } from '@cosmjs/proto-signing';
|
|
16
|
+
import type { RujiraClient } from '../client.js';
|
|
17
|
+
/** Scale of MOIC and DPI fields in analytics (divide raw bigint by this). */
|
|
18
|
+
export declare const RANGE_MOIC_SCALE = 1000000000000;
|
|
19
|
+
/** Scale of APR field in analytics (divide raw bigint by this). */
|
|
20
|
+
export declare const RANGE_APR_SCALE = 10000000000;
|
|
21
|
+
/** Fractional digits used by config Decimal fields (high/low/spread/skew/fee). */
|
|
22
|
+
export declare const RANGE_CONFIG_DECIMALS = 12;
|
|
23
|
+
/** Fractional digits used by the withdraw share parameter. */
|
|
24
|
+
export declare const RANGE_WITHDRAW_SHARE_DECIMALS = 4;
|
|
25
|
+
/** CosmWasm MsgExecuteContract payload — flat shape for one msg. */
|
|
26
|
+
export type RangeTransactionParams = {
|
|
27
|
+
contractAddress: string;
|
|
28
|
+
executeMsg: object;
|
|
29
|
+
funds: Coin[];
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Multi-msg payload for atomic close (claim + withdraw 100%).
|
|
33
|
+
* Callers MUST sign + broadcast all msgs in a SINGLE cosmos tx so they are
|
|
34
|
+
* atomic. Two separate txs would leak state between claim and withdraw.
|
|
35
|
+
*/
|
|
36
|
+
export type RangeMultiTransactionParams = {
|
|
37
|
+
msgs: RangeTransactionParams[];
|
|
38
|
+
};
|
|
39
|
+
/** Parameters for a CCL range position config. */
|
|
40
|
+
export type RangeConfig = {
|
|
41
|
+
/** Upper price bound (Decimal string, up to 12 fractional digits). Above this, position is 100% quote. */
|
|
42
|
+
high: string;
|
|
43
|
+
/** Lower price bound (Decimal string, 12 dp). Below this, position is 100% base. */
|
|
44
|
+
low: string;
|
|
45
|
+
/** Target profit per round trip (Decimal string, 12 dp, 0 < spread < 1). */
|
|
46
|
+
spread: string;
|
|
47
|
+
/** Distribution shape parameter (Decimal string, 12 dp, signed). Upstream UI presets use 0. */
|
|
48
|
+
skew: string;
|
|
49
|
+
/** Fraction of spread retained as claimable yield (Decimal string, 12 dp). Set equal to spread for accurate APR analytics. */
|
|
50
|
+
fee: string;
|
|
51
|
+
};
|
|
52
|
+
export type CreatePositionParams = {
|
|
53
|
+
pairAddress: string;
|
|
54
|
+
config: RangeConfig;
|
|
55
|
+
/** Base asset coin to deposit. Amount in smallest unit (string). */
|
|
56
|
+
base: Coin;
|
|
57
|
+
/** Quote asset coin to deposit. Amount in smallest unit (string). */
|
|
58
|
+
quote: Coin;
|
|
59
|
+
};
|
|
60
|
+
export type DepositParams = {
|
|
61
|
+
pairAddress: string;
|
|
62
|
+
idx: string;
|
|
63
|
+
base: Coin;
|
|
64
|
+
quote: Coin;
|
|
65
|
+
};
|
|
66
|
+
export type WithdrawParams = {
|
|
67
|
+
pairAddress: string;
|
|
68
|
+
idx: string;
|
|
69
|
+
/**
|
|
70
|
+
* Share of the position to withdraw, as a Decimal string with up to 4 fractional
|
|
71
|
+
* digits. 0 < share <= 1. Pass "1" for a full withdraw (but note this leaves
|
|
72
|
+
* unclaimed fees behind — use `buildWithdrawAll` for the atomic close path).
|
|
73
|
+
*/
|
|
74
|
+
share: string;
|
|
75
|
+
};
|
|
76
|
+
export type ClaimParams = {
|
|
77
|
+
pairAddress: string;
|
|
78
|
+
idx: string;
|
|
79
|
+
};
|
|
80
|
+
export type TransferParams = {
|
|
81
|
+
pairAddress: string;
|
|
82
|
+
idx: string;
|
|
83
|
+
/** Destination thor1... address. Validated before building. */
|
|
84
|
+
to: string;
|
|
85
|
+
};
|
|
86
|
+
export type WithdrawAllParams = {
|
|
87
|
+
pairAddress: string;
|
|
88
|
+
idx: string;
|
|
89
|
+
};
|
|
90
|
+
/** Analytics snapshot for a range position (scaled — use constants above to divide). */
|
|
91
|
+
export type RangeAnalytics = {
|
|
92
|
+
/** Multiple on Invested Capital, scaled by RANGE_MOIC_SCALE. */
|
|
93
|
+
moic?: string;
|
|
94
|
+
/** Distributed Paid-In ratio, scaled by RANGE_MOIC_SCALE. */
|
|
95
|
+
dpi?: string;
|
|
96
|
+
/** Annualized yield from claimable profits, scaled by RANGE_APR_SCALE. Only meaningful when fee > 0. */
|
|
97
|
+
apr?: string;
|
|
98
|
+
/** First deposit ISO timestamp. */
|
|
99
|
+
firstDepositDate?: string;
|
|
100
|
+
};
|
|
101
|
+
export type RangePosition = {
|
|
102
|
+
idx: string;
|
|
103
|
+
pairAddress: string;
|
|
104
|
+
base: string;
|
|
105
|
+
quote: string;
|
|
106
|
+
feesBase: string;
|
|
107
|
+
feesQuote: string;
|
|
108
|
+
/** Principal value in USD base units (8 dp). */
|
|
109
|
+
principalUsd?: string;
|
|
110
|
+
/** Claimable yield value in USD base units (8 dp). */
|
|
111
|
+
yieldUsd?: string;
|
|
112
|
+
config?: RangeConfig;
|
|
113
|
+
analytics?: RangeAnalytics;
|
|
114
|
+
};
|
|
115
|
+
export type FinPair = {
|
|
116
|
+
address: string;
|
|
117
|
+
base: {
|
|
118
|
+
symbol: string;
|
|
119
|
+
denom: string;
|
|
120
|
+
};
|
|
121
|
+
quote: {
|
|
122
|
+
symbol: string;
|
|
123
|
+
denom: string;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Builders + queries for RUJI Trade CCL range positions.
|
|
128
|
+
*
|
|
129
|
+
* ExecuteMsg shapes (keep in sync with `rujira-ui` Range.tsx / RangeManage.tsx):
|
|
130
|
+
*
|
|
131
|
+
* - create: `{ range: { create: { config: { high, low, spread, skew, fee } } } }`
|
|
132
|
+
* - deposit: `{ range: { deposit: { idx } } }`
|
|
133
|
+
* - withdraw: `{ range: { withdraw: { idx, amount } } }` (amount is the share Decimal 4dp)
|
|
134
|
+
* - claim: `{ range: { claim: { idx } } }`
|
|
135
|
+
* - transfer: `{ range: { transfer: { idx, to } } }`
|
|
136
|
+
*/
|
|
137
|
+
export declare class RujiraRange {
|
|
138
|
+
private readonly client;
|
|
139
|
+
constructor(client: RujiraClient);
|
|
140
|
+
buildCreatePosition(params: CreatePositionParams): RangeTransactionParams;
|
|
141
|
+
buildDeposit(params: DepositParams): RangeTransactionParams;
|
|
142
|
+
buildWithdraw(params: WithdrawParams): RangeTransactionParams;
|
|
143
|
+
buildClaim(params: ClaimParams): RangeTransactionParams;
|
|
144
|
+
buildTransfer(params: TransferParams): RangeTransactionParams;
|
|
145
|
+
/**
|
|
146
|
+
* Atomic close: claim fees + withdraw 100%. Emits two MsgExecuteContract
|
|
147
|
+
* payloads that MUST be signed + broadcast in a single cosmos tx. The order
|
|
148
|
+
* matters — claim first, then withdraw — to guarantee fees are harvested.
|
|
149
|
+
*/
|
|
150
|
+
buildWithdrawAll(params: WithdrawAllParams): RangeMultiTransactionParams;
|
|
151
|
+
/**
|
|
152
|
+
* List open range positions for a THORChain address.
|
|
153
|
+
* Returns [] when the account has no positions.
|
|
154
|
+
*/
|
|
155
|
+
getPositions(owner: string): Promise<RangePosition[]>;
|
|
156
|
+
/**
|
|
157
|
+
* Fetch a single range position by (pairAddress, idx).
|
|
158
|
+
* Returns null when the position doesn't exist.
|
|
159
|
+
*/
|
|
160
|
+
getPosition(pairAddress: string, idx: string): Promise<RangePosition | null>;
|
|
161
|
+
/**
|
|
162
|
+
* Resolve a FIN pair contract address from base + quote asset identifiers
|
|
163
|
+
* (denom or THORChain ticker). Returns null when the pair doesn't exist.
|
|
164
|
+
*/
|
|
165
|
+
getPairAddress(base: string, quote: string): Promise<FinPair | null>;
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=range.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../../src/modules/range.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAEjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAQhD,6EAA6E;AAC7E,eAAO,MAAM,gBAAgB,gBAAO,CAAA;AACpC,mEAAmE;AACnE,eAAO,MAAM,eAAe,cAAO,C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