@varla/sdk 1.11.4 → 1.14.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/AGENTS.md +82 -95
- package/CHANGELOG.md +367 -0
- package/LICENSE +21 -0
- package/README.md +227 -275
- package/dist/abi/full/OpinionCtfExecutionEngineAdapter.js +1 -0
- package/dist/abi/full/OpinionCtfExecutionEngineAdapter.js.map +1 -0
- package/dist/abi/full/OracleUpdaterRouter.d.ts +30 -9
- package/dist/abi/full/OracleUpdaterRouter.d.ts.map +1 -1
- package/dist/abi/full/OracleUpdaterRouter.js +37 -9
- package/dist/abi/full/OracleUpdaterRouter.js.map +1 -0
- package/dist/abi/full/PolymarketCtfAdapter.js +1 -0
- package/dist/abi/full/PolymarketCtfAdapter.js.map +1 -0
- package/dist/abi/full/VarlaAccessManager.js +1 -0
- package/dist/abi/full/VarlaAccessManager.js.map +1 -0
- package/dist/abi/full/VarlaConvertLiquidator.js +1 -0
- package/dist/abi/full/VarlaConvertLiquidator.js.map +1 -0
- package/dist/abi/full/VarlaCore.js +1 -0
- package/dist/abi/full/VarlaCore.js.map +1 -0
- package/dist/abi/full/VarlaInterestRateStrategy.js +1 -0
- package/dist/abi/full/VarlaInterestRateStrategy.js.map +1 -0
- package/dist/abi/full/VarlaLiquidator.d.ts +12 -0
- package/dist/abi/full/VarlaLiquidator.d.ts.map +1 -1
- package/dist/abi/full/VarlaLiquidator.js +17 -0
- package/dist/abi/full/VarlaLiquidator.js.map +1 -0
- package/dist/abi/full/VarlaMergeLiquidator.js +1 -0
- package/dist/abi/full/VarlaMergeLiquidator.js.map +1 -0
- package/dist/abi/full/VarlaOracle.js +1 -0
- package/dist/abi/full/VarlaOracle.js.map +1 -0
- package/dist/abi/full/VarlaPool.js +1 -0
- package/dist/abi/full/VarlaPool.js.map +1 -0
- package/dist/abi/full/VarlaProxyAdmin.js +1 -0
- package/dist/abi/full/VarlaProxyAdmin.js.map +1 -0
- package/dist/abi/index.js +1 -0
- package/dist/abi/index.js.map +1 -0
- package/dist/abi/subsets/VarlaOracle.registry.js +1 -0
- package/dist/abi/subsets/VarlaOracle.registry.js.map +1 -0
- package/dist/abi.js +1 -0
- package/dist/abi.js.map +1 -0
- package/dist/actions/admin.js +1 -0
- package/dist/actions/admin.js.map +1 -0
- package/dist/actions/core.js +1 -0
- package/dist/actions/core.js.map +1 -0
- package/dist/actions/erc1155.js +1 -0
- package/dist/actions/erc1155.js.map +1 -0
- package/dist/actions/erc20.js +1 -0
- package/dist/actions/erc20.js.map +1 -0
- package/dist/actions/index.d.ts +7 -7
- package/dist/actions/index.d.ts.map +1 -1
- package/dist/actions/index.js +8 -7
- package/dist/actions/index.js.map +1 -0
- package/dist/actions/liquidator.js +1 -0
- package/dist/actions/liquidator.js.map +1 -0
- package/dist/actions/oracle.d.ts +1 -2
- package/dist/actions/oracle.d.ts.map +1 -1
- package/dist/actions/oracle.js +1 -0
- package/dist/actions/oracle.js.map +1 -0
- package/dist/actions/oracleUpdaterRouter.d.ts +8 -1
- package/dist/actions/oracleUpdaterRouter.d.ts.map +1 -1
- package/dist/actions/oracleUpdaterRouter.js +14 -1
- package/dist/actions/oracleUpdaterRouter.js.map +1 -0
- package/dist/actions/pool.js +1 -0
- package/dist/actions/pool.js.map +1 -0
- package/dist/actions/rbac.js +1 -0
- package/dist/actions/rbac.js.map +1 -0
- package/dist/actions/tx.js +1 -0
- package/dist/actions/tx.js.map +1 -0
- package/dist/actions/utils.js +1 -0
- package/dist/actions/utils.js.map +1 -0
- package/dist/addresses/bsc.js +1 -0
- package/dist/addresses/bsc.js.map +1 -0
- package/dist/addresses/index.js +1 -0
- package/dist/addresses/index.js.map +1 -0
- package/dist/addresses/polygon.js +1 -0
- package/dist/addresses/polygon.js.map +1 -0
- package/dist/addresses.js +1 -0
- package/dist/addresses.js.map +1 -0
- package/dist/batch.js +1 -0
- package/dist/batch.js.map +1 -0
- package/dist/contracts.d.ts +1 -2
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +2 -2
- package/dist/contracts.js.map +1 -0
- package/dist/errors.d.ts +87 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +240 -0
- package/dist/errors.js.map +1 -0
- package/dist/events/decode.js +1 -0
- package/dist/events/decode.js.map +1 -0
- package/dist/events/defs.js +1 -0
- package/dist/events/defs.js.map +1 -0
- package/dist/events/index.d.ts +3 -3
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +4 -3
- package/dist/events/index.js.map +1 -0
- package/dist/events/logs.js +1 -0
- package/dist/events/logs.js.map +1 -0
- package/dist/events/oracleRegistrySync.js +1 -0
- package/dist/events/oracleRegistrySync.js.map +1 -0
- package/dist/events/recent.d.ts +1 -1
- package/dist/events/recent.d.ts.map +1 -1
- package/dist/events/recent.js +2 -1
- package/dist/events/recent.js.map +1 -0
- package/dist/format.js +1 -0
- package/dist/format.js.map +1 -0
- package/dist/generated.d.ts +42 -9
- package/dist/generated.d.ts.map +1 -1
- package/dist/generated.js +1 -0
- package/dist/generated.js.map +1 -0
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -9
- package/dist/index.js.map +1 -0
- package/dist/leverage/deleverageExecute.d.ts +36 -0
- package/dist/leverage/deleverageExecute.d.ts.map +1 -0
- package/dist/leverage/deleverageExecute.js +53 -0
- package/dist/leverage/deleverageExecute.js.map +1 -0
- package/dist/leverage/execute.d.ts +62 -0
- package/dist/leverage/execute.d.ts.map +1 -0
- package/dist/leverage/execute.js +84 -0
- package/dist/leverage/execute.js.map +1 -0
- package/dist/leverage/index.d.ts +32 -0
- package/dist/leverage/index.d.ts.map +1 -0
- package/dist/leverage/index.js +12 -0
- package/dist/leverage/index.js.map +1 -0
- package/dist/leverage/math.d.ts +119 -0
- package/dist/leverage/math.d.ts.map +1 -0
- package/dist/leverage/math.js +304 -0
- package/dist/leverage/math.js.map +1 -0
- package/dist/leverage/plan.d.ts +143 -0
- package/dist/leverage/plan.d.ts.map +1 -0
- package/dist/leverage/plan.js +204 -0
- package/dist/leverage/plan.js.map +1 -0
- package/dist/leverage/preflight.d.ts +27 -0
- package/dist/leverage/preflight.d.ts.map +1 -0
- package/dist/leverage/preflight.js +34 -0
- package/dist/leverage/preflight.js.map +1 -0
- package/dist/leverage/types.d.ts +157 -0
- package/dist/leverage/types.d.ts.map +1 -0
- package/dist/leverage/types.js +43 -0
- package/dist/leverage/types.js.map +1 -0
- package/dist/meta.d.ts +42 -0
- package/dist/meta.d.ts.map +1 -0
- package/dist/meta.js +47 -0
- package/dist/meta.js.map +1 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/dist/views/accessManager.js +1 -0
- package/dist/views/accessManager.js.map +1 -0
- package/dist/views/adapters.js +1 -0
- package/dist/views/adapters.js.map +1 -0
- package/dist/views/admin.d.ts.map +1 -1
- package/dist/views/admin.js +1 -0
- package/dist/views/admin.js.map +1 -0
- package/dist/views/core.d.ts.map +1 -1
- package/dist/views/core.js +1 -0
- package/dist/views/core.js.map +1 -0
- package/dist/views/index.d.ts +5 -5
- package/dist/views/index.d.ts.map +1 -1
- package/dist/views/index.js +6 -5
- package/dist/views/index.js.map +1 -0
- package/dist/views/lenders.js +1 -0
- package/dist/views/lenders.js.map +1 -0
- package/dist/views/liquidators.d.ts +82 -1
- package/dist/views/liquidators.d.ts.map +1 -1
- package/dist/views/liquidators.js +88 -0
- package/dist/views/liquidators.js.map +1 -0
- package/dist/views/oracle.js +1 -0
- package/dist/views/oracle.js.map +1 -0
- package/dist/views/pool.js +1 -0
- package/dist/views/pool.js.map +1 -0
- package/dist/views/system.d.ts.map +1 -1
- package/dist/views/system.js +1 -0
- package/dist/views/system.js.map +1 -0
- package/package.json +18 -5
- package/src/abi/README.md +17 -0
- package/src/abi/full/OpinionCtfExecutionEngineAdapter.ts +320 -0
- package/src/abi/full/OracleUpdaterRouter.ts +528 -0
- package/src/abi/full/PolymarketCtfAdapter.ts +312 -0
- package/src/abi/full/VarlaAccessManager.ts +1171 -0
- package/src/abi/full/VarlaConvertLiquidator.ts +834 -0
- package/src/abi/full/VarlaCore.ts +2277 -0
- package/src/abi/full/VarlaInterestRateStrategy.ts +442 -0
- package/src/abi/full/VarlaLiquidator.ts +930 -0
- package/src/abi/full/VarlaMergeLiquidator.ts +797 -0
- package/src/abi/full/VarlaOracle.ts +1825 -0
- package/src/abi/full/VarlaPool.ts +1637 -0
- package/src/abi/full/VarlaProxyAdmin.ts +301 -0
- package/src/abi/index.ts +17 -0
- package/src/abi/subsets/VarlaOracle.registry.ts +784 -0
- package/src/abi.ts +2 -0
- package/src/actions/admin.ts +357 -0
- package/src/actions/core.ts +68 -0
- package/src/actions/erc1155.ts +22 -0
- package/src/actions/erc20.ts +22 -0
- package/src/actions/index.ts +13 -0
- package/src/actions/liquidator.ts +76 -0
- package/src/actions/oracle.ts +618 -0
- package/src/actions/oracleUpdaterRouter.ts +233 -0
- package/src/actions/pool.ts +76 -0
- package/src/actions/rbac.ts +72 -0
- package/src/actions/tx.ts +16 -0
- package/src/actions/utils.ts +15 -0
- package/src/addresses/README.md +17 -0
- package/src/addresses/bsc.json +16 -0
- package/src/addresses/bsc.ts +15 -0
- package/src/addresses/index.ts +6 -0
- package/src/addresses/polygon.json +16 -0
- package/src/addresses/polygon.ts +15 -0
- package/src/addresses.ts +2 -0
- package/src/batch.ts +55 -0
- package/src/contracts.ts +232 -0
- package/src/errors.ts +305 -0
- package/src/events/decode.ts +37 -0
- package/src/events/defs.ts +70 -0
- package/src/events/index.ts +7 -0
- package/src/events/logs.ts +42 -0
- package/src/events/oracleRegistrySync.ts +206 -0
- package/src/events/recent.ts +39 -0
- package/src/format.ts +121 -0
- package/src/generated.ts +27 -0
- package/src/index.ts +18 -0
- package/src/leverage/deleverageExecute.ts +111 -0
- package/src/leverage/execute.ts +172 -0
- package/src/leverage/index.ts +88 -0
- package/src/leverage/math.ts +446 -0
- package/src/leverage/plan.ts +356 -0
- package/src/leverage/preflight.ts +63 -0
- package/src/leverage/types.ts +204 -0
- package/src/meta.ts +82 -0
- package/src/types.ts +25 -0
- package/src/views/accessManager.ts +286 -0
- package/src/views/adapters.ts +27 -0
- package/src/views/admin.ts +92 -0
- package/src/views/core.ts +1370 -0
- package/src/views/index.ts +11 -0
- package/src/views/lenders.ts +65 -0
- package/src/views/liquidators.ts +377 -0
- package/src/views/oracle.ts +739 -0
- package/src/views/pool.ts +277 -0
- package/src/views/system.ts +42 -0
- package/BACKEND.md +0 -405
- package/FRONTEND.md +0 -485
package/src/abi.ts
ADDED
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
// Note: explicit .js extension is required for Node ESM resolution.
|
|
2
|
+
|
|
3
|
+
import type { Address, PublicClient } from "viem";
|
|
4
|
+
|
|
5
|
+
import { abis } from "../generated.js";
|
|
6
|
+
import type { SimulatedTx } from "./oracle.js";
|
|
7
|
+
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
// Admin / governance write helpers
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
// -----------------
|
|
13
|
+
// Core admin
|
|
14
|
+
// -----------------
|
|
15
|
+
|
|
16
|
+
export async function prepareCoreSetDefaultLtvConfig(params: {
|
|
17
|
+
publicClient: Pick<PublicClient, "simulateContract">;
|
|
18
|
+
coreAddress: Address;
|
|
19
|
+
account: Address;
|
|
20
|
+
conservative: bigint;
|
|
21
|
+
moderate: bigint;
|
|
22
|
+
risk: bigint;
|
|
23
|
+
}): Promise<SimulatedTx> {
|
|
24
|
+
return (await params.publicClient.simulateContract({
|
|
25
|
+
address: params.coreAddress,
|
|
26
|
+
abi: abis.VARLACORE_ABI,
|
|
27
|
+
functionName: "setDefaultLtvConfig",
|
|
28
|
+
args: [params.conservative, params.moderate, params.risk],
|
|
29
|
+
account: params.account,
|
|
30
|
+
} as any)) as any;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export async function prepareCoreSetLiquidationConfig(params: {
|
|
34
|
+
publicClient: Pick<PublicClient, "simulateContract">;
|
|
35
|
+
coreAddress: Address;
|
|
36
|
+
account: Address;
|
|
37
|
+
targetHealthFactor: bigint;
|
|
38
|
+
healthFactorForMaxBonus: bigint;
|
|
39
|
+
liquidationBonusFactorBps: bigint;
|
|
40
|
+
dustThreshold: bigint;
|
|
41
|
+
collateralDustThreshold: bigint;
|
|
42
|
+
}): Promise<SimulatedTx> {
|
|
43
|
+
return (await params.publicClient.simulateContract({
|
|
44
|
+
address: params.coreAddress,
|
|
45
|
+
abi: abis.VARLACORE_ABI,
|
|
46
|
+
functionName: "setLiquidationConfig",
|
|
47
|
+
args: [
|
|
48
|
+
params.targetHealthFactor,
|
|
49
|
+
params.healthFactorForMaxBonus,
|
|
50
|
+
params.liquidationBonusFactorBps,
|
|
51
|
+
params.dustThreshold,
|
|
52
|
+
params.collateralDustThreshold,
|
|
53
|
+
],
|
|
54
|
+
account: params.account,
|
|
55
|
+
} as any)) as any;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export async function prepareCoreSetTierLiquidationConfig(params: {
|
|
59
|
+
publicClient: Pick<PublicClient, "simulateContract">;
|
|
60
|
+
coreAddress: Address;
|
|
61
|
+
account: Address;
|
|
62
|
+
tier: number;
|
|
63
|
+
maxLiquidationBonusBps: bigint;
|
|
64
|
+
liquidationFeeBps: bigint;
|
|
65
|
+
}): Promise<SimulatedTx> {
|
|
66
|
+
return (await params.publicClient.simulateContract({
|
|
67
|
+
address: params.coreAddress,
|
|
68
|
+
abi: abis.VARLACORE_ABI,
|
|
69
|
+
functionName: "setTierLiquidationConfig",
|
|
70
|
+
args: [params.tier, params.maxLiquidationBonusBps, params.liquidationFeeBps],
|
|
71
|
+
account: params.account,
|
|
72
|
+
} as any)) as any;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export async function prepareCoreSetMaxPositions(params: {
|
|
76
|
+
publicClient: Pick<PublicClient, "simulateContract">;
|
|
77
|
+
coreAddress: Address;
|
|
78
|
+
account: Address;
|
|
79
|
+
maxPositions: bigint;
|
|
80
|
+
}): Promise<SimulatedTx> {
|
|
81
|
+
return (await params.publicClient.simulateContract({
|
|
82
|
+
address: params.coreAddress,
|
|
83
|
+
abi: abis.VARLACORE_ABI,
|
|
84
|
+
functionName: "setMaxPositions",
|
|
85
|
+
args: [params.maxPositions],
|
|
86
|
+
account: params.account,
|
|
87
|
+
} as any)) as any;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export async function prepareCoreSetMaxPositionsBounds(params: {
|
|
91
|
+
publicClient: Pick<PublicClient, "simulateContract">;
|
|
92
|
+
coreAddress: Address;
|
|
93
|
+
account: Address;
|
|
94
|
+
min: bigint;
|
|
95
|
+
max: bigint;
|
|
96
|
+
}): Promise<SimulatedTx> {
|
|
97
|
+
return (await params.publicClient.simulateContract({
|
|
98
|
+
address: params.coreAddress,
|
|
99
|
+
abi: abis.VARLACORE_ABI,
|
|
100
|
+
functionName: "setMaxPositionsBounds",
|
|
101
|
+
args: [params.min, params.max],
|
|
102
|
+
account: params.account,
|
|
103
|
+
} as any)) as any;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export async function prepareCoreSetOracle(params: {
|
|
107
|
+
publicClient: Pick<PublicClient, "simulateContract">;
|
|
108
|
+
coreAddress: Address;
|
|
109
|
+
account: Address;
|
|
110
|
+
oracle: Address;
|
|
111
|
+
}): Promise<SimulatedTx> {
|
|
112
|
+
return (await params.publicClient.simulateContract({
|
|
113
|
+
address: params.coreAddress,
|
|
114
|
+
abi: abis.VARLACORE_ABI,
|
|
115
|
+
functionName: "setOracle",
|
|
116
|
+
args: [params.oracle],
|
|
117
|
+
account: params.account,
|
|
118
|
+
} as any)) as any;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export async function prepareCoreSetPositionLtvOverride(params: {
|
|
122
|
+
publicClient: Pick<PublicClient, "simulateContract">;
|
|
123
|
+
coreAddress: Address;
|
|
124
|
+
account: Address;
|
|
125
|
+
positionId: bigint;
|
|
126
|
+
ltvWad: bigint;
|
|
127
|
+
}): Promise<SimulatedTx> {
|
|
128
|
+
return (await params.publicClient.simulateContract({
|
|
129
|
+
address: params.coreAddress,
|
|
130
|
+
abi: abis.VARLACORE_ABI,
|
|
131
|
+
functionName: "setPositionLtvOverride",
|
|
132
|
+
args: [params.positionId, params.ltvWad],
|
|
133
|
+
account: params.account,
|
|
134
|
+
} as any)) as any;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export async function prepareCoreClearPositionLtvOverride(params: {
|
|
138
|
+
publicClient: Pick<PublicClient, "simulateContract">;
|
|
139
|
+
coreAddress: Address;
|
|
140
|
+
account: Address;
|
|
141
|
+
positionId: bigint;
|
|
142
|
+
}): Promise<SimulatedTx> {
|
|
143
|
+
return (await params.publicClient.simulateContract({
|
|
144
|
+
address: params.coreAddress,
|
|
145
|
+
abi: abis.VARLACORE_ABI,
|
|
146
|
+
functionName: "clearPositionLtvOverride",
|
|
147
|
+
args: [params.positionId],
|
|
148
|
+
account: params.account,
|
|
149
|
+
} as any)) as any;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export async function prepareCoreSetPositionLiquidationConfigOverride(params: {
|
|
153
|
+
publicClient: Pick<PublicClient, "simulateContract">;
|
|
154
|
+
coreAddress: Address;
|
|
155
|
+
account: Address;
|
|
156
|
+
positionId: bigint;
|
|
157
|
+
maxLiquidationBonusBps: bigint;
|
|
158
|
+
liquidationFeeBps: bigint;
|
|
159
|
+
}): Promise<SimulatedTx> {
|
|
160
|
+
return (await params.publicClient.simulateContract({
|
|
161
|
+
address: params.coreAddress,
|
|
162
|
+
abi: abis.VARLACORE_ABI,
|
|
163
|
+
functionName: "setPositionLiquidationConfigOverride",
|
|
164
|
+
args: [params.positionId, params.maxLiquidationBonusBps, params.liquidationFeeBps],
|
|
165
|
+
account: params.account,
|
|
166
|
+
} as any)) as any;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export async function prepareCoreClearPositionLiquidationConfigOverride(params: {
|
|
170
|
+
publicClient: Pick<PublicClient, "simulateContract">;
|
|
171
|
+
coreAddress: Address;
|
|
172
|
+
account: Address;
|
|
173
|
+
positionId: bigint;
|
|
174
|
+
}): Promise<SimulatedTx> {
|
|
175
|
+
return (await params.publicClient.simulateContract({
|
|
176
|
+
address: params.coreAddress,
|
|
177
|
+
abi: abis.VARLACORE_ABI,
|
|
178
|
+
functionName: "clearPositionLiquidationConfigOverride",
|
|
179
|
+
args: [params.positionId],
|
|
180
|
+
account: params.account,
|
|
181
|
+
} as any)) as any;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// -----------------
|
|
185
|
+
// Pool admin
|
|
186
|
+
// -----------------
|
|
187
|
+
|
|
188
|
+
export async function preparePoolSetDepositCap(params: {
|
|
189
|
+
publicClient: Pick<PublicClient, "simulateContract">;
|
|
190
|
+
poolAddress: Address;
|
|
191
|
+
account: Address;
|
|
192
|
+
cap: bigint;
|
|
193
|
+
}): Promise<SimulatedTx> {
|
|
194
|
+
return (await params.publicClient.simulateContract({
|
|
195
|
+
address: params.poolAddress,
|
|
196
|
+
abi: abis.VARLAPOOL_ABI,
|
|
197
|
+
functionName: "setDepositCap",
|
|
198
|
+
args: [params.cap],
|
|
199
|
+
account: params.account,
|
|
200
|
+
} as any)) as any;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export async function preparePoolSetBorrowCap(params: {
|
|
204
|
+
publicClient: Pick<PublicClient, "simulateContract">;
|
|
205
|
+
poolAddress: Address;
|
|
206
|
+
account: Address;
|
|
207
|
+
cap: bigint;
|
|
208
|
+
}): Promise<SimulatedTx> {
|
|
209
|
+
return (await params.publicClient.simulateContract({
|
|
210
|
+
address: params.poolAddress,
|
|
211
|
+
abi: abis.VARLAPOOL_ABI,
|
|
212
|
+
functionName: "setBorrowCap",
|
|
213
|
+
args: [params.cap],
|
|
214
|
+
account: params.account,
|
|
215
|
+
} as any)) as any;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export async function preparePoolWithdrawReserve(params: {
|
|
219
|
+
publicClient: Pick<PublicClient, "simulateContract">;
|
|
220
|
+
poolAddress: Address;
|
|
221
|
+
account: Address;
|
|
222
|
+
to: Address;
|
|
223
|
+
amount: bigint;
|
|
224
|
+
}): Promise<SimulatedTx> {
|
|
225
|
+
return (await params.publicClient.simulateContract({
|
|
226
|
+
address: params.poolAddress,
|
|
227
|
+
abi: abis.VARLAPOOL_ABI,
|
|
228
|
+
functionName: "withdrawReserve",
|
|
229
|
+
args: [params.to, params.amount],
|
|
230
|
+
account: params.account,
|
|
231
|
+
} as any)) as any;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export async function preparePoolSetInterestRateStrategy(params: {
|
|
235
|
+
publicClient: Pick<PublicClient, "simulateContract">;
|
|
236
|
+
poolAddress: Address;
|
|
237
|
+
account: Address;
|
|
238
|
+
strategy: Address;
|
|
239
|
+
}): Promise<SimulatedTx> {
|
|
240
|
+
return (await params.publicClient.simulateContract({
|
|
241
|
+
address: params.poolAddress,
|
|
242
|
+
abi: abis.VARLAPOOL_ABI,
|
|
243
|
+
functionName: "setInterestRateStrategy",
|
|
244
|
+
args: [params.strategy],
|
|
245
|
+
account: params.account,
|
|
246
|
+
} as any)) as any;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// -----------------
|
|
250
|
+
// Oracle admin
|
|
251
|
+
// -----------------
|
|
252
|
+
|
|
253
|
+
export async function prepareOracleSetMaxStaleness(params: {
|
|
254
|
+
publicClient: Pick<PublicClient, "simulateContract">;
|
|
255
|
+
oracleAddress: Address;
|
|
256
|
+
account: Address;
|
|
257
|
+
maxStaleness: bigint;
|
|
258
|
+
}): Promise<SimulatedTx> {
|
|
259
|
+
return (await params.publicClient.simulateContract({
|
|
260
|
+
address: params.oracleAddress,
|
|
261
|
+
abi: abis.VARLAORACLE_ABI,
|
|
262
|
+
functionName: "setMaxStaleness",
|
|
263
|
+
args: [params.maxStaleness],
|
|
264
|
+
account: params.account,
|
|
265
|
+
} as any)) as any;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export async function prepareOracleSetLiquidationGracePeriod(params: {
|
|
269
|
+
publicClient: Pick<PublicClient, "simulateContract">;
|
|
270
|
+
oracleAddress: Address;
|
|
271
|
+
account: Address;
|
|
272
|
+
gracePeriod: bigint;
|
|
273
|
+
}): Promise<SimulatedTx> {
|
|
274
|
+
return (await params.publicClient.simulateContract({
|
|
275
|
+
address: params.oracleAddress,
|
|
276
|
+
abi: abis.VARLAORACLE_ABI,
|
|
277
|
+
functionName: "setLiquidationGracePeriod",
|
|
278
|
+
args: [params.gracePeriod],
|
|
279
|
+
account: params.account,
|
|
280
|
+
} as any)) as any;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export async function prepareOracleSetDefaultEarlyClosureWindow(params: {
|
|
284
|
+
publicClient: Pick<PublicClient, "simulateContract">;
|
|
285
|
+
oracleAddress: Address;
|
|
286
|
+
account: Address;
|
|
287
|
+
window: bigint;
|
|
288
|
+
}): Promise<SimulatedTx> {
|
|
289
|
+
return (await params.publicClient.simulateContract({
|
|
290
|
+
address: params.oracleAddress,
|
|
291
|
+
abi: abis.VARLAORACLE_ABI,
|
|
292
|
+
functionName: "setDefaultEarlyClosureWindow",
|
|
293
|
+
args: [params.window],
|
|
294
|
+
account: params.account,
|
|
295
|
+
} as any)) as any;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// -----------------
|
|
299
|
+
// InterestRateStrategy admin
|
|
300
|
+
// -----------------
|
|
301
|
+
|
|
302
|
+
export async function prepareStrategySetPool(params: {
|
|
303
|
+
publicClient: Pick<PublicClient, "simulateContract">;
|
|
304
|
+
strategyAddress: Address;
|
|
305
|
+
account: Address;
|
|
306
|
+
pool: Address;
|
|
307
|
+
}): Promise<SimulatedTx> {
|
|
308
|
+
return (await params.publicClient.simulateContract({
|
|
309
|
+
address: params.strategyAddress,
|
|
310
|
+
abi: abis.VARLAINTERESTRATESTRATEGY_ABI,
|
|
311
|
+
functionName: "setPool",
|
|
312
|
+
args: [params.pool],
|
|
313
|
+
account: params.account,
|
|
314
|
+
} as any)) as any;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export type StrategyRateParams = {
|
|
318
|
+
optimalUsageRatio: number;
|
|
319
|
+
baseVariableBorrowRate: number;
|
|
320
|
+
variableRateSlope1: number;
|
|
321
|
+
variableRateSlope2: number;
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
export async function prepareStrategySetRateParams(params: {
|
|
325
|
+
publicClient: Pick<PublicClient, "simulateContract">;
|
|
326
|
+
strategyAddress: Address;
|
|
327
|
+
account: Address;
|
|
328
|
+
params: StrategyRateParams;
|
|
329
|
+
}): Promise<SimulatedTx> {
|
|
330
|
+
return (await params.publicClient.simulateContract({
|
|
331
|
+
address: params.strategyAddress,
|
|
332
|
+
abi: abis.VARLAINTERESTRATESTRATEGY_ABI,
|
|
333
|
+
functionName: "setRateParams",
|
|
334
|
+
args: [params.params],
|
|
335
|
+
account: params.account,
|
|
336
|
+
} as any)) as any;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// -----------------
|
|
340
|
+
// OracleUpdaterRouter admin
|
|
341
|
+
// -----------------
|
|
342
|
+
|
|
343
|
+
export async function prepareOracleUpdaterRouterSetPublisher(params: {
|
|
344
|
+
publicClient: Pick<PublicClient, "simulateContract">;
|
|
345
|
+
routerAddress: Address;
|
|
346
|
+
account: Address;
|
|
347
|
+
publisher: Address;
|
|
348
|
+
allowed: boolean;
|
|
349
|
+
}): Promise<SimulatedTx> {
|
|
350
|
+
return (await params.publicClient.simulateContract({
|
|
351
|
+
address: params.routerAddress,
|
|
352
|
+
abi: abis.ORACLEUPDATERROUTER_ABI,
|
|
353
|
+
functionName: "setPublisher",
|
|
354
|
+
args: [params.publisher, params.allowed],
|
|
355
|
+
account: params.account,
|
|
356
|
+
} as any)) as any;
|
|
357
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Note: explicit .js extension is required for Node ESM resolution.
|
|
2
|
+
|
|
3
|
+
import type { Address, PublicClient } from "viem";
|
|
4
|
+
|
|
5
|
+
import { abis } from "../generated.js";
|
|
6
|
+
import type { SimulatedTx } from "./oracle.js";
|
|
7
|
+
|
|
8
|
+
export async function prepareCoreDeposit(params: {
|
|
9
|
+
publicClient: Pick<PublicClient, "simulateContract">;
|
|
10
|
+
coreAddress: Address;
|
|
11
|
+
account: Address;
|
|
12
|
+
positionIds: readonly bigint[];
|
|
13
|
+
amounts: readonly bigint[];
|
|
14
|
+
}): Promise<SimulatedTx> {
|
|
15
|
+
return (await params.publicClient.simulateContract({
|
|
16
|
+
address: params.coreAddress,
|
|
17
|
+
abi: abis.VARLACORE_ABI,
|
|
18
|
+
functionName: "deposit",
|
|
19
|
+
args: [params.positionIds, params.amounts],
|
|
20
|
+
account: params.account,
|
|
21
|
+
} as any)) as any;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function prepareCoreWithdraw(params: {
|
|
25
|
+
publicClient: Pick<PublicClient, "simulateContract">;
|
|
26
|
+
coreAddress: Address;
|
|
27
|
+
account: Address;
|
|
28
|
+
positionIds: readonly bigint[];
|
|
29
|
+
amounts: readonly bigint[];
|
|
30
|
+
}): Promise<SimulatedTx> {
|
|
31
|
+
return (await params.publicClient.simulateContract({
|
|
32
|
+
address: params.coreAddress,
|
|
33
|
+
abi: abis.VARLACORE_ABI,
|
|
34
|
+
functionName: "withdraw",
|
|
35
|
+
args: [params.positionIds, params.amounts],
|
|
36
|
+
account: params.account,
|
|
37
|
+
} as any)) as any;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function prepareCoreBorrow(params: {
|
|
41
|
+
publicClient: Pick<PublicClient, "simulateContract">;
|
|
42
|
+
coreAddress: Address;
|
|
43
|
+
account: Address;
|
|
44
|
+
amount: bigint;
|
|
45
|
+
}): Promise<SimulatedTx> {
|
|
46
|
+
return (await params.publicClient.simulateContract({
|
|
47
|
+
address: params.coreAddress,
|
|
48
|
+
abi: abis.VARLACORE_ABI,
|
|
49
|
+
functionName: "borrow",
|
|
50
|
+
args: [params.amount],
|
|
51
|
+
account: params.account,
|
|
52
|
+
} as any)) as any;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export async function prepareCoreRepay(params: {
|
|
56
|
+
publicClient: Pick<PublicClient, "simulateContract">;
|
|
57
|
+
coreAddress: Address;
|
|
58
|
+
account: Address;
|
|
59
|
+
amount: bigint;
|
|
60
|
+
}): Promise<SimulatedTx> {
|
|
61
|
+
return (await params.publicClient.simulateContract({
|
|
62
|
+
address: params.coreAddress,
|
|
63
|
+
abi: abis.VARLACORE_ABI,
|
|
64
|
+
functionName: "repay",
|
|
65
|
+
args: [params.amount],
|
|
66
|
+
account: params.account,
|
|
67
|
+
} as any)) as any;
|
|
68
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Note: explicit .js extension is required for Node ESM resolution.
|
|
2
|
+
|
|
3
|
+
import type { Address, PublicClient } from "viem";
|
|
4
|
+
import { erc1155Abi } from "viem";
|
|
5
|
+
|
|
6
|
+
import type { SimulatedTx } from "./oracle.js";
|
|
7
|
+
|
|
8
|
+
export async function prepareErc1155SetApprovalForAll(params: {
|
|
9
|
+
publicClient: Pick<PublicClient, "simulateContract">;
|
|
10
|
+
tokenAddress: Address;
|
|
11
|
+
account: Address;
|
|
12
|
+
operator: Address;
|
|
13
|
+
approved: boolean;
|
|
14
|
+
}): Promise<SimulatedTx> {
|
|
15
|
+
return (await params.publicClient.simulateContract({
|
|
16
|
+
address: params.tokenAddress,
|
|
17
|
+
abi: erc1155Abi,
|
|
18
|
+
functionName: "setApprovalForAll",
|
|
19
|
+
args: [params.operator, params.approved],
|
|
20
|
+
account: params.account,
|
|
21
|
+
} as any)) as any;
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Note: explicit .js extension is required for Node ESM resolution.
|
|
2
|
+
|
|
3
|
+
import type { Address, PublicClient } from "viem";
|
|
4
|
+
import { erc20Abi } from "viem";
|
|
5
|
+
|
|
6
|
+
import type { SimulatedTx } from "./oracle.js";
|
|
7
|
+
|
|
8
|
+
export async function prepareErc20Approve(params: {
|
|
9
|
+
publicClient: Pick<PublicClient, "simulateContract">;
|
|
10
|
+
tokenAddress: Address;
|
|
11
|
+
account: Address;
|
|
12
|
+
spender: Address;
|
|
13
|
+
amount: bigint;
|
|
14
|
+
}): Promise<SimulatedTx> {
|
|
15
|
+
return (await params.publicClient.simulateContract({
|
|
16
|
+
address: params.tokenAddress,
|
|
17
|
+
abi: erc20Abi,
|
|
18
|
+
functionName: "approve",
|
|
19
|
+
args: [params.spender, params.amount],
|
|
20
|
+
account: params.account,
|
|
21
|
+
} as any)) as any;
|
|
22
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Note: explicit .js extension is required for Node ESM resolution.
|
|
2
|
+
|
|
3
|
+
export * from "./admin.js";
|
|
4
|
+
export * from "./core.js";
|
|
5
|
+
export * from "./erc20.js";
|
|
6
|
+
export * from "./erc1155.js";
|
|
7
|
+
export * from "./liquidator.js";
|
|
8
|
+
export * from "./oracle.js";
|
|
9
|
+
export * from "./oracleUpdaterRouter.js";
|
|
10
|
+
export * from "./pool.js";
|
|
11
|
+
export * from "./rbac.js";
|
|
12
|
+
export * from "./tx.js";
|
|
13
|
+
export * from "./utils.js";
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// Note: explicit .js extension is required for Node ESM resolution.
|
|
2
|
+
|
|
3
|
+
import type { Address, PublicClient } from "viem";
|
|
4
|
+
|
|
5
|
+
import { abis } from "../generated.js";
|
|
6
|
+
import type { SimulatedTx } from "./oracle.js";
|
|
7
|
+
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
// Liquidator (bot flows) write helpers
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
export async function prepareLiquidatorLiquidate(params: {
|
|
13
|
+
publicClient: Pick<PublicClient, "simulateContract">;
|
|
14
|
+
liquidatorAddress: Address;
|
|
15
|
+
account: Address;
|
|
16
|
+
user: Address;
|
|
17
|
+
positionId: bigint;
|
|
18
|
+
debtToCover: bigint;
|
|
19
|
+
}): Promise<SimulatedTx> {
|
|
20
|
+
return (await params.publicClient.simulateContract({
|
|
21
|
+
address: params.liquidatorAddress,
|
|
22
|
+
abi: abis.VARLALIQUIDATOR_ABI,
|
|
23
|
+
functionName: "liquidate",
|
|
24
|
+
args: [params.user, params.positionId, params.debtToCover],
|
|
25
|
+
account: params.account,
|
|
26
|
+
} as any)) as any;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export async function prepareLiquidatorLiquidateMulti(params: {
|
|
30
|
+
publicClient: Pick<PublicClient, "simulateContract">;
|
|
31
|
+
liquidatorAddress: Address;
|
|
32
|
+
account: Address;
|
|
33
|
+
user: Address;
|
|
34
|
+
positionIds: readonly bigint[];
|
|
35
|
+
debtToCover: bigint;
|
|
36
|
+
}): Promise<SimulatedTx> {
|
|
37
|
+
return (await params.publicClient.simulateContract({
|
|
38
|
+
address: params.liquidatorAddress,
|
|
39
|
+
abi: abis.VARLALIQUIDATOR_ABI,
|
|
40
|
+
functionName: "liquidateMulti",
|
|
41
|
+
args: [params.user, params.positionIds, params.debtToCover],
|
|
42
|
+
account: params.account,
|
|
43
|
+
} as any)) as any;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function prepareLiquidatorLiquidateBadDebt(params: {
|
|
47
|
+
publicClient: Pick<PublicClient, "simulateContract">;
|
|
48
|
+
liquidatorAddress: Address;
|
|
49
|
+
account: Address;
|
|
50
|
+
user: Address;
|
|
51
|
+
maxRepayAmount: bigint;
|
|
52
|
+
}): Promise<SimulatedTx> {
|
|
53
|
+
return (await params.publicClient.simulateContract({
|
|
54
|
+
address: params.liquidatorAddress,
|
|
55
|
+
abi: abis.VARLALIQUIDATOR_ABI,
|
|
56
|
+
functionName: "liquidateBadDebt",
|
|
57
|
+
args: [params.user, params.maxRepayAmount],
|
|
58
|
+
account: params.account,
|
|
59
|
+
} as any)) as any;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export async function prepareLiquidatorResolveBadDebtWithReserve(params: {
|
|
63
|
+
publicClient: Pick<PublicClient, "simulateContract">;
|
|
64
|
+
liquidatorAddress: Address;
|
|
65
|
+
account: Address;
|
|
66
|
+
user: Address;
|
|
67
|
+
expectedScaledDebt: bigint;
|
|
68
|
+
}): Promise<SimulatedTx> {
|
|
69
|
+
return (await params.publicClient.simulateContract({
|
|
70
|
+
address: params.liquidatorAddress,
|
|
71
|
+
abi: abis.VARLALIQUIDATOR_ABI,
|
|
72
|
+
functionName: "resolveBadDebtWithReserve",
|
|
73
|
+
args: [params.user, params.expectedScaledDebt],
|
|
74
|
+
account: params.account,
|
|
75
|
+
} as any)) as any;
|
|
76
|
+
}
|