@varla/sdk 2.12.0 → 2.13.1
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 +10 -10
- package/CHANGELOG.md +15 -0
- package/dist/abi/full/VarlaOracle.d.ts +72 -0
- package/dist/abi/full/VarlaOracle.d.ts.map +1 -1
- package/dist/abi/full/VarlaOracle.js +93 -0
- package/dist/abi/full/VarlaOracle.js.map +1 -1
- package/dist/abi/subsets/VarlaOracle.registry.d.ts +42 -0
- package/dist/abi/subsets/VarlaOracle.registry.d.ts.map +1 -1
- package/dist/abi/subsets/VarlaOracle.registry.js +54 -0
- package/dist/abi/subsets/VarlaOracle.registry.js.map +1 -1
- package/dist/addresses/index.d.ts +1 -1
- package/dist/addresses/index.d.ts.map +1 -1
- package/dist/addresses/index.js +1 -1
- package/dist/addresses/index.js.map +1 -1
- package/dist/addresses/polygon.d.ts.map +1 -1
- package/dist/addresses/polygon.js +12 -10
- package/dist/addresses/polygon.js.map +1 -1
- package/dist/addresses/polygonProxy.d.ts +3 -0
- package/dist/addresses/polygonProxy.d.ts.map +1 -0
- package/dist/addresses/polygonProxy.js +15 -0
- package/dist/addresses/polygonProxy.js.map +1 -0
- package/dist/contracts.d.ts +11 -3
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +20 -10
- package/dist/contracts.js.map +1 -1
- package/dist/generated.d.ts +115 -1
- package/dist/generated.d.ts.map +1 -1
- package/dist/generated.js +1 -1
- package/dist/generated.js.map +1 -1
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/views/admin.d.ts +25 -0
- package/dist/views/admin.d.ts.map +1 -1
- package/dist/views/admin.js +62 -1
- package/dist/views/admin.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/full/VarlaOracle.ts +93 -0
- package/src/abi/subsets/VarlaOracle.registry.ts +54 -0
- package/src/addresses/index.ts +1 -1
- package/src/addresses/polygon.json +10 -10
- package/src/addresses/polygon.ts +13 -11
- package/src/addresses/polygonProxy.ts +18 -0
- package/src/contracts.ts +30 -10
- package/src/generated.ts +1 -1
- package/src/types.ts +8 -0
- package/src/views/admin.ts +84 -1
|
@@ -170,6 +170,22 @@ export const VARLAORACLE_ABI_REGISTRY = [
|
|
|
170
170
|
"name": "InvalidMaxStaleness",
|
|
171
171
|
"type": "error"
|
|
172
172
|
},
|
|
173
|
+
{
|
|
174
|
+
"inputs": [
|
|
175
|
+
{
|
|
176
|
+
"internalType": "uint256",
|
|
177
|
+
"name": "value",
|
|
178
|
+
"type": "uint256"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"internalType": "uint256",
|
|
182
|
+
"name": "floor",
|
|
183
|
+
"type": "uint256"
|
|
184
|
+
}
|
|
185
|
+
],
|
|
186
|
+
"name": "InvalidMinLiquidity",
|
|
187
|
+
"type": "error"
|
|
188
|
+
},
|
|
173
189
|
{
|
|
174
190
|
"inputs": [
|
|
175
191
|
{
|
|
@@ -396,6 +412,25 @@ export const VARLAORACLE_ABI_REGISTRY = [
|
|
|
396
412
|
"name": "LowLiquidityConfigUpdated",
|
|
397
413
|
"type": "event"
|
|
398
414
|
},
|
|
415
|
+
{
|
|
416
|
+
"anonymous": false,
|
|
417
|
+
"inputs": [
|
|
418
|
+
{
|
|
419
|
+
"indexed": false,
|
|
420
|
+
"internalType": "bool",
|
|
421
|
+
"name": "oldValue",
|
|
422
|
+
"type": "bool"
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
"indexed": false,
|
|
426
|
+
"internalType": "bool",
|
|
427
|
+
"name": "newValue",
|
|
428
|
+
"type": "bool"
|
|
429
|
+
}
|
|
430
|
+
],
|
|
431
|
+
"name": "LowLiquidityGraceBlocksLiquidationUpdated",
|
|
432
|
+
"type": "event"
|
|
433
|
+
},
|
|
399
434
|
{
|
|
400
435
|
"anonymous": false,
|
|
401
436
|
"inputs": [
|
|
@@ -440,6 +475,25 @@ export const VARLAORACLE_ABI_REGISTRY = [
|
|
|
440
475
|
"name": "MaxStalenessUpdated",
|
|
441
476
|
"type": "event"
|
|
442
477
|
},
|
|
478
|
+
{
|
|
479
|
+
"anonymous": false,
|
|
480
|
+
"inputs": [
|
|
481
|
+
{
|
|
482
|
+
"indexed": false,
|
|
483
|
+
"internalType": "uint256",
|
|
484
|
+
"name": "oldMinLiquidity",
|
|
485
|
+
"type": "uint256"
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
"indexed": false,
|
|
489
|
+
"internalType": "uint256",
|
|
490
|
+
"name": "newMinLiquidity",
|
|
491
|
+
"type": "uint256"
|
|
492
|
+
}
|
|
493
|
+
],
|
|
494
|
+
"name": "MinLiquidityUpdated",
|
|
495
|
+
"type": "event"
|
|
496
|
+
},
|
|
443
497
|
{
|
|
444
498
|
"anonymous": false,
|
|
445
499
|
"inputs": [
|
package/src/addresses/index.ts
CHANGED
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
"generatedAt": "",
|
|
4
4
|
"deploymentsDir": "polygon",
|
|
5
5
|
"contracts": {
|
|
6
|
-
"VarlaAccessManager": "
|
|
7
|
-
"VarlaOracle": "
|
|
8
|
-
"VarlaCore": "
|
|
9
|
-
"VarlaPool": "
|
|
10
|
-
"OracleUpdaterRouter": "
|
|
11
|
-
"VarlaLiquidator": "
|
|
12
|
-
"VarlaMergeLiquidator": "
|
|
13
|
-
"VarlaConvertLiquidator": "
|
|
14
|
-
"PolymarketCtfAdapter": "
|
|
15
|
-
"PolymarketNegRiskMergeAdapter": "
|
|
6
|
+
"VarlaAccessManager": "0xEAC5659248A4f4c8440961874FA7994c6B821ad0",
|
|
7
|
+
"VarlaOracle": "0x6D6d16860c9366a97AbC02402cFe7988F9c20a8d",
|
|
8
|
+
"VarlaCore": "0x79870b76C01900e53a909b1F77d2CF3f1935c5D8",
|
|
9
|
+
"VarlaPool": "0xf1d4be6c15b6F7Fb66CE2C85368d26a603eb3cC0",
|
|
10
|
+
"OracleUpdaterRouter": "0xd98799d440034CeC1CE41c8495cdeF0dA18951C1",
|
|
11
|
+
"VarlaLiquidator": "0xD570aeFD9C54f816a53786ed1888fE4A03be359A",
|
|
12
|
+
"VarlaMergeLiquidator": "0x71becFD9AC3aeE3F3BD24A8518022147Efc18b4d",
|
|
13
|
+
"VarlaConvertLiquidator": "0x842905cA77B50eCDf2D890516fCD7E9A324B44e9",
|
|
14
|
+
"PolymarketCtfAdapter": "0x3bd6570DB3f6D6965F78399817678950d6eC6e4C",
|
|
15
|
+
"PolymarketNegRiskMergeAdapter": "0x424886B053D1eED5FE98A94988CFC8CA28c7C0A7"
|
|
16
16
|
}
|
|
17
17
|
}
|
package/src/addresses/polygon.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
// Auto-generated from varla-protocol deployments/polygon
|
|
1
|
+
// Auto-generated from varla-protocol deployments/polygon (immutable)
|
|
2
2
|
import type { AddressBook } from "../types";
|
|
3
3
|
|
|
4
4
|
export const polygon: AddressBook = {
|
|
5
|
-
accessManager: "
|
|
6
|
-
oracle: "
|
|
7
|
-
core: "
|
|
8
|
-
pool: "
|
|
9
|
-
oracleUpdaterRouter: "
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
accessManager: "0xEAC5659248A4f4c8440961874FA7994c6B821ad0",
|
|
6
|
+
oracle: "0x6D6d16860c9366a97AbC02402cFe7988F9c20a8d",
|
|
7
|
+
core: "0x79870b76C01900e53a909b1F77d2CF3f1935c5D8",
|
|
8
|
+
pool: "0xf1d4be6c15b6F7Fb66CE2C85368d26a603eb3cC0",
|
|
9
|
+
oracleUpdaterRouter: "0xd98799d440034CeC1CE41c8495cdeF0dA18951C1",
|
|
10
|
+
interestRateStrategy: "0x6eE2F00463632476614a01332aD490c87978fa1d",
|
|
11
|
+
proxyAdmin: "0xf42B3A7E9850DF4D6Ea0a58CF72C531b3B479aAB",
|
|
12
|
+
liquidator: "0xD570aeFD9C54f816a53786ed1888fE4A03be359A",
|
|
13
|
+
mergeLiquidator: "0x71becFD9AC3aeE3F3BD24A8518022147Efc18b4d",
|
|
14
|
+
convertLiquidator: "0x842905cA77B50eCDf2D890516fCD7E9A324B44e9",
|
|
15
|
+
polymarketCtfAdapter: "0x3bd6570DB3f6D6965F78399817678950d6eC6e4C",
|
|
16
|
+
negRiskMergeAdapter: "0x424886B053D1eED5FE98A94988CFC8CA28c7C0A7",
|
|
15
17
|
};
|
|
16
18
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Auto-generated from varla-protocol deployments/polygon (proxy)
|
|
2
|
+
import type { AddressBook } from "../types";
|
|
3
|
+
|
|
4
|
+
export const polygonProxy: AddressBook = {
|
|
5
|
+
accessManager: "0xEAC5659248A4f4c8440961874FA7994c6B821ad0",
|
|
6
|
+
oracle: "0x1021A3B50F824873D96Ef126e4622cFFcD8d59bc",
|
|
7
|
+
core: "0x336A935210b39E01aC296f211274492caF013F77",
|
|
8
|
+
pool: "0x990DA16Fb01186C5Ffc3f185ff07c126C6705d76",
|
|
9
|
+
oracleUpdaterRouter: "0xd98799d440034CeC1CE41c8495cdeF0dA18951C1",
|
|
10
|
+
interestRateStrategy: "0x2C1D739947F1DD4F1E683f9e98F8c7B3d4a31464",
|
|
11
|
+
proxyAdmin: "0xf42B3A7E9850DF4D6Ea0a58CF72C531b3B479aAB",
|
|
12
|
+
liquidator: "0xDb94015Dd6304d86c637b218a867D15F49c3cC9b",
|
|
13
|
+
mergeLiquidator: "0xaCc7f056B0b9FEF713c5F317Bb65Fe660b3e1b2a",
|
|
14
|
+
convertLiquidator: "0x4d175bCCc5400Aca8b2d9E8c6c0aF179607fB935",
|
|
15
|
+
polymarketCtfAdapter: "0x3bd6570DB3f6D6965F78399817678950d6eC6e4C",
|
|
16
|
+
negRiskMergeAdapter: "0x424886B053D1eED5FE98A94988CFC8CA28c7C0A7",
|
|
17
|
+
};
|
|
18
|
+
|
package/src/contracts.ts
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "viem";
|
|
12
12
|
|
|
13
13
|
import { abis, addresses } from "./generated.js";
|
|
14
|
-
import type { AddressBook, ChainKey } from "./types.js";
|
|
14
|
+
import type { AddressBook, ChainKey, DeployMode } from "./types.js";
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* A typed viem Contract instance.
|
|
@@ -53,15 +53,31 @@ export type VarlaContracts = {
|
|
|
53
53
|
export type GetVarlaContractsParams = {
|
|
54
54
|
chain: ChainKey;
|
|
55
55
|
client: PublicClient;
|
|
56
|
+
/** Deployment mode. Defaults to `"immutable"`. */
|
|
57
|
+
mode?: DeployMode;
|
|
56
58
|
};
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Resolve the address book for a chain + deployment mode.
|
|
62
|
+
*
|
|
63
|
+
* @param chain - Chain key (`"polygon"` | `"bsc"`)
|
|
64
|
+
* @param mode - `"immutable"` (default) or `"proxy"`
|
|
65
|
+
*/
|
|
66
|
+
export function getAddressBook(chain: ChainKey, mode?: DeployMode): AddressBook {
|
|
67
|
+
const m = mode ?? "immutable";
|
|
68
|
+
|
|
69
|
+
const key = m === "proxy" ? `${chain}Proxy` : chain;
|
|
70
|
+
const book = (addresses as Record<string, AddressBook | undefined>)[key];
|
|
71
|
+
if (!book) {
|
|
72
|
+
throw new Error(
|
|
73
|
+
m === "proxy"
|
|
74
|
+
? `No proxy deployment found for chain '${chain}'. ` +
|
|
75
|
+
`Run the deploy with DEPLOY_MODE=proxy and regenerate SDK artifacts.`
|
|
76
|
+
: `No deployment found for chain '${chain}'. ` +
|
|
77
|
+
`Deploy the chain and run \`bun run prepack\` to regenerate SDK artifacts.`,
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
return book;
|
|
65
81
|
}
|
|
66
82
|
|
|
67
83
|
function mustAddress(book: AddressBook, key: keyof AddressBook): Address {
|
|
@@ -77,8 +93,12 @@ function mustAddress(book: AddressBook, key: keyof AddressBook): Address {
|
|
|
77
93
|
*
|
|
78
94
|
* Optional deployments are returned as `undefined`.
|
|
79
95
|
*/
|
|
80
|
-
export function getVarlaContracts({
|
|
81
|
-
|
|
96
|
+
export function getVarlaContracts({
|
|
97
|
+
chain,
|
|
98
|
+
client,
|
|
99
|
+
mode,
|
|
100
|
+
}: GetVarlaContractsParams): VarlaContracts {
|
|
101
|
+
const book = getAddressBook(chain, mode);
|
|
82
102
|
|
|
83
103
|
const accessManager = getContract({
|
|
84
104
|
address: mustAddress(book, "accessManager"),
|
package/src/generated.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
export type ChainKey = "polygon" | "bsc";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Deployment mode.
|
|
5
|
+
*
|
|
6
|
+
* - `"immutable"` — contracts deployed directly (dev/testing, default)
|
|
7
|
+
* - `"proxy"` — contracts behind TransparentUpgradeableProxy (production/TVL)
|
|
8
|
+
*/
|
|
9
|
+
export type DeployMode = "immutable" | "proxy";
|
|
10
|
+
|
|
3
11
|
/**
|
|
4
12
|
* Minimal address book for off-chain services.
|
|
5
13
|
*
|
package/src/views/admin.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// Note: explicit .js extension is required for Node ESM resolution.
|
|
2
2
|
|
|
3
|
-
import { type Address, getContract, type PublicClient } from "viem";
|
|
3
|
+
import { type Address, getAddress, getContract, type PublicClient } from "viem";
|
|
4
4
|
|
|
5
5
|
import { abis } from "../generated.js";
|
|
6
|
+
import type { DeployMode } from "../types.js";
|
|
6
7
|
|
|
7
8
|
type StrategyLike = {
|
|
8
9
|
read: {
|
|
@@ -90,3 +91,85 @@ export async function readProxyAdminPaused(params: {
|
|
|
90
91
|
}): Promise<boolean> {
|
|
91
92
|
return params.proxyAdmin.read.paused();
|
|
92
93
|
}
|
|
94
|
+
|
|
95
|
+
// ---------------------------------------------------------------------------
|
|
96
|
+
// Proxy detection — EIP-1967
|
|
97
|
+
// ---------------------------------------------------------------------------
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* EIP-1967 implementation storage slot.
|
|
101
|
+
* `bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)`
|
|
102
|
+
*/
|
|
103
|
+
const EIP1967_IMPL_SLOT =
|
|
104
|
+
"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc" as const;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* EIP-1967 admin storage slot.
|
|
108
|
+
* `bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)`
|
|
109
|
+
*/
|
|
110
|
+
const EIP1967_ADMIN_SLOT =
|
|
111
|
+
"0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103" as const;
|
|
112
|
+
|
|
113
|
+
function slotToAddress(raw: string | undefined): Address | undefined {
|
|
114
|
+
if (!raw || raw === "0x" || BigInt(raw) === 0n) return undefined;
|
|
115
|
+
// Slot value is 32 bytes, address is the lower 20 bytes.
|
|
116
|
+
return getAddress(`0x${raw.slice(-40)}`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export type ProxyInfo = {
|
|
120
|
+
isProxy: boolean;
|
|
121
|
+
implementation?: Address;
|
|
122
|
+
proxyAdmin?: Address;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Detect whether a contract address is behind an EIP-1967 transparent proxy.
|
|
127
|
+
*
|
|
128
|
+
* Returns `"proxy"` if the EIP-1967 implementation slot is non-zero,
|
|
129
|
+
* `"immutable"` otherwise.
|
|
130
|
+
*/
|
|
131
|
+
// wraps: eth_getStorageAt (EIP-1967 implementation slot)
|
|
132
|
+
export async function readDeploymentMode(params: {
|
|
133
|
+
client: PublicClient;
|
|
134
|
+
address: Address;
|
|
135
|
+
}): Promise<DeployMode> {
|
|
136
|
+
const raw = await params.client.getStorageAt({
|
|
137
|
+
address: params.address,
|
|
138
|
+
slot: EIP1967_IMPL_SLOT,
|
|
139
|
+
});
|
|
140
|
+
const impl = slotToAddress(raw);
|
|
141
|
+
return impl ? "proxy" : "immutable";
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Read EIP-1967 proxy details (implementation + admin addresses).
|
|
146
|
+
*
|
|
147
|
+
* If the address is not a proxy, returns `{ isProxy: false }`.
|
|
148
|
+
*/
|
|
149
|
+
// wraps: eth_getStorageAt (EIP-1967 implementation + admin slots)
|
|
150
|
+
export async function readProxyInfo(params: {
|
|
151
|
+
client: PublicClient;
|
|
152
|
+
address: Address;
|
|
153
|
+
}): Promise<ProxyInfo> {
|
|
154
|
+
const [implRaw, adminRaw] = await Promise.all([
|
|
155
|
+
params.client.getStorageAt({
|
|
156
|
+
address: params.address,
|
|
157
|
+
slot: EIP1967_IMPL_SLOT,
|
|
158
|
+
}),
|
|
159
|
+
params.client.getStorageAt({
|
|
160
|
+
address: params.address,
|
|
161
|
+
slot: EIP1967_ADMIN_SLOT,
|
|
162
|
+
}),
|
|
163
|
+
]);
|
|
164
|
+
|
|
165
|
+
const implementation = slotToAddress(implRaw);
|
|
166
|
+
const proxyAdmin = slotToAddress(adminRaw);
|
|
167
|
+
|
|
168
|
+
if (!implementation) return { isProxy: false };
|
|
169
|
+
|
|
170
|
+
return {
|
|
171
|
+
isProxy: true,
|
|
172
|
+
implementation,
|
|
173
|
+
proxyAdmin,
|
|
174
|
+
};
|
|
175
|
+
}
|