@portal-hq/web 3.4.1 → 3.5.0-alpha
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/lib/commonjs/index.js +2 -0
- package/lib/commonjs/integrations/yield/index.js +16 -0
- package/lib/commonjs/integrations/yield/yieldxyz.js +115 -0
- package/lib/commonjs/integrations/yield/yieldxyz.test.js +154 -0
- package/lib/commonjs/mpc/index.js +122 -1
- package/lib/commonjs/mpc/index.test.js +539 -0
- package/lib/esm/index.js +2 -0
- package/lib/esm/integrations/yield/index.js +10 -0
- package/lib/esm/integrations/yield/yieldxyz.js +112 -0
- package/lib/esm/integrations/yield/yieldxyz.test.js +149 -0
- package/lib/esm/mpc/index.js +122 -1
- package/lib/esm/mpc/index.test.js +540 -1
- package/package.json +3 -2
- package/src/__mocks/constants.ts +319 -0
- package/src/index.ts +25 -2
- package/src/integrations/yield/index.ts +14 -0
- package/src/integrations/yield/yieldxyz.test.ts +220 -0
- package/src/integrations/yield/yieldxyz.ts +122 -0
- package/src/mpc/index.test.ts +645 -0
- package/src/mpc/index.ts +170 -5
- package/tsconfig.json +1 -1
- package/types.d.ts +1 -1
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import Mpc from 'src/mpc'
|
|
2
|
+
import {
|
|
3
|
+
YieldXyzGetBalancesRequest,
|
|
4
|
+
YieldXyzGetBalancesResponse,
|
|
5
|
+
YieldXyzGetHistoricalActionsRequest,
|
|
6
|
+
YieldXyzGetHistoricalActionsResponse,
|
|
7
|
+
YieldXyzManageYieldRequest,
|
|
8
|
+
YieldXyzManageYieldResponse,
|
|
9
|
+
YieldXyzTrackTransactionRequest,
|
|
10
|
+
YieldXyzTrackTransactionResponse,
|
|
11
|
+
YieldXyzGetTransactionResponse,
|
|
12
|
+
YieldXyzGetYieldsRequest,
|
|
13
|
+
YieldXyzGetYieldsResponse,
|
|
14
|
+
YieldXyzEnterRequest,
|
|
15
|
+
YieldXyzEnterYieldResponse,
|
|
16
|
+
YieldXyzExitRequest,
|
|
17
|
+
YieldXyzExitResponse,
|
|
18
|
+
} from '../../../yieldxyz-types'
|
|
19
|
+
|
|
20
|
+
export default class YieldXyz {
|
|
21
|
+
private mpc: Mpc
|
|
22
|
+
|
|
23
|
+
constructor({ mpc }: { mpc: Mpc }) {
|
|
24
|
+
this.mpc = mpc
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Retrieves yield balances for specified addresses and networks.
|
|
29
|
+
* @param data - The parameters for the yield balances request.
|
|
30
|
+
* @returns A `YieldXyzGetBalancesResponse` promise, resolving to balance information.
|
|
31
|
+
* @throws An error if the operation fails.
|
|
32
|
+
*/
|
|
33
|
+
public async getBalances(
|
|
34
|
+
data: YieldXyzGetBalancesRequest,
|
|
35
|
+
): Promise<YieldXyzGetBalancesResponse> {
|
|
36
|
+
return this.mpc?.getYieldXyzBalances(data)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Retrieves historical yield actions with optional filtering.
|
|
41
|
+
* @param data - The parameters for the historical yield actions request.
|
|
42
|
+
* @returns A `YieldXyzGetHistoricalActionsResponse` promise, resolving to historical actions.
|
|
43
|
+
* @throws An error if the operation fails.
|
|
44
|
+
*/
|
|
45
|
+
public async getHistoricalActions(
|
|
46
|
+
data: YieldXyzGetHistoricalActionsRequest,
|
|
47
|
+
): Promise<YieldXyzGetHistoricalActionsResponse> {
|
|
48
|
+
return this.mpc?.getYieldXyzHistoricalActions(data)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Manages a yield opportunity with the specified parameters.
|
|
53
|
+
* @param data - The parameters for managing a yield opportunity.
|
|
54
|
+
* @returns A `YieldXyzManageYieldResponse` promise, resolving to the action details.
|
|
55
|
+
* @throws An error if the operation fails.
|
|
56
|
+
*/
|
|
57
|
+
public async manage(
|
|
58
|
+
data: YieldXyzManageYieldRequest,
|
|
59
|
+
): Promise<YieldXyzManageYieldResponse> {
|
|
60
|
+
return this.mpc?.manageYieldXyzYield(data)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Enters a yield opportunity with the specified parameters.
|
|
65
|
+
* @param data - The parameters for entering a yield opportunity.
|
|
66
|
+
* @returns A `YieldXyzEnterYieldResponse` promise, resolving to the action details.
|
|
67
|
+
* @throws An error if the operation fails.
|
|
68
|
+
*/
|
|
69
|
+
public async enter(
|
|
70
|
+
data: YieldXyzEnterRequest,
|
|
71
|
+
): Promise<YieldXyzEnterYieldResponse> {
|
|
72
|
+
return this.mpc?.enterYieldXyzYield(data)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Exits a yield opportunity with the specified parameters.
|
|
77
|
+
* @param data - The parameters for exiting a yield opportunity.
|
|
78
|
+
* @returns A `YieldXyzExitResponse` promise, resolving to the action details.
|
|
79
|
+
* @throws An error if the operation fails.
|
|
80
|
+
*/
|
|
81
|
+
public async exit(data: YieldXyzExitRequest): Promise<YieldXyzExitResponse> {
|
|
82
|
+
return this.mpc?.exitYieldXyzYield(data)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Discovers yield opportunities based on the provided parameters.
|
|
87
|
+
* @param data - Optional parameters for yield discovery. If undefined, uses default parameters.
|
|
88
|
+
* @returns A `YieldXyzGetYieldsResponse` promise, resolving to available yield opportunities.
|
|
89
|
+
* @throws An error if the operation fails.
|
|
90
|
+
*/
|
|
91
|
+
public async discover(
|
|
92
|
+
data: YieldXyzGetYieldsRequest,
|
|
93
|
+
): Promise<YieldXyzGetYieldsResponse> {
|
|
94
|
+
return this.mpc?.getYieldXyzYields(data)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Tracks a transaction by submitting its hash to the Yield.xyz integration.
|
|
99
|
+
* @param data - The parameters for tracking a transaction:
|
|
100
|
+
* - transactionId: The ID of the transaction to track.
|
|
101
|
+
* - txHash: The hash of the transaction to submit.
|
|
102
|
+
* @returns A `YieldXyzTrackTransactionResponse` promise.
|
|
103
|
+
* @throws An error if the operation fails.
|
|
104
|
+
*/
|
|
105
|
+
public async track(
|
|
106
|
+
data: YieldXyzTrackTransactionRequest,
|
|
107
|
+
): Promise<YieldXyzTrackTransactionResponse> {
|
|
108
|
+
return this.mpc?.trackYieldXyzTransaction(data)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Retrieves a single yield action transaction by its ID.
|
|
113
|
+
* @param transactionId - The ID of the transaction to retrieve.
|
|
114
|
+
* @returns A `YieldXyzGetTransactionResponse` promise, resolving to transaction details.
|
|
115
|
+
* @throws An error if the operation fails.
|
|
116
|
+
*/
|
|
117
|
+
public async getTransaction(
|
|
118
|
+
transactionId: string,
|
|
119
|
+
): Promise<YieldXyzGetTransactionResponse> {
|
|
120
|
+
return this.mpc?.getYieldXyzTransaction(transactionId)
|
|
121
|
+
}
|
|
122
|
+
}
|