@dimes-dot-fi/sdk 2.4.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-KNGEIWFR.cjs → chunk-ERM4WP6D.cjs} +8 -4
- package/dist/chunk-ERM4WP6D.cjs.map +1 -0
- package/dist/{chunk-LXZAXWLO.mjs → chunk-GA7ZBK6W.mjs} +8 -4
- package/dist/chunk-GA7ZBK6W.mjs.map +1 -0
- package/dist/{chunk-Q34TMZ5J.mjs → chunk-HJ5EVO5A.mjs} +11 -6
- package/dist/chunk-HJ5EVO5A.mjs.map +1 -0
- package/dist/{chunk-IZI65LZF.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-IZI65LZF.cjs.map +0 -1
- package/dist/chunk-KNGEIWFR.cjs.map +0 -1
- package/dist/chunk-LXZAXWLO.mjs.map +0 -1
- package/dist/chunk-Q34TMZ5J.mjs.map +0 -1
package/dist/contract/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DimesContractError,
|
|
3
3
|
DimesError
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-GA7ZBK6W.mjs";
|
|
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",
|
|
@@ -5612,26 +6014,44 @@ function toAddress(value) {
|
|
|
5612
6014
|
return getAddress(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 encodeFunctionData({
|
|
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 encodeFunctionData({
|
|
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 recoverTypedDataAddress({
|
|
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 recoverTypedDataAddress({
|
|
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
|
}
|
|
@@ -6086,6 +6575,7 @@ export {
|
|
|
6086
6575
|
formatContractError,
|
|
6087
6576
|
getCachedContractInfo,
|
|
6088
6577
|
getDepositWalletBatchTypedData,
|
|
6578
|
+
isCommittedQuote,
|
|
6089
6579
|
polymarketRelayerBaseUrl,
|
|
6090
6580
|
recoverCreatePositionSigner,
|
|
6091
6581
|
resolveExpectedSigner,
|