forked from FlowwStar/FlowStar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstream.ts
More file actions
69 lines (65 loc) · 2.24 KB
/
Copy pathstream.ts
File metadata and controls
69 lines (65 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
* StreamData mirrors the struct returned by the Soroban streaming contract.
*
* All token amounts and timestamps are stored as `bigint` to match the
* contract's i128 / u64 types exactly (no precision loss). Timestamps are
* UNIX seconds. Amounts are in the token's smallest unit (stroops-like),
* scaled by `decimals`.
*
* When you wire the real contract, map the contract return value into this
* shape inside `lib/contract.ts`.
*/
export interface StreamData {
id: string
/** Address that funded and owns the stream (can cancel). */
sender: string
/** Address that receives the unlocking funds (can withdraw). */
recipient: string
/** Token contract address. */
token: TokenInfo
/** Total amount deposited into the stream (smallest unit). */
depositedAmount: bigint
/** Amount already withdrawn by the recipient (smallest unit). */
withdrawnAmount: bigint
/** Stream start time (UNIX seconds). */
startTime: bigint
/** Stream end time (UNIX seconds). */
endTime: bigint
/** Cliff time before which nothing (beyond cliffAmount) unlocks. */
cliffTime: bigint
/** Amount unlocked immediately at the cliff (smallest unit). */
cliffAmount: bigint
/** Linear unlock rate after the cliff (smallest unit per second). */
amountPerSecond: bigint
/** Total amount unlocked linearly after the cliff (smallest unit). Used with `duration` to reproduce the contract's exact unlock math. */
linearAmount: bigint
/** Length of the linear unlock period in seconds (matches the contract's `duration`). */
duration: bigint
/** Whether the sender has cancelled the stream. */
cancelled: boolean
/** Optional metadata attached to the stream. */
metadata?: StreamMetadata
}
export interface TokenInfo {
/** Token contract address on Stellar. */
address: string
symbol: string
/** Number of decimals used to display the raw amount. */
decimals: number
}
export interface StreamMetadata {
name: string
category: string
memo: string
}
export type StreamStatus = 'scheduled' | 'streaming' | 'completed' | 'cancelled'
export interface CreateStreamInput {
recipient: string
token: TokenInfo
totalAmount: bigint
startTime: bigint
endTime: bigint
cliffTime: bigint
cliffAmount: bigint
metadata?: StreamMetadata
}