sorare / api

Sorare API documentation
153 stars 47 forks source link

Bid at an auction Python #116

Closed AlessandroCordella closed 2 years ago

AlessandroCordella commented 2 years ago

Following the documentation, I was able to get:

I am not understanding this part of the documentation:

const starkSignatures = limitOrders.map((limitOrder) => ({
  data: JSON.stringify(signLimitOrder(privateKey, limitOrder)),
  nonce: limitOrder.nonce,
  expirationTimestamp: limitOrder.expirationTimestamp,
  starkKey,
}));

const bidInput = {
  starkSignatures,
  auctionId: englishAuctionId,
  amount: bidAmountInWei,
  clientMutationId: crypto.randomBytes(8).join(""),
};

Considering a limitOrders list, like the following:

[
{
   "data":{
      "englishAuction":{
         "limitOrders":[
            {
               "vaultIdSell":3662317,
               "vaultIdBuy":3756365,
               "amountSell":"200",
               "amountBuy":"1",
               "tokenSell":"0xb333e3142fe16b78628f19bb15afddaef437e72d6d7f5c6c20c6801a27fba6",
               "tokenBuy":"0x0400f73146b26bcbfcdaaf9f99c13f20be5abbc22925f81adc5f5025bd6ad325",
               "nonce":518,
               "expirationTimestamp":457632
            }
         ]
      }
   }
}
]

How can I implement that logic in Python? In particular, how can I implement the signLimitOrder function that seems to come only with a nodejs module? Could someone provide me the definition of those variables in Python?

redox commented 2 years ago

In particular, how can I implement the signLimitOrder function that seems to come only with a nodejs module?

Yes correct, from https://github.com/sorare/crypto that makes the usage of https://github.com/starkware-libs/starkex-resources/blob/master/crypto/starkware/crypto/signature/signature.js slightly more specific to Sorare by exposing a simple signLimitOrder helper.

Could someone provide me the definition of those variables in Python?

We might add some python examples (and helpers) in the future. In the meantime, you can inspire from https://github.com/sorare/crypto/blob/66706b3285dca54c11c577d10c2aca124ec5843a/src/index.ts#L160-L167 and rely on https://github.com/starkware-libs/starkex-resources/blob/master/crypto/starkware/crypto/signature/signature.py to hashMsg and sign.

redox commented 2 years ago

Closing for now.

nachoroncero commented 1 year ago

Following the documentation, I was able to get:

  • starkKey
  • id
  • minNextBid
  • limitOrders

I am not understanding this part of the documentation:

const starkSignatures = limitOrders.map((limitOrder) => ({
  data: JSON.stringify(signLimitOrder(privateKey, limitOrder)),
  nonce: limitOrder.nonce,
  expirationTimestamp: limitOrder.expirationTimestamp,
  starkKey,
}));

const bidInput = {
  starkSignatures,
  auctionId: englishAuctionId,
  amount: bidAmountInWei,
  clientMutationId: crypto.randomBytes(8).join(""),
};

Considering a limitOrders list, like the following:

[
{
   "data":{
      "englishAuction":{
         "limitOrders":[
            {
               "vaultIdSell":3662317,
               "vaultIdBuy":3756365,
               "amountSell":"200",
               "amountBuy":"1",
               "tokenSell":"0xb333e3142fe16b78628f19bb15afddaef437e72d6d7f5c6c20c6801a27fba6",
               "tokenBuy":"0x0400f73146b26bcbfcdaaf9f99c13f20be5abbc22925f81adc5f5025bd6ad325",
               "nonce":518,
               "expirationTimestamp":457632
            }
         ]
      }
   }
}
]

How can I implement that logic in Python? In particular, how can I implement the signLimitOrder function that seems to come only with a nodejs module? Could someone provide me the definition of those variables in Python?

Hello, could you implement this in Python...? I am so frustrated, thanks in advance for your help

AlessandroCordella commented 1 year ago

@nachoroncero The solution thaht I am using for the moment is to use a javascript function through python