Skip to content

Instantly share code, notes, and snippets.

View emilamaj's full-sized avatar

Emile Amajar emilamaj

  • 09:25 (UTC +01:00)
View GitHub Profile
@emilamaj
emilamaj / rotateSubList.py
Created June 14, 2023 23:10
Python rotate/shift a sub-list along an input list
# This function rotates a sublist of a list, given a starting position and a length. Position can be incremented infinitely.
def rotateSubList(bigList, position, length):
# We check if the left index is still smaller than the right index after the modulo operation.
if position % len(bigList) < (position+length) % len(bigList):
# The order is preserved, so we can safely use the slice notation
return bigList[position%len(bigList): (position+length)%len(bigList)]
else:
# The order is NOT preserved. The resulting array would have been clamped to the right by the slice notation.
# We add the missing part, sourced from the start of the bigList.
return bigList[position%len(bigList): len(bigList)] + bigList[0: (position+length)%len(bigList)]
@emilamaj
emilamaj / FactoriesV2.json
Created June 11, 2023 18:11
List of Uniswap V2-compatible factory contract addresses
{
"uniswapV2": {
"factory": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f"
},
"sushiswapV2": {
"factory": "0xC0AEe478e3658e2610c5F7A4A2E1777cE9e4f2Ac"
},
"shibaswapV2": {
"factory": "0x115934131916C8b277DD010Ee02de363c09d037c"
},