@dimes-dot-fi/sdk 2.3.0 → 2.5.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/README.md +10 -0
- package/dist/{aliases-Dne14KBa.d.cts → aliases-lNsFUKPA.d.cts} +147 -10
- package/dist/{aliases-Dne14KBa.d.ts → aliases-lNsFUKPA.d.ts} +147 -10
- package/dist/{chunk-E6YJDY4F.cjs → chunk-ERM4WP6D.cjs} +9 -4
- package/dist/chunk-ERM4WP6D.cjs.map +1 -0
- package/dist/{chunk-4OKYU5D7.mjs → chunk-GA7ZBK6W.mjs} +9 -4
- package/dist/chunk-GA7ZBK6W.mjs.map +1 -0
- package/dist/{chunk-IJO5E22G.mjs → chunk-HJ5EVO5A.mjs} +11 -6
- package/dist/chunk-HJ5EVO5A.mjs.map +1 -0
- package/dist/{chunk-GY6L2QGR.cjs → chunk-L273PAD4.cjs} +14 -9
- package/dist/chunk-L273PAD4.cjs.map +1 -0
- package/dist/contract/index.cjs +557 -67
- package/dist/contract/index.cjs.map +1 -1
- package/dist/contract/index.d.cts +69 -8
- package/dist/contract/index.d.ts +69 -8
- package/dist/contract/index.mjs +544 -54
- package/dist/contract/index.mjs.map +1 -1
- package/dist/{dimes-client-DJ1d_p31.d.ts → dimes-client-BUAeOsgL.d.cts} +48 -3
- package/dist/{dimes-client-D9tohawC.d.cts → dimes-client-DDF-f8yA.d.ts} +48 -3
- package/dist/{dimes-error-hSoOierP.d.ts → dimes-error-CkcjExUy.d.ts} +1 -1
- package/dist/{dimes-error-E9yPAZb-.d.cts → dimes-error-I7lEZ2V5.d.cts} +1 -1
- package/dist/index.cjs +78 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -9
- package/dist/index.d.ts +10 -9
- package/dist/index.mjs +74 -4
- package/dist/index.mjs.map +1 -1
- package/dist/{quote-D4QunMtN.d.ts → quote-B_cMLw7P.d.cts} +7 -2
- package/dist/{quote-sWguOcoJ.d.cts → quote-Z88cryAN.d.ts} +7 -2
- package/dist/react/index.cjs +34 -33
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +12 -8
- package/dist/react/index.d.ts +12 -8
- package/dist/react/index.mjs +7 -6
- package/dist/react/index.mjs.map +1 -1
- package/dist/{types-BHU4Qq7e.d.ts → types-BvZf3uFL.d.ts} +1 -1
- package/dist/{types-Bvj_WDbX.d.cts → types-F2rHf2Qv.d.cts} +1 -1
- package/dist/ws/index.d.cts +3 -3
- package/dist/ws/index.d.ts +3 -3
- package/package.json +1 -1
- package/dist/chunk-4OKYU5D7.mjs.map +0 -1
- package/dist/chunk-E6YJDY4F.cjs.map +0 -1
- package/dist/chunk-GY6L2QGR.cjs.map +0 -1
- package/dist/chunk-IJO5E22G.mjs.map +0 -1
package/dist/contract/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkERM4WP6Dcjs = require('../chunk-ERM4WP6D.cjs');
|
|
5
5
|
|
|
6
6
|
// src/contract/vault-abi.json
|
|
7
7
|
var vault_abi_default = {
|
|
@@ -285,6 +285,11 @@ var vault_abi_default = {
|
|
|
285
285
|
name: "LockedByPushDeposit",
|
|
286
286
|
inputs: []
|
|
287
287
|
},
|
|
288
|
+
{
|
|
289
|
+
type: "error",
|
|
290
|
+
name: "MarginAboveMaximum",
|
|
291
|
+
inputs: []
|
|
292
|
+
},
|
|
288
293
|
{
|
|
289
294
|
type: "error",
|
|
290
295
|
name: "MarketCapitalExceeded",
|
|
@@ -2502,6 +2507,86 @@ var vault_abi_default = {
|
|
|
2502
2507
|
],
|
|
2503
2508
|
anonymous: false
|
|
2504
2509
|
},
|
|
2510
|
+
{
|
|
2511
|
+
type: "event",
|
|
2512
|
+
name: "PositionMarginLocked",
|
|
2513
|
+
inputs: [
|
|
2514
|
+
{
|
|
2515
|
+
name: "positionKey",
|
|
2516
|
+
type: "bytes32",
|
|
2517
|
+
indexed: true,
|
|
2518
|
+
internalType: "bytes32"
|
|
2519
|
+
},
|
|
2520
|
+
{
|
|
2521
|
+
name: "owner",
|
|
2522
|
+
type: "address",
|
|
2523
|
+
indexed: true,
|
|
2524
|
+
internalType: "address"
|
|
2525
|
+
},
|
|
2526
|
+
{
|
|
2527
|
+
name: "marginUsdcUnits",
|
|
2528
|
+
type: "uint256",
|
|
2529
|
+
indexed: false,
|
|
2530
|
+
internalType: "uint256"
|
|
2531
|
+
},
|
|
2532
|
+
{
|
|
2533
|
+
name: "totalLockedMarginUsdcUnits",
|
|
2534
|
+
type: "uint256",
|
|
2535
|
+
indexed: false,
|
|
2536
|
+
internalType: "uint256"
|
|
2537
|
+
},
|
|
2538
|
+
{
|
|
2539
|
+
name: "timestamp",
|
|
2540
|
+
type: "uint256",
|
|
2541
|
+
indexed: false,
|
|
2542
|
+
internalType: "uint256"
|
|
2543
|
+
}
|
|
2544
|
+
],
|
|
2545
|
+
anonymous: false
|
|
2546
|
+
},
|
|
2547
|
+
{
|
|
2548
|
+
type: "event",
|
|
2549
|
+
name: "PositionMarginReleased",
|
|
2550
|
+
inputs: [
|
|
2551
|
+
{
|
|
2552
|
+
name: "positionKey",
|
|
2553
|
+
type: "bytes32",
|
|
2554
|
+
indexed: true,
|
|
2555
|
+
internalType: "bytes32"
|
|
2556
|
+
},
|
|
2557
|
+
{
|
|
2558
|
+
name: "owner",
|
|
2559
|
+
type: "address",
|
|
2560
|
+
indexed: true,
|
|
2561
|
+
internalType: "address"
|
|
2562
|
+
},
|
|
2563
|
+
{
|
|
2564
|
+
name: "marginUsdcUnits",
|
|
2565
|
+
type: "uint256",
|
|
2566
|
+
indexed: false,
|
|
2567
|
+
internalType: "uint256"
|
|
2568
|
+
},
|
|
2569
|
+
{
|
|
2570
|
+
name: "foldedIntoWaterfall",
|
|
2571
|
+
type: "bool",
|
|
2572
|
+
indexed: false,
|
|
2573
|
+
internalType: "bool"
|
|
2574
|
+
},
|
|
2575
|
+
{
|
|
2576
|
+
name: "totalLockedMarginUsdcUnits",
|
|
2577
|
+
type: "uint256",
|
|
2578
|
+
indexed: false,
|
|
2579
|
+
internalType: "uint256"
|
|
2580
|
+
},
|
|
2581
|
+
{
|
|
2582
|
+
name: "timestamp",
|
|
2583
|
+
type: "uint256",
|
|
2584
|
+
indexed: false,
|
|
2585
|
+
internalType: "uint256"
|
|
2586
|
+
}
|
|
2587
|
+
],
|
|
2588
|
+
anonymous: false
|
|
2589
|
+
},
|
|
2505
2590
|
{
|
|
2506
2591
|
type: "event",
|
|
2507
2592
|
name: "PositionOpened",
|
|
@@ -3045,6 +3130,73 @@ var vault_abi_default = {
|
|
|
3045
3130
|
],
|
|
3046
3131
|
anonymous: false
|
|
3047
3132
|
},
|
|
3133
|
+
{
|
|
3134
|
+
type: "event",
|
|
3135
|
+
name: "SettlePositionFinalizedWithReturn",
|
|
3136
|
+
inputs: [
|
|
3137
|
+
{
|
|
3138
|
+
name: "positionKey",
|
|
3139
|
+
type: "bytes32",
|
|
3140
|
+
indexed: true,
|
|
3141
|
+
internalType: "bytes32"
|
|
3142
|
+
},
|
|
3143
|
+
{
|
|
3144
|
+
name: "signer",
|
|
3145
|
+
type: "address",
|
|
3146
|
+
indexed: true,
|
|
3147
|
+
internalType: "address"
|
|
3148
|
+
},
|
|
3149
|
+
{
|
|
3150
|
+
name: "saleReceivedUsdcUnits",
|
|
3151
|
+
type: "uint256",
|
|
3152
|
+
indexed: false,
|
|
3153
|
+
internalType: "uint256"
|
|
3154
|
+
},
|
|
3155
|
+
{
|
|
3156
|
+
name: "tokensSoldUnits",
|
|
3157
|
+
type: "uint256",
|
|
3158
|
+
indexed: false,
|
|
3159
|
+
internalType: "uint256"
|
|
3160
|
+
},
|
|
3161
|
+
{
|
|
3162
|
+
name: "returnedTokenUnits",
|
|
3163
|
+
type: "uint256",
|
|
3164
|
+
indexed: false,
|
|
3165
|
+
internalType: "uint256"
|
|
3166
|
+
},
|
|
3167
|
+
{
|
|
3168
|
+
name: "positionTokenUnits",
|
|
3169
|
+
type: "uint256",
|
|
3170
|
+
indexed: false,
|
|
3171
|
+
internalType: "uint256"
|
|
3172
|
+
},
|
|
3173
|
+
{
|
|
3174
|
+
name: "marketOutcome",
|
|
3175
|
+
type: "uint8",
|
|
3176
|
+
indexed: false,
|
|
3177
|
+
internalType: "uint8"
|
|
3178
|
+
},
|
|
3179
|
+
{
|
|
3180
|
+
name: "settledInFavor",
|
|
3181
|
+
type: "bool",
|
|
3182
|
+
indexed: false,
|
|
3183
|
+
internalType: "bool"
|
|
3184
|
+
},
|
|
3185
|
+
{
|
|
3186
|
+
name: "sanityCheckPassed",
|
|
3187
|
+
type: "bool",
|
|
3188
|
+
indexed: false,
|
|
3189
|
+
internalType: "bool"
|
|
3190
|
+
},
|
|
3191
|
+
{
|
|
3192
|
+
name: "timestamp",
|
|
3193
|
+
type: "uint256",
|
|
3194
|
+
indexed: false,
|
|
3195
|
+
internalType: "uint256"
|
|
3196
|
+
}
|
|
3197
|
+
],
|
|
3198
|
+
anonymous: false
|
|
3199
|
+
},
|
|
3048
3200
|
{
|
|
3049
3201
|
type: "event",
|
|
3050
3202
|
name: "SettlePositionInitiated",
|
|
@@ -3535,6 +3687,152 @@ var vault_abi_default = {
|
|
|
3535
3687
|
outputs: [],
|
|
3536
3688
|
stateMutability: "nonpayable"
|
|
3537
3689
|
},
|
|
3690
|
+
{
|
|
3691
|
+
type: "function",
|
|
3692
|
+
name: "createPositionPushFundedWithMargin",
|
|
3693
|
+
inputs: [
|
|
3694
|
+
{
|
|
3695
|
+
name: "positionSeed",
|
|
3696
|
+
type: "bytes16",
|
|
3697
|
+
internalType: "bytes16"
|
|
3698
|
+
},
|
|
3699
|
+
{
|
|
3700
|
+
name: "marketId",
|
|
3701
|
+
type: "bytes32",
|
|
3702
|
+
internalType: "bytes32"
|
|
3703
|
+
},
|
|
3704
|
+
{
|
|
3705
|
+
name: "tokenId",
|
|
3706
|
+
type: "uint256",
|
|
3707
|
+
internalType: "uint256"
|
|
3708
|
+
},
|
|
3709
|
+
{
|
|
3710
|
+
name: "collateralUsdcUnits",
|
|
3711
|
+
type: "uint256",
|
|
3712
|
+
internalType: "uint256"
|
|
3713
|
+
},
|
|
3714
|
+
{
|
|
3715
|
+
name: "leverageBps",
|
|
3716
|
+
type: "uint32",
|
|
3717
|
+
internalType: "uint32"
|
|
3718
|
+
},
|
|
3719
|
+
{
|
|
3720
|
+
name: "notionalUsdcUnits",
|
|
3721
|
+
type: "uint256",
|
|
3722
|
+
internalType: "uint256"
|
|
3723
|
+
},
|
|
3724
|
+
{
|
|
3725
|
+
name: "originationFeeBps",
|
|
3726
|
+
type: "uint16",
|
|
3727
|
+
internalType: "uint16"
|
|
3728
|
+
},
|
|
3729
|
+
{
|
|
3730
|
+
name: "lifetimeFeeAprBps",
|
|
3731
|
+
type: "uint16",
|
|
3732
|
+
internalType: "uint16"
|
|
3733
|
+
},
|
|
3734
|
+
{
|
|
3735
|
+
name: "liquidationFeeBps",
|
|
3736
|
+
type: "uint16",
|
|
3737
|
+
internalType: "uint16"
|
|
3738
|
+
},
|
|
3739
|
+
{
|
|
3740
|
+
name: "venueFeeUsdcUnits",
|
|
3741
|
+
type: "uint256",
|
|
3742
|
+
internalType: "uint256"
|
|
3743
|
+
},
|
|
3744
|
+
{
|
|
3745
|
+
name: "marginUsdcUnits",
|
|
3746
|
+
type: "uint256",
|
|
3747
|
+
internalType: "uint256"
|
|
3748
|
+
},
|
|
3749
|
+
{
|
|
3750
|
+
name: "signature",
|
|
3751
|
+
type: "bytes",
|
|
3752
|
+
internalType: "bytes"
|
|
3753
|
+
},
|
|
3754
|
+
{
|
|
3755
|
+
name: "signatureExpiry",
|
|
3756
|
+
type: "uint256",
|
|
3757
|
+
internalType: "uint256"
|
|
3758
|
+
}
|
|
3759
|
+
],
|
|
3760
|
+
outputs: [],
|
|
3761
|
+
stateMutability: "nonpayable"
|
|
3762
|
+
},
|
|
3763
|
+
{
|
|
3764
|
+
type: "function",
|
|
3765
|
+
name: "createPositionWithMargin",
|
|
3766
|
+
inputs: [
|
|
3767
|
+
{
|
|
3768
|
+
name: "positionSeed",
|
|
3769
|
+
type: "bytes16",
|
|
3770
|
+
internalType: "bytes16"
|
|
3771
|
+
},
|
|
3772
|
+
{
|
|
3773
|
+
name: "marketId",
|
|
3774
|
+
type: "bytes32",
|
|
3775
|
+
internalType: "bytes32"
|
|
3776
|
+
},
|
|
3777
|
+
{
|
|
3778
|
+
name: "tokenId",
|
|
3779
|
+
type: "uint256",
|
|
3780
|
+
internalType: "uint256"
|
|
3781
|
+
},
|
|
3782
|
+
{
|
|
3783
|
+
name: "collateralUsdcUnits",
|
|
3784
|
+
type: "uint256",
|
|
3785
|
+
internalType: "uint256"
|
|
3786
|
+
},
|
|
3787
|
+
{
|
|
3788
|
+
name: "leverageBps",
|
|
3789
|
+
type: "uint32",
|
|
3790
|
+
internalType: "uint32"
|
|
3791
|
+
},
|
|
3792
|
+
{
|
|
3793
|
+
name: "notionalUsdcUnits",
|
|
3794
|
+
type: "uint256",
|
|
3795
|
+
internalType: "uint256"
|
|
3796
|
+
},
|
|
3797
|
+
{
|
|
3798
|
+
name: "originationFeeBps",
|
|
3799
|
+
type: "uint16",
|
|
3800
|
+
internalType: "uint16"
|
|
3801
|
+
},
|
|
3802
|
+
{
|
|
3803
|
+
name: "lifetimeFeeAprBps",
|
|
3804
|
+
type: "uint16",
|
|
3805
|
+
internalType: "uint16"
|
|
3806
|
+
},
|
|
3807
|
+
{
|
|
3808
|
+
name: "liquidationFeeBps",
|
|
3809
|
+
type: "uint16",
|
|
3810
|
+
internalType: "uint16"
|
|
3811
|
+
},
|
|
3812
|
+
{
|
|
3813
|
+
name: "venueFeeUsdcUnits",
|
|
3814
|
+
type: "uint256",
|
|
3815
|
+
internalType: "uint256"
|
|
3816
|
+
},
|
|
3817
|
+
{
|
|
3818
|
+
name: "marginUsdcUnits",
|
|
3819
|
+
type: "uint256",
|
|
3820
|
+
internalType: "uint256"
|
|
3821
|
+
},
|
|
3822
|
+
{
|
|
3823
|
+
name: "signature",
|
|
3824
|
+
type: "bytes",
|
|
3825
|
+
internalType: "bytes"
|
|
3826
|
+
},
|
|
3827
|
+
{
|
|
3828
|
+
name: "signatureExpiry",
|
|
3829
|
+
type: "uint256",
|
|
3830
|
+
internalType: "uint256"
|
|
3831
|
+
}
|
|
3832
|
+
],
|
|
3833
|
+
outputs: [],
|
|
3834
|
+
stateMutability: "nonpayable"
|
|
3835
|
+
},
|
|
3538
3836
|
{
|
|
3539
3837
|
type: "function",
|
|
3540
3838
|
name: "disableEmergencyOnlyMode",
|
|
@@ -4268,6 +4566,92 @@ var vault_abi_default = {
|
|
|
4268
4566
|
outputs: [],
|
|
4269
4567
|
stateMutability: "nonpayable"
|
|
4270
4568
|
},
|
|
4569
|
+
{
|
|
4570
|
+
type: "function",
|
|
4571
|
+
name: "finalizeSettleWithReturn",
|
|
4572
|
+
inputs: [
|
|
4573
|
+
{
|
|
4574
|
+
name: "positionKey",
|
|
4575
|
+
type: "bytes32",
|
|
4576
|
+
internalType: "bytes32"
|
|
4577
|
+
},
|
|
4578
|
+
{
|
|
4579
|
+
name: "saleReceivedUsdcUnits",
|
|
4580
|
+
type: "uint256",
|
|
4581
|
+
internalType: "uint256"
|
|
4582
|
+
},
|
|
4583
|
+
{
|
|
4584
|
+
name: "marketOutcome",
|
|
4585
|
+
type: "uint8",
|
|
4586
|
+
internalType: "uint8"
|
|
4587
|
+
},
|
|
4588
|
+
{
|
|
4589
|
+
name: "settledInFavor",
|
|
4590
|
+
type: "bool",
|
|
4591
|
+
internalType: "bool"
|
|
4592
|
+
},
|
|
4593
|
+
{
|
|
4594
|
+
name: "returnedTokenUnits",
|
|
4595
|
+
type: "uint256",
|
|
4596
|
+
internalType: "uint256"
|
|
4597
|
+
},
|
|
4598
|
+
{
|
|
4599
|
+
name: "signature",
|
|
4600
|
+
type: "bytes",
|
|
4601
|
+
internalType: "bytes"
|
|
4602
|
+
},
|
|
4603
|
+
{
|
|
4604
|
+
name: "signatureExpiry",
|
|
4605
|
+
type: "uint256",
|
|
4606
|
+
internalType: "uint256"
|
|
4607
|
+
}
|
|
4608
|
+
],
|
|
4609
|
+
outputs: [],
|
|
4610
|
+
stateMutability: "nonpayable"
|
|
4611
|
+
},
|
|
4612
|
+
{
|
|
4613
|
+
type: "function",
|
|
4614
|
+
name: "finalizeSettleWithReturnPushFunded",
|
|
4615
|
+
inputs: [
|
|
4616
|
+
{
|
|
4617
|
+
name: "positionKey",
|
|
4618
|
+
type: "bytes32",
|
|
4619
|
+
internalType: "bytes32"
|
|
4620
|
+
},
|
|
4621
|
+
{
|
|
4622
|
+
name: "saleReceivedUsdcUnits",
|
|
4623
|
+
type: "uint256",
|
|
4624
|
+
internalType: "uint256"
|
|
4625
|
+
},
|
|
4626
|
+
{
|
|
4627
|
+
name: "marketOutcome",
|
|
4628
|
+
type: "uint8",
|
|
4629
|
+
internalType: "uint8"
|
|
4630
|
+
},
|
|
4631
|
+
{
|
|
4632
|
+
name: "settledInFavor",
|
|
4633
|
+
type: "bool",
|
|
4634
|
+
internalType: "bool"
|
|
4635
|
+
},
|
|
4636
|
+
{
|
|
4637
|
+
name: "returnedTokenUnits",
|
|
4638
|
+
type: "uint256",
|
|
4639
|
+
internalType: "uint256"
|
|
4640
|
+
},
|
|
4641
|
+
{
|
|
4642
|
+
name: "signature",
|
|
4643
|
+
type: "bytes",
|
|
4644
|
+
internalType: "bytes"
|
|
4645
|
+
},
|
|
4646
|
+
{
|
|
4647
|
+
name: "signatureExpiry",
|
|
4648
|
+
type: "uint256",
|
|
4649
|
+
internalType: "uint256"
|
|
4650
|
+
}
|
|
4651
|
+
],
|
|
4652
|
+
outputs: [],
|
|
4653
|
+
stateMutability: "nonpayable"
|
|
4654
|
+
},
|
|
4271
4655
|
{
|
|
4272
4656
|
type: "function",
|
|
4273
4657
|
name: "flagUnwindDuringPartialClose",
|
|
@@ -4873,6 +5257,11 @@ var vault_abi_default = {
|
|
|
4873
5257
|
name: "originalPositionTokenUnits",
|
|
4874
5258
|
type: "uint256",
|
|
4875
5259
|
internalType: "uint256"
|
|
5260
|
+
},
|
|
5261
|
+
{
|
|
5262
|
+
name: "lockedMarginUsdcUnits",
|
|
5263
|
+
type: "uint256",
|
|
5264
|
+
internalType: "uint256"
|
|
4876
5265
|
}
|
|
4877
5266
|
],
|
|
4878
5267
|
stateMutability: "view"
|
|
@@ -5344,6 +5733,19 @@ var vault_abi_default = {
|
|
|
5344
5733
|
],
|
|
5345
5734
|
stateMutability: "view"
|
|
5346
5735
|
},
|
|
5736
|
+
{
|
|
5737
|
+
type: "function",
|
|
5738
|
+
name: "totalLockedMarginUsdcUnits",
|
|
5739
|
+
inputs: [],
|
|
5740
|
+
outputs: [
|
|
5741
|
+
{
|
|
5742
|
+
name: "",
|
|
5743
|
+
type: "uint256",
|
|
5744
|
+
internalType: "uint256"
|
|
5745
|
+
}
|
|
5746
|
+
],
|
|
5747
|
+
stateMutability: "view"
|
|
5748
|
+
},
|
|
5347
5749
|
{
|
|
5348
5750
|
type: "function",
|
|
5349
5751
|
name: "totalProtocolBorrowedUsdcUnits",
|
|
@@ -5598,7 +6000,7 @@ var _viem = require('viem');
|
|
|
5598
6000
|
function toHex(value) {
|
|
5599
6001
|
if (!_viem.isHex.call(void 0, value)) {
|
|
5600
6002
|
const HEX_PREVIEW_LENGTH = 10;
|
|
5601
|
-
throw new (0,
|
|
6003
|
+
throw new (0, _chunkERM4WP6Dcjs.DimesError)(
|
|
5602
6004
|
"invalid_hex",
|
|
5603
6005
|
`Expected hex string starting with 0x, got: ${value.slice(0, HEX_PREVIEW_LENGTH)}`
|
|
5604
6006
|
);
|
|
@@ -5607,31 +6009,49 @@ function toHex(value) {
|
|
|
5607
6009
|
}
|
|
5608
6010
|
function toAddress(value) {
|
|
5609
6011
|
if (!_viem.isAddress.call(void 0, value)) {
|
|
5610
|
-
throw new (0,
|
|
6012
|
+
throw new (0, _chunkERM4WP6Dcjs.DimesError)("invalid_address", `Invalid EVM address: ${value}`);
|
|
5611
6013
|
}
|
|
5612
6014
|
return _viem.getAddress.call(void 0, value);
|
|
5613
6015
|
}
|
|
5614
6016
|
|
|
6017
|
+
// src/contract/risk-mode.ts
|
|
6018
|
+
function isCommittedQuote(quote) {
|
|
6019
|
+
return quote.riskMode === "committed";
|
|
6020
|
+
}
|
|
6021
|
+
|
|
5615
6022
|
// src/contract/build-tx.ts
|
|
5616
6023
|
function buildCreatePositionTx(quote) {
|
|
6024
|
+
const address = toAddress(quote.polygonVaultContractAddress);
|
|
6025
|
+
const commonArgs = [
|
|
6026
|
+
toHex(quote.positionSeedHex),
|
|
6027
|
+
toHex(quote.polymarketMarketId),
|
|
6028
|
+
BigInt(quote.polymarketTokenId),
|
|
6029
|
+
BigInt(quote.collateralUsdcUnits),
|
|
6030
|
+
quote.leverageBps,
|
|
6031
|
+
BigInt(quote.notionalUsdcUnits),
|
|
6032
|
+
quote.originationFeeBps,
|
|
6033
|
+
quote.lifetimeFeeAprBps,
|
|
6034
|
+
quote.liquidationFeeBps,
|
|
6035
|
+
BigInt(quote.expectedOpenTradingFeeUsdcUnits)
|
|
6036
|
+
];
|
|
6037
|
+
if (isCommittedQuote(quote)) {
|
|
6038
|
+
return {
|
|
6039
|
+
address,
|
|
6040
|
+
abi: vaultAbi,
|
|
6041
|
+
functionName: "createPositionWithMargin",
|
|
6042
|
+
args: [
|
|
6043
|
+
...commonArgs,
|
|
6044
|
+
BigInt(quote.marginUsdcUnits),
|
|
6045
|
+
toHex(quote.contractSignature),
|
|
6046
|
+
BigInt(quote.signatureExpiry)
|
|
6047
|
+
]
|
|
6048
|
+
};
|
|
6049
|
+
}
|
|
5617
6050
|
return {
|
|
5618
|
-
address
|
|
6051
|
+
address,
|
|
5619
6052
|
abi: vaultAbi,
|
|
5620
6053
|
functionName: "createPosition",
|
|
5621
|
-
args: [
|
|
5622
|
-
toHex(quote.positionSeedHex),
|
|
5623
|
-
toHex(quote.polymarketMarketId),
|
|
5624
|
-
BigInt(quote.polymarketTokenId),
|
|
5625
|
-
BigInt(quote.collateralUsdcUnits),
|
|
5626
|
-
quote.leverageBps,
|
|
5627
|
-
BigInt(quote.notionalUsdcUnits),
|
|
5628
|
-
quote.originationFeeBps,
|
|
5629
|
-
quote.lifetimeFeeAprBps,
|
|
5630
|
-
quote.liquidationFeeBps,
|
|
5631
|
-
BigInt(quote.expectedOpenTradingFeeUsdcUnits),
|
|
5632
|
-
toHex(quote.contractSignature),
|
|
5633
|
-
BigInt(quote.signatureExpiry)
|
|
5634
|
-
]
|
|
6054
|
+
args: [...commonArgs, toHex(quote.contractSignature), BigInt(quote.signatureExpiry)]
|
|
5635
6055
|
};
|
|
5636
6056
|
}
|
|
5637
6057
|
function buildApproveTx(usdcAddress, spender, amount) {
|
|
@@ -5707,6 +6127,29 @@ var createPositionPushFundedAbi = [
|
|
|
5707
6127
|
outputs: []
|
|
5708
6128
|
}
|
|
5709
6129
|
];
|
|
6130
|
+
var createPositionPushFundedWithMarginAbi = [
|
|
6131
|
+
{
|
|
6132
|
+
type: "function",
|
|
6133
|
+
name: "createPositionPushFundedWithMargin",
|
|
6134
|
+
stateMutability: "nonpayable",
|
|
6135
|
+
inputs: [
|
|
6136
|
+
{ name: "positionSeed", type: "bytes16" },
|
|
6137
|
+
{ name: "marketId", type: "bytes32" },
|
|
6138
|
+
{ name: "tokenId", type: "uint256" },
|
|
6139
|
+
{ name: "collateralUsdcUnits", type: "uint256" },
|
|
6140
|
+
{ name: "leverageBps", type: "uint32" },
|
|
6141
|
+
{ name: "notionalUsdcUnits", type: "uint256" },
|
|
6142
|
+
{ name: "originationFeeBps", type: "uint16" },
|
|
6143
|
+
{ name: "lifetimeFeeAprBps", type: "uint16" },
|
|
6144
|
+
{ name: "liquidationFeeBps", type: "uint16" },
|
|
6145
|
+
{ name: "venueFeeUsdcUnits", type: "uint256" },
|
|
6146
|
+
{ name: "marginUsdcUnits", type: "uint256" },
|
|
6147
|
+
{ name: "signature", type: "bytes" },
|
|
6148
|
+
{ name: "signatureExpiry", type: "uint256" }
|
|
6149
|
+
],
|
|
6150
|
+
outputs: []
|
|
6151
|
+
}
|
|
6152
|
+
];
|
|
5710
6153
|
var erc20TransferAbi = [
|
|
5711
6154
|
{
|
|
5712
6155
|
type: "function",
|
|
@@ -5719,6 +6162,37 @@ var erc20TransferAbi = [
|
|
|
5719
6162
|
outputs: [{ name: "", type: "bool" }]
|
|
5720
6163
|
}
|
|
5721
6164
|
];
|
|
6165
|
+
function buildPushFundedCreateData(quote) {
|
|
6166
|
+
const commonArgs = [
|
|
6167
|
+
toHex(quote.positionSeedHex),
|
|
6168
|
+
toHex(quote.polymarketMarketId),
|
|
6169
|
+
BigInt(quote.polymarketTokenId),
|
|
6170
|
+
BigInt(quote.collateralUsdcUnits),
|
|
6171
|
+
quote.leverageBps,
|
|
6172
|
+
BigInt(quote.notionalUsdcUnits),
|
|
6173
|
+
quote.originationFeeBps,
|
|
6174
|
+
quote.lifetimeFeeAprBps,
|
|
6175
|
+
quote.liquidationFeeBps,
|
|
6176
|
+
BigInt(quote.expectedOpenTradingFeeUsdcUnits)
|
|
6177
|
+
];
|
|
6178
|
+
if (isCommittedQuote(quote)) {
|
|
6179
|
+
return _viem.encodeFunctionData.call(void 0, {
|
|
6180
|
+
abi: createPositionPushFundedWithMarginAbi,
|
|
6181
|
+
functionName: "createPositionPushFundedWithMargin",
|
|
6182
|
+
args: [
|
|
6183
|
+
...commonArgs,
|
|
6184
|
+
BigInt(quote.marginUsdcUnits),
|
|
6185
|
+
toHex(quote.contractSignature),
|
|
6186
|
+
BigInt(quote.signatureExpiry)
|
|
6187
|
+
]
|
|
6188
|
+
});
|
|
6189
|
+
}
|
|
6190
|
+
return _viem.encodeFunctionData.call(void 0, {
|
|
6191
|
+
abi: createPositionPushFundedAbi,
|
|
6192
|
+
functionName: "createPositionPushFunded",
|
|
6193
|
+
args: [...commonArgs, toHex(quote.contractSignature), BigInt(quote.signatureExpiry)]
|
|
6194
|
+
});
|
|
6195
|
+
}
|
|
5722
6196
|
function buildPushFundedCreateCalls(quote, pUsdAddress) {
|
|
5723
6197
|
const vaultAddress = toAddress(quote.polygonVaultContractAddress);
|
|
5724
6198
|
const totalUserAmountUsdcUnits = BigInt(quote.totalUserAmountUsdcUnits);
|
|
@@ -5732,24 +6206,7 @@ function buildPushFundedCreateCalls(quote, pUsdAddress) {
|
|
|
5732
6206
|
functionName: "transfer",
|
|
5733
6207
|
args: [vaultAddress, totalUserAmountUsdcUnits]
|
|
5734
6208
|
});
|
|
5735
|
-
const createPositionData =
|
|
5736
|
-
abi: createPositionPushFundedAbi,
|
|
5737
|
-
functionName: "createPositionPushFunded",
|
|
5738
|
-
args: [
|
|
5739
|
-
toHex(quote.positionSeedHex),
|
|
5740
|
-
toHex(quote.polymarketMarketId),
|
|
5741
|
-
BigInt(quote.polymarketTokenId),
|
|
5742
|
-
BigInt(quote.collateralUsdcUnits),
|
|
5743
|
-
quote.leverageBps,
|
|
5744
|
-
BigInt(quote.notionalUsdcUnits),
|
|
5745
|
-
quote.originationFeeBps,
|
|
5746
|
-
quote.lifetimeFeeAprBps,
|
|
5747
|
-
quote.liquidationFeeBps,
|
|
5748
|
-
BigInt(quote.expectedOpenTradingFeeUsdcUnits),
|
|
5749
|
-
toHex(quote.contractSignature),
|
|
5750
|
-
BigInt(quote.signatureExpiry)
|
|
5751
|
-
]
|
|
5752
|
-
});
|
|
6209
|
+
const createPositionData = buildPushFundedCreateData(quote);
|
|
5753
6210
|
return [
|
|
5754
6211
|
{ target: vaultAddress, value: 0n, data: reserveDepositData },
|
|
5755
6212
|
{ target: toAddress(pUsdAddress), value: 0n, data: transferData },
|
|
@@ -5868,30 +6325,62 @@ var createPositionTypes = {
|
|
|
5868
6325
|
{ name: "signatureExpiry", type: "uint256" }
|
|
5869
6326
|
]
|
|
5870
6327
|
};
|
|
6328
|
+
var createPositionWithMarginTypes = {
|
|
6329
|
+
CreatePositionWithMargin: [
|
|
6330
|
+
{ name: "positionSeed", type: "bytes16" },
|
|
6331
|
+
{ name: "user", type: "address" },
|
|
6332
|
+
{ name: "marketId", type: "bytes32" },
|
|
6333
|
+
{ name: "tokenId", type: "uint256" },
|
|
6334
|
+
{ name: "collateralUsdcUnits", type: "uint256" },
|
|
6335
|
+
{ name: "leverageBps", type: "uint32" },
|
|
6336
|
+
{ name: "notionalUsdcUnits", type: "uint256" },
|
|
6337
|
+
{ name: "originationFeeBps", type: "uint16" },
|
|
6338
|
+
{ name: "lifetimeFeeAprBps", type: "uint16" },
|
|
6339
|
+
{ name: "liquidationFeeBps", type: "uint16" },
|
|
6340
|
+
{ name: "venueFeeUsdcUnits", type: "uint256" },
|
|
6341
|
+
{ name: "marginUsdcUnits", type: "uint256" },
|
|
6342
|
+
{ name: "signatureExpiry", type: "uint256" }
|
|
6343
|
+
]
|
|
6344
|
+
};
|
|
6345
|
+
function buildDomain(quote) {
|
|
6346
|
+
return {
|
|
6347
|
+
name: "LeveragedPredictionVaultV1",
|
|
6348
|
+
version: "1",
|
|
6349
|
+
chainId: Number(quote.evmChainId),
|
|
6350
|
+
verifyingContract: toAddress(quote.polygonVaultContractAddress)
|
|
6351
|
+
};
|
|
6352
|
+
}
|
|
6353
|
+
function buildMessage(quote, userAddress) {
|
|
6354
|
+
return {
|
|
6355
|
+
positionSeed: toHex(quote.positionSeedHex),
|
|
6356
|
+
user: userAddress,
|
|
6357
|
+
marketId: toHex(quote.polymarketMarketId),
|
|
6358
|
+
tokenId: BigInt(quote.polymarketTokenId),
|
|
6359
|
+
collateralUsdcUnits: BigInt(quote.collateralUsdcUnits),
|
|
6360
|
+
leverageBps: quote.leverageBps,
|
|
6361
|
+
notionalUsdcUnits: BigInt(quote.notionalUsdcUnits),
|
|
6362
|
+
originationFeeBps: quote.originationFeeBps,
|
|
6363
|
+
lifetimeFeeAprBps: quote.lifetimeFeeAprBps,
|
|
6364
|
+
liquidationFeeBps: quote.liquidationFeeBps,
|
|
6365
|
+
venueFeeUsdcUnits: BigInt(quote.expectedOpenTradingFeeUsdcUnits),
|
|
6366
|
+
signatureExpiry: BigInt(quote.signatureExpiry)
|
|
6367
|
+
};
|
|
6368
|
+
}
|
|
5871
6369
|
async function recoverCreatePositionSigner(quote, userAddress) {
|
|
6370
|
+
if (isCommittedQuote(quote)) {
|
|
6371
|
+
return _viem.recoverTypedDataAddress.call(void 0, {
|
|
6372
|
+
domain: buildDomain(quote),
|
|
6373
|
+
types: createPositionWithMarginTypes,
|
|
6374
|
+
primaryType: "CreatePositionWithMargin",
|
|
6375
|
+
message: { ...buildMessage(quote, userAddress), marginUsdcUnits: BigInt(quote.marginUsdcUnits) },
|
|
6376
|
+
signature: toHex(quote.contractSignature)
|
|
6377
|
+
});
|
|
6378
|
+
}
|
|
5872
6379
|
return _viem.recoverTypedDataAddress.call(void 0, {
|
|
5873
|
-
domain:
|
|
5874
|
-
name: "LeveragedPredictionVaultV1",
|
|
5875
|
-
version: "1",
|
|
5876
|
-
chainId: Number(quote.evmChainId),
|
|
5877
|
-
verifyingContract: toAddress(quote.polygonVaultContractAddress)
|
|
5878
|
-
},
|
|
6380
|
+
domain: buildDomain(quote),
|
|
5879
6381
|
types: createPositionTypes,
|
|
5880
6382
|
primaryType: "CreatePosition",
|
|
5881
|
-
message:
|
|
5882
|
-
positionSeed: toHex(quote.positionSeedHex),
|
|
5883
|
-
user: userAddress,
|
|
5884
|
-
marketId: toHex(quote.polymarketMarketId),
|
|
5885
|
-
tokenId: BigInt(quote.polymarketTokenId),
|
|
5886
|
-
collateralUsdcUnits: BigInt(quote.collateralUsdcUnits),
|
|
5887
|
-
leverageBps: quote.leverageBps,
|
|
5888
|
-
notionalUsdcUnits: BigInt(quote.notionalUsdcUnits),
|
|
5889
|
-
originationFeeBps: quote.originationFeeBps,
|
|
5890
|
-
lifetimeFeeAprBps: quote.lifetimeFeeAprBps,
|
|
5891
|
-
liquidationFeeBps: quote.liquidationFeeBps,
|
|
5892
|
-
venueFeeUsdcUnits: BigInt(quote.expectedOpenTradingFeeUsdcUnits),
|
|
5893
|
-
signatureExpiry: BigInt(quote.signatureExpiry)
|
|
5894
|
-
},
|
|
6383
|
+
message: buildMessage(quote, userAddress),
|
|
5895
6384
|
signature: toHex(quote.contractSignature)
|
|
5896
6385
|
});
|
|
5897
6386
|
}
|
|
@@ -5902,7 +6391,7 @@ async function assertQuoteSigner(quote, userAddress, expectedSigner) {
|
|
|
5902
6391
|
const recoveredSigner = await recoverCreatePositionSigner(quote, userAddress);
|
|
5903
6392
|
const expected = _viem.getAddress.call(void 0, expectedSigner);
|
|
5904
6393
|
if (recoveredSigner !== expected) {
|
|
5905
|
-
throw new (0,
|
|
6394
|
+
throw new (0, _chunkERM4WP6Dcjs.DimesContractError)(
|
|
5906
6395
|
"invalid_signer",
|
|
5907
6396
|
`Recovered signer ${recoveredSigner} does not match expected authority ${expected}`
|
|
5908
6397
|
);
|
|
@@ -6025,12 +6514,12 @@ function firstLine(s) {
|
|
|
6025
6514
|
}
|
|
6026
6515
|
function formatContractError(err) {
|
|
6027
6516
|
if (!err) {
|
|
6028
|
-
return new (0,
|
|
6517
|
+
return new (0, _chunkERM4WP6Dcjs.DimesContractError)("unknown", "Transaction failed.");
|
|
6029
6518
|
}
|
|
6030
6519
|
if (err instanceof _viem.BaseError) {
|
|
6031
6520
|
const rejected = err.walk((e) => e instanceof _viem.UserRejectedRequestError);
|
|
6032
6521
|
if (rejected) {
|
|
6033
|
-
return new (0,
|
|
6522
|
+
return new (0, _chunkERM4WP6Dcjs.DimesContractError)("UserRejected", "Transaction rejected in wallet.");
|
|
6034
6523
|
}
|
|
6035
6524
|
const reverted = err.walk(
|
|
6036
6525
|
(e) => e instanceof _viem.ContractFunctionRevertedError
|
|
@@ -6041,12 +6530,12 @@ function formatContractError(err) {
|
|
|
6041
6530
|
if (errorName) {
|
|
6042
6531
|
const fmt = friendlyByErrorName[errorName];
|
|
6043
6532
|
const message = fmt ? fmt(args) : humanizeName(errorName);
|
|
6044
|
-
return new (0,
|
|
6533
|
+
return new (0, _chunkERM4WP6Dcjs.DimesContractError)(errorName, message);
|
|
6045
6534
|
}
|
|
6046
6535
|
const raw = reverted.raw;
|
|
6047
6536
|
const selector = raw && raw.length >= HEX_SELECTOR_LENGTH ? raw.slice(0, HEX_SELECTOR_LENGTH) : void 0;
|
|
6048
6537
|
const selectorMessage = selector ? friendlyBySelector[selector] : void 0;
|
|
6049
|
-
return new (0,
|
|
6538
|
+
return new (0, _chunkERM4WP6Dcjs.DimesContractError)(
|
|
6050
6539
|
_nullishCoalesce(selector, () => ( "unknown_revert")),
|
|
6051
6540
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
6052
6541
|
_nullishCoalesce(_nullishCoalesce(selectorMessage, () => ( reverted.shortMessage)), () => ( "Contract reverted."))
|
|
@@ -6054,17 +6543,17 @@ function formatContractError(err) {
|
|
|
6054
6543
|
}
|
|
6055
6544
|
const exec = err.walk((e) => e instanceof _viem.ContractFunctionExecutionError);
|
|
6056
6545
|
if (_optionalChain([exec, 'optionalAccess', _5 => _5.shortMessage])) {
|
|
6057
|
-
return new (0,
|
|
6546
|
+
return new (0, _chunkERM4WP6Dcjs.DimesContractError)("execution_error", firstLine(exec.shortMessage));
|
|
6058
6547
|
}
|
|
6059
6548
|
if (err.shortMessage) {
|
|
6060
|
-
return new (0,
|
|
6549
|
+
return new (0, _chunkERM4WP6Dcjs.DimesContractError)("base_error", firstLine(err.shortMessage));
|
|
6061
6550
|
}
|
|
6062
|
-
return new (0,
|
|
6551
|
+
return new (0, _chunkERM4WP6Dcjs.DimesContractError)("base_error", firstLine(err.message));
|
|
6063
6552
|
}
|
|
6064
6553
|
if (err instanceof Error) {
|
|
6065
|
-
return new (0,
|
|
6554
|
+
return new (0, _chunkERM4WP6Dcjs.DimesContractError)("error", firstLine(err.message));
|
|
6066
6555
|
}
|
|
6067
|
-
return new (0,
|
|
6556
|
+
return new (0, _chunkERM4WP6Dcjs.DimesContractError)("unknown", "Transaction failed.");
|
|
6068
6557
|
}
|
|
6069
6558
|
|
|
6070
6559
|
|
|
@@ -6094,5 +6583,6 @@ function formatContractError(err) {
|
|
|
6094
6583
|
|
|
6095
6584
|
|
|
6096
6585
|
|
|
6097
|
-
|
|
6586
|
+
|
|
6587
|
+
exports.assertQuoteSigner = assertQuoteSigner; exports.buildApproveTx = buildApproveTx; exports.buildCreatePositionTx = buildCreatePositionTx; exports.buildDepositWalletBatch = buildDepositWalletBatch; exports.buildPushFundedCreateCalls = buildPushFundedCreateCalls; exports.buildRelayerAuthHeaders = buildRelayerAuthHeaders; exports.buildRelayerSubmitPayload = buildRelayerSubmitPayload; exports.buildRequestCloseCalls = buildRequestCloseCalls; exports.buildRequestCloseTx = buildRequestCloseTx; exports.buildRequestPartialCloseCalls = buildRequestPartialCloseCalls; exports.buildRequestPartialCloseTx = buildRequestPartialCloseTx; exports.buildVerifiedCreatePositionTx = buildVerifiedCreatePositionTx; exports.buildVerifiedPushFundedCreateCalls = buildVerifiedPushFundedCreateCalls; exports.depositWalletBatchTypes = depositWalletBatchTypes; exports.depositWalletFactoryAddress = depositWalletFactoryAddress; exports.erc20Abi = erc20Abi; exports.formatContractError = formatContractError; exports.getCachedContractInfo = getCachedContractInfo; exports.getDepositWalletBatchTypedData = getDepositWalletBatchTypedData; exports.isCommittedQuote = isCommittedQuote; exports.polymarketRelayerBaseUrl = polymarketRelayerBaseUrl; exports.recoverCreatePositionSigner = recoverCreatePositionSigner; exports.resolveExpectedSigner = resolveExpectedSigner; exports.toAddress = toAddress; exports.toHex = toHex; exports.vaultAbi = vaultAbi; exports.verifyOfferSignature = verifyOfferSignature; exports.verifyQuoteSignature = verifyQuoteSignature;
|
|
6098
6588
|
//# sourceMappingURL=index.cjs.map
|