-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(algebra-integral): add mutex to protect timepoint storage (#633)
- Loading branch information
1 parent
5bff0b6
commit 722109c
Showing
27 changed files
with
4,131 additions
and
814 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package algebrav1 | ||
|
||
import ( | ||
"bytes" | ||
|
||
"github.com/ethereum/go-ethereum/accounts/abi" | ||
) | ||
|
||
var ( | ||
algebraV1PoolABI abi.ABI | ||
algebraV1DirFeePoolABI abi.ABI | ||
algebraV1DataStorageOperatorAPI abi.ABI | ||
algebraV1DirFeeDataStorageOperatorAPI abi.ABI | ||
erc20ABI abi.ABI | ||
ticklensABI abi.ABI | ||
) | ||
|
||
func init() { | ||
builder := []struct { | ||
ABI *abi.ABI | ||
data []byte | ||
}{ | ||
{&algebraV1PoolABI, algebraV1PoolJson}, | ||
{&algebraV1DirFeePoolABI, algebraV1DirFeePoolJson}, | ||
{&algebraV1DataStorageOperatorAPI, algebraV1DataStorageOperatorJson}, | ||
{&algebraV1DirFeeDataStorageOperatorAPI, algebraV1DirFeeDataStorageOperatorJson}, | ||
{&erc20ABI, erc20Json}, | ||
{&ticklensABI, ticklensJson}, | ||
} | ||
|
||
for _, b := range builder { | ||
var err error | ||
*b.ABI, err = abi.JSON(bytes.NewReader(b.data)) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} | ||
} |
181 changes: 181 additions & 0 deletions
181
pkg/liquidity-source/algebra/v1/abis/AlgebraV1DataStorageOperator.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
[ | ||
{ "inputs": [{ "internalType": "address", "name": "_pool", "type": "address" }], "stateMutability": "nonpayable", "type": "constructor" }, | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"components": [ | ||
{ "internalType": "uint16", "name": "alpha1", "type": "uint16" }, | ||
{ "internalType": "uint16", "name": "alpha2", "type": "uint16" }, | ||
{ "internalType": "uint32", "name": "beta1", "type": "uint32" }, | ||
{ "internalType": "uint32", "name": "beta2", "type": "uint32" }, | ||
{ "internalType": "uint16", "name": "gamma1", "type": "uint16" }, | ||
{ "internalType": "uint16", "name": "gamma2", "type": "uint16" }, | ||
{ "internalType": "uint32", "name": "volumeBeta", "type": "uint32" }, | ||
{ "internalType": "uint16", "name": "volumeGamma", "type": "uint16" }, | ||
{ "internalType": "uint16", "name": "baseFee", "type": "uint16" } | ||
], | ||
"indexed": false, | ||
"internalType": "struct AdaptiveFee.Configuration", | ||
"name": "feeConfig", | ||
"type": "tuple" | ||
} | ||
], | ||
"name": "FeeConfiguration", | ||
"type": "event" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ "internalType": "uint128", "name": "liquidity", "type": "uint128" }, | ||
{ "internalType": "int256", "name": "amount0", "type": "int256" }, | ||
{ "internalType": "int256", "name": "amount1", "type": "int256" } | ||
], | ||
"name": "calculateVolumePerLiquidity", | ||
"outputs": [{ "internalType": "uint128", "name": "volumePerLiquidity", "type": "uint128" }], | ||
"stateMutability": "pure", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"components": [ | ||
{ "internalType": "uint16", "name": "alpha1", "type": "uint16" }, | ||
{ "internalType": "uint16", "name": "alpha2", "type": "uint16" }, | ||
{ "internalType": "uint32", "name": "beta1", "type": "uint32" }, | ||
{ "internalType": "uint32", "name": "beta2", "type": "uint32" }, | ||
{ "internalType": "uint16", "name": "gamma1", "type": "uint16" }, | ||
{ "internalType": "uint16", "name": "gamma2", "type": "uint16" }, | ||
{ "internalType": "uint32", "name": "volumeBeta", "type": "uint32" }, | ||
{ "internalType": "uint16", "name": "volumeGamma", "type": "uint16" }, | ||
{ "internalType": "uint16", "name": "baseFee", "type": "uint16" } | ||
], | ||
"internalType": "struct AdaptiveFee.Configuration", | ||
"name": "_feeConfig", | ||
"type": "tuple" | ||
} | ||
], | ||
"name": "changeFeeConfiguration", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "feeConfig", | ||
"outputs": [ | ||
{ "internalType": "uint16", "name": "alpha1", "type": "uint16" }, | ||
{ "internalType": "uint16", "name": "alpha2", "type": "uint16" }, | ||
{ "internalType": "uint32", "name": "beta1", "type": "uint32" }, | ||
{ "internalType": "uint32", "name": "beta2", "type": "uint32" }, | ||
{ "internalType": "uint16", "name": "gamma1", "type": "uint16" }, | ||
{ "internalType": "uint16", "name": "gamma2", "type": "uint16" }, | ||
{ "internalType": "uint32", "name": "volumeBeta", "type": "uint32" }, | ||
{ "internalType": "uint16", "name": "volumeGamma", "type": "uint16" }, | ||
{ "internalType": "uint16", "name": "baseFee", "type": "uint16" } | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ "internalType": "uint32", "name": "time", "type": "uint32" }, | ||
{ "internalType": "int24", "name": "tick", "type": "int24" }, | ||
{ "internalType": "uint16", "name": "index", "type": "uint16" }, | ||
{ "internalType": "uint128", "name": "liquidity", "type": "uint128" } | ||
], | ||
"name": "getAverages", | ||
"outputs": [ | ||
{ "internalType": "uint112", "name": "TWVolatilityAverage", "type": "uint112" }, | ||
{ "internalType": "uint256", "name": "TWVolumePerLiqAverage", "type": "uint256" } | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ "internalType": "uint32", "name": "_time", "type": "uint32" }, | ||
{ "internalType": "int24", "name": "_tick", "type": "int24" }, | ||
{ "internalType": "uint16", "name": "_index", "type": "uint16" }, | ||
{ "internalType": "uint128", "name": "_liquidity", "type": "uint128" } | ||
], | ||
"name": "getFee", | ||
"outputs": [{ "internalType": "uint16", "name": "fee", "type": "uint16" }], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ "internalType": "uint32", "name": "time", "type": "uint32" }, | ||
{ "internalType": "uint32", "name": "secondsAgo", "type": "uint32" }, | ||
{ "internalType": "int24", "name": "tick", "type": "int24" }, | ||
{ "internalType": "uint16", "name": "index", "type": "uint16" }, | ||
{ "internalType": "uint128", "name": "liquidity", "type": "uint128" } | ||
], | ||
"name": "getSingleTimepoint", | ||
"outputs": [ | ||
{ "internalType": "int56", "name": "tickCumulative", "type": "int56" }, | ||
{ "internalType": "uint160", "name": "secondsPerLiquidityCumulative", "type": "uint160" }, | ||
{ "internalType": "uint112", "name": "volatilityCumulative", "type": "uint112" }, | ||
{ "internalType": "uint256", "name": "volumePerAvgLiquidity", "type": "uint256" } | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ "internalType": "uint32", "name": "time", "type": "uint32" }, | ||
{ "internalType": "uint32[]", "name": "secondsAgos", "type": "uint32[]" }, | ||
{ "internalType": "int24", "name": "tick", "type": "int24" }, | ||
{ "internalType": "uint16", "name": "index", "type": "uint16" }, | ||
{ "internalType": "uint128", "name": "liquidity", "type": "uint128" } | ||
], | ||
"name": "getTimepoints", | ||
"outputs": [ | ||
{ "internalType": "int56[]", "name": "tickCumulatives", "type": "int56[]" }, | ||
{ "internalType": "uint160[]", "name": "secondsPerLiquidityCumulatives", "type": "uint160[]" }, | ||
{ "internalType": "uint112[]", "name": "volatilityCumulatives", "type": "uint112[]" }, | ||
{ "internalType": "uint256[]", "name": "volumePerAvgLiquiditys", "type": "uint256[]" } | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ "internalType": "uint32", "name": "time", "type": "uint32" }, | ||
{ "internalType": "int24", "name": "tick", "type": "int24" } | ||
], | ||
"name": "initialize", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], | ||
"name": "timepoints", | ||
"outputs": [ | ||
{ "internalType": "bool", "name": "initialized", "type": "bool" }, | ||
{ "internalType": "uint32", "name": "blockTimestamp", "type": "uint32" }, | ||
{ "internalType": "int56", "name": "tickCumulative", "type": "int56" }, | ||
{ "internalType": "uint160", "name": "secondsPerLiquidityCumulative", "type": "uint160" }, | ||
{ "internalType": "uint88", "name": "volatilityCumulative", "type": "uint88" }, | ||
{ "internalType": "int24", "name": "averageTick", "type": "int24" }, | ||
{ "internalType": "uint144", "name": "volumePerLiquidityCumulative", "type": "uint144" } | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ "inputs": [], "name": "window", "outputs": [{ "internalType": "uint32", "name": "", "type": "uint32" }], "stateMutability": "pure", "type": "function" }, | ||
{ | ||
"inputs": [ | ||
{ "internalType": "uint16", "name": "index", "type": "uint16" }, | ||
{ "internalType": "uint32", "name": "blockTimestamp", "type": "uint32" }, | ||
{ "internalType": "int24", "name": "tick", "type": "int24" }, | ||
{ "internalType": "uint128", "name": "liquidity", "type": "uint128" }, | ||
{ "internalType": "uint128", "name": "volumePerLiquidity", "type": "uint128" } | ||
], | ||
"name": "write", | ||
"outputs": [{ "internalType": "uint16", "name": "indexUpdated", "type": "uint16" }], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
} | ||
] |
Oops, something went wrong.