Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Tractor SDK #791

Draft
wants to merge 13 commits into
base: secure-beanstalk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"sdk:dev": "yarn workspace @beanstalk/sdk dev",
"sdk:build": "yarn workspace @beanstalk/sdk build",
"sdk:test": "jest --selectProjects sdk --silent --runInBand --",
"sdk:tractor:reset": "cd protocol; npx hardhat tractor_sdk_test_init --network localhost; cd ..;",
"sdk:tractor:test": "yarn sdk:test -t 'tractor' --network localhost --verbose",
"sdk-wells:test": "jest --selectProjects sdk-wells --runInBand --silent=false --",
"sdk-wells:test:watch": "jest --selectProjects sdk-wells --runInBand --watch --verbose true --",
"sdk:testdev": "jest --selectProjects sdk --watch --runInBand --",
Expand Down
341 changes: 341 additions & 0 deletions projects/sdk/src/constants/abi/Ecosystem/Junction.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,341 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "Junction",
"sourceName": "contracts/ecosystem/junction/Junction.sol",
"abi": [
{
"inputs": [
{
"internalType": "uint256",
"name": "a",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "b",
"type": "uint256"
}
],
"name": "add",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "selector",
"type": "uint256"
},
{
"internalType": "bytes32[]",
"name": "options",
"type": "bytes32[]"
}
],
"name": "bytes32Switch",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "bool",
"name": "condition",
"type": "bool"
}
],
"name": "check",
"outputs": [],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "a",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "b",
"type": "uint256"
}
],
"name": "div",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "a",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "b",
"type": "uint256"
}
],
"name": "eq",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "a",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "b",
"type": "uint256"
}
],
"name": "gt",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "a",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "b",
"type": "uint256"
}
],
"name": "gte",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "a",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "b",
"type": "uint256"
}
],
"name": "lt",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "a",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "b",
"type": "uint256"
}
],
"name": "lte",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "a",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "b",
"type": "uint256"
}
],
"name": "mod",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "a",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "b",
"type": "uint256"
}
],
"name": "mul",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "a",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "b",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "c",
"type": "uint256"
}
],
"name": "mulDiv",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "a",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "b",
"type": "uint256"
}
],
"name": "neq",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "a",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "b",
"type": "uint256"
}
],
"name": "sub",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "pure",
"type": "function"
}
],
"bytecode": "0x608060405234801561001057600080fd5b50610681806100206000396000f3fe608060405234801561001057600080fd5b50600436106100ea5760003560e01c8063a391c15b1161008c578063b67d77c511610066578063b67d77c5146102cb578063c8a4ac9c146102ee578063ea6515c414610311578063f43f523a14610334576100ea565b8063a391c15b1461025c578063aa9a09121461027f578063b4773329146102a8576100ea565b806332148d73116100c857806332148d731461016a57806343df04251461018d578063771602f7146102165780637c6ed9ef14610239576100ea565b8063118fc88c146100ef57806321e5749b14610126578063241c591214610149575b600080fd5b6101126004803603604081101561010557600080fd5b5080359060200135610357565b604080519115158252519081900360200190f35b6101126004803603604081101561013c57600080fd5b5080359060200135610361565b6101686004803603602081101561015f57600080fd5b50351515610365565b005b6101126004803603604081101561018057600080fd5b50803590602001356103ba565b610204600480360360408110156101a357600080fd5b813591908101906040810160208201356401000000008111156101c557600080fd5b8201836020820111156101d757600080fd5b803590602001918460208302840111640100000000831117156101f957600080fd5b5090925090506103be565b60408051918252519081900360200190f35b6102046004803603604081101561022c57600080fd5b50803590602001356103dc565b6101126004803603604081101561024f57600080fd5b50803590602001356103ef565b6102046004803603604081101561027257600080fd5b50803590602001356103f4565b6102046004803603606081101561029557600080fd5b5080359060208101359060400135610400565b610112600480360360408110156102be57600080fd5b508035906020013561041e565b610204600480360360408110156102e157600080fd5b5080359060200135610423565b6102046004803603604081101561030457600080fd5b508035906020013561042f565b6101126004803603604081101561032757600080fd5b508035906020013561043b565b6102046004803603604081101561034a57600080fd5b5080359060200135610440565b8082105b92915050565b1090565b806103b7576040805162461bcd60e51b815260206004820152601660248201527f4a756e6374696f6e3a20636865636b206661696c656400000000000000000000604482015290519081900360640190fd5b50565b1490565b60008282858181106103cc57fe5b9050602002013590509392505050565b60006103e8838361044c565b9392505050565b141590565b60006103e883836104a6565b600061041682610410868661050d565b906104a6565b949350505050565b111590565b60006103e88383610566565b60006103e8838361050d565b101590565b60006103e883836105c3565b6000828201838110156103e8576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b60008082116104fc576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b81838161050557fe5b049392505050565b60008261051c5750600061035b565b8282028284828161052957fe5b04146103e85760405162461bcd60e51b815260040180806020018281038252602181526020018061062b6021913960400191505060405180910390fd5b6000828211156105bd576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b6000808211610619576040805162461bcd60e51b815260206004820152601860248201527f536166654d6174683a206d6f64756c6f206279207a65726f0000000000000000604482015290519081900360640190fd5b81838161062257fe5b06939250505056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a26469706673582212201074a71d2d918252f317eb2bdd5ba7239a046902016a306f30f5df7b58c1069e64736f6c63430007060033",
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c8063a391c15b1161008c578063b67d77c511610066578063b67d77c5146102cb578063c8a4ac9c146102ee578063ea6515c414610311578063f43f523a14610334576100ea565b8063a391c15b1461025c578063aa9a09121461027f578063b4773329146102a8576100ea565b806332148d73116100c857806332148d731461016a57806343df04251461018d578063771602f7146102165780637c6ed9ef14610239576100ea565b8063118fc88c146100ef57806321e5749b14610126578063241c591214610149575b600080fd5b6101126004803603604081101561010557600080fd5b5080359060200135610357565b604080519115158252519081900360200190f35b6101126004803603604081101561013c57600080fd5b5080359060200135610361565b6101686004803603602081101561015f57600080fd5b50351515610365565b005b6101126004803603604081101561018057600080fd5b50803590602001356103ba565b610204600480360360408110156101a357600080fd5b813591908101906040810160208201356401000000008111156101c557600080fd5b8201836020820111156101d757600080fd5b803590602001918460208302840111640100000000831117156101f957600080fd5b5090925090506103be565b60408051918252519081900360200190f35b6102046004803603604081101561022c57600080fd5b50803590602001356103dc565b6101126004803603604081101561024f57600080fd5b50803590602001356103ef565b6102046004803603604081101561027257600080fd5b50803590602001356103f4565b6102046004803603606081101561029557600080fd5b5080359060208101359060400135610400565b610112600480360360408110156102be57600080fd5b508035906020013561041e565b610204600480360360408110156102e157600080fd5b5080359060200135610423565b6102046004803603604081101561030457600080fd5b508035906020013561042f565b6101126004803603604081101561032757600080fd5b508035906020013561043b565b6102046004803603604081101561034a57600080fd5b5080359060200135610440565b8082105b92915050565b1090565b806103b7576040805162461bcd60e51b815260206004820152601660248201527f4a756e6374696f6e3a20636865636b206661696c656400000000000000000000604482015290519081900360640190fd5b50565b1490565b60008282858181106103cc57fe5b9050602002013590509392505050565b60006103e8838361044c565b9392505050565b141590565b60006103e883836104a6565b600061041682610410868661050d565b906104a6565b949350505050565b111590565b60006103e88383610566565b60006103e8838361050d565b101590565b60006103e883836105c3565b6000828201838110156103e8576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b60008082116104fc576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b81838161050557fe5b049392505050565b60008261051c5750600061035b565b8282028284828161052957fe5b04146103e85760405162461bcd60e51b815260040180806020018281038252602181526020018061062b6021913960400191505060405180910390fd5b6000828211156105bd576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b6000808211610619576040805162461bcd60e51b815260206004820152601860248201527f536166654d6174683a206d6f64756c6f206279207a65726f0000000000000000604482015290519081900360640190fd5b81838161062257fe5b06939250505056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a26469706673582212201074a71d2d918252f317eb2bdd5ba7239a046902016a306f30f5df7b58c1069e64736f6c63430007060033",
"linkReferences": {},
"deployedLinkReferences": {}
}
2 changes: 2 additions & 0 deletions projects/sdk/src/constants/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export const addresses = {
PIPELINE: Address.make("0xb1bE0000C6B3C62749b5F0c92480146452D15423"),
ROOT: Address.make("0x77700005BEA4DE0A78b956517f099260C2CA9a26"),
USD_ORACLE: Address.make("0x1aa19ed7DfC555E4644c9353Ad383c33024855F7"),
// TODO: Update with mainnet deployed address.
JUNCTION: Address.make("0x0f88D35a40bCF9FbE024DBB5df4e4504086336b0"),

// ----------------------------------------
// BeaNFT Contracts
Expand Down
6 changes: 6 additions & 0 deletions projects/sdk/src/lib/BeanstalkSDK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { Permit } from "./permit";
import { Root } from "./root";
import { Sdk as Queries, getSdk as getQueries } from "../constants/generated-gql/graphql";
import { Swap } from "src/lib/swap/Swap";
import { Tractor } from "src/lib/tractor/tractor";
import { Drafter } from "src/lib/tractor/drafter";
import { Bean } from "./bean";
import { Pools } from "./pools";
import defaultSettings from "src/defaultSettings.json";
Expand Down Expand Up @@ -60,6 +62,8 @@ export class BeanstalkSDK {
public readonly permit: Permit;
public readonly root: Root;
public readonly swap: Swap;
public readonly tractor: Tractor;
public readonly drafter: Drafter;
public readonly bean: Bean;
public readonly wells: WellsSDK;

Expand Down Expand Up @@ -92,6 +96,8 @@ export class BeanstalkSDK {
// Ecosystem
this.root = new Root(this);
this.swap = new Swap(this);
this.tractor = new Tractor(this);
this.drafter = new Drafter(this);

// Wells
this.wells = new WellsSDK(config);
Expand Down
Loading
Loading