diff --git a/sdk/package.json b/sdk/package.json index 56b11e6..6b890c8 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@ampleforthorg/sdk", - "version": "1.0.33", + "version": "1.0.34", "description": "Typescript SDK for the Ampleforth Protocol", "license": "GPL-3.0-or-later", "main": "dist/src/index.js", @@ -12,8 +12,8 @@ "scripts": { "clean": "rimraf coverage build tmp", "prebuild": "yarn lint:fix", - "build": "tsc -p tsconfig.json", - "build:watch": "tsc -w -p tsconfig.json", + "build": "tsc -p tsconfig.json --skipLibCheck", + "build:watch": "tsc -w -p tsconfig.json --skipLibCheck", "lint": "yarn eslint && yarn prettier:list-different", "lint:fix": "yarn eslint:fix && yarn prettier", "eslint": "eslint . --ext .ts,.tsx", diff --git a/sdk/src/abis/UFragmentsPolicy.json b/sdk/src/abis/UFragmentsPolicy.json index fbfe7e2..2f82591 100644 --- a/sdk/src/abis/UFragmentsPolicy.json +++ b/sdk/src/abis/UFragmentsPolicy.json @@ -1,556 +1,609 @@ -{ - "_format": "hh-sol-artifact-1", - "contractName": "UFragmentsPolicy", - "sourceName": "contracts/UFragmentsPolicy.sol", - "abi": [ - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "epoch", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "exchangeRate", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "cpi", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "int256", - "name": "requestedSupplyAdjustment", - "type": "int256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "timestampSec", - "type": "uint256" - } - ], - "name": "LogRebase", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "epoch", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "exchangeRate", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "targetRate", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "int256", - "name": "requestedSupplyAdjustment", - "type": "int256" - } - ], - "name": "LogRebaseV2", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - } - ], - "name": "OwnershipRenounced", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferred", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "int256", - "name": "normalizedRate", - "type": "int256" - }, - { - "internalType": "int256", - "name": "lower", - "type": "int256" - }, - { - "internalType": "int256", - "name": "upper", - "type": "int256" - }, - { - "internalType": "int256", - "name": "growth", - "type": "int256" - } - ], - "name": "computeRebasePercentage", - "outputs": [ - { - "internalType": "int256", - "name": "", - "type": "int256" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [], - "name": "cpiOracle", - "outputs": [ - { - "internalType": "contract IOracle", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "deviationThreshold", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "epoch", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "globalAmpleforthEpochAndAMPLSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "inRebaseWindow", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner_", - "type": "address" - }, - { - "internalType": "contract IUFragments", - "name": "uFrags_", - "type": "address" - } - ], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "isOwner", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "lastRebaseTimestampSec", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "marketOracle", - "outputs": [ - { - "internalType": "contract IOracle", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "minRebaseTimeIntervalSec", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "orchestrator", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "rebase", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "rebaseFunctionGrowth", - "outputs": [ - { - "internalType": "int256", - "name": "", - "type": "int256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "rebaseFunctionLowerPercentage", - "outputs": [ - { - "internalType": "int256", - "name": "", - "type": "int256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "rebaseFunctionUpperPercentage", - "outputs": [ - { - "internalType": "int256", - "name": "", - "type": "int256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "rebaseLag", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [], - "name": "rebaseWindowLengthSec", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "rebaseWindowOffsetSec", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IOracle", - "name": "cpiOracle_", - "type": "address" - } - ], - "name": "setCpiOracle", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "deviationThreshold_", - "type": "uint256" - } - ], - "name": "setDeviationThreshold", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IOracle", - "name": "marketOracle_", - "type": "address" - } - ], - "name": "setMarketOracle", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "orchestrator_", - "type": "address" - } - ], - "name": "setOrchestrator", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "int256", - "name": "rebaseFunctionGrowth_", - "type": "int256" - } - ], - "name": "setRebaseFunctionGrowth", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "int256", - "name": "rebaseFunctionLowerPercentage_", - "type": "int256" - } - ], - "name": "setRebaseFunctionLowerPercentage", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "int256", - "name": "rebaseFunctionUpperPercentage_", - "type": "int256" - } - ], - "name": "setRebaseFunctionUpperPercentage", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "minRebaseTimeIntervalSec_", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "rebaseWindowOffsetSec_", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "rebaseWindowLengthSec_", - "type": "uint256" - } - ], - "name": "setRebaseTimingParameters", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "uFrags", - "outputs": [ - { - "internalType": "contract IUFragments", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - } - ], - "bytecode": "0x608060405234801561001057600080fd5b5061185c806100206000396000f3fe608060405234801561001057600080fd5b50600436106101f05760003560e01c80638da5cb5b1161010f578063b74795d9116100a2578063d94ad83711610071578063d94ad837146103d1578063e9fa88a4146103da578063f2fde38b146103ed578063f4fefa491461040057600080fd5b8063b74795d914610385578063c4d66de814610398578063cd28ef0d146103ab578063d3d55d51146103be57600080fd5b80639db59b2f116100de5780639db59b2f1461034e5780639e30bac514610357578063ab33c5ca1461036a578063af14052c1461037d57600080fd5b80638da5cb5b146103185780638f32d59b14610329578063900cf0cf1461033c5780639466120f1461034557600080fd5b806353a15edc116101875780637052b902116101565780637052b902146102eb578063715018a6146102f45780637486cdea146102fc5780638001066d1461030557600080fd5b806353a15edc1461029d5780635ee01540146102b057806360961528146102b957806363f6d4c8146102e457600080fd5b80633a785af1116101c35780633a785af11461025b5780633a93069b1461026e5780633d6a46e514610277578063485cc9551461028a57600080fd5b806302101899146101f5578063105bad4f14610211578063111d04981461022e57806316250fd414610246575b600080fd5b6101fe606c5481565b6040519081526020015b60405180910390f35b610219610413565b60408051928352602083019190915201610208565b6102366104a7565b6040519015158152602001610208565b6102596102543660046114a5565b6104ee565b005b6101fe610269366004611434565b61052c565b6101fe606d5481565b6102596102853660046113c8565b61068d565b6102596102983660046113e4565b6106c6565b6102596102ab36600461141c565b610811565b6101fe60725481565b6068546102cc906001600160a01b031681565b6040516001600160a01b039091168152602001610208565b60016101fe565b6101fe606e5481565b61025961082d565b6101fe60745481565b61025961031336600461141c565b61088e565b6033546001600160a01b03166102cc565b6033546001600160a01b03163314610236565b6101fe60705481565b6101fe606f5481565b6101fe60735481565b6102596103653660046113c8565b6108b8565b6067546102cc906001600160a01b031681565b6102596108f1565b6071546102cc906001600160a01b031681565b6102596103a63660046113c8565b610d87565b6102596103b93660046113c8565b610e0b565b6066546102cc906001600160a01b031681565b6101fe606a5481565b6102596103e836600461141c565b610e44565b6102596103fb3660046113c8565b610e6e565b61025961040e36600461141c565b610e91565b600080607054606660009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561046757600080fd5b505afa15801561047b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061049f9190611465565b915091509091565b6000606e546104c1606c5442610ebb90919063ffffffff16565b101580156104e95750606f54606e546104d991610eda565b606c546104e7904290610ebb565b105b905090565b6033546001600160a01b0316331461050557600080fd5b6000831161051257600080fd5b82821061051e57600080fd5b606c92909255606e55606f55565b60008061054561053e6012600a6115fc565b8790610ef6565b905060006105686105586012600a6115fc565b6105628685610f34565b90610f85565b9050610581606461057b6012600a6115fc565b90610f34565b81131561059c57610599606461057b6012600a6115fc565b90505b6105ae60631961057b6012600a6115fc565b8112156105ca576105c760631961057b6012600a6115fc565b90505b60006105e1826105dc6012600a6115fc565b610faf565b9050806105f357869350505050610685565b60006105ff8789610ef6565b9050600061061d896105626106166012600a6115fc565b8b90610f34565b9050610639836105626106326012600a6115fc565b8490610f34565b905060006106538261064d6012600a6115fc565b90610ef6565b9050600061067b8b6106758461056261066e6012600a6115fc565b8990610f34565b90611115565b9750505050505050505b949350505050565b6033546001600160a01b031633146106a457600080fd5b606780546001600160a01b0319166001600160a01b0392909216919091179055565b600054610100900460ff16806106db5750303b155b806106e9575060005460ff16155b61070e5760405162461bcd60e51b8152600401610705906114d0565b60405180910390fd5b6000805461ffff19811661010117909155610100900460ff1661073083610d87565b61073c60026012611785565b61074790600a6115fc565b610752906005611727565b606a556107616012600a6115fc565b61076c906003611727565b60745561077b60026012611785565b61078690600a6115fc565b61079190600a611727565b6073556107a060026012611785565b6107ab90600a6115fc565b6107b7906009196116a4565b60725562015180606c55611c20606e556104b0606f556000606d8190556070819055606680546001600160a01b039094166001600160a01b03199094169390931790925581549015156101000261ff001990911617905550565b6033546001600160a01b0316331461082857600080fd5b606a55565b6033546001600160a01b0316331461084457600080fd5b6033546040516001600160a01b03909116907ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482090600090a2603380546001600160a01b0319169055565b6033546001600160a01b031633146108a557600080fd5b60008112156108b357600080fd5b607455565b6033546001600160a01b031633146108cf57600080fd5b606880546001600160a01b0319166001600160a01b0392909216919091179055565b6071546001600160a01b0316331461090857600080fd5b6109106104a7565b61091957600080fd5b42610931606c54606d54610eda90919063ffffffff16565b1061093b57600080fd5b610966606e54610960610959606c5442610ebb90919063ffffffff16565b4290611152565b90610eda565b606d55607054610977906001610eda565b607055606754604080516303bc5de360e41b8152815160009384936001600160a01b0390911692633bc5de30926004808301939282900301818787803b1580156109c057600080fd5b505af11580156109d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f8919061147d565b909250905080610a0757600080fd5b606854604080516303bc5de360e41b8152815160009384936001600160a01b0390911692633bc5de30926004808301939282900301818787803b158015610a4d57600080fd5b505af1158015610a61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a85919061147d565b909250905080610a9457600080fd5b610aa06012600a6115fc565b610aad90620f4240611727565b821115610ad057610ac06012600a6115fc565b610acd90620f4240611727565b91505b6000610adc838661116d565b9050600081138015610b9f5750610af56012600a6115fc565b610b0290620f4240611727565b610b13906001600160ff1b036115a5565b610b9d82606660009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015610b6557600080fd5b505afa158015610b79573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109609190611465565b115b15610c6857610c65610c60606660009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015610bf857600080fd5b505afa158015610c0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c309190611465565b610c3c6012600a6115fc565b610c4990620f4240611727565b610c5a906001600160ff1b036115a5565b90611152565b61126f565b90505b606654607054604051637a43e23f60e01b81526004810191909152602481018390526000916001600160a01b031690637a43e23f90604401602060405180830381600087803b158015610cba57600080fd5b505af1158015610cce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cf29190611465565b9050610d006012600a6115fc565b610d0d90620f4240611727565b610d1e906001600160ff1b036115a5565b811115610d3b57634e487b7160e01b600052600160045260246000fd5b60705460408051868152602081018990529081018490527f7399879426afecf71162ff2c4158fd1a28abe8d243658c82f54b0335a843710f9060600160405180910390a2505050505050565b600054610100900460ff1680610d9c5750303b155b80610daa575060005460ff16155b610dc65760405162461bcd60e51b8152600401610705906114d0565b60008054603380546001600160a01b0319166001600160a01b03949094169390931790925561ffff1982166101009283900460ff161515909202919091176001179055565b6033546001600160a01b03163314610e2257600080fd5b607180546001600160a01b0319166001600160a01b0392909216919091179055565b6033546001600160a01b03163314610e5b57600080fd5b6000811315610e6957600080fd5b607255565b6033546001600160a01b03163314610e8557600080fd5b610e8e81611289565b50565b6033546001600160a01b03163314610ea857600080fd5b6000811215610eb657600080fd5b607355565b600081610ec757600080fd5b610ed182846117b7565b90505b92915050565b600080610ee7838561155f565b905083811015610ed157600080fd5b600080610f038385611746565b905060008312158015610f165750838113155b80610f2b5750600083128015610f2b57508381135b610ed157600080fd5b600080610f4183856116a4565b9050600160ff1b81141580610f5f5750600160ff1b84811690841614155b610f6857600080fd5b821580610f2b575083610f7b8483611577565b14610ed157600080fd5b600081600019141580610f9c5750600160ff1b8314155b610fa557600080fd5b610ed18284611577565b60008080841215610fc957506001610fc6846112f8565b93505b6040805160a0810182526713a04bbdfdc9be898152671080e992061ab32b6020820152670f2243014e544ebb91810191909152670e7e0178e9d6ed506060820152670e2e820ade835f46608082015260006110248686610f85565b9050606481131561103457600080fd5b60006110436001831b87610f34565b9050600061105a88611055858a610f34565b610ef6565b90506000611069886002610f85565b905060005b60058110156110eb578183126110cc576110888383610ef6565b92506110c96110bb858884600581106110b157634e487b7160e01b600052603260045260246000fd5b6020020151610f34565b670de0b6b3a7640000610f85565b93505b6110d7826002610f85565b9150806110e38161179c565b91505061106e565b508515611108576111056110ff898a610f34565b84610f85565b92505b5090979650505050505050565b600080611122838561151e565b9050600083121580156111355750838112155b80610f2b5750600083128015610f2b5750838112610ed157600080fd5b60008282111561116157600080fd5b60006106858385611785565b60006111798383611322565b1561118657506000610ed4565b60006111918361126f565b905060006111b1826105626111a86012600a6115fc565b61057b8961126f565b905060006111c78260725460735460745461052c565b90506112656111d86012600a6115fc565b6105628361057b606660009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561122d57600080fd5b505afa158015611241573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c609190611465565b9695505050505050565b60006001600160ff1b0382111561128557600080fd5b5090565b6001600160a01b03811661129c57600080fd5b6033546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3603380546001600160a01b0319166001600160a01b0392909216919091179055565b6000600160ff1b82141561130b57600080fd5b600082126113195781610ed4565b610ed4826117cb565b6000806113486113346012600a6115fc565b606a54611342908690611386565b906113ae565b90508284101580156113625750806113608585611152565b105b806106855750828410801561068557508061137d8486611152565b10949350505050565b60008261139557506000610ed4565b60006113a18385611727565b905082610f7b85836115a5565b60008082116113bc57600080fd5b600061068583856115a5565b6000602082840312156113d9578081fd5b8135610ed181611811565b600080604083850312156113f6578081fd5b823561140181611811565b9150602083013561141181611811565b809150509250929050565b60006020828403121561142d578081fd5b5035919050565b60008060008060808587031215611449578182fd5b5050823594602084013594506040840135936060013592509050565b600060208284031215611476578081fd5b5051919050565b6000806040838503121561148f578182fd5b8251915060208301518015158114611411578182fd5b6000806000606084860312156114b9578283fd5b505081359360208301359350604090920135919050565b6020808252602e908201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560408201526d195b881a5b9a5d1a585b1a5e995960921b606082015260800190565b600080821280156001600160ff1b0384900385131615611540576115406117e5565b600160ff1b8390038412811615611559576115596117e5565b50500190565b60008219821115611572576115726117e5565b500190565b600082611586576115866117fb565b600160ff1b8214600019841416156115a0576115a06117e5565b500590565b6000826115b4576115b46117fb565b500490565b600181815b808511156115f45781600019048211156115da576115da6117e5565b808516156115e757918102915b93841c93908002906115be565b509250929050565b6000610ed1838360008261161257506001610ed4565b8161161f57506000610ed4565b8160018114611635576002811461163f5761165b565b6001915050610ed4565b60ff841115611650576116506117e5565b50506001821b610ed4565b5060208310610133831016604e8410600b841016171561167e575081810a610ed4565b61168883836115b9565b806000190482111561169c5761169c6117e5565b029392505050565b60006001600160ff1b03818413828413808216868404861116156116ca576116ca6117e5565b600160ff1b848712828116878305891216156116e8576116e86117e5565b858712925087820587128484161615611703576117036117e5565b87850587128184161615611719576117196117e5565b505050929093029392505050565b6000816000190483118215151615611741576117416117e5565b500290565b60008083128015600160ff1b850184121615611764576117646117e5565b6001600160ff1b038401831381161561177f5761177f6117e5565b50500390565b600082821015611797576117976117e5565b500390565b60006000198214156117b0576117b06117e5565b5060010190565b6000826117c6576117c66117fb565b500690565b6000600160ff1b8214156117e1576117e16117e5565b0390565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b6001600160a01b0381168114610e8e57600080fdfea264697066735822122027a03fa55c230ef2cdebf02459a8b32e51df56b4299f0d285eea96a44052054164736f6c63430008040033", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101f05760003560e01c80638da5cb5b1161010f578063b74795d9116100a2578063d94ad83711610071578063d94ad837146103d1578063e9fa88a4146103da578063f2fde38b146103ed578063f4fefa491461040057600080fd5b8063b74795d914610385578063c4d66de814610398578063cd28ef0d146103ab578063d3d55d51146103be57600080fd5b80639db59b2f116100de5780639db59b2f1461034e5780639e30bac514610357578063ab33c5ca1461036a578063af14052c1461037d57600080fd5b80638da5cb5b146103185780638f32d59b14610329578063900cf0cf1461033c5780639466120f1461034557600080fd5b806353a15edc116101875780637052b902116101565780637052b902146102eb578063715018a6146102f45780637486cdea146102fc5780638001066d1461030557600080fd5b806353a15edc1461029d5780635ee01540146102b057806360961528146102b957806363f6d4c8146102e457600080fd5b80633a785af1116101c35780633a785af11461025b5780633a93069b1461026e5780633d6a46e514610277578063485cc9551461028a57600080fd5b806302101899146101f5578063105bad4f14610211578063111d04981461022e57806316250fd414610246575b600080fd5b6101fe606c5481565b6040519081526020015b60405180910390f35b610219610413565b60408051928352602083019190915201610208565b6102366104a7565b6040519015158152602001610208565b6102596102543660046114a5565b6104ee565b005b6101fe610269366004611434565b61052c565b6101fe606d5481565b6102596102853660046113c8565b61068d565b6102596102983660046113e4565b6106c6565b6102596102ab36600461141c565b610811565b6101fe60725481565b6068546102cc906001600160a01b031681565b6040516001600160a01b039091168152602001610208565b60016101fe565b6101fe606e5481565b61025961082d565b6101fe60745481565b61025961031336600461141c565b61088e565b6033546001600160a01b03166102cc565b6033546001600160a01b03163314610236565b6101fe60705481565b6101fe606f5481565b6101fe60735481565b6102596103653660046113c8565b6108b8565b6067546102cc906001600160a01b031681565b6102596108f1565b6071546102cc906001600160a01b031681565b6102596103a63660046113c8565b610d87565b6102596103b93660046113c8565b610e0b565b6066546102cc906001600160a01b031681565b6101fe606a5481565b6102596103e836600461141c565b610e44565b6102596103fb3660046113c8565b610e6e565b61025961040e36600461141c565b610e91565b600080607054606660009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561046757600080fd5b505afa15801561047b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061049f9190611465565b915091509091565b6000606e546104c1606c5442610ebb90919063ffffffff16565b101580156104e95750606f54606e546104d991610eda565b606c546104e7904290610ebb565b105b905090565b6033546001600160a01b0316331461050557600080fd5b6000831161051257600080fd5b82821061051e57600080fd5b606c92909255606e55606f55565b60008061054561053e6012600a6115fc565b8790610ef6565b905060006105686105586012600a6115fc565b6105628685610f34565b90610f85565b9050610581606461057b6012600a6115fc565b90610f34565b81131561059c57610599606461057b6012600a6115fc565b90505b6105ae60631961057b6012600a6115fc565b8112156105ca576105c760631961057b6012600a6115fc565b90505b60006105e1826105dc6012600a6115fc565b610faf565b9050806105f357869350505050610685565b60006105ff8789610ef6565b9050600061061d896105626106166012600a6115fc565b8b90610f34565b9050610639836105626106326012600a6115fc565b8490610f34565b905060006106538261064d6012600a6115fc565b90610ef6565b9050600061067b8b6106758461056261066e6012600a6115fc565b8990610f34565b90611115565b9750505050505050505b949350505050565b6033546001600160a01b031633146106a457600080fd5b606780546001600160a01b0319166001600160a01b0392909216919091179055565b600054610100900460ff16806106db5750303b155b806106e9575060005460ff16155b61070e5760405162461bcd60e51b8152600401610705906114d0565b60405180910390fd5b6000805461ffff19811661010117909155610100900460ff1661073083610d87565b61073c60026012611785565b61074790600a6115fc565b610752906005611727565b606a556107616012600a6115fc565b61076c906003611727565b60745561077b60026012611785565b61078690600a6115fc565b61079190600a611727565b6073556107a060026012611785565b6107ab90600a6115fc565b6107b7906009196116a4565b60725562015180606c55611c20606e556104b0606f556000606d8190556070819055606680546001600160a01b039094166001600160a01b03199094169390931790925581549015156101000261ff001990911617905550565b6033546001600160a01b0316331461082857600080fd5b606a55565b6033546001600160a01b0316331461084457600080fd5b6033546040516001600160a01b03909116907ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482090600090a2603380546001600160a01b0319169055565b6033546001600160a01b031633146108a557600080fd5b60008112156108b357600080fd5b607455565b6033546001600160a01b031633146108cf57600080fd5b606880546001600160a01b0319166001600160a01b0392909216919091179055565b6071546001600160a01b0316331461090857600080fd5b6109106104a7565b61091957600080fd5b42610931606c54606d54610eda90919063ffffffff16565b1061093b57600080fd5b610966606e54610960610959606c5442610ebb90919063ffffffff16565b4290611152565b90610eda565b606d55607054610977906001610eda565b607055606754604080516303bc5de360e41b8152815160009384936001600160a01b0390911692633bc5de30926004808301939282900301818787803b1580156109c057600080fd5b505af11580156109d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f8919061147d565b909250905080610a0757600080fd5b606854604080516303bc5de360e41b8152815160009384936001600160a01b0390911692633bc5de30926004808301939282900301818787803b158015610a4d57600080fd5b505af1158015610a61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a85919061147d565b909250905080610a9457600080fd5b610aa06012600a6115fc565b610aad90620f4240611727565b821115610ad057610ac06012600a6115fc565b610acd90620f4240611727565b91505b6000610adc838661116d565b9050600081138015610b9f5750610af56012600a6115fc565b610b0290620f4240611727565b610b13906001600160ff1b036115a5565b610b9d82606660009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015610b6557600080fd5b505afa158015610b79573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109609190611465565b115b15610c6857610c65610c60606660009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015610bf857600080fd5b505afa158015610c0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c309190611465565b610c3c6012600a6115fc565b610c4990620f4240611727565b610c5a906001600160ff1b036115a5565b90611152565b61126f565b90505b606654607054604051637a43e23f60e01b81526004810191909152602481018390526000916001600160a01b031690637a43e23f90604401602060405180830381600087803b158015610cba57600080fd5b505af1158015610cce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cf29190611465565b9050610d006012600a6115fc565b610d0d90620f4240611727565b610d1e906001600160ff1b036115a5565b811115610d3b57634e487b7160e01b600052600160045260246000fd5b60705460408051868152602081018990529081018490527f7399879426afecf71162ff2c4158fd1a28abe8d243658c82f54b0335a843710f9060600160405180910390a2505050505050565b600054610100900460ff1680610d9c5750303b155b80610daa575060005460ff16155b610dc65760405162461bcd60e51b8152600401610705906114d0565b60008054603380546001600160a01b0319166001600160a01b03949094169390931790925561ffff1982166101009283900460ff161515909202919091176001179055565b6033546001600160a01b03163314610e2257600080fd5b607180546001600160a01b0319166001600160a01b0392909216919091179055565b6033546001600160a01b03163314610e5b57600080fd5b6000811315610e6957600080fd5b607255565b6033546001600160a01b03163314610e8557600080fd5b610e8e81611289565b50565b6033546001600160a01b03163314610ea857600080fd5b6000811215610eb657600080fd5b607355565b600081610ec757600080fd5b610ed182846117b7565b90505b92915050565b600080610ee7838561155f565b905083811015610ed157600080fd5b600080610f038385611746565b905060008312158015610f165750838113155b80610f2b5750600083128015610f2b57508381135b610ed157600080fd5b600080610f4183856116a4565b9050600160ff1b81141580610f5f5750600160ff1b84811690841614155b610f6857600080fd5b821580610f2b575083610f7b8483611577565b14610ed157600080fd5b600081600019141580610f9c5750600160ff1b8314155b610fa557600080fd5b610ed18284611577565b60008080841215610fc957506001610fc6846112f8565b93505b6040805160a0810182526713a04bbdfdc9be898152671080e992061ab32b6020820152670f2243014e544ebb91810191909152670e7e0178e9d6ed506060820152670e2e820ade835f46608082015260006110248686610f85565b9050606481131561103457600080fd5b60006110436001831b87610f34565b9050600061105a88611055858a610f34565b610ef6565b90506000611069886002610f85565b905060005b60058110156110eb578183126110cc576110888383610ef6565b92506110c96110bb858884600581106110b157634e487b7160e01b600052603260045260246000fd5b6020020151610f34565b670de0b6b3a7640000610f85565b93505b6110d7826002610f85565b9150806110e38161179c565b91505061106e565b508515611108576111056110ff898a610f34565b84610f85565b92505b5090979650505050505050565b600080611122838561151e565b9050600083121580156111355750838112155b80610f2b5750600083128015610f2b5750838112610ed157600080fd5b60008282111561116157600080fd5b60006106858385611785565b60006111798383611322565b1561118657506000610ed4565b60006111918361126f565b905060006111b1826105626111a86012600a6115fc565b61057b8961126f565b905060006111c78260725460735460745461052c565b90506112656111d86012600a6115fc565b6105628361057b606660009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561122d57600080fd5b505afa158015611241573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c609190611465565b9695505050505050565b60006001600160ff1b0382111561128557600080fd5b5090565b6001600160a01b03811661129c57600080fd5b6033546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3603380546001600160a01b0319166001600160a01b0392909216919091179055565b6000600160ff1b82141561130b57600080fd5b600082126113195781610ed4565b610ed4826117cb565b6000806113486113346012600a6115fc565b606a54611342908690611386565b906113ae565b90508284101580156113625750806113608585611152565b105b806106855750828410801561068557508061137d8486611152565b10949350505050565b60008261139557506000610ed4565b60006113a18385611727565b905082610f7b85836115a5565b60008082116113bc57600080fd5b600061068583856115a5565b6000602082840312156113d9578081fd5b8135610ed181611811565b600080604083850312156113f6578081fd5b823561140181611811565b9150602083013561141181611811565b809150509250929050565b60006020828403121561142d578081fd5b5035919050565b60008060008060808587031215611449578182fd5b5050823594602084013594506040840135936060013592509050565b600060208284031215611476578081fd5b5051919050565b6000806040838503121561148f578182fd5b8251915060208301518015158114611411578182fd5b6000806000606084860312156114b9578283fd5b505081359360208301359350604090920135919050565b6020808252602e908201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560408201526d195b881a5b9a5d1a585b1a5e995960921b606082015260800190565b600080821280156001600160ff1b0384900385131615611540576115406117e5565b600160ff1b8390038412811615611559576115596117e5565b50500190565b60008219821115611572576115726117e5565b500190565b600082611586576115866117fb565b600160ff1b8214600019841416156115a0576115a06117e5565b500590565b6000826115b4576115b46117fb565b500490565b600181815b808511156115f45781600019048211156115da576115da6117e5565b808516156115e757918102915b93841c93908002906115be565b509250929050565b6000610ed1838360008261161257506001610ed4565b8161161f57506000610ed4565b8160018114611635576002811461163f5761165b565b6001915050610ed4565b60ff841115611650576116506117e5565b50506001821b610ed4565b5060208310610133831016604e8410600b841016171561167e575081810a610ed4565b61168883836115b9565b806000190482111561169c5761169c6117e5565b029392505050565b60006001600160ff1b03818413828413808216868404861116156116ca576116ca6117e5565b600160ff1b848712828116878305891216156116e8576116e86117e5565b858712925087820587128484161615611703576117036117e5565b87850587128184161615611719576117196117e5565b505050929093029392505050565b6000816000190483118215151615611741576117416117e5565b500290565b60008083128015600160ff1b850184121615611764576117646117e5565b6001600160ff1b038401831381161561177f5761177f6117e5565b50500390565b600082821015611797576117976117e5565b500390565b60006000198214156117b0576117b06117e5565b5060010190565b6000826117c6576117c66117fb565b500690565b6000600160ff1b8214156117e1576117e16117e5565b0390565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b6001600160a01b0381168114610e8e57600080fdfea264697066735822122027a03fa55c230ef2cdebf02459a8b32e51df56b4299f0d285eea96a44052054164736f6c63430008040033", - "linkReferences": {}, - "deployedLinkReferences": {} -} +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "epoch", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "exchangeRate", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "cpi", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "int256", + "name": "requestedSupplyAdjustment", + "type": "int256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestampSec", + "type": "uint256" + } + ], + "name": "LogRebase", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "epoch", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "exchangeRate", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "targetRate", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "int256", + "name": "requestedSupplyAdjustment", + "type": "int256" + } + ], + "name": "LogRebaseV2", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + } + ], + "name": "OwnershipRenounced", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "normalizedRate", + "type": "int256" + }, + { + "internalType": "int256", + "name": "lower", + "type": "int256" + }, + { + "internalType": "int256", + "name": "upper", + "type": "int256" + }, + { + "internalType": "int256", + "name": "growth", + "type": "int256" + } + ], + "name": "computeRebasePercentage", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "cpiOracle", + "outputs": [ + { + "internalType": "contract IOracle", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "deviationThreshold", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "epoch", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getExchangeRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getTargetRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "globalAmpleforthEpochAndAMPLSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "inRebaseWindow", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner_", + "type": "address" + }, + { + "internalType": "contract IUFragments", + "name": "uFrags_", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "isOwner", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "lastRebaseTimestampSec", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "marketOracle", + "outputs": [ + { + "internalType": "contract IOracle", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "minRebaseTimeIntervalSec", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "orchestrator", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rebase", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "rebaseFunctionNegativeGrowth", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rebaseFunctionNegativePercentageLimit", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rebaseFunctionPositiveGrowth", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rebaseFunctionPositivePercentageLimit", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rebaseLag", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "rebaseWindowLengthSec", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rebaseWindowOffsetSec", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IOracle", + "name": "cpiOracle_", + "type": "address" + } + ], + "name": "setCpiOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "deviationThreshold_", + "type": "uint256" + } + ], + "name": "setDeviationThreshold", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IOracle", + "name": "marketOracle_", + "type": "address" + } + ], + "name": "setMarketOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "orchestrator_", + "type": "address" + } + ], + "name": "setOrchestrator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "rebaseFunctionNegativeGrowth_", + "type": "int256" + } + ], + "name": "setRebaseFunctionNegativeGrowth", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "rebaseFunctionNegativePercentageLimit_", + "type": "int256" + } + ], + "name": "setRebaseFunctionNegativePercentageLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "rebaseFunctionPositiveGrowth_", + "type": "int256" + } + ], + "name": "setRebaseFunctionPositiveGrowth", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "rebaseFunctionPositivePercentageLimit_", + "type": "int256" + } + ], + "name": "setRebaseFunctionPositivePercentageLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "minRebaseTimeIntervalSec_", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rebaseWindowOffsetSec_", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rebaseWindowLengthSec_", + "type": "uint256" + } + ], + "name": "setRebaseTimingParameters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "uFrags", + "outputs": [ + { + "internalType": "contract IUFragments", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/sdk/src/entities/policy/Policy.ts b/sdk/src/entities/policy/Policy.ts index c6d5bd8..d5834c6 100644 --- a/sdk/src/entities/policy/Policy.ts +++ b/sdk/src/entities/policy/Policy.ts @@ -4,9 +4,10 @@ import Rebase, { RebaseData } from './Rebase' export interface PolicyData { id: string address: string - rebaseFunctionLowerPercentage: string - rebaseFunctionUpperPercentage: string - rebaseFunctionGrowth: string + rebaseFunctionNegativePercentageLimit: string + rebaseFunctionPositivePercentageLimit: string + rebaseFunctionNegativeGrowth: string + rebaseFunctionPositiveGrowth: string rebaseLag: string deviationThreshold: string minRebaseTimeIntervalSec: string @@ -16,6 +17,13 @@ export interface PolicyData { historicalRebases: RebaseData[] } +const DATA_DEFAULTS = { + rebaseFunctionNegativePercentageLimit: '-0.077', + rebaseFunctionPositivePercentageLimit: '0.05', + rebaseFunctionNegativeGrowth: '41', + rebaseFunctionPositiveGrowth: '20', +} + export default class Policy { public lastRebase: Rebase public historicalRebases: Rebase[] = [] @@ -45,16 +53,32 @@ export default class Policy { return this.lastRebase.targetRate } - get rebaseFunctionLowerPercentage(): BigNumber { - return new BigNumber(this.data.rebaseFunctionLowerPercentage) + get rebaseFunctionNegativePercentageLimit(): BigNumber { + return new BigNumber( + this.data.rebaseFunctionNegativePercentageLimit || + DATA_DEFAULTS.rebaseFunctionNegativePercentageLimit, + ) + } + + get rebaseFunctionPositivePercentageLimit(): BigNumber { + return new BigNumber( + this.data.rebaseFunctionPositivePercentageLimit || + DATA_DEFAULTS.rebaseFunctionPositivePercentageLimit, + ) } - get rebaseFunctionUpperPercentage(): BigNumber { - return new BigNumber(this.data.rebaseFunctionUpperPercentage) + get rebaseFunctionNegativeGrowth(): BigNumber { + return new BigNumber( + this.data.rebaseFunctionNegativeGrowth || + DATA_DEFAULTS.rebaseFunctionNegativeGrowth, + ) } - get rebaseFunctionGrowth(): BigNumber { - return new BigNumber(this.data.rebaseFunctionGrowth) + get rebaseFunctionPositiveGrowth(): BigNumber { + return new BigNumber( + this.data.rebaseFunctionPositiveGrowth || + DATA_DEFAULTS.rebaseFunctionPositiveGrowth, + ) } get rebaseLag(): BigNumber { @@ -105,15 +129,26 @@ export default class Policy { return new BigNumber('0') } - const upper = new BigNumber(this.rebaseFunctionUpperPercentage) - const lower = new BigNumber(this.rebaseFunctionLowerPercentage) - const growth = new BigNumber(this.rebaseFunctionGrowth) - const scaling = new BigNumber('32') - const delta = new BigNumber(marketRate) .div(new BigNumber(targetRate)) .minus(new BigNumber('1')) + const isPositiveRebase = delta.gte(0) + const lower = isPositiveRebase + ? new BigNumber( + this.rebaseFunctionPositivePercentageLimit, + ).negated() + : new BigNumber(this.rebaseFunctionNegativePercentageLimit) + const upper = isPositiveRebase + ? new BigNumber(this.rebaseFunctionPositivePercentageLimit) + : new BigNumber( + this.rebaseFunctionNegativePercentageLimit, + ).negated() + const growth = isPositiveRebase + ? new BigNumber(this.rebaseFunctionPositiveGrowth) + : new BigNumber(this.rebaseFunctionNegativeGrowth) + const scaling = new BigNumber('32') + let exp = growth.multipliedBy(delta) exp = BigNumber.minimum(new BigNumber('100'), exp) exp = BigNumber.maximum(new BigNumber('-100'), exp) diff --git a/sdk/src/queries/policy.ts b/sdk/src/queries/policy.ts index 24ff82f..8e8a2e1 100644 --- a/sdk/src/queries/policy.ts +++ b/sdk/src/queries/policy.ts @@ -19,9 +19,10 @@ export const GET_POLICY_DATA = ` query GetPolicyData ($id: ID!) { policies(where: { id: $id }) { id - rebaseFunctionLowerPercentage - rebaseFunctionUpperPercentage - rebaseFunctionGrowth + rebaseFunctionNegativePercentageLimit + rebaseFunctionPositivePercentageLimit + rebaseFunctionNegativeGrowth + rebaseFunctionPositiveGrowth rebaseLag deviationThreshold minRebaseTimeIntervalSec diff --git a/subgraph/schema.graphql b/subgraph/schema.graphql index 7f17fcd..137ae7d 100644 --- a/subgraph/schema.graphql +++ b/subgraph/schema.graphql @@ -34,9 +34,10 @@ type Policy @entity { id: ID! token: Token! @derivedFrom(field: "policy") address: Bytes! - rebaseFunctionLowerPercentage: BigDecimal - rebaseFunctionUpperPercentage: BigDecimal - rebaseFunctionGrowth: BigDecimal + rebaseFunctionNegativePercentageLimit: BigDecimal + rebaseFunctionPositivePercentageLimit: BigDecimal + rebaseFunctionPositiveGrowth: BigDecimal + rebaseFunctionNegativeGrowth: BigDecimal rebaseLag: BigInt! deviationThreshold: BigDecimal! minRebaseTimeIntervalSec: BigInt! diff --git a/subgraph/scripts/deploy.sh b/subgraph/scripts/deploy.sh index 3c5399a..696b785 100755 --- a/subgraph/scripts/deploy.sh +++ b/subgraph/scripts/deploy.sh @@ -10,4 +10,5 @@ yarn build yarn graph deploy $2 \ --node https://subgraphs.alchemy.com/api/subgraphs/deploy \ --deploy-key $GRAPH_AUTH \ - --ipfs https://ipfs.satsuma.xyz \ No newline at end of file + --ipfs https://ipfs.satsuma.xyz + \ No newline at end of file diff --git a/subgraph/src/fetch/policy.ts b/subgraph/src/fetch/policy.ts index a04f792..accfa01 100644 --- a/subgraph/src/fetch/policy.ts +++ b/subgraph/src/fetch/policy.ts @@ -10,23 +10,29 @@ let INITIAL_RATE = constants.BIGDECIMAL_ONE export function refreshPolicy(policy: Policy): void { let policyAddress = Address.fromString(policy.id) let policyContract = PolicyABI.bind(policyAddress) - let lower = policyContract.try_rebaseFunctionLowerPercentage() + let lower = policyContract.try_rebaseFunctionNegativePercentageLimit() if (lower.reverted) { - log.info('rebaseFunctionLowerPercentage reverted', []) + log.info('rebaseFunctionNegativePercentageLimit reverted', []) } else { - policy.rebaseFunctionLowerPercentage = formatEther(lower.value) + policy.rebaseFunctionNegativePercentageLimit = formatEther(lower.value) } - let upper = policyContract.try_rebaseFunctionUpperPercentage() + let upper = policyContract.try_rebaseFunctionPositivePercentageLimit() if (upper.reverted) { - log.info('rebaseFunctionUpperPercentage reverted', []) + log.info('rebaseFunctionPositivePercentageLimit reverted', []) } else { - policy.rebaseFunctionUpperPercentage = formatEther(upper.value) + policy.rebaseFunctionPositivePercentageLimit = formatEther(upper.value) } - let growth = policyContract.try_rebaseFunctionGrowth() - if (growth.reverted) { - log.info('rebaseFunctionGrowth reverted', []) + let growthLower = policyContract.try_rebaseFunctionNegativeGrowth() + if (growthLower.reverted) { + log.info('rebaseFunctionNegativeGrowth reverted', []) } else { - policy.rebaseFunctionGrowth = formatEther(growth.value) + policy.rebaseFunctionNegativeGrowth = formatEther(growthLower.value) + } + let growthUpper = policyContract.try_rebaseFunctionPositiveGrowth() + if (growthUpper.reverted) { + log.info('rebaseFunctionPositiveGrowth reverted', []) + } else { + policy.rebaseFunctionPositiveGrowth = formatEther(growthUpper.value) } policy.rebaseLag = policyContract.rebaseLag() policy.deviationThreshold = formatEther(policyContract.deviationThreshold())